@agentproto/catalog-sync 0.7.4 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.mjs +77 -23
- package/dist/bin.mjs.map +1 -1
- package/dist/generators/llm-opencode.mjs.map +1 -1
- package/dist/generators/llm-openrouter.mjs +64 -10
- package/dist/generators/llm-openrouter.mjs.map +1 -1
- package/dist/index.mjs +79 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/snapshots/image-replicate.json +85 -85
- package/snapshots/llm-anthropic.json +256 -15
- package/snapshots/llm-huggingface.json +2034 -2079
- package/snapshots/llm-moonshot.json +6 -6
- package/snapshots/llm-opencode-go.json +15 -0
- package/snapshots/llm-opencode-zen.json +35 -0
- package/snapshots/llm-openrouter.json +2468 -2141
- package/snapshots/voice-elevenlabs.json +6051 -5837
package/dist/bin.mjs
CHANGED
|
@@ -58,6 +58,54 @@ function isoDateFromUnixSeconds(seconds) {
|
|
|
58
58
|
return new Date(seconds * 1e3).toISOString().slice(0, 10);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
// src/sources/openrouter-prompt-tiers.mjs
|
|
62
|
+
function round6(n) {
|
|
63
|
+
return Math.round(n * 1e6) / 1e6;
|
|
64
|
+
}
|
|
65
|
+
function per1m(tokenPrice) {
|
|
66
|
+
if (tokenPrice === void 0 || tokenPrice === null) return void 0;
|
|
67
|
+
const n = Number(tokenPrice);
|
|
68
|
+
return Number.isFinite(n) ? round6(n * 1e6) : void 0;
|
|
69
|
+
}
|
|
70
|
+
function promptLengthTiers(pricing) {
|
|
71
|
+
const overrides = pricing?.overrides;
|
|
72
|
+
if (!Array.isArray(overrides)) return void 0;
|
|
73
|
+
const byThreshold = /* @__PURE__ */ new Map();
|
|
74
|
+
for (const o of overrides) {
|
|
75
|
+
if (!o || typeof o !== "object") continue;
|
|
76
|
+
if (typeof o.min_prompt_tokens !== "number" || !(o.min_prompt_tokens > 0)) continue;
|
|
77
|
+
if (Object.keys(o).some((k) => k.startsWith("utc_"))) continue;
|
|
78
|
+
const inputPer1M = per1m(o.prompt);
|
|
79
|
+
const outputPer1M = per1m(o.completion);
|
|
80
|
+
if (inputPer1M === void 0 || outputPer1M === void 0) continue;
|
|
81
|
+
const tier = { aboveInputTokens: o.min_prompt_tokens, inputPer1M, outputPer1M };
|
|
82
|
+
const cacheRead = per1m(o.input_cache_read);
|
|
83
|
+
const cacheWrite = per1m(o.input_cache_write);
|
|
84
|
+
if (cacheRead !== void 0 && cacheRead > 0 && inputPer1M > 0) {
|
|
85
|
+
tier.cacheReadMultiplier = round6(cacheRead / inputPer1M);
|
|
86
|
+
}
|
|
87
|
+
if (cacheWrite !== void 0 && cacheWrite > 0 && inputPer1M > 0) {
|
|
88
|
+
tier.cacheWriteMultiplier = round6(cacheWrite / inputPer1M);
|
|
89
|
+
}
|
|
90
|
+
byThreshold.set(tier.aboveInputTokens, tier);
|
|
91
|
+
}
|
|
92
|
+
if (byThreshold.size === 0) return void 0;
|
|
93
|
+
return [...byThreshold.values()].sort((a, b) => a.aboveInputTokens - b.aboveInputTokens);
|
|
94
|
+
}
|
|
95
|
+
function serializeTiers(tiers) {
|
|
96
|
+
const items = tiers.map((t) => {
|
|
97
|
+
const fields = [
|
|
98
|
+
`aboveInputTokens: ${t.aboveInputTokens}`,
|
|
99
|
+
`inputPer1M: ${t.inputPer1M}`,
|
|
100
|
+
`outputPer1M: ${t.outputPer1M}`
|
|
101
|
+
];
|
|
102
|
+
if (t.cacheReadMultiplier !== void 0) fields.push(`cacheReadMultiplier: ${t.cacheReadMultiplier}`);
|
|
103
|
+
if (t.cacheWriteMultiplier !== void 0) fields.push(`cacheWriteMultiplier: ${t.cacheWriteMultiplier}`);
|
|
104
|
+
return `{ ${fields.join(", ")} }`;
|
|
105
|
+
});
|
|
106
|
+
return `tiers: [${items.join(", ")}]`;
|
|
107
|
+
}
|
|
108
|
+
|
|
61
109
|
// src/generators/llm-openrouter.ts
|
|
62
110
|
var OPENROUTER_MODELS_URL = "https://openrouter.ai/api/v1/models";
|
|
63
111
|
var OUTPUT_PATH = "packages/model-catalog/src/llm/openrouter-routes.generated.ts";
|
|
@@ -75,18 +123,18 @@ var ModelSchema = z.object({
|
|
|
75
123
|
var SnapshotSchema = z.object({
|
|
76
124
|
data: z.array(ModelSchema)
|
|
77
125
|
});
|
|
78
|
-
function
|
|
126
|
+
function round62(n) {
|
|
79
127
|
return Math.round(n * 1e6) / 1e6;
|
|
80
128
|
}
|
|
81
|
-
function
|
|
129
|
+
function per1m2(tokenPrice) {
|
|
82
130
|
if (tokenPrice === void 0) return void 0;
|
|
83
131
|
const n = Number(tokenPrice);
|
|
84
132
|
if (!Number.isFinite(n)) return void 0;
|
|
85
|
-
return
|
|
133
|
+
return round62(n * 1e6);
|
|
86
134
|
}
|
|
87
135
|
function fmt(n) {
|
|
88
136
|
if (!Number.isFinite(n)) return "0";
|
|
89
|
-
return `${
|
|
137
|
+
return `${round62(n)}`;
|
|
90
138
|
}
|
|
91
139
|
function vendorOf(id) {
|
|
92
140
|
if (!id.includes("/")) return id;
|
|
@@ -103,6 +151,9 @@ function serializeEntry(e) {
|
|
|
103
151
|
if (e.cacheWriteMultiplier !== void 0) {
|
|
104
152
|
fields.push(`cacheWriteMultiplier: ${fmt(e.cacheWriteMultiplier)}`);
|
|
105
153
|
}
|
|
154
|
+
if (e.tiers !== void 0) {
|
|
155
|
+
fields.push(serializeTiers(e.tiers));
|
|
156
|
+
}
|
|
106
157
|
if (e.addedAt !== void 0) {
|
|
107
158
|
fields.push(`addedAt: ${JSON.stringify(e.addedAt)}`);
|
|
108
159
|
}
|
|
@@ -122,6 +173,7 @@ function serializeFile(entries) {
|
|
|
122
173
|
"// Pricing carries provider USD (inputPer1M / outputPer1M) plus cache",
|
|
123
174
|
"// multipliers (cacheReadMultiplier / cacheWriteMultiplier) derived from the",
|
|
124
175
|
"// source's input_cache_read / input_cache_write per-token fields when present.",
|
|
176
|
+
"// tiers are the source's prompt-length price overrides (min_prompt_tokens).",
|
|
125
177
|
"// addedAt is the ISO date this id was first seen by a sync run \u2014 backfilled",
|
|
126
178
|
"// from the source's own `created` timestamp, then NEVER mutated; see",
|
|
127
179
|
"// packages/catalog-sync/src/added-at.ts and the package README.",
|
|
@@ -154,8 +206,8 @@ async function generate(ctx) {
|
|
|
154
206
|
for (const model of parsed.data) {
|
|
155
207
|
const pricing = model.pricing;
|
|
156
208
|
if (!pricing) continue;
|
|
157
|
-
const inputPer1M =
|
|
158
|
-
const outputPer1M =
|
|
209
|
+
const inputPer1M = per1m2(pricing.prompt);
|
|
210
|
+
const outputPer1M = per1m2(pricing.completion);
|
|
159
211
|
if (inputPer1M === void 0 || outputPer1M === void 0) continue;
|
|
160
212
|
if (inputPer1M === 0 && outputPer1M === 0) continue;
|
|
161
213
|
const entry = {
|
|
@@ -164,14 +216,16 @@ async function generate(ctx) {
|
|
|
164
216
|
vendor: vendorOf(model.id),
|
|
165
217
|
provider: "openrouter"
|
|
166
218
|
};
|
|
167
|
-
const cacheReadPer1M =
|
|
168
|
-
const cacheWritePer1M =
|
|
219
|
+
const cacheReadPer1M = per1m2(pricing.input_cache_read);
|
|
220
|
+
const cacheWritePer1M = per1m2(pricing.input_cache_write);
|
|
169
221
|
if (cacheReadPer1M !== void 0 && cacheReadPer1M > 0 && inputPer1M > 0) {
|
|
170
|
-
entry.cacheReadMultiplier =
|
|
222
|
+
entry.cacheReadMultiplier = round62(cacheReadPer1M / inputPer1M);
|
|
171
223
|
}
|
|
172
224
|
if (cacheWritePer1M !== void 0 && cacheWritePer1M > 0 && inputPer1M > 0) {
|
|
173
|
-
entry.cacheWriteMultiplier =
|
|
225
|
+
entry.cacheWriteMultiplier = round62(cacheWritePer1M / inputPer1M);
|
|
174
226
|
}
|
|
227
|
+
const tiers = promptLengthTiers(pricing);
|
|
228
|
+
if (tiers) entry.tiers = tiers;
|
|
175
229
|
entries[model.id] = entry;
|
|
176
230
|
if (model.created !== void 0) createdAt[model.id] = isoDateFromUnixSeconds(model.created);
|
|
177
231
|
}
|
|
@@ -207,17 +261,17 @@ var ModelSchema2 = z.object({
|
|
|
207
261
|
var SnapshotSchema2 = z.object({
|
|
208
262
|
data: z.array(ModelSchema2)
|
|
209
263
|
});
|
|
210
|
-
function
|
|
264
|
+
function round63(n) {
|
|
211
265
|
return Math.round(n * 1e6) / 1e6;
|
|
212
266
|
}
|
|
213
|
-
function
|
|
267
|
+
function per1m3(tokenPrice) {
|
|
214
268
|
if (tokenPrice === void 0) return void 0;
|
|
215
269
|
if (!Number.isFinite(tokenPrice)) return void 0;
|
|
216
|
-
return
|
|
270
|
+
return round63(tokenPrice * 1e6);
|
|
217
271
|
}
|
|
218
272
|
function fmt2(n) {
|
|
219
273
|
if (!Number.isFinite(n)) return "0";
|
|
220
|
-
return `${
|
|
274
|
+
return `${round63(n)}`;
|
|
221
275
|
}
|
|
222
276
|
function vendorOf2(id) {
|
|
223
277
|
if (!id.includes("/")) return id;
|
|
@@ -281,8 +335,8 @@ async function generate2(ctx) {
|
|
|
281
335
|
const entries = {};
|
|
282
336
|
const createdAt = {};
|
|
283
337
|
for (const model of parsed.data) {
|
|
284
|
-
const inputPer1M =
|
|
285
|
-
const outputPer1M =
|
|
338
|
+
const inputPer1M = per1m3(model.input_price);
|
|
339
|
+
const outputPer1M = per1m3(model.output_price);
|
|
286
340
|
if (inputPer1M === void 0 || outputPer1M === void 0) continue;
|
|
287
341
|
if (inputPer1M === 0 && outputPer1M === 0) continue;
|
|
288
342
|
const entry = {
|
|
@@ -292,9 +346,9 @@ async function generate2(ctx) {
|
|
|
292
346
|
provider: "requesty"
|
|
293
347
|
};
|
|
294
348
|
if (model.supports_caching === true && inputPer1M > 0) {
|
|
295
|
-
const cachePer1M =
|
|
349
|
+
const cachePer1M = per1m3(model.cached_price);
|
|
296
350
|
if (cachePer1M !== void 0) {
|
|
297
|
-
entry.cacheReadMultiplier =
|
|
351
|
+
entry.cacheReadMultiplier = round63(cachePer1M / inputPer1M);
|
|
298
352
|
}
|
|
299
353
|
}
|
|
300
354
|
entries[model.id] = entry;
|
|
@@ -358,17 +412,17 @@ var ProviderSchema = z.object({
|
|
|
358
412
|
models: z.record(z.string(), ModelSchema3).optional()
|
|
359
413
|
}).passthrough();
|
|
360
414
|
var SnapshotSchema3 = z.record(z.string(), ProviderSchema);
|
|
361
|
-
function
|
|
415
|
+
function round64(n) {
|
|
362
416
|
return Math.round(n * 1e6) / 1e6;
|
|
363
417
|
}
|
|
364
418
|
function fmt3(n) {
|
|
365
419
|
if (!Number.isFinite(n)) return "0";
|
|
366
|
-
return `${
|
|
420
|
+
return `${round64(n)}`;
|
|
367
421
|
}
|
|
368
422
|
function cacheMultiplier(cachePer1M, inputPer1M) {
|
|
369
423
|
if (cachePer1M === void 0 || !Number.isFinite(cachePer1M)) return void 0;
|
|
370
424
|
if (inputPer1M <= 0) return void 0;
|
|
371
|
-
return
|
|
425
|
+
return round64(cachePer1M / inputPer1M);
|
|
372
426
|
}
|
|
373
427
|
var VENDOR_BY_ID_PREFIX = [
|
|
374
428
|
[/^claude-/, "anthropic"],
|
|
@@ -541,8 +595,8 @@ async function generateFor(endpoint, source, ctx) {
|
|
|
541
595
|
if (!Number.isFinite(inputPer1M) || !Number.isFinite(outputPer1M)) continue;
|
|
542
596
|
const key = routeKey(endpoint.providerKey, bareId);
|
|
543
597
|
const entry = {
|
|
544
|
-
inputPer1M:
|
|
545
|
-
outputPer1M:
|
|
598
|
+
inputPer1M: round64(inputPer1M),
|
|
599
|
+
outputPer1M: round64(outputPer1M),
|
|
546
600
|
vendor: vendorForOpencodeModelId(bareId),
|
|
547
601
|
provider: endpoint.providerKey
|
|
548
602
|
};
|