@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.
Files changed (50) hide show
  1. package/LICENSE +34 -0
  2. package/dist/index.d.ts +63 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +380 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/main.d.ts +3 -0
  7. package/dist/main.d.ts.map +1 -0
  8. package/dist/main.js +31 -0
  9. package/dist/main.js.map +1 -0
  10. package/dist/migrate/command.d.ts +39 -0
  11. package/dist/migrate/command.d.ts.map +1 -0
  12. package/dist/migrate/command.js +257 -0
  13. package/dist/migrate/command.js.map +1 -0
  14. package/dist/migrate/credentials.d.ts +29 -0
  15. package/dist/migrate/credentials.d.ts.map +1 -0
  16. package/dist/migrate/credentials.js +56 -0
  17. package/dist/migrate/credentials.js.map +1 -0
  18. package/dist/migrate/litellm.d.ts +13 -0
  19. package/dist/migrate/litellm.d.ts.map +1 -0
  20. package/dist/migrate/litellm.js +454 -0
  21. package/dist/migrate/litellm.js.map +1 -0
  22. package/dist/migrate/nodes.d.ts +7 -0
  23. package/dist/migrate/nodes.d.ts.map +1 -0
  24. package/dist/migrate/nodes.js +17 -0
  25. package/dist/migrate/nodes.js.map +1 -0
  26. package/dist/migrate/paths.d.ts +17 -0
  27. package/dist/migrate/paths.d.ts.map +1 -0
  28. package/dist/migrate/paths.js +94 -0
  29. package/dist/migrate/paths.js.map +1 -0
  30. package/dist/migrate/portkey.d.ts +22 -0
  31. package/dist/migrate/portkey.d.ts.map +1 -0
  32. package/dist/migrate/portkey.js +371 -0
  33. package/dist/migrate/portkey.js.map +1 -0
  34. package/dist/migrate/render.d.ts +22 -0
  35. package/dist/migrate/render.d.ts.map +1 -0
  36. package/dist/migrate/render.js +124 -0
  37. package/dist/migrate/render.js.map +1 -0
  38. package/dist/migrate/runtime-rules.d.ts +55 -0
  39. package/dist/migrate/runtime-rules.d.ts.map +1 -0
  40. package/dist/migrate/runtime-rules.js +203 -0
  41. package/dist/migrate/runtime-rules.js.map +1 -0
  42. package/dist/migrate/translate.d.ts +96 -0
  43. package/dist/migrate/translate.d.ts.map +1 -0
  44. package/dist/migrate/translate.js +305 -0
  45. package/dist/migrate/translate.js.map +1 -0
  46. package/dist/migrate/types.d.ts +63 -0
  47. package/dist/migrate/types.d.ts.map +1 -0
  48. package/dist/migrate/types.js +9 -0
  49. package/dist/migrate/types.js.map +1 -0
  50. package/package.json +40 -0
@@ -0,0 +1,203 @@
1
+ /**
2
+ * Makine's own admission rules, restated here because `@makine/cli` is a client.
3
+ *
4
+ * `@makine/cli` ships depending on `@makine/sdk` and `yaml` (`package.json`), so the runtime
5
+ * predicates cannot be imported here — importing them would ship the runtime with the CLI.
6
+ * `packages/cli/test/runtime-parity.test.ts` closes the gap instead: it takes
7
+ * `@makine/executors` and `@makine/providers` as DEV dependencies — absent from the published
8
+ * package — and drives the real functions alongside every rule restated below. A restated rule that
9
+ * drifts from its source fails that test.
10
+ *
11
+ * Sources:
12
+ * - host rule `packages/providers/src/capability-registry.ts:152-189` (isPrivateEndpointUrl)
13
+ * - cloud chat egress `packages/providers/src/chat.ts:40-46`, `:279-290` (assertChatEgressPermitted)
14
+ * - endpoint validation `packages/executors/src/configuration.ts:312-329` (validateModelEndpoint)
15
+ * - alias rule `packages/executors/src/configuration.ts:233-234`, `:275-286`
16
+ * - alias uniqueness `packages/policy-core/src/model-alias.ts:36-38`, `:62`
17
+ */
18
+ /** `packages/executors/src/configuration.ts:233`. */
19
+ const MODEL_ALIAS_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:\/-]{0,127}$/;
20
+ /** `packages/executors/src/configuration.ts:234`. */
21
+ export const MAX_MODEL_ALIASES_PER_SLOT = 20;
22
+ /** `packages/executors/src/configuration.ts:248`, the model-id length the runtime accepts. */
23
+ export const MAX_MODEL_LENGTH = 256;
24
+ export function isValidModelAlias(alias) {
25
+ return MODEL_ALIAS_PATTERN.test(alias);
26
+ }
27
+ /** `packages/policy-core/src/model-alias.ts:36-38`. Two slots claiming one normalized alias boot
28
+ * fine and then fail every request for it as `ambiguous_alias`. */
29
+ export function normalizeModelAlias(alias) {
30
+ return alias.trim().toLowerCase();
31
+ }
32
+ /**
33
+ * The characters an emitted value may contain.
34
+ *
35
+ * Narrower than anything Makine enforces, and deliberately so: the output is read by Compose
36
+ * through `--env-file`, where `$` starts an interpolation and `#` can start a comment. A value that
37
+ * cannot contain either cannot be silently rewritten between this tool and the running container.
38
+ * Whitespace and quotes are out for the same reason.
39
+ */
40
+ const EMITTABLE_VALUE = /^[A-Za-z0-9._:\/@+,-]*$/;
41
+ export function isEmittableValue(value) {
42
+ return EMITTABLE_VALUE.test(value);
43
+ }
44
+ /**
45
+ * `packages/providers/src/capability-registry.ts:152-178`, restated.
46
+ *
47
+ * Does not resolve names, for the same reason the original does not: `*.local` and
48
+ * `host.docker.internal` are trusted for what they mean, not for where they point. `169.254/16` is
49
+ * NOT private here — it is the cloud instance-metadata range.
50
+ */
51
+ export function isPrivateEndpointUrl(url) {
52
+ const hostname = url.hostname.toLowerCase().replace(/^\[(.*)\]$/, "$1");
53
+ if (hostname === "localhost" ||
54
+ hostname === "::1" ||
55
+ hostname === "0.0.0.0" ||
56
+ hostname === "host.docker.internal") {
57
+ return true;
58
+ }
59
+ if (hostname.endsWith(".local"))
60
+ return true;
61
+ const ipv4 = parseIpv4Address(hostname);
62
+ if (ipv4 === undefined)
63
+ return false;
64
+ const [first, second] = ipv4;
65
+ return (first === 127 ||
66
+ first === 10 ||
67
+ (first === 172 && second >= 16 && second <= 31) ||
68
+ (first === 192 && second === 168));
69
+ }
70
+ function parseIpv4Address(hostname) {
71
+ const parts = hostname.split(".");
72
+ if (parts.length !== 4)
73
+ return undefined;
74
+ const octets = [];
75
+ for (const part of parts) {
76
+ if (!/^\d+$/.test(part))
77
+ return undefined;
78
+ const octet = Number.parseInt(part, 10);
79
+ if (octet < 0 || octet > 255)
80
+ return undefined;
81
+ octets.push(octet);
82
+ }
83
+ const [first, second] = octets;
84
+ if (first === undefined || second === undefined)
85
+ return undefined;
86
+ return [first, second];
87
+ }
88
+ /** `packages/providers/src/chat.ts:40-46`. The two hosts the 2026-08-23 egress sign-off names. */
89
+ export const SIGNED_CHAT_EGRESS_HOSTS = ["api.openai.com", "api.anthropic.com"];
90
+ /**
91
+ * Turns an upstream endpoint into a `MAKINE_LOCAL_PROVIDER_BASE_URL`, or says why it cannot.
92
+ *
93
+ * Checks run in the task's category precedence: `egress_refused` before `invalid_value`, because a
94
+ * host the guard will not admit is the more fundamental fact about the endpoint.
95
+ */
96
+ export function toLocalProviderBaseUrl(raw, shape) {
97
+ let url;
98
+ try {
99
+ url = new URL(raw);
100
+ }
101
+ catch {
102
+ return {
103
+ ok: false,
104
+ category: "egress_refused",
105
+ reason: "Not an absolute URL, so Makine's chat egress guard reads it as a remote host and refuses " +
106
+ "it. Every request would fail after the deployment booted. Give a full URL with a scheme, " +
107
+ "e.g. http://host.docker.internal:11434.",
108
+ };
109
+ }
110
+ // No part of a refused URL is quoted, the host included. A quick-tunnel address such as
111
+ // `https://<token>.trycloudflare.com` carries its credential in the HOSTNAME — the token is the
112
+ // only thing guarding the server behind it — and
113
+ // `system-governance/security-compliance/secrets-policy.md:84-85` says treat an ambiguous value
114
+ // as a secret. A refusal reason is printed in the report, in `--json`, and in whatever file the
115
+ // user redirects the output into, and the report entry already names which field it is about.
116
+ if (!isPrivateEndpointUrl(url)) {
117
+ return {
118
+ ok: false,
119
+ category: "egress_refused",
120
+ reason: `Makine's chat egress guard admits only local and private-network hosts for this slot — ` +
121
+ `localhost, ::1, 0.0.0.0, host.docker.internal, *.local, and IPv4 in 127/8, 10/8, ` +
122
+ `172.16/12 and 192.168/16. This endpoint's host is none of those, so the deployment ` +
123
+ `would boot and then fail every request. A bare Compose service name such as ` +
124
+ `http://vllm:8000 is refused for the same reason: the guard does not resolve names. Give ` +
125
+ `the container a ".local" network alias and point at that ` +
126
+ `(docs/operations/onprem-deployment.md:146-161).`,
127
+ };
128
+ }
129
+ if (url.username !== "" || url.password !== "") {
130
+ return {
131
+ ok: false,
132
+ category: "invalid_value",
133
+ reason: "The URL carries a username or password. Makine refuses that at boot, because it would " +
134
+ "store a credential inside a configuration row where no log redaction reaches it " +
135
+ "(packages/executors/src/configuration.ts:319-322). Move the credential to " +
136
+ "MAKINE_LOCAL_PROVIDER_API_KEY and give a bare URL.",
137
+ };
138
+ }
139
+ if (url.search !== "" || url.hash !== "") {
140
+ return {
141
+ ok: false,
142
+ category: "invalid_value",
143
+ reason: "The URL carries a query string or a fragment. Makine refuses both at boot " +
144
+ "(packages/executors/src/configuration.ts:323-324).",
145
+ };
146
+ }
147
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
148
+ return {
149
+ ok: false,
150
+ category: "invalid_value",
151
+ reason: `Makine's local chat slot speaks HTTP or HTTPS; "${url.protocol}" is neither.`,
152
+ };
153
+ }
154
+ // The runtime appends `/v1` to this variable and the adapter then appends `/chat/completions`
155
+ // (`apps/api/src/index.ts:426`; `docs/operations/onprem-deployment.md:168`). An upstream config
156
+ // naming either suffix reaches the same endpoint once both are stripped, so both come off, in
157
+ // that order and case-insensitively — `/V1` is the same route to every HTTP server.
158
+ const path = url.pathname
159
+ .replace(/\/+$/, "")
160
+ .replace(/\/chat\/completions$/i, "")
161
+ .replace(/\/v1$/i, "");
162
+ let host = url.host;
163
+ let rewritten = false;
164
+ let rewriteReason;
165
+ if (shape === "onprem" && isContainerLoopback(url)) {
166
+ host = url.port === "" ? "host.docker.internal" : `host.docker.internal:${url.port}`;
167
+ rewritten = true;
168
+ rewriteReason =
169
+ `Rewritten from ${url.host} to ${host}. On the on-prem shape the API runs inside a ` +
170
+ `container, where a loopback address is the container itself, not the machine running the ` +
171
+ `model server. The compose file maps host.docker.internal to the host for exactly this ` +
172
+ `(docker-compose.onprem.yml:33-34), and the egress guard admits that name.`;
173
+ }
174
+ const value = `${url.protocol}//${host}${path}`;
175
+ if (!isEmittableValue(value)) {
176
+ return {
177
+ ok: false,
178
+ category: "invalid_value",
179
+ reason: `The endpoint contains characters that cannot be carried safely through an env file read ` +
180
+ `by Compose. An IPv6 literal is the usual cause: its square brackets are outside the ` +
181
+ `emittable set. Use a hostname or an IPv4 address.`,
182
+ };
183
+ }
184
+ return rewriteReason === undefined
185
+ ? { ok: true, value, rewritten }
186
+ : { ok: true, value, rewritten, rewriteReason };
187
+ }
188
+ /**
189
+ * Loopback as seen from inside the API container.
190
+ *
191
+ * The task names `localhost`, `127.0.0.1` and `::1`. This covers the whole loopback family —
192
+ * `0.0.0.0` and all of `127/8` — because the failure is identical for each: inside the container
193
+ * the address resolves to the container, and the model server is not there. The wider set is
194
+ * declared in the completion note.
195
+ */
196
+ function isContainerLoopback(url) {
197
+ const hostname = url.hostname.toLowerCase().replace(/^\[(.*)\]$/, "$1");
198
+ if (hostname === "localhost" || hostname === "::1" || hostname === "0.0.0.0")
199
+ return true;
200
+ const ipv4 = parseIpv4Address(hostname);
201
+ return ipv4 !== undefined && ipv4[0] === 127;
202
+ }
203
+ //# sourceMappingURL=runtime-rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-rules.js","sourceRoot":"","sources":["../../src/migrate/runtime-rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,qDAAqD;AACrD,MAAM,mBAAmB,GAAG,uCAAuC,CAAC;AAEpE,qDAAqD;AACrD,MAAM,CAAC,MAAM,0BAA0B,GAAG,EAAE,CAAC;AAE7C,8FAA8F;AAC9F,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAEpC,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,OAAO,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACzC,CAAC;AAED;mEACmE;AACnE,MAAM,UAAU,mBAAmB,CAAC,KAAa;IAC/C,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AACp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B,CAAC,CAAC,CAAC,wBAAwB,GAAG,CAAC,IAAI,EAAE,CAAC;QACrF,SAAS,GAAG,IAAI,CAAC;QACjB,aAAa;YACX,kBAAkB,GAAG,CAAC,IAAI,OAAO,IAAI,+CAA+C;gBACpF,2FAA2F;gBAC3F,wFAAwF;gBACxF,2EAA2E,CAAC;IAChF,CAAC;IAED,MAAM,KAAK,GAAG,GAAG,GAAG,CAAC,QAAQ,KAAK,IAAI,GAAG,IAAI,EAAE,CAAC;IAChD,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO;YACL,EAAE,EAAE,KAAK;YACT,QAAQ,EAAE,eAAe;YACzB,MAAM,EACJ,0FAA0F;gBAC1F,sFAAsF;gBACtF,mDAAmD;SACtD,CAAC;IACJ,CAAC;IAED,OAAO,aAAa,KAAK,SAAS;QAChC,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE;QAChC,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;AACpD,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,mBAAmB,CAAC,GAAQ;IACnC,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;IACxE,IAAI,QAAQ,KAAK,WAAW,IAAI,QAAQ,KAAK,KAAK,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAC1F,MAAM,IAAI,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACxC,OAAO,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * The translator's core: a pure function from a parsed config to data.
3
+ *
4
+ * Nothing here reads a file, touches the network, or prints. `render.ts` turns the result into an
5
+ * env-file fragment or JSON; `command.ts` is the only part that does I/O.
6
+ *
7
+ * The invariant the whole design serves: **every leaf of the input is either consumed or reported**.
8
+ * A construct that is silently dropped produces settings that look migrated and behave differently,
9
+ * which is worse than refusing to translate it.
10
+ */
11
+ import { type CredentialSource } from "./credentials.js";
12
+ import type { InputPath, MigrationShape, MigrationSource, ReportCategory, TranslationResult } from "./types.js";
13
+ export type SlotName = "openai" | "anthropic" | "local";
14
+ /**
15
+ * The closed list of variables each shape may emit, in emission order.
16
+ *
17
+ * `onprem` is short because the compose file's `api.environment` block is the whole channel into
18
+ * the API container (`docker-compose.onprem.yml:11-27`): there is no `env_file:`, and `--env-file`
19
+ * only feeds Compose's own interpolation. A name the block does not list never reaches the process,
20
+ * however carefully it is written into `makine.env`.
21
+ */
22
+ export declare const SHAPE_VARIABLES: Readonly<Record<MigrationShape, readonly string[]>>;
23
+ export interface SlotCandidate {
24
+ slot: SlotName;
25
+ /** The alias an application will send as `"model"`. LiteLLM `model_name`, Portkey pinned model. */
26
+ alias: {
27
+ value: string;
28
+ path: InputPath;
29
+ };
30
+ /** The upstream model id the provider itself understands. */
31
+ model: {
32
+ value: string;
33
+ path: InputPath;
34
+ };
35
+ /** Local slot only, as written upstream; normalized here. */
36
+ baseUrl?: {
37
+ value: string;
38
+ path: InputPath;
39
+ };
40
+ credential?: {
41
+ path: InputPath;
42
+ source: CredentialSource;
43
+ };
44
+ }
45
+ export type ClaimResult = {
46
+ ok: true;
47
+ } | {
48
+ ok: false;
49
+ category: ReportCategory;
50
+ reason: string;
51
+ };
52
+ /**
53
+ * Accumulates the four output lists and owns the rules that decide whether a deployment can become
54
+ * a slot at all.
55
+ *
56
+ * Both source parsers drive this; neither decides shape limits, slot occupancy or alias uniqueness
57
+ * for itself, so the two cannot drift.
58
+ */
59
+ export declare class TranslationBuilder {
60
+ readonly shape: MigrationShape;
61
+ private readonly slots;
62
+ private readonly aliasOwners;
63
+ private readonly consumedPaths;
64
+ private readonly reportEntries;
65
+ private readonly mappingEntries;
66
+ constructor(shape: MigrationShape);
67
+ /** A leaf whose value reached the output. Must be an exact leaf path: a parent covers nothing. */
68
+ consume(path: InputPath, variable?: string): void;
69
+ note(path: InputPath, category: ReportCategory, reason: string): void;
70
+ map(path: InputPath, variable: string): void;
71
+ isSlotTaken(slot: SlotName): boolean;
72
+ /**
73
+ * Try to turn one upstream deployment into one Makine slot.
74
+ *
75
+ * On success this records every consumption and every report the slot implies, so a caller
76
+ * cannot accept a deployment and then forget to withhold its key. On failure nothing is recorded
77
+ * and the caller reports the whole deployment: a partly emitted slot is never produced.
78
+ */
79
+ claimSlot(candidate: SlotCandidate): ClaimResult;
80
+ build(source: MigrationSource): TranslationResult;
81
+ /**
82
+ * Builds the lines, in the closed list's order.
83
+ *
84
+ * A slot's credential line is always emitted, blank. For OpenAI and Anthropic that is a blank the
85
+ * user must fill: the runtime registers those slots only when the key is non-empty
86
+ * (`apps/api/src/index.ts:382`, `:398`). For the local slot blank is the finished answer — a
87
+ * local model server needs no key, and blank reads as absent (`apps/api/src/index.ts:439-442`).
88
+ */
89
+ private emit;
90
+ }
91
+ export interface TranslateOptions {
92
+ source: MigrationSource;
93
+ shape: MigrationShape;
94
+ }
95
+ export declare function translate(input: unknown, options: TranslateOptions): TranslationResult;
96
+ //# sourceMappingURL=translate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translate.d.ts","sourceRoot":"","sources":["../../src/migrate/translate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAsB,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAY7E,OAAO,KAAK,EAEV,SAAS,EAET,cAAc,EACd,eAAe,EACf,cAAc,EAEd,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,WAAW,GAAG,OAAO,CAAC;AA4BxD;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,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AAE,MAAM,GAAG,IAAI;IAIrE,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAI5C,WAAW,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO;IAIpC;;;;;;OAMG;IACH,SAAS,CAAC,SAAS,EAAE,aAAa,GAAG,WAAW;IAgKhD,KAAK,CAAC,MAAM,EAAE,eAAe,GAAG,iBAAiB;IAWjD;;;;;;;OAOG;IACH,OAAO,CAAC,IAAI;CAuBb;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,eAAe,CAAC;IACxB,KAAK,EAAE,cAAc,CAAC;CACvB;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,GAAG,iBAAiB,CAQtF"}
@@ -0,0 +1,305 @@
1
+ /**
2
+ * The translator's core: a pure function from a parsed config to data.
3
+ *
4
+ * Nothing here reads a file, touches the network, or prints. `render.ts` turns the result into an
5
+ * env-file fragment or JSON; `command.ts` is the only part that does I/O.
6
+ *
7
+ * The invariant the whole design serves: **every leaf of the input is either consumed or reported**.
8
+ * A construct that is silently dropped produces settings that look migrated and behave differently,
9
+ * which is worse than refusing to translate it.
10
+ */
11
+ import { describeCredential } from "./credentials.js";
12
+ import { translateLiteLlm } from "./litellm.js";
13
+ import { pathsEqual } from "./paths.js";
14
+ import { translatePortkey } from "./portkey.js";
15
+ import { isEmittableValue, isValidModelAlias, MAX_MODEL_ALIASES_PER_SLOT, MAX_MODEL_LENGTH, normalizeModelAlias, toLocalProviderBaseUrl, } from "./runtime-rules.js";
16
+ const SLOT_VARIABLES = {
17
+ openai: {
18
+ credential: "OPENAI_API_KEY",
19
+ model: "MAKINE_OPENAI_CHAT_MODEL",
20
+ aliases: "MAKINE_OPENAI_CHAT_ALIASES",
21
+ },
22
+ anthropic: {
23
+ credential: "ANTHROPIC_API_KEY",
24
+ model: "MAKINE_ANTHROPIC_CHAT_MODEL",
25
+ aliases: "MAKINE_ANTHROPIC_CHAT_ALIASES",
26
+ },
27
+ local: {
28
+ credential: "MAKINE_LOCAL_PROVIDER_API_KEY",
29
+ model: "MAKINE_LOCAL_PROVIDER_MODEL",
30
+ aliases: "MAKINE_LOCAL_CHAT_ALIASES",
31
+ baseUrl: "MAKINE_LOCAL_PROVIDER_BASE_URL",
32
+ },
33
+ };
34
+ /**
35
+ * The closed list of variables each shape may emit, in emission order.
36
+ *
37
+ * `onprem` is short because the compose file's `api.environment` block is the whole channel into
38
+ * the API container (`docker-compose.onprem.yml:11-27`): there is no `env_file:`, and `--env-file`
39
+ * only feeds Compose's own interpolation. A name the block does not list never reaches the process,
40
+ * however carefully it is written into `makine.env`.
41
+ */
42
+ export const SHAPE_VARIABLES = {
43
+ onprem: [
44
+ "MAKINE_LOCAL_PROVIDER_BASE_URL",
45
+ "MAKINE_LOCAL_PROVIDER_MODEL",
46
+ "MAKINE_LOCAL_PROVIDER_API_KEY",
47
+ ],
48
+ direct: [
49
+ "OPENAI_API_KEY",
50
+ "MAKINE_OPENAI_CHAT_MODEL",
51
+ "MAKINE_OPENAI_CHAT_ALIASES",
52
+ "ANTHROPIC_API_KEY",
53
+ "MAKINE_ANTHROPIC_CHAT_MODEL",
54
+ "MAKINE_ANTHROPIC_CHAT_ALIASES",
55
+ "MAKINE_LOCAL_PROVIDER_BASE_URL",
56
+ "MAKINE_LOCAL_PROVIDER_MODEL",
57
+ "MAKINE_LOCAL_PROVIDER_API_KEY",
58
+ "MAKINE_LOCAL_CHAT_ALIASES",
59
+ ],
60
+ };
61
+ /**
62
+ * The local slot is not a chat-only setting, and nothing in the upstream config says so.
63
+ *
64
+ * `MAKINE_LOCAL_PROVIDER_BASE_URL` and `MAKINE_LOCAL_PROVIDER_MODEL` are read a second time by the
65
+ * document-extraction adapter (`apps/api/src/index.ts:273-295`) and a third time by the readiness
66
+ * probe (`:511-516`). Translating one upstream chat deployment therefore also moves extraction and
67
+ * the probe, which is a change to a part of the deployment the user was not migrating.
68
+ */
69
+ const LOCAL_SLOT_SIDE_EFFECT_REASON = "Translated as written, but this setting does more than chat. MAKINE_LOCAL_PROVIDER_BASE_URL " +
70
+ "and MAKINE_LOCAL_PROVIDER_MODEL are also read by Makine's document-extraction adapter " +
71
+ "(apps/api/src/index.ts:273-295) and by the readiness probe (apps/api/src/index.ts:511-516). " +
72
+ "Emitting them moves document extraction and the readiness probe to this endpoint and this " +
73
+ "model as well, whatever they used before. If extraction was pointed at a different model, " +
74
+ "re-point it after migrating.";
75
+ /**
76
+ * Accumulates the four output lists and owns the rules that decide whether a deployment can become
77
+ * a slot at all.
78
+ *
79
+ * Both source parsers drive this; neither decides shape limits, slot occupancy or alias uniqueness
80
+ * for itself, so the two cannot drift.
81
+ */
82
+ export class TranslationBuilder {
83
+ shape;
84
+ slots = new Map();
85
+ aliasOwners = new Map();
86
+ consumedPaths = [];
87
+ reportEntries = [];
88
+ mappingEntries = [];
89
+ constructor(shape) {
90
+ this.shape = shape;
91
+ }
92
+ /** A leaf whose value reached the output. Must be an exact leaf path: a parent covers nothing. */
93
+ consume(path, variable) {
94
+ this.consumedPaths.push([...path]);
95
+ if (variable !== undefined)
96
+ this.mappingEntries.push({ path: [...path], variable });
97
+ }
98
+ note(path, category, reason) {
99
+ this.reportEntries.push({ path: [...path], category, reason });
100
+ }
101
+ map(path, variable) {
102
+ this.mappingEntries.push({ path: [...path], variable });
103
+ }
104
+ isSlotTaken(slot) {
105
+ return this.slots.has(slot);
106
+ }
107
+ /**
108
+ * Try to turn one upstream deployment into one Makine slot.
109
+ *
110
+ * On success this records every consumption and every report the slot implies, so a caller
111
+ * cannot accept a deployment and then forget to withhold its key. On failure nothing is recorded
112
+ * and the caller reports the whole deployment: a partly emitted slot is never produced.
113
+ */
114
+ claimSlot(candidate) {
115
+ const variables = SLOT_VARIABLES[candidate.slot];
116
+ if (this.shape === "onprem" && candidate.slot !== "local") {
117
+ return {
118
+ ok: false,
119
+ category: "shape_limit",
120
+ reason: `This is ${candidate.slot === "openai" ? "an OpenAI" : "an Anthropic"} deployment, and ` +
121
+ `the on-prem compose file passes no cloud provider key into the API container by design ` +
122
+ `(apps/api/test/onprem-compose-egress.test.ts:13-14). It cannot be reached in this ` +
123
+ `shape at all. Re-run with --shape direct to see the settings it would need, and expect ` +
124
+ `to run the API outside the on-prem compose file. It is deliberately NOT routed through ` +
125
+ `the local slot pointed at the vendor's URL: those same variables also configure ` +
126
+ `document extraction, which has no egress check, so that would send documents to the ` +
127
+ `vendor under the name "local".`,
128
+ };
129
+ }
130
+ let baseUrl;
131
+ let rewriteReason;
132
+ if (candidate.slot === "local") {
133
+ if (candidate.baseUrl === undefined) {
134
+ return {
135
+ ok: false,
136
+ category: "invalid_value",
137
+ reason: "A local OpenAI-compatible deployment needs an explicit endpoint, and this one names " +
138
+ "none. Makine has no default: MAKINE_LOCAL_PROVIDER_BASE_URL must be a real URL.",
139
+ };
140
+ }
141
+ const normalized = toLocalProviderBaseUrl(candidate.baseUrl.value, this.shape);
142
+ if (!normalized.ok)
143
+ return { ok: false, category: normalized.category, reason: normalized.reason };
144
+ baseUrl = normalized.value;
145
+ rewriteReason = normalized.rewriteReason;
146
+ }
147
+ if (!isEmittableValue(candidate.model.value)) {
148
+ return {
149
+ ok: false,
150
+ category: "invalid_value",
151
+ reason: "The model name contains characters that cannot be carried safely through an env file " +
152
+ "read by Compose — whitespace, quotes, `$` or `#`. Nothing was emitted for this " +
153
+ "deployment rather than emitting a value Compose might rewrite.",
154
+ };
155
+ }
156
+ if (candidate.model.value.length > MAX_MODEL_LENGTH) {
157
+ return {
158
+ ok: false,
159
+ category: "invalid_value",
160
+ reason: `Makine accepts a model id of at most ${String(MAX_MODEL_LENGTH)} characters and this ` +
161
+ `one is ${String(candidate.model.value.length)} ` +
162
+ `(packages/executors/src/configuration.ts:248). Emitting it would produce a deployment ` +
163
+ `that fails to boot, so nothing was emitted for this deployment.`,
164
+ };
165
+ }
166
+ // On `onprem` the alias variable is not in the closed list, so an alias is never emitted and
167
+ // its validity cannot sink the deployment. `reportAliasShapeLimit` below tells the user what
168
+ // their application must send instead.
169
+ if (this.shape === "direct") {
170
+ if (!isValidModelAlias(candidate.alias.value) || !isEmittableValue(candidate.alias.value)) {
171
+ return {
172
+ ok: false,
173
+ category: "invalid_value",
174
+ reason: `Makine rejects "${candidate.alias.value}" as a model alias at boot: an alias must ` +
175
+ `start with a letter or digit, use only letters, digits and . _ : / -, and be at most ` +
176
+ `128 characters (packages/executors/src/configuration.ts:233). Rename it upstream, or ` +
177
+ `choose a different name for the Makine alias.`,
178
+ };
179
+ }
180
+ const normalizedAlias = normalizeModelAlias(candidate.alias.value);
181
+ const owner = this.aliasOwners.get(normalizedAlias);
182
+ if (owner !== undefined) {
183
+ return {
184
+ ok: false,
185
+ category: "invalid_value",
186
+ reason: `The alias "${candidate.alias.value}" is already claimed by the ${owner} slot. Makine ` +
187
+ `compares aliases trimmed and lower-cased, and two slots claiming one alias boot ` +
188
+ `normally and then fail every request for it as "ambiguous_alias" ` +
189
+ `(packages/policy-core/src/model-alias.ts:62). Give one of them a different name.`,
190
+ };
191
+ }
192
+ }
193
+ if (this.slots.has(candidate.slot)) {
194
+ const taken = this.slots.get(candidate.slot);
195
+ return {
196
+ ok: false,
197
+ category: "shape_limit",
198
+ reason: `Makine registers one model per slot, and the ${candidate.slot} slot already holds ` +
199
+ `"${taken?.model ?? ""}" (apps/api/src/index.ts:381-446). A second model here is not ` +
200
+ `expressible: it was NOT added as an extra alias of the first model, which would route ` +
201
+ `requests for this deployment to a different model without saying so. Run a second ` +
202
+ `Makine deployment if you need both.`,
203
+ };
204
+ }
205
+ this.slots.set(candidate.slot, {
206
+ model: candidate.model.value,
207
+ alias: candidate.alias.value,
208
+ ...(baseUrl === undefined ? {} : { baseUrl }),
209
+ });
210
+ if (this.shape === "direct") {
211
+ this.aliasOwners.set(normalizeModelAlias(candidate.alias.value), candidate.slot);
212
+ }
213
+ this.consume(candidate.model.path, variables.model);
214
+ if (candidate.slot === "local") {
215
+ this.note(candidate.model.path, "rewritten", LOCAL_SLOT_SIDE_EFFECT_REASON);
216
+ }
217
+ if (candidate.baseUrl !== undefined && variables.baseUrl !== undefined) {
218
+ this.consume(candidate.baseUrl.path, variables.baseUrl);
219
+ if (rewriteReason !== undefined) {
220
+ this.note(candidate.baseUrl.path, "rewritten", rewriteReason);
221
+ }
222
+ }
223
+ if (this.shape === "direct") {
224
+ // Portkey pins one string that becomes both the model and the alias. Consuming that leaf
225
+ // twice would be harmless for reconciliation but would read as two separate fields.
226
+ if (pathsEqual(candidate.alias.path, candidate.model.path)) {
227
+ this.map(candidate.alias.path, variables.aliases);
228
+ }
229
+ else {
230
+ this.consume(candidate.alias.path, variables.aliases);
231
+ }
232
+ }
233
+ else {
234
+ this.note(candidate.alias.path, "shape_limit", `The application will have to send "local-chat" as its model, not ` +
235
+ `"${candidate.alias.value}". The on-prem compose file does not pass ` +
236
+ `MAKINE_LOCAL_CHAT_ALIASES into the API container, so the alias falls back to ` +
237
+ `"local-chat" (apps/api/src/index.ts:443). Change the model name in your application, ` +
238
+ `or run with --shape direct where the alias can be set.`);
239
+ }
240
+ if (candidate.credential !== undefined) {
241
+ this.map(candidate.credential.path, variables.credential);
242
+ this.note(candidate.credential.path, "credential_withheld", describeCredential(candidate.credential.source, variables.credential));
243
+ }
244
+ if (this.slots.size > MAX_MODEL_ALIASES_PER_SLOT) {
245
+ // Unreachable by construction — there are three slots and one alias each — but the cap is
246
+ // Makine's (`packages/executors/src/configuration.ts:234`) and stating it keeps the restated
247
+ // rule complete rather than partially copied.
248
+ throw new Error("Model executor must declare 1..20 model aliases.");
249
+ }
250
+ return { ok: true };
251
+ }
252
+ build(source) {
253
+ return {
254
+ source,
255
+ shape: this.shape,
256
+ env: this.emit(),
257
+ mapping: this.mappingEntries,
258
+ consumed: this.consumedPaths,
259
+ report: this.reportEntries,
260
+ };
261
+ }
262
+ /**
263
+ * Builds the lines, in the closed list's order.
264
+ *
265
+ * A slot's credential line is always emitted, blank. For OpenAI and Anthropic that is a blank the
266
+ * user must fill: the runtime registers those slots only when the key is non-empty
267
+ * (`apps/api/src/index.ts:382`, `:398`). For the local slot blank is the finished answer — a
268
+ * local model server needs no key, and blank reads as absent (`apps/api/src/index.ts:439-442`).
269
+ */
270
+ emit() {
271
+ const values = new Map();
272
+ for (const [slot, filled] of this.slots) {
273
+ const variables = SLOT_VARIABLES[slot];
274
+ values.set(variables.credential, "");
275
+ values.set(variables.model, filled.model);
276
+ if (this.shape === "direct")
277
+ values.set(variables.aliases, filled.alias);
278
+ if (variables.baseUrl !== undefined && filled.baseUrl !== undefined) {
279
+ values.set(variables.baseUrl, filled.baseUrl);
280
+ }
281
+ }
282
+ const lines = [];
283
+ for (const name of SHAPE_VARIABLES[this.shape]) {
284
+ const value = values.get(name);
285
+ if (value === undefined)
286
+ continue;
287
+ if (!isEmittableValue(value)) {
288
+ throw new Error(`Refusing to emit ${name}: the value is not env-file safe.`);
289
+ }
290
+ lines.push({ name, value });
291
+ }
292
+ return lines;
293
+ }
294
+ }
295
+ export function translate(input, options) {
296
+ const builder = new TranslationBuilder(options.shape);
297
+ if (options.source === "litellm") {
298
+ translateLiteLlm(input, builder);
299
+ }
300
+ else {
301
+ translatePortkey(input, builder);
302
+ }
303
+ return builder.build(options.source);
304
+ }
305
+ //# sourceMappingURL=translate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translate.js","sourceRoot":"","sources":["../../src/migrate/translate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,kBAAkB,EAAyB,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,0BAA0B,EAC1B,gBAAgB,EAChB,mBAAmB,EACnB,sBA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