briefcase-node 2.4.1

Node.js bindings for Briefcase AI
Documentation
const { describe, it, expect } = require("@jest/globals");
const briefcase = require("../index.js");

describe("SimpleCostCalculator", () => {
  it("estimates known model costs", () => {
    const calc = new briefcase.SimpleCostCalculator();
    const estimate = JSON.parse(calc.estimateCost("gpt-4", 1200, 300));

    expect(estimate.model_name).toBe("gpt-4");
    expect(estimate.input_tokens).toBe(1200);
    expect(estimate.output_tokens).toBe(300);
    expect(estimate.total_cost).toBeGreaterThan(0);
    expect(estimate.currency).toBe("USD");
  });

  it("returns budget status details", () => {
    const calc = new briefcase.SimpleCostCalculator();
    const status = JSON.parse(calc.checkBudget(85, 100));

    expect(status.spent_usd).toBe(85);
    expect(status.budget_usd).toBe(100);
    expect(String(status.status).toLowerCase()).toBe("warning");
    expect(status.percent_used).toBe(85);
  });

  it("projects monthly cost", () => {
    const calc = new briefcase.SimpleCostCalculator();
    const projection = JSON.parse(calc.projectMonthlyCost("gpt-4", 4000, 1000, 30));

    expect(projection.model_name).toBe("gpt-4");
    expect(projection.daily_cost).toBeGreaterThan(0);
    expect(projection.monthly_cost).toBeCloseTo(projection.daily_cost * 30);
    expect(projection.annual_cost).toBeCloseTo(projection.monthly_cost * 12);
  });
});