@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,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Portkey config JSON → Makine slots.
|
|
3
|
+
*
|
|
4
|
+
* Read from `https://portkey.ai/docs/api-reference/inference-api/config-object` on 2026-09-24.
|
|
5
|
+
*
|
|
6
|
+
* A Portkey config is one routing decision, not a set of independent deployments: `targets` is a
|
|
7
|
+
* chain the gateway walks under a `strategy`. Makine has no configurable chain, so at most ONE
|
|
8
|
+
* target can become a slot and every other target is reported whatever provider it names —
|
|
9
|
+
* translating a second would silently promote a fallback to the primary.
|
|
10
|
+
*
|
|
11
|
+
* Which one depends on the strategy. Under `fallback` and `loadbalance` the chain starts at
|
|
12
|
+
* `targets[0]`, so that is the one. Under `conditional` there is no first target: the gateway
|
|
13
|
+
* evaluates `conditions` per request and falls back to the target whose `name` is
|
|
14
|
+
* `strategy.default`. That named target is the only one a static translation can defend, and if
|
|
15
|
+
* `default` names nothing, no target is translated at all.
|
|
16
|
+
*
|
|
17
|
+
* A config with no `targets` is itself the single target, and the root object is then the
|
|
18
|
+
* deployment. The root cannot be a report path, so a rejected root is reported key by key.
|
|
19
|
+
*/
|
|
20
|
+
import type { TranslationBuilder } from "./translate.js";
|
|
21
|
+
export declare function translatePortkey(root: unknown, builder: TranslationBuilder): void;
|
|
22
|
+
//# sourceMappingURL=portkey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portkey.d.ts","sourceRoot":"","sources":["../../src/migrate/portkey.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,KAAK,EAA2B,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAiElF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,kBAAkB,GAAG,IAAI,CA8CjF"}
|
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Portkey config JSON → Makine slots.
|
|
3
|
+
*
|
|
4
|
+
* Read from `https://portkey.ai/docs/api-reference/inference-api/config-object` on 2026-09-24.
|
|
5
|
+
*
|
|
6
|
+
* A Portkey config is one routing decision, not a set of independent deployments: `targets` is a
|
|
7
|
+
* chain the gateway walks under a `strategy`. Makine has no configurable chain, so at most ONE
|
|
8
|
+
* target can become a slot and every other target is reported whatever provider it names —
|
|
9
|
+
* translating a second would silently promote a fallback to the primary.
|
|
10
|
+
*
|
|
11
|
+
* Which one depends on the strategy. Under `fallback` and `loadbalance` the chain starts at
|
|
12
|
+
* `targets[0]`, so that is the one. Under `conditional` there is no first target: the gateway
|
|
13
|
+
* evaluates `conditions` per request and falls back to the target whose `name` is
|
|
14
|
+
* `strategy.default`. That named target is the only one a static translation can defend, and if
|
|
15
|
+
* `default` names nothing, no target is translated at all.
|
|
16
|
+
*
|
|
17
|
+
* A config with no `targets` is itself the single target, and the root object is then the
|
|
18
|
+
* deployment. The root cannot be a report path, so a rejected root is reported key by key.
|
|
19
|
+
*/
|
|
20
|
+
import { readCredentialSource } from "./credentials.js";
|
|
21
|
+
import { isPlainObject, MigrateInputError, readString, UNKNOWN_KEY_REASON } from "./nodes.js";
|
|
22
|
+
const STRATEGY_REASON = "Portkey's strategy object chooses between targets — fallback, loadbalance, conditional, and " +
|
|
23
|
+
"the status codes that trigger each. Makine registers one model per slot and has no " +
|
|
24
|
+
"configurable chain or weighting, so the strategy itself has no equivalent";
|
|
25
|
+
const PORTKEY_REASONS = {
|
|
26
|
+
strategy: `${STRATEGY_REASON}.`,
|
|
27
|
+
name: "A target's name is the label Portkey's conditional query selects by. Makine registers one " +
|
|
28
|
+
"model per slot and chooses no target per request, so a target name has no equivalent " +
|
|
29
|
+
"setting; it is not the model name an application sends.",
|
|
30
|
+
retry: "Automatic retries and the status codes that trigger them are not configurable through " +
|
|
31
|
+
"Makine's environment file. The Gateway's own repair and reroute behaviour is fixed.",
|
|
32
|
+
cache: "Makine has no response cache, simple or semantic. Nothing is stored and replayed, so there " +
|
|
33
|
+
"is no setting to turn on and no age to configure.",
|
|
34
|
+
request_timeout: "Request timeouts are not configurable through the environment file; Makine's executor " +
|
|
35
|
+
"timeout is fixed at boot.",
|
|
36
|
+
weight: "Load-balancing weights have no equivalent. Makine registers one model per slot and sends " +
|
|
37
|
+
"every request for an alias to that one model.",
|
|
38
|
+
on_status_codes: "Status-code-triggered routing has no equivalent setting.",
|
|
39
|
+
forward_headers: "Makine does not forward arbitrary caller headers to a provider; the adapter builds the " +
|
|
40
|
+
"provider request itself.",
|
|
41
|
+
metadata: "Portkey request metadata has no equivalent setting.",
|
|
42
|
+
input_guardrails: "Makine checks output through acceptance contracts named on each request, not through a list " +
|
|
43
|
+
"of guardrail ids in a configuration file. Nothing here was translated, and the checks these " +
|
|
44
|
+
"ids stand for are NOT in place after migrating.",
|
|
45
|
+
output_guardrails: "Makine checks output through acceptance contracts named on each request, not through a list " +
|
|
46
|
+
"of guardrail ids in a configuration file. Nothing here was translated, and the checks these " +
|
|
47
|
+
"ids stand for are NOT in place after migrating.",
|
|
48
|
+
default_input_guardrails: "Makine has no configuration-level guardrail list.",
|
|
49
|
+
default_output_guardrails: "Makine has no configuration-level guardrail list.",
|
|
50
|
+
before_request_hooks: "Makine has no request or response hook plugins. Whatever this hook did does not happen " +
|
|
51
|
+
"after migrating.",
|
|
52
|
+
after_request_hooks: "Makine has no request or response hook plugins. Whatever this hook did does not happen " +
|
|
53
|
+
"after migrating.",
|
|
54
|
+
cache_force_refresh: "Makine has no response cache to refresh.",
|
|
55
|
+
};
|
|
56
|
+
/** Keys that describe the deployment itself rather than the config around it. */
|
|
57
|
+
const TARGET_KEYS = new Set([
|
|
58
|
+
"provider",
|
|
59
|
+
"api_key",
|
|
60
|
+
"virtual_key",
|
|
61
|
+
"custom_host",
|
|
62
|
+
"override_params",
|
|
63
|
+
"weight",
|
|
64
|
+
]);
|
|
65
|
+
const OVERRIDE_PARAM_REASON = "Makine takes request parameters from each chat request rather than pinning them in " +
|
|
66
|
+
"configuration (packages/executors/src/model-adapter.ts:243-250). Only the model can be pinned, " +
|
|
67
|
+
"and it was.";
|
|
68
|
+
export function translatePortkey(root, builder) {
|
|
69
|
+
if (!isPlainObject(root)) {
|
|
70
|
+
throw new MigrateInputError("This does not look like a Portkey config: the top level is not an object.");
|
|
71
|
+
}
|
|
72
|
+
const targets = root.targets;
|
|
73
|
+
if (targets === undefined) {
|
|
74
|
+
translateTarget(root, [], builder, { isRoot: true });
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const conditional = readConditionalDefault(root.strategy);
|
|
78
|
+
const chosen = chooseTarget(Array.isArray(targets) ? targets : undefined, conditional);
|
|
79
|
+
for (const key of Object.keys(root)) {
|
|
80
|
+
if (key === "targets")
|
|
81
|
+
continue;
|
|
82
|
+
if (key === "strategy") {
|
|
83
|
+
builder.note([key], "not_expressible", strategyReason(conditional !== undefined, chosen));
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
reportConfigKey(key, [key], builder);
|
|
87
|
+
}
|
|
88
|
+
if (!Array.isArray(targets)) {
|
|
89
|
+
builder.note(["targets"], "invalid_value", "`targets` is expected to be a list. Nothing was read from it.");
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (targets.length === 0) {
|
|
93
|
+
builder.note(["targets"], "not_expressible", "`targets` is empty; there was nothing to translate.");
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const skipped = skippedTargetReason(conditional !== undefined, chosen);
|
|
97
|
+
for (let index = 0; index < targets.length; index += 1) {
|
|
98
|
+
if (index === chosen) {
|
|
99
|
+
translateTarget(targets[index], ["targets", index], builder, { isRoot: false });
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
builder.note(["targets", index], "not_expressible", skipped);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/** `{ mode: "conditional", default: "<a target's name>" }`, or `undefined` for every other mode. */
|
|
106
|
+
function readConditionalDefault(strategy) {
|
|
107
|
+
if (!isPlainObject(strategy))
|
|
108
|
+
return undefined;
|
|
109
|
+
if (readString(strategy.mode)?.toLowerCase() !== "conditional")
|
|
110
|
+
return undefined;
|
|
111
|
+
return { wanted: readString(strategy.default) };
|
|
112
|
+
}
|
|
113
|
+
function chooseTarget(targets, conditional) {
|
|
114
|
+
if (targets === undefined || targets.length === 0)
|
|
115
|
+
return undefined;
|
|
116
|
+
if (conditional === undefined)
|
|
117
|
+
return 0;
|
|
118
|
+
if (conditional.wanted === undefined)
|
|
119
|
+
return undefined;
|
|
120
|
+
for (let index = 0; index < targets.length; index += 1) {
|
|
121
|
+
const target = targets[index];
|
|
122
|
+
if (isPlainObject(target) && readString(target.name) === conditional.wanted)
|
|
123
|
+
return index;
|
|
124
|
+
}
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
function strategyReason(conditional, chosen) {
|
|
128
|
+
if (!conditional)
|
|
129
|
+
return `${STRATEGY_REASON}, and only the first target was considered.`;
|
|
130
|
+
if (chosen !== undefined) {
|
|
131
|
+
return (`${STRATEGY_REASON}. This one is conditional: the gateway reads its conditions on every ` +
|
|
132
|
+
`request. Makine cannot choose per request, so the conditions were not translated and the ` +
|
|
133
|
+
`target named by strategy.default is the one that was considered — NOT the first target, ` +
|
|
134
|
+
`which is only one branch of the condition.`);
|
|
135
|
+
}
|
|
136
|
+
return (`${STRATEGY_REASON}. This one is conditional and strategy.default names no target in the ` +
|
|
137
|
+
`list, so no target was translated at all. Makine cannot choose per request, and picking a ` +
|
|
138
|
+
`branch of the condition would promote a route the gateway takes only for some requests.`);
|
|
139
|
+
}
|
|
140
|
+
function skippedTargetReason(conditional, chosen) {
|
|
141
|
+
if (!conditional) {
|
|
142
|
+
return ("Portkey walks its targets in order under the strategy above. Makine has no configurable " +
|
|
143
|
+
"chain and registers one model per slot, so only the first target was considered. Nothing " +
|
|
144
|
+
"from this target was translated, whatever provider it names — translating it would " +
|
|
145
|
+
"quietly promote a fallback to the primary.");
|
|
146
|
+
}
|
|
147
|
+
if (chosen !== undefined) {
|
|
148
|
+
return ("The strategy above is conditional, and this is not the target strategy.default names. " +
|
|
149
|
+
"Makine registers one model per slot and cannot pick a target per request, so nothing from " +
|
|
150
|
+
"this target was translated, whatever provider it names.");
|
|
151
|
+
}
|
|
152
|
+
return ("The strategy above is conditional and strategy.default names no target in this list, so no " +
|
|
153
|
+
"target was translated, this one included. Makine cannot choose per request, and promoting " +
|
|
154
|
+
"one branch of the condition would route every request down it.");
|
|
155
|
+
}
|
|
156
|
+
function translateTarget(node, path, builder, options) {
|
|
157
|
+
if (!isPlainObject(node)) {
|
|
158
|
+
rejectTarget(node, path, builder, options, "invalid_value", "A target is expected to be an object.");
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const analysed = analyseTarget(node, path, options);
|
|
162
|
+
if (!analysed.ok) {
|
|
163
|
+
rejectTarget(node, path, builder, options, analysed.category, analysed.reason);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const claim = builder.claimSlot(analysed.analysis.candidate);
|
|
167
|
+
if (!claim.ok) {
|
|
168
|
+
rejectTarget(node, path, builder, options, claim.category, claim.reason);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
for (const consumed of analysed.analysis.extraConsumed)
|
|
172
|
+
builder.consume(consumed);
|
|
173
|
+
for (const leftover of analysed.analysis.leftovers) {
|
|
174
|
+
builder.note(leftover.path, leftover.category, leftover.reason);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Reports a deployment that produced nothing.
|
|
179
|
+
*
|
|
180
|
+
* A nested target is one report entry on its own node, which covers the whole subtree because
|
|
181
|
+
* nothing beneath it was consumed. The root cannot be reported — a report path must be a non-root
|
|
182
|
+
* node — so a rejected root is reported one top-level key at a time instead.
|
|
183
|
+
*/
|
|
184
|
+
function rejectTarget(node, path, builder, options, category, reason) {
|
|
185
|
+
if (!options.isRoot) {
|
|
186
|
+
builder.note(path, category, reason);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (!isPlainObject(node))
|
|
190
|
+
return;
|
|
191
|
+
for (const key of Object.keys(node)) {
|
|
192
|
+
if (!TARGET_KEYS.has(key)) {
|
|
193
|
+
reportConfigKey(key, [key], builder);
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
if (key === "api_key" || key === "virtual_key") {
|
|
197
|
+
builder.note([key], "credential_withheld", "A credential was present here and was not copied. Nothing was translated from this " +
|
|
198
|
+
"deployment in any case, so no Makine variable needs it.");
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
builder.note([key], category, reason);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
function analyseTarget(node, path, options) {
|
|
205
|
+
const leftovers = [];
|
|
206
|
+
// Portkey nests config objects to any depth, so a "target" is often another whole strategy. It
|
|
207
|
+
// names no provider, and reporting it as `unsupported_provider` would tell the reader to add
|
|
208
|
+
// one — the wrong repair for a construct Makine cannot express at any depth. The root is
|
|
209
|
+
// excluded: a root with `targets` never reaches here, and a root carrying only a `strategy` is a
|
|
210
|
+
// config whose strategy has nothing to choose between.
|
|
211
|
+
if (!options.isRoot && (node.strategy !== undefined || node.targets !== undefined)) {
|
|
212
|
+
return {
|
|
213
|
+
ok: false,
|
|
214
|
+
category: "not_expressible",
|
|
215
|
+
reason: "This target is itself a nested strategy: it carries its own `strategy` or `targets` " +
|
|
216
|
+
"instead of naming one provider. Makine registers one model per slot and has no " +
|
|
217
|
+
"configurable chain at any depth, so nothing was translated from this target or from " +
|
|
218
|
+
"anything inside it.",
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
if (node.virtual_key !== undefined) {
|
|
222
|
+
return {
|
|
223
|
+
ok: false,
|
|
224
|
+
category: "unsupported_provider",
|
|
225
|
+
reason: "This target routes through a Portkey virtual key, which names a provider and a " +
|
|
226
|
+
"credential held inside Portkey. Makine cannot resolve one: it reads provider keys from " +
|
|
227
|
+
"its own environment. Replace it with the provider name and supply the key yourself.",
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
const provider = readString(node.provider);
|
|
231
|
+
if (provider === undefined) {
|
|
232
|
+
return {
|
|
233
|
+
ok: false,
|
|
234
|
+
category: "unsupported_provider",
|
|
235
|
+
reason: "This target names no provider, so there is no slot to put it in.",
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
if (provider.startsWith("@")) {
|
|
239
|
+
return {
|
|
240
|
+
ok: false,
|
|
241
|
+
category: "unsupported_provider",
|
|
242
|
+
reason: `"${provider}" is a Portkey workspace provider slug: the real provider and its key live ` +
|
|
243
|
+
`inside Portkey. Makine cannot resolve one. Name the provider directly and supply the ` +
|
|
244
|
+
`key yourself.`,
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
const customHost = readString(node.custom_host);
|
|
248
|
+
const routed = routeProvider(provider, customHost);
|
|
249
|
+
if (!routed.ok)
|
|
250
|
+
return routed;
|
|
251
|
+
const overrideParams = node.override_params;
|
|
252
|
+
const overridePath = [...path, "override_params"];
|
|
253
|
+
if (!isPlainObject(overrideParams)) {
|
|
254
|
+
return {
|
|
255
|
+
ok: false,
|
|
256
|
+
category: "invalid_value",
|
|
257
|
+
reason: "The target pins no model: Makine registers one named model per slot and cannot pass " +
|
|
258
|
+
"through whatever model the application happens to send. Pin one with " +
|
|
259
|
+
'override_params: { "model": "..." }.',
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
const model = readString(overrideParams.model);
|
|
263
|
+
if (model === undefined) {
|
|
264
|
+
return {
|
|
265
|
+
ok: false,
|
|
266
|
+
category: "invalid_value",
|
|
267
|
+
reason: "`override_params.model` is missing or empty. Makine registers one named model per slot " +
|
|
268
|
+
"and needs it stated.",
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
const candidate = {
|
|
272
|
+
slot: routed.slot,
|
|
273
|
+
// Portkey has no separate public name for a deployment: the pinned model is what an
|
|
274
|
+
// application already sends, so it becomes both the Makine model and its alias.
|
|
275
|
+
alias: { value: model, path: [...overridePath, "model"] },
|
|
276
|
+
model: { value: model, path: [...overridePath, "model"] },
|
|
277
|
+
};
|
|
278
|
+
const consumedKeys = new Set(["provider", "override_params"]);
|
|
279
|
+
if (routed.slot === "local" && customHost !== undefined) {
|
|
280
|
+
candidate.baseUrl = { value: customHost, path: [...path, "custom_host"] };
|
|
281
|
+
consumedKeys.add("custom_host");
|
|
282
|
+
}
|
|
283
|
+
if (node.api_key !== undefined) {
|
|
284
|
+
candidate.credential = { path: [...path, "api_key"], source: readCredentialSource(node.api_key) };
|
|
285
|
+
consumedKeys.add("api_key");
|
|
286
|
+
}
|
|
287
|
+
for (const key of Object.keys(overrideParams)) {
|
|
288
|
+
if (key === "model")
|
|
289
|
+
continue;
|
|
290
|
+
leftovers.push({
|
|
291
|
+
path: [...overridePath, key],
|
|
292
|
+
category: "not_expressible",
|
|
293
|
+
reason: OVERRIDE_PARAM_REASON,
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
for (const key of Object.keys(node)) {
|
|
297
|
+
if (consumedKeys.has(key))
|
|
298
|
+
continue;
|
|
299
|
+
if (key === "custom_host") {
|
|
300
|
+
leftovers.push({
|
|
301
|
+
path: [...path, key],
|
|
302
|
+
category: "not_expressible",
|
|
303
|
+
reason: "Makine's OpenAI and Anthropic slots always call the vendor's own endpoint " +
|
|
304
|
+
"(apps/api/src/index.ts:389, :405); there is no variable that re-points them.",
|
|
305
|
+
});
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
if (!options.isRoot && TARGET_KEYS.has(key)) {
|
|
309
|
+
// `Object.hasOwn`, not a plain lookup: the key comes from somebody else's file, so
|
|
310
|
+
// `constructor`, `toString` and `valueOf` are all reachable key names, and a plain lookup
|
|
311
|
+
// hands back `Object.prototype`'s function as the reason.
|
|
312
|
+
const reason = Object.hasOwn(PORTKEY_REASONS, key) ? PORTKEY_REASONS[key] : undefined;
|
|
313
|
+
leftovers.push({
|
|
314
|
+
path: [...path, key],
|
|
315
|
+
category: "not_expressible",
|
|
316
|
+
reason: reason ?? "A Portkey target setting with no Makine equivalent.",
|
|
317
|
+
});
|
|
318
|
+
continue;
|
|
319
|
+
}
|
|
320
|
+
leftovers.push(configKeyEntry(key, [...path, key]));
|
|
321
|
+
}
|
|
322
|
+
// `provider` chose the slot — which set of variable NAMES is emitted — rather than supplying one
|
|
323
|
+
// variable's value, so it is consumed with no mapping row.
|
|
324
|
+
return { ok: true, analysis: { candidate, extraConsumed: [[...path, "provider"]], leftovers } };
|
|
325
|
+
}
|
|
326
|
+
function routeProvider(provider, customHost) {
|
|
327
|
+
const vendor = provider.trim().toLowerCase();
|
|
328
|
+
if (customHost !== undefined) {
|
|
329
|
+
const host = hostOf(customHost);
|
|
330
|
+
if (vendor === "openai" && host === "api.openai.com")
|
|
331
|
+
return { ok: true, slot: "openai" };
|
|
332
|
+
if (vendor === "anthropic" && host === "api.anthropic.com")
|
|
333
|
+
return { ok: true, slot: "anthropic" };
|
|
334
|
+
// Everything else with a custom host is somebody's own OpenAI-compatible server. The base-URL
|
|
335
|
+
// rule then decides whether it is reachable at all; a vendor host that does not match the
|
|
336
|
+
// declared provider fails it, which is the outcome we want — the local variables also
|
|
337
|
+
// configure document extraction, which has no egress check.
|
|
338
|
+
return { ok: true, slot: "local" };
|
|
339
|
+
}
|
|
340
|
+
if (vendor === "openai")
|
|
341
|
+
return { ok: true, slot: "openai" };
|
|
342
|
+
if (vendor === "anthropic")
|
|
343
|
+
return { ok: true, slot: "anthropic" };
|
|
344
|
+
return {
|
|
345
|
+
ok: false,
|
|
346
|
+
category: "unsupported_provider",
|
|
347
|
+
reason: `Makine has no chat slot for "${provider}". A deployment reaches Makine's Gateway through ` +
|
|
348
|
+
`one of three slots only: OpenAI, Anthropic, and one OpenAI-compatible endpoint you run ` +
|
|
349
|
+
`yourself (apps/api/src/index.ts:365-449). If this provider serves an OpenAI-compatible API ` +
|
|
350
|
+
`on a host you control, give it a custom_host and it becomes the local slot.`,
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
function hostOf(value) {
|
|
354
|
+
try {
|
|
355
|
+
return new URL(value).hostname.toLowerCase();
|
|
356
|
+
}
|
|
357
|
+
catch {
|
|
358
|
+
return undefined;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
function reportConfigKey(key, path, builder) {
|
|
362
|
+
const entry = configKeyEntry(key, path);
|
|
363
|
+
builder.note(entry.path, entry.category, entry.reason);
|
|
364
|
+
}
|
|
365
|
+
function configKeyEntry(key, path) {
|
|
366
|
+
const reason = Object.hasOwn(PORTKEY_REASONS, key) ? PORTKEY_REASONS[key] : undefined;
|
|
367
|
+
if (reason !== undefined)
|
|
368
|
+
return { path, category: "not_expressible", reason };
|
|
369
|
+
return { path, category: "unknown_key", reason: UNKNOWN_KEY_REASON };
|
|
370
|
+
}
|
|
371
|
+
//# sourceMappingURL=portkey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portkey.js","sourceRoot":"","sources":["../../src/migrate/portkey.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAI9F,MAAM,eAAe,GACnB,8FAA8F;IAC9F,qFAAqF;IACrF,2EAA2E,CAAC;AAE9E,MAAM,eAAe,GAAqC;IACxD,QAAQ,EAAE,GAAG,eAAe,GAAG;IAC/B,IAAI,EACF,4FAA4F;QAC5F,uFAAuF;QACvF,yDAAyD;IAC3D,KAAK,EACH,wFAAwF;QACxF,qFAAqF;IACvF,KAAK,EACH,6FA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output forms.
|
|
3
|
+
*
|
|
4
|
+
* The default form is a valid env-file fragment: settings first, then the whole report as `#`
|
|
5
|
+
* comment lines. Redirecting stdout to a file therefore captures something `docker compose
|
|
6
|
+
* --env-file` can read, with the reasons it could not translate everything sitting in the same
|
|
7
|
+
* file as the settings — which is the point. A report that lives somewhere else is a report nobody
|
|
8
|
+
* re-reads when the migrated deployment behaves oddly six weeks later.
|
|
9
|
+
*/
|
|
10
|
+
import type { TranslationResult } from "./types.js";
|
|
11
|
+
export declare function renderEnvFile(result: TranslationResult): string;
|
|
12
|
+
export declare function renderReport(result: TranslationResult): readonly string[];
|
|
13
|
+
/**
|
|
14
|
+
* Every path leaves through `withholdPath`, including `mapping` and `consumed`.
|
|
15
|
+
*
|
|
16
|
+
* Those two carry only key names the translator recognised, so withholding changes nothing they
|
|
17
|
+
* print today. Applying it at the one boundary anyway makes the rule a property of the OUTPUT —
|
|
18
|
+
* no path this tool prints contains a credential-shaped key — rather than a property of which
|
|
19
|
+
* lists the translator happens to fill.
|
|
20
|
+
*/
|
|
21
|
+
export declare function renderJson(result: TranslationResult): string;
|
|
22
|
+
//# sourceMappingURL=render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/migrate/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAmC,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAkCrF,wBAAgB,aAAa,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CAsB/D;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,iBAAiB,GAAG,SAAS,MAAM,EAAE,CA0BzE;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CAa5D"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turns a `TranslationResult` into the two output forms.
|
|
3
|
+
*
|
|
4
|
+
* The default form is a valid env-file fragment: settings first, then the whole report as `#`
|
|
5
|
+
* comment lines. Redirecting stdout to a file therefore captures something `docker compose
|
|
6
|
+
* --env-file` can read, with the reasons it could not translate everything sitting in the same
|
|
7
|
+
* file as the settings — which is the point. A report that lives somewhere else is a report nobody
|
|
8
|
+
* re-reads when the migrated deployment behaves oddly six weeks later.
|
|
9
|
+
*/
|
|
10
|
+
import { formatPath, withholdPath } from "./paths.js";
|
|
11
|
+
const SHAPE_HEADERS = {
|
|
12
|
+
onprem: "shape: onprem — started with `docker compose --env-file makine.env -f " +
|
|
13
|
+
"docker-compose.onprem.yml up`.",
|
|
14
|
+
direct: "shape: direct — the API process started with these variables in its environment.",
|
|
15
|
+
};
|
|
16
|
+
const CATEGORY_HEADINGS = {
|
|
17
|
+
unsupported_provider: "NOT TRANSLATED — no Makine slot for this provider",
|
|
18
|
+
not_expressible: "NOT TRANSLATED — Makine has no setting that means this",
|
|
19
|
+
shape_limit: "NOT TRANSLATED IN THIS SHAPE",
|
|
20
|
+
egress_refused: "NOT TRANSLATED — Makine would refuse this endpoint",
|
|
21
|
+
credential_withheld: "CREDENTIAL WITHHELD — fill this in yourself",
|
|
22
|
+
rewritten: "TRANSLATED, BUT CHANGED",
|
|
23
|
+
invalid_value: "NOT TRANSLATED — the value cannot be carried",
|
|
24
|
+
unknown_key: "NOT EXAMINED — this tool does not know this key",
|
|
25
|
+
};
|
|
26
|
+
/** Report order: the things that change behaviour first, the merely-absent last. */
|
|
27
|
+
const CATEGORY_ORDER = [
|
|
28
|
+
"credential_withheld",
|
|
29
|
+
"rewritten",
|
|
30
|
+
"shape_limit",
|
|
31
|
+
"egress_refused",
|
|
32
|
+
"invalid_value",
|
|
33
|
+
"unsupported_provider",
|
|
34
|
+
"not_expressible",
|
|
35
|
+
"unknown_key",
|
|
36
|
+
];
|
|
37
|
+
const WIDTH = 96;
|
|
38
|
+
export function renderEnvFile(result) {
|
|
39
|
+
const lines = [];
|
|
40
|
+
lines.push(`# ${SHAPE_HEADERS[result.shape] ?? `shape: ${result.shape}`}`);
|
|
41
|
+
lines.push(`# Translated from a ${sourceName(result.source)} config by \`makine migrate\`.`);
|
|
42
|
+
lines.push("#");
|
|
43
|
+
if (result.env.length === 0) {
|
|
44
|
+
lines.push("# NOTHING WAS TRANSLATED. No setting in this shape can express this config.");
|
|
45
|
+
lines.push("# Every construct is listed below with the reason.");
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
// The claim covers credential FIELDS only, with the exception stated beside it: an accepted
|
|
49
|
+
// endpoint IS emitted with its URL path, and a model server can authenticate by a path segment,
|
|
50
|
+
// so a blanket "no credential is copied" would be false of the line directly below it.
|
|
51
|
+
lines.push("# Settings. A blank key is a blank you fill in: no credential FIELD is copied.");
|
|
52
|
+
lines.push("# An endpoint is copied whole, path included, because the path is the endpoint.");
|
|
53
|
+
lines.push("#");
|
|
54
|
+
for (const line of result.env)
|
|
55
|
+
lines.push(`${line.name}=${line.value}`);
|
|
56
|
+
}
|
|
57
|
+
lines.push("");
|
|
58
|
+
lines.push(...renderReport(result));
|
|
59
|
+
return `${lines.join("\n")}\n`;
|
|
60
|
+
}
|
|
61
|
+
export function renderReport(result) {
|
|
62
|
+
const lines = [];
|
|
63
|
+
const total = result.report.length;
|
|
64
|
+
lines.push(`# ------------------------------------------------------------------------------------`);
|
|
65
|
+
lines.push(`# GAP REPORT — ${String(total)} ${total === 1 ? "construct" : "constructs"} from the input, ` +
|
|
66
|
+
`each named with the reason.`);
|
|
67
|
+
lines.push("# Nothing in the input is silently dropped: every value is either a setting above or an " +
|
|
68
|
+
"entry here.");
|
|
69
|
+
for (const category of CATEGORY_ORDER) {
|
|
70
|
+
const entries = result.report.filter((entry) => entry.category === category);
|
|
71
|
+
if (entries.length === 0)
|
|
72
|
+
continue;
|
|
73
|
+
lines.push("#");
|
|
74
|
+
lines.push(`# ${CATEGORY_HEADINGS[category]} (${String(entries.length)})`);
|
|
75
|
+
for (const entry of entries) {
|
|
76
|
+
lines.push(`# ${formatPath(entry.path)}`);
|
|
77
|
+
for (const wrapped of wrap(entry.reason, WIDTH - 8))
|
|
78
|
+
lines.push(`# ${wrapped}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return lines;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Every path leaves through `withholdPath`, including `mapping` and `consumed`.
|
|
85
|
+
*
|
|
86
|
+
* Those two carry only key names the translator recognised, so withholding changes nothing they
|
|
87
|
+
* print today. Applying it at the one boundary anyway makes the rule a property of the OUTPUT —
|
|
88
|
+
* no path this tool prints contains a credential-shaped key — rather than a property of which
|
|
89
|
+
* lists the translator happens to fill.
|
|
90
|
+
*/
|
|
91
|
+
export function renderJson(result) {
|
|
92
|
+
return JSON.stringify({
|
|
93
|
+
source: result.source,
|
|
94
|
+
shape: result.shape,
|
|
95
|
+
env: result.env,
|
|
96
|
+
mapping: result.mapping.map((entry) => ({ ...entry, path: withholdPath(entry.path) })),
|
|
97
|
+
consumed: result.consumed.map(withholdPath),
|
|
98
|
+
report: result.report.map((entry) => ({ ...entry, path: withholdPath(entry.path) })),
|
|
99
|
+
}, null, 2);
|
|
100
|
+
}
|
|
101
|
+
function sourceName(source) {
|
|
102
|
+
return source === "litellm" ? "LiteLLM proxy" : "Portkey";
|
|
103
|
+
}
|
|
104
|
+
function wrap(text, width) {
|
|
105
|
+
const words = text.split(/\s+/).filter((word) => word.length > 0);
|
|
106
|
+
const lines = [];
|
|
107
|
+
let current = "";
|
|
108
|
+
for (const word of words) {
|
|
109
|
+
if (current.length === 0) {
|
|
110
|
+
current = word;
|
|
111
|
+
}
|
|
112
|
+
else if (current.length + 1 + word.length <= width) {
|
|
113
|
+
current = `${current} ${word}`;
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
lines.push(current);
|
|
117
|
+
current = word;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (current.length > 0)
|
|
121
|
+
lines.push(current);
|
|
122
|
+
return lines.length === 0 ? [""] : lines;
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../src/migrate/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAGtD,MAAM,aAAa,GAAqC;IACtD,MAAM,EACJ,wEAAwE;QACxE,gCAAgC;IAClC,MAAM,EAAE,kFAAkF;CAC3F,CAAC;AAEF,MAAM,iBAAiB,GAA6C;IAClE,oBAAoB,EAAE,mDAAmD;IACzE,eAAe,EAAE,wDAAwD;IACzE,WAAW,EAAE,8BAA8B;IAC3C,cAAc,EAAE,oDAAoD;IACpE,mBAAmB,EAAE,6CAA6C;IAClE,SAAS,EAAE,yBAAyB;IACpC,aAAa,EAAE,8CAA8C;IAC7D,WAAW,EAAE,iDAAiD;CAC/D,CAAC;AAEF,oFAAoF;AACpF,MAAM,cAAc,GAA8B;IAChD,qBAAqB;IACrB,WAAW;IACX,aAAa;IACb,gBAAgB;IAChB,eAAe;IACf,sBAAsB;IACtB,iBAAiB;IACjB,aAAa;CACd,CAAC;AAEF,MAAM,KAAK,GAAG,EAAE,CAAC;AAEjB,MAAM,UAAU,aAAa,CAAC,MAAyB;IACrD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,CAAC,IAAI,CAAC,KAAK,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,UAAU,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC3E,KAAK,CAAC,IAAI,CAAC,uBAAuB,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,gCAAgC,CAAC,CAAC;IAC7F,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEhB,IAAI,MAAM,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,KAAK,CA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F,EACD,IAAI,EACJ,CAAC,CACF,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,MAAuB;IACzC,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS,CAAC;AAC5D,CAAC;AAED,SAAS,IAAI,CAAC,IAAY,EAAE,KAAa;IACvC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAClE,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,OAAO,GAAG,EAAE,CAAC;IACjB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,GAAG,IAAI,CAAC;QACjB,CAAC;aAAM,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,IAAI,KAAK,EAAE,CAAC;YACrD,OAAO,GAAG,GAAG,OAAO,IAAI,IAAI,EAAE,CAAC;QACjC,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACpB,OAAO,GAAG,IAAI,CAAC;QACjB,CAAC;IACH,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC5C,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
import type { MigrationShape, ReportCategory } from "./types.js";
|
|
19
|
+
/** `packages/executors/src/configuration.ts:234`. */
|
|
20
|
+
export declare const MAX_MODEL_ALIASES_PER_SLOT = 20;
|
|
21
|
+
/** `packages/executors/src/configuration.ts:248`, the model-id length the runtime accepts. */
|
|
22
|
+
export declare const MAX_MODEL_LENGTH = 256;
|
|
23
|
+
export declare function isValidModelAlias(alias: string): boolean;
|
|
24
|
+
/** `packages/policy-core/src/model-alias.ts:36-38`. Two slots claiming one normalized alias boot
|
|
25
|
+
* fine and then fail every request for it as `ambiguous_alias`. */
|
|
26
|
+
export declare function normalizeModelAlias(alias: string): string;
|
|
27
|
+
export declare function isEmittableValue(value: string): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* `packages/providers/src/capability-registry.ts:152-178`, restated.
|
|
30
|
+
*
|
|
31
|
+
* Does not resolve names, for the same reason the original does not: `*.local` and
|
|
32
|
+
* `host.docker.internal` are trusted for what they mean, not for where they point. `169.254/16` is
|
|
33
|
+
* NOT private here — it is the cloud instance-metadata range.
|
|
34
|
+
*/
|
|
35
|
+
export declare function isPrivateEndpointUrl(url: URL): boolean;
|
|
36
|
+
/** `packages/providers/src/chat.ts:40-46`. The two hosts the 2026-08-23 egress sign-off names. */
|
|
37
|
+
export declare const SIGNED_CHAT_EGRESS_HOSTS: readonly string[];
|
|
38
|
+
export type LocalBaseUrlResult = {
|
|
39
|
+
ok: true;
|
|
40
|
+
value: string;
|
|
41
|
+
rewritten: boolean;
|
|
42
|
+
rewriteReason?: string;
|
|
43
|
+
} | {
|
|
44
|
+
ok: false;
|
|
45
|
+
category: ReportCategory;
|
|
46
|
+
reason: string;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Turns an upstream endpoint into a `MAKINE_LOCAL_PROVIDER_BASE_URL`, or says why it cannot.
|
|
50
|
+
*
|
|
51
|
+
* Checks run in the task's category precedence: `egress_refused` before `invalid_value`, because a
|
|
52
|
+
* host the guard will not admit is the more fundamental fact about the endpoint.
|
|
53
|
+
*/
|
|
54
|
+
export declare function toLocalProviderBaseUrl(raw: string, shape: MigrationShape): LocalBaseUrlResult;
|
|
55
|
+
//# sourceMappingURL=runtime-rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-rules.d.ts","sourceRoot":"","sources":["../../src/migrate/runtime-rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAKjE,qDAAqD;AACrD,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAE7C,8FAA8F;AAC9F,eAAO,MAAM,gBAAgB,MAAM,CAAC;AAEpC,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAExD;AAED;mEACmE;AACnE,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEzD;AAYD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAqBtD;AAiBD,kGAAkG;AAClG,eAAO,MAAM,wBAAwB,EAAE,SAAS,MAAM,EAA4C,CAAC;AAEnG,MAAM,MAAM,kBAAkB,GAC1B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,OAAO,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,GACvE;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,EAAE,cAAc,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5D;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,GAAG,kBAAkB,CAqG7F"}
|