@makine/cli 0.1.4
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/LICENSE +34 -0
- package/dist/index.d.ts +63 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +380 -0
- package/dist/index.js.map +1 -0
- package/dist/main.d.ts +3 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +31 -0
- package/dist/main.js.map +1 -0
- package/dist/migrate/command.d.ts +39 -0
- package/dist/migrate/command.d.ts.map +1 -0
- package/dist/migrate/command.js +257 -0
- package/dist/migrate/command.js.map +1 -0
- package/dist/migrate/credentials.d.ts +29 -0
- package/dist/migrate/credentials.d.ts.map +1 -0
- package/dist/migrate/credentials.js +56 -0
- package/dist/migrate/credentials.js.map +1 -0
- package/dist/migrate/litellm.d.ts +13 -0
- package/dist/migrate/litellm.d.ts.map +1 -0
- package/dist/migrate/litellm.js +454 -0
- package/dist/migrate/litellm.js.map +1 -0
- package/dist/migrate/nodes.d.ts +7 -0
- package/dist/migrate/nodes.d.ts.map +1 -0
- package/dist/migrate/nodes.js +17 -0
- package/dist/migrate/nodes.js.map +1 -0
- package/dist/migrate/paths.d.ts +17 -0
- package/dist/migrate/paths.d.ts.map +1 -0
- package/dist/migrate/paths.js +94 -0
- package/dist/migrate/paths.js.map +1 -0
- package/dist/migrate/portkey.d.ts +22 -0
- package/dist/migrate/portkey.d.ts.map +1 -0
- package/dist/migrate/portkey.js +371 -0
- package/dist/migrate/portkey.js.map +1 -0
- package/dist/migrate/render.d.ts +22 -0
- package/dist/migrate/render.d.ts.map +1 -0
- package/dist/migrate/render.js +124 -0
- package/dist/migrate/render.js.map +1 -0
- package/dist/migrate/runtime-rules.d.ts +55 -0
- package/dist/migrate/runtime-rules.d.ts.map +1 -0
- package/dist/migrate/runtime-rules.js +203 -0
- package/dist/migrate/runtime-rules.js.map +1 -0
- package/dist/migrate/translate.d.ts +96 -0
- package/dist/migrate/translate.d.ts.map +1 -0
- package/dist/migrate/translate.js +305 -0
- package/dist/migrate/translate.js.map +1 -0
- package/dist/migrate/types.d.ts +63 -0
- package/dist/migrate/types.d.ts.map +1 -0
- package/dist/migrate/types.js +9 -0
- package/dist/migrate/types.js.map +1 -0
- package/package.json +40 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `makine migrate` — the only part of the translator that touches the world.
|
|
3
|
+
*
|
|
4
|
+
* Reads one file, parses it, translates, prints. No network call is made on any path: a migration
|
|
5
|
+
* tool that phoned a provider to "check" a config would be sending someone else's credentials to
|
|
6
|
+
* someone else's endpoint on their behalf.
|
|
7
|
+
*/
|
|
8
|
+
import { readFileSync } from "node:fs";
|
|
9
|
+
import { isAlias, isCollection, isScalar, LineCounter, parseDocument, visit, } from "yaml";
|
|
10
|
+
import { MigrateInputError } from "./nodes.js";
|
|
11
|
+
import { renderEnvFile, renderJson } from "./render.js";
|
|
12
|
+
import { translate } from "./translate.js";
|
|
13
|
+
const SOURCES = ["litellm", "portkey"];
|
|
14
|
+
const SHAPES = ["onprem", "direct"];
|
|
15
|
+
/** `true` when the input parsed and a report was produced — gaps or not. */
|
|
16
|
+
export function runMigrate(invocation, io) {
|
|
17
|
+
const { from, shape = "onprem", files } = invocation;
|
|
18
|
+
if (from === undefined) {
|
|
19
|
+
io.err("migrate needs --from litellm or --from portkey.");
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
if (!SOURCES.includes(from)) {
|
|
23
|
+
io.err(`--from must be litellm or portkey, got \`${from}\`.`);
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
if (!SHAPES.includes(shape)) {
|
|
27
|
+
io.err(`--shape must be onprem or direct, got \`${shape}\`.`);
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
if (files.length === 0) {
|
|
31
|
+
io.err("migrate needs the path to the config file to translate.");
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
if (files.length > 1) {
|
|
35
|
+
io.err(`migrate takes one file, got ${String(files.length)}.`);
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
const path = files[0] ?? "";
|
|
39
|
+
const read = io.readFile ?? ((target) => readFileSync(target, "utf8"));
|
|
40
|
+
let text;
|
|
41
|
+
try {
|
|
42
|
+
text = read(path);
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
io.err(`Could not read \`${path}\`: ${messageOf(error)}`);
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
const source = from;
|
|
49
|
+
const parsed = parseConfigText(text, source, path);
|
|
50
|
+
if (!parsed.ok) {
|
|
51
|
+
io.err(parsed.message);
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
let output;
|
|
55
|
+
try {
|
|
56
|
+
const result = translate(parsed.value, { source, shape: shape });
|
|
57
|
+
output = invocation.json ? renderJson(result) : renderEnvFile(result);
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
if (error instanceof MigrateInputError) {
|
|
61
|
+
io.err(`Could not translate \`${path}\`: ${error.message}`);
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
66
|
+
io.out(output.replace(/\n$/, ""));
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
function messageOf(error) {
|
|
70
|
+
return error instanceof Error ? error.message : String(error);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Exported so the reconciliation test walks EXACTLY the tree the command translates.
|
|
74
|
+
*
|
|
75
|
+
* The leaf walker in `packages/cli/test/migrate.test.ts` is deliberately written there rather than
|
|
76
|
+
* imported — a walker imported from the translator would agree with the translator's own bugs. The
|
|
77
|
+
* parser is the opposite case: if the test parsed with different options, it would reconcile a
|
|
78
|
+
* different document, and a YAML merge key would appear as a leaf in one and not in the other.
|
|
79
|
+
*/
|
|
80
|
+
export function parseConfigText(text, source, path) {
|
|
81
|
+
return source === "litellm" ? parseYamlInput(text, path) : parseJsonInput(text, path);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The one sentence a refusal is allowed to print.
|
|
85
|
+
*
|
|
86
|
+
* Every parser this command uses quotes the offending source in its message — YAML prints the whole
|
|
87
|
+
* line with a caret under it, V8 prints a short window around the bad token. The file is somebody
|
|
88
|
+
* else's provider config, so those lines routinely hold an API key, and stderr is as public as
|
|
89
|
+
* stdout: it lands in a CI log and in the terminal the user screenshots. A line and column locate
|
|
90
|
+
* the problem without reproducing it.
|
|
91
|
+
*
|
|
92
|
+
* It also covers the constructs refused AFTER the parser succeeded — an unresolved alias, a
|
|
93
|
+
* mapping key the report cannot print, a typed value — because the only safe sentence is the one
|
|
94
|
+
* that quotes nothing, and a second vocabulary would be a second chance to quote something.
|
|
95
|
+
*/
|
|
96
|
+
function parseFailureMessage(path, format, at) {
|
|
97
|
+
const where = at === undefined ? "" : ` at line ${String(at.line)}, column ${String(at.column)}`;
|
|
98
|
+
return (`Could not parse \`${path}\` as ${format}${where}; no part of the file is shown here, ` +
|
|
99
|
+
`because a config file holds credentials.`);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* `merge: true` because LiteLLM loads its config with PyYAML, which applies `<<` merge keys.
|
|
103
|
+
* Without it a deployment whose `api_base` arrives through a merge is translated as if it had none,
|
|
104
|
+
* and a self-hosted route is emitted as a cloud one.
|
|
105
|
+
*
|
|
106
|
+
* `parseDocument` rather than `parse`: `parse` with `logLevel: "error"` DISCARDS warnings, and an
|
|
107
|
+
* unresolved tag (`!vault`) is a warning. That path exits 0 today and hands back the tag's argument
|
|
108
|
+
* as if it were a plain string — so a vault reference silently becomes a literal value.
|
|
109
|
+
*/
|
|
110
|
+
function parseYamlInput(text, path) {
|
|
111
|
+
const lineCounter = new LineCounter();
|
|
112
|
+
const doc = parseDocument(text, {
|
|
113
|
+
prettyErrors: false,
|
|
114
|
+
logLevel: "error",
|
|
115
|
+
lineCounter,
|
|
116
|
+
merge: true,
|
|
117
|
+
});
|
|
118
|
+
const problem = doc.errors[0] ?? doc.warnings[0];
|
|
119
|
+
if (problem !== undefined) {
|
|
120
|
+
return { ok: false, message: parseFailureMessage(path, "YAML", positionOf(problem, lineCounter)) };
|
|
121
|
+
}
|
|
122
|
+
const badKey = findUnprintableKey(doc, lineCounter);
|
|
123
|
+
if (badKey.found) {
|
|
124
|
+
return { ok: false, message: parseFailureMessage(path, "YAML", badKey.at) };
|
|
125
|
+
}
|
|
126
|
+
let value;
|
|
127
|
+
try {
|
|
128
|
+
value = doc.toJS();
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
// An unresolved alias and the alias-count guard both throw here, carrying no position and a
|
|
132
|
+
// message that names the alias — which in a config written against a secret store is the
|
|
133
|
+
// secret's own name.
|
|
134
|
+
return { ok: false, message: parseFailureMessage(path, "YAML", undefined) };
|
|
135
|
+
}
|
|
136
|
+
if (!isJsonShaped(value)) {
|
|
137
|
+
return { ok: false, message: parseFailureMessage(path, "YAML", undefined) };
|
|
138
|
+
}
|
|
139
|
+
return { ok: true, value };
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* A mapping key the report cannot safely print.
|
|
143
|
+
*
|
|
144
|
+
* An alias used as a key (`a: &k sk-…` then `*k : 1`) resolves to whatever the anchor held; a
|
|
145
|
+
* complex key (`? {api_key: sk-…}` then `: 1`) is a whole collection stringified into one key; a
|
|
146
|
+
* TAGGED scalar key (`? !!binary c2s…` then `: 1`) is decoded by the tag's resolver before it
|
|
147
|
+
* becomes a key. All three become a key STRING in the parsed tree that no rule reading the source
|
|
148
|
+
* text could have recognised — the `!!binary` case arrives base64-encoded, so neither the
|
|
149
|
+
* separator test nor the prefix test in `paths.ts` sees the secret it decodes to. None of the
|
|
150
|
+
* three occurs in a real proxy config — LiteLLM's own loader refuses the complex key outright — so
|
|
151
|
+
* the file is refused rather than rendered carefully.
|
|
152
|
+
*
|
|
153
|
+
* The fourth is a pair with NO VALUE NODE. One slip inside a flow mapping turns the whole secret
|
|
154
|
+
* into a key name: `{master_key;sk-…}`, `{master_key.sk-…}` and `{master_key:sk-…}` are each ONE
|
|
155
|
+
* key holding the separator and the secret, while `{master_key,sk-…}` is TWO keys — the comma ends
|
|
156
|
+
* the entry, so the secret becomes a key of its own. Every one of those shapes reads the same way
|
|
157
|
+
* in LiteLLM's own loader, which then runs the proxy with no master key at all. `paths.ts` can only
|
|
158
|
+
* withhold the separators it lists, so every separator not on the list is a fresh leak.
|
|
159
|
+
*
|
|
160
|
+
* The shape is the reliable test rather than the character: `yaml` gives such a pair
|
|
161
|
+
* `value === null`, while `{master_key: }` and a blank block line `master_key:` both carry a
|
|
162
|
+
* `Scalar` null and stay admitted. A block `? master_key` with no `:` line also has no value node,
|
|
163
|
+
* so it is refused too — PyYAML loads that as an ordinary blank, and refusing it is the cost of
|
|
164
|
+
* testing the shape rather than the character. Refused rather than withheld, because the user needs
|
|
165
|
+
* to be stopped at that line rather than handed a placeholder for a proxy that is running
|
|
166
|
+
* unauthenticated.
|
|
167
|
+
*
|
|
168
|
+
* Only an EXPLICIT tag is refused: `yaml` sets `Scalar.tag` for `!!binary`, `!!str`, `!!int` and
|
|
169
|
+
* `!`, and leaves it undefined for plain, quoted and `? key` keys. The merge key is admitted in
|
|
170
|
+
* both its forms — `<<` is an untagged scalar key whose VALUE is the alias, and `!!merge <<` is
|
|
171
|
+
* exempted below, because PyYAML and `yaml` both apply it.
|
|
172
|
+
*/
|
|
173
|
+
function findUnprintableKey(doc, lineCounter) {
|
|
174
|
+
let at;
|
|
175
|
+
let found = false;
|
|
176
|
+
visit(doc, {
|
|
177
|
+
Pair(_index, pair) {
|
|
178
|
+
const tagged = isScalar(pair.key) && pair.key.tag !== undefined && !isExplicitMergeKey(pair.key);
|
|
179
|
+
const noValue = pair.value === null;
|
|
180
|
+
if (!isAlias(pair.key) && !isCollection(pair.key) && !tagged && !noValue)
|
|
181
|
+
return undefined;
|
|
182
|
+
found = true;
|
|
183
|
+
const offset = pair.key.range?.[0];
|
|
184
|
+
if (typeof offset === "number") {
|
|
185
|
+
const position = lineCounter.linePos(offset);
|
|
186
|
+
at = { line: position.line, column: position.col };
|
|
187
|
+
}
|
|
188
|
+
return visit.BREAK;
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
return at === undefined ? { found } : { found, at };
|
|
192
|
+
}
|
|
193
|
+
/** `yaml` resolves `!!merge` to this, and to this alone. */
|
|
194
|
+
const MERGE_TAG = "tag:yaml.org,2002:merge";
|
|
195
|
+
/**
|
|
196
|
+
* `!!merge <<`, the merge key written with its tag spelled out.
|
|
197
|
+
*
|
|
198
|
+
* The tag's resolver replaces the key with `Symbol(<<)` and keeps the written text in `source`, so
|
|
199
|
+
* the key never becomes a key string at all — there is nothing for the report to print, and both
|
|
200
|
+
* PyYAML and `yaml` merge the mapping it names.
|
|
201
|
+
*
|
|
202
|
+
* That holds for ANY key carrying the tag, `!!merge foo:` included: the resolver reads the tag, not
|
|
203
|
+
* the text, so `!!merge sk-…: *anchor` also becomes `Symbol(<<)` and also merges. So requiring
|
|
204
|
+
* `source === "<<"` withholds nothing that would otherwise leak. It is a conservative refusal of a
|
|
205
|
+
* construct no real config writes, kept because a file that spells the merge key as something other
|
|
206
|
+
* than `<<` is far more likely to be hand-crafted than to be a deployment someone wants migrated.
|
|
207
|
+
*/
|
|
208
|
+
function isExplicitMergeKey(key) {
|
|
209
|
+
return isScalar(key) && key.tag === MERGE_TAG && key.source === "<<";
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Whether `toJS()` produced something the translator can walk.
|
|
213
|
+
*
|
|
214
|
+
* `yaml` resolves `!!omap` to a Map, `!!set` to a Set, `!!timestamp` — and under `%YAML 1.1` a bare
|
|
215
|
+
* date — to a Date, and `!!binary` to a `Uint8Array`, none of which needs a directive to be
|
|
216
|
+
* recognised. Every one of them satisfies `isPlainObject` (`nodes.ts`), so the translator walks it
|
|
217
|
+
* as an EMPTY mapping: a `general_settings` written as an `!!omap` is reported "The section is
|
|
218
|
+
* empty", and a `!!binary` section is reported as one unknown key per byte. The file then reads as
|
|
219
|
+
* fully accounted for while its contents were never seen, which is the one thing this tool must
|
|
220
|
+
* never do. `resolveKnownTags: false` does not close it, because `%YAML 1.1` resolves the
|
|
221
|
+
* timestamp implicitly.
|
|
222
|
+
*/
|
|
223
|
+
function isJsonShaped(value) {
|
|
224
|
+
if (value === null || value === undefined)
|
|
225
|
+
return true;
|
|
226
|
+
if (typeof value !== "object") {
|
|
227
|
+
return typeof value !== "function" && typeof value !== "symbol";
|
|
228
|
+
}
|
|
229
|
+
if (Array.isArray(value))
|
|
230
|
+
return value.every(isJsonShaped);
|
|
231
|
+
const prototype = Object.getPrototypeOf(value);
|
|
232
|
+
if (prototype !== Object.prototype && prototype !== null)
|
|
233
|
+
return false;
|
|
234
|
+
return Object.values(value).every(isJsonShaped);
|
|
235
|
+
}
|
|
236
|
+
function positionOf(problem, lineCounter) {
|
|
237
|
+
const offset = problem.pos?.[0];
|
|
238
|
+
if (typeof offset !== "number")
|
|
239
|
+
return undefined;
|
|
240
|
+
const at = lineCounter.linePos(offset);
|
|
241
|
+
return { line: at.line, column: at.col };
|
|
242
|
+
}
|
|
243
|
+
/** V8's `Unexpected token …` message quotes the file and carries no position; it is never shown. */
|
|
244
|
+
const JSON_POSITION = /\(line (\d+) column (\d+)\)/;
|
|
245
|
+
function parseJsonInput(text, path) {
|
|
246
|
+
try {
|
|
247
|
+
return { ok: true, value: JSON.parse(text) };
|
|
248
|
+
}
|
|
249
|
+
catch (error) {
|
|
250
|
+
const match = JSON_POSITION.exec(messageOf(error));
|
|
251
|
+
const line = Number(match?.[1]);
|
|
252
|
+
const column = Number(match?.[2]);
|
|
253
|
+
const at = Number.isInteger(line) && Number.isInteger(column) ? { line, column } : undefined;
|
|
254
|
+
return { ok: false, message: parseFailureMessage(path, "JSON", at) };
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 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,SAAS,cAAc,CAAC,IAAY,EAAE,IAAY;IAChD,IAAI,CAAC;QACH,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;IAC/C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;QACnD,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAChC,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAClC,MAAM,EAAE,GACN,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QACpF,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;IACvE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What counts as a credential in a file this tool was handed.
|
|
3
|
+
*
|
|
4
|
+
* The tool reads a config written for another product, so it cannot know which fields are secret
|
|
5
|
+
* from a schema. It decides by key name and by position, and errs wide: over-detection only means a
|
|
6
|
+
* value is not quoted back at the user, which costs nothing.
|
|
7
|
+
*
|
|
8
|
+
* This module decides by key name alone. A credential carried somewhere other than a key — the
|
|
9
|
+
* userinfo of a connection string, which
|
|
10
|
+
* `system-governance/security-compliance/secrets-policy.md:134-135` classifies as a secret — is
|
|
11
|
+
* refused where endpoints are normalised (`runtime-rules.ts`), not here.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Splits on non-alphanumerics, and additionally on camelCase boundaries so `apiKey` is caught as
|
|
15
|
+
* well as `api_key`. Upstream config files are snake_case, but a hand-edited one need not be.
|
|
16
|
+
*/
|
|
17
|
+
export declare function splitKeyWords(key: string): readonly string[];
|
|
18
|
+
export declare function isCredentialKey(key: string): boolean;
|
|
19
|
+
export type CredentialKind = "env_ref" | "literal";
|
|
20
|
+
export interface CredentialSource {
|
|
21
|
+
kind: CredentialKind;
|
|
22
|
+
/** For `os.environ/NAME`, the variable NAME — a name, never a secret. */
|
|
23
|
+
envName?: string;
|
|
24
|
+
}
|
|
25
|
+
/** LiteLLM writes `os.environ/OPENAI_API_KEY` for "read it from the environment". */
|
|
26
|
+
export declare function readCredentialSource(value: unknown): CredentialSource;
|
|
27
|
+
/** The sentence a `credential_withheld` entry carries. Never contains the value. */
|
|
28
|
+
export declare function describeCredential(source: CredentialSource, variable: string): string;
|
|
29
|
+
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../src/migrate/credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAaH;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAM5D;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEpD;AAQD,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,SAAS,CAAC;AAEnD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,cAAc,CAAC;IACrB,yEAAyE;IACzE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qFAAqF;AACrF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,gBAAgB,CAQrE;AAED,oFAAoF;AACpF,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAWrF"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What counts as a credential in a file this tool was handed.
|
|
3
|
+
*
|
|
4
|
+
* The tool reads a config written for another product, so it cannot know which fields are secret
|
|
5
|
+
* from a schema. It decides by key name and by position, and errs wide: over-detection only means a
|
|
6
|
+
* value is not quoted back at the user, which costs nothing.
|
|
7
|
+
*
|
|
8
|
+
* This module decides by key name alone. A credential carried somewhere other than a key — the
|
|
9
|
+
* userinfo of a connection string, which
|
|
10
|
+
* `system-governance/security-compliance/secrets-policy.md:134-135` classifies as a secret — is
|
|
11
|
+
* refused where endpoints are normalised (`runtime-rules.ts`), not here.
|
|
12
|
+
*/
|
|
13
|
+
const CREDENTIAL_WORDS = new Set([
|
|
14
|
+
"key",
|
|
15
|
+
"secret",
|
|
16
|
+
"token",
|
|
17
|
+
"password",
|
|
18
|
+
"credential",
|
|
19
|
+
"credentials",
|
|
20
|
+
"auth",
|
|
21
|
+
"authorization",
|
|
22
|
+
]);
|
|
23
|
+
/**
|
|
24
|
+
* Splits on non-alphanumerics, and additionally on camelCase boundaries so `apiKey` is caught as
|
|
25
|
+
* well as `api_key`. Upstream config files are snake_case, but a hand-edited one need not be.
|
|
26
|
+
*/
|
|
27
|
+
export function splitKeyWords(key) {
|
|
28
|
+
return key
|
|
29
|
+
.replace(/([a-z0-9])([A-Z])/g, "$1 $2")
|
|
30
|
+
.split(/[^A-Za-z0-9]+/)
|
|
31
|
+
.filter((word) => word.length > 0)
|
|
32
|
+
.map((word) => word.toLowerCase());
|
|
33
|
+
}
|
|
34
|
+
export function isCredentialKey(key) {
|
|
35
|
+
return splitKeyWords(key).some((word) => CREDENTIAL_WORDS.has(word));
|
|
36
|
+
}
|
|
37
|
+
/** LiteLLM writes `os.environ/OPENAI_API_KEY` for "read it from the environment". */
|
|
38
|
+
export function readCredentialSource(value) {
|
|
39
|
+
if (typeof value === "string" && value.startsWith("os.environ/")) {
|
|
40
|
+
const envName = value.slice("os.environ/".length).trim();
|
|
41
|
+
if (envName.length > 0 && /^[A-Za-z_][A-Za-z0-9_]*$/.test(envName)) {
|
|
42
|
+
return { kind: "env_ref", envName };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return { kind: "literal" };
|
|
46
|
+
}
|
|
47
|
+
/** The sentence a `credential_withheld` entry carries. Never contains the value. */
|
|
48
|
+
export function describeCredential(source, variable) {
|
|
49
|
+
if (source.kind === "env_ref" && source.envName !== undefined) {
|
|
50
|
+
return (`The upstream config read this key from the environment variable ${source.envName}. ` +
|
|
51
|
+
`Set ${variable} to that same value yourself; this tool did not copy it.`);
|
|
52
|
+
}
|
|
53
|
+
return (`A literal key was written in the file. It was not copied. ` +
|
|
54
|
+
`${variable} is emitted empty — fill it in yourself, from a secret store rather than the file.`);
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../src/migrate/credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC;IAC/B,KAAK;IACL,QAAQ;IACR,OAAO;IACP,UAAU;IACV,YAAY;IACZ,aAAa;IACb,MAAM;IACN,eAAe;CAChB,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,OAAO,GAAG;SACP,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC;SACtC,KAAK,CAAC,eAAe,CAAC;SACtB,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;SACjC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,GAAW;IACzC,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;AACvE,CAAC;AAgBD,qFAAqF;AACrF,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;QACjE,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;QACzD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,0BAA0B,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YACnE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;QACtC,CAAC;IACH,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AAC7B,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,kBAAkB,CAAC,MAAwB,EAAE,QAAgB;IAC3E,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QAC9D,OAAO,CACL,mEAAmE,MAAM,CAAC,OAAO,IAAI;YACrF,OAAO,QAAQ,0DAA0D,CAC1E,CAAC;IACJ,CAAC;IACD,OAAO,CACL,4DAA4D;QAC5D,GAAG,QAAQ,oFAAoF,CAChG,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LiteLLM proxy `config.yaml` → Makine slots.
|
|
3
|
+
*
|
|
4
|
+
* Read from `https://docs.litellm.ai/docs/proxy/configs` on 2026-09-24. Keys this file does not
|
|
5
|
+
* list come out as `unknown_key`: the walk is over the file, not over a list of sections the tool
|
|
6
|
+
* hopes to find.
|
|
7
|
+
*
|
|
8
|
+
* `model_list` entries are independent deployments — unlike Portkey's `targets`, which are one
|
|
9
|
+
* fallback chain — so each is considered on its own and each can claim a different slot.
|
|
10
|
+
*/
|
|
11
|
+
import type { TranslationBuilder } from "./translate.js";
|
|
12
|
+
export declare function translateLiteLlm(root: unknown, builder: TranslationBuilder): void;
|
|
13
|
+
//# sourceMappingURL=litellm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"litellm.d.ts","sourceRoot":"","sources":["../../src/migrate/litellm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,KAAK,EAA2B,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAyMlF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAoCjF"}
|