@rulemetric/cli 0.7.40 → 0.7.41

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.
@@ -1,2 +1,2 @@
1
- import{b as B}from"./chunk-N7TGRFVZ.js";import{a as R}from"./chunk-5RBLIVBF.js";import{a as v,f as d,g as n,h as m,i as U}from"./chunk-45DOTNQM.js";import{a as $}from"./chunk-ZLLER3HP.js";import{and as L,asc as j,eq as l,gt as q,isNotNull as F,sql as O}from"drizzle-orm";var _=100,C=10;async function G(I,s={}){let t=s.db??U(),D=s.sendEmail??B,p=s.log??(o=>process.stderr.write(`[process_announcement] ${o}
1
+ import{b as B}from"./chunk-N7TGRFVZ.js";import{a as v,f as d,g as n,h as m,i as U}from"./chunk-45DOTNQM.js";import{a as R}from"./chunk-5RBLIVBF.js";import{a as $}from"./chunk-ZLLER3HP.js";import{and as L,asc as j,eq as l,gt as q,isNotNull as F,sql as O}from"drizzle-orm";var _=100,C=10;async function G(I,s={}){let t=s.db??U(),D=s.sendEmail??B,p=s.log??(o=>process.stderr.write(`[process_announcement] ${o}
2
2
  `)),b=s.webBaseUrl??process.env.RULEMETRIC_WEB_URL??process.env.WEB_URL??"https://rulemetric.com",{announcementId:r}=I,[i]=await t.select().from(d).where(l(d.id,r)).limit(1);if(!i)throw new R(`Announcement ${r} not found`);if(i.status!=="queued"&&i.status!=="sending")throw new R(`Announcement ${r} is in status='${i.status}'; expected 'queued' or 'sending'.`);await t.update(d).set({status:"sending",updatedAt:new Date}).where(l(d.id,r)),p(`Sending announcement ${r} (${i.subject??""})`);let w=0,f=0,h=0,y=0,k=null;try{for(;;){let c=await t.select({userId:m.userId,email:v.email,displayName:v.displayName,unsubscribeToken:m.unsubscribeToken}).from(m).innerJoin(v,l(v.id,m.userId)).where(L(l(m.productAnnouncements,!0),F(v.email),k?q(m.userId,k):void 0)).orderBy(j(m.userId)).limit(_);if(c.length===0)break;k=c[c.length-1].userId;for(let A=0;A<c.length;A+=C){let P=c.slice(A,A+C),S=await Promise.allSettled(P.map(g=>W({recipient:g,announcement:i,webBaseUrl:b,sendEmail:D,db:t})));for(let g=0;g<S.length;g++){let u=S[g];if(u.status==="fulfilled")u.value.ok==="sent"?w++:u.value.ok==="skipped"?h++:(f++,u.value.provider==="noop"&&y++,p(` recipient ${P[g].userId}: send failed \u2014 ${u.value.error}`));else{f++;let T=u.reason instanceof Error?u.reason.message:String(u.reason);p(` recipient ${P[g].userId}: send failed \u2014 ${T}`)}}}if(c.length<_)break}y>0&&p(`WARNING: ${y} recipient(s) hit the noop email provider and were recorded as FAILED \u2014 no email provider is configured on this worker (set RESEND_API_KEY in ~/.config/rulemetric/env and reinstall the service)`);let o=await t.select({status:n.status,count:O`count(*)::int`}).from(n).where(l(n.announcementId,r)).groupBy(n.status),e={};for(let c of o)e[c.status]=c.count;let a=e.sent??0,E=e.failed??0,N=a===0&&E>0?"failed":"sent",x=E>0?`${E} of ${a+E} recipient(s) failed; see announcement_deliveries`:null;return await t.update(d).set({status:N,recipientCount:a,...N==="sent"?{sentAt:new Date}:{},error:x,updatedAt:new Date}).where(l(d.id,r)),p(`Done: status=${N} sent=${a} failed=${E} (this attempt: sent=${w} failed=${f} skipped=${h})`),{sent:w,failed:f,skipped:h}}catch(o){let e=o instanceof Error?o.message:String(o);throw await t.update(d).set({status:"failed",error:e.slice(0,1e3),updatedAt:new Date}).where(l(d.id,r)).catch(()=>{}),o}}$(G,"processAnnouncement");function K(I){return I.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}$(K,"escapeHtml");async function W(I){let{recipient:s,announcement:t,webBaseUrl:D,sendEmail:p,db:b}=I;if(!s.email)return{ok:"skipped",reason:"no-email"};let r=await b.insert(n).values({announcementId:t.id,userId:s.userId,email:s.email,status:"pending"}).onConflictDoNothing({target:[n.announcementId,n.userId]}).returning({id:n.id});if(r.length===0)return{ok:"skipped",reason:"already-claimed"};let i=r[0].id,w=D.replace(/\/$/,""),f=encodeURIComponent(s.unsubscribeToken),h=`${w}/unsubscribe/${f}`,y=s.displayName?.trim().split(/\s+/)[0]||"there",k=t.htmlBody.replaceAll("{{unsubscribe_url}}",h).replaceAll("{{recipient_name}}",K(y)),o=t.textBody.replaceAll("{{unsubscribe_url}}",h).replaceAll("{{recipient_name}}",y);try{let e=await p({to:s.email,subject:t.subject,html:k,text:o,fromName:"RuleMetric",idempotencyKey:i,headers:{"List-Unsubscribe":`<${w}/api/unsubscribe/${f}>`,"List-Unsubscribe-Post":"List-Unsubscribe=One-Click"}});if(e.provider==="noop"){let a="no email provider configured (RESEND_API_KEY unset on the worker)";return await b.update(n).set({status:"failed",error:a}).where(l(n.id,i)),{ok:"failed",error:a,provider:e.provider}}return await b.update(n).set({status:"sent",providerId:e.id,sentAt:new Date}).where(l(n.id,i)),{ok:"sent",providerId:e.id,provider:e.provider}}catch(e){let a=e instanceof Error?e.message:String(e);return await b.update(n).set({status:"failed",error:a.slice(0,1e3)}).where(l(n.id,i)).catch(()=>{}),{ok:"failed",error:a}}}$(W,"sendOne");export{G as a};
@@ -1 +1 @@
1
- import{a as J}from"./chunk-B22HYCBV.js";import{a as j}from"./chunk-ULMEKK7C.js";import{b as I,c as P,d as v}from"./chunk-5RUEROLC.js";import{a as E}from"./chunk-X23L2MF6.js";import{d as T}from"./chunk-NJ5UED3H.js";import{a as b}from"./chunk-ZLLER3HP.js";import{useEffect as R,useState as i}from"react";import{Box as l,Text as s,useInput as Z}from"ink";import{jsx as t,jsxs as a}from"react/jsx-runtime";function K({onClose:A,activeOrg:F,defaultProjectPath:y,width:_}){let{jobs:u,error:L,loading:$,refetch:S}=j(20),[M,C]=i([]),[d,m]=i("list"),[f,w]=i(0),[h,g]=i(null),[x,B]=i(null),[p,c]=i(null);R(()=>{v().then(C).catch(o=>{let r=o instanceof Error?o.message:String(o);c(`couldn't load launchers: ${r}`),C([{tool:"claude_code",capabilities:{headless:!0,interactive:!0,remoteSpawn:!0}}])})},[]),R(()=>{if(!p)return;let o=setTimeout(()=>c(null),5e3);return()=>clearTimeout(o)},[p]),Z((o,r)=>{if(h){if(o==="y"||o==="Y"){let e=h.id;g(null),P(e).then(()=>{S(),c(`cancelled ${e.slice(0,8)}`)}).catch(n=>c(`cancel failed: ${n instanceof Error?n.message:String(n)}`))}else(o==="n"||o==="N"||r.escape)&&g(null);return}if(r.escape){if(d!=="none"){m("none");return}A();return}if(r.tab){m(e=>e==="list"?"form":e==="form"?"none":"list");return}if(o!=="q"&&d==="list"){if(r.upArrow)w(e=>Math.max(0,e-1));else if(r.downArrow)w(e=>Math.min(u.length-1,e+1));else if(o==="c"){let e=u[f];e&&(e.status==="running"||e.status==="queued"||e.status==="pending")&&g(e)}else if(o==="r"){let e=u[f],n=e?.result?.externalSessionId;e&&e.tool==="claude_code"&&n?(B({tool:"claude_code",projectPath:e.config.projectPath,resumeSessionId:n}),m("form")):c("resume needs a Claude Code session with a session id")}else if(o==="o"){let n=u[f]?.result?.externalSessionId;if(n){let O=process.env.RULEMETRIC_WEB_URL??"http://localhost:5174";import("node:child_process").then(({spawn:U})=>{U("open",[`${O}/sessions/${n}`],{detached:!0,stdio:"ignore"}).unref()})}}}});async function N(o){await I(o),B(null),m("list"),c("launched"),S()}return b(N,"handleSubmit"),a(l,{flexDirection:"column",borderStyle:"round",borderColor:T,width:_,paddingX:1,children:[a(l,{children:[t(s,{bold:!0,color:T,children:"Launcher"}),t(s,{dimColor:!0,children:" active org: "}),t(s,{children:F??"(none)"}),$&&t(s,{dimColor:!0,children:" loading\u2026"}),L&&a(s,{color:"#F55B5B",children:[" \u26A0 ",L]})]}),t(l,{marginTop:1,children:t(E,{jobs:u,selectedIndex:f,focused:d==="list"})}),t(l,{marginTop:1,children:t(J,{launchers:M,defaultProjectPath:x?.projectPath??y,defaultTool:x?.tool,defaultResumeSessionId:x?.resumeSessionId,focused:d==="form",onSubmit:N})}),h&&t(l,{marginTop:1,children:a(s,{color:"#FFD700",children:["Cancel job ",h.id.slice(0,8),"? (y/n)"]})}),p&&t(l,{marginTop:1,children:a(s,{dimColor:!0,children:["\xB7 ",p]})}),t(l,{marginTop:1,children:a(s,{dimColor:!0,children:["\u2191\u2193 select tab focus c cancel r resume o open esc ",d==="none"?"close":"back"]})})]})}b(K,"LauncherOverlay");export{K as a};
1
+ import{a as E}from"./chunk-X23L2MF6.js";import{a as J}from"./chunk-B22HYCBV.js";import{a as j}from"./chunk-ULMEKK7C.js";import{b as I,c as P,d as v}from"./chunk-5RUEROLC.js";import{d as T}from"./chunk-NJ5UED3H.js";import{a as b}from"./chunk-ZLLER3HP.js";import{useEffect as R,useState as i}from"react";import{Box as l,Text as s,useInput as Z}from"ink";import{jsx as t,jsxs as a}from"react/jsx-runtime";function K({onClose:A,activeOrg:F,defaultProjectPath:y,width:_}){let{jobs:u,error:L,loading:$,refetch:S}=j(20),[M,C]=i([]),[d,m]=i("list"),[f,w]=i(0),[h,g]=i(null),[x,B]=i(null),[p,c]=i(null);R(()=>{v().then(C).catch(o=>{let r=o instanceof Error?o.message:String(o);c(`couldn't load launchers: ${r}`),C([{tool:"claude_code",capabilities:{headless:!0,interactive:!0,remoteSpawn:!0}}])})},[]),R(()=>{if(!p)return;let o=setTimeout(()=>c(null),5e3);return()=>clearTimeout(o)},[p]),Z((o,r)=>{if(h){if(o==="y"||o==="Y"){let e=h.id;g(null),P(e).then(()=>{S(),c(`cancelled ${e.slice(0,8)}`)}).catch(n=>c(`cancel failed: ${n instanceof Error?n.message:String(n)}`))}else(o==="n"||o==="N"||r.escape)&&g(null);return}if(r.escape){if(d!=="none"){m("none");return}A();return}if(r.tab){m(e=>e==="list"?"form":e==="form"?"none":"list");return}if(o!=="q"&&d==="list"){if(r.upArrow)w(e=>Math.max(0,e-1));else if(r.downArrow)w(e=>Math.min(u.length-1,e+1));else if(o==="c"){let e=u[f];e&&(e.status==="running"||e.status==="queued"||e.status==="pending")&&g(e)}else if(o==="r"){let e=u[f],n=e?.result?.externalSessionId;e&&e.tool==="claude_code"&&n?(B({tool:"claude_code",projectPath:e.config.projectPath,resumeSessionId:n}),m("form")):c("resume needs a Claude Code session with a session id")}else if(o==="o"){let n=u[f]?.result?.externalSessionId;if(n){let O=process.env.RULEMETRIC_WEB_URL??"http://localhost:5174";import("node:child_process").then(({spawn:U})=>{U("open",[`${O}/sessions/${n}`],{detached:!0,stdio:"ignore"}).unref()})}}}});async function N(o){await I(o),B(null),m("list"),c("launched"),S()}return b(N,"handleSubmit"),a(l,{flexDirection:"column",borderStyle:"round",borderColor:T,width:_,paddingX:1,children:[a(l,{children:[t(s,{bold:!0,color:T,children:"Launcher"}),t(s,{dimColor:!0,children:" active org: "}),t(s,{children:F??"(none)"}),$&&t(s,{dimColor:!0,children:" loading\u2026"}),L&&a(s,{color:"#F55B5B",children:[" \u26A0 ",L]})]}),t(l,{marginTop:1,children:t(E,{jobs:u,selectedIndex:f,focused:d==="list"})}),t(l,{marginTop:1,children:t(J,{launchers:M,defaultProjectPath:x?.projectPath??y,defaultTool:x?.tool,defaultResumeSessionId:x?.resumeSessionId,focused:d==="form",onSubmit:N})}),h&&t(l,{marginTop:1,children:a(s,{color:"#FFD700",children:["Cancel job ",h.id.slice(0,8),"? (y/n)"]})}),p&&t(l,{marginTop:1,children:a(s,{dimColor:!0,children:["\xB7 ",p]})}),t(l,{marginTop:1,children:a(s,{dimColor:!0,children:["\u2191\u2193 select tab focus c cancel r resume o open esc ",d==="none"?"close":"back"]})})]})}b(K,"LauncherOverlay");export{K as a};
@@ -1,2 +1,2 @@
1
- import{c as R}from"./chunk-6QKI756T.js";import{a as P}from"./chunk-5RBLIVBF.js";import{b as s,c as r,i as j}from"./chunk-45DOTNQM.js";import{a as g}from"./chunk-ZLLER3HP.js";import{and as y,eq as l,isNotNull as I}from"drizzle-orm";async function O($,p={}){let k=p.db??j(),b=p.removeWorktreeFn??R,n=p.log??(e=>process.stderr.write(`[process_run_cleanup] ${e}
1
+ import{b as s,c as r,i as j}from"./chunk-45DOTNQM.js";import{c as R}from"./chunk-6QKI756T.js";import{a as P}from"./chunk-5RBLIVBF.js";import{a as g}from"./chunk-ZLLER3HP.js";import{and as y,eq as l,isNotNull as I}from"drizzle-orm";async function O($,p={}){let k=p.db??j(),b=p.removeWorktreeFn??R,n=p.log??(e=>process.stderr.write(`[process_run_cleanup] ${e}
2
2
  `)),{runId:t}=$,[i]=await k.select({id:s.id,userId:s.userId,projectPath:s.projectPath}).from(s).where(l(s.id,t)).limit(1);if(!i)throw new P(`Run ${t} not found`);if(!i.projectPath)throw new P(`Run ${t} has no projectPath; cannot resolve a repo root for worktree cleanup`);let c=i.projectPath,v=await k.select({id:r.id,projectPath:r.projectPath}).from(r).where(y(l(r.runId,t),l(r.userId,i.userId),I(r.endedAt))),a=[],u=0,d=0,h=0,m=0,w=new Set;for(let e of v)if(!(!e.projectPath||e.projectPath===c)&&!w.has(e.projectPath)){w.add(e.projectPath);try{let o=await b({repoRoot:c,worktreePath:e.projectPath});o.removed?(u++,a.push({sessionId:e.id,worktreePath:e.projectPath,status:"removed"}),n(`removed worktree ${e.projectPath} (session ${e.id})`)):o.reason==="dirty"?(d++,a.push({sessionId:e.id,worktreePath:e.projectPath,status:"skipped-dirty"}),n(`skipped dirty worktree ${e.projectPath} (session ${e.id}) \u2014 uncommitted changes`)):(h++,a.push({sessionId:e.id,worktreePath:e.projectPath,status:"absent"}),n(`worktree absent ${e.projectPath} (session ${e.id})`))}catch(o){let f=o instanceof Error?o.message:String(o);m++,a.push({sessionId:e.id,worktreePath:e.projectPath,status:"error",error:f.slice(0,1e3)}),n(`error removing worktree ${e.projectPath} (session ${e.id}): ${f}`)}}return n(`run ${t} cleanup: removed=${u} skippedDirty=${d} absent=${h} errored=${m}`),{runId:t,repoRoot:c,removed:u,skippedDirty:d,absent:h,errored:m,worktrees:a}}g(O,"processRunCleanup");export{O as a};
@@ -1 +1 @@
1
- import{d as m,e as p}from"./chunk-5R5RGKOW.js";import{a as C}from"./chunk-N7TGRFVZ.js";import{f as c,i as f}from"./chunk-45DOTNQM.js";import{a as r}from"./chunk-ZLLER3HP.js";import*as a from"node:fs/promises";import*as g from"node:path";import{eq as b}from"drizzle-orm";async function v(e){let n=e;for(let t=0;t<50;t++){try{return await a.stat(g.join(n,"pnpm-workspace.yaml")),n}catch{}let i=g.dirname(n);if(i===n)return null;n=i}return null}r(v,"findRepoRoot");async function k(e){if(e)try{return await a.readFile(e,"utf-8")}catch{return null}let n=await v(process.cwd())??process.cwd(),t=g.join(n,"CHANGELOG.md");try{return await a.readFile(t,"utf-8")}catch{return null}}r(k,"readChangelog");var _="https://rulemetric.com";function D(e){let n=e.date??new Date().toISOString().slice(0,10),t=C({version:e.version,date:n,sections:e.sections,unsubscribeUrl:"{{unsubscribe_url}}",recipientName:"{{recipient_name}}",productUrl:_});return{version:e.version,releaseDate:n,subject:t.subject,htmlBody:t.html,textBody:t.text,sections:e.sections}}r(D,"renderRow");async function R(e={}){let n=e.db??f(),t=e.logger??{info:r(s=>console.log(s),"info"),warn:r(s=>console.warn(s),"warn")},i=await k(e.changelogPath);if(i===null)return t.info("[cron_check_changelog] CHANGELOG.md not found; nothing to do"),{createdCount:0,skippedCount:0};let y=m(i),h=p(y);if(h.length===0)return t.info("[cron_check_changelog] No announceable entries; nothing to do"),{createdCount:0,skippedCount:0};let d=0,l=0;for(let s of h){if((await n.select({id:c.id}).from(c).where(b(c.version,s.version)).limit(1)).length>0){l++;continue}let o=D(s);try{await n.insert(c).values({version:o.version,releaseDate:o.releaseDate,subject:o.subject,htmlBody:o.htmlBody,textBody:o.textBody,sections:o.sections,status:"draft"}),d++,t.info(`[cron_check_changelog] Created draft announcement for ${o.version}`)}catch(u){let w=u instanceof Error?u.message:String(u);if(/duplicate key|unique/i.test(w)){l++;continue}throw u}}return t.info(`[cron_check_changelog] Done: created ${d}, skipped ${l}`),{createdCount:d,skippedCount:l}}r(R,"processChangelog");export{R as a};
1
+ import{a as C}from"./chunk-N7TGRFVZ.js";import{f as c,i as f}from"./chunk-45DOTNQM.js";import{d as m,e as p}from"./chunk-5R5RGKOW.js";import{a as r}from"./chunk-ZLLER3HP.js";import*as a from"node:fs/promises";import*as g from"node:path";import{eq as b}from"drizzle-orm";async function v(e){let n=e;for(let t=0;t<50;t++){try{return await a.stat(g.join(n,"pnpm-workspace.yaml")),n}catch{}let i=g.dirname(n);if(i===n)return null;n=i}return null}r(v,"findRepoRoot");async function k(e){if(e)try{return await a.readFile(e,"utf-8")}catch{return null}let n=await v(process.cwd())??process.cwd(),t=g.join(n,"CHANGELOG.md");try{return await a.readFile(t,"utf-8")}catch{return null}}r(k,"readChangelog");var _="https://rulemetric.com";function D(e){let n=e.date??new Date().toISOString().slice(0,10),t=C({version:e.version,date:n,sections:e.sections,unsubscribeUrl:"{{unsubscribe_url}}",recipientName:"{{recipient_name}}",productUrl:_});return{version:e.version,releaseDate:n,subject:t.subject,htmlBody:t.html,textBody:t.text,sections:e.sections}}r(D,"renderRow");async function R(e={}){let n=e.db??f(),t=e.logger??{info:r(s=>console.log(s),"info"),warn:r(s=>console.warn(s),"warn")},i=await k(e.changelogPath);if(i===null)return t.info("[cron_check_changelog] CHANGELOG.md not found; nothing to do"),{createdCount:0,skippedCount:0};let y=m(i),h=p(y);if(h.length===0)return t.info("[cron_check_changelog] No announceable entries; nothing to do"),{createdCount:0,skippedCount:0};let d=0,l=0;for(let s of h){if((await n.select({id:c.id}).from(c).where(b(c.version,s.version)).limit(1)).length>0){l++;continue}let o=D(s);try{await n.insert(c).values({version:o.version,releaseDate:o.releaseDate,subject:o.subject,htmlBody:o.htmlBody,textBody:o.textBody,sections:o.sections,status:"draft"}),d++,t.info(`[cron_check_changelog] Created draft announcement for ${o.version}`)}catch(u){let w=u instanceof Error?u.message:String(u);if(/duplicate key|unique/i.test(w)){l++;continue}throw u}}return t.info(`[cron_check_changelog] Done: created ${d}, skipped ${l}`),{createdCount:d,skippedCount:l}}r(R,"processChangelog");export{R as a};
@@ -0,0 +1,2 @@
1
+ import{a as c}from"./chunk-ZLLER3HP.js";import*as n from"node:fs";import*as i from"node:path";import*as E from"node:os";import{spawnSync as f}from"node:child_process";var m=i.join(E.homedir(),".config","rulemetric","local"),u=i.join(m,"runtime"),R=m,A="com.rulemetric.local",_="rulemetric-local",S={54420:"54620",54421:"54621",54422:"54622",54423:"54623",54424:"54624",54429:"54629",54327:"54627"};function g(r){let t=i.join(r,"dist"),e=i.join(t,"meta.json"),s=i.join(t,"server.mjs");if(!n.existsSync(e)||!n.existsSync(s))return null;let o;try{o=JSON.parse(n.readFileSync(e,"utf-8")).version??""}catch{return null}if(!o)return null;let a=i.join(t,"supabase","email-templates"),l=i.join(t,"skills-registry.json");return{root:r,version:o,serverEntry:s,webDist:i.join(t,"web"),migrationsDir:i.join(t,"supabase","migrations"),configToml:i.join(t,"supabase","config.toml"),emailTemplatesDir:n.existsSync(a)?a:null,skillsRegistry:n.existsSync(l)?l:null}}c(g,"inspectLocalPackage");function d(){let r=process.env.RULEMETRIC_LOCAL_PKG_PATH;return g(r||i.join(u,"node_modules","@rulemetric","local"))}c(d,"findLocalPackage");function P(r,t){return r!==t}c(P,"versionSkew");function D(r,t){n.mkdirSync(u,{recursive:!0}),t(`[..] Installing @rulemetric/local@${r} into ${u}...`);let e=f("npm",["install","--prefix",u,"--no-fund","--no-audit","--loglevel=error",`@rulemetric/local@${r}`],{encoding:"utf-8",stdio:["ignore","pipe","pipe"]});return e.status!==0?{ok:!1,error:(e.stderr||e.stdout||`npm exited ${e.status}`).trim()}:{ok:!0}}c(D,"installLocalPackage");function L(r){let t=r.replace(/^project_id\s*=\s*".*"$/m,`project_id = "${_}"`);for(let[e,s]of Object.entries(S))t=t.replace(new RegExp(`(=\\s*)${e}\\b`,"g"),`$1${s}`);return t}c(L,"rewriteConfigToml");function h(r,t=R){let e=i.join(t,"supabase");n.mkdirSync(e,{recursive:!0}),n.writeFileSync(i.join(e,"config.toml"),L(n.readFileSync(r.configToml,"utf-8")));let s=i.join(e,"migrations");if(n.rmSync(s,{recursive:!0,force:!0}),n.cpSync(r.migrationsDir,s,{recursive:!0}),r.emailTemplatesDir){let o=i.join(e,"email-templates");n.rmSync(o,{recursive:!0,force:!0}),n.cpSync(r.emailTemplatesDir,o,{recursive:!0})}return t}c(h,"prepareSupabaseWorkdir");function v(r){let t={};for(let e of r.split(`
2
+ `)){let s=/^([A-Z0-9_]+)=(.*)$/.exec(e.trim());if(!s)continue;let o=s[2];o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1)),t[s[1]]=o}return t}c(v,"parseStatusEnv");function y(r){let{statusEnv:t,pkg:e,port:s,cliVersion:o}=r,a=t.ANON_KEY??t.PUBLISHABLE_KEY??"",l=t.SERVICE_ROLE_KEY??t.SECRET_KEY??"",p={DATABASE_URL:t.DB_URL??"",SUPABASE_URL:t.API_URL??"",SUPABASE_ANON_KEY:a,SUPABASE_SERVICE_ROLE_KEY:l,RULEMETRIC_DEPLOYMENT:"local",RULEMETRIC_STRICT_LOCAL:"1",RULEMETRIC_BUNDLED_CLI_VERSION:o,WEB_DIST_PATH:e.webDist,WEB_URL:`http://localhost:${s}`,RULEMETRIC_WEB_URL:`http://localhost:${s}`,API_PORT:String(s),PORT:String(s),NODE_ENV:"production",SENTRY_DSN:"",OTEL_SPAN_EXPORT:"none"};return t.JWT_SECRET&&(p.SUPABASE_JWT_SECRET=t.JWT_SECRET),e.skillsRegistry&&(p.RULEMETRIC_SKILLS_REGISTRY_PATH=e.skillsRegistry),p}c(y,"buildServerEnv");export{m as a,u as b,R as c,A as d,_ as e,S as f,g,d as h,P as i,D as j,L as k,h as l,v as m,y as n};
@@ -1,4 +1,4 @@
1
- import{a as S,b as z,c as T}from"./chunk-QFVGUZDO.js";import{a as O}from"./chunk-5R5RGKOW.js";import{a as j}from"./chunk-5RBLIVBF.js";import{c as A,d as C,f as b}from"./chunk-B3BHB26P.js";import{e as _,f as I,h as u}from"./chunk-KLEF5D3A.js";import{a as $}from"./chunk-ZLLER3HP.js";async function D(f,m){let{mirrorId:o,projectPath:s,projectId:i,config:p}=f,e=$(n=>m.logger.info(n),"log");if(p?.sessionId)return M({mirrorId:o,sessionId:p.sessionId},e);e(`Processing insights job ${o}...`),await u(`/api/insights-jobs/${o}/progress`,{status:"running",progress:{step:"reading_data"}});try{let{repaired:n}=await I("/api/sessions/repair-analyzed-at",{});n>0&&e(` Repaired analyzed_at on ${n} orphan session(s).`)}catch(n){e(` Warning: analyzed_at repair failed: ${n instanceof Error?n.message:String(n)}`)}let a=await J(s,i);if(!a)throw new j("No session data found \u2014 ensure sessions are captured and enriched.");e(` Found ${a.stats.sessions} sessions, generating recommendations...`);let w=20,c=200;if(C()!=="none"){let n=0,t=0;try{for(;n<c;){let l=await _(`/api/sessions?hasAnalysis=false&limit=${w}&offset=${t}`);if(l.length===0)break;e(` Generating facets for ${l.length} un-analyzed sessions (drained ${n} so far)...`);for(let g of l){if(n>=c)break;try{let d=await _(`/api/sessions/${g.id}/events?limit=100`);if(d.length<2){n++,t++;continue}let P=d.filter(h=>h.eventType==="user_message"||h.eventType==="human").map(h=>h.content?.slice(0,200)??"").filter(Boolean).join(`
1
+ import{a as S,b as z,c as T}from"./chunk-QFVGUZDO.js";import{a as j}from"./chunk-5RBLIVBF.js";import{a as O}from"./chunk-5R5RGKOW.js";import{c as A,d as C,f as b}from"./chunk-B3BHB26P.js";import{e as _,f as I,h as u}from"./chunk-KLEF5D3A.js";import{a as $}from"./chunk-ZLLER3HP.js";async function D(f,m){let{mirrorId:o,projectPath:s,projectId:i,config:p}=f,e=$(n=>m.logger.info(n),"log");if(p?.sessionId)return M({mirrorId:o,sessionId:p.sessionId},e);e(`Processing insights job ${o}...`),await u(`/api/insights-jobs/${o}/progress`,{status:"running",progress:{step:"reading_data"}});try{let{repaired:n}=await I("/api/sessions/repair-analyzed-at",{});n>0&&e(` Repaired analyzed_at on ${n} orphan session(s).`)}catch(n){e(` Warning: analyzed_at repair failed: ${n instanceof Error?n.message:String(n)}`)}let a=await J(s,i);if(!a)throw new j("No session data found \u2014 ensure sessions are captured and enriched.");e(` Found ${a.stats.sessions} sessions, generating recommendations...`);let w=20,c=200;if(C()!=="none"){let n=0,t=0;try{for(;n<c;){let l=await _(`/api/sessions?hasAnalysis=false&limit=${w}&offset=${t}`);if(l.length===0)break;e(` Generating facets for ${l.length} un-analyzed sessions (drained ${n} so far)...`);for(let g of l){if(n>=c)break;try{let d=await _(`/api/sessions/${g.id}/events?limit=100`);if(d.length<2){n++,t++;continue}let P=d.filter(h=>h.eventType==="user_message"||h.eventType==="human").map(h=>h.content?.slice(0,200)??"").filter(Boolean).join(`
2
2
  ---
3
3
  `);if(!P){n++,t++;continue}let E=await b(T,P,4096);if(E){let h=d.filter(R=>R.eventType==="user_message"||R.eventType==="human").length;await u(`/api/sessions/${g.id}/enrich`,{analysis:{source:"generated_facets",...E},analyzedEventCount:d.length,analyzedTurnCount:h}),e(` Generated facets for session ${g.id} (${g.tool})`)}else t++;n++}catch(d){e(` Failed to generate facets for session ${g.id}: ${d instanceof Error?d.message:String(d)}`),n++,t++}}if(l.length<w)break}}catch(l){e(` Warning: facet generation failed after ${n} sessions: ${l instanceof Error?l.message:String(l)}`)}}let r={},y=S.length+1;for(let n=0;n<S.length;n++){let t=S[n];e(` [${n+1}/${y}] Generating ${t.name}...`);try{await u(`/api/insights-jobs/${o}/progress`,{status:"running",progress:{step:t.name,current:n+1,total:y,partial:{...r}}})}catch(g){e(` Warning: progress update failed for ${t.name}: ${g instanceof Error?g.message:String(g)}`)}e(` Running LLM prompt for ${t.name}...`);let l=await b(t.prompt,a.summary,t.maxTokens);l?(r[t.name]=l,e(` Got result for ${t.name}`)):e(` No result for ${t.name} (LLM returned null)`)}e(` [${y}/${y}] Generating at_a_glance...`),await u(`/api/insights-jobs/${o}/progress`,{status:"running",progress:{step:"at_a_glance",current:y,total:y,partial:{...r}}});let N=[a.summary,r.what_works?`
4
4
  ## What Works
@@ -1 +1 @@
1
- import{c as C}from"./chunk-5XUN743A.js";import{a as y}from"./chunk-RSKQRVPJ.js";import{a as H}from"./chunk-HXZM2UHO.js";import{a as A}from"./chunk-O2BKBW7Z.js";import{a as E}from"./chunk-KGQ5W54Y.js";import{a as I}from"./chunk-O7PSLZO6.js";import{a as x}from"./chunk-MOAJLSYV.js";import{b as S}from"./chunk-BLCMXTIK.js";import{a as M}from"./chunk-QUDMK76I.js";import{a as L}from"./chunk-EF6JLMNH.js";import{a as P}from"./chunk-EN43UYBN.js";import{a as N}from"./chunk-FAXV5AAG.js";import{a as k}from"./chunk-UF6US7VU.js";import{b as _}from"./chunk-6ME5OTS5.js";import{b as R}from"./chunk-YW3JQKGY.js";import{a as T}from"./chunk-7UCNONVI.js";import{b as h}from"./chunk-5RBLIVBF.js";import{j as b}from"./chunk-2RCWYVEU.js";import{d as w}from"./chunk-NTKO4H2K.js";import{b as f,e as v,f as p}from"./chunk-KLEF5D3A.js";import{a as s}from"./chunk-ZLLER3HP.js";var W={process_eval:E,process_insights:I,process_launch:S,process_send_message:y,process_conversation:A,process_session_goal:H,distill_memories:R,memory_ab:M,process_announcement:T,process_run_cleanup:L,cron_suggest_instructions:_,cron_refresh_skills:k,cron_refresh_pricing:N,cron_eval_autorun:P,cron_instruction_evolution:b,process_judge_review:x},D=Object.keys(W),F=new Set(["process_announcement","process_run_cleanup","memory_ab"]);function J(e=process.env){return e.DATABASE_URL?D:D.filter(n=>!F.has(n))}s(J,"availableCapabilities");var U=3e4,K=3e4,G=3e4,V=250,B=5e3,q=`thin-agent-${process.pid}`,g=null;function Q(e,n,r,l){let c;try{let d=w();c={claude:d.claudeBin!=null,codex:d.codexBin!=null,codexModel:d.codexConfiguredModel}}catch{}let i=s(d=>{p("/api/workers/heartbeat",{workerType:"cli-worker",clientName:q,clientVersion:l,workerVersion:"0.1.0",currentJobId:null,inFlightCount:0,lastError:null,status:d,metadata:{capabilities:e,mode:"thin-agent",llmEngines:c}}).then(u=>{let t=u?.advisory;t&&t.message!==g?(g=t.message,a(r,{event:"worker_advisory",code:t.code,message:t.message})):t||(g=null)}).catch(u=>{a(r,{event:"presence_heartbeat_error",error:u instanceof Error?u.message:String(u)})})},"send");i("alive");let o=setInterval(()=>i("alive"),G);n.addEventListener("abort",()=>{clearInterval(o),i("shutting_down")},{once:!0})}s(Q,"startPresenceHeartbeat");function a(e,n){try{e(JSON.stringify({ts:new Date().toISOString(),...n}))}catch{e(`[agent-loop] log_error event=${n.event}`)}}s(a,"structuredLog");function O(e,n){return n.aborted?Promise.resolve(!1):e<=0?Promise.resolve(!0):new Promise(r=>{let l=setTimeout(()=>{n.removeEventListener("abort",c),r(!0)},e),c=s(()=>{clearTimeout(l),n.removeEventListener("abort",c),r(!1)},"onAbort");n.addEventListener("abort",c,{once:!0})})}s(O,"abortableSleep");async function X(e,n){let r=`capabilities=${encodeURIComponent(e.join(","))}&waitMs=${n}`,l=await v(`/api/work/next?${r}`);return l==null||typeof l=="string"?null:l}s(X,"pollForWork");function z(e,n){return{logger:{info:s(r=>n(r),"info"),warn:s(r=>n(r),"warn"),error:s(r=>n(r),"error")},job:{attempts:e}}}s(z,"makeHelpers");async function Y(e,n,r){let l=W[e.kind],c=Date.now();if(a(r,{event:"claim",jobId:e.id,kind:e.kind,attempts:e.attempts}),!l){let o=`unknown kind: ${e.kind}`;a(r,{event:"fail",jobId:e.id,kind:e.kind,terminal:!0,error:o}),await p(`/api/work/${e.id}/fail`,{leaseToken:e.leaseToken,error:o,terminal:!0}).catch(()=>{});return}let i=setInterval(()=>{a(r,{event:"heartbeat",jobId:e.id}),p(`/api/work/${e.id}/heartbeat`,{leaseToken:e.leaseToken}).catch(o=>{a(r,{event:"heartbeat_error",jobId:e.id,error:o instanceof Error?o.message:String(o)})})},n);try{let o=z(e.attempts,r),d=await l(e.payload,o)??{};clearInterval(i),a(r,{event:"complete",jobId:e.id,kind:e.kind,durationMs:Date.now()-c}),await p(`/api/work/${e.id}/complete`,{leaseToken:e.leaseToken,result:d})}catch(o){clearInterval(i);let d=h(o),u=o instanceof Error?o.message:String(o);a(r,{event:"fail",jobId:e.id,kind:e.kind,durationMs:Date.now()-c,terminal:d,error:u}),await p(`/api/work/${e.id}/fail`,{leaseToken:e.leaseToken,error:u,terminal:d}).catch(t=>{a(r,{event:"fail_post_error",jobId:e.id,error:t instanceof Error?t.message:String(t)})})}}s(Y,"runOne");async function we(e){let n=e.log??(()=>{}),r=e.pollWaitMs??U,l=e.heartbeatIntervalMs??K,c=e.capabilities??J(),i=V;a(n,{event:"agent_start",capabilities:c,pollWaitMs:r,heartbeatIntervalMs:l}),Q(c,e.signal,n,e.version),C({signal:e.signal,log:n}).catch(t=>{a(n,{event:"tt_heartbeat_fatal",error:t instanceof Error?t.message:String(t)})});let o=5*6e4,d=0,u=s(()=>{if(!e.readInstalledVersion||!e.version)return!1;let t=Date.now();if(t-d<o)return!1;d=t;let m=e.readInstalledVersion();return!!(m&&m!==e.version)},"versionDrifted");for(;!e.signal.aborted;){if(u()){a(n,{event:"agent_version_drift",bootVersion:e.version,installedVersion:e.readInstalledVersion?.()??null}),e.onVersionDrift?.();break}let t=null;try{t=await X(c,r)}catch(m){let $=m instanceof f?m.statusCode:void 0;if(a(n,{event:"poll_error",status:$,error:m instanceof Error?m.message:String(m)}),!await O(i,e.signal))break;i=Math.min(i*2,B);continue}if(!t){if(a(n,{event:"poll_204"}),!await O(i,e.signal))break;i=Math.min(i*2,B);continue}i=V,await Y(t,l,n)}a(n,{event:"agent_stop"})}s(we,"runAgentLoop");export{W as a,D as b,J as c,X as d,we as e};
1
+ import{c as C}from"./chunk-5XUN743A.js";import{a as M}from"./chunk-QUDMK76I.js";import{a as L}from"./chunk-C7YRLB37.js";import{a as y}from"./chunk-RSKQRVPJ.js";import{a as H}from"./chunk-HXZM2UHO.js";import{b as R}from"./chunk-YW3JQKGY.js";import{a as T}from"./chunk-2J3IHWE2.js";import{a as A}from"./chunk-O2BKBW7Z.js";import{a as E}from"./chunk-KGQ5W54Y.js";import{a as I}from"./chunk-JCXKWHZX.js";import{a as x}from"./chunk-MOAJLSYV.js";import{b as S}from"./chunk-BLCMXTIK.js";import{b as h}from"./chunk-5RBLIVBF.js";import{a as P}from"./chunk-EN43UYBN.js";import{a as N}from"./chunk-FAXV5AAG.js";import{a as k}from"./chunk-UF6US7VU.js";import{b as _}from"./chunk-6ME5OTS5.js";import{j as b}from"./chunk-2RCWYVEU.js";import{d as w}from"./chunk-NTKO4H2K.js";import{b as f,e as v,f as p}from"./chunk-KLEF5D3A.js";import{a as s}from"./chunk-ZLLER3HP.js";var W={process_eval:E,process_insights:I,process_launch:S,process_send_message:y,process_conversation:A,process_session_goal:H,distill_memories:R,memory_ab:M,process_announcement:T,process_run_cleanup:L,cron_suggest_instructions:_,cron_refresh_skills:k,cron_refresh_pricing:N,cron_eval_autorun:P,cron_instruction_evolution:b,process_judge_review:x},D=Object.keys(W),F=new Set(["process_announcement","process_run_cleanup","memory_ab"]);function J(e=process.env){return e.DATABASE_URL?D:D.filter(n=>!F.has(n))}s(J,"availableCapabilities");var U=3e4,K=3e4,G=3e4,V=250,B=5e3,q=`thin-agent-${process.pid}`,g=null;function Q(e,n,r,l){let c;try{let d=w();c={claude:d.claudeBin!=null,codex:d.codexBin!=null,codexModel:d.codexConfiguredModel}}catch{}let i=s(d=>{p("/api/workers/heartbeat",{workerType:"cli-worker",clientName:q,clientVersion:l,workerVersion:"0.1.0",currentJobId:null,inFlightCount:0,lastError:null,status:d,metadata:{capabilities:e,mode:"thin-agent",llmEngines:c}}).then(u=>{let t=u?.advisory;t&&t.message!==g?(g=t.message,a(r,{event:"worker_advisory",code:t.code,message:t.message})):t||(g=null)}).catch(u=>{a(r,{event:"presence_heartbeat_error",error:u instanceof Error?u.message:String(u)})})},"send");i("alive");let o=setInterval(()=>i("alive"),G);n.addEventListener("abort",()=>{clearInterval(o),i("shutting_down")},{once:!0})}s(Q,"startPresenceHeartbeat");function a(e,n){try{e(JSON.stringify({ts:new Date().toISOString(),...n}))}catch{e(`[agent-loop] log_error event=${n.event}`)}}s(a,"structuredLog");function O(e,n){return n.aborted?Promise.resolve(!1):e<=0?Promise.resolve(!0):new Promise(r=>{let l=setTimeout(()=>{n.removeEventListener("abort",c),r(!0)},e),c=s(()=>{clearTimeout(l),n.removeEventListener("abort",c),r(!1)},"onAbort");n.addEventListener("abort",c,{once:!0})})}s(O,"abortableSleep");async function X(e,n){let r=`capabilities=${encodeURIComponent(e.join(","))}&waitMs=${n}`,l=await v(`/api/work/next?${r}`);return l==null||typeof l=="string"?null:l}s(X,"pollForWork");function z(e,n){return{logger:{info:s(r=>n(r),"info"),warn:s(r=>n(r),"warn"),error:s(r=>n(r),"error")},job:{attempts:e}}}s(z,"makeHelpers");async function Y(e,n,r){let l=W[e.kind],c=Date.now();if(a(r,{event:"claim",jobId:e.id,kind:e.kind,attempts:e.attempts}),!l){let o=`unknown kind: ${e.kind}`;a(r,{event:"fail",jobId:e.id,kind:e.kind,terminal:!0,error:o}),await p(`/api/work/${e.id}/fail`,{leaseToken:e.leaseToken,error:o,terminal:!0}).catch(()=>{});return}let i=setInterval(()=>{a(r,{event:"heartbeat",jobId:e.id}),p(`/api/work/${e.id}/heartbeat`,{leaseToken:e.leaseToken}).catch(o=>{a(r,{event:"heartbeat_error",jobId:e.id,error:o instanceof Error?o.message:String(o)})})},n);try{let o=z(e.attempts,r),d=await l(e.payload,o)??{};clearInterval(i),a(r,{event:"complete",jobId:e.id,kind:e.kind,durationMs:Date.now()-c}),await p(`/api/work/${e.id}/complete`,{leaseToken:e.leaseToken,result:d})}catch(o){clearInterval(i);let d=h(o),u=o instanceof Error?o.message:String(o);a(r,{event:"fail",jobId:e.id,kind:e.kind,durationMs:Date.now()-c,terminal:d,error:u}),await p(`/api/work/${e.id}/fail`,{leaseToken:e.leaseToken,error:u,terminal:d}).catch(t=>{a(r,{event:"fail_post_error",jobId:e.id,error:t instanceof Error?t.message:String(t)})})}}s(Y,"runOne");async function we(e){let n=e.log??(()=>{}),r=e.pollWaitMs??U,l=e.heartbeatIntervalMs??K,c=e.capabilities??J(),i=V;a(n,{event:"agent_start",capabilities:c,pollWaitMs:r,heartbeatIntervalMs:l}),Q(c,e.signal,n,e.version),C({signal:e.signal,log:n}).catch(t=>{a(n,{event:"tt_heartbeat_fatal",error:t instanceof Error?t.message:String(t)})});let o=5*6e4,d=0,u=s(()=>{if(!e.readInstalledVersion||!e.version)return!1;let t=Date.now();if(t-d<o)return!1;d=t;let m=e.readInstalledVersion();return!!(m&&m!==e.version)},"versionDrifted");for(;!e.signal.aborted;){if(u()){a(n,{event:"agent_version_drift",bootVersion:e.version,installedVersion:e.readInstalledVersion?.()??null}),e.onVersionDrift?.();break}let t=null;try{t=await X(c,r)}catch(m){let $=m instanceof f?m.statusCode:void 0;if(a(n,{event:"poll_error",status:$,error:m instanceof Error?m.message:String(m)}),!await O(i,e.signal))break;i=Math.min(i*2,B);continue}if(!t){if(a(n,{event:"poll_204"}),!await O(i,e.signal))break;i=Math.min(i*2,B);continue}i=V,await Y(t,l,n)}a(n,{event:"agent_stop"})}s(we,"runAgentLoop");export{W as a,D as b,J as c,X as d,we as e};
@@ -0,0 +1,6 @@
1
+ import{a as o}from"./chunk-ZLLER3HP.js";import{execFileSync as i}from"node:child_process";import{writeFileSync as l}from"node:fs";function g(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}o(g,"escapeXml");function b(t){return Object.entries(t).map(([r,e])=>` <key>${g(r)}</key>
2
+ <string>${g(e)}</string>`).join(`
3
+ `)}o(b,"buildEnvDictEntries");var p=["Could not find specified service","No such process","3: No such process","5: Input/output error"];function $(t,r,e,s){try{i("launchctl",["bootout",`gui/${t}`,r],{encoding:"utf-8",stdio:["ignore","pipe","pipe"]})}catch(n){let c=n.message||"",u=(n.stderr??"").toString(),a=`${c}
4
+ ${u}`;p.some(d=>a.includes(d))||s(`Could not unload existing service at ${r}: ${c.trim()}`)}l(r,e,{mode:384})}o($,"bootoutAndWrite");function E(t,r,e){try{return i("launchctl",["bootstrap",`gui/${t}`,r]),!0}catch(s){try{return i("launchctl",["load",r]),!0}catch(n){return e(`Could not load service.
5
+ bootstrap: ${s.message.trim()}
6
+ load: ${n.message.trim()}`),!1}}}o(E,"bootstrapPlist");export{g as a,b,$ as c,E as d};
@@ -1,3 +1,3 @@
1
- import{a as C,b as L,c as D}from"../../chunk-GWDZNGUP.js";import{e as I}from"../../chunk-FNGVEZPD.js";import"../../chunk-5XUN743A.js";import"../../chunk-RSKQRVPJ.js";import"../../chunk-HXZM2UHO.js";import"../../chunk-O2BKBW7Z.js";import"../../chunk-KGQ5W54Y.js";import"../../chunk-O7PSLZO6.js";import"../../chunk-QFVGUZDO.js";import"../../chunk-MOAJLSYV.js";import"../../chunk-BLCMXTIK.js";import"../../chunk-QUDMK76I.js";import"../../chunk-EF6JLMNH.js";import"../../chunk-6QKI756T.js";import"../../chunk-EN43UYBN.js";import"../../chunk-FAXV5AAG.js";import"../../chunk-UF6US7VU.js";import"../../chunk-6ME5OTS5.js";import"../../chunk-5R5RGKOW.js";import"../../chunk-YW3JQKGY.js";import"../../chunk-7UCNONVI.js";import"../../chunk-N7TGRFVZ.js";import"../../chunk-5RBLIVBF.js";import{j as d}from"../../chunk-45DOTNQM.js";import"../../chunk-5KD2N2MH.js";import"../../chunk-YQ56FQEO.js";import"../../chunk-GIRPEMTW.js";import"../../chunk-MODXEGCU.js";import"../../chunk-7DFNBRLY.js";import"../../chunk-4VZLIGMS.js";import"../../chunk-CNOD6HWU.js";import"../../chunk-AI6FMGKM.js";import"../../chunk-6UEFCMR2.js";import"../../chunk-2RCWYVEU.js";import"../../chunk-RMDLJN4L.js";import"../../chunk-BL4BN6RU.js";import"../../chunk-DBELYMDA.js";import"../../chunk-NTKO4H2K.js";import"../../chunk-CJRYYV76.js";import"../../chunk-ATL4WZBF.js";import"../../chunk-L2CFSMBC.js";import"../../chunk-Z72VHGV7.js";import"../../chunk-4L2ZEIRE.js";import"../../chunk-CDY7TQFZ.js";import"../../chunk-XRTZU7IZ.js";import"../../chunk-B3BHB26P.js";import"../../chunk-N7ODX6PO.js";import"../../chunk-PJ3WHQ67.js";import"../../chunk-G5BXZT6F.js";import"../../chunk-HMMO27U4.js";import{b as k,f as h,h as A}from"../../chunk-QXPYGN7I.js";import{a as O}from"../../chunk-LWI5K6T4.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-6VKQT2J3.js";import"../../chunk-NIRD7ETU.js";import"../../chunk-QY3UKLDE.js";import"../../chunk-3AV3GTMP.js";import{f as b}from"../../chunk-KLEF5D3A.js";import{e as P,l as f}from"../../chunk-JZ5Z2BRO.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{e as I}from"../../chunk-OMD3JCGB.js";import"../../chunk-5XUN743A.js";import"../../chunk-QUDMK76I.js";import"../../chunk-C7YRLB37.js";import"../../chunk-RSKQRVPJ.js";import"../../chunk-HXZM2UHO.js";import"../../chunk-YW3JQKGY.js";import"../../chunk-2J3IHWE2.js";import"../../chunk-N7TGRFVZ.js";import{j as d}from"../../chunk-45DOTNQM.js";import"../../chunk-O2BKBW7Z.js";import"../../chunk-KGQ5W54Y.js";import"../../chunk-JCXKWHZX.js";import"../../chunk-QFVGUZDO.js";import"../../chunk-MOAJLSYV.js";import"../../chunk-BLCMXTIK.js";import"../../chunk-6QKI756T.js";import"../../chunk-5RBLIVBF.js";import"../../chunk-EN43UYBN.js";import"../../chunk-FAXV5AAG.js";import"../../chunk-UF6US7VU.js";import"../../chunk-6ME5OTS5.js";import"../../chunk-5R5RGKOW.js";import"../../chunk-YQ56FQEO.js";import"../../chunk-5KD2N2MH.js";import"../../chunk-GIRPEMTW.js";import"../../chunk-MODXEGCU.js";import"../../chunk-7DFNBRLY.js";import"../../chunk-4VZLIGMS.js";import"../../chunk-CNOD6HWU.js";import"../../chunk-AI6FMGKM.js";import"../../chunk-6UEFCMR2.js";import"../../chunk-2RCWYVEU.js";import"../../chunk-RMDLJN4L.js";import"../../chunk-BL4BN6RU.js";import"../../chunk-DBELYMDA.js";import"../../chunk-NTKO4H2K.js";import"../../chunk-CJRYYV76.js";import"../../chunk-ATL4WZBF.js";import"../../chunk-L2CFSMBC.js";import"../../chunk-Z72VHGV7.js";import"../../chunk-4L2ZEIRE.js";import"../../chunk-CDY7TQFZ.js";import"../../chunk-XRTZU7IZ.js";import"../../chunk-B3BHB26P.js";import"../../chunk-N7ODX6PO.js";import"../../chunk-PJ3WHQ67.js";import"../../chunk-G5BXZT6F.js";import"../../chunk-HMMO27U4.js";import{b as k,f as h,h as A}from"../../chunk-QXPYGN7I.js";import{a as O}from"../../chunk-LWI5K6T4.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-6VKQT2J3.js";import"../../chunk-NIRD7ETU.js";import"../../chunk-QY3UKLDE.js";import"../../chunk-3AV3GTMP.js";import{f as b}from"../../chunk-KLEF5D3A.js";import{e as P,l as f}from"../../chunk-JZ5Z2BRO.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};
@@ -0,0 +1 @@
1
+ import{c as t,d as c}from"../../chunk-HRXACKAH.js";import{a as l}from"../../chunk-LWI5K6T4.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-6VKQT2J3.js";import"../../chunk-NIRD7ETU.js";import"../../chunk-QY3UKLDE.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-KLEF5D3A.js";import"../../chunk-JZ5Z2BRO.js";import{a as i}from"../../chunk-ZLLER3HP.js";import{Flags as u}from"@oclif/core";import{execFileSync as m,execSync as f,spawnSync as h}from"node:child_process";import{existsSync as d,rmSync as g}from"node:fs";import{homedir as b}from"node:os";import{join as n}from"node:path";var a=n(b(),"Library","LaunchAgents",`${c}.plist`),s=class p extends l{static{i(this,"LocalDown")}static description="Stop the local RuleMetric server and database stack. Data is preserved (restart with `rulemetric local up`); use --delete-data to also wipe the local database.";static flags={"delete-data":u.boolean({default:!1,description:"Also delete the local database volumes (irreversible)"})};async run(){let{flags:o}=await this.parse(p);if(process.platform==="darwin"&&d(a)){let e=f("id -u",{encoding:"utf-8"}).trim();try{m("launchctl",["bootout",`gui/${e}`,a],{stdio:["ignore","pipe","pipe"]}),this.log("[OK] Stopped the local server")}catch{}g(a,{force:!0})}if(d(n(t,"supabase","config.toml"))){let e=o["delete-data"]?["stop","--no-backup"]:["stop"],r=h("supabase",e,{cwd:t,stdio:"inherit"});r.status!==0?this.warn(`\`supabase ${e.join(" ")}\` exited ${r.status} \u2014 the stack may not have been running.`):this.log(o["delete-data"]?"[OK] Database stack stopped and data deleted":"[OK] Database stack stopped (data preserved)")}else this.log("No local stack configured (nothing to stop). Run: rulemetric local up")}};export{s as default};
@@ -0,0 +1,52 @@
1
+ import{a as o,b as O,c as x,d as U}from"../../chunk-XB4OMOSE.js";import{a as E,c as p,d as h,h as m,i as f,j as D,l as C,m as I,n as _}from"../../chunk-HRXACKAH.js";import{a as $}from"../../chunk-RJLAAKEN.js";import{a as A}from"../../chunk-LWI5K6T4.js";import"../../chunk-IZTIYR5Q.js";import{c as T}from"../../chunk-6VKQT2J3.js";import"../../chunk-NIRD7ETU.js";import{b as R}from"../../chunk-QY3UKLDE.js";import"../../chunk-3AV3GTMP.js";import{b as S,d}from"../../chunk-KLEF5D3A.js";import{d as L,h as P}from"../../chunk-JZ5Z2BRO.js";import{a as w}from"../../chunk-ZLLER3HP.js";import{Flags as l}from"@oclif/core";import{execSync as H,spawnSync as a}from"node:child_process";import{mkdirSync as M}from"node:fs";import{homedir as b}from"node:os";import{dirname as G,join as n}from"node:path";var K=n(b(),"Library","LaunchAgents",`${h}.plist`),g=n(b(),".config","rulemetric","logs"),v=class B extends A{static{w(this,"LocalUp")}static description="Run RuleMetric fully locally: start a local Supabase stack (Docker), apply migrations, and serve the API + dashboard from the @rulemetric/local runtime \u2014 all data on this machine, zero cloud contact. Downloads the runtime package on first run.";static examples=["<%= config.bin %> local up --email you@example.com --password <pw>","<%= config.bin %> local up --port 3000","<%= config.bin %> local up --foreground"];static flags={port:l.integer({char:"p",default:3e3,description:"Local API + dashboard port"}),email:l.string({char:"e",description:"Create the first user with this email (with --password)"}),password:l.string({description:"Password for the first user (min 8 chars)"}),foreground:l.boolean({default:!1,description:"Run the server in this terminal instead of installing a launchd service (works on any OS; skips user provisioning)"}),yes:l.boolean({char:"y",default:!1,description:"Skip the runtime-download confirmation"})};async run(){let{flags:s}=await this.parse(B),t=s.port;!s.foreground&&process.platform!=="darwin"&&this.error(`The managed local service is macOS-only (launchd) for now. On this OS, run the server in the foreground instead:
2
+ rulemetric local up --foreground`),a("docker",["info"],{stdio:"ignore"}).status!==0&&this.error(`Docker is not running (or not installed). The local database runs in Docker.
3
+ Install/start Docker Desktop (or colima), then re-run: rulemetric local up`),a("supabase",["--version"],{stdio:"ignore"}).status!==0&&this.error(`The Supabase CLI is required to manage the local database stack.
4
+ Install it: brew install supabase/tap/supabase (or see supabase.com/docs/guides/cli)
5
+ Then re-run: rulemetric local up`);let e=await this.ensureRuntime(s.yes);C(e),this.log("[..] Starting the local database stack (first run downloads Docker images)...");let r=a("supabase",["start"],{cwd:p,stdio:"inherit"});r.status!==0&&this.error(`\`supabase start\` failed (exit ${r.status}). Fix the error above and re-run.`);let i=a("supabase",["migration","up"],{cwd:p,encoding:"utf-8"});i.status!==0&&this.error(`Applying migrations failed:
6
+ ${i.stderr||i.stdout}`),this.log("[OK] Database ready (migrations applied)");let c=a("supabase",["status","-o","env"],{cwd:p,encoding:"utf-8"});c.status!==0&&this.error(`\`supabase status\` failed:
7
+ ${c.stderr||c.stdout}`);let F=I(c.stdout),u=_({statusEnv:F,pkg:e,port:t,cliVersion:this.config.version});if((!u.DATABASE_URL||!u.SUPABASE_URL)&&this.error("Could not read DB_URL/API_URL from `supabase status` \u2014 is the stack healthy? Try: supabase status"),s.foreground){this.log(`[..] Running server in the foreground on :${t} (Ctrl-C to stop)`);let W=a(process.execPath,[e.serverEntry],{stdio:"inherit",env:{...process.env,...u}});process.exitCode=W.status??0;return}M(n(b(),"Library","LaunchAgents"),{recursive:!0}),M(g,{recursive:!0});let k=H("id -u",{encoding:"utf-8"}).trim(),j=this.buildLocalPlist(e,u);x(k,K,j,this.warn.bind(this)),U(k,K,this.warn.bind(this))||this.error(`Could not load ${h} into launchd. See warnings above.`),this.log(`[..] Waiting for the local server on :${t}...`),await this.waitForApi(t,20)||this.error(`Server did not respond on :${t}. Check logs:
8
+ tail -f ${n(g,"local-api-stderr.log")}`),this.log(`[OK] RuleMetric running locally at http://localhost:${t}`);let y=`http://localhost:${t}`;s.email&&s.password?await this.provisionUser(y,s.email,s.password):(this.log(""),this.log("No --email/--password given \u2014 create your account with:"),this.log(` RULEMETRIC_API_URL=${y} rulemetric auth signup`)),this.log(""),this.log(`Dashboard: http://localhost:${t}`),this.log('Data: local Postgres (Docker, project "rulemetric-local") \u2014 nothing leaves this machine'),this.log("Manage: rulemetric local down \u2014 stop the server + database stack"),T("local_up",{port:String(t)},this.config.version)}async ensureRuntime(s){let t=this.config.version,e=m();if(e&&!f(e.version,t))return e;if(process.env.RULEMETRIC_LOCAL_PKG_PATH)return e||this.error("RULEMETRIC_LOCAL_PKG_PATH is set but no built runtime found there (need dist/server.mjs + dist/meta.json)."),this.warn(`Runtime override in use (${e.root}) at version ${e.version} \u2260 CLI ${t}.`),e;if(e)this.log(`[..] Local runtime is ${e.version} but the CLI is ${t} \u2014 reinstalling to match.`);else if(!s){this.log("Local mode needs the @rulemetric/local runtime package (~10MB download, one time).");let{confirm:i}=await import("@inquirer/prompts");process.stdout.isTTY&&!await i({message:"Download it now?",default:!0})&&this.error("Aborted. Re-run with --yes to skip this prompt.")}let r=D(t,this.log.bind(this));return r.ok||this.error(`Could not install @rulemetric/local@${t}:
9
+ ${r.error}`),e=m(),e||this.error("Runtime installed but could not be resolved \u2014 this is a bug; please report it."),f(e.version,t)&&this.error(`Installed runtime reports ${e.version}, expected ${t}. Refusing to run mismatched migrations.`),this.log(`[OK] Runtime ready (${e.version})`),e}async provisionUser(s,t,e){process.env.RULEMETRIC_API_URL=s;let r;try{r=await d("/auth/signup",{method:"POST",body:{email:t,password:e},timeoutMs:2e4})}catch(i){if(i instanceof S&&i.statusCode===409)this.log(`[..] ${t} already exists on the local server \u2014 logging in instead.`),r=await d("/auth/login",{method:"POST",body:{email:t,password:e},timeoutMs:2e4});else throw i}if(!r.accessToken||!r.refreshToken){this.warn("Signup did not return a session (is email confirmation enabled?). Run `rulemetric auth login` manually.");return}L({accessToken:r.accessToken,refreshToken:r.refreshToken,expiresAt:r.expiresAt??new Date(Date.now()+3600*1e3).toISOString(),email:r.email}),P(r.accessToken,s),await R(),await $(this.log.bind(this),this.warn.bind(this),this.config.version);try{await d("/api/skills/sync-public",{method:"POST",body:{},timeoutMs:6e4}),this.log("[OK] Seeded public skills catalog")}catch(i){this.warn(`Could not seed the skills catalog (non-fatal): ${i instanceof Error?i.message:String(i)}`)}this.log(`[OK] Logged in as ${r.email} \u2014 CLI now targets ${s}`)}buildLocalPlist(s,t){let e=process.execPath,r=[...new Set([G(e),"/opt/homebrew/bin","/usr/local/bin","/usr/bin","/bin"])],i=O({...t,PATH:r.join(":")});return`<?xml version="1.0" encoding="UTF-8"?>
10
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
11
+ <plist version="1.0">
12
+ <dict>
13
+ <key>Label</key>
14
+ <string>${h}</string>
15
+
16
+ <key>ProgramArguments</key>
17
+ <array>
18
+ <string>${o(e)}</string>
19
+ <string>${o(s.serverEntry)}</string>
20
+ </array>
21
+
22
+ <key>WorkingDirectory</key>
23
+ <string>${o(E)}</string>
24
+
25
+ <key>EnvironmentVariables</key>
26
+ <dict>
27
+ ${i}
28
+ </dict>
29
+
30
+ <key>RunAtLoad</key>
31
+ <true/>
32
+
33
+ <key>KeepAlive</key>
34
+ <dict>
35
+ <key>SuccessfulExit</key>
36
+ <false/>
37
+ </dict>
38
+
39
+ <key>ThrottleInterval</key>
40
+ <integer>10</integer>
41
+
42
+ <key>StandardOutPath</key>
43
+ <string>${o(n(g,"local-api-stdout.log"))}</string>
44
+
45
+ <key>StandardErrorPath</key>
46
+ <string>${o(n(g,"local-api-stderr.log"))}</string>
47
+
48
+ <key>ProcessType</key>
49
+ <string>Background</string>
50
+ </dict>
51
+ </plist>
52
+ `}async waitForApi(s,t){for(let e=0;e<t;e++){try{if((await fetch(`http://localhost:${s}/health`)).ok)return!0}catch{}await new Promise(r=>setTimeout(r,1e3))}return!1}};export{v as default};
@@ -1 +1 @@
1
- import{a as O}from"../chunk-WSCK4WNK.js";import{a as D}from"../chunk-4Z5ECCJE.js";import{a as F}from"../chunk-DVN7GFJG.js";import{a as M}from"../chunk-O2SDD2WW.js";import{a as E}from"../chunk-GBMF3TP6.js";import"../chunk-ARNZQBMX.js";import{a as B,b as S,c as R}from"../chunk-4Q72B377.js";import{a as $}from"../chunk-KUTOHRLK.js";import"../chunk-B22HYCBV.js";import"../chunk-ULMEKK7C.js";import"../chunk-5RUEROLC.js";import"../chunk-X23L2MF6.js";import"../chunk-ZXF5NE54.js";import{a as u,b as T,d as a,e as v}from"../chunk-NJ5UED3H.js";import"../chunk-7DFNBRLY.js";import{a as X}from"../chunk-3AV3GTMP.js";import"../chunk-KLEF5D3A.js";import"../chunk-JZ5Z2BRO.js";import{a as m}from"../chunk-ZLLER3HP.js";import{useState as w,useEffect as nt,useCallback as G,useRef as st}from"react";import{render as U,Box as c,Text as o,useInput as at,useApp as lt}from"ink";import{Fragment as ht,jsx as t,jsxs as h}from"react/jsx-runtime";var dt=90;function J(){let s=process.stdout.columns||80,n=Math.min(160,s),i=n>=dt,d=i?Math.floor(n/2):n,b=Math.max(6,Math.min(10,d-34));return{dashWidth:n,wide:i,halfWidth:d,barWidth:b}}m(J,"getLayout");function z({active:s,providerName:n}){return h(c,{justifyContent:"space-between",paddingX:1,children:[t(c,{gap:1,children:u.map(i=>t(o,{bold:s===i,color:s===i?a:v,children:s===i?`[ ${T[i]} ]`:` ${T[i]} `},i))}),n&&t(o,{color:a,bold:!0,children:n})]})}m(z,"PeriodTabs");function H({width:s,insightsFocused:n=!1}){return t(c,{borderStyle:"round",borderColor:v,width:s,justifyContent:"center",paddingX:1,children:h(o,{children:[t(o,{color:a,bold:!0,children:"<"}),t(o,{color:a,children:">"}),t(o,{dimColor:!0,children:" switch "}),t(o,{color:a,bold:!0,children:"q"}),t(o,{dimColor:!0,children:" quit "}),t(o,{color:a,bold:!0,children:"s"}),h(o,{dimColor:!0,children:[" ",n?"back":"suggestions"," "]}),t(o,{color:a,bold:!0,children:"1"}),t(o,{dimColor:!0,children:"-"}),t(o,{color:a,bold:!0,children:"5"}),t(o,{dimColor:!0,children:" period "}),t(o,{color:a,bold:!0,children:"r"}),t(o,{dimColor:!0,children:" refresh "}),t(o,{color:a,bold:!0,children:"n"}),t(o,{dimColor:!0,children:" new session "}),t(o,{color:a,bold:!0,children:"l"}),t(o,{dimColor:!0,children:" launcher"})]})})}m(H,"StatusBar");function ct({wide:s,width:n,children:i}){return s?t(c,{width:n,children:i}):t(ht,{children:i})}m(ct,"Row");function ut({initialLocal:s,initialApi:n,initialInstructions:i,initialPeriod:d,initialLauncherFocused:b=!1}){let{exit:j}=lt(),[e,L]=w(d),[K,Q]=w(s),[W,V]=w(n),[Z,tt]=w(i),[ot,k]=w(!1),[p,I]=w(!1),[Y,_]=w(b),et=X()?.orgSlug??null,y=st(null),it=J(),g=G(async()=>{k(!0);let[r,x,P]=await Promise.all([B(),S(),R()]);Q(r),V(x),tt(P),k(!1)},[]);nt(()=>{let r=setInterval(g,3e4);return()=>clearInterval(r)},[g]);let f=G(r=>{r!==e&&(L(r),y.current&&clearTimeout(y.current),y.current=setTimeout(g,300))},[e,g]);at((r,x)=>{if(Y)return;if(r==="q"){if(p){I(!1);return}j();return}if(r==="s"){I(A=>!A);return}if(x.escape&&p){I(!1);return}if(r==="l"&&!p){_(!0);return}if(p)return;if(r==="r"){g();return}if(r==="n"){import("../dist-FAVALJ5C.js").then(({getLauncher:A})=>{A("claude_code").launch({projectPath:process.cwd(),mode:"interactive"})});return}let P=u.indexOf(e);x.leftArrow?f(u[(P-1+u.length)%u.length]):x.rightArrow||x.tab?f(u[(P+1)%u.length]):r==="1"?f("today"):r==="2"?f("week"):r==="3"?f("30days"):r==="4"?f("month"):r==="5"&&f("all")});let{dashWidth:l,wide:q,halfWidth:rt,barWidth:C}=it,N=q?rt:l;return ot?h(c,{flexDirection:"column",width:l,children:[t(z,{active:e}),t(c,{borderStyle:"round",borderColor:a,paddingX:1,width:l,children:h(o,{dimColor:!0,children:["Loading ",T[e],"..."]})}),t(H,{width:l})]}):Y?t(c,{flexDirection:"column",width:l,children:t($,{onClose:()=>_(!1),activeOrg:et,defaultProjectPath:process.cwd(),width:l})}):h(c,{flexDirection:"column",width:l,children:[t(z,{active:e}),t(D,{local:K,api:W,label:T[e],width:l}),h(ct,{wide:q,width:l,children:[t(O,{api:W,width:N,barWidth:C}),t(F,{api:W,width:N,barWidth:C})]}),t(E,{instructions:Z,width:l,barWidth:C}),t(M,{api:W,width:l,focused:p}),t(H,{width:l,insightsFocused:p})]})}m(ut,"InteractiveDashboard");async function yt(s="week",n={}){let[i,d,b]=await Promise.all([B(),S(),R()]);if(process.stdin.isTTY&&process.stdout.isTTY){let{waitUntilExit:e}=U(t(ut,{initialLocal:i,initialApi:d,initialInstructions:b,initialPeriod:s,initialLauncherFocused:n.openLauncher??!1}));await e()}else{let e=J(),{unmount:L}=U(h(c,{flexDirection:"column",width:e.dashWidth,children:[t(D,{local:i,api:d,label:T[s],width:e.dashWidth}),t(O,{api:d,width:e.dashWidth,barWidth:e.barWidth}),t(F,{api:d,width:e.dashWidth,barWidth:e.barWidth}),t(E,{instructions:b,width:e.dashWidth,barWidth:e.barWidth}),t(M,{api:d,width:e.dashWidth})]}),{patchConsole:!1});L()}}m(yt,"renderDashboard");export{yt as renderDashboard};
1
+ import{a as M}from"../chunk-O2SDD2WW.js";import{a as E}from"../chunk-GBMF3TP6.js";import{a as O}from"../chunk-WSCK4WNK.js";import{a as D}from"../chunk-4Z5ECCJE.js";import{a as $}from"../chunk-3HZU6FNG.js";import"../chunk-X23L2MF6.js";import"../chunk-B22HYCBV.js";import"../chunk-ZXF5NE54.js";import"../chunk-ULMEKK7C.js";import"../chunk-5RUEROLC.js";import{a as F}from"../chunk-DVN7GFJG.js";import"../chunk-ARNZQBMX.js";import{a as u,b as T,d as a,e as v}from"../chunk-NJ5UED3H.js";import{a as B,b as S,c as R}from"../chunk-4Q72B377.js";import"../chunk-7DFNBRLY.js";import{a as X}from"../chunk-3AV3GTMP.js";import"../chunk-KLEF5D3A.js";import"../chunk-JZ5Z2BRO.js";import{a as m}from"../chunk-ZLLER3HP.js";import{useState as w,useEffect as nt,useCallback as G,useRef as st}from"react";import{render as U,Box as c,Text as o,useInput as at,useApp as lt}from"ink";import{Fragment as ht,jsx as t,jsxs as h}from"react/jsx-runtime";var dt=90;function J(){let s=process.stdout.columns||80,n=Math.min(160,s),i=n>=dt,d=i?Math.floor(n/2):n,b=Math.max(6,Math.min(10,d-34));return{dashWidth:n,wide:i,halfWidth:d,barWidth:b}}m(J,"getLayout");function z({active:s,providerName:n}){return h(c,{justifyContent:"space-between",paddingX:1,children:[t(c,{gap:1,children:u.map(i=>t(o,{bold:s===i,color:s===i?a:v,children:s===i?`[ ${T[i]} ]`:` ${T[i]} `},i))}),n&&t(o,{color:a,bold:!0,children:n})]})}m(z,"PeriodTabs");function H({width:s,insightsFocused:n=!1}){return t(c,{borderStyle:"round",borderColor:v,width:s,justifyContent:"center",paddingX:1,children:h(o,{children:[t(o,{color:a,bold:!0,children:"<"}),t(o,{color:a,children:">"}),t(o,{dimColor:!0,children:" switch "}),t(o,{color:a,bold:!0,children:"q"}),t(o,{dimColor:!0,children:" quit "}),t(o,{color:a,bold:!0,children:"s"}),h(o,{dimColor:!0,children:[" ",n?"back":"suggestions"," "]}),t(o,{color:a,bold:!0,children:"1"}),t(o,{dimColor:!0,children:"-"}),t(o,{color:a,bold:!0,children:"5"}),t(o,{dimColor:!0,children:" period "}),t(o,{color:a,bold:!0,children:"r"}),t(o,{dimColor:!0,children:" refresh "}),t(o,{color:a,bold:!0,children:"n"}),t(o,{dimColor:!0,children:" new session "}),t(o,{color:a,bold:!0,children:"l"}),t(o,{dimColor:!0,children:" launcher"})]})})}m(H,"StatusBar");function ct({wide:s,width:n,children:i}){return s?t(c,{width:n,children:i}):t(ht,{children:i})}m(ct,"Row");function ut({initialLocal:s,initialApi:n,initialInstructions:i,initialPeriod:d,initialLauncherFocused:b=!1}){let{exit:j}=lt(),[e,L]=w(d),[K,Q]=w(s),[W,V]=w(n),[Z,tt]=w(i),[ot,k]=w(!1),[p,I]=w(!1),[Y,_]=w(b),et=X()?.orgSlug??null,y=st(null),it=J(),g=G(async()=>{k(!0);let[r,x,P]=await Promise.all([B(),S(),R()]);Q(r),V(x),tt(P),k(!1)},[]);nt(()=>{let r=setInterval(g,3e4);return()=>clearInterval(r)},[g]);let f=G(r=>{r!==e&&(L(r),y.current&&clearTimeout(y.current),y.current=setTimeout(g,300))},[e,g]);at((r,x)=>{if(Y)return;if(r==="q"){if(p){I(!1);return}j();return}if(r==="s"){I(A=>!A);return}if(x.escape&&p){I(!1);return}if(r==="l"&&!p){_(!0);return}if(p)return;if(r==="r"){g();return}if(r==="n"){import("../dist-FAVALJ5C.js").then(({getLauncher:A})=>{A("claude_code").launch({projectPath:process.cwd(),mode:"interactive"})});return}let P=u.indexOf(e);x.leftArrow?f(u[(P-1+u.length)%u.length]):x.rightArrow||x.tab?f(u[(P+1)%u.length]):r==="1"?f("today"):r==="2"?f("week"):r==="3"?f("30days"):r==="4"?f("month"):r==="5"&&f("all")});let{dashWidth:l,wide:q,halfWidth:rt,barWidth:C}=it,N=q?rt:l;return ot?h(c,{flexDirection:"column",width:l,children:[t(z,{active:e}),t(c,{borderStyle:"round",borderColor:a,paddingX:1,width:l,children:h(o,{dimColor:!0,children:["Loading ",T[e],"..."]})}),t(H,{width:l})]}):Y?t(c,{flexDirection:"column",width:l,children:t($,{onClose:()=>_(!1),activeOrg:et,defaultProjectPath:process.cwd(),width:l})}):h(c,{flexDirection:"column",width:l,children:[t(z,{active:e}),t(D,{local:K,api:W,label:T[e],width:l}),h(ct,{wide:q,width:l,children:[t(O,{api:W,width:N,barWidth:C}),t(F,{api:W,width:N,barWidth:C})]}),t(E,{instructions:Z,width:l,barWidth:C}),t(M,{api:W,width:l,focused:p}),t(H,{width:l,insightsFocused:p})]})}m(ut,"InteractiveDashboard");async function yt(s="week",n={}){let[i,d,b]=await Promise.all([B(),S(),R()]);if(process.stdin.isTTY&&process.stdout.isTTY){let{waitUntilExit:e}=U(t(ut,{initialLocal:i,initialApi:d,initialInstructions:b,initialPeriod:s,initialLauncherFocused:n.openLauncher??!1}));await e()}else{let e=J(),{unmount:L}=U(h(c,{flexDirection:"column",width:e.dashWidth,children:[t(D,{local:i,api:d,label:T[s],width:e.dashWidth}),t(O,{api:d,width:e.dashWidth,barWidth:e.barWidth}),t(F,{api:d,width:e.dashWidth,barWidth:e.barWidth}),t(E,{instructions:b,width:e.dashWidth,barWidth:e.barWidth}),t(M,{api:d,width:e.dashWidth})]}),{patchConsole:!1});L()}}m(yt,"renderDashboard");export{yt as renderDashboard};
@@ -1 +1 @@
1
- import{a}from"../../chunk-KUTOHRLK.js";import"../../chunk-B22HYCBV.js";import"../../chunk-ULMEKK7C.js";import"../../chunk-5RUEROLC.js";import"../../chunk-X23L2MF6.js";import"../../chunk-ZXF5NE54.js";import"../../chunk-NJ5UED3H.js";import"../../chunk-KLEF5D3A.js";import"../../chunk-JZ5Z2BRO.js";import"../../chunk-ZLLER3HP.js";export{a as LauncherOverlay};
1
+ import{a}from"../../chunk-3HZU6FNG.js";import"../../chunk-X23L2MF6.js";import"../../chunk-B22HYCBV.js";import"../../chunk-ZXF5NE54.js";import"../../chunk-ULMEKK7C.js";import"../../chunk-5RUEROLC.js";import"../../chunk-NJ5UED3H.js";import"../../chunk-KLEF5D3A.js";import"../../chunk-JZ5Z2BRO.js";import"../../chunk-ZLLER3HP.js";export{a as LauncherOverlay};
@@ -1 +1 @@
1
- import{a,b,c,d,e}from"../chunk-FNGVEZPD.js";import"../chunk-5XUN743A.js";import"../chunk-RSKQRVPJ.js";import"../chunk-HXZM2UHO.js";import"../chunk-O2BKBW7Z.js";import"../chunk-KGQ5W54Y.js";import"../chunk-O7PSLZO6.js";import"../chunk-QFVGUZDO.js";import"../chunk-MOAJLSYV.js";import"../chunk-BLCMXTIK.js";import"../chunk-QUDMK76I.js";import"../chunk-EF6JLMNH.js";import"../chunk-6QKI756T.js";import"../chunk-EN43UYBN.js";import"../chunk-FAXV5AAG.js";import"../chunk-UF6US7VU.js";import"../chunk-6ME5OTS5.js";import"../chunk-5R5RGKOW.js";import"../chunk-YW3JQKGY.js";import"../chunk-7UCNONVI.js";import"../chunk-N7TGRFVZ.js";import"../chunk-5RBLIVBF.js";import"../chunk-45DOTNQM.js";import"../chunk-5KD2N2MH.js";import"../chunk-YQ56FQEO.js";import"../chunk-GIRPEMTW.js";import"../chunk-MODXEGCU.js";import"../chunk-7DFNBRLY.js";import"../chunk-4VZLIGMS.js";import"../chunk-CNOD6HWU.js";import"../chunk-AI6FMGKM.js";import"../chunk-6UEFCMR2.js";import"../chunk-2RCWYVEU.js";import"../chunk-RMDLJN4L.js";import"../chunk-BL4BN6RU.js";import"../chunk-DBELYMDA.js";import"../chunk-NTKO4H2K.js";import"../chunk-CJRYYV76.js";import"../chunk-ATL4WZBF.js";import"../chunk-L2CFSMBC.js";import"../chunk-Z72VHGV7.js";import"../chunk-4L2ZEIRE.js";import"../chunk-CDY7TQFZ.js";import"../chunk-XRTZU7IZ.js";import"../chunk-B3BHB26P.js";import"../chunk-N7ODX6PO.js";import"../chunk-PJ3WHQ67.js";import"../chunk-G5BXZT6F.js";import"../chunk-HMMO27U4.js";import"../chunk-KLEF5D3A.js";import"../chunk-JZ5Z2BRO.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-OMD3JCGB.js";import"../chunk-5XUN743A.js";import"../chunk-QUDMK76I.js";import"../chunk-C7YRLB37.js";import"../chunk-RSKQRVPJ.js";import"../chunk-HXZM2UHO.js";import"../chunk-YW3JQKGY.js";import"../chunk-2J3IHWE2.js";import"../chunk-N7TGRFVZ.js";import"../chunk-45DOTNQM.js";import"../chunk-O2BKBW7Z.js";import"../chunk-KGQ5W54Y.js";import"../chunk-JCXKWHZX.js";import"../chunk-QFVGUZDO.js";import"../chunk-MOAJLSYV.js";import"../chunk-BLCMXTIK.js";import"../chunk-6QKI756T.js";import"../chunk-5RBLIVBF.js";import"../chunk-EN43UYBN.js";import"../chunk-FAXV5AAG.js";import"../chunk-UF6US7VU.js";import"../chunk-6ME5OTS5.js";import"../chunk-5R5RGKOW.js";import"../chunk-YQ56FQEO.js";import"../chunk-5KD2N2MH.js";import"../chunk-GIRPEMTW.js";import"../chunk-MODXEGCU.js";import"../chunk-7DFNBRLY.js";import"../chunk-4VZLIGMS.js";import"../chunk-CNOD6HWU.js";import"../chunk-AI6FMGKM.js";import"../chunk-6UEFCMR2.js";import"../chunk-2RCWYVEU.js";import"../chunk-RMDLJN4L.js";import"../chunk-BL4BN6RU.js";import"../chunk-DBELYMDA.js";import"../chunk-NTKO4H2K.js";import"../chunk-CJRYYV76.js";import"../chunk-ATL4WZBF.js";import"../chunk-L2CFSMBC.js";import"../chunk-Z72VHGV7.js";import"../chunk-4L2ZEIRE.js";import"../chunk-CDY7TQFZ.js";import"../chunk-XRTZU7IZ.js";import"../chunk-B3BHB26P.js";import"../chunk-N7ODX6PO.js";import"../chunk-PJ3WHQ67.js";import"../chunk-G5BXZT6F.js";import"../chunk-HMMO27U4.js";import"../chunk-KLEF5D3A.js";import"../chunk-JZ5Z2BRO.js";import"../chunk-ZLLER3HP.js";export{b as CAPABILITIES,a as HANDLERS,c as availableCapabilities,d as pollForWork,e as runAgentLoop};
@@ -1 +1 @@
1
- import{a}from"../../chunk-7UCNONVI.js";import"../../chunk-N7TGRFVZ.js";import"../../chunk-5RBLIVBF.js";import"../../chunk-45DOTNQM.js";import"../../chunk-ZLLER3HP.js";export{a as processAnnouncement};
1
+ import{a}from"../../chunk-2J3IHWE2.js";import"../../chunk-N7TGRFVZ.js";import"../../chunk-45DOTNQM.js";import"../../chunk-5RBLIVBF.js";import"../../chunk-ZLLER3HP.js";export{a as processAnnouncement};
@@ -1 +1 @@
1
- import{a}from"../../chunk-QDYMIFY4.js";import"../../chunk-5R5RGKOW.js";import"../../chunk-N7TGRFVZ.js";import"../../chunk-45DOTNQM.js";import"../../chunk-ZLLER3HP.js";export{a as processChangelog};
1
+ import{a}from"../../chunk-EDJMMKA5.js";import"../../chunk-N7TGRFVZ.js";import"../../chunk-45DOTNQM.js";import"../../chunk-5R5RGKOW.js";import"../../chunk-ZLLER3HP.js";export{a as processChangelog};
@@ -1 +1 @@
1
- import{a}from"../../chunk-O7PSLZO6.js";import"../../chunk-QFVGUZDO.js";import"../../chunk-5R5RGKOW.js";import"../../chunk-5RBLIVBF.js";import"../../chunk-B3BHB26P.js";import"../../chunk-N7ODX6PO.js";import"../../chunk-PJ3WHQ67.js";import"../../chunk-KLEF5D3A.js";import"../../chunk-JZ5Z2BRO.js";import"../../chunk-ZLLER3HP.js";export{a as processInsights};
1
+ import{a}from"../../chunk-JCXKWHZX.js";import"../../chunk-QFVGUZDO.js";import"../../chunk-5RBLIVBF.js";import"../../chunk-5R5RGKOW.js";import"../../chunk-B3BHB26P.js";import"../../chunk-N7ODX6PO.js";import"../../chunk-PJ3WHQ67.js";import"../../chunk-KLEF5D3A.js";import"../../chunk-JZ5Z2BRO.js";import"../../chunk-ZLLER3HP.js";export{a as processInsights};
@@ -1 +1 @@
1
- import{a}from"../../chunk-EF6JLMNH.js";import"../../chunk-6QKI756T.js";import"../../chunk-5RBLIVBF.js";import"../../chunk-45DOTNQM.js";import"../../chunk-7DFNBRLY.js";import"../../chunk-N7ODX6PO.js";import"../../chunk-ZLLER3HP.js";export{a as processRunCleanup};
1
+ import{a}from"../../chunk-C7YRLB37.js";import"../../chunk-45DOTNQM.js";import"../../chunk-6QKI756T.js";import"../../chunk-5RBLIVBF.js";import"../../chunk-7DFNBRLY.js";import"../../chunk-N7ODX6PO.js";import"../../chunk-ZLLER3HP.js";export{a as processRunCleanup};
@@ -0,0 +1 @@
1
+ import{a,b,c,d}from"../chunk-XB4OMOSE.js";import"../chunk-ZLLER3HP.js";export{c as bootoutAndWrite,d as bootstrapPlist,b as buildEnvDictEntries,a as escapeXml};
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n}from"../chunk-HRXACKAH.js";import"../chunk-ZLLER3HP.js";export{a as LOCAL_DIR,d as LOCAL_PLIST_LABEL,f as LOCAL_PORT_MAP,e as LOCAL_PROJECT_ID,b as RUNTIME_DIR,c as SUPABASE_WORKDIR,n as buildServerEnv,h as findLocalPackage,g as inspectLocalPackage,j as installLocalPackage,m as parseStatusEnv,l as prepareSupabaseWorkdir,k as rewriteConfigToml,i as versionSkew};
@@ -1 +1 @@
1
- import{a as l}from"../chunk-QDYMIFY4.js";import{a as u}from"../chunk-UF6US7VU.js";import{b as g}from"../chunk-6ME5OTS5.js";import"../chunk-5R5RGKOW.js";import"../chunk-N7TGRFVZ.js";import"../chunk-45DOTNQM.js";import"../chunk-GIRPEMTW.js";import"../chunk-MODXEGCU.js";import"../chunk-B3BHB26P.js";import"../chunk-N7ODX6PO.js";import"../chunk-PJ3WHQ67.js";import{a as i}from"../chunk-GY5IJ4RS.js";import"../chunk-KLEF5D3A.js";import"../chunk-JZ5Z2BRO.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-EDJMMKA5.js";import"../chunk-N7TGRFVZ.js";import"../chunk-45DOTNQM.js";import{a as u}from"../chunk-UF6US7VU.js";import{b as g}from"../chunk-6ME5OTS5.js";import"../chunk-5R5RGKOW.js";import"../chunk-GIRPEMTW.js";import"../chunk-MODXEGCU.js";import"../chunk-B3BHB26P.js";import"../chunk-N7ODX6PO.js";import"../chunk-PJ3WHQ67.js";import{a as i}from"../chunk-GY5IJ4RS.js";import"../chunk-KLEF5D3A.js";import"../chunk-JZ5Z2BRO.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};
@@ -2601,6 +2601,116 @@
2601
2601
  "versions.js"
2602
2602
  ]
2603
2603
  },
2604
+ "local:down": {
2605
+ "aliases": [],
2606
+ "args": {},
2607
+ "description": "Stop the local RuleMetric server and database stack. Data is preserved (restart with `rulemetric local up`); use --delete-data to also wipe the local database.",
2608
+ "flags": {
2609
+ "api-url": {
2610
+ "description": "Override API base URL",
2611
+ "env": "RULEMETRIC_API_URL",
2612
+ "hidden": true,
2613
+ "name": "api-url",
2614
+ "hasDynamicHelp": false,
2615
+ "multiple": false,
2616
+ "type": "option"
2617
+ },
2618
+ "delete-data": {
2619
+ "description": "Also delete the local database volumes (irreversible)",
2620
+ "name": "delete-data",
2621
+ "allowNo": false,
2622
+ "type": "boolean"
2623
+ }
2624
+ },
2625
+ "hasDynamicHelp": false,
2626
+ "hiddenAliases": [],
2627
+ "id": "local:down",
2628
+ "pluginAlias": "@rulemetric/cli",
2629
+ "pluginName": "@rulemetric/cli",
2630
+ "pluginType": "core",
2631
+ "strict": true,
2632
+ "enableJsonFlag": false,
2633
+ "isESM": true,
2634
+ "relativePath": [
2635
+ "dist",
2636
+ "commands",
2637
+ "local",
2638
+ "down.js"
2639
+ ]
2640
+ },
2641
+ "local:up": {
2642
+ "aliases": [],
2643
+ "args": {},
2644
+ "description": "Run RuleMetric fully locally: start a local Supabase stack (Docker), apply migrations, and serve the API + dashboard from the @rulemetric/local runtime — all data on this machine, zero cloud contact. Downloads the runtime package on first run.",
2645
+ "examples": [
2646
+ "<%= config.bin %> local up --email you@example.com --password <pw>",
2647
+ "<%= config.bin %> local up --port 3000",
2648
+ "<%= config.bin %> local up --foreground"
2649
+ ],
2650
+ "flags": {
2651
+ "api-url": {
2652
+ "description": "Override API base URL",
2653
+ "env": "RULEMETRIC_API_URL",
2654
+ "hidden": true,
2655
+ "name": "api-url",
2656
+ "hasDynamicHelp": false,
2657
+ "multiple": false,
2658
+ "type": "option"
2659
+ },
2660
+ "port": {
2661
+ "char": "p",
2662
+ "description": "Local API + dashboard port",
2663
+ "name": "port",
2664
+ "default": 3000,
2665
+ "hasDynamicHelp": false,
2666
+ "multiple": false,
2667
+ "type": "option"
2668
+ },
2669
+ "email": {
2670
+ "char": "e",
2671
+ "description": "Create the first user with this email (with --password)",
2672
+ "name": "email",
2673
+ "hasDynamicHelp": false,
2674
+ "multiple": false,
2675
+ "type": "option"
2676
+ },
2677
+ "password": {
2678
+ "description": "Password for the first user (min 8 chars)",
2679
+ "name": "password",
2680
+ "hasDynamicHelp": false,
2681
+ "multiple": false,
2682
+ "type": "option"
2683
+ },
2684
+ "foreground": {
2685
+ "description": "Run the server in this terminal instead of installing a launchd service (works on any OS; skips user provisioning)",
2686
+ "name": "foreground",
2687
+ "allowNo": false,
2688
+ "type": "boolean"
2689
+ },
2690
+ "yes": {
2691
+ "char": "y",
2692
+ "description": "Skip the runtime-download confirmation",
2693
+ "name": "yes",
2694
+ "allowNo": false,
2695
+ "type": "boolean"
2696
+ }
2697
+ },
2698
+ "hasDynamicHelp": false,
2699
+ "hiddenAliases": [],
2700
+ "id": "local:up",
2701
+ "pluginAlias": "@rulemetric/cli",
2702
+ "pluginName": "@rulemetric/cli",
2703
+ "pluginType": "core",
2704
+ "strict": true,
2705
+ "enableJsonFlag": false,
2706
+ "isESM": true,
2707
+ "relativePath": [
2708
+ "dist",
2709
+ "commands",
2710
+ "local",
2711
+ "up.js"
2712
+ ]
2713
+ },
2604
2714
  "org:current": {
2605
2715
  "aliases": [],
2606
2716
  "args": {},
@@ -4507,5 +4617,5 @@
4507
4617
  ]
4508
4618
  }
4509
4619
  },
4510
- "version": "0.7.40"
4620
+ "version": "0.7.41"
4511
4621
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulemetric/cli",
3
- "version": "0.7.40",
3
+ "version": "0.7.41",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -77,9 +77,9 @@
77
77
  "postgres": "^3.4.0",
78
78
  "react": "^19.0.0",
79
79
  "zod": "^3.24.0",
80
- "@rulemetric/hooks": "0.7.40",
81
- "@rulemetric/proxy": "0.7.40",
82
- "@rulemetric/skills-registry": "0.7.40"
80
+ "@rulemetric/proxy": "0.7.41",
81
+ "@rulemetric/hooks": "0.7.41",
82
+ "@rulemetric/skills-registry": "0.7.41"
83
83
  },
84
84
  "//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.",
85
85
  "optionalDependencies": {
@@ -101,9 +101,9 @@
101
101
  "@rulemetric/core": "0.0.1",
102
102
  "@rulemetric/db": "0.0.1",
103
103
  "@rulemetric/effectiveness": "0.0.1",
104
+ "@rulemetric/telemetry": "0.0.1",
104
105
  "@rulemetric/email": "0.0.1",
105
106
  "@rulemetric/session": "0.2.1",
106
- "@rulemetric/telemetry": "0.0.1",
107
107
  "@rulemetric/typescript-config": "0.0.0"
108
108
  },
109
109
  "scripts": {