@exulu/backend 2.1.0 → 2.2.0

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.
@@ -665,6 +665,9 @@ async function tagUpdate(input) {
665
665
  budget_duration: input.budget_duration
666
666
  });
667
667
  }
668
+ async function budgetUpdate(budget_id, patch) {
669
+ await call("/budget/update", { budget_id, ...patch });
670
+ }
668
671
  async function tagDelete(name) {
669
672
  await call("/tag/delete", { name });
670
673
  }
@@ -673,8 +676,9 @@ function extractBudget(raw) {
673
676
  const max_budget = bt.max_budget ?? raw?.max_budget ?? null;
674
677
  const budget_duration = bt.budget_duration ?? raw?.budget_duration ?? null;
675
678
  const budget_reset_at = bt.budget_reset_at ?? raw?.budget_reset_at ?? null;
679
+ const budget_id = bt.budget_id ?? raw?.budget_id ?? null;
676
680
  const spend = typeof raw?.spend === "number" ? raw.spend : typeof bt.spend === "number" ? bt.spend : 0;
677
- return { max_budget, budget_duration, budget_reset_at, spend };
681
+ return { max_budget, budget_duration, budget_reset_at, budget_id, spend };
678
682
  }
679
683
  async function listTags() {
680
684
  const { url, masterKey } = litellmBase();
@@ -707,7 +711,8 @@ async function listTagBudgets() {
707
711
  spend: b.spend,
708
712
  max_budget: b.max_budget,
709
713
  budget_duration: b.budget_duration,
710
- budget_reset_at: b.budget_reset_at
714
+ budget_reset_at: b.budget_reset_at,
715
+ budget_id: b.budget_id
711
716
  };
712
717
  }
713
718
  const names = Object.keys(map);
@@ -753,7 +758,8 @@ async function tagInfo(names) {
753
758
  spend: b.spend,
754
759
  max_budget: b.max_budget,
755
760
  budget_duration: b.budget_duration,
756
- budget_reset_at: b.budget_reset_at
761
+ budget_reset_at: b.budget_reset_at,
762
+ budget_id: b.budget_id
757
763
  };
758
764
  }
759
765
  return out;
@@ -975,7 +981,16 @@ async function setBudgetSettings(settings) {
975
981
  }).onConflict("config_key").merge({ config_value: JSON.stringify(settings) });
976
982
  return settings;
977
983
  }
978
- async function upsertBudget(tag, max_budget, budget_duration) {
984
+ function parseResetAt(raw) {
985
+ if (raw === void 0 || raw === null || raw === "") {
986
+ return { valid: true, value: void 0 };
987
+ }
988
+ if (typeof raw !== "string") return { valid: false };
989
+ const t = Date.parse(raw);
990
+ if (Number.isNaN(t)) return { valid: false };
991
+ return { valid: true, value: new Date(t).toISOString() };
992
+ }
993
+ async function upsertBudget(tag, max_budget, budget_duration, budget_reset_at) {
979
994
  const info = await tagInfo([tag]);
980
995
  try {
981
996
  if (info[tag]) {
@@ -990,6 +1005,15 @@ async function upsertBudget(tag, max_budget, budget_duration) {
990
1005
  await tagUpdate({ name: tag, max_budget, budget_duration });
991
1006
  }
992
1007
  }
1008
+ if (budget_reset_at) {
1009
+ const after = await tagInfo([tag]);
1010
+ const budgetId = after[tag]?.budget_id ?? null;
1011
+ if (budgetId) {
1012
+ await budgetUpdate(budgetId, { budget_reset_at });
1013
+ } else {
1014
+ console.warn(`[EXULU] upsertBudget: no budget_id for ${tag}; reset date not applied`);
1015
+ }
1016
+ }
993
1017
  invalidateBudgetCaches(tag);
994
1018
  }
995
1019
  function invalidateBudgetCaches(tag) {
@@ -1691,7 +1715,7 @@ var ExuluTool = class _ExuluTool {
1691
1715
  });
1692
1716
  providerapikey = resolved.apiKey;
1693
1717
  }
1694
- const { convertExuluToolsToAiSdkTools: convertExuluToolsToAiSdkTools2 } = await import("./convert-exulu-tools-to-ai-sdk-tools-K3RHHLN6.js");
1718
+ const { convertExuluToolsToAiSdkTools: convertExuluToolsToAiSdkTools2 } = await import("./convert-exulu-tools-to-ai-sdk-tools-M7I2TZQQ.js");
1695
1719
  const tools = await convertExuluToolsToAiSdkTools2(
1696
1720
  [this],
1697
1721
  [],
@@ -4545,7 +4569,12 @@ function getS3Client(config) {
4545
4569
  credentials: {
4546
4570
  accessKeyId: config.fileUploads.s3key,
4547
4571
  secretAccessKey: config.fileUploads.s3secret
4548
- }
4572
+ },
4573
+ // AWS SDK >= 3.729 injects x-amz-checksum-crc32 (of an empty body) into
4574
+ // presigned PUT URLs, which S3-compatible stores like MinIO reject on
4575
+ // upload with a checksum mismatch. WHEN_REQUIRED disables that default.
4576
+ requestChecksumCalculation: "WHEN_REQUIRED",
4577
+ responseChecksumValidation: "WHEN_REQUIRED"
4549
4578
  });
4550
4579
  return s3Client;
4551
4580
  }
@@ -6671,6 +6700,7 @@ export {
6671
6700
  listTagsByPrefix,
6672
6701
  getBudgetSettings,
6673
6702
  setBudgetSettings,
6703
+ parseResetAt,
6674
6704
  upsertBudget,
6675
6705
  invalidateBudgetCaches,
6676
6706
  getTagBudgetMap,
@@ -2,7 +2,7 @@ import "dotenv/config";
2
2
  import {
3
3
  convertExuluToolsToAiSdkTools,
4
4
  hydrateVariables
5
- } from "./chunk-RVZWZNWG.js";
5
+ } from "./chunk-Y7JPNBFM.js";
6
6
  export {
7
7
  convertExuluToolsToAiSdkTools,
8
8
  hydrateVariables