@acarmisc/backstage-plugin-litellm-backend 0.28.0 → 0.30.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.
@@ -0,0 +1,8 @@
1
+ /** Starter-snippet tabs the key dialog can show, in default order. */
2
+ export declare const KEY_SNIPPET_TABS: readonly ["office365", "opencode", "claude-code", "pi", "openai", "curl"];
3
+ export type KeySnippetTab = (typeof KEY_SNIPPET_TABS)[number];
4
+ /**
5
+ * Reads litellm.display.keySnippets. Omitted means every tab in default order.
6
+ * Throws at startup on an empty, unknown or duplicated list so a typo fails loudly.
7
+ */
8
+ export declare function parseKeySnippetTabs(raw: string[] | undefined): KeySnippetTab[];
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KEY_SNIPPET_TABS = void 0;
4
+ exports.parseKeySnippetTabs = parseKeySnippetTabs;
5
+ /** Starter-snippet tabs the key dialog can show, in default order. */
6
+ exports.KEY_SNIPPET_TABS = ['office365', 'opencode', 'claude-code', 'pi', 'openai', 'curl'];
7
+ /**
8
+ * Reads litellm.display.keySnippets. Omitted means every tab in default order.
9
+ * Throws at startup on an empty, unknown or duplicated list so a typo fails loudly.
10
+ */
11
+ function parseKeySnippetTabs(raw) {
12
+ if (raw === undefined)
13
+ return [...exports.KEY_SNIPPET_TABS];
14
+ if (raw.length === 0) {
15
+ throw new Error('litellm.display.keySnippets must list at least one tab');
16
+ }
17
+ const allowed = exports.KEY_SNIPPET_TABS;
18
+ const unknown = raw.filter(tab => !allowed.includes(tab));
19
+ if (unknown.length > 0) {
20
+ throw new Error(`litellm.display.keySnippets: unknown tab(s) ${unknown.join(', ')}. Allowed: ${exports.KEY_SNIPPET_TABS.join(', ')}`);
21
+ }
22
+ if (new Set(raw).size !== raw.length) {
23
+ throw new Error('litellm.display.keySnippets lists a tab more than once');
24
+ }
25
+ return raw;
26
+ }
package/dist/openapi.js CHANGED
@@ -69,6 +69,8 @@ exports.openApiSpec = {
69
69
  display: { type: 'object', properties: {
70
70
  hideTeamBudgetForMembers: { type: 'boolean' },
71
71
  hideTeamBudgetForManagers: { type: 'boolean' },
72
+ serviceKeyPrefixes: { type: 'array', items: { type: 'string' } },
73
+ keySnippets: { type: 'array', items: { type: 'string', enum: ['office365', 'opencode', 'claude-code', 'pi', 'openai', 'curl'] } },
72
74
  } },
73
75
  } } } },
74
76
  },
package/dist/router.js CHANGED
@@ -42,6 +42,7 @@ const catalog_client_1 = require("@backstage/catalog-client");
42
42
  const client_1 = require("./client");
43
43
  const provisioning_1 = require("./provisioning");
44
44
  Object.defineProperty(exports, "ProvisioningError", { enumerable: true, get: function () { return provisioning_1.ProvisioningError; } });
45
+ const keySnippets_1 = require("./keySnippets");
45
46
  const backstage_plugin_litellm_common_1 = require("@acarmisc/backstage-plugin-litellm-common");
46
47
  const teamAdmin_1 = require("./teamAdmin");
47
48
  const teamBudgetVisibility_1 = require("./teamBudgetVisibility");
@@ -71,6 +72,12 @@ async function createRouter(options) {
71
72
  const publicBaseUrl = config.getOptionalString('litellm.publicBaseUrl') ?? null;
72
73
  // Support contact for unprovisioned users (optional).
73
74
  const supportContact = config.getOptionalString('litellm.supportContact');
75
+ // Alias prefixes of system/service keys the frontend hides by default.
76
+ const serviceKeyPrefixes = (config.getOptionalStringArray('litellm.display.serviceKeyPrefixes') ?? [])
77
+ .map(p => p.trim())
78
+ .filter(p => p.length > 0);
79
+ // Starter-snippet tabs shown after key generation, in order (display-only).
80
+ const keySnippets = (0, keySnippets_1.parseKeySnippetTabs)(config.getOptionalStringArray('litellm.display.keySnippets'));
74
81
  const baseClient = options.client ?? new client_1.LiteLLMClient({ baseUrl, masterKey });
75
82
  // Wrap client with userInfoCache. TTL is configurable (default 10s, 0 disables).
76
83
  const userInfoCacheTtlSeconds = config.getOptionalNumber('litellm.cache.userInfoTtlSeconds') ?? 10;
@@ -134,6 +141,8 @@ async function createRouter(options) {
134
141
  baseUrl,
135
142
  publicBaseUrl,
136
143
  supportContact,
144
+ serviceKeyPrefixes,
145
+ keySnippets,
137
146
  userIdDomain,
138
147
  provisioningEnabled,
139
148
  provisioningDefaults,
@@ -35,6 +35,8 @@ function registerConfigRoutes(router, ctx) {
35
35
  display: {
36
36
  hideTeamBudgetForMembers: ctx.teamBudgetVisibility.hideTeamBudgetForMembers,
37
37
  hideTeamBudgetForManagers: ctx.teamBudgetVisibility.hideTeamBudgetForManagers,
38
+ serviceKeyPrefixes: ctx.serviceKeyPrefixes,
39
+ keySnippets: ctx.keySnippets,
38
40
  },
39
41
  });
40
42
  });
@@ -5,6 +5,7 @@ import { CatalogClient } from '@backstage/catalog-client';
5
5
  import { LiteLLMClient } from '../client';
6
6
  import { ProvisioningDefaults, RoleConfig, VirtualKey, TeamInfo } from '../types';
7
7
  import { TeamAdminConfig } from '../teamAdmin';
8
+ import type { KeySnippetTab } from '../keySnippets';
8
9
  import type { KeyValidationConfig } from '@acarmisc/backstage-plugin-litellm-common';
9
10
  import { TeamBudgetVisibility } from '../teamBudgetVisibility';
10
11
  import { OpencodeConfig } from '../opencode';
@@ -23,6 +24,10 @@ export interface RouterContext {
23
24
  baseUrl: string;
24
25
  publicBaseUrl: string | null;
25
26
  supportContact: string | undefined;
27
+ /** Key-alias prefixes treated as service keys by the frontend (display-only). */
28
+ serviceKeyPrefixes: string[];
29
+ /** Starter-snippet tabs the key dialog shows, in order (display-only). */
30
+ keySnippets: KeySnippetTab[];
26
31
  userIdDomain: string | undefined;
27
32
  provisioningEnabled: boolean;
28
33
  provisioningDefaults: ProvisioningDefaults;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acarmisc/backstage-plugin-litellm-backend",
3
- "version": "0.28.0",
3
+ "version": "0.30.0",
4
4
  "description": "The Backstage backend plugin for LiteLLM governance",
5
5
  "backstage": {
6
6
  "role": "backend-plugin",