@acarmisc/backstage-plugin-litellm-backend 0.20.0 → 0.21.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.
package/config.d.ts CHANGED
@@ -216,6 +216,12 @@ export interface Config {
216
216
  */
217
217
  maxBudget?: number;
218
218
 
219
+ /**
220
+ * Reset period of maxBudget in LiteLLM format (e.g. "30d"). Unset, maxBudget
221
+ * covers the whole life of the key.
222
+ */
223
+ budgetDuration?: string;
224
+
219
225
  /**
220
226
  * When true a team must be supplied and the user must belong to it.
221
227
  * @default false
package/dist/index.cjs.js CHANGED
@@ -9351,6 +9351,7 @@ function readOpencodeConfig(config) {
9351
9351
  enabled,
9352
9352
  keyDuration: config.getOptionalString("litellm.opencode.keyDuration") ?? "30d",
9353
9353
  maxBudget: config.getOptionalNumber("litellm.opencode.maxBudget") ?? 50,
9354
+ budgetDuration: config.getOptionalString("litellm.opencode.budgetDuration"),
9354
9355
  requireTeam: config.getOptionalBoolean("litellm.opencode.requireTeam") ?? false,
9355
9356
  metadata: config.getOptional(
9356
9357
  "litellm.opencode.metadata"
@@ -10647,6 +10648,7 @@ function registerOpencodeRoutes(router, ctx) {
10647
10648
  alias,
10648
10649
  duration: opencodeCfg.keyDuration,
10649
10650
  max_budget: opencodeCfg.maxBudget,
10651
+ ...opencodeCfg.budgetDuration && { budget_duration: opencodeCfg.budgetDuration },
10650
10652
  team_id: teamId,
10651
10653
  metadata: {
10652
10654
  ...opencodeCfg.metadata,
@@ -10681,14 +10683,15 @@ function registerOpencodeRoutes(router, ctx) {
10681
10683
  res.status(502).json({ error: "LiteLLM returned no key material" });
10682
10684
  return;
10683
10685
  }
10686
+ logger.info("opencode.connect", { userId, team: teamId ?? null, rotated });
10687
+ if (req.is("application/json")) {
10688
+ res.set("Cache-Control", "no-store");
10689
+ res.json({ key, team: teamId ?? null });
10690
+ return;
10691
+ }
10684
10692
  const url = new URL(redirectUri);
10685
10693
  url.searchParams.set("key", key);
10686
10694
  if (teamId) url.searchParams.set("team", teamId);
10687
- logger.info("opencode.connect", {
10688
- userId,
10689
- team: teamId ?? null,
10690
- rotated
10691
- });
10692
10695
  res.redirect(302, url.href);
10693
10696
  } catch (error) {
10694
10697
  if (error instanceof ProvisioningError) {