@rulemetric/cli 0.12.3 → 0.12.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ import{a as f,c as h}from"./chunk-QUOH6GWM.js";import{e as g,f as d}from"./chunk-2AVGUZ2P.js";import{a as u}from"./chunk-ZLLER3HP.js";import{execFileSync as y}from"node:child_process";import{openSync as R,readSync as v,closeSync as S}from"node:fs";function w(a){let t;try{t=R(a,"r");let i=Buffer.alloc(64*1024),o=v(t,i,0,i.length,0),r=i.subarray(0,o).toString("utf-8");for(let e of r.split(`
2
+ `))if(e.startsWith("{"))try{let s=JSON.parse(e).cwd;if(typeof s=="string"&&s.startsWith("/"))return s}catch{}return null}catch{return null}finally{t!==void 0&&S(t)}}u(w,"readTranscriptCwd");function A(a){let t=u(e=>{try{return y("git",["-C",a,...e],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],timeout:5e3}).trim()||null}catch{return null}},"git");if(!t(["rev-parse","--show-toplevel"]))return null;let o=t(["rev-parse","--git-dir"]),r=t(["rev-parse","--git-common-dir"]);return{gitRemote:t(["remote","get-url","origin"]),gitRootCommit:t(["rev-list","--max-parents=0","HEAD"])?.split(`
3
+ `).pop()?.trim()??null,gitBranch:t(["branch","--show-current"]),isWorktree:!!o&&!!r&&o!==r}}u(A,"gitAnchors");async function j(a,t,i=f(A,w)){let o=Math.min(a.limit??200,1e3),r=await g(`/api/sessions/unattributed?limit=${o}`),e=r.sessions??[],s=r.total??e.length;if(e.length===0)return t.logger.info("no unattributed sessions"),{scanned:0,repaired:0,unrepairable:0,remaining:0};let m=0,c=0;for(let l of e){if(!l.externalSessionId){c++;continue}let n=h(l,i);if(!n){c++;continue}try{await d("/api/sessions",{tool:l.tool,externalSessionId:l.externalSessionId,projectPath:n.projectPath,...n.gitBranch?{gitBranch:n.gitBranch}:{},metadata:{...n.gitRemote?{gitRemote:n.gitRemote}:{},...n.gitRootCommit?{gitRootCommit:n.gitRootCommit}:{},isWorktree:n.isWorktree,reconciledAttribution:!0}}),m++}catch(b){c++,t.logger.info(`reconcile failed for ${l.externalSessionId}: ${b.message}`)}}let p=s-m;return t.logger.info(`reconciled attribution: scanned=${e.length} repaired=${m} unrepairable=${c} remaining=${p} (of ${s} total)`),{scanned:e.length,repaired:m,unrepairable:c,remaining:p}}u(j,"cronReconcileAttribution");export{j as a};
@@ -1 +1 @@
1
- import{b as u,c as d}from"./chunk-ASQG7BTP.js";import{b as g}from"./chunk-KJRMGTAO.js";import{e as m,f as p,h as l}from"./chunk-2AVGUZ2P.js";import{a as s}from"./chunk-ZLLER3HP.js";async function x(f,R){let r=s(e=>R?.logger?.info?.(e)??console.log(e),"log"),{evalTargetId:n}=f,i=`[cron_refine_cases] ${n}`,t=await m(`/api/eval-targets/${n}`);if(!(t.metadata?.autoRefineCases===!0))return r(`${i} not opted in (metadata.autoRefineCases)`),{skipped:"not-opted-in",reason:`"${t.name}" has not opted into automatic case refinement. Set metadata.autoRefineCases=true to let the loop cull cases that carry no treatment signal, or run \`rulemetric evals refine-cases ${n}\` by hand.`,targetName:t.name};let C=await m(`/api/eval-targets/${n}/judge-calibration`),a=u(C.caseDiscrimination);if(a.refused)return r(`${i} ${a.refused}: ${a.summary}`),{skipped:a.refused,reason:a.summary,targetName:t.name};r(`${i} ${a.summary}`);let o=await d(a,{generate:s(e=>g({content:t.content,name:t.name,feedback:e}),"generate"),createCase:s(e=>p(`/api/eval-targets/${n}/evals`,{name:e.name,prompt:e.prompt,expectations:e.expectations}),"createCase"),retireCase:s(async(e,y)=>{await l(`/api/eval-targets/${n}/evals/${e}`,{retire:!0,retiredReason:y})},"retireCase"),log:r});r(`${i} ${o.summary}`);let{skipped:c,...$}=o;return{...$,targetName:t.name,...c?{skipped:c,reason:o.summary}:{}}}s(x,"cronRefineCases");export{x as a};
1
+ import{b as u,c as d}from"./chunk-LZJXW3B6.js";import{b as g}from"./chunk-KJRMGTAO.js";import{e as m,f as p,h as l}from"./chunk-2AVGUZ2P.js";import{a as s}from"./chunk-ZLLER3HP.js";async function x(f,R){let r=s(e=>R?.logger?.info?.(e)??console.log(e),"log"),{evalTargetId:n}=f,i=`[cron_refine_cases] ${n}`,t=await m(`/api/eval-targets/${n}`);if(!(t.metadata?.autoRefineCases===!0))return r(`${i} not opted in (metadata.autoRefineCases)`),{skipped:"not-opted-in",reason:`"${t.name}" has not opted into automatic case refinement. Set metadata.autoRefineCases=true to let the loop cull cases that carry no treatment signal, or run \`rulemetric evals refine-cases ${n}\` by hand.`,targetName:t.name};let C=await m(`/api/eval-targets/${n}/judge-calibration`),a=u(C.caseDiscrimination);if(a.refused)return r(`${i} ${a.refused}: ${a.summary}`),{skipped:a.refused,reason:a.summary,targetName:t.name};r(`${i} ${a.summary}`);let o=await d(a,{generate:s(e=>g({content:t.content,name:t.name,feedback:e}),"generate"),createCase:s(e=>p(`/api/eval-targets/${n}/evals`,{name:e.name,prompt:e.prompt,expectations:e.expectations}),"createCase"),retireCase:s(async(e,y)=>{await l(`/api/eval-targets/${n}/evals/${e}`,{retire:!0,retiredReason:y})},"retireCase"),log:r});r(`${i} ${o.summary}`);let{skipped:c,...$}=o;return{...$,targetName:t.name,...c?{skipped:c,reason:o.summary}:{}}}s(x,"cronRefineCases");export{x as a};
@@ -0,0 +1 @@
1
+ var e=[{name:"cron_check_changelog",description:"Parse CHANGELOG.md and create draft announcement rows for new versions.",scheduledBy:"manual only \u2014 announcement drafts are reminder-driven, never scheduled"},{name:"cron_suggest_instructions",description:"Precompute per-project instruction suggestions for the SessionStart hook.",scheduledBy:"Supabase pg_cron daily 04:30 UTC \u2192 agent_jobs \u2192 agent loop (migration 00083)"},{name:"cron_reconcile_attribution",description:"Re-attribute captured sessions that never resolved to a project (project_id NULL), using git anchors read from the checkouts on this machine.",scheduledBy:"Supabase pg_cron hourly :20 \u2192 agent_jobs \u2192 agent loop (migration 00206)"},{name:"cron_refresh_skills",description:"Refresh the skills registry from GitHub sources (disk JSON + public instructions sync). Requires GITHUB_TOKEN.",scheduledBy:"Supabase pg_cron daily 03:30 UTC \u2192 agent_jobs \u2192 agent loop (migration 00086)"}];export{e as a};
@@ -0,0 +1 @@
1
+ import{c as G}from"./chunk-FNMJ6E6F.js";import{b as q}from"./chunk-IEQDLURA.js";import{a as M}from"./chunk-LYP3LNFL.js";import{a as L}from"./chunk-Y6TAPCA5.js";import{a as B}from"./chunk-PMW35N32.js";import{b as N}from"./chunk-ZQJWKIJS.js";import{a as V}from"./chunk-LDQ6FLET.js";import{a as W}from"./chunk-J35L3LR3.js";import{a as x}from"./chunk-ZYGBABMZ.js";import{b as T}from"./chunk-5RBLIVBF.js";import{a as C}from"./chunk-2MZFB46B.js";import{a as U}from"./chunk-5C3DRKW3.js";import{a as O}from"./chunk-CRPOQMQ2.js";import{a as A}from"./chunk-PZS55PW2.js";import{a as K}from"./chunk-YRTG6SX6.js";import{e as S}from"./chunk-NMWP3JLW.js";import{b as D}from"./chunk-2IEYDOFE.js";import{a as P}from"./chunk-FIPW2SGV.js";import{a as F}from"./chunk-5BTNALJL.js";import{a as $}from"./chunk-4XLMX642.js";import{a as J}from"./chunk-RK2LZIBA.js";import{a as y}from"./chunk-2K3RUBKC.js";import{l as R}from"./chunk-TZUTX4PG.js";import{d as H}from"./chunk-NF2BIEAF.js";import{b as E,e as I,f as _}from"./chunk-2AVGUZ2P.js";import{a}from"./chunk-ZLLER3HP.js";var j={process_eval:M,process_insights:L,process_launch:N,process_send_message:x,process_conversation:P,process_session_goal:C,distill_memories:D,memory_ab:V,process_run_cleanup:W,cron_refine_cases:U,cron_retire_unused_skills:K,cron_reconcile_attribution:y,cron_suggest_instructions:S,cron_refresh_skills:A,cron_refresh_pricing:O,cron_eval_autorun:$,cron_auto_accept_suggestions:F,cron_instruction_training:J,cron_instruction_evolution:R,process_judge_review:B},Q=Object.keys(j),ne=new Set([]);function re(e=process.env){return e.DATABASE_URL?Q:Q.filter(n=>!ne.has(n))}a(re,"availableCapabilities");var te=3e4,oe=3e4,se=3e4,X=500,Y=1e4,ae=`thin-agent-${process.pid}`,b=null;function ie(e,n,r,c){let i;try{let u=H();i={claude:u.claudeBin!=null,codex:u.codexBin!=null,codexModel:u.codexConfiguredModel}}catch{}let m=a(u=>{_("/api/workers/heartbeat",{workerType:"cli-worker",clientName:ae,clientVersion:c,workerVersion:"0.1.0",currentJobId:null,inFlightCount:0,lastError:null,status:u,metadata:{capabilities:e,mode:"thin-agent",llmEngines:i}}).then(d=>{let l=d?.advisory;l&&l.message!==b?(b=l.message,s(r,{event:"worker_advisory",code:l.code,message:l.message})):l||(b=null)}).catch(d=>{s(r,{event:"presence_heartbeat_error",error:d instanceof Error?d.message:String(d)})})},"send");m("alive");let o=setInterval(()=>m("alive"),se);n.addEventListener("abort",()=>{clearInterval(o),m("shutting_down")},{once:!0})}a(ie,"startPresenceHeartbeat");function s(e,n){try{e(JSON.stringify({ts:new Date().toISOString(),...n}))}catch{e(`[agent-loop] log_error event=${n.event}`)}}a(s,"structuredLog");function z(e,n){return n.aborted?Promise.resolve(!1):e<=0?Promise.resolve(!0):new Promise(r=>{let c=setTimeout(()=>{n.removeEventListener("abort",i),r(!0)},e),i=a(()=>{clearTimeout(c),n.removeEventListener("abort",i),r(!1)},"onAbort");n.addEventListener("abort",i,{once:!0})})}a(z,"abortableSleep");async function le(e,n){let r=`capabilities=${encodeURIComponent(e.join(","))}&waitMs=${n}`,c=await I(`/api/work/next?${r}`);return c==null||typeof c=="string"?null:c}a(le,"pollForWork");function ce(e,n){return{logger:{info:a(r=>n(r),"info"),warn:a(r=>n(r),"warn"),error:a(r=>n(r),"error")},job:{attempts:e}}}a(ce,"makeHelpers");async function de(e,n,r){let c=j[e.kind],i=Date.now();if(s(r,{event:"claim",jobId:e.id,kind:e.kind,attempts:e.attempts}),!c){let o=`unknown kind: ${e.kind}`;s(r,{event:"fail",jobId:e.id,kind:e.kind,terminal:!0,error:o}),await _(`/api/work/${e.id}/fail`,{leaseToken:e.leaseToken,error:o,terminal:!0}).catch(()=>{});return}let m=setInterval(()=>{s(r,{event:"heartbeat",jobId:e.id}),_(`/api/work/${e.id}/heartbeat`,{leaseToken:e.leaseToken}).catch(o=>{s(r,{event:"heartbeat_error",jobId:e.id,error:o instanceof Error?o.message:String(o)})})},n);try{let o=ce(e.attempts,r),u=await c(e.payload,o)??{};clearInterval(m),s(r,{event:"complete",jobId:e.id,kind:e.kind,durationMs:Date.now()-i}),await _(`/api/work/${e.id}/complete`,{leaseToken:e.leaseToken,result:u})}catch(o){clearInterval(m);let u=T(o),d=o instanceof Error?o.message:String(o);s(r,{event:"fail",jobId:e.id,kind:e.kind,durationMs:Date.now()-i,terminal:u,error:d}),await _(`/api/work/${e.id}/fail`,{leaseToken:e.leaseToken,error:d,terminal:u}).catch(l=>{s(r,{event:"fail_post_error",jobId:e.id,error:l instanceof Error?l.message:String(l)})})}}a(de,"runOne");var Z=new Set(["process_eval","process_conversation","process_insights","process_session_goal","distill_memories","memory_ab","cron_suggest_instructions","cron_eval_autorun","cron_instruction_evolution","process_judge_review"]);async function Ve(e){let n=e.log??(()=>{}),r=e.pollWaitMs??te,c=e.heartbeatIntervalMs??oe,i=e.capabilities??re();s(n,{event:"agent_start",capabilities:i,pollWaitMs:r,heartbeatIntervalMs:c});try{let t=q();t.removed.length>0&&s(n,{event:"eval_worktrees_swept",removed:t.removed.length})}catch(t){s(n,{event:"eval_worktree_sweep_failed",error:t instanceof Error?t.message:String(t)})}ie(i,e.signal,n,e.version),G({signal:e.signal,log:n}).catch(t=>{s(n,{event:"tt_heartbeat_fatal",error:t instanceof Error?t.message:String(t)})});let m=5*6e4,o=0,u=a(()=>{if(!e.readInstalledVersion||!e.version)return!1;let t=Date.now();if(t-o<m)return!1;o=t;let f=e.readInstalledVersion();return!!(f&&f!==e.version)},"versionDrifted"),d=new AbortController,l=d.signal;e.signal.aborted?d.abort():e.signal.addEventListener("abort",()=>d.abort(),{once:!0});let v=a(async(t,f)=>{let g=X;for(;!l.aborted;){if(u()){s(n,{event:"agent_version_drift",bootVersion:e.version,installedVersion:e.readInstalledVersion?.()??null}),d.abort(),e.onVersionDrift?.();break}let h=null;try{h=await le([...f],r)}catch(p){let ee=p instanceof E?p.statusCode:void 0;if(s(n,{event:"poll_error",lane:t,status:ee,error:p instanceof Error?p.message:String(p)}),!await z(g,l))break;g=Math.min(g*2,Y);continue}if(!h){if(s(n,{event:"poll_204",lane:t}),!await z(g,l))break;g=Math.min(g*2,Y);continue}g=X,await de(h,c,n)}},"runLane"),k=i.filter(t=>Z.has(t)),w=i.filter(t=>!Z.has(t));k.length>0&&w.length>0?(s(n,{event:"agent_lanes",heavy:k.length,fast:w.length}),await Promise.all([v("heavy",k),v("fast",w)])):await v("single",i),s(n,{event:"agent_stop"})}a(Ve,"runAgentLoop");export{j as a,Q as b,re as c,le as d,Ve as e};
@@ -1 +1 @@
1
- import{b as t,e as E}from"./chunk-IS2AZIG7.js";import{a as r}from"./chunk-ZLLER3HP.js";function s(o=10,_=t){for(let e=1;e<=o;e++)if(E(e,o,_).feasible)return e;return o}r(s,"minFeasibleLiveCases");var S=s(),A=3;export{s as a,S as b,A as c};
1
+ import{b as t,e as E}from"./chunk-TZUTX4PG.js";import{a as r}from"./chunk-ZLLER3HP.js";function s(o=10,_=t){for(let e=1;e<=o;e++)if(E(e,o,_).feasible)return e;return o}r(s,"minFeasibleLiveCases");var S=s(),A=3;export{s as a,S as b,A as c};
@@ -1 +1 @@
1
- import{b as m}from"./chunk-4Y54EMS6.js";import{a as g}from"./chunk-ZLLER3HP.js";var p=5;function b(t){let r=g((e,f)=>({retire:[],survivingCases:0,replacementsRequired:!1,refused:e,summary:f}),"none");if(!t||t.cases.length===0&&t.unpairedCases.length===0)return r("no-discrimination-data","No case-discrimination data yet \u2014 the target needs runs in BOTH cohorts before any case can be judged dead.");let c=[...t.cases.filter(e=>!e.discriminating).map(e=>({evalId:e.evalId,name:e.name,feedback:{name:e.name,withPassRate:e.withPassRate,withoutPassRate:e.withoutPassRate,reason:e.note}})),...t.unpairedCases.map(e=>({evalId:e.evalId,name:e.name,feedback:{name:e.name,withPassRate:e.withPassRate??0,withoutPassRate:e.withoutPassRate,reason:"runs in only one cohort (no with-vs-without comparison possible)"}}))];if(c.length===0)return r("all-discriminating","Every case discriminates \u2014 nothing to retire.");let s=new Map(t.cases.map(e=>[e.evalId,e.separation])),o=[...c].sort((e,f)=>(s.get(e.evalId)??-1)-(s.get(f.evalId)??-1)).slice(0,p),u=c.length-o.length,d=t.total+t.unpaired,l=d-o.length,i=l<m,n=`${o.length} of ${d} live case(s) carry no treatment signal`+(u>0?` (${u} more over the ${p}-per-run cap)`:"")+(i?`; retiring them leaves ${l}, below the ${m}-case evolution floor, so replacements must be generated first`:"");return{retire:o,survivingCases:l,replacementsRequired:i,refused:null,summary:n}}g(b,"planCaseRefinement");async function v(t,r){let h=r.log??(()=>{}),c=g((n,e)=>({retired:0,generated:0,skipped:n,summary:e,retiredNames:[],generatedNames:[]}),"empty");if(t.refused)return c(t.refused,t.summary);let s=await r.generate(t.retire.map(n=>n.feedback)),a=[];for(let n of s??[]){let e=await r.createCase(n);a.push(e.name),h(` + ${e.name} (${e.id})`)}let o=t.survivingCases+t.retire.length+a.length,u=Math.max(0,o-m),d=t.retire.slice(0,Math.min(t.retire.length,u)),l=t.retire.length-d.length;if(d.length===0)return{retired:0,generated:a.length,skipped:s===null?"no-llm-backend":"no-replacements-generated",summary:`${t.summary}. `+(s===null?"No local LLM backend available, so nothing was retired":`The generator produced ${a.length} usable replacement(s), not enough to retire anything`)+` \u2014 dropping below the ${m}-case floor would silently disenrol the target from the nightly loop.`,retiredNames:[],generatedNames:a};let i=[];for(let n of d)await r.retireCase(n.evalId,n.feedback.reason),i.push(n.name),h(` retired ${n.name}`);return{retired:i.length,generated:a.length,skipped:null,summary:`Retired ${i.length} non-discriminating case(s), added ${a.length} replacement(s)`+(l>0?`; held ${l} back to stay at the ${m}-case floor (they remain condemned and will be retired once replacements exist)`:"")+". The replacements have no runs yet \u2014 the next autorun batch builds their depth.",retiredNames:i,generatedNames:a}}g(v,"executeCaseRefinement");export{p as a,b,v as c};
1
+ import{b as m}from"./chunk-KHCMVYTH.js";import{a as g}from"./chunk-ZLLER3HP.js";var p=5;function b(t){let r=g((e,f)=>({retire:[],survivingCases:0,replacementsRequired:!1,refused:e,summary:f}),"none");if(!t||t.cases.length===0&&t.unpairedCases.length===0)return r("no-discrimination-data","No case-discrimination data yet \u2014 the target needs runs in BOTH cohorts before any case can be judged dead.");let c=[...t.cases.filter(e=>!e.discriminating).map(e=>({evalId:e.evalId,name:e.name,feedback:{name:e.name,withPassRate:e.withPassRate,withoutPassRate:e.withoutPassRate,reason:e.note}})),...t.unpairedCases.map(e=>({evalId:e.evalId,name:e.name,feedback:{name:e.name,withPassRate:e.withPassRate??0,withoutPassRate:e.withoutPassRate,reason:"runs in only one cohort (no with-vs-without comparison possible)"}}))];if(c.length===0)return r("all-discriminating","Every case discriminates \u2014 nothing to retire.");let s=new Map(t.cases.map(e=>[e.evalId,e.separation])),o=[...c].sort((e,f)=>(s.get(e.evalId)??-1)-(s.get(f.evalId)??-1)).slice(0,p),u=c.length-o.length,d=t.total+t.unpaired,l=d-o.length,i=l<m,n=`${o.length} of ${d} live case(s) carry no treatment signal`+(u>0?` (${u} more over the ${p}-per-run cap)`:"")+(i?`; retiring them leaves ${l}, below the ${m}-case evolution floor, so replacements must be generated first`:"");return{retire:o,survivingCases:l,replacementsRequired:i,refused:null,summary:n}}g(b,"planCaseRefinement");async function v(t,r){let h=r.log??(()=>{}),c=g((n,e)=>({retired:0,generated:0,skipped:n,summary:e,retiredNames:[],generatedNames:[]}),"empty");if(t.refused)return c(t.refused,t.summary);let s=await r.generate(t.retire.map(n=>n.feedback)),a=[];for(let n of s??[]){let e=await r.createCase(n);a.push(e.name),h(` + ${e.name} (${e.id})`)}let o=t.survivingCases+t.retire.length+a.length,u=Math.max(0,o-m),d=t.retire.slice(0,Math.min(t.retire.length,u)),l=t.retire.length-d.length;if(d.length===0)return{retired:0,generated:a.length,skipped:s===null?"no-llm-backend":"no-replacements-generated",summary:`${t.summary}. `+(s===null?"No local LLM backend available, so nothing was retired":`The generator produced ${a.length} usable replacement(s), not enough to retire anything`)+` \u2014 dropping below the ${m}-case floor would silently disenrol the target from the nightly loop.`,retiredNames:[],generatedNames:a};let i=[];for(let n of d)await r.retireCase(n.evalId,n.feedback.reason),i.push(n.name),h(` retired ${n.name}`);return{retired:i.length,generated:a.length,skipped:null,summary:`Retired ${i.length} non-discriminating case(s), added ${a.length} replacement(s)`+(l>0?`; held ${l} back to stay at the ${m}-case floor (they remain condemned and will be retired once replacements exist)`:"")+". The replacements have no runs yet \u2014 the next autorun batch builds their depth.",retiredNames:i,generatedNames:a}}g(v,"executeCaseRefinement");export{p as a,b,v as c};
@@ -0,0 +1 @@
1
+ import{a as o}from"./chunk-ZLLER3HP.js";import{existsSync as c,readdirSync as a}from"node:fs";import{homedir as u}from"node:os";import{join as l}from"node:path";var d=o(r=>/^\/(Users|home)\/[^/]+\/?$/.test(r),"isHomeDir"),g=o(r=>/^\/(private\/)?(tmp|var\/folders)/.test(r),"isThrowaway");function x(r,e){return{exists:o(n=>c(n),"exists"),listDirs:o(n=>{try{return a(n,{withFileTypes:!0}).filter(t=>t.isDirectory()).map(t=>t.name)}catch{return[]}},"listDirs"),readTranscriptCwd:e,gitAnchors:r,home:u()}}o(x,"defaultRecoveryEnv");function p(r,e){let n=l(e.home,".claude","projects");if(!e.exists(n))return null;for(let t of e.listDirs(n)){let i=l(n,t,`${r}.jsonl`);if(!e.exists(i))continue;let s=e.readTranscriptCwd(i);return s||null}return null}o(p,"findClaudeCodeCwd");function v(r,e){let n=o(s=>s&&!d(s)&&!g(s)?s:null,"usable"),t=n(r.projectPath);if(!t&&r.tool==="claude_code"&&r.externalSessionId&&(t=n(p(r.externalSessionId,e))),!t||!e.exists(t))return null;let i=e.gitAnchors(t);return!i||!i.gitRemote&&!i.gitRootCommit?null:{projectPath:t,...i}}o(v,"recoverAnchors");export{x as a,p as b,v as c};
@@ -1 +1 @@
1
- import{a as Re}from"./chunk-M7QSC64D.js";import{i as Ae}from"./chunk-DPCAPIQB.js";import{b as ce,i as ue,j as pe,k as de,l as ge,m as me,n as fe}from"./chunk-LB24UKHZ.js";import{c as we}from"./chunk-G7V4ZZZ3.js";import{a as Pe,b as ye,c as ve,d as ke,e as ee,f as Ce}from"./chunk-T67L2YTW.js";import{d as he,e as be,g as $e}from"./chunk-SD626JBZ.js";import{d as se,e as Z,f as le}from"./chunk-VBXL7XO7.js";import{e as P,f as K}from"./chunk-2AVGUZ2P.js";import{a as u}from"./chunk-ZLLER3HP.js";import{createHash as We}from"node:crypto";import{existsSync as Ee,readFileSync as Se,writeFileSync as Ne}from"node:fs";var W=u(a=>We("sha256").update(a).digest("hex"),"sha256"),Ie=1.3,te=4,Le=20;function Fe(a,i){if(!a.configured||i<=0)return te;let t=Math.ceil(a.minPairs*Ie/i);return Math.min(Le,Math.max(te,t))}u(Fe,"passCapFor");function je(a,i=10,t=te){if(a<=0)return{passes:0,expectedPairs:0,feasible:!1,reason:"no live cases"};let l=Math.ceil(i*Ie),e=Math.min(t,Math.ceil(l/a)),r=e*a;return r<i?{passes:e,expectedPairs:r,feasible:!1,reason:`${a} live case(s) x ${t} passes = ${a*t} pairs at best, below the ${i} a controlled verdict requires \u2014 add cases rather than replaying these`}:{passes:e,expectedPairs:r,feasible:!0}}u(je,"planPasses");var Ue=60,qe=u(a=>typeof a=="object"&&a!==null&&typeof a.withScore=="number"&&typeof a.withoutScore=="number","isPair");function Ge(a,i,t){let l=[...a].sort((e,r)=>Date.parse(r.createdAt)-Date.parse(e.createdAt));for(let e of l){if(e.applied)continue;let r=e.gates?.accumulation;if(!r||typeof r!="object"||r.priorContentHash!==i||r.targetPairs!==t||typeof r.candidateContentHash!="string"||!Array.isArray(r.pairs))continue;let o=r.pairs.filter(qe);if(o.length===r.pairs.length&&!(o.length>=t))return{promotionId:e.id,candidateContentHash:r.candidateContentHash,pairs:o,runs:typeof r.runs=="number"?r.runs:1}}return null}u(Ge,"findOpenAccumulation");var Be=5,xe=u(a=>Array.isArray(a)?a.filter(i=>typeof i=="string"):[],"stringList"),j=u(a=>typeof a=="number"&&Number.isFinite(a)?a:null,"finite");function Xe(a,i,t=Be){let l=[...a].filter(o=>o.fromContentHash===i).sort((o,g)=>Date.parse(g.createdAt)-Date.parse(o.createdAt)),e=[],r=new Set;for(let o of l){let g=o.toContentHash??o.id;if(r.has(g))continue;r.add(g);let y=o.verdict??null,S=j(y?.delta),x=j(y?.ci?.lower),H=j(y?.ci?.upper),C=j(y?.nWith),ne=y?.sufficient===!0&&S!=null&&x!=null&&H!=null&&C!=null?{delta:S,ciLower:x,ciUpper:H,nPairs:C}:null;if(e.push({decision:typeof o.decision=="string"?o.decision:"unknown",applied:o.applied===!0,at:typeof o.createdAt=="string"?o.createdAt:"",rationale:typeof o.proposalRationale=="string"?o.proposalRationale:"",touched:xe(o.touchedSections),refusals:xe(o.refusals),measured:ne}),e.length>=t)break}return e}u(Xe,"summarisePriorDecisions");function ze(a,i){let t=i.accumulate??(a.autoEvolveAccumulate===!0||a.autoEvolveAccumulate==="true"),l=i.accumulateTargetPairs??a.autoEvolveAccumulateTarget,e=typeof l=="string"?Number.parseInt(l,10):l,r=typeof e=="number"&&Number.isInteger(e)&&e>0?e:Ue;return{enabled:t,targetPairs:r}}u(ze,"readAccumulateConfig");function Qe(a){let i=a.accumulateEnabled&&a.pairCount<a.targetPairs;return{apply:a.consented&&!i,peeking:i}}u(Qe,"resolveApply");async function it(a,i){let t=u(n=>i?.logger?.info?.(n)??console.log(n),"log"),{evalTargetId:l}=a,e=`[cron_instruction_evolution] ${l}`,r=await P(`/api/eval-targets/${l}`),o=r.metadata??{},g=null,y=!1;if(r.name.startsWith("/")&&Ee(r.name))try{if(g=Se(r.name,"utf8"),g!==r.content){let n=await K(`/api/eval-targets/${l}/sync-content`,{content:g});y=n.synced,t(`${e}: target content drifted from disk by ${Math.abs(g.length-r.content.length)} chars \u2014 synced to disk truth (v${n.version}). Prior verdicts against the old text dissolve via content-hash keying.`),r={...r,content:g,version:n.version}}}catch(n){t(`${e}: disk sync failed (${n instanceof Error?n.message:String(n)}) \u2014 measuring the stored snapshot`)}let S=!1;try{S=(await P("/api/settings/evolution-account")).paused}catch(n){t(`${e}: could not read the account switch (${n instanceof Error?n.message:String(n)}) \u2014 pausing to be safe`),S=!0}if(S)return t(`${e}: PAUSED for the whole account (profiles.evolution_paused) \u2014 no model budget spent.`),{skipped:"paused-account"};if(pe(o))return t(`${e}: PAUSED (metadata.autoEvolvePaused) \u2014 no model budget spent. Opt-in is intact.`),{skipped:"paused"};let x=Re(r);if(x)return t(`${e}: ${x.reason}`),x;let H=a.apply??(o.autoEvolveApply===!0||o.autoEvolveApply==="true"),C=Ve(o);if(C==null){if(H)return t(`${e}: refusing \u2014 metadata.immutableSections is unset. Set it (use [] to explicitly protect nothing) before letting the loop edit this target unattended.`),{skipped:"immutable-sections-unset"};t(`${e}: metadata.immutableSections unset \u2014 measure-only cycle proceeds with [] (nothing protected). Writing still requires setting it explicitly.`),C=[]}let $=(await P(`/api/eval-targets/${l}/evals`)).filter(n=>!n.retiredAt);if($.length===0)return{skipped:"no-live-cases"};let N=ue(o);N.note&&t(`${e}: ${N.note}`);let v=je($.length,N.minPairs,Fe(N,$.length));if(!v.feasible)return t(`${e}: cannot reach a sufficient verdict \u2014 ${v.reason}`),{skipped:"cannot-reach-min-n",reason:v.reason};let He=de({liveCases:$.length,passes:v.passes});t(`${e}: budget for this run \u2014 ${fe(He)}`);let U=await P(`/api/eval-targets/${l}/judge-calibration`);if(!U.powerCheck.adequate){let n=(U.powerCheck.reasons??[]).join("; ");return t(`${e}: not adequately powered, skipping before spending budget \u2014 ${n}`),{skipped:"not-adequate",reason:n}}let re=le,_e=Date.now()-re*24*60*60*1e3,q=await P(`/api/eval-targets/${l}/promotions?limit=200`),ae=q.promotions.filter(n=>n.applied&&Date.parse(n.createdAt)>=_e).length;if(ae>=Z)return t(`${e}: change budget looks exhausted (${ae}/${Z} applied in ${re}d), skipping before spending budget`),{skipped:"budget-exhausted"};try{let n=await P("/api/usage/current-limits"),c=we({limits:n,now:new Date});if(!c.ok)return t(`${e}: deferring before spending budget \u2014 ${c.reason}`),{skipped:"quota-exhausted",reason:c.reason}}catch(n){t(`${e}: quota unknown (${n instanceof Error?n.message:String(n)}) \u2014 proceeding`)}let L=se();if(!L.green)return t(`${e}: A/A canary is RED \u2014 halting. ${L.failures.join(" | ")}`),{skipped:"canary-red",reason:L.failures.join(" | ")};let G=r.content,D=W(G),p=ze(o,a),k=p.enabled?Ge(q.promotions,D,p.targetPairs):null,m,F,w=[],_=0,B=ce,f=k?null:ye(o,D);if(f){m=f.content,F="",B=0;try{w=await ke({evalTargetId:l,candidateContentHash:f.hash})}catch(n){return t(`${e}: could not rebuild banked pairs (${n instanceof Error?n.message:String(n)})`),{skipped:"resume-read-failed",reason:f.hash}}t(`${e}: resuming interrupted cycle \u2014 ${w.length}/${f.plannedPairs} pair(s) rebuilt from eval_runs, no proposal call spent`)}else if(k){let n=await P(`/api/promotions/${k.promotionId}`);if(W(n.toContent)!==k.candidateContentHash)return t(`${e}: stored candidate does not match its recorded hash \u2014 refusing to continue`),{skipped:"accumulation-hash-mismatch",reason:k.promotionId};m=n.toContent,F=n.proposalRationale??"",w=k.pairs,_=k.runs,B=0,t(`${e}: continuing accumulation ${k.promotionId} \u2014 ${w.length}/${p.targetPairs} pair(s) carried from ${_} prior run(s)`)}else{let n=U.caseDiscrimination?.cases??[],c=[];if(r.name.startsWith("/")){let s=r.name.slice(0,r.name.lastIndexOf("/"));try{let b=await P(`/api/insights/evidence?projectPath=${encodeURIComponent(s)}`);b.analyzedAt&&(c=[...b.friction.map(Y=>`Real-session friction (insights, ${b.analyzedAt.slice(0,10)}): ${Y}`),...b.whatWorks.map(Y=>`Working well in real sessions \u2014 do not break: ${Y}`)],c.length>0&&t(`${e}: proposer sees ${b.friction.length} friction + ${b.whatWorks.length} what-works item(s) from insights`))}catch(b){t(`${e}: insights evidence unavailable (${b instanceof Error?b.message:String(b)}) \u2014 proposing without it`)}}let T=[];try{T=Xe(q.promotions,D)}catch(s){t(`${e}: could not summarise prior decisions (${s instanceof Error?s.message:String(s)}) \u2014 proposing without them`)}T.length>0&&t(`${e}: proposer sees ${T.length} prior decision(s) against this exact body (${T.map(s=>`${s.decision}${s.measured?"/measured":""}`).join(", ")})`);let M=await Ae({currentContent:r.content,targetType:r.type,targetName:r.name,immutableSections:C,evidence:{nonDiscriminating:n.filter(s=>!s.discriminating).map(s=>`${s.name??s.assertion??"unnamed"} \u2014 ${s.note}`),weakest:n.filter(s=>s.discriminating&&s.withPassRate<s.withoutPassRate).map(s=>({name:s.name??s.assertion??"unnamed",withPassRate:s.withPassRate,withoutPassRate:s.withoutPassRate})),priorDecisions:T,notes:c}});if(!M.ok)return t(`${e}: no usable proposal \u2014 ${M.reason}`),{skipped:"no-proposal",reason:M.reason};m=M.proposal.candidateContent,F=M.proposal.rationale}let I=f?ve({plannedPairs:f.plannedPairs||v.expectedPairs,carriedPairs:w.length,liveCases:$.length}):v.passes;t(`${e}: measuring ${$.length} case(s) x ${I} pass(es) = up to ${$.length*I} pairs, candidate vs prior version`+(f?` (resumed; ${w.length} pair(s) already banked)`:""));let A=[],X=[],Oe=Date.now(),oe=0,z=0;for(let n=1;n<=I;n++){let c=await $e({cases:$,candidateContent:m,priorVersionContent:G,concurrency:a.concurrency??2,runNumber:n,opts:{targetId:l,targetVersion:r.version??1,iteration:1,timeout:a.timeout??24e4,model:a.model,graderModel:a.graderModel,skipGrading:!1,targetType:r.type,targetName:r.name,candidateContentHash:W(m)},onLog:t});if(A.push(...c.pairs),X.push(...c.results),oe+=c.completed,z+=c.failed,t(`${e}: pass ${n}/${I} \u2014 ${c.pairs.length} pair(s), running total ${A.length}`),c.abortedForQuota){t(`${e}: stopping after pass ${n}/${I} \u2014 ${c.abortedForQuota}. Remaining passes would spend against an exhausted account.`);break}}let R=[...w,...A],O=he(X),Q=A.length>0,d=ge({runs:X,plannedPairs:v.expectedPairs,usablePairs:A.length,verdictPairs:Q?R.length:A.length,proposalCalls:B,passes:I,liveCases:$.length,wallMs:Date.now()-Oe});if(t(`${e}: ${oe} completed, ${z} failed, ${A.length} usable pair(s) \u2014 spent ~${d.modelCalls} model calls (${d.proposalCalls} proposal + ${d.executorCalls} executor + >=${d.graderCalls} grader) in ${(d.wallMs/6e4).toFixed(1)} min`+(Q?`; the ${d.verdictPairs} pair(s) behind this verdict resolve +/-${me(d.mde)} at 80% power`:"")),!Q)return{skipped:O.infrastructureFailed?"infrastructure-failure":"no-pairs",reason:O.infrastructureFailed?`${O.infrastructureFailed} run(s) never executed (${O.summary.describe()}) \u2014 the environment failed, not the target`:`${z} run(s) failed or were ungradeable`,cost:d};let V=be({pairs:R.length,minPairs:10,accounting:O});if(V.kind==="infrastructure-incomplete")return t(`${e}: not posting a verdict \u2014 ${V.reason}`),await ee({evalTargetId:l,meta:o,blob:Ce({content:m,hash:W(m),priorHash:D,plannedPairs:f?.plannedPairs||v.expectedPairs,now:new Date}),log:t,tag:e}),{skipped:"infrastructure-incomplete",reason:V.reason,cost:d};p.enabled&&t(`${e}: accumulated ${R.length}/${p.targetPairs} pair(s) over ${_+1} run(s) on one candidate`);let ie=H,{apply:Te,peeking:Me}=Qe({consented:ie,accumulateEnabled:p.enabled,pairCount:R.length,targetPairs:p.targetPairs});ie&&Me&&t(`${e}: interim readout at ${R.length}/${p.targetPairs} pairs \u2014 recording the decision but not acting until the target is reached`);let h=await K(`/api/eval-targets/${l}/promotions`,{candidateContent:m,proposalSource:"llm",proposalRationale:F,pairs:R,canaryGreen:L.green,measuredAgainstContentHash:D,immutableSections:C,apply:Te,measurementCost:d,...p.enabled?{accumulation:{candidateContentHash:W(m),priorContentHash:D,targetPairs:p.targetPairs,carriedPairs:w.length,runs:_+1}}:{}});t(`${e}: ${h.decision}${h.applied?" (APPLIED)":""} \u2014 ${h.rationale}`+(h.refusals.length>0?` | refusals: ${h.refusals.join("; ")}`:"")),(f||o[Pe])&&await ee({evalTargetId:l,meta:o,blob:null,log:t,tag:e});let J=!1,E;if(h.applied&&r.name.startsWith("/"))try{Ee(r.name)?Se(r.name,"utf8")!==G?E="file changed since measurement started \u2014 refusing to clobber; next cycle re-syncs":(Ne(r.name,m,"utf8"),J=!0):E="file no longer exists on disk",t(J?`${e}: measured improvement written to ${r.name} (undo: git checkout -- ${r.name})`:`${e}: NOT written to disk \u2014 ${E}`)}catch(n){E=n instanceof Error?n.message:String(n),t(`${e}: disk write-back failed \u2014 ${E}. The eval target is updated; the file is not.`)}return{decision:h.decision,applied:h.applied,nPairs:R.length,promotionId:h.id,cost:d,diskSynced:y,...h.applied?{fileWritten:J,...E?{fileWriteSkipped:E}:{}}:{},...p.enabled?{carriedPairs:w.length,accumulationRuns:_+1}:{}}}u(it,"cronInstructionEvolution");function Ve(a){let i=a.immutableSections;return i==null||!Array.isArray(i)?null:i.filter(t=>typeof t=="string")}u(Ve,"readImmutableSections");export{Ie as a,te as b,Le as c,Fe as d,je as e,Ue as f,Ge as g,Be as h,Xe as i,ze as j,Qe as k,it as l,Ve as m};
1
+ import{a as Re}from"./chunk-M7QSC64D.js";import{i as Ae}from"./chunk-DPCAPIQB.js";import{a as Pe,b as ye,c as ve,d as ke,e as ee,f as Ce}from"./chunk-T67L2YTW.js";import{b as ce,i as ue,j as pe,k as de,l as ge,m as me,n as fe}from"./chunk-LB24UKHZ.js";import{c as we}from"./chunk-G7V4ZZZ3.js";import{d as he,e as be,g as $e}from"./chunk-SD626JBZ.js";import{d as se,e as Z,f as le}from"./chunk-VBXL7XO7.js";import{e as P,f as K}from"./chunk-2AVGUZ2P.js";import{a as u}from"./chunk-ZLLER3HP.js";import{createHash as We}from"node:crypto";import{existsSync as Ee,readFileSync as Se,writeFileSync as Ne}from"node:fs";var W=u(a=>We("sha256").update(a).digest("hex"),"sha256"),Ie=1.3,te=4,Le=20;function Fe(a,i){if(!a.configured||i<=0)return te;let t=Math.ceil(a.minPairs*Ie/i);return Math.min(Le,Math.max(te,t))}u(Fe,"passCapFor");function je(a,i=10,t=te){if(a<=0)return{passes:0,expectedPairs:0,feasible:!1,reason:"no live cases"};let l=Math.ceil(i*Ie),e=Math.min(t,Math.ceil(l/a)),r=e*a;return r<i?{passes:e,expectedPairs:r,feasible:!1,reason:`${a} live case(s) x ${t} passes = ${a*t} pairs at best, below the ${i} a controlled verdict requires \u2014 add cases rather than replaying these`}:{passes:e,expectedPairs:r,feasible:!0}}u(je,"planPasses");var Ue=60,qe=u(a=>typeof a=="object"&&a!==null&&typeof a.withScore=="number"&&typeof a.withoutScore=="number","isPair");function Ge(a,i,t){let l=[...a].sort((e,r)=>Date.parse(r.createdAt)-Date.parse(e.createdAt));for(let e of l){if(e.applied)continue;let r=e.gates?.accumulation;if(!r||typeof r!="object"||r.priorContentHash!==i||r.targetPairs!==t||typeof r.candidateContentHash!="string"||!Array.isArray(r.pairs))continue;let o=r.pairs.filter(qe);if(o.length===r.pairs.length&&!(o.length>=t))return{promotionId:e.id,candidateContentHash:r.candidateContentHash,pairs:o,runs:typeof r.runs=="number"?r.runs:1}}return null}u(Ge,"findOpenAccumulation");var Be=5,xe=u(a=>Array.isArray(a)?a.filter(i=>typeof i=="string"):[],"stringList"),j=u(a=>typeof a=="number"&&Number.isFinite(a)?a:null,"finite");function Xe(a,i,t=Be){let l=[...a].filter(o=>o.fromContentHash===i).sort((o,g)=>Date.parse(g.createdAt)-Date.parse(o.createdAt)),e=[],r=new Set;for(let o of l){let g=o.toContentHash??o.id;if(r.has(g))continue;r.add(g);let y=o.verdict??null,S=j(y?.delta),x=j(y?.ci?.lower),H=j(y?.ci?.upper),C=j(y?.nWith),ne=y?.sufficient===!0&&S!=null&&x!=null&&H!=null&&C!=null?{delta:S,ciLower:x,ciUpper:H,nPairs:C}:null;if(e.push({decision:typeof o.decision=="string"?o.decision:"unknown",applied:o.applied===!0,at:typeof o.createdAt=="string"?o.createdAt:"",rationale:typeof o.proposalRationale=="string"?o.proposalRationale:"",touched:xe(o.touchedSections),refusals:xe(o.refusals),measured:ne}),e.length>=t)break}return e}u(Xe,"summarisePriorDecisions");function ze(a,i){let t=i.accumulate??(a.autoEvolveAccumulate===!0||a.autoEvolveAccumulate==="true"),l=i.accumulateTargetPairs??a.autoEvolveAccumulateTarget,e=typeof l=="string"?Number.parseInt(l,10):l,r=typeof e=="number"&&Number.isInteger(e)&&e>0?e:Ue;return{enabled:t,targetPairs:r}}u(ze,"readAccumulateConfig");function Qe(a){let i=a.accumulateEnabled&&a.pairCount<a.targetPairs;return{apply:a.consented&&!i,peeking:i}}u(Qe,"resolveApply");async function it(a,i){let t=u(n=>i?.logger?.info?.(n)??console.log(n),"log"),{evalTargetId:l}=a,e=`[cron_instruction_evolution] ${l}`,r=await P(`/api/eval-targets/${l}`),o=r.metadata??{},g=null,y=!1;if(r.name.startsWith("/")&&Ee(r.name))try{if(g=Se(r.name,"utf8"),g!==r.content){let n=await K(`/api/eval-targets/${l}/sync-content`,{content:g});y=n.synced,t(`${e}: target content drifted from disk by ${Math.abs(g.length-r.content.length)} chars \u2014 synced to disk truth (v${n.version}). Prior verdicts against the old text dissolve via content-hash keying.`),r={...r,content:g,version:n.version}}}catch(n){t(`${e}: disk sync failed (${n instanceof Error?n.message:String(n)}) \u2014 measuring the stored snapshot`)}let S=!1;try{S=(await P("/api/settings/evolution-account")).paused}catch(n){t(`${e}: could not read the account switch (${n instanceof Error?n.message:String(n)}) \u2014 pausing to be safe`),S=!0}if(S)return t(`${e}: PAUSED for the whole account (profiles.evolution_paused) \u2014 no model budget spent.`),{skipped:"paused-account"};if(pe(o))return t(`${e}: PAUSED (metadata.autoEvolvePaused) \u2014 no model budget spent. Opt-in is intact.`),{skipped:"paused"};let x=Re(r);if(x)return t(`${e}: ${x.reason}`),x;let H=a.apply??(o.autoEvolveApply===!0||o.autoEvolveApply==="true"),C=Ve(o);if(C==null){if(H)return t(`${e}: refusing \u2014 metadata.immutableSections is unset. Set it (use [] to explicitly protect nothing) before letting the loop edit this target unattended.`),{skipped:"immutable-sections-unset"};t(`${e}: metadata.immutableSections unset \u2014 measure-only cycle proceeds with [] (nothing protected). Writing still requires setting it explicitly.`),C=[]}let $=(await P(`/api/eval-targets/${l}/evals`)).filter(n=>!n.retiredAt);if($.length===0)return{skipped:"no-live-cases"};let N=ue(o);N.note&&t(`${e}: ${N.note}`);let v=je($.length,N.minPairs,Fe(N,$.length));if(!v.feasible)return t(`${e}: cannot reach a sufficient verdict \u2014 ${v.reason}`),{skipped:"cannot-reach-min-n",reason:v.reason};let He=de({liveCases:$.length,passes:v.passes});t(`${e}: budget for this run \u2014 ${fe(He)}`);let U=await P(`/api/eval-targets/${l}/judge-calibration`);if(!U.powerCheck.adequate){let n=(U.powerCheck.reasons??[]).join("; ");return t(`${e}: not adequately powered, skipping before spending budget \u2014 ${n}`),{skipped:"not-adequate",reason:n}}let re=le,_e=Date.now()-re*24*60*60*1e3,q=await P(`/api/eval-targets/${l}/promotions?limit=200`),ae=q.promotions.filter(n=>n.applied&&Date.parse(n.createdAt)>=_e).length;if(ae>=Z)return t(`${e}: change budget looks exhausted (${ae}/${Z} applied in ${re}d), skipping before spending budget`),{skipped:"budget-exhausted"};try{let n=await P("/api/usage/current-limits"),c=we({limits:n,now:new Date});if(!c.ok)return t(`${e}: deferring before spending budget \u2014 ${c.reason}`),{skipped:"quota-exhausted",reason:c.reason}}catch(n){t(`${e}: quota unknown (${n instanceof Error?n.message:String(n)}) \u2014 proceeding`)}let L=se();if(!L.green)return t(`${e}: A/A canary is RED \u2014 halting. ${L.failures.join(" | ")}`),{skipped:"canary-red",reason:L.failures.join(" | ")};let G=r.content,D=W(G),p=ze(o,a),k=p.enabled?Ge(q.promotions,D,p.targetPairs):null,m,F,w=[],_=0,B=ce,f=k?null:ye(o,D);if(f){m=f.content,F="",B=0;try{w=await ke({evalTargetId:l,candidateContentHash:f.hash})}catch(n){return t(`${e}: could not rebuild banked pairs (${n instanceof Error?n.message:String(n)})`),{skipped:"resume-read-failed",reason:f.hash}}t(`${e}: resuming interrupted cycle \u2014 ${w.length}/${f.plannedPairs} pair(s) rebuilt from eval_runs, no proposal call spent`)}else if(k){let n=await P(`/api/promotions/${k.promotionId}`);if(W(n.toContent)!==k.candidateContentHash)return t(`${e}: stored candidate does not match its recorded hash \u2014 refusing to continue`),{skipped:"accumulation-hash-mismatch",reason:k.promotionId};m=n.toContent,F=n.proposalRationale??"",w=k.pairs,_=k.runs,B=0,t(`${e}: continuing accumulation ${k.promotionId} \u2014 ${w.length}/${p.targetPairs} pair(s) carried from ${_} prior run(s)`)}else{let n=U.caseDiscrimination?.cases??[],c=[];if(r.name.startsWith("/")){let s=r.name.slice(0,r.name.lastIndexOf("/"));try{let b=await P(`/api/insights/evidence?projectPath=${encodeURIComponent(s)}`);b.analyzedAt&&(c=[...b.friction.map(Y=>`Real-session friction (insights, ${b.analyzedAt.slice(0,10)}): ${Y}`),...b.whatWorks.map(Y=>`Working well in real sessions \u2014 do not break: ${Y}`)],c.length>0&&t(`${e}: proposer sees ${b.friction.length} friction + ${b.whatWorks.length} what-works item(s) from insights`))}catch(b){t(`${e}: insights evidence unavailable (${b instanceof Error?b.message:String(b)}) \u2014 proposing without it`)}}let T=[];try{T=Xe(q.promotions,D)}catch(s){t(`${e}: could not summarise prior decisions (${s instanceof Error?s.message:String(s)}) \u2014 proposing without them`)}T.length>0&&t(`${e}: proposer sees ${T.length} prior decision(s) against this exact body (${T.map(s=>`${s.decision}${s.measured?"/measured":""}`).join(", ")})`);let M=await Ae({currentContent:r.content,targetType:r.type,targetName:r.name,immutableSections:C,evidence:{nonDiscriminating:n.filter(s=>!s.discriminating).map(s=>`${s.name??s.assertion??"unnamed"} \u2014 ${s.note}`),weakest:n.filter(s=>s.discriminating&&s.withPassRate<s.withoutPassRate).map(s=>({name:s.name??s.assertion??"unnamed",withPassRate:s.withPassRate,withoutPassRate:s.withoutPassRate})),priorDecisions:T,notes:c}});if(!M.ok)return t(`${e}: no usable proposal \u2014 ${M.reason}`),{skipped:"no-proposal",reason:M.reason};m=M.proposal.candidateContent,F=M.proposal.rationale}let I=f?ve({plannedPairs:f.plannedPairs||v.expectedPairs,carriedPairs:w.length,liveCases:$.length}):v.passes;t(`${e}: measuring ${$.length} case(s) x ${I} pass(es) = up to ${$.length*I} pairs, candidate vs prior version`+(f?` (resumed; ${w.length} pair(s) already banked)`:""));let A=[],X=[],Oe=Date.now(),oe=0,z=0;for(let n=1;n<=I;n++){let c=await $e({cases:$,candidateContent:m,priorVersionContent:G,concurrency:a.concurrency??2,runNumber:n,opts:{targetId:l,targetVersion:r.version??1,iteration:1,timeout:a.timeout??24e4,model:a.model,graderModel:a.graderModel,skipGrading:!1,targetType:r.type,targetName:r.name,candidateContentHash:W(m)},onLog:t});if(A.push(...c.pairs),X.push(...c.results),oe+=c.completed,z+=c.failed,t(`${e}: pass ${n}/${I} \u2014 ${c.pairs.length} pair(s), running total ${A.length}`),c.abortedForQuota){t(`${e}: stopping after pass ${n}/${I} \u2014 ${c.abortedForQuota}. Remaining passes would spend against an exhausted account.`);break}}let R=[...w,...A],O=he(X),Q=A.length>0,d=ge({runs:X,plannedPairs:v.expectedPairs,usablePairs:A.length,verdictPairs:Q?R.length:A.length,proposalCalls:B,passes:I,liveCases:$.length,wallMs:Date.now()-Oe});if(t(`${e}: ${oe} completed, ${z} failed, ${A.length} usable pair(s) \u2014 spent ~${d.modelCalls} model calls (${d.proposalCalls} proposal + ${d.executorCalls} executor + >=${d.graderCalls} grader) in ${(d.wallMs/6e4).toFixed(1)} min`+(Q?`; the ${d.verdictPairs} pair(s) behind this verdict resolve +/-${me(d.mde)} at 80% power`:"")),!Q)return{skipped:O.infrastructureFailed?"infrastructure-failure":"no-pairs",reason:O.infrastructureFailed?`${O.infrastructureFailed} run(s) never executed (${O.summary.describe()}) \u2014 the environment failed, not the target`:`${z} run(s) failed or were ungradeable`,cost:d};let V=be({pairs:R.length,minPairs:10,accounting:O});if(V.kind==="infrastructure-incomplete")return t(`${e}: not posting a verdict \u2014 ${V.reason}`),await ee({evalTargetId:l,meta:o,blob:Ce({content:m,hash:W(m),priorHash:D,plannedPairs:f?.plannedPairs||v.expectedPairs,now:new Date}),log:t,tag:e}),{skipped:"infrastructure-incomplete",reason:V.reason,cost:d};p.enabled&&t(`${e}: accumulated ${R.length}/${p.targetPairs} pair(s) over ${_+1} run(s) on one candidate`);let ie=H,{apply:Te,peeking:Me}=Qe({consented:ie,accumulateEnabled:p.enabled,pairCount:R.length,targetPairs:p.targetPairs});ie&&Me&&t(`${e}: interim readout at ${R.length}/${p.targetPairs} pairs \u2014 recording the decision but not acting until the target is reached`);let h=await K(`/api/eval-targets/${l}/promotions`,{candidateContent:m,proposalSource:"llm",proposalRationale:F,pairs:R,canaryGreen:L.green,measuredAgainstContentHash:D,immutableSections:C,apply:Te,measurementCost:d,...p.enabled?{accumulation:{candidateContentHash:W(m),priorContentHash:D,targetPairs:p.targetPairs,carriedPairs:w.length,runs:_+1}}:{}});t(`${e}: ${h.decision}${h.applied?" (APPLIED)":""} \u2014 ${h.rationale}`+(h.refusals.length>0?` | refusals: ${h.refusals.join("; ")}`:"")),(f||o[Pe])&&await ee({evalTargetId:l,meta:o,blob:null,log:t,tag:e});let J=!1,E;if(h.applied&&r.name.startsWith("/"))try{Ee(r.name)?Se(r.name,"utf8")!==G?E="file changed since measurement started \u2014 refusing to clobber; next cycle re-syncs":(Ne(r.name,m,"utf8"),J=!0):E="file no longer exists on disk",t(J?`${e}: measured improvement written to ${r.name} (undo: git checkout -- ${r.name})`:`${e}: NOT written to disk \u2014 ${E}`)}catch(n){E=n instanceof Error?n.message:String(n),t(`${e}: disk write-back failed \u2014 ${E}. The eval target is updated; the file is not.`)}return{decision:h.decision,applied:h.applied,nPairs:R.length,promotionId:h.id,cost:d,diskSynced:y,...h.applied?{fileWritten:J,...E?{fileWriteSkipped:E}:{}}:{},...p.enabled?{carriedPairs:w.length,accumulationRuns:_+1}:{}}}u(it,"cronInstructionEvolution");function Ve(a){let i=a.immutableSections;return i==null||!Array.isArray(i)?null:i.filter(t=>typeof t=="string")}u(Ve,"readImmutableSections");export{Ie as a,te as b,Le as c,Fe as d,je as e,Ue as f,Ge as g,Be as h,Xe as i,ze as j,Qe as k,it as l,Ve as m};
@@ -1 +1 @@
1
- import{a as o}from"../../chunk-GY5IJ4RS.js";import{a as n}from"../../chunk-65TQMBNF.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-6PUH7HEL.js";import"../../chunk-WRQEHXSN.js";import"../../chunk-YTPQ7VBO.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-2AVGUZ2P.js";import"../../chunk-OOGTQOL3.js";import"../../chunk-PZNWH4VQ.js";import{a as i}from"../../chunk-ZLLER3HP.js";import{printTable as t}from"@oclif/table";var a=class s extends n{static{i(this,"CronsList")}static description="List manually-runnable maintenance tasks";static examples=["<%= config.bin %> crons list"];async run(){await this.parse(s),t({data:o.map(e=>({Name:e.name,"Scheduled by":e.scheduledBy,Description:e.description})),columns:["Name","Scheduled by","Description"]}),this.log(""),this.log("Scheduled crons run in Supabase pg_cron \u2014 audit them with:"),this.log(` psql "$DATABASE_URL" -c 'select jobname, schedule, active from cron.job;'`),this.log("Run any task above on demand with: rulemetric crons run <name>")}};export{a as default};
1
+ import{a as o}from"../../chunk-APXQLQZY.js";import{a as n}from"../../chunk-65TQMBNF.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-6PUH7HEL.js";import"../../chunk-WRQEHXSN.js";import"../../chunk-YTPQ7VBO.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-2AVGUZ2P.js";import"../../chunk-OOGTQOL3.js";import"../../chunk-PZNWH4VQ.js";import{a as i}from"../../chunk-ZLLER3HP.js";import{printTable as t}from"@oclif/table";var a=class s extends n{static{i(this,"CronsList")}static description="List manually-runnable maintenance tasks";static examples=["<%= config.bin %> crons list"];async run(){await this.parse(s),t({data:o.map(e=>({Name:e.name,"Scheduled by":e.scheduledBy,Description:e.description})),columns:["Name","Scheduled by","Description"]}),this.log(""),this.log("Scheduled crons run in Supabase pg_cron \u2014 audit them with:"),this.log(` psql "$DATABASE_URL" -c 'select jobname, schedule, active from cron.job;'`),this.log("Run any task above on demand with: rulemetric crons run <name>")}};export{a as default};
@@ -1,2 +1,2 @@
1
- import{a as u}from"../../chunk-GY5IJ4RS.js";import{a as c}from"../../chunk-65TQMBNF.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-6PUH7HEL.js";import"../../chunk-WRQEHXSN.js";import"../../chunk-YTPQ7VBO.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-2AVGUZ2P.js";import"../../chunk-OOGTQOL3.js";import"../../chunk-PZNWH4VQ.js";import{a as l}from"../../chunk-ZLLER3HP.js";import{Args as g,Flags as f}from"@oclif/core";var i=class m extends c{static{l(this,"CronsRun")}static description="Run a maintenance task synchronously, right now";static examples=["<%= config.bin %> crons run cron_check_changelog","<%= config.bin %> crons run cron_suggest_instructions --quiet"];static args={name:g.string({description:"Task name (run `rulemetric crons list` to see all)",required:!0})};static flags={quiet:f.boolean({char:"q",description:"Suppress per-line log output; print summary only"})};async run(){let{args:s,flags:d}=await this.parse(m);this.requireAuth();let n=u.find(e=>e.name===s.name);n||this.error(`Unknown task: ${s.name}
1
+ import{a as u}from"../../chunk-APXQLQZY.js";import{a as c}from"../../chunk-65TQMBNF.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-6PUH7HEL.js";import"../../chunk-WRQEHXSN.js";import"../../chunk-YTPQ7VBO.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-2AVGUZ2P.js";import"../../chunk-OOGTQOL3.js";import"../../chunk-PZNWH4VQ.js";import{a as l}from"../../chunk-ZLLER3HP.js";import{Args as g,Flags as f}from"@oclif/core";var i=class m extends c{static{l(this,"CronsRun")}static description="Run a maintenance task synchronously, right now";static examples=["<%= config.bin %> crons run cron_check_changelog","<%= config.bin %> crons run cron_suggest_instructions --quiet"];static args={name:g.string({description:"Task name (run `rulemetric crons list` to see all)",required:!0})};static flags={quiet:f.boolean({char:"q",description:"Suppress per-line log output; print summary only"})};async run(){let{args:s,flags:d}=await this.parse(m);this.requireAuth();let n=u.find(e=>e.name===s.name);n||this.error(`Unknown task: ${s.name}
2
2
  Run \`rulemetric crons list\` to see available tasks.`);let o;try{({runManualTask:o}=await import("../../lib/manual-tasks.js"))}catch(e){let r=e?.code;throw(r==="ERR_MODULE_NOT_FOUND"||r==="MODULE_NOT_FOUND")&&this.error("`crons run` needs the worker runtime, which isn't available in this install.\nThese maintenance tasks connect to the database directly \u2014 run them from a full RuleMetric checkout with DATABASE_URL and the worker dependencies installed."),e}this.log(`\u25B6 Running ${n.name} \u2026`);let h=Date.now(),t=await o(s.name);if(!d.quiet)for(let e of t.logs){let r=e.level==="error"||e.level==="warn"?`[${e.level}]`:"";this.log(` ${r} ${e.message}`)}let a=((t.durationMs??Date.now()-h)/1e3).toFixed(1);t.ok?this.log(`\u2713 ${n.name} completed in ${a}s (${t.logs.length} log line${t.logs.length===1?"":"s"})`):this.error(`\u2717 ${n.name} failed after ${a}s: ${t.error}`)}};export{i as default};
@@ -1 +1 @@
1
- import{b as R,c as B}from"../chunk-V5U3E4BZ.js";import{e as S,f as A,g as C}from"../chunk-QWCEZEDO.js";import"../chunk-KKDHD4XA.js";import"../chunk-SZ62CP55.js";import{d as J,e as q}from"../chunk-IS2AZIG7.js";import"../chunk-M7QSC64D.js";import"../chunk-DPCAPIQB.js";import{i as j,j as F,k as G,m as W,n as V}from"../chunk-LB24UKHZ.js";import"../chunk-G7V4ZZZ3.js";import"../chunk-T67L2YTW.js";import"../chunk-SD626JBZ.js";import{d as D}from"../chunk-NF2BIEAF.js";import{a as Y}from"../chunk-3QXRLIGC.js";import"../chunk-HFGO5762.js";import"../chunk-SVON2JIS.js";import"../chunk-GN3ZHQ46.js";import"../chunk-U2NT5OSQ.js";import"../chunk-KGURGIZ2.js";import"../chunk-UPFH72PF.js";import"../chunk-BJSVATVJ.js";import"../chunk-CDY7TQFZ.js";import"../chunk-RIVEBBZC.js";import"../chunk-QBNLZJIR.js";import"../chunk-N7ODX6PO.js";import"../chunk-PJ3WHQ67.js";import"../chunk-VBXL7XO7.js";import"../chunk-TZA4HAVF.js";import{a as I,b as M,c as N,f as U,g as X}from"../chunk-QXPYGN7I.js";import{a as H}from"../chunk-65TQMBNF.js";import"../chunk-IZTIYR5Q.js";import"../chunk-6PUH7HEL.js";import"../chunk-WRQEHXSN.js";import"../chunk-YTPQ7VBO.js";import"../chunk-3AV3GTMP.js";import{a as L,e as P}from"../chunk-2AVGUZ2P.js";import"../chunk-OOGTQOL3.js";import{a as O,g as f,l as E}from"../chunk-PZNWH4VQ.js";import{a as T}from"../chunk-ZLLER3HP.js";import{spawnSync as ee}from"node:child_process";import{existsSync as te,readFileSync as oe}from"node:fs";import{join as K}from"node:path";var _=class h extends H{static{T(this,"Diagnostics")}static description='Diagnose capture / proxy / connectivity problems (e.g. a client-side "502 Bad Gateway")';static examples=["<%= config.bin %> diagnostics"];baseUrl(){return process.env.RULEMETRIC_API_URL??O().apiUrl??L}async checkDirect(){let n=process.env.HTTPS_PROXY,i=process.env.HTTP_PROXY;delete process.env.HTTPS_PROXY,delete process.env.HTTP_PROXY;let o=new AbortController,a=setTimeout(()=>o.abort(),8e3);try{return(await globalThis.fetch(`${this.baseUrl()}/health`,{signal:o.signal})).ok}catch{return!1}finally{clearTimeout(a),n!==void 0&&(process.env.HTTPS_PROXY=n),i!==void 0&&(process.env.HTTP_PROXY=i)}}configuredProxy(){if(process.env.HTTPS_PROXY)return process.env.HTTPS_PROXY;for(let n of["settings.local.json","settings.json"]){let i=K(process.cwd(),".claude",n);if(te(i))try{let o=JSON.parse(oe(i,"utf8"));if(o.env?.HTTPS_PROXY)return o.env.HTTPS_PROXY}catch{}}return null}checkThroughProxy(n){let i=ee("curl",["-sS","-x",n,"--max-time","8","-o","/dev/null","-w","%{http_code}",`${this.baseUrl()}/health`],{encoding:"utf8",stdio:["ignore","pipe","ignore"]});return i.error||typeof i.stdout!="string"?null:i.stdout.trim()==="200"}async run(){await this.parse(h);let n=process.version,i=this.configuredProxy(),o=i!=null,[a,m,u]=await Promise.all([this.checkDirect(),C(S),C(A)]),d=o&&i?this.checkThroughProxy(i):null,e=T((r,p,b)=>{let c=p===null?"\u2013":p?"[OK]":"[!!]";this.log(` ${c} ${r.padEnd(22)} ${b}`)},"line");this.log("RuleMetric diagnostics"),this.log(""),e("Node",!R(n),`${n}${R(n)?" (< 20.11 \u2014 breaks the bundled proxy)":""}`),e("API (direct)",a,`${this.baseUrl()}/health ${a?"reachable":"UNREACHABLE"}`),e("Authenticated",f(),f()?"yes":"no \u2014 run `rulemetric auth login`"),e("Proxy configured",o?!0:null,o?i:"no HTTPS_PROXY set"),o&&(e("Gateway :"+S,m,m?"listening":"NOT listening"),e("mitmproxy :"+A,u,u?"listening":"not listening (gateway should route direct)"),e("API (via proxy)",d,d===null?"inconclusive (curl unavailable)":d?"reachable":"FAILED \u2014 502/blocked through your proxy"));let s=D();e("claude CLI",s.claudeBin!=null,s.claudeBin??"not found \u2014 LLM features (grading, distill) will no-op"),e("codex CLI",s.codexBin!=null?!0:null,s.codexBin?`${s.codexBin}${s.codexConfiguredModel?` (model ${s.codexConfiguredModel})`:""}`:"not found \u2014 optional; enables the cross-vendor reviewer (evals validate-judge)");let t=null;if(f()&&a)try{t=await P("/api/workers/health")}catch{t=null}if(t){let r=t.worker;e("Worker",!!r.active,r.present?r.active?`online (last heartbeat ${r.ageSeconds??"?"}s ago${r.clientVersion?`, v${r.clientVersion}`:""})`:`NOT RUNNING \u2014 last heartbeat ${ne(r.ageSeconds)} ago`:"never connected \u2014 no worker has ever reported in");let p=t.worker.engines;if(p!=null){let c=[p.claude&&"claude",p.codex&&"codex"].filter(Boolean);e("LLM engine",c.length>0,c.length>0?`${c.join(" + ")} available to the worker`:"NONE \u2014 the worker found no `claude` and no `codex`. LLM jobs will complete with empty output rather than failing.")}let b=t.pending.reduce((c,w)=>c+w.count,0);if(b>0){let c=t.verdict.stuck.reduce((v,y)=>v+y.count,0),w=t.verdict.unclaimable.reduce((v,y)=>v+y.count,0),x=(t.verdict.engineBlocked??[]).reduce((v,y)=>v+y.count,0);e("Job queue",c===0&&x===0,`${b} pending`+(c>0?` \u2014 ${c} waiting on this worker`:"")+(x>0?` \u2014 ${x} need a local LLM engine`:"")+(w>0?` \u2014 ${w} need a worker with DATABASE_URL`:""))}else e("Job queue",!0,"empty")}else f()&&a&&e("Worker",null,"could not read /workers/health (older API?)");let l=Y(process.cwd()),g=await M({configDir:E()}),z=await N({configDir:E()}),$=` \u2014 ${X(z)}`,Q={claude_code:`session hooks (+ proxy for instruction linking)${$}`,codex:`worker transcript sync of ~/.codex/sessions \u2014 ${U(g)}`,cursor:`user hooks (~/.cursor/hooks.json)${$}`,copilot_agent:`workspace hooks${$}`,antigravity:`user hooks (~/.gemini/config/hooks.json)${$}`};this.log(""),this.log(" Capture coverage (agents found on this machine):");for(let r of l)this.log(` \u2022 ${r.padEnd(15)} ${Q[r]??"captured"}`);if(l.includes("codex"))if(g.error)this.log(` ! ${g.error}`);else if(g.mode==="allowlist")for(let r of g.roots)this.log(` \u21B3 ${r}`);else g.mode==="all"&&this.log(` \u21B3 scope it with ${K(E(),I)} ({"codex":{"roots":["/path/to/repo"]}}) or RULEMETRIC_CODEX_CAPTURE=off`);t&&!t.worker.active&&l.includes("codex")&&g.mode!=="off"&&this.log(" ! Codex capture runs INSIDE the worker \u2014 it is stopped while the worker is down."),f()&&a&&await this.reportEvolutionSpend();let k=B({nodeVersion:n,directApiOk:a,httpsProxySet:o,gatewayAlive:m,mitmproxyAlive:u,proxyPathOk:d});this.log("");let Z=k.severity==="ok"?"[OK]":k.severity==="warn"?"[!!]":"[XX]";this.log(`${Z} ${k.headline}`);for(let r of k.hints)this.log(` \u2022 ${r}`);if(t&&t.verdict.severity!=="ok"){let r=t.verdict.severity==="warn"?"[!!]":"[XX]";this.log(""),this.log(`${r} ${t.verdict.headline}`);for(let p of t.verdict.hints)this.log(` \u2022 ${p}`)}}async reportEvolutionSpend(){let n;try{n=await P("/api/eval-targets?type=instruction&limit=200")}catch{return}let i=n.filter(o=>{let a=o.metadata??{};return a.autoEvolveEnabled===!0||a.autoEvolveEnabled==="true"});if(i.length!==0){this.log(""),this.log(" Nightly instruction evolution (cron_instruction_evolution, 07:30 UTC):");for(let o of i){let a=o.metadata??{},m=F(a),u=j(a);if(m){this.log(` \u2022 ${o.name} \u2014 PAUSED (metadata.autoEvolvePaused). Opt-in preserved.`),this.log(" \u21B3 resume: set autoEvolvePaused=false");continue}let d=null;try{d=(await P(`/api/eval-targets/${o.id}/evals`)).filter(s=>!s.retiredAt).length}catch{}if(this.log(` \u2022 ${o.name}`),d!=null){let e=q(d,u.minPairs,J(u,d));if(!e.feasible)this.log(` \u21B3 cannot reach a verdict \u2014 ${e.reason}`);else{let s=G({liveCases:d,passes:e.passes});this.log(` \u21B3 each night: ${V(s)}`)}}this.log(` \u21B3 pairs budget ${u.minPairs}`+(u.configured?" (metadata.autoEvolvePairs)":" (default)")+` \xB7 writes ${a.autoEvolveApply===!0||a.autoEvolveApply==="true"?"ENABLED":"off (dry run)"}`),u.note&&this.log(` ! ${u.note}`);try{let e=await P(`/api/eval-targets/${o.id}/promotions?limit=1`),s=e.promotions[0];if(s){let l=s.gates?.cost,g=l?.modelCalls?`${l.modelCalls} model calls, ${l.usablePairs??"?"} usable pair(s)`+(l.mde!=null?`, resolved +/-${W(l.mde)}`:"")+(l.wallMs?`, ${(l.wallMs/6e4).toFixed(0)} min`:""):"cost not recorded (decision predates cost tracking)";this.log(` \u21B3 last run ${new Date(s.createdAt).toISOString().slice(0,10)}: ${s.decision}${s.applied?" (APPLIED)":""} \u2014 ${g}`)}let t=e.counts??{};this.log(` \u21B3 lifetime: ${t.promote??0} promote / ${t.revert??0} revert / ${t.refuse??0} refuse`)}catch{}}this.log(" \u21B3 pause the spend: metadata.autoEvolvePaused=true (keeps the opt-in)")}}};function ne(h){if(h===null)return"never";if(h<90)return`${Math.round(h)}s`;let n=Math.round(h/60);return n<90?`${n}m`:`${Math.round(n/60)}h`}T(ne,"formatAge");export{_ as default};
1
+ import{b as R,c as B}from"../chunk-V5U3E4BZ.js";import{e as S,f as A,g as C}from"../chunk-QWCEZEDO.js";import"../chunk-KKDHD4XA.js";import"../chunk-SZ62CP55.js";import{d as J,e as q}from"../chunk-TZUTX4PG.js";import"../chunk-M7QSC64D.js";import"../chunk-DPCAPIQB.js";import"../chunk-T67L2YTW.js";import{i as j,j as F,k as G,m as W,n as V}from"../chunk-LB24UKHZ.js";import"../chunk-G7V4ZZZ3.js";import"../chunk-SD626JBZ.js";import{d as D}from"../chunk-NF2BIEAF.js";import{a as Y}from"../chunk-3QXRLIGC.js";import"../chunk-HFGO5762.js";import"../chunk-SVON2JIS.js";import"../chunk-GN3ZHQ46.js";import"../chunk-U2NT5OSQ.js";import"../chunk-KGURGIZ2.js";import"../chunk-UPFH72PF.js";import"../chunk-BJSVATVJ.js";import"../chunk-CDY7TQFZ.js";import"../chunk-RIVEBBZC.js";import"../chunk-QBNLZJIR.js";import"../chunk-N7ODX6PO.js";import"../chunk-PJ3WHQ67.js";import"../chunk-VBXL7XO7.js";import"../chunk-TZA4HAVF.js";import{a as I,b as M,c as N,f as U,g as X}from"../chunk-QXPYGN7I.js";import{a as H}from"../chunk-65TQMBNF.js";import"../chunk-IZTIYR5Q.js";import"../chunk-6PUH7HEL.js";import"../chunk-WRQEHXSN.js";import"../chunk-YTPQ7VBO.js";import"../chunk-3AV3GTMP.js";import{a as L,e as P}from"../chunk-2AVGUZ2P.js";import"../chunk-OOGTQOL3.js";import{a as O,g as f,l as E}from"../chunk-PZNWH4VQ.js";import{a as T}from"../chunk-ZLLER3HP.js";import{spawnSync as ee}from"node:child_process";import{existsSync as te,readFileSync as oe}from"node:fs";import{join as K}from"node:path";var _=class h extends H{static{T(this,"Diagnostics")}static description='Diagnose capture / proxy / connectivity problems (e.g. a client-side "502 Bad Gateway")';static examples=["<%= config.bin %> diagnostics"];baseUrl(){return process.env.RULEMETRIC_API_URL??O().apiUrl??L}async checkDirect(){let n=process.env.HTTPS_PROXY,i=process.env.HTTP_PROXY;delete process.env.HTTPS_PROXY,delete process.env.HTTP_PROXY;let o=new AbortController,a=setTimeout(()=>o.abort(),8e3);try{return(await globalThis.fetch(`${this.baseUrl()}/health`,{signal:o.signal})).ok}catch{return!1}finally{clearTimeout(a),n!==void 0&&(process.env.HTTPS_PROXY=n),i!==void 0&&(process.env.HTTP_PROXY=i)}}configuredProxy(){if(process.env.HTTPS_PROXY)return process.env.HTTPS_PROXY;for(let n of["settings.local.json","settings.json"]){let i=K(process.cwd(),".claude",n);if(te(i))try{let o=JSON.parse(oe(i,"utf8"));if(o.env?.HTTPS_PROXY)return o.env.HTTPS_PROXY}catch{}}return null}checkThroughProxy(n){let i=ee("curl",["-sS","-x",n,"--max-time","8","-o","/dev/null","-w","%{http_code}",`${this.baseUrl()}/health`],{encoding:"utf8",stdio:["ignore","pipe","ignore"]});return i.error||typeof i.stdout!="string"?null:i.stdout.trim()==="200"}async run(){await this.parse(h);let n=process.version,i=this.configuredProxy(),o=i!=null,[a,m,u]=await Promise.all([this.checkDirect(),C(S),C(A)]),d=o&&i?this.checkThroughProxy(i):null,e=T((r,p,b)=>{let c=p===null?"\u2013":p?"[OK]":"[!!]";this.log(` ${c} ${r.padEnd(22)} ${b}`)},"line");this.log("RuleMetric diagnostics"),this.log(""),e("Node",!R(n),`${n}${R(n)?" (< 20.11 \u2014 breaks the bundled proxy)":""}`),e("API (direct)",a,`${this.baseUrl()}/health ${a?"reachable":"UNREACHABLE"}`),e("Authenticated",f(),f()?"yes":"no \u2014 run `rulemetric auth login`"),e("Proxy configured",o?!0:null,o?i:"no HTTPS_PROXY set"),o&&(e("Gateway :"+S,m,m?"listening":"NOT listening"),e("mitmproxy :"+A,u,u?"listening":"not listening (gateway should route direct)"),e("API (via proxy)",d,d===null?"inconclusive (curl unavailable)":d?"reachable":"FAILED \u2014 502/blocked through your proxy"));let s=D();e("claude CLI",s.claudeBin!=null,s.claudeBin??"not found \u2014 LLM features (grading, distill) will no-op"),e("codex CLI",s.codexBin!=null?!0:null,s.codexBin?`${s.codexBin}${s.codexConfiguredModel?` (model ${s.codexConfiguredModel})`:""}`:"not found \u2014 optional; enables the cross-vendor reviewer (evals validate-judge)");let t=null;if(f()&&a)try{t=await P("/api/workers/health")}catch{t=null}if(t){let r=t.worker;e("Worker",!!r.active,r.present?r.active?`online (last heartbeat ${r.ageSeconds??"?"}s ago${r.clientVersion?`, v${r.clientVersion}`:""})`:`NOT RUNNING \u2014 last heartbeat ${ne(r.ageSeconds)} ago`:"never connected \u2014 no worker has ever reported in");let p=t.worker.engines;if(p!=null){let c=[p.claude&&"claude",p.codex&&"codex"].filter(Boolean);e("LLM engine",c.length>0,c.length>0?`${c.join(" + ")} available to the worker`:"NONE \u2014 the worker found no `claude` and no `codex`. LLM jobs will complete with empty output rather than failing.")}let b=t.pending.reduce((c,w)=>c+w.count,0);if(b>0){let c=t.verdict.stuck.reduce((v,y)=>v+y.count,0),w=t.verdict.unclaimable.reduce((v,y)=>v+y.count,0),x=(t.verdict.engineBlocked??[]).reduce((v,y)=>v+y.count,0);e("Job queue",c===0&&x===0,`${b} pending`+(c>0?` \u2014 ${c} waiting on this worker`:"")+(x>0?` \u2014 ${x} need a local LLM engine`:"")+(w>0?` \u2014 ${w} need a worker with DATABASE_URL`:""))}else e("Job queue",!0,"empty")}else f()&&a&&e("Worker",null,"could not read /workers/health (older API?)");let l=Y(process.cwd()),g=await M({configDir:E()}),z=await N({configDir:E()}),$=` \u2014 ${X(z)}`,Q={claude_code:`session hooks (+ proxy for instruction linking)${$}`,codex:`worker transcript sync of ~/.codex/sessions \u2014 ${U(g)}`,cursor:`user hooks (~/.cursor/hooks.json)${$}`,copilot_agent:`workspace hooks${$}`,antigravity:`user hooks (~/.gemini/config/hooks.json)${$}`};this.log(""),this.log(" Capture coverage (agents found on this machine):");for(let r of l)this.log(` \u2022 ${r.padEnd(15)} ${Q[r]??"captured"}`);if(l.includes("codex"))if(g.error)this.log(` ! ${g.error}`);else if(g.mode==="allowlist")for(let r of g.roots)this.log(` \u21B3 ${r}`);else g.mode==="all"&&this.log(` \u21B3 scope it with ${K(E(),I)} ({"codex":{"roots":["/path/to/repo"]}}) or RULEMETRIC_CODEX_CAPTURE=off`);t&&!t.worker.active&&l.includes("codex")&&g.mode!=="off"&&this.log(" ! Codex capture runs INSIDE the worker \u2014 it is stopped while the worker is down."),f()&&a&&await this.reportEvolutionSpend();let k=B({nodeVersion:n,directApiOk:a,httpsProxySet:o,gatewayAlive:m,mitmproxyAlive:u,proxyPathOk:d});this.log("");let Z=k.severity==="ok"?"[OK]":k.severity==="warn"?"[!!]":"[XX]";this.log(`${Z} ${k.headline}`);for(let r of k.hints)this.log(` \u2022 ${r}`);if(t&&t.verdict.severity!=="ok"){let r=t.verdict.severity==="warn"?"[!!]":"[XX]";this.log(""),this.log(`${r} ${t.verdict.headline}`);for(let p of t.verdict.hints)this.log(` \u2022 ${p}`)}}async reportEvolutionSpend(){let n;try{n=await P("/api/eval-targets?type=instruction&limit=200")}catch{return}let i=n.filter(o=>{let a=o.metadata??{};return a.autoEvolveEnabled===!0||a.autoEvolveEnabled==="true"});if(i.length!==0){this.log(""),this.log(" Nightly instruction evolution (cron_instruction_evolution, 07:30 UTC):");for(let o of i){let a=o.metadata??{},m=F(a),u=j(a);if(m){this.log(` \u2022 ${o.name} \u2014 PAUSED (metadata.autoEvolvePaused). Opt-in preserved.`),this.log(" \u21B3 resume: set autoEvolvePaused=false");continue}let d=null;try{d=(await P(`/api/eval-targets/${o.id}/evals`)).filter(s=>!s.retiredAt).length}catch{}if(this.log(` \u2022 ${o.name}`),d!=null){let e=q(d,u.minPairs,J(u,d));if(!e.feasible)this.log(` \u21B3 cannot reach a verdict \u2014 ${e.reason}`);else{let s=G({liveCases:d,passes:e.passes});this.log(` \u21B3 each night: ${V(s)}`)}}this.log(` \u21B3 pairs budget ${u.minPairs}`+(u.configured?" (metadata.autoEvolvePairs)":" (default)")+` \xB7 writes ${a.autoEvolveApply===!0||a.autoEvolveApply==="true"?"ENABLED":"off (dry run)"}`),u.note&&this.log(` ! ${u.note}`);try{let e=await P(`/api/eval-targets/${o.id}/promotions?limit=1`),s=e.promotions[0];if(s){let l=s.gates?.cost,g=l?.modelCalls?`${l.modelCalls} model calls, ${l.usablePairs??"?"} usable pair(s)`+(l.mde!=null?`, resolved +/-${W(l.mde)}`:"")+(l.wallMs?`, ${(l.wallMs/6e4).toFixed(0)} min`:""):"cost not recorded (decision predates cost tracking)";this.log(` \u21B3 last run ${new Date(s.createdAt).toISOString().slice(0,10)}: ${s.decision}${s.applied?" (APPLIED)":""} \u2014 ${g}`)}let t=e.counts??{};this.log(` \u21B3 lifetime: ${t.promote??0} promote / ${t.revert??0} revert / ${t.refuse??0} refuse`)}catch{}}this.log(" \u21B3 pause the spend: metadata.autoEvolvePaused=true (keeps the opt-in)")}}};function ne(h){if(h===null)return"never";if(h<90)return`${Math.round(h)}s`;let n=Math.round(h/60);return n<90?`${n}m`:`${Math.round(n/60)}h`}T(ne,"formatAge");export{_ as default};
@@ -1,3 +1,3 @@
1
- import{a as C,b as L,c as D}from"../../chunk-GWDZNGUP.js";import{c as d}from"../../chunk-LUCVMLHV.js";import{e as I}from"../../chunk-2WTCH4RR.js";import"../../chunk-FNMJ6E6F.js";import"../../chunk-IEQDLURA.js";import"../../chunk-PMW35N32.js";import"../../chunk-ZQJWKIJS.js";import"../../chunk-LDQ6FLET.js";import"../../chunk-J35L3LR3.js";import"../../chunk-RFISMWRW.js";import"../../chunk-ZYGBABMZ.js";import"../../chunk-2MZFB46B.js";import"../../chunk-PZS55PW2.js";import"../../chunk-YRTG6SX6.js";import"../../chunk-3ZHVP3KE.js";import"../../chunk-NMWP3JLW.js";import"../../chunk-HOQPVOMF.js";import"../../chunk-2IEYDOFE.js";import"../../chunk-FIPW2SGV.js";import"../../chunk-LYP3LNFL.js";import"../../chunk-Y6TAPCA5.js";import"../../chunk-5RBLIVBF.js";import"../../chunk-5BTNALJL.js";import"../../chunk-4XLMX642.js";import"../../chunk-RK2LZIBA.js";import"../../chunk-6LJD6TXN.js";import"../../chunk-CRPOQMQ2.js";import"../../chunk-3UKZJAFS.js";import"../../chunk-MOY7XDR6.js";import"../../chunk-SJKS3PYX.js";import"../../chunk-E7N5R3HV.js";import"../../chunk-K6T4ODPZ.js";import"../../chunk-XFAFMYIP.js";import"../../chunk-GIRPEMTW.js";import"../../chunk-PQMWZHEY.js";import"../../chunk-OCHAV6YZ.js";import"../../chunk-LVAROIKP.js";import"../../chunk-D4UDSY7Y.js";import"../../chunk-E7XOYGL5.js";import"../../chunk-TJYXSMQV.js";import"../../chunk-LJRE3LZ2.js";import"../../chunk-ASQG7BTP.js";import"../../chunk-4Y54EMS6.js";import"../../chunk-KJRMGTAO.js";import"../../chunk-UQSUSB6G.js";import"../../chunk-6UEFCMR2.js";import"../../chunk-MODXEGCU.js";import"../../chunk-RBSEE2Z6.js";import"../../chunk-AFYZYXQ3.js";import"../../chunk-IS2AZIG7.js";import"../../chunk-M7QSC64D.js";import"../../chunk-DPCAPIQB.js";import"../../chunk-LB24UKHZ.js";import"../../chunk-G7V4ZZZ3.js";import"../../chunk-T67L2YTW.js";import"../../chunk-SD626JBZ.js";import"../../chunk-NF2BIEAF.js";import"../../chunk-3QXRLIGC.js";import"../../chunk-HFGO5762.js";import"../../chunk-SVON2JIS.js";import"../../chunk-GN3ZHQ46.js";import"../../chunk-U2NT5OSQ.js";import"../../chunk-KGURGIZ2.js";import"../../chunk-UPFH72PF.js";import"../../chunk-BJSVATVJ.js";import"../../chunk-CDY7TQFZ.js";import"../../chunk-RIVEBBZC.js";import"../../chunk-QBNLZJIR.js";import"../../chunk-N7ODX6PO.js";import"../../chunk-PJ3WHQ67.js";import"../../chunk-VBXL7XO7.js";import"../../chunk-TZA4HAVF.js";import{b as k,f as h,h as A}from"../../chunk-QXPYGN7I.js";import{a as O}from"../../chunk-65TQMBNF.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-6PUH7HEL.js";import"../../chunk-WRQEHXSN.js";import"../../chunk-YTPQ7VBO.js";import"../../chunk-3AV3GTMP.js";import{f as b}from"../../chunk-2AVGUZ2P.js";import"../../chunk-OOGTQOL3.js";import{e as P,l as f}from"../../chunk-PZNWH4VQ.js";import{a as e}from"../../chunk-ZLLER3HP.js";import{trace as se,context as ie}from"@opentelemetry/api";import{NodeSDK as j}from"@opentelemetry/sdk-node";import{OTLPTraceExporter as q}from"@opentelemetry/exporter-trace-otlp-http";import{BatchSpanProcessor as F,ConsoleSpanExporter as U,SimpleSpanProcessor as X}from"@opentelemetry/sdk-trace-node";import{Resource as B}from"@opentelemetry/resources";import{ATTR_SERVICE_NAME as H,ATTR_SERVICE_VERSION as K}from"@opentelemetry/semantic-conventions";function $(t){if(!t)return{};let r={};for(let n of t.split(",")){let s=n.indexOf("=");if(s===-1)continue;let i=n.slice(0,s).trim(),a=n.slice(s+1).trim();i&&(r[i]=a)}return r}e($,"parseOtlpHeaders");var p=null;function y(){return process.env.TELEMETRY_ENABLED!=="false"}e(y,"isTelemetryEnabled");function S(t){if(!y()||p!==null)return"off";let r=new B({[H]:t.serviceName,[K]:t.serviceVersion??"0.1.0"}),n=process.env.OTEL_EXPORTER_OTLP_ENDPOINT,s,i;if(n){let a=$(process.env.OTEL_EXPORTER_OTLP_HEADERS),l=new q({url:`${n}/v1/traces`,headers:a});i=new F(l),s="otlp"}else if(process.env.OTEL_SPAN_EXPORT==="none")i=void 0,s="silent";else{let a=new U;i=new X(a),s="console"}return p=new j({resource:r,spanProcessors:i?[i]:[]}),p.start(),s}e(S,"initTelemetry");async function m(){p&&(await p.shutdown(),p=null)}e(m,"shutdownTelemetry");import{SpanKind as he,SpanStatusCode as ye}from"@opentelemetry/api";import{trace as ve,context as we}from"@opentelemetry/api";import*as u from"@sentry/node";var E=!1;function T(t){if(E)return!1;let r=process.env.SENTRY_DSN;return r?(u.init({dsn:r,serverName:t.serviceName,environment:process.env.NODE_ENV??"development",tracesSampleRate:0}),E=!0,!0):!1}e(T,"initSentry");async function g(t){E&&await u.flush(t)}e(g,"flushSentry");import{existsSync as J,mkdirSync as W,readFileSync as R,unlinkSync as V,writeFileSync as M}from"node:fs";import{dirname as z,join as v}from"node:path";import{execFileSync as Q}from"node:child_process";var c=v(f(),"evals-agent.lock");function Z(t){try{return process.kill(t,0),!0}catch(r){return r.code==="EPERM"}}e(Z,"pidAlive");function ee(t){if(!Z(t))return!1;try{let r=Q("ps",["-p",String(t),"-o","command="],{encoding:"utf-8",stdio:["ignore","pipe","ignore"]});return/run\.js\s+evals\s+agent|evals\s+agent/.test(r)}catch{return!0}}e(ee,"isLiveAgent");function te(){try{W(z(c),{recursive:!0})}catch{}for(let t=0;t<2;t++)try{return M(c,String(process.pid),{flag:"wx"}),{ok:!0}}catch(r){if(r.code!=="EEXIST")throw r;let n=0;try{n=Number(R(c,"utf-8").trim())}catch{}if(n&&n!==process.pid&&ee(n))return{ok:!1,holder:n};try{V(c)}catch{}}try{M(c,String(process.pid))}catch{}return{ok:!0}}e(te,"acquireAgentLock");function x(){try{J(c)&&Number(R(c,"utf-8").trim())===process.pid&&V(c)}catch{}}e(x,"releaseAgentLock");var w=class t extends O{static{e(this,"EvalAgentCommand")}static description="The worker daemon: long-polls /api/work/next, claims jobs, and runs them locally. Installed as a launchd service by `rulemetric service install`.";static examples=["<%= config.bin %> evals agent"];async run(){await this.parse(t),this.requireAuth();let r=te();if(!r.ok){this.log(`Another rulemetric evals agent is already running (pid ${r.holder}). Refusing to start a second instance.`);return}process.env.PG_APPLICATION_NAME||="rulemetric-agent",T({serviceName:"rulemetric-agent"})&&this.log("[sentry] error capture enabled");let s=S({serviceName:"rulemetric-agent"});s==="otlp"?this.log(`[otel] traces exporting to ${process.env.OTEL_EXPORTER_OTLP_ENDPOINT}`):s==="console"?this.log("[otel] cron spans printing to stdout (set OTEL_EXPORTER_OTLP_ENDPOINT to ship to a backend)"):this.log("[otel] disabled (TELEMETRY_ENABLED=false)"),!P()&&!process.env.RULEMETRIC_API_KEY&&this.error("No auth token found. Run `rulemetric auth login` first."),this.log("Starting thin agent (Phase 4b parallel-run)..."),this.log(`Long-polling /api/work/next. Press Ctrl+C to stop.
1
+ import{a as C,b as L,c as D}from"../../chunk-GWDZNGUP.js";import{c as d}from"../../chunk-LUCVMLHV.js";import{e as I}from"../../chunk-D55QB3QI.js";import"../../chunk-FNMJ6E6F.js";import"../../chunk-IEQDLURA.js";import"../../chunk-LYP3LNFL.js";import"../../chunk-Y6TAPCA5.js";import"../../chunk-PMW35N32.js";import"../../chunk-ZQJWKIJS.js";import"../../chunk-LDQ6FLET.js";import"../../chunk-J35L3LR3.js";import"../../chunk-RFISMWRW.js";import"../../chunk-ZYGBABMZ.js";import"../../chunk-5RBLIVBF.js";import"../../chunk-2MZFB46B.js";import"../../chunk-5C3DRKW3.js";import"../../chunk-CRPOQMQ2.js";import"../../chunk-PZS55PW2.js";import"../../chunk-YRTG6SX6.js";import"../../chunk-3ZHVP3KE.js";import"../../chunk-NMWP3JLW.js";import"../../chunk-HOQPVOMF.js";import"../../chunk-2IEYDOFE.js";import"../../chunk-FIPW2SGV.js";import"../../chunk-5BTNALJL.js";import"../../chunk-4XLMX642.js";import"../../chunk-RK2LZIBA.js";import"../../chunk-2K3RUBKC.js";import"../../chunk-3UKZJAFS.js";import"../../chunk-MOY7XDR6.js";import"../../chunk-SJKS3PYX.js";import"../../chunk-E7N5R3HV.js";import"../../chunk-K6T4ODPZ.js";import"../../chunk-XFAFMYIP.js";import"../../chunk-GIRPEMTW.js";import"../../chunk-QUOH6GWM.js";import"../../chunk-PQMWZHEY.js";import"../../chunk-OCHAV6YZ.js";import"../../chunk-LVAROIKP.js";import"../../chunk-D4UDSY7Y.js";import"../../chunk-E7XOYGL5.js";import"../../chunk-TJYXSMQV.js";import"../../chunk-LJRE3LZ2.js";import"../../chunk-LZJXW3B6.js";import"../../chunk-KHCMVYTH.js";import"../../chunk-KJRMGTAO.js";import"../../chunk-UQSUSB6G.js";import"../../chunk-6UEFCMR2.js";import"../../chunk-MODXEGCU.js";import"../../chunk-RBSEE2Z6.js";import"../../chunk-AFYZYXQ3.js";import"../../chunk-TZUTX4PG.js";import"../../chunk-M7QSC64D.js";import"../../chunk-DPCAPIQB.js";import"../../chunk-T67L2YTW.js";import"../../chunk-LB24UKHZ.js";import"../../chunk-G7V4ZZZ3.js";import"../../chunk-SD626JBZ.js";import"../../chunk-NF2BIEAF.js";import"../../chunk-3QXRLIGC.js";import"../../chunk-HFGO5762.js";import"../../chunk-SVON2JIS.js";import"../../chunk-GN3ZHQ46.js";import"../../chunk-U2NT5OSQ.js";import"../../chunk-KGURGIZ2.js";import"../../chunk-UPFH72PF.js";import"../../chunk-BJSVATVJ.js";import"../../chunk-CDY7TQFZ.js";import"../../chunk-RIVEBBZC.js";import"../../chunk-QBNLZJIR.js";import"../../chunk-N7ODX6PO.js";import"../../chunk-PJ3WHQ67.js";import"../../chunk-VBXL7XO7.js";import"../../chunk-TZA4HAVF.js";import{b as k,f as h,h as A}from"../../chunk-QXPYGN7I.js";import{a as O}from"../../chunk-65TQMBNF.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-6PUH7HEL.js";import"../../chunk-WRQEHXSN.js";import"../../chunk-YTPQ7VBO.js";import"../../chunk-3AV3GTMP.js";import{f as b}from"../../chunk-2AVGUZ2P.js";import"../../chunk-OOGTQOL3.js";import{e as P,l as f}from"../../chunk-PZNWH4VQ.js";import{a as e}from"../../chunk-ZLLER3HP.js";import{trace as se,context as ie}from"@opentelemetry/api";import{NodeSDK as j}from"@opentelemetry/sdk-node";import{OTLPTraceExporter as q}from"@opentelemetry/exporter-trace-otlp-http";import{BatchSpanProcessor as F,ConsoleSpanExporter as U,SimpleSpanProcessor as X}from"@opentelemetry/sdk-trace-node";import{Resource as B}from"@opentelemetry/resources";import{ATTR_SERVICE_NAME as H,ATTR_SERVICE_VERSION as K}from"@opentelemetry/semantic-conventions";function $(t){if(!t)return{};let r={};for(let n of t.split(",")){let s=n.indexOf("=");if(s===-1)continue;let i=n.slice(0,s).trim(),a=n.slice(s+1).trim();i&&(r[i]=a)}return r}e($,"parseOtlpHeaders");var p=null;function y(){return process.env.TELEMETRY_ENABLED!=="false"}e(y,"isTelemetryEnabled");function S(t){if(!y()||p!==null)return"off";let r=new B({[H]:t.serviceName,[K]:t.serviceVersion??"0.1.0"}),n=process.env.OTEL_EXPORTER_OTLP_ENDPOINT,s,i;if(n){let a=$(process.env.OTEL_EXPORTER_OTLP_HEADERS),l=new q({url:`${n}/v1/traces`,headers:a});i=new F(l),s="otlp"}else if(process.env.OTEL_SPAN_EXPORT==="none")i=void 0,s="silent";else{let a=new U;i=new X(a),s="console"}return p=new j({resource:r,spanProcessors:i?[i]:[]}),p.start(),s}e(S,"initTelemetry");async function m(){p&&(await p.shutdown(),p=null)}e(m,"shutdownTelemetry");import{SpanKind as he,SpanStatusCode as ye}from"@opentelemetry/api";import{trace as ve,context as we}from"@opentelemetry/api";import*as u from"@sentry/node";var E=!1;function T(t){if(E)return!1;let r=process.env.SENTRY_DSN;return r?(u.init({dsn:r,serverName:t.serviceName,environment:process.env.NODE_ENV??"development",tracesSampleRate:0}),E=!0,!0):!1}e(T,"initSentry");async function g(t){E&&await u.flush(t)}e(g,"flushSentry");import{existsSync as J,mkdirSync as W,readFileSync as R,unlinkSync as V,writeFileSync as M}from"node:fs";import{dirname as z,join as v}from"node:path";import{execFileSync as Q}from"node:child_process";var c=v(f(),"evals-agent.lock");function Z(t){try{return process.kill(t,0),!0}catch(r){return r.code==="EPERM"}}e(Z,"pidAlive");function ee(t){if(!Z(t))return!1;try{let r=Q("ps",["-p",String(t),"-o","command="],{encoding:"utf-8",stdio:["ignore","pipe","ignore"]});return/run\.js\s+evals\s+agent|evals\s+agent/.test(r)}catch{return!0}}e(ee,"isLiveAgent");function te(){try{W(z(c),{recursive:!0})}catch{}for(let t=0;t<2;t++)try{return M(c,String(process.pid),{flag:"wx"}),{ok:!0}}catch(r){if(r.code!=="EEXIST")throw r;let n=0;try{n=Number(R(c,"utf-8").trim())}catch{}if(n&&n!==process.pid&&ee(n))return{ok:!1,holder:n};try{V(c)}catch{}}try{M(c,String(process.pid))}catch{}return{ok:!0}}e(te,"acquireAgentLock");function x(){try{J(c)&&Number(R(c,"utf-8").trim())===process.pid&&V(c)}catch{}}e(x,"releaseAgentLock");var w=class t extends O{static{e(this,"EvalAgentCommand")}static description="The worker daemon: long-polls /api/work/next, claims jobs, and runs them locally. Installed as a launchd service by `rulemetric service install`.";static examples=["<%= config.bin %> evals agent"];async run(){await this.parse(t),this.requireAuth();let r=te();if(!r.ok){this.log(`Another rulemetric evals agent is already running (pid ${r.holder}). Refusing to start a second instance.`);return}process.env.PG_APPLICATION_NAME||="rulemetric-agent",T({serviceName:"rulemetric-agent"})&&this.log("[sentry] error capture enabled");let s=S({serviceName:"rulemetric-agent"});s==="otlp"?this.log(`[otel] traces exporting to ${process.env.OTEL_EXPORTER_OTLP_ENDPOINT}`):s==="console"?this.log("[otel] cron spans printing to stdout (set OTEL_EXPORTER_OTLP_ENDPOINT to ship to a backend)"):this.log("[otel] disabled (TELEMETRY_ENABLED=false)"),!P()&&!process.env.RULEMETRIC_API_KEY&&this.error("No auth token found. Run `rulemetric auth login` first."),this.log("Starting thin agent (Phase 4b parallel-run)..."),this.log(`Long-polling /api/work/next. Press Ctrl+C to stop.
2
2
  `);let a=new AbortController,l=await k({configDir:f()});if(this.log(`[transcript-sync] Codex capture: ${h(l)}`),l.error)this.log(`[transcript-sync] WARNING: ${l.error}`);else if(l.mode==="allowlist")for(let o of l.roots)this.log(`[transcript-sync] \u2022 ${o}`);let G=new C({providers:[L(void 0,void 0,A({configDir:f(),onChange:e(o=>this.log(`[transcript-sync] Codex capture changed: ${h(o)}`),"onChange")}))],statePath:v(f(),"transcript-sync-state.json"),importTranscript:e(o=>b("/api/sessions/import",o),"importTranscript"),log:e(o=>this.log(`[transcript-sync] ${o}`),"log")});D(G,{signal:a.signal,log:e(o=>this.log(`[transcript-sync] ${o}`),"log")});let N=e(async o=>{this.log(`
3
3
  [${o}] shutting down agent...`),a.abort(),await Promise.allSettled([g(2e3),m(),d()]),x(),process.exit(0)},"shutdown");process.on("SIGINT",()=>{N("SIGINT")}),process.on("SIGTERM",()=>{N("SIGTERM")});let _=!1;try{await I({signal:a.signal,log:e(o=>this.log(o),"log"),version:this.config.version,readInstalledVersion:e(()=>{try{return JSON.parse(R(v(this.config.root,"package.json"),"utf-8")).version??null}catch{return null}},"readInstalledVersion"),onVersionDrift:e(()=>{_=!0},"onVersionDrift")}),_&&(this.log("[upgrade] Installed CLI version changed \u2014 restarting worker onto the new code."),await Promise.allSettled([g(2e3),m(),d()]),x(),process.exit(1))}finally{x(),await d()}}};export{w as default};
@@ -1,4 +1,4 @@
1
- import{b as w,c as $}from"../../chunk-ASQG7BTP.js";import"../../chunk-4Y54EMS6.js";import{b as v}from"../../chunk-KJRMGTAO.js";import"../../chunk-IS2AZIG7.js";import"../../chunk-M7QSC64D.js";import"../../chunk-DPCAPIQB.js";import"../../chunk-LB24UKHZ.js";import"../../chunk-G7V4ZZZ3.js";import"../../chunk-T67L2YTW.js";import"../../chunk-SD626JBZ.js";import"../../chunk-SVON2JIS.js";import"../../chunk-GN3ZHQ46.js";import"../../chunk-U2NT5OSQ.js";import"../../chunk-KGURGIZ2.js";import"../../chunk-UPFH72PF.js";import"../../chunk-BJSVATVJ.js";import"../../chunk-CDY7TQFZ.js";import"../../chunk-RIVEBBZC.js";import"../../chunk-QBNLZJIR.js";import"../../chunk-N7ODX6PO.js";import"../../chunk-PJ3WHQ67.js";import"../../chunk-VBXL7XO7.js";import"../../chunk-TZA4HAVF.js";import{a as f}from"../../chunk-65TQMBNF.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-6PUH7HEL.js";import"../../chunk-WRQEHXSN.js";import"../../chunk-YTPQ7VBO.js";import"../../chunk-3AV3GTMP.js";import{e as d,f as p,h}from"../../chunk-2AVGUZ2P.js";import"../../chunk-OOGTQOL3.js";import"../../chunk-PZNWH4VQ.js";import{a}from"../../chunk-ZLLER3HP.js";import{Args as P,Flags as y}from"@oclif/core";var c=a(s=>s==null?"n/a":`${Math.round(s*100)}%`,"pct"),g=class s extends f{static{a(this,"EvalRefineCases")}static description="Retire non-discriminating eval cases and regenerate discriminating replacements (\xA76e)";static examples=["<%= config.bin %> evals refine-cases <target-id> # preview","<%= config.bin %> evals refine-cases <target-id> --yes # apply: retire + regenerate","<%= config.bin %> evals refine-cases <target-id> --yes --no-generate"];static args={targetId:P.string({description:"Eval target ID",required:!0})};static flags={yes:y.boolean({char:"y",description:"Apply (retire + regenerate). Without this, only previews."}),"no-generate":y.boolean({description:"Retire dead cases but do not regenerate replacements."})};async run(){let{args:b,flags:l}=await this.parse(s);this.requireAuth();let n=b.targetId,o=await d(`/api/eval-targets/${n}`),m=await d(`/api/eval-targets/${n}/judge-calibration`),i=m.caseDiscrimination,t=w(i);if(this.log(`Target "${o.name}" v${o.version} \u2014 judge ${m.judge.currentModel??"(unstamped)"}`),t.refused==="no-discrimination-data"){this.log("No case-discrimination data yet \u2014 run some evals with AND without the target first (`evals run` / the web Run Evals button), then refine.");return}if(this.log(`${i.total} diagnosable case(s): ${i.discriminating} discriminate, ${i.nonDiscriminating} flat/wrong-sign, ${i.unpaired} unpaired.`),t.refused==="all-discriminating"){this.log("Every case discriminates \u2014 nothing to retire. \u{1F389}");return}let C=i.cases.filter(e=>!e.discriminating),u=new Set(t.retire.map(e=>e.evalId));this.log(`
1
+ import{b as w,c as $}from"../../chunk-LZJXW3B6.js";import"../../chunk-KHCMVYTH.js";import{b as v}from"../../chunk-KJRMGTAO.js";import"../../chunk-TZUTX4PG.js";import"../../chunk-M7QSC64D.js";import"../../chunk-DPCAPIQB.js";import"../../chunk-T67L2YTW.js";import"../../chunk-LB24UKHZ.js";import"../../chunk-G7V4ZZZ3.js";import"../../chunk-SD626JBZ.js";import"../../chunk-SVON2JIS.js";import"../../chunk-GN3ZHQ46.js";import"../../chunk-U2NT5OSQ.js";import"../../chunk-KGURGIZ2.js";import"../../chunk-UPFH72PF.js";import"../../chunk-BJSVATVJ.js";import"../../chunk-CDY7TQFZ.js";import"../../chunk-RIVEBBZC.js";import"../../chunk-QBNLZJIR.js";import"../../chunk-N7ODX6PO.js";import"../../chunk-PJ3WHQ67.js";import"../../chunk-VBXL7XO7.js";import"../../chunk-TZA4HAVF.js";import{a as f}from"../../chunk-65TQMBNF.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-6PUH7HEL.js";import"../../chunk-WRQEHXSN.js";import"../../chunk-YTPQ7VBO.js";import"../../chunk-3AV3GTMP.js";import{e as d,f as p,h}from"../../chunk-2AVGUZ2P.js";import"../../chunk-OOGTQOL3.js";import"../../chunk-PZNWH4VQ.js";import{a}from"../../chunk-ZLLER3HP.js";import{Args as P,Flags as y}from"@oclif/core";var c=a(s=>s==null?"n/a":`${Math.round(s*100)}%`,"pct"),g=class s extends f{static{a(this,"EvalRefineCases")}static description="Retire non-discriminating eval cases and regenerate discriminating replacements (\xA76e)";static examples=["<%= config.bin %> evals refine-cases <target-id> # preview","<%= config.bin %> evals refine-cases <target-id> --yes # apply: retire + regenerate","<%= config.bin %> evals refine-cases <target-id> --yes --no-generate"];static args={targetId:P.string({description:"Eval target ID",required:!0})};static flags={yes:y.boolean({char:"y",description:"Apply (retire + regenerate). Without this, only previews."}),"no-generate":y.boolean({description:"Retire dead cases but do not regenerate replacements."})};async run(){let{args:b,flags:l}=await this.parse(s);this.requireAuth();let n=b.targetId,o=await d(`/api/eval-targets/${n}`),m=await d(`/api/eval-targets/${n}/judge-calibration`),i=m.caseDiscrimination,t=w(i);if(this.log(`Target "${o.name}" v${o.version} \u2014 judge ${m.judge.currentModel??"(unstamped)"}`),t.refused==="no-discrimination-data"){this.log("No case-discrimination data yet \u2014 run some evals with AND without the target first (`evals run` / the web Run Evals button), then refine.");return}if(this.log(`${i.total} diagnosable case(s): ${i.discriminating} discriminate, ${i.nonDiscriminating} flat/wrong-sign, ${i.unpaired} unpaired.`),t.refused==="all-discriminating"){this.log("Every case discriminates \u2014 nothing to retire. \u{1F389}");return}let C=i.cases.filter(e=>!e.discriminating),u=new Set(t.retire.map(e=>e.evalId));this.log(`
2
2
  Would retire ${t.retire.length} non-discriminating case(s):`);for(let e of C)u.has(e.evalId)&&this.log(` \u2717 ${e.name} \u2014 ${c(e.withPassRate)} with vs ${c(e.withoutPassRate)} without (\u0394${(e.separation*100).toFixed(0)}pp) \u2014 ${e.note}`);for(let e of i.unpairedCases)u.has(e.evalId)&&this.log(` \u2717 ${e.name} \u2014 ${c(e.withPassRate)} with vs ${c(e.withoutPassRate)} without \u2014 unpaired`);if(t.replacementsRequired&&this.log(`
3
3
  ${t.summary}. Replacements are generated and created BEFORE anything is retired \u2014 a target left under the floor drops out of the nightly evolution rotation with no error anywhere.`),!l.yes){this.log(`
4
4
  Preview only. Re-run with --yes to retire ${t.retire.length} case(s)${l["no-generate"]?"":" and generate replacements"}.`);return}let r=await $(t,{generate:a(e=>l["no-generate"]?Promise.resolve([]):v({content:o.content,name:o.name,feedback:e}),"generate"),createCase:a(e=>p(`/api/eval-targets/${n}/evals`,{name:e.name,prompt:e.prompt,expectations:e.expectations}),"createCase"),retireCase:a(async(e,R)=>{await h(`/api/eval-targets/${n}/evals/${e}`,{retire:!0,retiredReason:R})},"retireCase"),log:a(e=>this.log(e),"log")});if(r.skipped==="no-llm-backend"){this.warn(r.summary+" Install the `claude` CLI (or set ANTHROPIC_API_KEY), then run `evals refine-cases` again.");return}if(r.skipped==="no-replacements-generated"){this.warn(r.summary);return}this.log(`
@@ -1 +1 @@
1
- import{e as a}from"../../chunk-NVKX36YN.js";import{b as n}from"../../chunk-OEZNBFJ2.js";import{a as s}from"../../chunk-65TQMBNF.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-6PUH7HEL.js";import"../../chunk-WRQEHXSN.js";import"../../chunk-YTPQ7VBO.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-2AVGUZ2P.js";import"../../chunk-OOGTQOL3.js";import"../../chunk-PZNWH4VQ.js";import{a as o}from"../../chunk-ZLLER3HP.js";import{Flags as d}from"@oclif/core";import l from"node:path";import u from"node:os";var i=class c extends s{static{o(this,"ResearchBackfill")}static description="Scan every ~/.claude/projects transcript for past rate-limit (429) events and POST them as observations. Opt-in seed for the usage-research dataset \u2014 forward-only tail is the default capture path.";static examples=["<%= config.bin %> research backfill","<%= config.bin %> research backfill --claude-dir /custom/.claude --dry-run"];static flags={"claude-dir":d.string({description:"Override the Claude Code projects directory",default:l.join(u.homedir(),".claude")}),"dry-run":d.boolean({description:"Print observation count without POSTing",default:!1})};async run(){let{flags:r}=await this.parse(c);this.requireAuth(),this.log(`Scanning ${l.join(r["claude-dir"],"projects")} for rate-limit events...`);let e=await a(r["claude-dir"]);if(this.log(`Found ${e.length} rate-limit observation(s).`),e.length===0)return;if(r["dry-run"]){this.log("Dry run \u2014 nothing posted.");return}let t=await n(e);if(this.log(`Posted ${t.posted} observation(s); ${t.failed} failed.`),t.failed>0)for(let f of t.errors)this.warn(f)}};export{i as default};
1
+ import{e as s}from"../../chunk-NVKX36YN.js";import{b as n}from"../../chunk-OEZNBFJ2.js";import{a}from"../../chunk-65TQMBNF.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-6PUH7HEL.js";import"../../chunk-WRQEHXSN.js";import"../../chunk-YTPQ7VBO.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-2AVGUZ2P.js";import"../../chunk-OOGTQOL3.js";import"../../chunk-PZNWH4VQ.js";import{a as o}from"../../chunk-ZLLER3HP.js";import{Flags as d}from"@oclif/core";import l from"node:path";import f from"node:os";var i=class c extends a{static{o(this,"ResearchBackfill")}static description="Scan every ~/.claude/projects transcript for past rate-limit (429) events and POST them as observations. Opt-in seed for the usage-research dataset \u2014 forward-only tail is the default capture path.";static examples=["<%= config.bin %> research backfill","<%= config.bin %> research backfill --claude-dir /custom/.claude --dry-run"];static flags={"claude-dir":d.string({description:"Override the Claude Code projects directory (defaults to ~/.claude)",default:l.join(f.homedir(),".claude"),noCacheDefault:!0}),"dry-run":d.boolean({description:"Print observation count without POSTing",default:!1})};async run(){let{flags:e}=await this.parse(c);this.requireAuth(),this.log(`Scanning ${l.join(e["claude-dir"],"projects")} for rate-limit events...`);let r=await s(e["claude-dir"]);if(this.log(`Found ${r.length} rate-limit observation(s).`),r.length===0)return;if(e["dry-run"]){this.log("Dry run \u2014 nothing posted.");return}let t=await n(r);if(this.log(`Posted ${t.posted} observation(s); ${t.failed} failed.`),t.failed>0)for(let u of t.errors)this.warn(u)}};export{i as default};
@@ -1 +1 @@
1
- import{a,b,c,d,e}from"../chunk-2WTCH4RR.js";import"../chunk-FNMJ6E6F.js";import"../chunk-IEQDLURA.js";import"../chunk-PMW35N32.js";import"../chunk-ZQJWKIJS.js";import"../chunk-LDQ6FLET.js";import"../chunk-J35L3LR3.js";import"../chunk-RFISMWRW.js";import"../chunk-ZYGBABMZ.js";import"../chunk-2MZFB46B.js";import"../chunk-PZS55PW2.js";import"../chunk-YRTG6SX6.js";import"../chunk-3ZHVP3KE.js";import"../chunk-NMWP3JLW.js";import"../chunk-HOQPVOMF.js";import"../chunk-2IEYDOFE.js";import"../chunk-FIPW2SGV.js";import"../chunk-LYP3LNFL.js";import"../chunk-Y6TAPCA5.js";import"../chunk-5RBLIVBF.js";import"../chunk-5BTNALJL.js";import"../chunk-4XLMX642.js";import"../chunk-RK2LZIBA.js";import"../chunk-6LJD6TXN.js";import"../chunk-CRPOQMQ2.js";import"../chunk-3UKZJAFS.js";import"../chunk-MOY7XDR6.js";import"../chunk-SJKS3PYX.js";import"../chunk-E7N5R3HV.js";import"../chunk-K6T4ODPZ.js";import"../chunk-XFAFMYIP.js";import"../chunk-GIRPEMTW.js";import"../chunk-PQMWZHEY.js";import"../chunk-OCHAV6YZ.js";import"../chunk-LVAROIKP.js";import"../chunk-D4UDSY7Y.js";import"../chunk-E7XOYGL5.js";import"../chunk-TJYXSMQV.js";import"../chunk-LJRE3LZ2.js";import"../chunk-ASQG7BTP.js";import"../chunk-4Y54EMS6.js";import"../chunk-KJRMGTAO.js";import"../chunk-UQSUSB6G.js";import"../chunk-6UEFCMR2.js";import"../chunk-MODXEGCU.js";import"../chunk-RBSEE2Z6.js";import"../chunk-AFYZYXQ3.js";import"../chunk-IS2AZIG7.js";import"../chunk-M7QSC64D.js";import"../chunk-DPCAPIQB.js";import"../chunk-LB24UKHZ.js";import"../chunk-G7V4ZZZ3.js";import"../chunk-T67L2YTW.js";import"../chunk-SD626JBZ.js";import"../chunk-NF2BIEAF.js";import"../chunk-3QXRLIGC.js";import"../chunk-HFGO5762.js";import"../chunk-SVON2JIS.js";import"../chunk-GN3ZHQ46.js";import"../chunk-U2NT5OSQ.js";import"../chunk-KGURGIZ2.js";import"../chunk-UPFH72PF.js";import"../chunk-BJSVATVJ.js";import"../chunk-CDY7TQFZ.js";import"../chunk-RIVEBBZC.js";import"../chunk-QBNLZJIR.js";import"../chunk-N7ODX6PO.js";import"../chunk-PJ3WHQ67.js";import"../chunk-VBXL7XO7.js";import"../chunk-TZA4HAVF.js";import"../chunk-2AVGUZ2P.js";import"../chunk-OOGTQOL3.js";import"../chunk-PZNWH4VQ.js";import"../chunk-ZLLER3HP.js";export{b as CAPABILITIES,a as HANDLERS,c as availableCapabilities,d as pollForWork,e as runAgentLoop};
1
+ import{a,b,c,d,e}from"../chunk-D55QB3QI.js";import"../chunk-FNMJ6E6F.js";import"../chunk-IEQDLURA.js";import"../chunk-LYP3LNFL.js";import"../chunk-Y6TAPCA5.js";import"../chunk-PMW35N32.js";import"../chunk-ZQJWKIJS.js";import"../chunk-LDQ6FLET.js";import"../chunk-J35L3LR3.js";import"../chunk-RFISMWRW.js";import"../chunk-ZYGBABMZ.js";import"../chunk-5RBLIVBF.js";import"../chunk-2MZFB46B.js";import"../chunk-5C3DRKW3.js";import"../chunk-CRPOQMQ2.js";import"../chunk-PZS55PW2.js";import"../chunk-YRTG6SX6.js";import"../chunk-3ZHVP3KE.js";import"../chunk-NMWP3JLW.js";import"../chunk-HOQPVOMF.js";import"../chunk-2IEYDOFE.js";import"../chunk-FIPW2SGV.js";import"../chunk-5BTNALJL.js";import"../chunk-4XLMX642.js";import"../chunk-RK2LZIBA.js";import"../chunk-2K3RUBKC.js";import"../chunk-3UKZJAFS.js";import"../chunk-MOY7XDR6.js";import"../chunk-SJKS3PYX.js";import"../chunk-E7N5R3HV.js";import"../chunk-K6T4ODPZ.js";import"../chunk-XFAFMYIP.js";import"../chunk-GIRPEMTW.js";import"../chunk-QUOH6GWM.js";import"../chunk-PQMWZHEY.js";import"../chunk-OCHAV6YZ.js";import"../chunk-LVAROIKP.js";import"../chunk-D4UDSY7Y.js";import"../chunk-E7XOYGL5.js";import"../chunk-TJYXSMQV.js";import"../chunk-LJRE3LZ2.js";import"../chunk-LZJXW3B6.js";import"../chunk-KHCMVYTH.js";import"../chunk-KJRMGTAO.js";import"../chunk-UQSUSB6G.js";import"../chunk-6UEFCMR2.js";import"../chunk-MODXEGCU.js";import"../chunk-RBSEE2Z6.js";import"../chunk-AFYZYXQ3.js";import"../chunk-TZUTX4PG.js";import"../chunk-M7QSC64D.js";import"../chunk-DPCAPIQB.js";import"../chunk-T67L2YTW.js";import"../chunk-LB24UKHZ.js";import"../chunk-G7V4ZZZ3.js";import"../chunk-SD626JBZ.js";import"../chunk-NF2BIEAF.js";import"../chunk-3QXRLIGC.js";import"../chunk-HFGO5762.js";import"../chunk-SVON2JIS.js";import"../chunk-GN3ZHQ46.js";import"../chunk-U2NT5OSQ.js";import"../chunk-KGURGIZ2.js";import"../chunk-UPFH72PF.js";import"../chunk-BJSVATVJ.js";import"../chunk-CDY7TQFZ.js";import"../chunk-RIVEBBZC.js";import"../chunk-QBNLZJIR.js";import"../chunk-N7ODX6PO.js";import"../chunk-PJ3WHQ67.js";import"../chunk-VBXL7XO7.js";import"../chunk-TZA4HAVF.js";import"../chunk-2AVGUZ2P.js";import"../chunk-OOGTQOL3.js";import"../chunk-PZNWH4VQ.js";import"../chunk-ZLLER3HP.js";export{b as CAPABILITIES,a as HANDLERS,c as availableCapabilities,d as pollForWork,e as runAgentLoop};
@@ -0,0 +1 @@
1
+ import{a,b,c}from"../chunk-QUOH6GWM.js";import"../chunk-ZLLER3HP.js";export{a as defaultRecoveryEnv,b as findClaudeCodeCwd,c as recoverAnchors};
@@ -1 +1 @@
1
- import{a,b,c}from"../chunk-4Y54EMS6.js";import"../chunk-IS2AZIG7.js";import"../chunk-M7QSC64D.js";import"../chunk-DPCAPIQB.js";import"../chunk-LB24UKHZ.js";import"../chunk-G7V4ZZZ3.js";import"../chunk-T67L2YTW.js";import"../chunk-SD626JBZ.js";import"../chunk-SVON2JIS.js";import"../chunk-GN3ZHQ46.js";import"../chunk-U2NT5OSQ.js";import"../chunk-KGURGIZ2.js";import"../chunk-UPFH72PF.js";import"../chunk-BJSVATVJ.js";import"../chunk-CDY7TQFZ.js";import"../chunk-RIVEBBZC.js";import"../chunk-QBNLZJIR.js";import"../chunk-N7ODX6PO.js";import"../chunk-PJ3WHQ67.js";import"../chunk-VBXL7XO7.js";import"../chunk-TZA4HAVF.js";import"../chunk-2AVGUZ2P.js";import"../chunk-OOGTQOL3.js";import"../chunk-PZNWH4VQ.js";import"../chunk-ZLLER3HP.js";export{b as MIN_LIVE_CASES,c as RULE_ENROLMENT_CAP_PER_USER,a as minFeasibleLiveCases};
1
+ import{a,b,c}from"../chunk-KHCMVYTH.js";import"../chunk-TZUTX4PG.js";import"../chunk-M7QSC64D.js";import"../chunk-DPCAPIQB.js";import"../chunk-T67L2YTW.js";import"../chunk-LB24UKHZ.js";import"../chunk-G7V4ZZZ3.js";import"../chunk-SD626JBZ.js";import"../chunk-SVON2JIS.js";import"../chunk-GN3ZHQ46.js";import"../chunk-U2NT5OSQ.js";import"../chunk-KGURGIZ2.js";import"../chunk-UPFH72PF.js";import"../chunk-BJSVATVJ.js";import"../chunk-CDY7TQFZ.js";import"../chunk-RIVEBBZC.js";import"../chunk-QBNLZJIR.js";import"../chunk-N7ODX6PO.js";import"../chunk-PJ3WHQ67.js";import"../chunk-VBXL7XO7.js";import"../chunk-TZA4HAVF.js";import"../chunk-2AVGUZ2P.js";import"../chunk-OOGTQOL3.js";import"../chunk-PZNWH4VQ.js";import"../chunk-ZLLER3HP.js";export{b as MIN_LIVE_CASES,c as RULE_ENROLMENT_CAP_PER_USER,a as minFeasibleLiveCases};
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m}from"../../../chunk-IS2AZIG7.js";import"../../../chunk-M7QSC64D.js";import"../../../chunk-DPCAPIQB.js";import"../../../chunk-LB24UKHZ.js";import"../../../chunk-G7V4ZZZ3.js";import"../../../chunk-T67L2YTW.js";import"../../../chunk-SD626JBZ.js";import"../../../chunk-SVON2JIS.js";import"../../../chunk-GN3ZHQ46.js";import"../../../chunk-U2NT5OSQ.js";import"../../../chunk-KGURGIZ2.js";import"../../../chunk-UPFH72PF.js";import"../../../chunk-BJSVATVJ.js";import"../../../chunk-CDY7TQFZ.js";import"../../../chunk-RIVEBBZC.js";import"../../../chunk-QBNLZJIR.js";import"../../../chunk-N7ODX6PO.js";import"../../../chunk-PJ3WHQ67.js";import"../../../chunk-VBXL7XO7.js";import"../../../chunk-TZA4HAVF.js";import"../../../chunk-2AVGUZ2P.js";import"../../../chunk-OOGTQOL3.js";import"../../../chunk-PZNWH4VQ.js";import"../../../chunk-ZLLER3HP.js";export{f as DEFAULT_ACCUMULATE_TARGET_PAIRS,b as MAX_PASSES,c as MAX_PASSES_CEILING,h as MAX_PRIOR_DECISIONS,a as PAIR_HEADROOM,l as cronInstructionEvolution,g as findOpenAccumulation,d as passCapFor,e as planPasses,j as readAccumulateConfig,m as readImmutableSections,k as resolveApply,i as summarisePriorDecisions};
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m}from"../../../chunk-TZUTX4PG.js";import"../../../chunk-M7QSC64D.js";import"../../../chunk-DPCAPIQB.js";import"../../../chunk-T67L2YTW.js";import"../../../chunk-LB24UKHZ.js";import"../../../chunk-G7V4ZZZ3.js";import"../../../chunk-SD626JBZ.js";import"../../../chunk-SVON2JIS.js";import"../../../chunk-GN3ZHQ46.js";import"../../../chunk-U2NT5OSQ.js";import"../../../chunk-KGURGIZ2.js";import"../../../chunk-UPFH72PF.js";import"../../../chunk-BJSVATVJ.js";import"../../../chunk-CDY7TQFZ.js";import"../../../chunk-RIVEBBZC.js";import"../../../chunk-QBNLZJIR.js";import"../../../chunk-N7ODX6PO.js";import"../../../chunk-PJ3WHQ67.js";import"../../../chunk-VBXL7XO7.js";import"../../../chunk-TZA4HAVF.js";import"../../../chunk-2AVGUZ2P.js";import"../../../chunk-OOGTQOL3.js";import"../../../chunk-PZNWH4VQ.js";import"../../../chunk-ZLLER3HP.js";export{f as DEFAULT_ACCUMULATE_TARGET_PAIRS,b as MAX_PASSES,c as MAX_PASSES_CEILING,h as MAX_PRIOR_DECISIONS,a as PAIR_HEADROOM,l as cronInstructionEvolution,g as findOpenAccumulation,d as passCapFor,e as planPasses,j as readAccumulateConfig,m as readImmutableSections,k as resolveApply,i as summarisePriorDecisions};
@@ -0,0 +1 @@
1
+ import{a}from"../../../chunk-2K3RUBKC.js";import"../../../chunk-QUOH6GWM.js";import"../../../chunk-2AVGUZ2P.js";import"../../../chunk-OOGTQOL3.js";import"../../../chunk-PZNWH4VQ.js";import"../../../chunk-ZLLER3HP.js";export{a as cronReconcileAttribution};
@@ -1 +1 @@
1
- import{a}from"../../../chunk-6LJD6TXN.js";import"../../../chunk-ASQG7BTP.js";import"../../../chunk-4Y54EMS6.js";import"../../../chunk-KJRMGTAO.js";import"../../../chunk-IS2AZIG7.js";import"../../../chunk-M7QSC64D.js";import"../../../chunk-DPCAPIQB.js";import"../../../chunk-LB24UKHZ.js";import"../../../chunk-G7V4ZZZ3.js";import"../../../chunk-T67L2YTW.js";import"../../../chunk-SD626JBZ.js";import"../../../chunk-SVON2JIS.js";import"../../../chunk-GN3ZHQ46.js";import"../../../chunk-U2NT5OSQ.js";import"../../../chunk-KGURGIZ2.js";import"../../../chunk-UPFH72PF.js";import"../../../chunk-BJSVATVJ.js";import"../../../chunk-CDY7TQFZ.js";import"../../../chunk-RIVEBBZC.js";import"../../../chunk-QBNLZJIR.js";import"../../../chunk-N7ODX6PO.js";import"../../../chunk-PJ3WHQ67.js";import"../../../chunk-VBXL7XO7.js";import"../../../chunk-TZA4HAVF.js";import"../../../chunk-2AVGUZ2P.js";import"../../../chunk-OOGTQOL3.js";import"../../../chunk-PZNWH4VQ.js";import"../../../chunk-ZLLER3HP.js";export{a as cronRefineCases};
1
+ import{a}from"../../../chunk-5C3DRKW3.js";import"../../../chunk-LZJXW3B6.js";import"../../../chunk-KHCMVYTH.js";import"../../../chunk-KJRMGTAO.js";import"../../../chunk-TZUTX4PG.js";import"../../../chunk-M7QSC64D.js";import"../../../chunk-DPCAPIQB.js";import"../../../chunk-T67L2YTW.js";import"../../../chunk-LB24UKHZ.js";import"../../../chunk-G7V4ZZZ3.js";import"../../../chunk-SD626JBZ.js";import"../../../chunk-SVON2JIS.js";import"../../../chunk-GN3ZHQ46.js";import"../../../chunk-U2NT5OSQ.js";import"../../../chunk-KGURGIZ2.js";import"../../../chunk-UPFH72PF.js";import"../../../chunk-BJSVATVJ.js";import"../../../chunk-CDY7TQFZ.js";import"../../../chunk-RIVEBBZC.js";import"../../../chunk-QBNLZJIR.js";import"../../../chunk-N7ODX6PO.js";import"../../../chunk-PJ3WHQ67.js";import"../../../chunk-VBXL7XO7.js";import"../../../chunk-TZA4HAVF.js";import"../../../chunk-2AVGUZ2P.js";import"../../../chunk-OOGTQOL3.js";import"../../../chunk-PZNWH4VQ.js";import"../../../chunk-ZLLER3HP.js";export{a as cronRefineCases};
@@ -1 +1 @@
1
- import{a}from"../chunk-GY5IJ4RS.js";import"../chunk-ZLLER3HP.js";export{a as MANUAL_TASK_META};
1
+ import{a}from"../chunk-APXQLQZY.js";import"../chunk-ZLLER3HP.js";export{a as MANUAL_TASK_META};
@@ -1 +1 @@
1
- import{a as l}from"../chunk-QLG6OCYF.js";import"../chunk-LUCVMLHV.js";import{a as u}from"../chunk-PZS55PW2.js";import{e as g}from"../chunk-NMWP3JLW.js";import"../chunk-HOQPVOMF.js";import"../chunk-GIRPEMTW.js";import"../chunk-MODXEGCU.js";import{a as i}from"../chunk-GY5IJ4RS.js";import"../chunk-QBNLZJIR.js";import"../chunk-N7ODX6PO.js";import"../chunk-PJ3WHQ67.js";import"../chunk-2AVGUZ2P.js";import"../chunk-OOGTQOL3.js";import"../chunk-PZNWH4VQ.js";import{a as o}from"../chunk-ZLLER3HP.js";var c={cron_check_changelog:o(async(r,e)=>{let s=await l({logger:{info:o(t=>e.logger.info(t),"info"),warn:o(t=>e.logger.warn(t),"warn")}});e.logger.info(`[cron_check_changelog] result: created=${s.createdCount} skipped=${s.skippedCount}`)},"cron_check_changelog"),cron_suggest_instructions:o((r,e)=>g(r,e),"cron_suggest_instructions"),cron_refresh_skills:o((r,e)=>u(r,e),"cron_refresh_skills")},p=i.map(r=>{let e=c[r.name];if(!e)throw new Error(`manual-tasks: no handler registered for "${r.name}"`);return{...r,handler:e}});async function m(r){let e=p.find(n=>n.name===r);if(!e)return{name:r,durationMs:0,ok:!1,error:`Unknown task: ${r}`,logs:[]};let s=[],t={logger:{info:o(n=>s.push({level:"info",message:n}),"info"),warn:o(n=>s.push({level:"warn",message:n}),"warn"),error:o(n=>s.push({level:"error",message:n}),"error")},job:{attempts:0}},a=Date.now();try{return await e.handler({},t),{name:r,durationMs:Date.now()-a,ok:!0,logs:s}}catch(n){return{name:r,durationMs:Date.now()-a,ok:!1,error:n instanceof Error?n.message:String(n),logs:s}}}o(m,"runManualTask");export{p as MANUAL_TASKS,m as runManualTask};
1
+ import{a as l}from"../chunk-QLG6OCYF.js";import"../chunk-LUCVMLHV.js";import{a as u}from"../chunk-PZS55PW2.js";import{e as c}from"../chunk-NMWP3JLW.js";import"../chunk-HOQPVOMF.js";import{a as g}from"../chunk-2K3RUBKC.js";import"../chunk-GIRPEMTW.js";import"../chunk-QUOH6GWM.js";import"../chunk-MODXEGCU.js";import{a as i}from"../chunk-APXQLQZY.js";import"../chunk-QBNLZJIR.js";import"../chunk-N7ODX6PO.js";import"../chunk-PJ3WHQ67.js";import"../chunk-2AVGUZ2P.js";import"../chunk-OOGTQOL3.js";import"../chunk-PZNWH4VQ.js";import{a as o}from"../chunk-ZLLER3HP.js";var f={cron_check_changelog:o(async(r,n)=>{let t=await l({logger:{info:o(s=>n.logger.info(s),"info"),warn:o(s=>n.logger.warn(s),"warn")}});n.logger.info(`[cron_check_changelog] result: created=${t.createdCount} skipped=${t.skippedCount}`)},"cron_check_changelog"),cron_suggest_instructions:o((r,n)=>c(r,n),"cron_suggest_instructions"),cron_reconcile_attribution:o((r,n)=>g(r,n).then(()=>{}),"cron_reconcile_attribution"),cron_refresh_skills:o((r,n)=>u(r,n),"cron_refresh_skills")},p=i.map(r=>{let n=f[r.name];if(!n)throw new Error(`manual-tasks: no handler registered for "${r.name}"`);return{...r,handler:n}});async function w(r){let n=p.find(e=>e.name===r);if(!n)return{name:r,durationMs:0,ok:!1,error:`Unknown task: ${r}`,logs:[]};let t=[],s={logger:{info:o(e=>t.push({level:"info",message:e}),"info"),warn:o(e=>t.push({level:"warn",message:e}),"warn"),error:o(e=>t.push({level:"error",message:e}),"error")},job:{attempts:0}},a=Date.now();try{return await n.handler({},s),{name:r,durationMs:Date.now()-a,ok:!0,logs:t}}catch(e){return{name:r,durationMs:Date.now()-a,ok:!1,error:e instanceof Error?e.message:String(e),logs:t}}}o(w,"runManualTask");export{p as MANUAL_TASKS,w as runManualTask};
@@ -1 +1 @@
1
- import{a,b,c}from"../chunk-ASQG7BTP.js";import"../chunk-4Y54EMS6.js";import"../chunk-IS2AZIG7.js";import"../chunk-M7QSC64D.js";import"../chunk-DPCAPIQB.js";import"../chunk-LB24UKHZ.js";import"../chunk-G7V4ZZZ3.js";import"../chunk-T67L2YTW.js";import"../chunk-SD626JBZ.js";import"../chunk-SVON2JIS.js";import"../chunk-GN3ZHQ46.js";import"../chunk-U2NT5OSQ.js";import"../chunk-KGURGIZ2.js";import"../chunk-UPFH72PF.js";import"../chunk-BJSVATVJ.js";import"../chunk-CDY7TQFZ.js";import"../chunk-RIVEBBZC.js";import"../chunk-QBNLZJIR.js";import"../chunk-N7ODX6PO.js";import"../chunk-PJ3WHQ67.js";import"../chunk-VBXL7XO7.js";import"../chunk-TZA4HAVF.js";import"../chunk-2AVGUZ2P.js";import"../chunk-OOGTQOL3.js";import"../chunk-PZNWH4VQ.js";import"../chunk-ZLLER3HP.js";export{a as MAX_RETIREMENTS_PER_REFINEMENT,c as executeCaseRefinement,b as planCaseRefinement};
1
+ import{a,b,c}from"../chunk-LZJXW3B6.js";import"../chunk-KHCMVYTH.js";import"../chunk-TZUTX4PG.js";import"../chunk-M7QSC64D.js";import"../chunk-DPCAPIQB.js";import"../chunk-T67L2YTW.js";import"../chunk-LB24UKHZ.js";import"../chunk-G7V4ZZZ3.js";import"../chunk-SD626JBZ.js";import"../chunk-SVON2JIS.js";import"../chunk-GN3ZHQ46.js";import"../chunk-U2NT5OSQ.js";import"../chunk-KGURGIZ2.js";import"../chunk-UPFH72PF.js";import"../chunk-BJSVATVJ.js";import"../chunk-CDY7TQFZ.js";import"../chunk-RIVEBBZC.js";import"../chunk-QBNLZJIR.js";import"../chunk-N7ODX6PO.js";import"../chunk-PJ3WHQ67.js";import"../chunk-VBXL7XO7.js";import"../chunk-TZA4HAVF.js";import"../chunk-2AVGUZ2P.js";import"../chunk-OOGTQOL3.js";import"../chunk-PZNWH4VQ.js";import"../chunk-ZLLER3HP.js";export{a as MAX_RETIREMENTS_PER_REFINEMENT,c as executeCaseRefinement,b as planCaseRefinement};
@@ -3593,9 +3593,9 @@
3593
3593
  "type": "option"
3594
3594
  },
3595
3595
  "claude-dir": {
3596
- "description": "Override the Claude Code projects directory",
3596
+ "description": "Override the Claude Code projects directory (defaults to ~/.claude)",
3597
3597
  "name": "claude-dir",
3598
- "default": "/home/runner/.claude",
3598
+ "noCacheDefault": true,
3599
3599
  "hasDynamicHelp": false,
3600
3600
  "multiple": false,
3601
3601
  "type": "option"
@@ -4787,5 +4787,5 @@
4787
4787
  ]
4788
4788
  }
4789
4789
  },
4790
- "version": "0.12.3"
4790
+ "version": "0.12.4"
4791
4791
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulemetric/cli",
3
- "version": "0.12.3",
3
+ "version": "0.12.4",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -80,9 +80,9 @@
80
80
  "postgres": "^3.4.0",
81
81
  "react": "^19.0.0",
82
82
  "zod": "^3.24.0",
83
- "@rulemetric/hooks": "0.12.3",
84
- "@rulemetric/proxy": "0.12.3",
85
- "@rulemetric/skills-registry": "0.12.3"
83
+ "@rulemetric/hooks": "0.12.4",
84
+ "@rulemetric/proxy": "0.12.4",
85
+ "@rulemetric/skills-registry": "0.12.4"
86
86
  },
87
87
  "//deps": "Worker (`evals agent`) runtime deps: the @opentelemetry/* set, @sentry/node, and postgres are STATIC top-level imports loaded at worker startup (via bundled @rulemetric/{telemetry,db}) — they MUST be runtime deps or a clean `npm i -g` crashes with ModuleLoadError. `better-sqlite3` is optionalDependencies (below): it's a native module, lazy `require()`'d inside a try/catch (packages/session providers cursor/opencode) so a missing binary degrades gracefully — making it a hard dep would break `npm i -g` on platforms without prebuilt binaries. `resend` stays a devDep: lazy `await import('resend')` guarded by RESEND_API_KEY, which end-user workers never set (provider falls back to noop). Classification verified via import-graph scan of dist/commands/evals/agent.js + per-importer static/lazy check.",
88
88
  "optionalDependencies": {
@@ -103,13 +103,13 @@
103
103
  "typescript": "^5.9.0",
104
104
  "vitest": "^3.2.0",
105
105
  "@rulemetric/api": "0.0.1",
106
+ "@rulemetric/core": "0.0.1",
106
107
  "@rulemetric/db": "0.0.1",
107
108
  "@rulemetric/effectiveness": "0.0.1",
108
109
  "@rulemetric/email": "0.0.1",
109
- "@rulemetric/core": "0.0.1",
110
- "@rulemetric/telemetry": "0.0.1",
110
+ "@rulemetric/session": "0.2.1",
111
111
  "@rulemetric/typescript-config": "0.0.0",
112
- "@rulemetric/session": "0.2.1"
112
+ "@rulemetric/telemetry": "0.0.1"
113
113
  },
114
114
  "scripts": {
115
115
  "build": "node scripts/build.mjs",
@@ -1 +0,0 @@
1
- import{c as K}from"./chunk-FNMJ6E6F.js";import{b as G}from"./chunk-IEQDLURA.js";import{a as W}from"./chunk-PMW35N32.js";import{b as L}from"./chunk-ZQJWKIJS.js";import{a as D}from"./chunk-LDQ6FLET.js";import{a as V}from"./chunk-J35L3LR3.js";import{a as P}from"./chunk-ZYGBABMZ.js";import{a as x}from"./chunk-2MZFB46B.js";import{a as y}from"./chunk-PZS55PW2.js";import{a as U}from"./chunk-YRTG6SX6.js";import{e as S}from"./chunk-NMWP3JLW.js";import{b as C}from"./chunk-2IEYDOFE.js";import{a as N}from"./chunk-FIPW2SGV.js";import{a as T}from"./chunk-LYP3LNFL.js";import{a as M}from"./chunk-Y6TAPCA5.js";import{b as R}from"./chunk-5RBLIVBF.js";import{a as $}from"./chunk-5BTNALJL.js";import{a as O}from"./chunk-4XLMX642.js";import{a as F}from"./chunk-RK2LZIBA.js";import{a as J}from"./chunk-6LJD6TXN.js";import{a as B}from"./chunk-CRPOQMQ2.js";import{l as H}from"./chunk-IS2AZIG7.js";import{d as A}from"./chunk-NF2BIEAF.js";import{b as E,e as I,f as _}from"./chunk-2AVGUZ2P.js";import{a}from"./chunk-ZLLER3HP.js";var Z={process_eval:T,process_insights:M,process_launch:L,process_send_message:P,process_conversation:N,process_session_goal:x,distill_memories:C,memory_ab:D,process_run_cleanup:V,cron_refine_cases:J,cron_retire_unused_skills:U,cron_suggest_instructions:S,cron_refresh_skills:y,cron_refresh_pricing:B,cron_eval_autorun:O,cron_auto_accept_suggestions:$,cron_instruction_training:F,cron_instruction_evolution:H,process_judge_review:W},q=Object.keys(Z),ee=new Set([]);function ne(e=process.env){return e.DATABASE_URL?q:q.filter(n=>!ee.has(n))}a(ne,"availableCapabilities");var re=3e4,te=3e4,oe=3e4,Q=500,X=1e4,se=`thin-agent-${process.pid}`,b=null;function ae(e,n,r,c){let i;try{let u=A();i={claude:u.claudeBin!=null,codex:u.codexBin!=null,codexModel:u.codexConfiguredModel}}catch{}let m=a(u=>{_("/api/workers/heartbeat",{workerType:"cli-worker",clientName:se,clientVersion:c,workerVersion:"0.1.0",currentJobId:null,inFlightCount:0,lastError:null,status:u,metadata:{capabilities:e,mode:"thin-agent",llmEngines:i}}).then(d=>{let l=d?.advisory;l&&l.message!==b?(b=l.message,s(r,{event:"worker_advisory",code:l.code,message:l.message})):l||(b=null)}).catch(d=>{s(r,{event:"presence_heartbeat_error",error:d instanceof Error?d.message:String(d)})})},"send");m("alive");let o=setInterval(()=>m("alive"),oe);n.addEventListener("abort",()=>{clearInterval(o),m("shutting_down")},{once:!0})}a(ae,"startPresenceHeartbeat");function s(e,n){try{e(JSON.stringify({ts:new Date().toISOString(),...n}))}catch{e(`[agent-loop] log_error event=${n.event}`)}}a(s,"structuredLog");function Y(e,n){return n.aborted?Promise.resolve(!1):e<=0?Promise.resolve(!0):new Promise(r=>{let c=setTimeout(()=>{n.removeEventListener("abort",i),r(!0)},e),i=a(()=>{clearTimeout(c),n.removeEventListener("abort",i),r(!1)},"onAbort");n.addEventListener("abort",i,{once:!0})})}a(Y,"abortableSleep");async function ie(e,n){let r=`capabilities=${encodeURIComponent(e.join(","))}&waitMs=${n}`,c=await I(`/api/work/next?${r}`);return c==null||typeof c=="string"?null:c}a(ie,"pollForWork");function le(e,n){return{logger:{info:a(r=>n(r),"info"),warn:a(r=>n(r),"warn"),error:a(r=>n(r),"error")},job:{attempts:e}}}a(le,"makeHelpers");async function ce(e,n,r){let c=Z[e.kind],i=Date.now();if(s(r,{event:"claim",jobId:e.id,kind:e.kind,attempts:e.attempts}),!c){let o=`unknown kind: ${e.kind}`;s(r,{event:"fail",jobId:e.id,kind:e.kind,terminal:!0,error:o}),await _(`/api/work/${e.id}/fail`,{leaseToken:e.leaseToken,error:o,terminal:!0}).catch(()=>{});return}let m=setInterval(()=>{s(r,{event:"heartbeat",jobId:e.id}),_(`/api/work/${e.id}/heartbeat`,{leaseToken:e.leaseToken}).catch(o=>{s(r,{event:"heartbeat_error",jobId:e.id,error:o instanceof Error?o.message:String(o)})})},n);try{let o=le(e.attempts,r),u=await c(e.payload,o)??{};clearInterval(m),s(r,{event:"complete",jobId:e.id,kind:e.kind,durationMs:Date.now()-i}),await _(`/api/work/${e.id}/complete`,{leaseToken:e.leaseToken,result:u})}catch(o){clearInterval(m);let u=R(o),d=o instanceof Error?o.message:String(o);s(r,{event:"fail",jobId:e.id,kind:e.kind,durationMs:Date.now()-i,terminal:u,error:d}),await _(`/api/work/${e.id}/fail`,{leaseToken:e.leaseToken,error:d,terminal:u}).catch(l=>{s(r,{event:"fail_post_error",jobId:e.id,error:l instanceof Error?l.message:String(l)})})}}a(ce,"runOne");var z=new Set(["process_eval","process_conversation","process_insights","process_session_goal","distill_memories","memory_ab","cron_suggest_instructions","cron_eval_autorun","cron_instruction_evolution","process_judge_review"]);async function Ce(e){let n=e.log??(()=>{}),r=e.pollWaitMs??re,c=e.heartbeatIntervalMs??te,i=e.capabilities??ne();s(n,{event:"agent_start",capabilities:i,pollWaitMs:r,heartbeatIntervalMs:c});try{let t=G();t.removed.length>0&&s(n,{event:"eval_worktrees_swept",removed:t.removed.length})}catch(t){s(n,{event:"eval_worktree_sweep_failed",error:t instanceof Error?t.message:String(t)})}ae(i,e.signal,n,e.version),K({signal:e.signal,log:n}).catch(t=>{s(n,{event:"tt_heartbeat_fatal",error:t instanceof Error?t.message:String(t)})});let m=5*6e4,o=0,u=a(()=>{if(!e.readInstalledVersion||!e.version)return!1;let t=Date.now();if(t-o<m)return!1;o=t;let f=e.readInstalledVersion();return!!(f&&f!==e.version)},"versionDrifted"),d=new AbortController,l=d.signal;e.signal.aborted?d.abort():e.signal.addEventListener("abort",()=>d.abort(),{once:!0});let v=a(async(t,f)=>{let g=Q;for(;!l.aborted;){if(u()){s(n,{event:"agent_version_drift",bootVersion:e.version,installedVersion:e.readInstalledVersion?.()??null}),d.abort(),e.onVersionDrift?.();break}let h=null;try{h=await ie([...f],r)}catch(p){let j=p instanceof E?p.statusCode:void 0;if(s(n,{event:"poll_error",lane:t,status:j,error:p instanceof Error?p.message:String(p)}),!await Y(g,l))break;g=Math.min(g*2,X);continue}if(!h){if(s(n,{event:"poll_204",lane:t}),!await Y(g,l))break;g=Math.min(g*2,X);continue}g=Q,await ce(h,c,n)}},"runLane"),k=i.filter(t=>z.has(t)),w=i.filter(t=>!z.has(t));k.length>0&&w.length>0?(s(n,{event:"agent_lanes",heavy:k.length,fast:w.length}),await Promise.all([v("heavy",k),v("fast",w)])):await v("single",i),s(n,{event:"agent_stop"})}a(Ce,"runAgentLoop");export{Z as a,q as b,ne as c,ie as d,Ce as e};
@@ -1 +0,0 @@
1
- var e=[{name:"cron_check_changelog",description:"Parse CHANGELOG.md and create draft announcement rows for new versions.",scheduledBy:"manual only \u2014 announcement drafts are reminder-driven, never scheduled"},{name:"cron_suggest_instructions",description:"Precompute per-project instruction suggestions for the SessionStart hook.",scheduledBy:"Supabase pg_cron daily 04:30 UTC \u2192 agent_jobs \u2192 agent loop (migration 00083)"},{name:"cron_refresh_skills",description:"Refresh the skills registry from GitHub sources (disk JSON + public instructions sync). Requires GITHUB_TOKEN.",scheduledBy:"Supabase pg_cron daily 03:30 UTC \u2192 agent_jobs \u2192 agent loop (migration 00086)"}];export{e as a};