@evolinkai/cli 0.10.1 → 0.10.2
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/package.json +1 -1
- package/src/platform/core/src/services/model-catalog.js +10 -1
- package/src/platform/core/src/services/pricing-rules-client.js +52 -8
- package/src/platform/core/src/tools/get-pricing-rules.js +4 -0
- package/src/platform/core/src/version.js +1 -1
- package/src/platform/source.json +9 -9
package/package.json
CHANGED
|
@@ -41,16 +41,25 @@ export async function loadCatalog(config, pricingOptions = {}) {
|
|
|
41
41
|
try {
|
|
42
42
|
const { body } = await getPricingRules({ view: 'full' }, { fresh: pricingOptions.fresh });
|
|
43
43
|
const rules = 'models' in body ? body.models : [body.model];
|
|
44
|
+
// Rules left out of the list only matter here when they belong to a model this catalog shows.
|
|
45
|
+
const rejected = new Set(('models' in body ? body.rejected_models ?? [] : []).map(id => id.toLowerCase()));
|
|
46
|
+
const unreadable = [];
|
|
44
47
|
for (const entry of entries.values()) {
|
|
45
48
|
const rule = rules.find(model => model.model_id.toLowerCase() === entry.id.toLowerCase());
|
|
46
|
-
if (!rule)
|
|
49
|
+
if (!rule) {
|
|
50
|
+
if (rejected.has(entry.id.toLowerCase()))
|
|
51
|
+
unreadable.push(entry.id);
|
|
47
52
|
continue;
|
|
53
|
+
}
|
|
48
54
|
entry.priced = { id: entry.id, kind: entry.kind, pricingIncomplete: rule.pricing_status !== 'available',
|
|
49
55
|
prices: rule.components.map(c => ({ sku_id: c.sku_id, name: c.id,
|
|
50
56
|
unit: c.unit.includes('token') ? c.unit : c.unit.includes('second') ? 'second' : c.unit.includes('image') ? 'image' : c.unit,
|
|
51
57
|
min_usd: Number(c.rate.usd), max_usd: Number(c.rate.usd), min_charge_usd: Number(c.minimum_charge.usd),
|
|
52
58
|
role: c.unit.includes('token') ? 'token' : c.role.includes('output') || c.role === 'request' || c.role === 'output' ? 'output' : 'add_on' })) };
|
|
53
59
|
}
|
|
60
|
+
if (unreadable.length > 0) {
|
|
61
|
+
pricingWarning = `Prices for ${unreadable.length} listed model${unreadable.length === 1 ? ' are' : 's are'} unavailable right now because their published pricing rules could not be read: ${unreadable.slice(0, 10).join(', ')}${unreadable.length > 10 ? `, and ${unreadable.length - 10} more` : ''}. Other prices are unaffected.`;
|
|
62
|
+
}
|
|
54
63
|
}
|
|
55
64
|
catch (error) {
|
|
56
65
|
pricingWarning = `Prices are unavailable right now (${error instanceof Error ? error.message : 'unknown error'}).`;
|
|
@@ -51,8 +51,10 @@ const rateFields = {
|
|
|
51
51
|
billing_rule: z.string().min(1).max(60), pricing_status: z.enum(['available', 'unavailable']),
|
|
52
52
|
effective_at: z.string().datetime({ offset: true }),
|
|
53
53
|
};
|
|
54
|
+
// Legacy text adapters express a tier as base rate × multiplier; published policies give each tier its own
|
|
55
|
+
// SKU and absolute rate and omit the multiplier. Either way tier.rate is the rate to charge.
|
|
54
56
|
const Tier = z.object({ ...rateFields, multiplier: decimal.refine(value => /^(?:0|[1-9]\d*)(?:\.\d+)?$/.test(value)
|
|
55
|
-
&& fraction(value)[0] > 0n), when: ExpressionSchema.optional() });
|
|
57
|
+
&& fraction(value)[0] > 0n).optional(), when: ExpressionSchema.optional() });
|
|
56
58
|
const Component = z.object({ ...rateFields, id: z.string().min(1).max(100), role: z.string().min(1).max(100),
|
|
57
59
|
label_key: z.string().min(1).max(100).optional(),
|
|
58
60
|
dimension: z.string().min(1).max(100), unit: z.string().min(1).max(100),
|
|
@@ -80,7 +82,8 @@ const Meta = z.object({ schema_version: z.literal('2'), catalog_version: z.strin
|
|
|
80
82
|
exchange_rate_version: z.literal('pricing-fx/v1:USD-CNY=6.8'),
|
|
81
83
|
updated_at: z.string().datetime({ offset: true }), fresh_until: z.string().datetime({ offset: true }),
|
|
82
84
|
});
|
|
83
|
-
|
|
85
|
+
// A list is checked model by model, so one unreadable model cannot void every other price.
|
|
86
|
+
const Envelope = z.object({ meta: Meta, models: z.array(z.unknown()).max(1000) });
|
|
84
87
|
const Single = z.object({ meta: Meta, model: Model });
|
|
85
88
|
const cache = new Map();
|
|
86
89
|
const pending = new Map();
|
|
@@ -104,15 +107,57 @@ function bounded(value, depth = 0, budget = { nodes: 0 }) {
|
|
|
104
107
|
return Object.values(value).every(item => bounded(item, depth + 1, budget));
|
|
105
108
|
return true;
|
|
106
109
|
}
|
|
110
|
+
/** A rejected model is named by its ID when that is a readable identifier, otherwise by its position. */
|
|
111
|
+
function rejectedName(raw, index) {
|
|
112
|
+
const id = identifier(100).safeParse(raw && typeof raw === 'object' ? raw.model_id : undefined);
|
|
113
|
+
return id.success ? id.data : `#${index}`;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Bounds, metadata and freshness apply to the whole response and fail closed. In a list, a model whose rules
|
|
117
|
+
* cannot be read is left out and named in `rejected_models`; the list fails only when no model is readable.
|
|
118
|
+
* A single-model response fails when its model cannot be read.
|
|
119
|
+
*/
|
|
107
120
|
export function validatePricingRules(body, single) {
|
|
108
121
|
if (!bounded(body))
|
|
109
122
|
throw new PricingRulesError('invalid_pricing_rules');
|
|
110
|
-
const parsed = (single ? Single :
|
|
123
|
+
const parsed = (single ? Single : Envelope).safeParse(body);
|
|
111
124
|
if (!parsed.success)
|
|
112
125
|
throw new PricingRulesError('invalid_pricing_rules');
|
|
113
126
|
if (Date.parse(parsed.data.meta.fresh_until) <= Date.now())
|
|
114
127
|
throw new PricingRulesError('expired_pricing_rules');
|
|
115
|
-
|
|
128
|
+
if ('model' in parsed.data)
|
|
129
|
+
return parsed.data;
|
|
130
|
+
const models = [], rejected = [];
|
|
131
|
+
parsed.data.models.forEach((raw, index) => {
|
|
132
|
+
const model = Model.safeParse(raw);
|
|
133
|
+
if (model.success)
|
|
134
|
+
models.push(model.data);
|
|
135
|
+
else
|
|
136
|
+
rejected.push(rejectedName(raw, index));
|
|
137
|
+
});
|
|
138
|
+
if (rejected.length > 0 && models.length === 0)
|
|
139
|
+
throw new PricingRulesError('invalid_pricing_rules');
|
|
140
|
+
return { meta: parsed.data.meta, models, ...(rejected.length > 0 ? { rejected_models: rejected } : {}) };
|
|
141
|
+
}
|
|
142
|
+
const completeRule = (model) => model.components.every(component => component.quantity_rule && component.rounding
|
|
143
|
+
&& component.tiers.every(tier => tier.when));
|
|
144
|
+
/**
|
|
145
|
+
* The full view must carry every expression an estimate evaluates. A single model without them fails; in a
|
|
146
|
+
* list, such a model is left out and named like an unreadable one, and the list fails only when none is left.
|
|
147
|
+
*/
|
|
148
|
+
function completeRules(body) {
|
|
149
|
+
if ('model' in body) {
|
|
150
|
+
if (!completeRule(body.model))
|
|
151
|
+
throw new PricingRulesError('incomplete_pricing_rules');
|
|
152
|
+
return body;
|
|
153
|
+
}
|
|
154
|
+
const kept = body.models.filter(completeRule);
|
|
155
|
+
if (kept.length === body.models.length)
|
|
156
|
+
return body;
|
|
157
|
+
if (kept.length === 0)
|
|
158
|
+
throw new PricingRulesError('incomplete_pricing_rules');
|
|
159
|
+
return { meta: body.meta, models: kept,
|
|
160
|
+
rejected_models: [...(body.rejected_models ?? []), ...body.models.filter(model => !completeRule(model)).map(model => model.model_id)] };
|
|
116
161
|
}
|
|
117
162
|
async function readBody(response) {
|
|
118
163
|
if (!response.body)
|
|
@@ -189,16 +234,15 @@ export async function getPricingRules(input, options = {}) {
|
|
|
189
234
|
throw new PricingRulesError(status === 404 ? 'not_found' : status === 429 ? 'rate_limit_exceeded'
|
|
190
235
|
: status === 503 ? 'pricing_rules_unavailable' : 'pricing_rules_http_error', status, status === 429 ? retryAfterSeconds(response.headers.get('Retry-After')) : undefined);
|
|
191
236
|
}
|
|
192
|
-
|
|
237
|
+
let body = validatePricingRules(await readBody(response), Boolean(query.model));
|
|
193
238
|
const models = 'model' in body ? [body.model] : body.models;
|
|
194
239
|
if (models.some(model => (query.model && model.model_id !== query.model)
|
|
195
240
|
|| (query.product_id && model.product_id !== query.product_id) || (query.operation && model.operation !== query.operation)
|
|
196
241
|
|| (query.modality && model.modality !== query.modality) || (query.lifecycle && model.lifecycle !== query.lifecycle))) {
|
|
197
242
|
throw new PricingRulesError('mismatched_pricing_rules');
|
|
198
243
|
}
|
|
199
|
-
if (query.view === 'full'
|
|
200
|
-
|
|
201
|
-
throw new PricingRulesError('incomplete_pricing_rules');
|
|
244
|
+
if (query.view === 'full')
|
|
245
|
+
body = completeRules(body);
|
|
202
246
|
if (cache.size >= MAX_CACHE_ENTRIES)
|
|
203
247
|
cache.delete(cache.keys().next().value);
|
|
204
248
|
cache.set(key, { body, etag: response.headers.get('ETag') ?? undefined,
|
|
@@ -23,6 +23,10 @@ export function registerPricingRules(server) {
|
|
|
23
23
|
'No task quote or final spending cap was established. Do not multiply unit rates into a bill; minimum charges, tiers and rounding apply.',
|
|
24
24
|
'Coverage follows the models returned for this query. Empty results mean no matching public rules were returned, not zero cost.',
|
|
25
25
|
];
|
|
26
|
+
const rejected = 'models' in body ? body.rejected_models ?? [] : [];
|
|
27
|
+
if (rejected.length > 0) {
|
|
28
|
+
warnings.push(`${rejected.length} model(s) were left out because their published rules could not be read: ${rejected.slice(0, 20).join(', ')}${rejected.length > 20 ? `, and ${rejected.length - 20} more` : ''}. Missing rules do not mean these models are free.`);
|
|
29
|
+
}
|
|
26
30
|
const lines = [`Public pricing rules (${body.meta.price_scope}; ${selection}; ${source}); ${models.length} model(s).`, ...warnings];
|
|
27
31
|
for (const model of models) {
|
|
28
32
|
lines.push(`${model.model_id} (${model.modality}; ${model.pricing_status}; ${model.policy_source} v${model.policy_version})`);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// Copyright 2024 EvoLink AI. SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// Generated from Evolink-AI/evolink-mcp; adapted for direct REST operations. See platform/LICENSE and platform/NOTICE.
|
|
3
3
|
/** Version reported in serverInfo and in the X-Evo-Client-Version header. */
|
|
4
|
-
export const MCP_VERSION = '1.8.
|
|
4
|
+
export const MCP_VERSION = '1.8.2';
|
package/src/platform/source.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"schema_version": 1,
|
|
3
3
|
"repository": "Evolink-AI/evolink-mcp",
|
|
4
4
|
"baseline": "acc9fd43b945e3917b47809fc94f85ba26c7c8db",
|
|
5
|
-
"source_sha256": "
|
|
5
|
+
"source_sha256": "6a1ecce8f5359314b795ed793b52835dce8d547b99578d50655eebaadd7a28e5",
|
|
6
6
|
"files": {
|
|
7
7
|
"packages/core/src/branding.ts": "534b944a1370f210a3858c1a85b1a23071aca8e26b7a3e70e4d859ba5b152ff7",
|
|
8
8
|
"packages/core/src/config.ts": "208496230e22f43817cfb9b3805cde279fcce61a82227dfbd9f63485a33d33c7",
|
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
"packages/core/src/services/http-policy.ts": "f8cc029627655718d52b30dadaaa503fa6d4597846a13c802b7558d9797ea6bd",
|
|
21
21
|
"packages/core/src/services/media-preview.ts": "89410d8eb9a02e6fb9d9bc0de8a69b48bec7a06039e54569b9fea7e35527b6c4",
|
|
22
22
|
"packages/core/src/services/model-capabilities.ts": "b41c8b6dd34432cd2e44529e7f40aa1dd7c3b5d0d20e5964b78468517e1979df",
|
|
23
|
-
"packages/core/src/services/model-catalog.ts": "
|
|
23
|
+
"packages/core/src/services/model-catalog.ts": "0cad28a41774ea99ff6caf66860ac33a02e8fab254243368d502935b33842364",
|
|
24
24
|
"packages/core/src/services/model-recommendations.ts": "e986db35ac3a5e3c0c8daa1d4b9e5426e081b90674740de96fbcb11ddc2baf35",
|
|
25
25
|
"packages/core/src/services/param-validator.ts": "506e6d6f6a1ad170024d6a24ffcd2434c73e7ac855a89bbba9fdbb81653416fb",
|
|
26
26
|
"packages/core/src/services/preview-download.ts": "719e100e05f7632f633551773159ba7202f755c6d6ff5ecf364b40eeb26bee7b",
|
|
27
27
|
"packages/core/src/services/pricing-client.ts": "2e8d1107bac56c7e6fd47dbdd79f35b446af283f3f85a18c8bedeca60b822d98",
|
|
28
28
|
"packages/core/src/services/pricing-quote-client.ts": "a4537ce5ba83d9a8859ce6fb72223353443b67a42a0525b0cfad2abb93d0649a",
|
|
29
|
-
"packages/core/src/services/pricing-rules-client.ts": "
|
|
29
|
+
"packages/core/src/services/pricing-rules-client.ts": "d9424c7b249f2f559b50bf0a356fb5062a37460f9340213ea5488099d2c43c66",
|
|
30
30
|
"packages/core/src/services/pricing-rules-estimate.ts": "18b9115ffe4b7d04abd7c6fa2252cfe79a31a412567742ff9e8ea7237c59da21",
|
|
31
31
|
"packages/core/src/services/public-error.ts": "b706d2b5ccef1542c8f13e8cd41bfe844a590221e29053376f045680a912c54d",
|
|
32
32
|
"packages/core/src/services/upload-policy.ts": "2dc36716a3b9e78b078c618b029499bf6e27448dd44900b6f917dda5f8046ce3",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"packages/core/src/tools/estimate-cost.ts": "b01e7f2a5d9b1a5ec44f58d1f5bade121cb9ed46a63aea98e6bfa0dbb7055b5b",
|
|
39
39
|
"packages/core/src/tools/generate.ts": "7ff1150e256eb5373a0c7f824cacdb65d76056da81d3ea6de0623df2aec7da2b",
|
|
40
40
|
"packages/core/src/tools/get-model.ts": "bd727644aa554c7aa9d0246cbcb427d5063fb4b86fa33561af73f54eed2d1aa6",
|
|
41
|
-
"packages/core/src/tools/get-pricing-rules.ts": "
|
|
41
|
+
"packages/core/src/tools/get-pricing-rules.ts": "6fdd62f1f09804c6149c423f8203c89b8e9a7c181f661e0d49d7468f7ceb5f00",
|
|
42
42
|
"packages/core/src/tools/get-task.ts": "937a5ad4454956dd000abfd11149523d135527018d4d643ede600950d69e6205",
|
|
43
43
|
"packages/core/src/tools/list-tasks.ts": "c430f7c06b5aef88a3c386cf68d8462c7bf7371063cbfa85fa2511495ba9d69c",
|
|
44
44
|
"packages/core/src/tools/prepare-upload.ts": "c58cfb04725cc660e34f68391727e99f726e355f9329d91ced56878212294d40",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"packages/core/src/tools/task-format.ts": "05179cb238263817d4e67c711ef939d8b086246937698d0bd47b406eaf17a430",
|
|
49
49
|
"packages/core/src/tools/task-usage.ts": "ba05d054e1d60d67f6ab75cc6d9169f453c87e0e89c17a2c1be5fc429e8f9f47",
|
|
50
50
|
"packages/core/src/tools/upload-file.ts": "da6f239d1b1e6a13a7b418d24e738ebabf9823b2656111eeaa70eb247421ad40",
|
|
51
|
-
"packages/core/src/version.ts": "
|
|
51
|
+
"packages/core/src/version.ts": "b7195826c4fb9389d2b9c6420705667854517b43a004905434499cb714132cfa"
|
|
52
52
|
},
|
|
53
53
|
"artifacts": {
|
|
54
54
|
"core/src/config.js": "e5f001e6bb30fa3ca49ca1383b3deb83ea495d20079adefad6d0451f5bbee0e3",
|
|
@@ -64,12 +64,12 @@
|
|
|
64
64
|
"core/src/services/file-client.js": "d11798bfddc6637727a874532ad218b5deac58d6bca8f20abcd2c30b132210e4",
|
|
65
65
|
"core/src/services/http-policy.js": "322892ddb21f15cb3111a36b006b3ab62bea7a9d13b05d970ded62bae3ca32cd",
|
|
66
66
|
"core/src/services/model-capabilities.js": "2ad86bc08c82cce82964b18d6187632fc738f8cd17d03de1ef04f27b1e35cfe1",
|
|
67
|
-
"core/src/services/model-catalog.js": "
|
|
67
|
+
"core/src/services/model-catalog.js": "e25b005d48a38106565919cdfb50abf2b018b92e7d762a88470ba3af1ba2fa06",
|
|
68
68
|
"core/src/services/model-recommendations.js": "f330f941d26aa9fc127c2f7479cb2be026d6111a3f3066e89442ff29ec33803a",
|
|
69
69
|
"core/src/services/param-validator.js": "9e3fba916a39140614851689fcf47f1aa644a30b6192b6126af4d78695f88b10",
|
|
70
70
|
"core/src/services/pricing-client.js": "2f0f74f7769442e4edf8c3f37a66bb1c6c099253189e9b2079ad265d1327225d",
|
|
71
71
|
"core/src/services/pricing-quote-client.js": "6107815eb757036470fac21f9d79da3a3862f583c3b2f0c1d9f56761fa9fc9f6",
|
|
72
|
-
"core/src/services/pricing-rules-client.js": "
|
|
72
|
+
"core/src/services/pricing-rules-client.js": "6c6a6de64a2fbf816f7be5661712bc18ae996328ffcb53401fe0cc0ce3123b6f",
|
|
73
73
|
"core/src/services/pricing-rules-estimate.js": "c7288e2f76b4de7116c88f7b443ed835d0e0af21387d6e1e389ad13a1c71f506",
|
|
74
74
|
"core/src/services/public-error.js": "306665fb8ac54beb911a8e908755e49c3a9aec64f3b9a5dee1a28eb64e8a2681",
|
|
75
75
|
"core/src/services/utm.js": "8aa328ddb92c3ef65568fab60226cb5fa2e940449d7ac3d6c2e35b6f9bcf835d",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"core/src/tools/estimate-cost.js": "794374dc2b64e87375410e5f1bc049cd9fd1e58cd3b62db1b6f014a3135671fd",
|
|
80
80
|
"core/src/tools/generate.js": "85ef70bb75f685013c35bb862af0fec2ebf35477add9a3bffdafbd7b4fcfea3f",
|
|
81
81
|
"core/src/tools/get-model.js": "32bbba590e8f0fb632dab0e517f761cddcc7b64a8eb76f1d9ae571e6f80bf08d",
|
|
82
|
-
"core/src/tools/get-pricing-rules.js": "
|
|
82
|
+
"core/src/tools/get-pricing-rules.js": "3dcab9b74ec08156a27f34a0930363b7dead5d00bba8e6cdbb47cd68ea76aaad",
|
|
83
83
|
"core/src/tools/get-task.js": "1ef62167c629c7ad859d1d31cd8779eb98e3a22c8bb754b2c355e58515b308f0",
|
|
84
84
|
"core/src/tools/list-tasks.js": "73de0c3c7ecfff6f99202d17c1db53f2c394b15d01781199cc38f9c3eb80c6a5",
|
|
85
85
|
"core/src/tools/search-models.js": "9850b7d2d74a1d69229400d465b21ecb9ede79c75dddeb41787668f418c5bd06",
|
|
@@ -87,6 +87,6 @@
|
|
|
87
87
|
"core/src/tools/task-billing.js": "f49b252afcaf4a6275f5db6ebc8e6380387b2406bd5fc91e7367e3523025af8b",
|
|
88
88
|
"core/src/tools/task-format.js": "fd409b11bf24826d7669fcf8a0994e23d244034ae88fdc4d931444d7d12ce0fa",
|
|
89
89
|
"core/src/tools/task-usage.js": "3aae5d7807efc2c762bf604cf9ecfecf8f9008185bcef584e6d4243404418dc5",
|
|
90
|
-
"core/src/version.js": "
|
|
90
|
+
"core/src/version.js": "25a0bb45f50ed3031858e110bc463b93e87ca536d2701b11da39dc09b225ef61"
|
|
91
91
|
}
|
|
92
92
|
}
|