@x12i/ai-tools 1.0.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/README.md +214 -0
- package/dist/AiModelsCatalogClient-4RF5BCDL.cjs +9 -0
- package/dist/AiModelsCatalogClient-4RF5BCDL.cjs.map +1 -0
- package/dist/AiModelsCatalogClient-B-dNLXX0.d.ts +29 -0
- package/dist/AiModelsCatalogClient-CSVlKql5.d.cts +29 -0
- package/dist/AiModelsCatalogClient-NUF3CBLW.js +9 -0
- package/dist/AiModelsCatalogClient-NUF3CBLW.js.map +1 -0
- package/dist/aliases/index.cjs +11 -0
- package/dist/aliases/index.cjs.map +1 -0
- package/dist/aliases/index.d.cts +21 -0
- package/dist/aliases/index.d.ts +21 -0
- package/dist/aliases/index.js +11 -0
- package/dist/aliases/index.js.map +1 -0
- package/dist/catalox/index.cjs +21 -0
- package/dist/catalox/index.cjs.map +1 -0
- package/dist/catalox/index.d.cts +23 -0
- package/dist/catalox/index.d.ts +23 -0
- package/dist/catalox/index.js +21 -0
- package/dist/catalox/index.js.map +1 -0
- package/dist/chunk-2PYACSZ5.cjs +1 -0
- package/dist/chunk-2PYACSZ5.cjs.map +1 -0
- package/dist/chunk-3E67S427.cjs +1 -0
- package/dist/chunk-3E67S427.cjs.map +1 -0
- package/dist/chunk-4NAY6HRP.js +137 -0
- package/dist/chunk-4NAY6HRP.js.map +1 -0
- package/dist/chunk-5HNFAYTO.cjs +254 -0
- package/dist/chunk-5HNFAYTO.cjs.map +1 -0
- package/dist/chunk-6QGDZTGH.js +127 -0
- package/dist/chunk-6QGDZTGH.js.map +1 -0
- package/dist/chunk-7Q742NI3.cjs +106 -0
- package/dist/chunk-7Q742NI3.cjs.map +1 -0
- package/dist/chunk-AJEKEWWB.js +106 -0
- package/dist/chunk-AJEKEWWB.js.map +1 -0
- package/dist/chunk-AV6OE2YQ.cjs +127 -0
- package/dist/chunk-AV6OE2YQ.cjs.map +1 -0
- package/dist/chunk-COK34C6P.js +1 -0
- package/dist/chunk-COK34C6P.js.map +1 -0
- package/dist/chunk-DJ5SWJDY.js +729 -0
- package/dist/chunk-DJ5SWJDY.js.map +1 -0
- package/dist/chunk-F2F4UEFD.cjs +75 -0
- package/dist/chunk-F2F4UEFD.cjs.map +1 -0
- package/dist/chunk-G2G4KSC5.js +30 -0
- package/dist/chunk-G2G4KSC5.js.map +1 -0
- package/dist/chunk-HHNHWYTP.cjs +105 -0
- package/dist/chunk-HHNHWYTP.cjs.map +1 -0
- package/dist/chunk-HN6UAQAE.cjs +83 -0
- package/dist/chunk-HN6UAQAE.cjs.map +1 -0
- package/dist/chunk-KHODXGPV.js +1 -0
- package/dist/chunk-KHODXGPV.js.map +1 -0
- package/dist/chunk-KQOALKKX.js +75 -0
- package/dist/chunk-KQOALKKX.js.map +1 -0
- package/dist/chunk-LYOU7CA2.cjs +30 -0
- package/dist/chunk-LYOU7CA2.cjs.map +1 -0
- package/dist/chunk-ML2FRR4L.js +105 -0
- package/dist/chunk-ML2FRR4L.js.map +1 -0
- package/dist/chunk-MLRHYOCD.js +160 -0
- package/dist/chunk-MLRHYOCD.js.map +1 -0
- package/dist/chunk-O2A6OVEH.js +240 -0
- package/dist/chunk-O2A6OVEH.js.map +1 -0
- package/dist/chunk-ONA73BU6.cjs +160 -0
- package/dist/chunk-ONA73BU6.cjs.map +1 -0
- package/dist/chunk-QCRLKVB3.cjs +137 -0
- package/dist/chunk-QCRLKVB3.cjs.map +1 -0
- package/dist/chunk-QWAX7VQO.cjs +240 -0
- package/dist/chunk-QWAX7VQO.cjs.map +1 -0
- package/dist/chunk-TF4L2NEC.cjs +729 -0
- package/dist/chunk-TF4L2NEC.cjs.map +1 -0
- package/dist/chunk-XRBZQQQU.js +254 -0
- package/dist/chunk-XRBZQQQU.js.map +1 -0
- package/dist/chunk-YHO57D2V.js +83 -0
- package/dist/chunk-YHO57D2V.js.map +1 -0
- package/dist/cli/index.cjs +403 -0
- package/dist/cli/index.cjs.map +1 -0
- package/dist/cli/index.d.cts +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +403 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cost/index.cjs +7 -0
- package/dist/cost/index.cjs.map +1 -0
- package/dist/cost/index.d.cts +52 -0
- package/dist/cost/index.d.ts +52 -0
- package/dist/cost/index.js +7 -0
- package/dist/cost/index.js.map +1 -0
- package/dist/index.cjs +104 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +58 -0
- package/dist/index.d.ts +58 -0
- package/dist/index.js +104 -0
- package/dist/index.js.map +1 -0
- package/dist/modelNameResolver-Bn8QnkSj.d.ts +80 -0
- package/dist/modelNameResolver-bZD-eBSJ.d.cts +80 -0
- package/dist/models/index.cjs +33 -0
- package/dist/models/index.cjs.map +1 -0
- package/dist/models/index.d.cts +75 -0
- package/dist/models/index.d.ts +75 -0
- package/dist/models/index.js +33 -0
- package/dist/models/index.js.map +1 -0
- package/dist/sync/index.cjs +38 -0
- package/dist/sync/index.cjs.map +1 -0
- package/dist/sync/index.d.cts +12 -0
- package/dist/sync/index.d.ts +12 -0
- package/dist/sync/index.js +38 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/toolbox/index.cjs +7 -0
- package/dist/toolbox/index.cjs.map +1 -0
- package/dist/toolbox/index.d.cts +72 -0
- package/dist/toolbox/index.d.ts +72 -0
- package/dist/toolbox/index.js +7 -0
- package/dist/toolbox/index.js.map +1 -0
- package/dist/types-DdGB3YaA.d.cts +278 -0
- package/dist/types-DdGB3YaA.d.ts +278 -0
- package/package.json +115 -0
- package/schemas/aliases.json +28 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts"],"sourcesContent":["import type {\n ModelResolutionInput,\n ModelResolutionNotFound,\n} from \"./sync/modelNameResolver/types.js\";\n\nexport type AiToolsErrorCode =\n | \"MODEL_NOT_FOUND\"\n | \"SYNC_FETCH_FAILED\"\n | \"SYNC_UPSERT_FAILED\"\n | \"CATALOG_BOOTSTRAP_FAILED\"\n | \"COST_CALCULATION_FAILED\"\n | \"INVALID_USAGE_INPUT\"\n | \"OPENROUTER_AUTH_FAILED\"\n | \"OPENROUTER_MODELS_FETCH_FAILED\"\n | \"CACHE_READ_ERROR\"\n | \"ALIAS_NOT_FOUND\"\n | \"ALIAS_INVALID_NAME\"\n | \"ALIAS_CONFLICT\"\n | \"ALIAS_FILE_PARSE_ERROR\"\n | \"ALIAS_FILE_WRITE_ERROR\";\n\nexport class AiToolsError extends Error {\n constructor(\n public readonly code: AiToolsErrorCode,\n message: string,\n public readonly cause?: unknown,\n ) {\n super(message);\n this.name = \"AiToolsError\";\n }\n}\n\nexport class ModelNotFoundError extends AiToolsError {\n constructor(modelId: string) {\n super(\n \"MODEL_NOT_FOUND\",\n `Model not found: \"${modelId}\". Run \"ai-tools sync\" to populate the catalog.`,\n );\n this.name = \"ModelNotFoundError\";\n }\n}\n\nexport class ModelResolutionError extends AiToolsError {\n constructor(\n public readonly input: ModelResolutionInput,\n public readonly result: ModelResolutionNotFound,\n ) {\n super(\n \"MODEL_NOT_FOUND\",\n `Could not resolve model \"${input.model}\" (provider: \"${input.provider ?? \"unspecified\"}\"). ` +\n result.reason +\n (result.bestRejectedCandidate\n ? ` Best candidate was \"${result.bestRejectedCandidate.modelId}\" (confidence ${result.bestRejectedCandidate.confidence.toFixed(2)}).`\n : \"\"),\n );\n this.name = \"ModelResolutionError\";\n }\n}\n\nexport class AliasNotFoundError extends AiToolsError {\n constructor(aliasName: string) {\n super(\n \"ALIAS_NOT_FOUND\",\n `Alias not found: \"${aliasName}\". Run \"ai-tools alias list\" to see defined aliases.`,\n );\n this.name = \"AliasNotFoundError\";\n }\n}\n\nexport class AliasInvalidNameError extends AiToolsError {\n constructor(aliasName: string) {\n super(\n \"ALIAS_INVALID_NAME\",\n `Invalid alias name: \"${aliasName}\". Names must match /^[a-z0-9][a-z0-9-]*$/`,\n );\n this.name = \"AliasInvalidNameError\";\n }\n}\n\nexport class AliasConflictError extends AiToolsError {\n constructor(aliasName: string) {\n super(\n \"ALIAS_CONFLICT\",\n `Alias \"${aliasName}\" already exists. Use --force to overwrite.`,\n );\n this.name = \"AliasConflictError\";\n }\n}\n\nexport class AliasFileParseError extends AiToolsError {\n constructor(path: string, cause?: unknown) {\n super(\n \"ALIAS_FILE_PARSE_ERROR\",\n `Failed to parse aliases file at \"${path}\". Check JSON syntax.`,\n cause,\n );\n this.name = \"AliasFileParseError\";\n }\n}\n\nexport class AliasFileWriteError extends AiToolsError {\n constructor(path: string, cause?: unknown) {\n super(\n \"ALIAS_FILE_WRITE_ERROR\",\n `Failed to write aliases file at \"${path}\".`,\n cause,\n );\n this.name = \"AliasFileWriteError\";\n }\n}\n\nexport class SyncError extends AiToolsError {\n constructor(code: Extract<AiToolsErrorCode, \"SYNC_FETCH_FAILED\" | \"SYNC_UPSERT_FAILED\" | \"OPENROUTER_AUTH_FAILED\" | \"OPENROUTER_MODELS_FETCH_FAILED\">, message: string, cause?: unknown) {\n super(code, message, cause);\n this.name = \"SyncError\";\n }\n}\n\nexport class CostCalculationError extends AiToolsError {\n constructor(message: string, cause?: unknown) {\n super(\"COST_CALCULATION_FAILED\", message, cause);\n this.name = \"CostCalculationError\";\n }\n}\n"],"mappings":";AAqBO,IAAM,eAAN,cAA2B,MAAM;AAAA,EACtC,YACkB,MAChB,SACgB,OAChB;AACA,UAAM,OAAO;AAJG;AAEA;AAGhB,SAAK,OAAO;AAAA,EACd;AAAA,EANkB;AAAA,EAEA;AAKpB;AAEO,IAAM,qBAAN,cAAiC,aAAa;AAAA,EACnD,YAAY,SAAiB;AAC3B;AAAA,MACE;AAAA,MACA,qBAAqB,OAAO;AAAA,IAC9B;AACA,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,uBAAN,cAAmC,aAAa;AAAA,EACrD,YACkB,OACA,QAChB;AACA;AAAA,MACE;AAAA,MACA,4BAA4B,MAAM,KAAK,iBAAiB,MAAM,YAAY,aAAa,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}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/models/reasoningModel.ts
|
|
2
|
+
var REASONING_SUPPORTED_PARAMETERS = ["reasoning", "include_reasoning"];
|
|
3
|
+
function supportsReasoningParameter(model) {
|
|
4
|
+
return model.supportedParameters.some(
|
|
5
|
+
(p) => REASONING_SUPPORTED_PARAMETERS.includes(p)
|
|
6
|
+
);
|
|
7
|
+
}
|
|
8
|
+
function hasReasoningPricing(model) {
|
|
9
|
+
const raw = _optionalChain([model, 'access', _ => _.openRouterPricing, 'optionalAccess', _2 => _2.internal_reasoning]);
|
|
10
|
+
if (raw !== void 0 && raw !== null && String(raw).trim() !== "") {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
return model.pricing.reasoningUsdPerToken !== void 0;
|
|
14
|
+
}
|
|
15
|
+
function computeSupportsReasoning(model) {
|
|
16
|
+
return supportsReasoningParameter(model) || hasReasoningPricing(model);
|
|
17
|
+
}
|
|
18
|
+
function isReasoningModel(model) {
|
|
19
|
+
if (model.supportsReasoning !== void 0) {
|
|
20
|
+
return model.supportsReasoning;
|
|
21
|
+
}
|
|
22
|
+
return computeSupportsReasoning(model);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// src/models/normalizeOpenRouterModel.ts
|
|
26
|
+
function parsePrice(value) {
|
|
27
|
+
if (value === void 0 || value === null || value === "") return 0;
|
|
28
|
+
const n = typeof value === "number" ? value : Number.parseFloat(String(value));
|
|
29
|
+
return Number.isFinite(n) ? n : 0;
|
|
30
|
+
}
|
|
31
|
+
function extractProviderId(modelId) {
|
|
32
|
+
const slash = modelId.indexOf("/");
|
|
33
|
+
if (slash > 0) return modelId.slice(0, slash);
|
|
34
|
+
return "other";
|
|
35
|
+
}
|
|
36
|
+
function buildAliases(modelId, name) {
|
|
37
|
+
const aliases = /* @__PURE__ */ new Set();
|
|
38
|
+
if (name) aliases.add(name);
|
|
39
|
+
const slash = modelId.indexOf("/");
|
|
40
|
+
if (slash > 0) {
|
|
41
|
+
const direct = modelId.slice(slash + 1);
|
|
42
|
+
aliases.add(direct);
|
|
43
|
+
const base = direct.replace(/-\d{4}-\d{2}-\d{2}$/, "").replace(/-\d{8}$/, "");
|
|
44
|
+
if (base !== direct) aliases.add(base);
|
|
45
|
+
}
|
|
46
|
+
return [...aliases];
|
|
47
|
+
}
|
|
48
|
+
function normalizePricing(raw) {
|
|
49
|
+
return {
|
|
50
|
+
promptUsdPerToken: parsePrice(raw.prompt),
|
|
51
|
+
completionUsdPerToken: parsePrice(raw.completion),
|
|
52
|
+
imageUsdPerUnit: parsePrice(raw.image),
|
|
53
|
+
requestUsdPerRequest: parsePrice(raw.request),
|
|
54
|
+
cacheReadUsdPerToken: raw.input_cache_read ? parsePrice(raw.input_cache_read) : void 0,
|
|
55
|
+
cacheWriteUsdPerToken: raw.input_cache_write ? parsePrice(raw.input_cache_write) : void 0,
|
|
56
|
+
reasoningUsdPerToken: raw.internal_reasoning ? parsePrice(raw.internal_reasoning) : void 0,
|
|
57
|
+
webSearchUsdPerRequest: raw.web_search ? parsePrice(raw.web_search) : void 0,
|
|
58
|
+
openRouterMarkupUsdPerInputToken: 0,
|
|
59
|
+
openRouterMarkupUsdPerOutputToken: 0,
|
|
60
|
+
pricedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
61
|
+
source: "openrouter"
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function resolveStatus(row) {
|
|
65
|
+
if (row.expiration_date) {
|
|
66
|
+
const exp = Date.parse(row.expiration_date);
|
|
67
|
+
if (!Number.isNaN(exp) && exp < Date.now()) return "deprecated";
|
|
68
|
+
}
|
|
69
|
+
return "active";
|
|
70
|
+
}
|
|
71
|
+
function normalizeOpenRouterModel(row, syncedAt) {
|
|
72
|
+
const outputModalities = _nullishCoalesce(_optionalChain([row, 'access', _3 => _3.architecture, 'optionalAccess', _4 => _4.output_modalities]), () => ( ["text"]));
|
|
73
|
+
const inputModalities = _nullishCoalesce(_optionalChain([row, 'access', _5 => _5.architecture, 'optionalAccess', _6 => _6.input_modalities]), () => ( ["text"]));
|
|
74
|
+
const supportedParameters = _nullishCoalesce(row.supported_parameters, () => ( []));
|
|
75
|
+
const pricing = normalizePricing(row.pricing);
|
|
76
|
+
const openRouterPricing = row.pricing;
|
|
77
|
+
const supportsReasoning = computeSupportsReasoning({
|
|
78
|
+
supportedParameters,
|
|
79
|
+
pricing,
|
|
80
|
+
openRouterPricing
|
|
81
|
+
});
|
|
82
|
+
return {
|
|
83
|
+
modelId: row.id,
|
|
84
|
+
name: _nullishCoalesce(row.name, () => ( row.id)),
|
|
85
|
+
providerId: extractProviderId(row.id),
|
|
86
|
+
canonicalSlug: _nullishCoalesce(row.canonical_slug, () => ( row.id)),
|
|
87
|
+
status: resolveStatus(row),
|
|
88
|
+
description: _nullishCoalesce(row.description, () => ( "")),
|
|
89
|
+
created: _nullishCoalesce(row.created, () => ( 0)),
|
|
90
|
+
expirationDate: _nullishCoalesce(row.expiration_date, () => ( null)),
|
|
91
|
+
contextLength: _nullishCoalesce(_nullishCoalesce(row.context_length, () => ( _optionalChain([row, 'access', _7 => _7.top_provider, 'optionalAccess', _8 => _8.context_length]))), () => ( 0)),
|
|
92
|
+
maxCompletionTokens: _nullishCoalesce(_optionalChain([row, 'access', _9 => _9.top_provider, 'optionalAccess', _10 => _10.max_completion_tokens]), () => ( null)),
|
|
93
|
+
isModerated: _nullishCoalesce(_optionalChain([row, 'access', _11 => _11.top_provider, 'optionalAccess', _12 => _12.is_moderated]), () => ( false)),
|
|
94
|
+
modality: _nullishCoalesce(_optionalChain([row, 'access', _13 => _13.architecture, 'optionalAccess', _14 => _14.modality]), () => ( "")),
|
|
95
|
+
inputModalities,
|
|
96
|
+
outputModalities,
|
|
97
|
+
tokenizer: _nullishCoalesce(_optionalChain([row, 'access', _15 => _15.architecture, 'optionalAccess', _16 => _16.tokenizer]), () => ( "")),
|
|
98
|
+
instructType: _nullishCoalesce(_optionalChain([row, 'access', _17 => _17.architecture, 'optionalAccess', _18 => _18.instruct_type]), () => ( null)),
|
|
99
|
+
supportedParameters,
|
|
100
|
+
defaultParameters: _nullishCoalesce(row.default_parameters, () => ( null)),
|
|
101
|
+
perRequestLimits: _nullishCoalesce(row.per_request_limits, () => ( null)),
|
|
102
|
+
pricing,
|
|
103
|
+
openRouterPricing,
|
|
104
|
+
architecture: row.architecture,
|
|
105
|
+
topProvider: row.top_provider,
|
|
106
|
+
openRouter: row,
|
|
107
|
+
aliases: buildAliases(row.id, row.name),
|
|
108
|
+
availableOnOpenRouter: true,
|
|
109
|
+
supportsStreaming: outputModalities.includes("text"),
|
|
110
|
+
supportsTools: supportedParameters.includes("tools"),
|
|
111
|
+
supportsReasoning,
|
|
112
|
+
primaryOutputModality: _nullishCoalesce(outputModalities[0], () => ( "text")),
|
|
113
|
+
syncedAt,
|
|
114
|
+
syncSource: "openrouter"
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
exports.REASONING_SUPPORTED_PARAMETERS = REASONING_SUPPORTED_PARAMETERS; exports.supportsReasoningParameter = supportsReasoningParameter; exports.hasReasoningPricing = hasReasoningPricing; exports.computeSupportsReasoning = computeSupportsReasoning; exports.isReasoningModel = isReasoningModel; exports.extractProviderId = extractProviderId; exports.normalizeOpenRouterModel = normalizeOpenRouterModel;
|
|
127
|
+
//# sourceMappingURL=chunk-AV6OE2YQ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/ami/Documents/prometheus/x12i/ai-tools/dist/chunk-AV6OE2YQ.cjs","../src/models/reasoningModel.ts","../src/models/normalizeOpenRouterModel.ts"],"names":[],"mappings":"AAAA;ACGO,IAAM,+BAAA,EAAiC,CAAC,WAAA,EAAa,mBAAmB,CAAA;AAaxE,SAAS,0BAAA,CAA2B,KAAA,EAA4D;AACrG,EAAA,OAAO,KAAA,CAAM,mBAAA,CAAoB,IAAA;AAAA,IAAK,CAAC,CAAA,EAAA,GACpC,8BAAA,CAAqD,QAAA,CAAS,CAAC;AAAA,EAClE,CAAA;AACF;AAMO,SAAS,mBAAA,CACd,KAAA,EACS;AACT,EAAA,MAAM,IAAA,kBAAM,KAAA,mBAAM,iBAAA,6BAAmB,oBAAA;AACrC,EAAA,GAAA,CAAI,IAAA,IAAQ,KAAA,EAAA,GAAa,IAAA,IAAQ,KAAA,GAAQ,MAAA,CAAO,GAAG,CAAA,CAAE,IAAA,CAAK,EAAA,IAAM,EAAA,EAAI;AAClE,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,OAAO,KAAA,CAAM,OAAA,CAAQ,qBAAA,IAAyB,KAAA,CAAA;AAChD;AAKO,SAAS,wBAAA,CAAyB,KAAA,EAAqC;AAC5E,EAAA,OAAO,0BAAA,CAA2B,KAAK,EAAA,GAAK,mBAAA,CAAoB,KAAK,CAAA;AACvE;AAQO,SAAS,gBAAA,CAAiB,KAAA,EAAqC;AACpE,EAAA,GAAA,CAAI,KAAA,CAAM,kBAAA,IAAsB,KAAA,CAAA,EAAW;AACzC,IAAA,OAAO,KAAA,CAAM,iBAAA;AAAA,EACf;AACA,EAAA,OAAO,wBAAA,CAAyB,KAAK,CAAA;AACvC;AD/BA;AACA;AEpBA,SAAS,UAAA,CAAW,KAA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AA,mCAAqB,GAAA,qBAAI,YAAA,+BAAc,uBAAA,UAAyB,MAAA;AAAA,IAChE,WAAA,mCAAa,GAAA,uBAAI,YAAA,+BAAc,cAAA,UAAgB,OAAA;AAAA,IAC/C,QAAA,mCAAU,GAAA,uBAAI,YAAA,+BAAc,UAAA,UAAY,IAAA;AAAA,IACxC,eAAA;AAAA,IACA,gBAAA;AAAA,IACA,SAAA,mCAAW,GAAA,uBAAI,YAAA,+BAAc,WAAA,UAAa,IAAA;AAAA,IAC1C,YAAA,mCAAc,GAAA,uBAAI,YAAA,+BAAc,eAAA,UAAiB,MAAA;AAAA,IACjD,mBAAA;AAAA,IACA,iBAAA,mBAAmB,GAAA,CAAI,kBAAA,UAAsB,MAAA;AAAA,IAC7C,gBAAA,mBAAkB,GAAA,CAAI,kBAAA,UAAsB,MAAA;AAAA,IAC5C,OAAA;AAAA,IACA,iBAAA;AAAA,IACA,YAAA,EAAc,GAAA,CAAI,YAAA;AAAA,IAClB,WAAA,EAAa,GAAA,CAAI,YAAA;AAAA,IACjB,UAAA,EAAY,GAAA;AAAA,IACZ,OAAA,EAAS,YAAA,CAAa,GAAA,CAAI,EAAA,EAAI,GAAA,CAAI,IAAI,CAAA;AAAA,IACtC,qBAAA,EAAuB,IAAA;AAAA,IACvB,iBAAA,EAAmB,gBAAA,CAAiB,QAAA,CAAS,MAAM,CAAA;AAAA,IACnD,aAAA,EAAe,mBAAA,CAAoB,QAAA,CAAS,OAAO,CAAA;AAAA,IACnD,iBAAA;AAAA,IACA,qBAAA,mBAAuB,gBAAA,CAAiB,CAAC,CAAA,UAAK,QAAA;AAAA,IAC9C,QAAA;AAAA,IACA,UAAA,EAAY;AAAA,EACd,CAAA;AACF;AFUA;AACA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACF,kZAAC","file":"/Users/ami/Documents/prometheus/x12i/ai-tools/dist/chunk-AV6OE2YQ.cjs","sourcesContent":[null,"import type { AiModelRecord } from \"./types.js\";\n\n/** OpenRouter `supported_parameters` values that indicate reasoning API support. */\nexport const REASONING_SUPPORTED_PARAMETERS = [\"reasoning\", \"include_reasoning\"] as const;\n\nexport type ReasoningModelInput = Pick<\n AiModelRecord,\n \"supportedParameters\" | \"pricing\" | \"openRouterPricing\"\n> & {\n supportsReasoning?: boolean;\n};\n\n/**\n * Whether the model accepts OpenRouter's `reasoning` request parameter\n * (effort, max_tokens, exclude, enabled).\n */\nexport function supportsReasoningParameter(model: Pick<AiModelRecord, \"supportedParameters\">): boolean {\n return model.supportedParameters.some((p) =>\n (REASONING_SUPPORTED_PARAMETERS as readonly string[]).includes(p),\n );\n}\n\n/**\n * Whether the model bills separate reasoning / thinking tokens\n * (`internal_reasoning` in OpenRouter pricing).\n */\nexport function hasReasoningPricing(\n model: Pick<AiModelRecord, \"pricing\" | \"openRouterPricing\">,\n): boolean {\n const raw = model.openRouterPricing?.internal_reasoning;\n if (raw !== undefined && raw !== null && String(raw).trim() !== \"\") {\n return true;\n }\n return model.pricing.reasoningUsdPerToken !== undefined;\n}\n\n/**\n * Compute `supportsReasoning` from catalog fields (used during sync normalization).\n */\nexport function computeSupportsReasoning(model: ReasoningModelInput): boolean {\n return supportsReasoningParameter(model) || hasReasoningPricing(model);\n}\n\n/**\n * True when the model supports reasoning tokens (API param and/or separate reasoning pricing).\n *\n * Prefer `model.supportsReasoning` on {@link AiModelRecord} after catalog sync;\n * this helper also works when only partial fields are available.\n */\nexport function isReasoningModel(model: ReasoningModelInput): boolean {\n if (model.supportsReasoning !== undefined) {\n return model.supportsReasoning;\n }\n return computeSupportsReasoning(model);\n}\n","import { computeSupportsReasoning } from \"./reasoningModel.js\";\nimport type { AiModelPricing, AiModelRecord } from \"./types.js\";\nimport type { OpenRouterModelApi } from \"./openrouter.types.js\";\n\nfunction parsePrice(value: string | number | undefined): number {\n if (value === undefined || value === null || value === \"\") return 0;\n const n = typeof value === \"number\" ? value : Number.parseFloat(String(value));\n return Number.isFinite(n) ? n : 0;\n}\n\nexport function extractProviderId(modelId: string): string {\n const slash = modelId.indexOf(\"/\");\n if (slash > 0) return modelId.slice(0, slash);\n return \"other\";\n}\n\nfunction buildAliases(modelId: string, name?: string): string[] {\n const aliases = new Set<string>();\n if (name) aliases.add(name);\n const slash = modelId.indexOf(\"/\");\n if (slash > 0) {\n const direct = modelId.slice(slash + 1);\n aliases.add(direct);\n const base = direct.replace(/-\\d{4}-\\d{2}-\\d{2}$/, \"\").replace(/-\\d{8}$/, \"\");\n if (base !== direct) aliases.add(base);\n }\n return [...aliases];\n}\n\nfunction normalizePricing(raw: OpenRouterModelApi[\"pricing\"]): AiModelPricing {\n return {\n promptUsdPerToken: parsePrice(raw.prompt),\n completionUsdPerToken: parsePrice(raw.completion),\n imageUsdPerUnit: parsePrice(raw.image),\n requestUsdPerRequest: parsePrice(raw.request),\n cacheReadUsdPerToken: raw.input_cache_read\n ? parsePrice(raw.input_cache_read)\n : undefined,\n cacheWriteUsdPerToken: raw.input_cache_write\n ? parsePrice(raw.input_cache_write)\n : undefined,\n reasoningUsdPerToken: raw.internal_reasoning\n ? parsePrice(raw.internal_reasoning)\n : undefined,\n webSearchUsdPerRequest: raw.web_search ? parsePrice(raw.web_search) : undefined,\n openRouterMarkupUsdPerInputToken: 0,\n openRouterMarkupUsdPerOutputToken: 0,\n pricedAt: new Date().toISOString(),\n source: \"openrouter\",\n };\n}\n\nfunction resolveStatus(row: OpenRouterModelApi): AiModelRecord[\"status\"] {\n if (row.expiration_date) {\n const exp = Date.parse(row.expiration_date);\n if (!Number.isNaN(exp) && exp < Date.now()) return \"deprecated\";\n }\n return \"active\";\n}\n\nexport function normalizeOpenRouterModel(row: OpenRouterModelApi, syncedAt: string): AiModelRecord {\n const outputModalities = row.architecture?.output_modalities ?? [\"text\"];\n const inputModalities = row.architecture?.input_modalities ?? [\"text\"];\n const supportedParameters = row.supported_parameters ?? [];\n const pricing = normalizePricing(row.pricing);\n const openRouterPricing = row.pricing;\n const supportsReasoning = computeSupportsReasoning({\n supportedParameters,\n pricing,\n openRouterPricing,\n });\n\n return {\n modelId: row.id,\n name: row.name ?? row.id,\n providerId: extractProviderId(row.id),\n canonicalSlug: row.canonical_slug ?? row.id,\n status: resolveStatus(row),\n description: row.description ?? \"\",\n created: row.created ?? 0,\n expirationDate: row.expiration_date ?? null,\n contextLength: row.context_length ?? row.top_provider?.context_length ?? 0,\n maxCompletionTokens: row.top_provider?.max_completion_tokens ?? null,\n isModerated: row.top_provider?.is_moderated ?? false,\n modality: row.architecture?.modality ?? \"\",\n inputModalities,\n outputModalities,\n tokenizer: row.architecture?.tokenizer ?? \"\",\n instructType: row.architecture?.instruct_type ?? null,\n supportedParameters,\n defaultParameters: row.default_parameters ?? null,\n perRequestLimits: row.per_request_limits ?? null,\n pricing,\n openRouterPricing,\n architecture: row.architecture,\n topProvider: row.top_provider,\n openRouter: row,\n aliases: buildAliases(row.id, row.name),\n availableOnOpenRouter: true,\n supportsStreaming: outputModalities.includes(\"text\"),\n supportsTools: supportedParameters.includes(\"tools\"),\n supportsReasoning,\n primaryOutputModality: outputModalities[0] ?? \"text\",\n syncedAt,\n syncSource: \"openrouter\",\n };\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-COK34C6P.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|