@tech-leads-club/harness-toolkit 0.4.0 → 0.4.2

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{createRequire as T}from"node:module";var k=T(import.meta.url);function M(P){let G=[],J=!1;for(let Q of P){if(Q==="--json"){J=!0;continue}G.push(Q)}return{json:J,rest:G}}function _(P,G=w){G(`${JSON.stringify(P)}
2
- `)}function w(P){process.stdout.write(P)}import{existsSync as z,readFileSync as f}from"node:fs";import{join as E}from"node:path";import{homedir as S}from"node:os";import{delimiter as o,join as b,resolve as n}from"node:path";function C(){return b(S(),".tlc","harness")}function D(P=process.env){return P.TLC_HOME??C()}function R(P=process.env){return P.TLC_HOME_FROM_ENV==="0"?C():D(P)}var p="litellm",j={"cursor-grok-4.5":"grok-4.5",auto:"auto-cost"};function F(P){if(!P)return{};let{_meta:G,...J}=P;return J}function L(P){return P.trim().toLowerCase().replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/[[\]]/g,"").replace(/[^a-z0-9.+]+/g,"-").replace(/^-+|-+$/g,"")}function v(P,G){let J=P.trim(),Q=[],X=(q)=>{if(q&&!Q.includes(q))Q.push(q)};if(X(J),X(G[J]),X(L(J)),X(G[L(J)]),J.includes("/"))X(J.slice(J.lastIndexOf("/")+1));let $=J.replace(/-(high|medium|low|max|fast|thinking)$/i,"");if($!==J)X($),X(G[$]),X(L($));return Q}function U(P,G){let J=P[G];if(J)return{key:G,entry:J};for(let[Q,X]of Object.entries(P))if(G.startsWith(Q)||Q.startsWith(G))return{key:Q,entry:X};return}function g(){return E(R(),"model-prices.json")}function y(){return E(R(),"model-prices.local.json")}var A=new Map;function O(P){if(!z(P))return A.delete(P),null;let G;try{G=f(P,"utf8")}catch{return A.delete(P),null}let J=A.get(P);if(J&&J.text===G)return J.value;let Q;try{Q=JSON.parse(G)}catch{return A.delete(P),null}return A.set(P,{text:G,value:Q}),Q}function c(){return O(g())??{}}function H(P,G){return F(P.planes?.[G]??null)}function W(P,G){let J=G.trim();if(!J)return;let Q=c(),X=F(O(y())),$=P?H(Q,P):{},q=H(Q,p),B=v(J,j);for(let Z of B){let x=X[Z];if(x)return{entry:x,key:Z,source:"override"}}for(let Z of B){let x=$[Z];if(x)return{entry:x,key:Z,source:"provider"}}for(let Z of B){let x=q[Z];if(x)return{entry:x,key:Z,source:"litellm"}}let Y=L(J),I=U(X,Y);if(I)return{...I,source:"override"};let K=U($,Y);if(K)return{...K,source:"provider"};let V=U(q,Y);if(V)return{...V,source:"litellm"};return}function N(P,G,J){let Q=J.inputTokens??0,X=J.outputTokens??0,$=J.cacheReadTokens??0,q=J.cacheWriteTokens??0;if(!G||Q<=0&&X<=0&&$<=0&&q<=0)return{costUsd:null,billing:"unknown",pool:"unknown",source:"missing"};let B=W(P,G);if(!B)return{costUsd:null,billing:"unknown",pool:"unknown",source:"missing"};let{entry:Y,key:I,source:K}=B,V=Y.pool??"unknown";if(Y.billing==="included")return{costUsd:null,billing:"included",pool:V,source:K,catalogKey:I};if(typeof Y.promptPer1M!=="number"||typeof Y.completionPer1M!=="number")return{costUsd:null,billing:Y.billing??"unknown",pool:V,source:K,catalogKey:I};let Z=Q/1e6*Y.promptPer1M+X/1e6*Y.completionPer1M;if(typeof Y.cacheReadPer1M==="number"&&$>0)Z+=$/1e6*Y.cacheReadPer1M;if(typeof Y.cacheWritePer1M==="number"&&q>0)Z+=q/1e6*Y.cacheWritePer1M;return{costUsd:Z,billing:"metered",pool:V,source:K,catalogKey:I}}function m(P){let G=P[0];if(!G)return null;return{model:G,provider:P[1]??""}}function u(P){let G=W(P.provider,P.model),J=N(P.provider,P.model,{inputTokens:1e6,outputTokens:1e6});return{model:P.model,provider:P.provider,resolved:G,per1M:J}}function l(){let{json:P,rest:G}=M(process.argv.slice(2)),J=m(G);if(!J)console.error("usage: tlc harness prices lookup <model-id> [provider]"),console.error(" or: node --experimental-strip-types tools/price-lookup.ts <model-id> [provider] (dev)"),process.exit(1);let Q=u(J);if(P)_(Q);else console.log(JSON.stringify(Q,null,2));if(!Q.resolved)process.exit(2)}if(k.main==k.module)l();export{m as parsePriceLookupArgs,u as lookupPrice};
1
+ import{createRequire as T}from"node:module";var _=T(import.meta.url);function H(P){let G=[],J=!1;for(let Q of P){if(Q==="--json"){J=!0;continue}G.push(Q)}return{json:J,rest:G}}function C(P,G=D){G(`${JSON.stringify(P)}
2
+ `)}function D(P){process.stdout.write(P)}import{existsSync as z,readFileSync as f}from"node:fs";import{join as k}from"node:path";import{homedir as E}from"node:os";import{delimiter as r,dirname as n,join as b,resolve as t}from"node:path";function F(){return b(E(),".tlc","harness")}function S(P=process.env){return P.TLC_HOME??F()}function U(P=process.env){return P.TLC_HOME_FROM_ENV==="0"?F():S(P)}var j="litellm",p={"cursor-grok-4.5":"grok-4.5",auto:"auto-cost"};function x(P){if(!P)return{};let{_meta:G,...J}=P;return J}function L(P){return P.trim().toLowerCase().replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/[[\]]/g,"").replace(/[^a-z0-9.+]+/g,"-").replace(/^-+|-+$/g,"")}function g(P,G){let J=P.trim(),Q=[],Y=(V)=>{if(V&&!Q.includes(V))Q.push(V)};if(Y(J),Y(G[J]),Y(L(J)),Y(G[L(J)]),J.includes("/"))Y(J.slice(J.lastIndexOf("/")+1));let K=J.replace(/-(high|medium|low|max|fast|thinking)$/i,"");if(K!==J)Y(K),Y(G[K]),Y(L(K));return Q}function W(P,G){let J=P[G];if(J)return{key:G,entry:J};for(let[Q,Y]of Object.entries(P))if(G.startsWith(Q)||Q.startsWith(G))return{key:Q,entry:Y};return}function v(){return k(U(),"model-prices.json")}function y(){return k(U(),"model-prices.local.json")}var A=new Map;function N(P){if(!z(P))return A.delete(P),null;let G;try{G=f(P,"utf8")}catch{return A.delete(P),null}let J=A.get(P);if(J&&J.text===G)return J.value;let Q;try{Q=JSON.parse(G)}catch{return A.delete(P),null}return A.set(P,{text:G,value:Q}),Q}function c(){return N(v())??{}}function O(P,G){return x(P.planes?.[G]??null)}function M(P,G){let J=G.trim();if(!J)return;let Q=c(),Y=x(N(y())),K=P?O(Q,P):{},V=O(Q,j),B=g(J,p);for(let $ of B){let q=Y[$];if(q)return{entry:q,key:$,source:"override"}}for(let $ of B){let q=K[$];if(q)return{entry:q,key:$,source:"provider"}}for(let $ of B){let q=V[$];if(q)return{entry:q,key:$,source:"litellm"}}let Z=L(J),I=W(Y,Z);if(I)return{...I,source:"override"};let X=W(K,Z);if(X)return{...X,source:"provider"};let R=W(V,Z);if(R)return{...R,source:"litellm"};return}function w(P,G,J){let Q=J.inputTokens??0,Y=J.outputTokens??0,K=J.cacheReadTokens??0,V=J.cacheWriteTokens??0;if(!G||Q<=0&&Y<=0&&K<=0&&V<=0)return{costUsd:null,billing:"unknown",pool:"unknown",source:"missing"};let B=M(P,G);if(!B)return{costUsd:null,billing:"unknown",pool:"unknown",source:"missing"};let{entry:Z,key:I,source:X}=B,R=Z.pool??"unknown";if(Z.billing==="included")return{costUsd:null,billing:"included",pool:R,source:X,catalogKey:I};if(typeof Z.promptPer1M!=="number"||typeof Z.completionPer1M!=="number")return{costUsd:null,billing:Z.billing??"unknown",pool:R,source:X,catalogKey:I};let $=Q/1e6*Z.promptPer1M+Y/1e6*Z.completionPer1M;if(typeof Z.cacheReadPer1M==="number"&&K>0)$+=K/1e6*Z.cacheReadPer1M;if(typeof Z.cacheWritePer1M==="number"&&V>0)$+=V/1e6*Z.cacheWritePer1M;return{costUsd:$,billing:"metered",pool:R,source:X,catalogKey:I}}function m(P){let G=P[0];if(!G)return null;return{model:G,provider:P[1]??""}}function u(P){let G=M(P.provider,P.model),J=w(P.provider,P.model,{inputTokens:1e6,outputTokens:1e6});return{model:P.model,provider:P.provider,resolved:G,per1M:J}}function l(){let{json:P,rest:G}=H(process.argv.slice(2)),J=m(G);if(!J)console.error("usage: tlc harness prices lookup <model-id> [provider]"),console.error(" or: node --experimental-strip-types tools/price-lookup.ts <model-id> [provider] (dev)"),process.exit(1);let Q=u(J);if(P)C(Q);else console.log(JSON.stringify(Q,null,2));if(!Q.resolved)process.exit(2)}if(_.main==_.module)l();export{m as parsePriceLookupArgs,u as lookupPrice};