@hydra-acp/budgeter 0.1.16 → 0.1.18

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,17 +1,17 @@
1
- function k(e){return"label"in e?e.label:e.bucket}function w(e){let n=0,s=!1;for(const o of e){if(o===void 0)continue;const f=String(o);f.length>n&&(n=f.length),o!==1&&(s=!0)}const l=s?8:7,r=e.map(o=>{if(o===void 0)return"";const f=String(o).padStart(n),d=(o===1?"session":"sessions").padEnd(l);return`${f} ${d}`}),u=n+1+l;return{strs:r,width:u}}function b(e){if(e<1e3)return String(e);let n,s;return e<1e6?(n=e/1e3,s="k"):e<1e9?(n=e/1e6,s="M"):(n=e/1e9,s="B"),(n%1===0?n.toFixed(0):n.toFixed(2)).replace(/\.?0+$/,"")+s}function j(e,n){let s=0;for(const u of e)u>s&&(s=u);if(s<=0||n<=0)return e.map(()=>"");const l=Math.max(1,n),r=[];for(const u of e){const o=u/s,f=Math.round(o*l),d=l-f;r.push("\u2588".repeat(f)+"\u2591".repeat(d))}return r}function E(e,n={}){const s=process.stdout.columns??80,l=n.histogram===!0,r=n.tokens===!0,u=n.loc===!0;let o="";const f=t=>`${t} session${t===1?"":"s"}`,d=(t,i)=>{if(u){let a=0;for(const c of i)a+=R(c);return`${A(a)} lines`}return S(t)};if(e.kind==="total"){const t=e.row.sessionCount,i=t!==void 0?f(t):e.row.label??"all sessions";o+=`Total: ${d(e.row.costAmount,[e.row])} across ${i}
2
- `}else if(e.kind==="grouped"){const t=[];let i=0;for(const c of e.groups)for(const p of c.items)t.push(p),i+=p.sessionCount??0;e.totalSessions!==void 0&&(i=e.totalSessions);const a=_(e.groups);o+=`Total: ${d(a,t)} across ${f(i)}
3
- `}else if(e.kind==="timeSeries"){const t=e.timeSeries.reduce((a,c)=>a+c.costAmount,0),i=e.totalSessions??e.timeSeries.reduce((a,c)=>a+(c.sessionCount??0),0);o+=`Total: ${d(t,e.timeSeries)} across ${f(i)}
4
- `}else if(e.kind==="timeSeriesGrouped"){const t=[];let i=0;for(const c of e.groups)for(const p of c.items)t.push(p),i+=p.sessionCount??0;e.totalSessions!==void 0&&(i=e.totalSessions);const a=_(e.groups);o+=`Total: ${d(a,t)} across ${f(i)}
1
+ function b(e){return"label"in e?e.label:e.bucket}function w(e){let n=0,i=!1;for(const o of e){if(o===void 0)continue;const f=String(o);f.length>n&&(n=f.length),o!==1&&(i=!0)}const l=i?8:7,r=e.map(o=>{if(o===void 0)return"";const f=String(o).padStart(n),d=(o===1?"session":"sessions").padEnd(l);return`${f} ${d}`}),u=n+1+l;return{strs:r,width:u}}function h(e){if(e<1e3)return String(e);let n,i;return e<1e6?(n=e/1e3,i="k"):e<1e9?(n=e/1e6,i="M"):(n=e/1e9,i="B"),(n%1===0?n.toFixed(0):n.toFixed(2)).replace(/\.?0+$/,"")+i}function j(e,n){let i=0;for(const u of e)u>i&&(i=u);if(i<=0||n<=0)return e.map(()=>"");const l=Math.max(1,n),r=[];for(const u of e){const o=u/i,f=Math.round(o*l),d=l-f;r.push("\u2588".repeat(f)+"\u2591".repeat(d))}return r}function E(e,n={}){const i=process.stdout.columns??80,l=n.histogram===!0,r=n.tokens===!0,u=n.loc===!0;let o="";const f=t=>`${t} session${t===1?"":"s"}`,d=(t,s)=>{if(u){let a=0;for(const c of s)a+=R(c);return`${A(a)} lines`}if(r){let a=0;for(const c of s)a+=k(c);return`${h(a)} tokens`}return S(t)};if(e.kind==="total"){const t=e.row.sessionCount,s=t!==void 0?f(t):e.row.label??"all sessions";o+=`Total: ${d(e.row.costAmount,[e.row])} across ${s}
2
+ `}else if(e.kind==="grouped"){const t=[];let s=0;for(const c of e.groups)for(const p of c.items)t.push(p),s+=p.sessionCount??0;e.totalSessions!==void 0&&(s=e.totalSessions);const a=_(e.groups);o+=`Total: ${d(a,t)} across ${f(s)}
3
+ `}else if(e.kind==="timeSeries"){const t=e.timeSeries.reduce((a,c)=>a+c.costAmount,0),s=e.totalSessions??e.timeSeries.reduce((a,c)=>a+(c.sessionCount??0),0);o+=`Total: ${d(t,e.timeSeries)} across ${f(s)}
4
+ `}else if(e.kind==="timeSeriesGrouped"){const t=[];let s=0;for(const c of e.groups)for(const p of c.items)t.push(p),s+=p.sessionCount??0;e.totalSessions!==void 0&&(s=e.totalSessions);const a=_(e.groups);o+=`Total: ${d(a,t)} across ${f(s)}
5
5
  `}if(n.windowLabel!==void 0&&n.windowLabel.length>0&&(o+=`Window: ${n.windowLabel}
6
- `),e.kind==="grouped")if(e.groups.every(i=>i.items.length===1)){const i=[];for(const a of e.groups){const c=a.items[0];c!==void 0&&i.push({...c,label:a.label})}i.sort((a,c)=>{const p=$(a,r,u);return $(c,r,u)-p}),l?o+=T(i,s,r,u):o+=N(i,r,u)}else for(const i of e.groups){o+=`
7
- ${i.label}: ${x(i.items,i.sessionCount,r,u)}
8
- `;const a=i.items,c=a.some(p=>p.inputTokens!==void 0||p.outputTokens!==void 0);l?o+=T(a,s,r,u):o+=v(a,c,r,u)}else if(e.kind==="timeSeries"){const t=e.timeSeries.some(i=>i.inputTokens!==void 0||i.outputTokens!==void 0);l?o+=T(e.timeSeries,s,r,u):o+=v(e.timeSeries,t,r,u)}else if(e.kind==="timeSeriesGrouped")for(const t of e.groups){o+=`
6
+ `),e.kind==="grouped")if(e.groups.every(s=>s.items.length===1)){const s=[];for(const a of e.groups){const c=a.items[0];c!==void 0&&s.push({...c,label:a.label})}s.sort((a,c)=>{const p=$(a,r,u);return $(c,r,u)-p}),l?o+=T(s,i,r,u):o+=N(s,r,u)}else for(const s of e.groups){o+=`
7
+ ${s.label}: ${x(s.items,s.sessionCount,r,u)}
8
+ `;const a=s.items,c=a.some(p=>p.inputTokens!==void 0||p.outputTokens!==void 0);l?o+=T(a,i,r,u):o+=v(a,c,r,u)}else if(e.kind==="timeSeries"){const t=e.timeSeries.some(s=>s.inputTokens!==void 0||s.outputTokens!==void 0);l?o+=T(e.timeSeries,i,r,u):o+=v(e.timeSeries,t,r,u)}else if(e.kind==="timeSeriesGrouped")for(const t of e.groups){o+=`
9
9
  ${t.label}: ${x(t.items,t.sessionCount,r,u)}
10
- `;const i=t.items.some(a=>a.inputTokens!==void 0||a.outputTokens!==void 0);l?o+=T(t.items,s,r,u):o+=v(t.items,i,r,u)}return o}function $(e,n,s){return s?R(e):n?h(e):e.costAmount}function L(e,n,s){return s?A(R(e)):n?b(h(e)):S(e.costAmount)}function x(e,n,s,l){let r=0;for(const d of e)r+=l?R(d):s?h(d):d.costAmount;const u=l?`${A(r)} lines`:s?`${b(r)} tokens`:S(r),o=n??e.reduce((d,t)=>d+(t.sessionCount??0),0);return o===0?u:`${u} across ${o} ${o===1?"session":"sessions"}`}function N(e,n,s){if(e.length===0)return` (no data)
11
- `;let l=0;for(const t of e)t.label.length>l&&(l=t.label.length);const r=e.map(t=>L(t,n,s));let u=0;for(const t of r)t.length>u&&(u=t.length);const{strs:o,width:f}=w(e.map(t=>t.sessionCount)),d=[];for(let t=0;t<e.length;t++){const i=e[t];if(i===void 0)continue;const a=r[t]??"";let c=` ${i.label.padEnd(l)} ${a.padStart(u)}`;f>0&&(c+=` ${o[t]}`),d.push(c+`
12
- `)}return d.join("")}function T(e,n,s,l){if(e.length===0)return` (no data)
13
- `;let r=0;for(const m of e){const g=k(m);g.length>r&&(r=g.length)}const u=e.map(m=>{const g=$(m,s,l);return l?Math.abs(g):g}),o=e.map(m=>L(m,s,l));let f=0;for(const m of o)m.length>f&&(f=m.length);const{strs:d,width:t}=w(e.map(m=>m.sessionCount)),i=t>0?t+2:0;let a=n-r-f-i-8;a<1&&(a=e.length>1?1:0);const c=j(u,a),p=[];for(let m=0;m<e.length;m++){const g=e[m];if(g===void 0)continue;const G=k(g).padEnd(r),y=(o[m]??"").padStart(f);let C=` ${G} ${y} ${c[m]??""}`;t>0&&(C+=` ${d[m]}`),p.push(C+`
14
- `)}return p.join("")}function v(e,n,s,l){if(e.length===0)return` (no data)
15
- `;let r=28;for(const o of e){const f=k(o);f.length>r&&(r=f.length)}let u=" ";u+=z("",r),u+=" ",l?u+=" +Added -Removed Net":s?u+=" Tokens":(u+=" Cost",n&&(u+=" Tokens")),u+=`
16
- `;for(const o of e){const f=k(o).padEnd(r);let d=" ";if(d+=f,d+=" ",l){const t=o.linesAdded??0,i=o.linesRemoved??0;d+=t.toLocaleString().padStart(10),d+=" ",d+=i.toLocaleString().padStart(8),d+=" ",d+=A(t-i).padStart(8)}else if(s){const t=h(o);d+=b(t).padStart(12)}else{const t=o.costAmount??0;if(d+=S(t).padStart(10),n){const i=h(o);d+=" ".padStart(2),d+=b(i).padStart(12)}}u+=d+`
17
- `}return u}function F(e){const n={kind:e.kind,currency:e.currency};if(e.kind==="total")n.row=B(e.row);else if(e.kind==="grouped"){const s=e.groups.slice().sort((l,r)=>l.label.localeCompare(r.label));n.groups=s.map(l=>({label:l.label,items:l.items.map(B)}))}else if(e.kind==="timeSeries")n.timeSeries=e.timeSeries.map(W);else if(e.kind==="timeSeriesGrouped"){const s=e.groups.slice().sort((l,r)=>l.label.localeCompare(r.label));n.groups=s.map(l=>({label:l.label,items:l.items.map(W)}))}return JSON.stringify(n,null,2)}function B(e){const n={label:e.label,costAmount:e.costAmount};return e.deltaCost!==void 0&&(n.deltaCost=e.deltaCost),e.inputTokens!==void 0&&(n.inputTokens=e.inputTokens),e.outputTokens!==void 0&&(n.outputTokens=e.outputTokens),e.cacheReadTokens!==void 0&&(n.cacheReadTokens=e.cacheReadTokens),e.cacheWriteTokens!==void 0&&(n.cacheWriteTokens=e.cacheWriteTokens),e.linesAdded!==void 0&&(n.linesAdded=e.linesAdded),e.linesRemoved!==void 0&&(n.linesRemoved=e.linesRemoved),(e.linesAdded!==void 0||e.linesRemoved!==void 0)&&(n.linesNet=(e.linesAdded??0)-(e.linesRemoved??0)),n}function W(e){const n={bucket:e.bucket,costAmount:e.costAmount,deltaCost:e.deltaCost};return e.inputTokens!==void 0&&(n.inputTokens=e.inputTokens),e.outputTokens!==void 0&&(n.outputTokens=e.outputTokens),e.cacheReadTokens!==void 0&&(n.cacheReadTokens=e.cacheReadTokens),e.cacheWriteTokens!==void 0&&(n.cacheWriteTokens=e.cacheWriteTokens),e.linesAdded!==void 0&&(n.linesAdded=e.linesAdded),e.linesRemoved!==void 0&&(n.linesRemoved=e.linesRemoved),(e.linesAdded!==void 0||e.linesRemoved!==void 0)&&(n.linesNet=(e.linesAdded??0)-(e.linesRemoved??0)),n}function S(e){return`$${e.toFixed(2)}`}function R(e){const n=e.linesAdded??0,s=e.linesRemoved??0;return n-s}function A(e){return`${e>0?"+":""}${e.toLocaleString()}`}function h(e){let n=0;return e.inputTokens!==void 0&&(n+=e.inputTokens),e.outputTokens!==void 0&&(n+=e.outputTokens),n}function z(e,n){return e.length>=n?e:e+" ".repeat(n-e.length)}function _(e){let n=0;for(const s of e)for(const l of s.items)n+=l.costAmount;return n}export{F as renderJson,E as renderText};
10
+ `;const s=t.items.some(a=>a.inputTokens!==void 0||a.outputTokens!==void 0);l?o+=T(t.items,i,r,u):o+=v(t.items,s,r,u)}return o}function $(e,n,i){return i?R(e):n?k(e):e.costAmount}function L(e,n,i){return i?A(R(e)):n?h(k(e)):S(e.costAmount)}function x(e,n,i,l){let r=0;for(const d of e)r+=l?R(d):i?k(d):d.costAmount;const u=l?`${A(r)} lines`:i?`${h(r)} tokens`:S(r),o=n??e.reduce((d,t)=>d+(t.sessionCount??0),0);return o===0?u:`${u} across ${o} ${o===1?"session":"sessions"}`}function N(e,n,i){if(e.length===0)return` (no data)
11
+ `;let l=0;for(const t of e)t.label.length>l&&(l=t.label.length);const r=e.map(t=>L(t,n,i));let u=0;for(const t of r)t.length>u&&(u=t.length);const{strs:o,width:f}=w(e.map(t=>t.sessionCount)),d=[];for(let t=0;t<e.length;t++){const s=e[t];if(s===void 0)continue;const a=r[t]??"";let c=` ${s.label.padEnd(l)} ${a.padStart(u)}`;f>0&&(c+=` ${o[t]}`),d.push(c+`
12
+ `)}return d.join("")}function T(e,n,i,l){if(e.length===0)return` (no data)
13
+ `;let r=0;for(const m of e){const g=b(m);g.length>r&&(r=g.length)}const u=e.map(m=>{const g=$(m,i,l);return l?Math.abs(g):g}),o=e.map(m=>L(m,i,l));let f=0;for(const m of o)m.length>f&&(f=m.length);const{strs:d,width:t}=w(e.map(m=>m.sessionCount)),s=t>0?t+2:0;let a=n-r-f-s-8;a<1&&(a=e.length>1?1:0);const c=j(u,a),p=[];for(let m=0;m<e.length;m++){const g=e[m];if(g===void 0)continue;const G=b(g).padEnd(r),y=(o[m]??"").padStart(f);let C=` ${G} ${y} ${c[m]??""}`;t>0&&(C+=` ${d[m]}`),p.push(C+`
14
+ `)}return p.join("")}function v(e,n,i,l){if(e.length===0)return` (no data)
15
+ `;let r=28;for(const o of e){const f=b(o);f.length>r&&(r=f.length)}let u=" ";u+=z("",r),u+=" ",l?u+=" +Added -Removed Net":i?u+=" Tokens":(u+=" Cost",n&&(u+=" Tokens")),u+=`
16
+ `;for(const o of e){const f=b(o).padEnd(r);let d=" ";if(d+=f,d+=" ",l){const t=o.linesAdded??0,s=o.linesRemoved??0;d+=t.toLocaleString().padStart(10),d+=" ",d+=s.toLocaleString().padStart(8),d+=" ",d+=A(t-s).padStart(8)}else if(i){const t=k(o);d+=h(t).padStart(12)}else{const t=o.costAmount??0;if(d+=S(t).padStart(10),n){const s=k(o);d+=" ".padStart(2),d+=h(s).padStart(12)}}u+=d+`
17
+ `}return u}function M(e){const n={kind:e.kind,currency:e.currency};if(e.kind==="total")n.row=B(e.row);else if(e.kind==="grouped"){const i=e.groups.slice().sort((l,r)=>l.label.localeCompare(r.label));n.groups=i.map(l=>({label:l.label,items:l.items.map(B)}))}else if(e.kind==="timeSeries")n.timeSeries=e.timeSeries.map(W);else if(e.kind==="timeSeriesGrouped"){const i=e.groups.slice().sort((l,r)=>l.label.localeCompare(r.label));n.groups=i.map(l=>({label:l.label,items:l.items.map(W)}))}return JSON.stringify(n,null,2)}function B(e){const n={label:e.label,costAmount:e.costAmount};return e.deltaCost!==void 0&&(n.deltaCost=e.deltaCost),e.inputTokens!==void 0&&(n.inputTokens=e.inputTokens),e.outputTokens!==void 0&&(n.outputTokens=e.outputTokens),e.cacheReadTokens!==void 0&&(n.cacheReadTokens=e.cacheReadTokens),e.cacheWriteTokens!==void 0&&(n.cacheWriteTokens=e.cacheWriteTokens),e.linesAdded!==void 0&&(n.linesAdded=e.linesAdded),e.linesRemoved!==void 0&&(n.linesRemoved=e.linesRemoved),(e.linesAdded!==void 0||e.linesRemoved!==void 0)&&(n.linesNet=(e.linesAdded??0)-(e.linesRemoved??0)),n}function W(e){const n={bucket:e.bucket,costAmount:e.costAmount,deltaCost:e.deltaCost};return e.inputTokens!==void 0&&(n.inputTokens=e.inputTokens),e.outputTokens!==void 0&&(n.outputTokens=e.outputTokens),e.cacheReadTokens!==void 0&&(n.cacheReadTokens=e.cacheReadTokens),e.cacheWriteTokens!==void 0&&(n.cacheWriteTokens=e.cacheWriteTokens),e.linesAdded!==void 0&&(n.linesAdded=e.linesAdded),e.linesRemoved!==void 0&&(n.linesRemoved=e.linesRemoved),(e.linesAdded!==void 0||e.linesRemoved!==void 0)&&(n.linesNet=(e.linesAdded??0)-(e.linesRemoved??0)),n}function S(e){return`$${e.toFixed(2)}`}function R(e){const n=e.linesAdded??0,i=e.linesRemoved??0;return n-i}function A(e){return`${e>0?"+":""}${e.toLocaleString()}`}function k(e){let n=0;return e.inputTokens!==void 0&&(n+=e.inputTokens),e.outputTokens!==void 0&&(n+=e.outputTokens),n}function z(e,n){return e.length>=n?e:e+" ".repeat(n-e.length)}function _(e){let n=0;for(const i of e)for(const l of i.items)n+=l.costAmount;return n}export{M as renderJson,E as renderText};
@@ -1 +1 @@
1
- import{readdirSync as k,readFileSync as C,realpathSync as M,statSync as E}from"node:fs";import{isAbsolute as x,resolve as a}from"node:path";import{homedir as F}from"node:os";import{logger as j}from"../util/log.js";const c=j("cost/session-store"),f=new Map;function $(n){if(f.has(n))return f.get(n);try{const s=M(n);return f.set(n,s),s}catch{f.set(n,void 0);return}}function N(){const n=process.env.HYDRA_ACP_HOME??a(F(),".hydra-acp");return a(n,"sessions")}function J(n){const s=a(n,"meta.json");let r;try{r=C(s,"utf8")}catch(m){const p=m;if(p.code==="ENOENT")return;c.debug(`skipping ${n}: read meta.json failed: ${p.message}`);return}let t;try{t=JSON.parse(r)}catch{c.debug(`skipping ${n}: meta.json is not valid JSON`);return}if(!t||typeof t!="object"||Array.isArray(t)){c.debug(`skipping ${n}: meta.json is not an object`);return}const e=t,o=typeof e.sessionId=="string"?e.sessionId:void 0;if(o===void 0){c.debug(`skipping ${n}: missing sessionId`);return}let d;const u=typeof e.cwd=="string"?e.cwd:void 0;u!==void 0&&(x(u)?d=$(u):d=u);const g=typeof e.agentId=="string"?e.agentId:"",y=typeof e.currentModel=="string"?e.currentModel:"",l=e.interactive===!0,i=e.currentUsage??void 0,S=(typeof i?.costAmount=="number"?i.costAmount:0)+(typeof i?.cumulativeCost=="number"?i.cumulativeCost:0),v=typeof i?.costCurrency=="string"?i.costCurrency:"",b=typeof i?.used=="number"?i.used:0,w=typeof e.title=="string"?e.title:"",A=typeof e.createdAt=="string"?e.createdAt:"",h=typeof e.updatedAt=="string"?e.updatedAt:"",I=typeof e.importedFromMachine=="string"&&e.importedFromMachine.length>0?e.importedFromMachine:void 0,R=typeof e.upstreamSessionId=="string"&&e.upstreamSessionId.length>0?e.upstreamSessionId:void 0;return{sessionId:o,cwd:d,agentId:g,model:y,interactive:l,costAmount:S,costCurrency:v,contextTokens:b,title:w,createdAt:A,updatedAt:h,importedFromMachine:I,upstreamSessionId:R}}async function U(n){const{streamHistoryEditEvents:s}=await import("./history-stream.js");for(const r of n){const t={};for await(const e of s(r)){const o=t[e.filetype]??{added:0,removed:0};o.added+=e.linesAdded,o.removed+=e.linesRemoved,t[e.filetype]=o}r.locByFiletype=t}return n}function _(){const n=N();let s;try{s=k(n)}catch(t){const e=t;return c.debug(`session store not found at ${n}: ${e.message}`),[]}const r=[];for(const t of s){const e=a(n,t);let o;try{o=E(e)}catch{continue}if(!o.isDirectory())continue;const d=J(e);d!==void 0&&r.push(d)}return r}export{U as enrichSessionsWithLoc,_ as scanSessions,N as sessionsDir};
1
+ import{readdirSync as I,readFileSync as M,realpathSync as E,statSync as j}from"node:fs";import{isAbsolute as x,resolve as a}from"node:path";import{homedir as F}from"node:os";import{logger as $}from"../util/log.js";const c=$("cost/session-store"),f=new Map;function N(n){if(f.has(n))return f.get(n);try{const s=E(n);return f.set(n,s),s}catch{f.set(n,void 0);return}}function J(){const n=process.env.HYDRA_ACP_HOME??a(F(),".hydra-acp");return a(n,"sessions")}function O(n){const s=a(n,"meta.json");let r;try{r=M(s,"utf8")}catch(m){const g=m;if(g.code==="ENOENT")return;c.debug(`skipping ${n}: read meta.json failed: ${g.message}`);return}let t;try{t=JSON.parse(r)}catch{c.debug(`skipping ${n}: meta.json is not valid JSON`);return}if(!t||typeof t!="object"||Array.isArray(t)){c.debug(`skipping ${n}: meta.json is not an object`);return}const e=t,o=typeof e.sessionId=="string"?e.sessionId:void 0;if(o===void 0){c.debug(`skipping ${n}: missing sessionId`);return}let d;const p=typeof e.workspace=="object"&&e.workspace!==null?e.workspace:void 0,u=(typeof p?.sourceCwd=="string"?p.sourceCwd:void 0)??(typeof e.cwd=="string"?e.cwd:void 0);u!==void 0&&(x(u)?d=N(u):d=u);const y=typeof e.agentId=="string"?e.agentId:"",l=typeof e.currentModel=="string"?e.currentModel:"",w=e.interactive===!0,i=e.currentUsage??void 0,S=(typeof i?.costAmount=="number"?i.costAmount:0)+(typeof i?.cumulativeCost=="number"?i.cumulativeCost:0),b=typeof i?.costCurrency=="string"?i.costCurrency:"",v=typeof i?.used=="number"?i.used:0,A=typeof e.title=="string"?e.title:"",k=typeof e.createdAt=="string"?e.createdAt:"",h=typeof e.updatedAt=="string"?e.updatedAt:"",C=typeof e.importedFromMachine=="string"&&e.importedFromMachine.length>0?e.importedFromMachine:void 0,R=typeof e.upstreamSessionId=="string"&&e.upstreamSessionId.length>0?e.upstreamSessionId:void 0;return{sessionId:o,cwd:d,agentId:y,model:l,interactive:w,costAmount:S,costCurrency:b,contextTokens:v,title:A,createdAt:k,updatedAt:h,importedFromMachine:C,upstreamSessionId:R}}async function L(n){const{streamHistoryEditEvents:s}=await import("./history-stream.js");for(const r of n){const t={};for await(const e of s(r)){const o=t[e.filetype]??{added:0,removed:0};o.added+=e.linesAdded,o.removed+=e.linesRemoved,t[e.filetype]=o}r.locByFiletype=t}return n}function W(){const n=J();let s;try{s=I(n)}catch(t){const e=t;return c.debug(`session store not found at ${n}: ${e.message}`),[]}const r=[];for(const t of s){const e=a(n,t);let o;try{o=j(e)}catch{continue}if(!o.isDirectory())continue;const d=O(e);d!==void 0&&r.push(d)}return r}export{L as enrichSessionsWithLoc,W as scanSessions,J as sessionsDir};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hydra-acp/budgeter",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "description": "Cost-budget transformer extension for hydra-acp — warns on soft limit, rejects further prompts/sessions on hard limit.",
5
5
  "license": "MIT",
6
6
  "type": "module",