@rulemetric/cli 0.20.0 → 0.21.0

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.
Files changed (70) hide show
  1. package/bin/dev.js +0 -0
  2. package/dist/{chunk-RAOV3MFF.js → chunk-254I3NH2.js} +1 -1
  3. package/dist/{chunk-KUD7LWJJ.js → chunk-2EXQM3UF.js} +1 -1
  4. package/dist/{chunk-LDFGM37E.js → chunk-4K3MVOVQ.js} +2 -2
  5. package/dist/{chunk-4W5BF4ZN.js → chunk-5JYK5HWH.js} +1 -1
  6. package/dist/chunk-A4YGEMXC.js +1 -0
  7. package/dist/{chunk-K2PI3OGV.js → chunk-D6B2DJE6.js} +1 -1
  8. package/dist/{chunk-IULEYP4V.js → chunk-DRX65ZLX.js} +1 -1
  9. package/dist/{chunk-EA3X4TAE.js → chunk-FG5EISSP.js} +1 -1
  10. package/dist/chunk-GJLZWEMQ.js +1 -0
  11. package/dist/{chunk-HN2MRF25.js → chunk-HEO56SKT.js} +1 -1
  12. package/dist/{chunk-25JPYUEV.js → chunk-LVAIQTYA.js} +1 -1
  13. package/dist/{chunk-BXXC3VXB.js → chunk-MJAIG2EY.js} +3 -3
  14. package/dist/chunk-MN4GOU3T.js +1 -0
  15. package/dist/{chunk-XQEI7NOC.js → chunk-NXQUM2GW.js} +1 -1
  16. package/dist/{chunk-YL62YV7G.js → chunk-OGMQEA3L.js} +1 -1
  17. package/dist/{chunk-6NTW62L4.js → chunk-PWZY2P65.js} +1 -1
  18. package/dist/{chunk-6XCD343D.js → chunk-QFHWFULY.js} +1 -1
  19. package/dist/{chunk-KYJ6WAPX.js → chunk-VGBATQZ3.js} +1 -1
  20. package/dist/chunk-W67OZWQV.js +1 -0
  21. package/dist/chunk-XQ5ENDKO.js +1 -0
  22. package/dist/{chunk-P2N4KRAR.js → chunk-YUSY3IHE.js} +1 -1
  23. package/dist/commands/evals/agent.js +1 -1
  24. package/dist/commands/experiments/admissions.js +1 -0
  25. package/dist/commands/experiments/reuse.js +1 -1
  26. package/dist/commands/sessions/list.js +1 -1
  27. package/dist/commands/suggestions/accept.js +1 -1
  28. package/dist/commands/suggestions/undo.js +1 -1
  29. package/dist/dashboard/Dashboard.js +1 -1
  30. package/dist/dashboard/data.js +1 -1
  31. package/dist/dashboard/launcher/LauncherOverlay.js +1 -1
  32. package/dist/{dist-D2HLWE5I.js → dist-TNM2RNPT.js} +1 -1
  33. package/dist/harbor/cost_delta.py +0 -0
  34. package/dist/harbor/rm-batch-task/solution/solve.sh +0 -0
  35. package/dist/harbor/rm-batch-task/tests/test.sh +0 -0
  36. package/dist/harbor/rm-locality-task/solution/solve.sh +0 -0
  37. package/dist/harbor/rm-locality-task/tests/test.sh +0 -0
  38. package/dist/harbor/rm-migrations-task/solution/solve.sh +0 -0
  39. package/dist/harbor/rm-migrations-task/tests/test.sh +0 -0
  40. package/dist/harbor/rm-pagination-task/solution/solve.sh +0 -0
  41. package/dist/harbor/rm-pagination-task/tests/test.sh +0 -0
  42. package/dist/harbor/run.sh +0 -0
  43. package/dist/lib/agent-loop.js +1 -1
  44. package/dist/lib/agent-presence.js +1 -1
  45. package/dist/lib/experiment-reuse.js +1 -1
  46. package/dist/lib/gateway-entry.js +0 -0
  47. package/dist/lib/instructions/acceptance/accept-hook.js +1 -1
  48. package/dist/lib/instructions/acceptance/suggestion-accept.js +1 -1
  49. package/dist/lib/jobs/handlers/cron-auto-accept-suggestions.js +1 -1
  50. package/dist/lib/jobs/handlers/cron-instruction-training.js +1 -1
  51. package/dist/lib/jobs/handlers/prepare-isolated-launch.js +1 -1
  52. package/dist/lib/jobs/handlers/prepare-suggestion-live.js +1 -1
  53. package/dist/lib/jobs/handlers/process-eval.js +1 -1
  54. package/dist/lib/jobs/handlers/process-launch.js +1 -1
  55. package/dist/lib/jobs/handlers/process-run-cleanup.js +1 -1
  56. package/dist/lib/jobs/handlers/process-suggestion-adoption.js +1 -1
  57. package/dist/lib/jobs/handlers/process-suggestion-discovery.js +1 -1
  58. package/dist/lib/jobs/handlers/process-suggestion-eval.js +1 -1
  59. package/dist/lib/projects/workspace/worktree.js +1 -1
  60. package/dist/lib/study-fixture.js +1 -1
  61. package/dist/lib/suggestion-discovery.js +1 -1
  62. package/dist/lib/transcript-sync.js +1 -1
  63. package/oclif.manifest.json +599 -553
  64. package/package.json +28 -28
  65. package/dist/chunk-D6CXQBMN.js +0 -1
  66. package/dist/chunk-E6O2IFOK.js +0 -1
  67. package/dist/chunk-FKUFJWII.js +0 -1
  68. package/dist/chunk-JES2CV5Z.js +0 -1
  69. package/dist/chunk-XLFVX7N7.js +0 -1
  70. /package/dist/{chunk-4XIYUMTD.js → chunk-OLOECA5V.js} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulemetric/cli",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -17,6 +17,18 @@
17
17
  "oclif.manifest.json",
18
18
  "!dist/**/*.map"
19
19
  ],
20
+ "scripts": {
21
+ "build": "node scripts/build.mjs",
22
+ "dev": "./bin/dev.js",
23
+ "test": "vitest run",
24
+ "test:e2e": "vitest run --config vitest.e2e.config.ts",
25
+ "test:unit": "vitest run --config vitest.config.ts",
26
+ "mutation-audit": "node scripts/mutation-audit.mjs",
27
+ "type-check": "tsc --noEmit",
28
+ "postbuild": "oclif manifest",
29
+ "worker:restart": "pnpm build && launchctl unload ~/Library/LaunchAgents/com.rulemetric.worker.plist 2>/dev/null; launchctl load ~/Library/LaunchAgents/com.rulemetric.worker.plist && echo 'worker restarted with fresh dist'",
30
+ "lint": "eslint ."
31
+ },
20
32
  "oclif": {
21
33
  "commands": "./dist/commands",
22
34
  "bin": "rulemetric",
@@ -69,6 +81,9 @@
69
81
  "@opentelemetry/sdk-node": "^0.57.0",
70
82
  "@opentelemetry/sdk-trace-node": "^1.30.0",
71
83
  "@opentelemetry/semantic-conventions": "^1.28.0",
84
+ "@rulemetric/hooks": "workspace:*",
85
+ "@rulemetric/proxy": "workspace:*",
86
+ "@rulemetric/skills-registry": "workspace:*",
72
87
  "@sentry/node": "^8.42.0",
73
88
  "@supabase/supabase-js": "^2.95.0",
74
89
  "drizzle-orm": "^0.44.0",
@@ -79,18 +94,24 @@
79
94
  "ink-text-input": "^6.0.0",
80
95
  "postgres": "^3.4.0",
81
96
  "react": "^19.0.0",
82
- "zod": "^3.24.0",
83
- "@rulemetric/hooks": "0.20.0",
84
- "@rulemetric/proxy": "0.20.0",
85
- "@rulemetric/skills-registry": "0.20.0"
97
+ "zod": "^3.24.0"
86
98
  },
87
99
  "//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
100
  "optionalDependencies": {
89
101
  "better-sqlite3": "^11.0.0"
90
102
  },
91
103
  "devDependencies": {
104
+ "@rulemetric/contracts": "workspace:*",
92
105
  "@hono/node-server": "^1.13.0",
93
106
  "@oclif/test": "^4.1.0",
107
+ "@rulemetric/api": "workspace:*",
108
+ "@rulemetric/core": "workspace:*",
109
+ "@rulemetric/db": "workspace:*",
110
+ "@rulemetric/effectiveness": "workspace:*",
111
+ "@rulemetric/email": "workspace:*",
112
+ "@rulemetric/session": "workspace:*",
113
+ "@rulemetric/telemetry": "workspace:*",
114
+ "@rulemetric/typescript-config": "workspace:*",
94
115
  "@types/js-yaml": "^4.0.9",
95
116
  "@types/node": "^22.0.0",
96
117
  "@types/react": "^19.0.0",
@@ -101,27 +122,6 @@
101
122
  "resend": "^4.0.0",
102
123
  "tsx": "^4.19.0",
103
124
  "typescript": "^5.9.0",
104
- "vitest": "^3.2.0",
105
- "@rulemetric/db": "0.0.1",
106
- "@rulemetric/contracts": "0.0.1",
107
- "@rulemetric/api": "0.0.1",
108
- "@rulemetric/effectiveness": "0.0.1",
109
- "@rulemetric/typescript-config": "0.0.0",
110
- "@rulemetric/email": "0.0.1",
111
- "@rulemetric/core": "0.0.1",
112
- "@rulemetric/session": "0.2.1",
113
- "@rulemetric/telemetry": "0.0.1"
114
- },
115
- "scripts": {
116
- "build": "node scripts/build.mjs",
117
- "dev": "./bin/dev.js",
118
- "test": "vitest run",
119
- "test:e2e": "vitest run --config vitest.e2e.config.ts",
120
- "test:unit": "vitest run --config vitest.config.ts",
121
- "mutation-audit": "node scripts/mutation-audit.mjs",
122
- "type-check": "tsc --noEmit",
123
- "postbuild": "oclif manifest",
124
- "worker:restart": "pnpm build && launchctl unload ~/Library/LaunchAgents/com.rulemetric.worker.plist 2>/dev/null; launchctl load ~/Library/LaunchAgents/com.rulemetric.worker.plist && echo 'worker restarted with fresh dist'",
125
- "lint": "eslint ."
125
+ "vitest": "^3.2.0"
126
126
  }
127
- }
127
+ }
@@ -1 +0,0 @@
1
- import{c as se}from"./chunk-RYMQMJ7O.js";import{b as te}from"./chunk-IEQDLURA.js";import{d as ae,e as ie,f as le}from"./chunk-KINIFUZQ.js";import{a as ee}from"./chunk-UFRJ75FW.js";import{a as Q}from"./chunk-ID47WFUP.js";import{b as U}from"./chunk-4W5BF4ZN.js";import{a as q}from"./chunk-KUD7LWJJ.js";import{a as K}from"./chunk-ZYGBABMZ.js";import{a as G}from"./chunk-WGPFOHV3.js";import{a as N}from"./chunk-K2PI3OGV.js";import{a as x}from"./chunk-JES2CV5Z.js";import{a as V}from"./chunk-XLFVX7N7.js";import{c as C}from"./chunk-JE2JX7IJ.js";import{a as F}from"./chunk-KIXBBZL5.js";import{a as $}from"./chunk-25JPYUEV.js";import{a as O}from"./chunk-NNUZ4CG4.js";import{b as B}from"./chunk-5RBLIVBF.js";import{a as L}from"./chunk-ZFIGOHQ6.js";import{a as ne}from"./chunk-4RC2SYZX.js";import{a as X}from"./chunk-7F3S6JQ2.js";import{d as P}from"./chunk-SW24KZ5C.js";import{a as re}from"./chunk-2WRP6ZJF.js";import{d as T}from"./chunk-JXUSXDS6.js";import{b as Y}from"./chunk-SWCM7IHC.js";import{a as Z}from"./chunk-XQEI7NOC.js";import{a as z}from"./chunk-Q42RXJ4R.js";import{a as j}from"./chunk-E6O2IFOK.js";import{a as oe}from"./chunk-FKUFJWII.js";import{b as R,c as W,f as o,g as A,i as J,j as b}from"./chunk-45CCW25C.js";import{d as M}from"./chunk-GPBN4ROE.js";import{b as y,e as H,f as D}from"./chunk-E5FI5YHO.js";import{a as l}from"./chunk-ZLLER3HP.js";var E=null,S=new Map,ge={process_eval:$,process_suggestion_eval:V,process_suggestion_discovery:x,process_insights:O,process_launch:U,process_send_message:K,process_conversation:F,process_session_goal:G,distill_memories:Y,process_run_cleanup:q,cron_refine_cases:ne,cron_retire_unused_skills:re,cron_reconcile_attribution:L,cron_suggest_instructions:T,cron_refresh_skills:P,cron_refresh_pricing:X,cron_eval_autorun:z,process_suggestion_adoption:N,cron_auto_accept_suggestions:Z,cron_instruction_training:j,cron_instruction_evolution:ee,process_judge_review:Q,harbor_ab:C},de=500,ce=1e4,ue=Object.keys(ge),ke=new Set([]);function ve(e=process.env){return e.DATABASE_URL?ue:ue.filter(s=>!ke.has(s))}l(ve,"availableCapabilities");var he=3e4,we=3e4;async function be(e,s,t=M(),i){let d=[...t.claudeBin?["claude"]:[],...t.codexBin?["codex"]:[],...t.piBin?["pi"]:[]],c=`capabilities=${encodeURIComponent(e.join(","))}&waitMs=${s}&experimentProtocol=1&measurementProtocol=1&studyProtocol=1&studyRepairs=1&scopedCollector=3&memorySnapshots=1&boundedAutorun=1&measurementEngines=${encodeURIComponent(d.join(","))}`,u=await H(`/api/work/next?${c}${i?`&launchMode=${i}`:""}`);return u==null||typeof u=="string"?null:u}l(be,"pollForWork");function Se(e,s,t){return{logger:{info:l(i=>s(i),"info"),warn:l(i=>s(i),"warn"),error:l(i=>s(i),"error")},job:{attempts:e},leaseSignal:t}}l(Se,"makeHelpers");async function Ie(e,s,t,i){let d=ge[e.kind],c=Date.now();if(o(t,{event:"claim",jobId:e.id,kind:e.kind,attempts:e.attempts}),!d){let n=`unknown kind: ${e.kind}`;o(t,{event:"fail",jobId:e.id,kind:e.kind,terminal:!0,error:n}),await D(`/api/work/${e.id}/fail`,{leaseToken:e.leaseToken,error:n,terminal:!0}).catch(()=>{});return}let u=new AbortController,m=!1,k,g=l(()=>{m||(o(t,{event:"heartbeat",jobId:e.id}),b(`/api/work/${e.id}/heartbeat`,{leaseToken:e.leaseToken},{budgetMs:Math.min(W,Math.max(0,s-1e3)),signal:i,log:t,event:"heartbeat",jobId:e.id}).then(n=>{if(!(n.ok||m)){if(J(n.error)){m=!0,k!==void 0&&clearInterval(k),o(t,{event:"lease_lost",jobId:e.id,kind:e.kind,elapsedMs:Date.now()-c,error:n.error instanceof Error?n.error.message:String(n.error)}),u.abort(new Error(`lease lost for job ${e.id} (${e.kind}); stop work`));return}o(t,{event:"heartbeat_error",jobId:e.id,attempts:n.attempts,error:n.error instanceof Error?n.error.message:String(n.error)})}}))},"beat");k=setInterval(g,s),S.set(e.id,g);let a;try{let n=Se(e.attempts,t,u.signal);a={kind:"complete",result:await d(e.payload,n)??{}}}catch(n){let v=E?.pausesSince(c)??[],_=le(v),h=n instanceof Error?n.message:String(n),r=B(n),p=!r&&ie(v);a={kind:"fail",message:_?`${_}; ${h}`:h,pausedDuringJob:!!_,terminal:r,hostSuspended:p}}try{if(m)o(t,{event:"lease_lost_stop",jobId:e.id,kind:e.kind,durationMs:Date.now()-c,handlerOutcome:a.kind,...a.kind==="fail"?{error:a.message}:{}});else if(a.kind==="complete"){o(t,{event:"complete",jobId:e.id,kind:e.kind,durationMs:Date.now()-c});let n=await b(`/api/work/${e.id}/complete`,{leaseToken:e.leaseToken,result:a.result},{budgetMs:R,signal:i,log:t,event:"complete_post",jobId:e.id});n.ok||o(t,{event:"complete_post_error",jobId:e.id,kind:e.kind,attempts:n.attempts,error:n.error instanceof Error?n.error.message:String(n.error)})}else{o(t,{event:"fail",jobId:e.id,kind:e.kind,durationMs:Date.now()-c,terminal:a.terminal,error:a.message,...a.pausedDuringJob?{pausedDuringJob:!0}:{},...a.hostSuspended?{hostSuspended:!0}:{}});let n=await b(`/api/work/${e.id}/fail`,{leaseToken:e.leaseToken,error:a.message,terminal:a.terminal,hostSuspended:a.hostSuspended},{budgetMs:R,signal:i,log:t,event:"fail_post",jobId:e.id});n.ok||o(t,{event:"fail_post_error",jobId:e.id,attempts:n.attempts,error:n.error instanceof Error?n.error.message:String(n.error)})}}finally{clearInterval(k),S.delete(e.id)}}l(Ie,"runOne");var pe=new Set(["process_launch","process_eval","process_suggestion_eval","process_suggestion_discovery","process_conversation","process_insights","process_session_goal","distill_memories","cron_suggest_instructions","cron_eval_autorun","cron_instruction_evolution","process_judge_review","harbor_ab"]),me=new Set(["cron_refresh_skills"]);async function rn(e){let s=e.log??(()=>{}),t=e.pollWaitMs??he,i=e.heartbeatIntervalMs??we,d=e.capabilities??ve();o(s,{event:"agent_start",capabilities:d,pollWaitMs:t,heartbeatIntervalMs:i});try{let r=te();r.removed.length>0&&o(s,{event:"eval_worktrees_swept",removed:r.removed.length})}catch(r){o(s,{event:"eval_worktree_sweep_failed",error:r instanceof Error?r.message:String(r)})}E=ae({signal:e.signal,onPause:l(r=>{o(s,{event:"machine_pause",...r,jobIds:[...S.keys()]});for(let p of S.values())p()},"onPause")});let c=oe(d,e.signal,s,e.version,()=>E);se({signal:e.signal,log:s}).catch(r=>{o(s,{event:"tt_heartbeat_fatal",error:r instanceof Error?r.message:String(r)})});let u=5*6e4,m=0,k=l(()=>{if(!e.readInstalledVersion||!e.version)return!1;let r=Date.now();if(r-m<u)return!1;m=r;let p=e.readInstalledVersion();return!!(p&&p!==e.version)},"versionDrifted"),g=new AbortController,a=g.signal;e.signal.aborted?g.abort():e.signal.addEventListener("abort",()=>g.abort(),{once:!0});let n=l(async(r,p,_e)=>{let f=de;for(;!a.aborted&&!e.shouldDrain?.();){if(k()){o(s,{event:"agent_version_drift",bootVersion:e.version,installedVersion:e.readInstalledVersion?.()??null}),g.abort(),e.onVersionDrift?.();break}let I=null;try{I=await be([...p],t,void 0,_e)}catch(w){let fe=w instanceof y?w.statusCode:void 0;if(o(s,{event:"poll_error",lane:r,status:fe,error:w instanceof Error?w.message:String(w)}),!await A(f,a))break;f=Math.min(f*2,ce);continue}if(!I){if(o(s,{event:"poll_204",lane:r}),!await A(f,a))break;f=Math.min(f*2,ce);continue}f=de,await Ie(I,i,s,a)}},"runLane"),v=d.filter(r=>pe.has(r)),_=d.filter(r=>(r==="process_launch"||!pe.has(r))&&!me.has(r)),h=d.filter(r=>me.has(r));o(s,{event:"agent_lanes",heavy:v.length,fast:_.length,background:h.length}),await Promise.all([...v.length?[n("heavy",v,"headless")]:[],..._.length?[n("fast",_,"interactive")]:[],...h.length?[n("background",h)]:[]]),await c.shutdown(),o(s,{event:"agent_stop"})}l(rn,"runAgentLoop");export{ge as a,ue as b,ve as c,be as d,rn as e};
@@ -1 +0,0 @@
1
- import{e as m,f as g}from"./chunk-E5FI5YHO.js";import{a as l}from"./chunk-ZLLER3HP.js";async function f(c,p){let r=l(e=>p?.logger?.info?.(e)??console.log(e),"log"),{projectPath:a}=c,i=`[cron_instruction_training] ${a}`;if(!a)return{skipped:"no-project-path"};let n=await g("/api/instruction-experiments/settle",{projectPath:a}),o=n.settled.map(e=>e.outcome),d=o.filter(e=>e==="graduated").length;for(let e of n.settled)r(`${i}: experiment ${e.experimentId} \u2192 ${e.outcome}`);n.examined>0&&r(`${i}: examined ${n.examined} running experiment(s) \u2014 ${n.settled.length} settled (${d} graduated), ${n.stillRunning} still gathering`);let t=await m(`/api/instruction-suggestions/trialable?projectPath=${encodeURIComponent(a)}`);for(let e of t.refused)r(`${i}: not trialling "${e.name}" \u2014 ${e.reason}`);if(t.candidates.length===0)return r(`${i}: no new trial started (${t.running}/${t.limits.maxConcurrent} running, ${t.slots} slot(s) free)`),{examined:n.examined,settled:n.settled.length,graduated:d,nominated:0,running:t.running,outcomes:o};let u=0;for(let e of t.candidates)try{let s=await g(`/api/instruction-suggestions/${e.id}/test`,{action:"discover"});if(s.existing){r(`${i}: testing budget already recorded for "${e.name}" (${s.evalJobId})`);continue}u+=1,r(`${i}: queued automatic task preparation and isolated study for "${e.name}"`)}catch(s){r(`${i}: could not measure "${e.name}" \u2014 ${s instanceof Error?s.message:String(s)}`)}return{examined:n.examined,settled:n.settled.length,graduated:d,nominated:u,queued:u,running:t.running,outcomes:o}}l(f,"cronInstructionTraining");export{f as a};
@@ -1 +0,0 @@
1
- import{f as i}from"./chunk-45CCW25C.js";import{b as p}from"./chunk-PIVEJTNF.js";import{d as g}from"./chunk-GPBN4ROE.js";import{f as m}from"./chunk-E5FI5YHO.js";import{a as n}from"./chunk-ZLLER3HP.js";var E=3e4,P=`thin-agent-${process.pid}`,a=null;function A(y,v,l,h,b){let d;try{let e=g();d={claude:e.claudeBin!=null,codex:e.codexBin!=null,pi:e.piBin!=null,codexModel:e.codexConfiguredModel}}catch{}let c;try{c=p()}catch{}let s=n(e=>m("/api/workers/heartbeat",{workerType:"cli-worker",clientName:P,clientVersion:h,workerVersion:"0.1.0",currentJobId:null,inFlightCount:0,lastError:null,status:e,metadata:{capabilities:y,mode:"thin-agent",experimentProtocol:1,measurementProtocol:1,studyProtocol:1,studyRepairs:1,scopedCollector:3,memorySnapshots:1,boundedAutorun:1,llmEngines:d,harborReady:c,machine:b()?.summary()}}).then(r=>{let o=r?.advisory;o&&o.message!==a?(a=o.message,i(l,{event:"worker_advisory",code:o.code,message:o.message})):o||(a=null)}).catch(r=>{i(l,{event:"presence_heartbeat_error",error:r instanceof Error?r.message:String(r)})}),"send");s("alive");let f=setInterval(()=>s("alive"),E),t=null,u=n(()=>t||(clearInterval(f),t=Promise.race([s("shutting_down"),new Promise(e=>setTimeout(e,2e3).unref())]),t),"sayGoodbye");return v.addEventListener("abort",()=>{u()},{once:!0}),{shutdown:u}}n(A,"startPresenceHeartbeat");export{A as a};
@@ -1 +0,0 @@
1
- import{a as C,c as N,d as H,e as L,f as U,g as G,h as q,i as K,j as z,l as B}from"./chunk-BXXC3VXB.js";import{f as S}from"./chunk-VZYNZS5U.js";import{b as J,c as M}from"./chunk-ONSRPEUQ.js";import{a as _}from"./chunk-GKWZ2DSE.js";import{b as O,c as P}from"./chunk-5MXZJWQS.js";import{g as R}from"./chunk-FLP6WIJV.js";import{a as A}from"./chunk-6XTLP2G7.js";import{e as b,f as x,h as $}from"./chunk-E5FI5YHO.js";import{a as f}from"./chunk-ZLLER3HP.js";import{execFileSync as F}from"node:child_process";import{tmpdir as V}from"node:os";async function ie(a,l){let s=C.parse(a.discovery);if(l.job.attempts>1)throw new Error("Discovery preparation cannot replay an unknown generation budget");let e={evidenceKind:"automatic_discovery",stage:"preparing",suggestionId:s.suggestionId,generationCalls:[],adoptionAllowed:!1},i=f(()=>$(`/api/eval-jobs/${a.mirrorId}/state`,{result:e}),"persist"),D=f(async()=>{if(l.leaseSignal?.throwIfAborted(),new Date(s.expiresAt)<=new Date)throw new Error("Discovery budget expired");if(!(await b(`/api/eval-targets/${a.evalTargetId}/jobs`)).some(c=>c.id===a.mirrorId&&["claimed","running"].includes(c.status)))throw new Error("Discovery preparation cancelled or no longer claimed")},"active"),u=s.requestedModel,j=f(async(o,c,y)=>{await D();let k=e.generationCalls;if(k.length>=s.maxGenerationCalls)throw new Error("Discovery generation budget exhausted");await x(`/api/eval-jobs/${a.mirrorId}/discovery-calls`,{stage:o});let g=Math.min(o==="authoring_tasks"?3e5:12e4,Math.max(1,new Date(s.expiresAt).getTime()-Date.now())),p={stage:o,status:"reserved",timeoutMs:g};k.push(p),e.stage=o,await i();let r=S({baseDir:V(),engine:"claude"});try{let t=await R({engine:"claude",textOnly:!0,model:u,workDir:r.workDir,timeout:g,systemPrompt:c,prompt:JSON.stringify(y)});if(Object.assign(p,{status:"returned",model:t.model,durationMs:t.durationMs,tokens:t.totalTokens,costUsd:t.costUsd??null,error:t.error??null}),await i(),t.error||t.exitCode!==0||!t.model)throw new Error(`Discovery ${o} failed: ${t.error??"missing successful model provenance"}`);if(u&&t.model!==u)throw new Error("Observed discovery model differs from frozen pin");u=t.model;let w=O(P(t.output)??t.output);if(!w.ok)throw new Error(`Discovery ${o} returned invalid JSON`);return w.value}finally{r.cleanup()}},"generate");try{await D();let c=(await b(`/api/eval-targets/${a.evalTargetId}/jobs`)).find(n=>n.id===a.mirrorId)?.result;if(c?.generationCalls?.length){if(Object.assign(e,c),c.studyId)return e;throw new Error("Previous preparation reserved generation calls; its unknown spend cannot be replayed")}let y=A("claude");if(!y)throw new Error("Claude is not installed; frozen fixture execution is unavailable");let k=F(y,["--version"],{encoding:"utf8",timeout:1e4}).trim(),g=F("git",["rev-parse","HEAD"],{cwd:s.projectPath,encoding:"utf8",timeout:5e3}).trim(),p=await J({projectPath:s.projectPath},n=>b(n,{timeoutMs:15e3,signal:l.leaseSignal})),r=M(p);e.capturedEvidence=p;let t=_(s.projectPath,g,r.text);if(e.evidence=r,e.repository=t,!r.sessionIds.length)throw new Error("No usable project session evidence; no tasks were invented");let w=await j("authoring_tasks",L,{evidence:r.text,repository:t,taskLimit:s.taskLimit});e.taskDraft=w,await i();let m=K(w,r.sessionIds,r.text,s.taskLimit,t),v=m.draft;if(e.eligibleTaskDraft=v,e.taskRejections=m.rejected,await i(),!v.tasks.length&&m.rejected.length)throw new Error(`No executable tasks after preparation checks: ${m.rejected.map(n=>`${n.taskId}: ${n.reason}`).join("; ")}`);q(v,r.sessionIds,r.text,s.taskLimit,t);let h=N.parse(await j("deriving_change",U,{source:s.source,evidence:r.text}));if(e.change=h,await i(),!h.applicable)throw new Error(`No applicable change: ${h.reason}`);let T=H.parse(await j("reviewing_tasks",G,{evidence:r.text,repository:t,tasks:v.tasks}));e.taskAudit=T,await i();let d=z(v,T);if(e.reviewedTaskDraft=d.draft,e.taskRejections=[...m.rejected,...d.rejected],await i(),!d.draft.tasks.length)throw new Error(`No executable tasks after independent review: ${d.rejected.map(n=>`${n.taskId}: ${n.reason}`).join("; ")}`);let I=B({snapshot:s,draft:d.draft,change:h,audit:d.audit,model:u,harnessVersion:k,repositoryRevision:g,sessionIds:r.sessionIds,evidence:r.text,repository:t});e.protocol=I,e.stage="registering_study",await i(),await D();let E=await x(`/api/instruction-suggestions/${s.suggestionId}/test`,{action:"study",protocol:I,discoveryJobId:a.mirrorId});return Object.assign(e,{stage:"study_queued",...E}),await i(),l.logger.info(`Discovery prepared ${I.tasks.length} tasks and queued study ${E.studyId}`),e}catch(o){return Object.assign(e,{stage:"blocked",reason:o instanceof Error?o.message:String(o)}),await i(),l.logger.warn(`Discovery stopped: ${e.reason}`),e}}f(ie,"processSuggestionDiscovery");export{ie as a};
@@ -1 +0,0 @@
1
- import{a as p}from"./chunk-RAOV3MFF.js";import{a as l}from"./chunk-25JPYUEV.js";import{d}from"./chunk-LDFGM37E.js";import{e as c,h as u}from"./chunk-E5FI5YHO.js";import{a}from"./chunk-ZLLER3HP.js";import{createHash as g}from"node:crypto";import{z as t}from"zod";var f=t.object({content:t.string().min(1),name:t.string().min(1),type:t.enum(["instruction","skill"]),contentHash:t.string().regex(/^[a-f0-9]{64}$/),suggestionId:t.string().uuid()}).strict();async function j(e,m){e.preparationOnly&&!e.confirmationSourceStudyId&&d.parse(e.research);let r=f.parse(e.candidateSnapshot);if(g("sha256").update(r.content).digest("hex")!==r.contentHash)throw new Error("Candidate snapshot hash mismatch");let o=e.preparationOnly||e.preparationSourceJobId?{preparationSourceJobId:e.preparationSourceJobId}:await l({...e,candidateSnapshot:r,config:{...e.config,parallel:1,runsPerEval:1,iteration:1,skipBaseline:!1,skipGrading:!1,generateIfEmpty:!0,timeout:12e4}},m);if((await c(`/api/eval-targets/${e.evalTargetId}/jobs`)).find(i=>i.id===e.mirrorId)?.status==="cancelled")return{...o,cancelled:!0,adoptionAllowed:!1};let n;try{n=await p({sourceStudyId:e.confirmationSourceStudyId,research:e.research,requestedModel:e.requestedModel,evalTargetId:e.evalTargetId,evalJobId:e.preparationSourceJobId??e.mirrorId,preparationJobId:e.mirrorId,...r})}catch(i){n={status:"blocked",reason:i instanceof Error?i.message:String(i)}}if(n.status==="cancelled")return{...o,cancelled:!0,livePreparation:n,adoptionAllowed:!1};let s={...o,livePreparation:n,sourceStudyId:e.confirmationSourceStudyId,evidenceKind:e.preparationOnly?"live_preparation":"constructed_evaluation",candidateHash:r.contentHash,suggestionId:r.suggestionId,adoptionAllowed:!1};return await u(`/api/eval-jobs/${e.mirrorId}/state`,{result:s}),s}a(j,"processSuggestionEval");export{j as a};
File without changes