export interface PricingConfig { evalFeeSats?: number; workFeeShortSats?: number; workFeeMediumSats?: number; workFeeLongSats?: number; shortMaxChars?: number; mediumMaxChars?: number; bootstrapFeeSats?: number; } export class PricingService { private readonly evalFee: number; private readonly workFeeShort: number; private readonly workFeeMedium: number; private readonly workFeeLong: number; private readonly shortMax: number; private readonly mediumMax: number; private readonly bootstrapFee: number; constructor(config?: PricingConfig) { this.evalFee = config?.evalFeeSats ?? 10; this.workFeeShort = config?.workFeeShortSats ?? 50; this.workFeeMedium = config?.workFeeMediumSats ?? 100; this.workFeeLong = config?.workFeeLongSats ?? 250; this.shortMax = config?.shortMaxChars ?? 100; this.mediumMax = config?.mediumMaxChars ?? 300; const rawFee = parseInt(process.env.BOOTSTRAP_FEE_SATS ?? "", 10); this.bootstrapFee = config?.bootstrapFeeSats ?? (Number.isFinite(rawFee) && rawFee > 0 ? rawFee : 10_000); } calculateEvalFeeSats(): number { return this.evalFee; } calculateWorkFeeSats(requestText: string): number { const len = requestText.trim().length; if (len <= this.shortMax) return this.workFeeShort; if (len <= this.mediumMax) return this.workFeeMedium; return this.workFeeLong; } calculateBootstrapFeeSats(): number { return this.bootstrapFee; } } export const pricingService = new PricingService();