@acarmisc/backstage-plugin-litellm-backend 0.29.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.
- package/config.d.ts +8 -0
- package/dist/index.cjs.js +26 -2
- package/dist/index.cjs.js.map +3 -3
- package/dist/keySnippets.d.ts +8 -0
- package/dist/keySnippets.js +26 -0
- package/dist/openapi.js +1 -0
- package/dist/router.js +4 -0
- package/dist/routes/config.js +1 -0
- package/dist/routes/context.d.ts +3 -0
- package/package.json +1 -1
|
@@ -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
|
@@ -70,6 +70,7 @@ exports.openApiSpec = {
|
|
|
70
70
|
hideTeamBudgetForMembers: { type: 'boolean' },
|
|
71
71
|
hideTeamBudgetForManagers: { type: 'boolean' },
|
|
72
72
|
serviceKeyPrefixes: { type: 'array', items: { type: 'string' } },
|
|
73
|
+
keySnippets: { type: 'array', items: { type: 'string', enum: ['office365', 'opencode', 'claude-code', 'pi', 'openai', 'curl'] } },
|
|
73
74
|
} },
|
|
74
75
|
} } } },
|
|
75
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");
|
|
@@ -75,6 +76,8 @@ async function createRouter(options) {
|
|
|
75
76
|
const serviceKeyPrefixes = (config.getOptionalStringArray('litellm.display.serviceKeyPrefixes') ?? [])
|
|
76
77
|
.map(p => p.trim())
|
|
77
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'));
|
|
78
81
|
const baseClient = options.client ?? new client_1.LiteLLMClient({ baseUrl, masterKey });
|
|
79
82
|
// Wrap client with userInfoCache. TTL is configurable (default 10s, 0 disables).
|
|
80
83
|
const userInfoCacheTtlSeconds = config.getOptionalNumber('litellm.cache.userInfoTtlSeconds') ?? 10;
|
|
@@ -139,6 +142,7 @@ async function createRouter(options) {
|
|
|
139
142
|
publicBaseUrl,
|
|
140
143
|
supportContact,
|
|
141
144
|
serviceKeyPrefixes,
|
|
145
|
+
keySnippets,
|
|
142
146
|
userIdDomain,
|
|
143
147
|
provisioningEnabled,
|
|
144
148
|
provisioningDefaults,
|
package/dist/routes/config.js
CHANGED
|
@@ -36,6 +36,7 @@ function registerConfigRoutes(router, ctx) {
|
|
|
36
36
|
hideTeamBudgetForMembers: ctx.teamBudgetVisibility.hideTeamBudgetForMembers,
|
|
37
37
|
hideTeamBudgetForManagers: ctx.teamBudgetVisibility.hideTeamBudgetForManagers,
|
|
38
38
|
serviceKeyPrefixes: ctx.serviceKeyPrefixes,
|
|
39
|
+
keySnippets: ctx.keySnippets,
|
|
39
40
|
},
|
|
40
41
|
});
|
|
41
42
|
});
|
package/dist/routes/context.d.ts
CHANGED
|
@@ -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';
|
|
@@ -25,6 +26,8 @@ export interface RouterContext {
|
|
|
25
26
|
supportContact: string | undefined;
|
|
26
27
|
/** Key-alias prefixes treated as service keys by the frontend (display-only). */
|
|
27
28
|
serviceKeyPrefixes: string[];
|
|
29
|
+
/** Starter-snippet tabs the key dialog shows, in order (display-only). */
|
|
30
|
+
keySnippets: KeySnippetTab[];
|
|
28
31
|
userIdDomain: string | undefined;
|
|
29
32
|
provisioningEnabled: boolean;
|
|
30
33
|
provisioningDefaults: ProvisioningDefaults;
|