@runnerpro/backend 1.19.5 → 1.19.7

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/lib/cjs/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.reprocessRecentMedia = exports.processMediaFile = exports.describeImage = exports.transcribeAudio = exports.updateSenderView = exports.saveResponseTime = exports.getPlanificacionPrueba7dias = exports.sendWorkoutToWatch = exports.getDefaultWorkoutImage = exports.generateShareMap = exports.reduceSizeImage = exports.getLetter = exports.getNumberByLetter = exports.appendSheet = exports.writeSheet = exports.findCellByValue = exports.readSheet = exports.NOTION_DATABASES_ID = exports.notionEditPage = exports.notionAddPage = exports.notionGetDatabase = exports.notionGetUsers = exports.getCountNotificaciones = exports.chatExposed = exports.chatApi = exports.chat = exports.getExerciseTranslatedDescription = exports.useTranslation = exports.LANGUAGES = exports.translate = exports.CHANNEL_SLACK = exports.notifySlack = exports.fetchIA = exports.err = exports.sendMail = exports.pool = exports.toPgArray = exports.batchQuery = exports.longRunningQuery = exports.queryWithClient = exports.query = exports.sleep = exports.sendNotification = void 0;
3
+ exports.runWithModels = exports.runWithCostTracking = exports.createBedrockModelFromString = exports.createGoogleModelFromString = exports.createGoogleModel = exports.generateText = exports.generateObject = exports.reprocessRecentMedia = exports.processMediaFile = exports.describeImage = exports.transcribeAudio = exports.updateSenderView = exports.saveResponseTime = exports.getPlanificacionPrueba7dias = exports.sendWorkoutToWatch = exports.getDefaultWorkoutImage = exports.generateShareMap = exports.reduceSizeImage = exports.getLetter = exports.getNumberByLetter = exports.appendSheet = exports.writeSheet = exports.findCellByValue = exports.readSheet = exports.NOTION_DATABASES_ID = exports.notionEditPage = exports.notionAddPage = exports.notionGetDatabase = exports.notionGetUsers = exports.getCountNotificaciones = exports.chatExposed = exports.chatApi = exports.chat = exports.getExerciseTranslatedDescription = exports.useTranslation = exports.LANGUAGES = exports.translate = exports.CHANNEL_SLACK = exports.notifySlack = exports.fetchIA = exports.err = exports.sendMail = exports.pool = exports.toPgArray = exports.batchQuery = exports.longRunningQuery = exports.queryWithClient = exports.query = exports.sleep = exports.sendNotification = void 0;
4
+ exports.calculateCost = exports.MODEL_PRICING = exports.AISTUDIO_PREFIX = exports.FALLBACK_MODELS = exports.PRODUCTION_MODELS = exports.AI_MODELS = exports.MODEL_TIER = void 0;
4
5
  const sendNotification_1 = require("./sendNotification");
5
6
  Object.defineProperty(exports, "sendNotification", { enumerable: true, get: function () { return sendNotification_1.sendNotification; } });
6
7
  const sleep_1 = require("./sleep");
@@ -63,3 +64,18 @@ Object.defineProperty(exports, "transcribeAudio", { enumerable: true, get: funct
63
64
  Object.defineProperty(exports, "describeImage", { enumerable: true, get: function () { return mediaProcessing_1.describeImage; } });
64
65
  Object.defineProperty(exports, "processMediaFile", { enumerable: true, get: function () { return mediaProcessing_1.processMediaFile; } });
65
66
  Object.defineProperty(exports, "reprocessRecentMedia", { enumerable: true, get: function () { return mediaProcessing_1.reprocessRecentMedia; } });
67
+ const prompt_1 = require("./prompt");
68
+ Object.defineProperty(exports, "generateObject", { enumerable: true, get: function () { return prompt_1.generateObject; } });
69
+ Object.defineProperty(exports, "generateText", { enumerable: true, get: function () { return prompt_1.generateText; } });
70
+ Object.defineProperty(exports, "createGoogleModel", { enumerable: true, get: function () { return prompt_1.createGoogleModel; } });
71
+ Object.defineProperty(exports, "createGoogleModelFromString", { enumerable: true, get: function () { return prompt_1.createGoogleModelFromString; } });
72
+ Object.defineProperty(exports, "createBedrockModelFromString", { enumerable: true, get: function () { return prompt_1.createBedrockModelFromString; } });
73
+ Object.defineProperty(exports, "runWithCostTracking", { enumerable: true, get: function () { return prompt_1.runWithCostTracking; } });
74
+ Object.defineProperty(exports, "runWithModels", { enumerable: true, get: function () { return prompt_1.runWithModels; } });
75
+ Object.defineProperty(exports, "MODEL_TIER", { enumerable: true, get: function () { return prompt_1.MODEL_TIER; } });
76
+ Object.defineProperty(exports, "AI_MODELS", { enumerable: true, get: function () { return prompt_1.AI_MODELS; } });
77
+ Object.defineProperty(exports, "PRODUCTION_MODELS", { enumerable: true, get: function () { return prompt_1.PRODUCTION_MODELS; } });
78
+ Object.defineProperty(exports, "FALLBACK_MODELS", { enumerable: true, get: function () { return prompt_1.FALLBACK_MODELS; } });
79
+ Object.defineProperty(exports, "AISTUDIO_PREFIX", { enumerable: true, get: function () { return prompt_1.AISTUDIO_PREFIX; } });
80
+ Object.defineProperty(exports, "MODEL_PRICING", { enumerable: true, get: function () { return prompt_1.MODEL_PRICING; } });
81
+ Object.defineProperty(exports, "calculateCost", { enumerable: true, get: function () { return prompt_1.calculateCost; } });
@@ -0,0 +1,228 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.runWithCostTracking = exports.generateText = exports.generateObject = void 0;
13
+ const ai_1 = require("ai");
14
+ const node_async_hooks_1 = require("node:async_hooks");
15
+ const modelPricing_1 = require("./modelPricing");
16
+ const constants_1 = require("./constants");
17
+ const googleModel_1 = require("./googleModel");
18
+ const bedrockModel_1 = require("./bedrockModel");
19
+ const MIN_RETRIES = 1;
20
+ const costTrackingStorage = new node_async_hooks_1.AsyncLocalStorage();
21
+ /**
22
+ * Indica si conviene saltar inmediatamente al siguiente modelo de la cadena de fallback.
23
+ * Cubre rate limit, cuota, saturación temporal y límites diarios de tokens.
24
+ */
25
+ function shouldUseAlternateModel(error) {
26
+ var _a, _b;
27
+ const msg = (_b = (_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : '';
28
+ return ((error === null || error === void 0 ? void 0 : error.status) === 429 ||
29
+ (error === null || error === void 0 ? void 0 : error.statusCode) === 429 ||
30
+ msg.includes('rate limit') ||
31
+ msg.includes('quota') ||
32
+ msg.includes('high demand') ||
33
+ msg.includes('resource exhausted') ||
34
+ msg.includes('too many'));
35
+ }
36
+ function isBedrockModel(modelName) {
37
+ return modelName === constants_1.BEDROCK_CLAUDE_OPUS || modelName.includes('anthropic.');
38
+ }
39
+ function createFallbackModel(modelName) {
40
+ if (isBedrockModel(modelName)) {
41
+ return (0, bedrockModel_1.createBedrockModelFromString)(modelName);
42
+ }
43
+ return (0, googleModel_1.createGoogleModelFromString)(modelName);
44
+ }
45
+ function extractModelName(model) {
46
+ var _a;
47
+ if (model === null || model === void 0 ? void 0 : model._productionModelName)
48
+ return model._productionModelName;
49
+ if (model === null || model === void 0 ? void 0 : model.modelId)
50
+ return model.modelId;
51
+ if ((_a = model === null || model === void 0 ? void 0 : model.providerMetadata) === null || _a === void 0 ? void 0 : _a.modelId)
52
+ return model.providerMetadata.modelId;
53
+ if (model === null || model === void 0 ? void 0 : model._modelId)
54
+ return model._modelId;
55
+ const modelString = (model === null || model === void 0 ? void 0 : model.toString()) || '';
56
+ if (modelString.includes('gemini-3-flash-preview'))
57
+ return constants_1.PRODUCTION_MODELS.FLASH;
58
+ if (modelString.includes('gemini-3.1-pro-preview'))
59
+ return constants_1.PRODUCTION_MODELS.PRO;
60
+ if (modelString.includes('gemini-3.1-flash-lite-preview'))
61
+ return constants_1.PRODUCTION_MODELS.LITE;
62
+ return constants_1.PRODUCTION_MODELS.FLASH;
63
+ }
64
+ // eslint-disable-next-line no-console
65
+ const log = (...args) => console.error(...args);
66
+ /**
67
+ * Wrapper de generateObject con retry automático y cadena de fallbacks.
68
+ * Calcula el coste de producción de la llamada y lo acumula automáticamente
69
+ * si se ejecuta dentro de runWithCostTracking.
70
+ *
71
+ * Estrategia de resiliencia:
72
+ * - Error de rate limit/cuota → salto inmediato al siguiente fallback
73
+ * - Cualquier otro error → reintento transitorio, si falla → siguiente fallback
74
+ *
75
+ * @param options - Opciones para generateObject (model, schema, system, prompt, temperature, etc.)
76
+ * @returns Objeto generado y coste de la llamada
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * const { object, cost } = await generateObject({
81
+ * model: createGoogleModel('PRO'),
82
+ * schema: myZodSchema,
83
+ * system: 'Eres un asistente',
84
+ * prompt: 'Genera un plan de entrenamiento',
85
+ * });
86
+ * ```
87
+ */
88
+ function generateObject(options) {
89
+ var _a;
90
+ return __awaiter(this, void 0, void 0, function* () {
91
+ let lastError;
92
+ let currentOptions = options;
93
+ const fallbackNames = ((_a = currentOptions.model) === null || _a === void 0 ? void 0 : _a._fallbackModelNames) || [];
94
+ const maxAttempts = (1 + fallbackNames.length) * (1 + MIN_RETRIES);
95
+ let transientRetries = 0;
96
+ let fallbackIdx = 0;
97
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
98
+ try {
99
+ const { object, usage } = yield (0, ai_1.generateObject)(currentOptions);
100
+ const modelName = extractModelName(currentOptions.model);
101
+ const cost = (0, modelPricing_1.calculateCost)(modelName, usage === null || usage === void 0 ? void 0 : usage.inputTokens, usage === null || usage === void 0 ? void 0 : usage.outputTokens);
102
+ const tracker = costTrackingStorage.getStore();
103
+ if (tracker)
104
+ tracker.push(cost);
105
+ return { object, cost };
106
+ }
107
+ catch (error) {
108
+ lastError = error;
109
+ const currentModelLabel = extractModelName(currentOptions.model);
110
+ if (shouldUseAlternateModel(error) && fallbackIdx < fallbackNames.length) {
111
+ const nextFallback = fallbackNames[fallbackIdx++];
112
+ log(`[AI] generateObject — rate limit/cuota en ${currentModelLabel}, salto inmediato a fallback: ${nextFallback}`);
113
+ currentOptions = Object.assign(Object.assign({}, currentOptions), { model: createFallbackModel(nextFallback) });
114
+ transientRetries = 0;
115
+ }
116
+ else if (transientRetries < MIN_RETRIES) {
117
+ transientRetries++;
118
+ log(`[AI] generateObject falló en ${currentModelLabel} (reintento ${transientRetries}/${MIN_RETRIES}): ${lastError === null || lastError === void 0 ? void 0 : lastError.message}`);
119
+ }
120
+ else if (fallbackIdx < fallbackNames.length) {
121
+ const nextFallback = fallbackNames[fallbackIdx++];
122
+ log(`[AI] generateObject — reintentos agotados en ${currentModelLabel}, usando fallback: ${nextFallback}`);
123
+ currentOptions = Object.assign(Object.assign({}, currentOptions), { model: createFallbackModel(nextFallback) });
124
+ transientRetries = 0;
125
+ }
126
+ else {
127
+ break;
128
+ }
129
+ }
130
+ }
131
+ throw lastError;
132
+ });
133
+ }
134
+ exports.generateObject = generateObject;
135
+ /**
136
+ * Wrapper de generateText con retry automático y cadena de fallbacks.
137
+ * Calcula el coste de producción de la llamada y lo acumula automáticamente
138
+ * si se ejecuta dentro de runWithCostTracking.
139
+ *
140
+ * @param options - Opciones para generateText (model, system, prompt, temperature, etc.)
141
+ * @returns Texto generado y coste de la llamada
142
+ *
143
+ * @example
144
+ * ```typescript
145
+ * const { text, cost } = await generateText({
146
+ * model: createGoogleModel('FLASH'),
147
+ * prompt: 'Traduce al inglés: Hola mundo',
148
+ * });
149
+ * ```
150
+ */
151
+ function generateText(options) {
152
+ var _a;
153
+ return __awaiter(this, void 0, void 0, function* () {
154
+ let lastError;
155
+ let currentOptions = options;
156
+ const fallbackNames = ((_a = currentOptions.model) === null || _a === void 0 ? void 0 : _a._fallbackModelNames) || [];
157
+ const maxAttempts = (1 + fallbackNames.length) * (1 + MIN_RETRIES);
158
+ let transientRetries = 0;
159
+ let fallbackIdx = 0;
160
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
161
+ try {
162
+ const { text, usage } = yield (0, ai_1.generateText)(currentOptions);
163
+ const modelName = extractModelName(currentOptions.model);
164
+ const cost = (0, modelPricing_1.calculateCost)(modelName, usage === null || usage === void 0 ? void 0 : usage.inputTokens, usage === null || usage === void 0 ? void 0 : usage.outputTokens);
165
+ const tracker = costTrackingStorage.getStore();
166
+ if (tracker)
167
+ tracker.push(cost);
168
+ return { text: text.trim(), cost };
169
+ }
170
+ catch (error) {
171
+ lastError = error;
172
+ const currentModelLabel = extractModelName(currentOptions.model);
173
+ if (shouldUseAlternateModel(error) && fallbackIdx < fallbackNames.length) {
174
+ const nextFallback = fallbackNames[fallbackIdx++];
175
+ log(`[AI] generateText — rate limit/cuota en ${currentModelLabel}, salto inmediato a fallback: ${nextFallback}`);
176
+ currentOptions = Object.assign(Object.assign({}, currentOptions), { model: createFallbackModel(nextFallback) });
177
+ transientRetries = 0;
178
+ }
179
+ else if (transientRetries < MIN_RETRIES) {
180
+ transientRetries++;
181
+ log(`[AI] generateText falló en ${currentModelLabel} (reintento ${transientRetries}/${MIN_RETRIES}): ${lastError === null || lastError === void 0 ? void 0 : lastError.message}`);
182
+ }
183
+ else if (fallbackIdx < fallbackNames.length) {
184
+ const nextFallback = fallbackNames[fallbackIdx++];
185
+ log(`[AI] generateText — reintentos agotados en ${currentModelLabel}, usando fallback: ${nextFallback}`);
186
+ currentOptions = Object.assign(Object.assign({}, currentOptions), { model: createFallbackModel(nextFallback) });
187
+ transientRetries = 0;
188
+ }
189
+ else {
190
+ break;
191
+ }
192
+ }
193
+ }
194
+ throw lastError;
195
+ });
196
+ }
197
+ exports.generateText = generateText;
198
+ /**
199
+ * Ejecuta una función async acumulando los costes de todas las llamadas a IA.
200
+ * Al finalizar, devuelve el resultado original junto con el coste total agregado.
201
+ *
202
+ * @param fn - Función async a ejecutar
203
+ * @returns Resultado de la función, coste total y número de llamadas
204
+ *
205
+ * @example
206
+ * ```typescript
207
+ * const { result, totalCost, callCount } = await runWithCostTracking(async () => {
208
+ * const { object } = await generateObject({ model: createGoogleModel('PRO'), ... });
209
+ * const { text } = await generateText({ model: createGoogleModel('FLASH'), ... });
210
+ * return { object, text };
211
+ * });
212
+ * // totalCost = { inputTokens: 3500, outputTokens: 1200, cost: 0.0054 }
213
+ * // callCount = 2
214
+ * ```
215
+ */
216
+ function runWithCostTracking(fn) {
217
+ return __awaiter(this, void 0, void 0, function* () {
218
+ const costs = [];
219
+ const result = yield costTrackingStorage.run(costs, fn);
220
+ const totalCost = costs.reduce((acc, c) => ({
221
+ inputTokens: acc.inputTokens + (c.inputTokens || 0),
222
+ outputTokens: acc.outputTokens + (c.outputTokens || 0),
223
+ cost: acc.cost + (c.cost || 0),
224
+ }), { inputTokens: 0, outputTokens: 0, cost: 0 });
225
+ return { result, totalCost, callCount: costs.length };
226
+ });
227
+ }
228
+ exports.runWithCostTracking = runWithCostTracking;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createBedrockModelFromString = void 0;
4
+ const amazon_bedrock_1 = require("@ai-sdk/amazon-bedrock");
5
+ /**
6
+ * Crea una instancia del provider de Amazon Bedrock con las credenciales configuradas.
7
+ * Usa variables de entorno estándar de AWS (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY).
8
+ *
9
+ * @returns Provider de Bedrock configurado
10
+ */
11
+ function getBedrockProvider() {
12
+ return (0, amazon_bedrock_1.createAmazonBedrock)({
13
+ region: 'us-east-1',
14
+ accessKeyId: process.env.AWS_ACCESS_KEY_ID,
15
+ secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
16
+ });
17
+ }
18
+ /**
19
+ * Crea una instancia del modelo de Bedrock a partir de un model ID.
20
+ * Etiqueta el objeto con _productionModelName para el cálculo de costes.
21
+ *
22
+ * @param modelId - ID del modelo en Bedrock (ej: 'us.anthropic.claude-opus-4-6-v1')
23
+ * @returns Instancia del modelo de Bedrock compatible con AI SDK
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * const model = createBedrockModelFromString('us.anthropic.claude-opus-4-6-v1');
28
+ * const { object } = await generateObject({ model, schema, prompt });
29
+ * ```
30
+ */
31
+ function createBedrockModelFromString(modelId) {
32
+ const bedrock = getBedrockProvider();
33
+ const model = bedrock(modelId);
34
+ model._productionModelName = modelId;
35
+ model._fallbackModelNames = [];
36
+ return model;
37
+ }
38
+ exports.createBedrockModelFromString = createBedrockModelFromString;
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runWithModels = exports.AISTUDIO_PREFIX = exports.MODEL_TIER = exports.BEDROCK_CLAUDE_SONNET = exports.BEDROCK_CLAUDE_OPUS = exports.FALLBACK_MODELS = exports.TRIAL_MODELS = exports.FAST_MODELS = exports.SEMI_MODELS = exports.PRODUCTION_MODELS = exports.AI_MODELS = void 0;
4
+ const node_async_hooks_1 = require("node:async_hooks");
5
+ const modelContextStorage = new node_async_hooks_1.AsyncLocalStorage();
6
+ const BEDROCK_CLAUDE_OPUS = 'us.anthropic.claude-opus-4-6-v1';
7
+ exports.BEDROCK_CLAUDE_OPUS = BEDROCK_CLAUDE_OPUS;
8
+ const BEDROCK_CLAUDE_SONNET = 'us.anthropic.claude-sonnet-4-6';
9
+ exports.BEDROCK_CLAUDE_SONNET = BEDROCK_CLAUDE_SONNET;
10
+ const PRODUCTION_MODELS = {
11
+ FLASH: 'gemini-3-flash-preview',
12
+ PRO: 'gemini-3.1-pro-preview',
13
+ LITE: 'gemini-3.1-flash-lite-preview',
14
+ };
15
+ exports.PRODUCTION_MODELS = PRODUCTION_MODELS;
16
+ const SEMI_MODELS = {
17
+ FLASH: 'gemini-3-flash-preview',
18
+ PRO: 'gemini-3-flash-preview',
19
+ LITE: 'gemini-3-flash-preview',
20
+ };
21
+ exports.SEMI_MODELS = SEMI_MODELS;
22
+ const FAST_MODELS = {
23
+ FLASH: 'gemini-3.1-flash-lite-preview',
24
+ PRO: 'gemini-3.1-flash-lite-preview',
25
+ LITE: 'gemini-3.1-flash-lite-preview',
26
+ };
27
+ exports.FAST_MODELS = FAST_MODELS;
28
+ // Cada modelo baja un escalón: PRO→FLASH, FLASH→LITE, LITE→LITE
29
+ const TRIAL_MODELS = {
30
+ FLASH: PRODUCTION_MODELS.LITE,
31
+ PRO: PRODUCTION_MODELS.FLASH,
32
+ LITE: PRODUCTION_MODELS.LITE,
33
+ };
34
+ exports.TRIAL_MODELS = TRIAL_MODELS;
35
+ const AISTUDIO_PREFIX = 'aistudio:';
36
+ exports.AISTUDIO_PREFIX = AISTUDIO_PREFIX;
37
+ const FALLBACK_MODELS = {
38
+ FLASH: [`${AISTUDIO_PREFIX}gemini-3-flash-preview`, 'gemini-2.5-flash', `${AISTUDIO_PREFIX}gemini-2.5-flash`, 'gemini-3.1-flash-lite-preview', BEDROCK_CLAUDE_SONNET],
39
+ PRO: [`${AISTUDIO_PREFIX}gemini-3.1-pro-preview`, 'gemini-2.5-pro', `${AISTUDIO_PREFIX}gemini-2.5-pro`, BEDROCK_CLAUDE_OPUS, 'gemini-3-flash-preview', `${AISTUDIO_PREFIX}gemini-3-flash-preview`, 'gemini-2.5-flash', `${AISTUDIO_PREFIX}gemini-2.5-flash`, 'gemini-3.1-flash-lite-preview'],
40
+ LITE: [`${AISTUDIO_PREFIX}gemini-3.1-flash-lite-preview`, 'gemini-2.5-flash-lite', `${AISTUDIO_PREFIX}gemini-2.5-flash-lite`],
41
+ };
42
+ exports.FALLBACK_MODELS = FALLBACK_MODELS;
43
+ const MODEL_TIER = {
44
+ PRODUCTION: 'PRODUCTION',
45
+ SEMI: 'SEMI',
46
+ FAST: 'FAST',
47
+ TRIAL: 'TRIAL',
48
+ };
49
+ exports.MODEL_TIER = MODEL_TIER;
50
+ const MODELS_BY_TIER = {
51
+ [MODEL_TIER.PRODUCTION]: PRODUCTION_MODELS,
52
+ [MODEL_TIER.SEMI]: SEMI_MODELS,
53
+ [MODEL_TIER.FAST]: FAST_MODELS,
54
+ [MODEL_TIER.TRIAL]: TRIAL_MODELS,
55
+ };
56
+ /**
57
+ * Proxy que resuelve dinámicamente los modelos según el contexto de ejecución.
58
+ *
59
+ * - Dentro de runWithModels(PRODUCTION): modelos de producción (FLASH, PRO, LITE)
60
+ * - Dentro de runWithModels(SEMI): todos FLASH
61
+ * - Dentro de runWithModels(FAST): todos LITE
62
+ * - Dentro de runWithModels(TRIAL): cada modelo baja un escalón (PRO→FLASH, FLASH→LITE, LITE→LITE)
63
+ * - Fuera de runWithModels: modelos de producción por defecto
64
+ */
65
+ const AI_MODELS = new Proxy({}, {
66
+ get(_, prop) {
67
+ const ctx = modelContextStorage.getStore();
68
+ if (ctx === null || ctx === void 0 ? void 0 : ctx.modelTier) {
69
+ return (MODELS_BY_TIER[ctx.modelTier] || PRODUCTION_MODELS)[prop];
70
+ }
71
+ return PRODUCTION_MODELS[prop];
72
+ },
73
+ });
74
+ exports.AI_MODELS = AI_MODELS;
75
+ /**
76
+ * Ejecuta una función asíncrona con un conjunto específico de modelos.
77
+ * Usa AsyncLocalStorage para propagar la elección sin pasar parámetros manualmente.
78
+ *
79
+ * @param modelTier - Tier de modelos a usar: 'PRODUCTION', 'SEMI', 'FAST' o 'TRIAL'
80
+ * @param fn - Función asíncrona a ejecutar
81
+ * @returns Resultado de la función ejecutada
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * const result = await runWithModels('PRODUCTION', async () => {
86
+ * return await generateObject({ model: createGoogleModel('PRO'), ... });
87
+ * });
88
+ * ```
89
+ */
90
+ function runWithModels(modelTier, fn) {
91
+ return modelContextStorage.run({ modelTier }, fn);
92
+ }
93
+ exports.runWithModels = runWithModels;
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createGoogleModelFromString = exports.createGoogleModel = void 0;
4
+ const google_vertex_1 = require("@ai-sdk/google-vertex");
5
+ const google_1 = require("@ai-sdk/google");
6
+ const constants_1 = require("./constants");
7
+ const bedrockModel_1 = require("./bedrockModel");
8
+ const vertex = (0, google_vertex_1.createVertex)({
9
+ project: process.env.GOOGLE_VERTEX_PROJECT || process.env.PROJECT_ID,
10
+ location: process.env.GOOGLE_VERTEX_LOCATION || 'global',
11
+ });
12
+ /**
13
+ * Obtiene la API key de Google AI Studio desde las variables de entorno
14
+ *
15
+ * @returns API key
16
+ * @throws Error si no se encuentra la API key
17
+ */
18
+ function getAIStudioApiKey() {
19
+ const apiKey = process.env.GOOGLE_GENERATIVE_AI_API_KEY || process.env.GEMINI_API_KEY;
20
+ if (!apiKey) {
21
+ throw new Error('Google AI Studio API key is missing. Set GOOGLE_GENERATIVE_AI_API_KEY or GEMINI_API_KEY.');
22
+ }
23
+ return apiKey;
24
+ }
25
+ /**
26
+ * Crea una instancia del modelo según su key, detectando automáticamente
27
+ * el provider (Vertex AI o Bedrock). Resuelve qué modelo ejecutar según el entorno
28
+ * (producción/prueba) y etiqueta el objeto para el cálculo de costes.
29
+ *
30
+ * @param modelKey - Clave del modelo: 'FLASH', 'PRO' o 'LITE'
31
+ * @returns Instancia del modelo con _productionModelName y _fallbackModelNames
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * const model = createGoogleModel('PRO');
36
+ * const { object } = await generateObject({ model, schema, prompt });
37
+ * ```
38
+ */
39
+ function createGoogleModel(modelKey = 'FLASH') {
40
+ var _a;
41
+ const runtimeModelName = constants_1.AI_MODELS[modelKey];
42
+ const model = runtimeModelName.includes('anthropic.')
43
+ ? (0, bedrockModel_1.createBedrockModelFromString)(runtimeModelName)
44
+ : vertex(runtimeModelName);
45
+ model._productionModelName = constants_1.PRODUCTION_MODELS[modelKey];
46
+ model._fallbackModelNames = (_a = constants_1.FALLBACK_MODELS[modelKey]) !== null && _a !== void 0 ? _a : [];
47
+ return model;
48
+ }
49
+ exports.createGoogleModel = createGoogleModel;
50
+ /**
51
+ * Crea una instancia del modelo a partir de un nombre exacto (string).
52
+ * Si el nombre tiene prefijo "aistudio:", usa Google AI Studio (API key).
53
+ * Si no, usa Vertex AI (Service Account).
54
+ *
55
+ * @param modelName - Nombre del modelo, opcionalmente con prefijo "aistudio:"
56
+ * @returns Instancia del modelo compatible con AI SDK
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * const model = createGoogleModelFromString('gemini-2.5-flash');
61
+ * const studioModel = createGoogleModelFromString('aistudio:gemini-2.5-flash');
62
+ * ```
63
+ */
64
+ function createGoogleModelFromString(modelName) {
65
+ const isAIStudio = modelName.startsWith(constants_1.AISTUDIO_PREFIX);
66
+ const cleanName = isAIStudio ? modelName.slice(constants_1.AISTUDIO_PREFIX.length) : modelName;
67
+ const aiStudio = isAIStudio ? (0, google_1.createGoogleGenerativeAI)({ apiKey: getAIStudioApiKey() }) : null;
68
+ const model = aiStudio ? aiStudio(cleanName) : vertex(cleanName);
69
+ model._productionModelName = cleanName;
70
+ model._fallbackModelNames = [];
71
+ return model;
72
+ }
73
+ exports.createGoogleModelFromString = createGoogleModelFromString;
@@ -1,89 +1,27 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.createGoogleModel = exports.generateText = void 0;
13
- const ai_1 = require("ai");
14
- const google_1 = require("@ai-sdk/google");
15
- const AI_MODELS = {
16
- LITE: 'gemini-3.1-flash-lite-preview',
17
- FLASH: 'gemini-3-flash-preview',
18
- PRO: 'gemini-3.1-pro-preview',
19
- };
20
- const MAX_RETRIES = 1;
21
- /**
22
- * Crea una instancia del modelo de Google Gemini con la API key configurada
23
- *
24
- * @param modelKey - Clave del modelo: 'LITE' (rápido/barato), 'FLASH' (equilibrado), 'PRO' (potente)
25
- * @returns Instancia del modelo configurado para usar con generateText
26
- *
27
- * @example
28
- * ```typescript
29
- * const model = createGoogleModel('LITE');
30
- * const { text } = await generateText({ model, prompt: 'Hola' });
31
- * ```
32
- */
33
- function createGoogleModel(modelKey = 'FLASH') {
34
- return (0, google_1.google)(AI_MODELS[modelKey]);
35
- }
36
- exports.createGoogleModel = createGoogleModel;
37
- /**
38
- * Wrapper de generateText del Vercel AI SDK con retry automático (1 reintento)
39
- * Soporta texto simple, system prompt y contenido multimodal (imágenes, audio)
40
- *
41
- * @param options - Opciones del Vercel AI SDK: model, system, prompt, messages, temperature, etc.
42
- * @returns Promise<{ text: string }> - Texto generado por la IA
43
- *
44
- * @example
45
- * ```typescript
46
- * // Solo texto
47
- * const { text } = await generateText({
48
- * model: createGoogleModel('LITE'),
49
- * prompt: 'Traduce al inglés: Hola mundo',
50
- * });
51
- *
52
- * // Con system prompt
53
- * const { text } = await generateText({
54
- * model: createGoogleModel('FLASH'),
55
- * system: 'Eres un corrector ortográfico',
56
- * prompt: 'ola como estas',
57
- * });
58
- *
59
- * // Multimodal (imagen)
60
- * const { text } = await generateText({
61
- * model: createGoogleModel('PRO'),
62
- * messages: [{
63
- * role: 'user',
64
- * content: [
65
- * { type: 'file', data: imageBuffer, mimeType: 'image/jpeg' },
66
- * { type: 'text', text: 'Describe esta imagen' },
67
- * ],
68
- * }],
69
- * });
70
- * ```
71
- */
72
- function generateText(options) {
73
- return __awaiter(this, void 0, void 0, function* () {
74
- for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
75
- try {
76
- const { text } = yield (0, ai_1.generateText)(options);
77
- return { text: text.trim() };
78
- }
79
- catch (error) {
80
- if (attempt < MAX_RETRIES)
81
- continue;
82
- throw error;
83
- }
84
- }
85
- // Fallback (nunca debería llegar aquí)
86
- throw new Error('generateText: reintentos agotados');
87
- });
88
- }
89
- exports.generateText = generateText;
3
+ exports.calculateCost = exports.MODEL_PRICING = exports.AISTUDIO_PREFIX = exports.BEDROCK_CLAUDE_SONNET = exports.BEDROCK_CLAUDE_OPUS = exports.FALLBACK_MODELS = exports.TRIAL_MODELS = exports.FAST_MODELS = exports.SEMI_MODELS = exports.PRODUCTION_MODELS = exports.AI_MODELS = exports.runWithModels = exports.MODEL_TIER = exports.createBedrockModelFromString = exports.createGoogleModelFromString = exports.createGoogleModel = exports.runWithCostTracking = exports.generateText = exports.generateObject = void 0;
4
+ const ai_1 = require("./ai");
5
+ Object.defineProperty(exports, "generateObject", { enumerable: true, get: function () { return ai_1.generateObject; } });
6
+ Object.defineProperty(exports, "generateText", { enumerable: true, get: function () { return ai_1.generateText; } });
7
+ Object.defineProperty(exports, "runWithCostTracking", { enumerable: true, get: function () { return ai_1.runWithCostTracking; } });
8
+ const googleModel_1 = require("./googleModel");
9
+ Object.defineProperty(exports, "createGoogleModel", { enumerable: true, get: function () { return googleModel_1.createGoogleModel; } });
10
+ Object.defineProperty(exports, "createGoogleModelFromString", { enumerable: true, get: function () { return googleModel_1.createGoogleModelFromString; } });
11
+ const constants_1 = require("./constants");
12
+ Object.defineProperty(exports, "AI_MODELS", { enumerable: true, get: function () { return constants_1.AI_MODELS; } });
13
+ Object.defineProperty(exports, "PRODUCTION_MODELS", { enumerable: true, get: function () { return constants_1.PRODUCTION_MODELS; } });
14
+ Object.defineProperty(exports, "SEMI_MODELS", { enumerable: true, get: function () { return constants_1.SEMI_MODELS; } });
15
+ Object.defineProperty(exports, "FAST_MODELS", { enumerable: true, get: function () { return constants_1.FAST_MODELS; } });
16
+ Object.defineProperty(exports, "TRIAL_MODELS", { enumerable: true, get: function () { return constants_1.TRIAL_MODELS; } });
17
+ Object.defineProperty(exports, "FALLBACK_MODELS", { enumerable: true, get: function () { return constants_1.FALLBACK_MODELS; } });
18
+ Object.defineProperty(exports, "BEDROCK_CLAUDE_OPUS", { enumerable: true, get: function () { return constants_1.BEDROCK_CLAUDE_OPUS; } });
19
+ Object.defineProperty(exports, "BEDROCK_CLAUDE_SONNET", { enumerable: true, get: function () { return constants_1.BEDROCK_CLAUDE_SONNET; } });
20
+ Object.defineProperty(exports, "MODEL_TIER", { enumerable: true, get: function () { return constants_1.MODEL_TIER; } });
21
+ Object.defineProperty(exports, "AISTUDIO_PREFIX", { enumerable: true, get: function () { return constants_1.AISTUDIO_PREFIX; } });
22
+ Object.defineProperty(exports, "runWithModels", { enumerable: true, get: function () { return constants_1.runWithModels; } });
23
+ const modelPricing_1 = require("./modelPricing");
24
+ Object.defineProperty(exports, "MODEL_PRICING", { enumerable: true, get: function () { return modelPricing_1.MODEL_PRICING; } });
25
+ Object.defineProperty(exports, "calculateCost", { enumerable: true, get: function () { return modelPricing_1.calculateCost; } });
26
+ const bedrockModel_1 = require("./bedrockModel");
27
+ Object.defineProperty(exports, "createBedrockModelFromString", { enumerable: true, get: function () { return bedrockModel_1.createBedrockModelFromString; } });
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calculateCost = exports.MODEL_PRICING = void 0;
4
+ const constants_1 = require("./constants");
5
+ /**
6
+ * Precios por millón de tokens de entrada y salida para cada modelo.
7
+ * Los precios están en USD.
8
+ */
9
+ const MODEL_PRICING = {
10
+ [constants_1.PRODUCTION_MODELS.FLASH]: {
11
+ inputTokenPrice: 0.5,
12
+ outputTokenPrice: 3,
13
+ },
14
+ [constants_1.PRODUCTION_MODELS.PRO]: {
15
+ inputTokenPrice: 2,
16
+ outputTokenPrice: 12,
17
+ },
18
+ [constants_1.FAST_MODELS.LITE]: {
19
+ inputTokenPrice: 0.25,
20
+ outputTokenPrice: 1.5,
21
+ },
22
+ [constants_1.BEDROCK_CLAUDE_OPUS]: {
23
+ inputTokenPrice: 5,
24
+ outputTokenPrice: 25,
25
+ },
26
+ };
27
+ exports.MODEL_PRICING = MODEL_PRICING;
28
+ /**
29
+ * Calcula el costo de una llamada a IA basado en tokens de entrada y salida
30
+ *
31
+ * @param modelName - Nombre del modelo (ej: 'gemini-3-flash-preview')
32
+ * @param promptTokens - Tokens de entrada
33
+ * @param completionTokens - Tokens de salida
34
+ * @returns Coste en USD con desglose de tokens
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * const cost = calculateCost('gemini-3-flash-preview', 1500, 800);
39
+ * // { inputTokens: 1500, outputTokens: 800, cost: 0.00315 }
40
+ * ```
41
+ */
42
+ function calculateCost(modelName, promptTokens, completionTokens) {
43
+ const pricing = MODEL_PRICING[modelName];
44
+ if (!pricing) {
45
+ return {
46
+ inputTokens: promptTokens || 0,
47
+ outputTokens: completionTokens || 0,
48
+ cost: 0,
49
+ };
50
+ }
51
+ const inputCost = ((promptTokens || 0) * pricing.inputTokenPrice) / 1000000;
52
+ const outputCost = ((completionTokens || 0) * pricing.outputTokenPrice) / 1000000;
53
+ return {
54
+ inputTokens: promptTokens || 0,
55
+ outputTokens: completionTokens || 0,
56
+ cost: inputCost + outputCost,
57
+ };
58
+ }
59
+ exports.calculateCost = calculateCost;
@@ -17,5 +17,6 @@ import { getPlanificacionPrueba7dias } from './workout/planificacionPrueba7dias'
17
17
  import { saveResponseTime } from './chat/saveResponseTime';
18
18
  import { updateSenderView } from './chat/api/conversation';
19
19
  import { transcribeAudio, describeImage, processMediaFile, reprocessRecentMedia } from './mediaProcessing';
20
- export { sendNotification, sleep, query, queryWithClient, longRunningQuery, batchQuery, toPgArray, pool, sendMail, err, fetchIA, notifySlack, CHANNEL_SLACK, translate, LANGUAGES, useTranslation, getExerciseTranslatedDescription, chat, chatApi, chatExposed, getCountNotificaciones, notionGetUsers, notionGetDatabase, notionAddPage, notionEditPage, NOTION_DATABASES_ID, readSheet, findCellByValue, writeSheet, appendSheet, getNumberByLetter, getLetter, reduceSizeImage, generateShareMap, getDefaultWorkoutImage, sendWorkoutToWatch, getPlanificacionPrueba7dias, saveResponseTime, updateSenderView, transcribeAudio, describeImage, processMediaFile, reprocessRecentMedia, };
20
+ import { generateObject, generateText, createGoogleModel, createGoogleModelFromString, createBedrockModelFromString, runWithCostTracking, runWithModels, MODEL_TIER, AI_MODELS, PRODUCTION_MODELS, FALLBACK_MODELS, AISTUDIO_PREFIX, MODEL_PRICING, calculateCost } from './prompt';
21
+ export { sendNotification, sleep, query, queryWithClient, longRunningQuery, batchQuery, toPgArray, pool, sendMail, err, fetchIA, notifySlack, CHANNEL_SLACK, translate, LANGUAGES, useTranslation, getExerciseTranslatedDescription, chat, chatApi, chatExposed, getCountNotificaciones, notionGetUsers, notionGetDatabase, notionAddPage, notionEditPage, NOTION_DATABASES_ID, readSheet, findCellByValue, writeSheet, appendSheet, getNumberByLetter, getLetter, reduceSizeImage, generateShareMap, getDefaultWorkoutImage, sendWorkoutToWatch, getPlanificacionPrueba7dias, saveResponseTime, updateSenderView, transcribeAudio, describeImage, processMediaFile, reprocessRecentMedia, generateObject, generateText, createGoogleModel, createGoogleModelFromString, createBedrockModelFromString, runWithCostTracking, runWithModels, MODEL_TIER, AI_MODELS, PRODUCTION_MODELS, FALLBACK_MODELS, AISTUDIO_PREFIX, MODEL_PRICING, calculateCost, };
21
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC7F,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,gCAAgC,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,QAAQ,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,aAAa,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACjH,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,UAAU,EAAE,WAAW,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAClH,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE3G,OAAO,EACL,gBAAgB,EAChB,KAAK,EACL,KAAK,EACL,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,SAAS,EACT,IAAI,EACJ,QAAQ,EACR,GAAG,EACH,OAAO,EACP,WAAW,EACX,aAAa,EACb,SAAS,EACT,SAAS,EACT,cAAc,EACd,gCAAgC,EAChC,IAAI,EACJ,OAAO,EACP,WAAW,EACX,sBAAsB,EACtB,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,SAAS,EACT,eAAe,EACf,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,EAClB,2BAA2B,EAC3B,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,oBAAoB,GACrB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC7F,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,gCAAgC,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,QAAQ,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,aAAa,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACjH,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,UAAU,EAAE,WAAW,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAClH,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC3G,OAAO,EACL,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,2BAA2B,EAC3B,4BAA4B,EAC5B,mBAAmB,EACnB,aAAa,EACb,UAAU,EACV,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,aAAa,EACb,aAAa,EACd,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,gBAAgB,EAChB,KAAK,EACL,KAAK,EACL,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,SAAS,EACT,IAAI,EACJ,QAAQ,EACR,GAAG,EACH,OAAO,EACP,WAAW,EACX,aAAa,EACb,SAAS,EACT,SAAS,EACT,cAAc,EACd,gCAAgC,EAChC,IAAI,EACJ,OAAO,EACP,WAAW,EACX,sBAAsB,EACtB,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,SAAS,EACT,eAAe,EACf,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,EAClB,2BAA2B,EAC3B,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,2BAA2B,EAC3B,4BAA4B,EAC5B,mBAAmB,EACnB,aAAa,EACb,UAAU,EACV,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,aAAa,EACb,aAAa,GACd,CAAC"}
@@ -0,0 +1,73 @@
1
+ import { generateObject as originalGenerateObject, generateText as originalGenerateText } from 'ai';
2
+ import { type CostResult } from './modelPricing';
3
+ /**
4
+ * Wrapper de generateObject con retry automático y cadena de fallbacks.
5
+ * Calcula el coste de producción de la llamada y lo acumula automáticamente
6
+ * si se ejecuta dentro de runWithCostTracking.
7
+ *
8
+ * Estrategia de resiliencia:
9
+ * - Error de rate limit/cuota → salto inmediato al siguiente fallback
10
+ * - Cualquier otro error → reintento transitorio, si falla → siguiente fallback
11
+ *
12
+ * @param options - Opciones para generateObject (model, schema, system, prompt, temperature, etc.)
13
+ * @returns Objeto generado y coste de la llamada
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const { object, cost } = await generateObject({
18
+ * model: createGoogleModel('PRO'),
19
+ * schema: myZodSchema,
20
+ * system: 'Eres un asistente',
21
+ * prompt: 'Genera un plan de entrenamiento',
22
+ * });
23
+ * ```
24
+ */
25
+ declare function generateObject(options: Parameters<typeof originalGenerateObject>[0]): Promise<{
26
+ object: any;
27
+ cost: CostResult;
28
+ }>;
29
+ /**
30
+ * Wrapper de generateText con retry automático y cadena de fallbacks.
31
+ * Calcula el coste de producción de la llamada y lo acumula automáticamente
32
+ * si se ejecuta dentro de runWithCostTracking.
33
+ *
34
+ * @param options - Opciones para generateText (model, system, prompt, temperature, etc.)
35
+ * @returns Texto generado y coste de la llamada
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * const { text, cost } = await generateText({
40
+ * model: createGoogleModel('FLASH'),
41
+ * prompt: 'Traduce al inglés: Hola mundo',
42
+ * });
43
+ * ```
44
+ */
45
+ declare function generateText(options: Parameters<typeof originalGenerateText>[0]): Promise<{
46
+ text: string;
47
+ cost: CostResult;
48
+ }>;
49
+ /**
50
+ * Ejecuta una función async acumulando los costes de todas las llamadas a IA.
51
+ * Al finalizar, devuelve el resultado original junto con el coste total agregado.
52
+ *
53
+ * @param fn - Función async a ejecutar
54
+ * @returns Resultado de la función, coste total y número de llamadas
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * const { result, totalCost, callCount } = await runWithCostTracking(async () => {
59
+ * const { object } = await generateObject({ model: createGoogleModel('PRO'), ... });
60
+ * const { text } = await generateText({ model: createGoogleModel('FLASH'), ... });
61
+ * return { object, text };
62
+ * });
63
+ * // totalCost = { inputTokens: 3500, outputTokens: 1200, cost: 0.0054 }
64
+ * // callCount = 2
65
+ * ```
66
+ */
67
+ declare function runWithCostTracking<T>(fn: () => Promise<T>): Promise<{
68
+ result: T;
69
+ totalCost: CostResult;
70
+ callCount: number;
71
+ }>;
72
+ export { generateObject, generateText, runWithCostTracking };
73
+ //# sourceMappingURL=ai.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../../../../src/prompt/ai.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,IAAI,sBAAsB,EAAE,YAAY,IAAI,oBAAoB,EAAE,MAAM,IAAI,CAAC;AAEpG,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAsDhE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,iBAAe,cAAc,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;IAAE,MAAM,EAAE,GAAG,CAAC;IAAC,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,CAyC/H;AAED;;;;;;;;;;;;;;;GAeG;AACH,iBAAe,YAAY,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,CAyC5H;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,iBAAe,mBAAmB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;IAAE,MAAM,EAAE,CAAC,CAAC;IAAC,SAAS,EAAE,UAAU,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAc5H;AAED,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,mBAAmB,EAAE,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Crea una instancia del modelo de Bedrock a partir de un model ID.
3
+ * Etiqueta el objeto con _productionModelName para el cálculo de costes.
4
+ *
5
+ * @param modelId - ID del modelo en Bedrock (ej: 'us.anthropic.claude-opus-4-6-v1')
6
+ * @returns Instancia del modelo de Bedrock compatible con AI SDK
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * const model = createBedrockModelFromString('us.anthropic.claude-opus-4-6-v1');
11
+ * const { object } = await generateObject({ model, schema, prompt });
12
+ * ```
13
+ */
14
+ declare function createBedrockModelFromString(modelId: string): any;
15
+ export { createBedrockModelFromString };
16
+ //# sourceMappingURL=bedrockModel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bedrockModel.d.ts","sourceRoot":"","sources":["../../../../src/prompt/bedrockModel.ts"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;GAYG;AACH,iBAAS,4BAA4B,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAM1D;AAED,OAAO,EAAE,4BAA4B,EAAE,CAAC"}
@@ -0,0 +1,44 @@
1
+ type ModelKey = 'FLASH' | 'PRO' | 'LITE';
2
+ declare const BEDROCK_CLAUDE_OPUS = "us.anthropic.claude-opus-4-6-v1";
3
+ declare const BEDROCK_CLAUDE_SONNET = "us.anthropic.claude-sonnet-4-6";
4
+ declare const PRODUCTION_MODELS: Record<ModelKey, string>;
5
+ declare const SEMI_MODELS: Record<ModelKey, string>;
6
+ declare const FAST_MODELS: Record<ModelKey, string>;
7
+ declare const TRIAL_MODELS: Record<ModelKey, string>;
8
+ declare const AISTUDIO_PREFIX = "aistudio:";
9
+ declare const FALLBACK_MODELS: Record<ModelKey, string[]>;
10
+ declare const MODEL_TIER: {
11
+ readonly PRODUCTION: "PRODUCTION";
12
+ readonly SEMI: "SEMI";
13
+ readonly FAST: "FAST";
14
+ readonly TRIAL: "TRIAL";
15
+ };
16
+ type ModelTierValue = (typeof MODEL_TIER)[keyof typeof MODEL_TIER];
17
+ /**
18
+ * Proxy que resuelve dinámicamente los modelos según el contexto de ejecución.
19
+ *
20
+ * - Dentro de runWithModels(PRODUCTION): modelos de producción (FLASH, PRO, LITE)
21
+ * - Dentro de runWithModels(SEMI): todos FLASH
22
+ * - Dentro de runWithModels(FAST): todos LITE
23
+ * - Dentro de runWithModels(TRIAL): cada modelo baja un escalón (PRO→FLASH, FLASH→LITE, LITE→LITE)
24
+ * - Fuera de runWithModels: modelos de producción por defecto
25
+ */
26
+ declare const AI_MODELS: Record<ModelKey, string>;
27
+ /**
28
+ * Ejecuta una función asíncrona con un conjunto específico de modelos.
29
+ * Usa AsyncLocalStorage para propagar la elección sin pasar parámetros manualmente.
30
+ *
31
+ * @param modelTier - Tier de modelos a usar: 'PRODUCTION', 'SEMI', 'FAST' o 'TRIAL'
32
+ * @param fn - Función asíncrona a ejecutar
33
+ * @returns Resultado de la función ejecutada
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * const result = await runWithModels('PRODUCTION', async () => {
38
+ * return await generateObject({ model: createGoogleModel('PRO'), ... });
39
+ * });
40
+ * ```
41
+ */
42
+ declare function runWithModels<T>(modelTier: ModelTierValue, fn: () => Promise<T>): Promise<T>;
43
+ export { ModelKey, ModelTierValue, AI_MODELS, PRODUCTION_MODELS, SEMI_MODELS, FAST_MODELS, TRIAL_MODELS, FALLBACK_MODELS, BEDROCK_CLAUDE_OPUS, BEDROCK_CLAUDE_SONNET, MODEL_TIER, AISTUDIO_PREFIX, runWithModels, };
44
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/prompt/constants.ts"],"names":[],"mappings":"AAEA,KAAK,QAAQ,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;AAIzC,QAAA,MAAM,mBAAmB,oCAAoC,CAAC;AAC9D,QAAA,MAAM,qBAAqB,mCAAmC,CAAC;AAE/D,QAAA,MAAM,iBAAiB,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAI/C,CAAC;AAEF,QAAA,MAAM,WAAW,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAIzC,CAAC;AAEF,QAAA,MAAM,WAAW,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAIzC,CAAC;AAGF,QAAA,MAAM,YAAY,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAI1C,CAAC;AAEF,QAAA,MAAM,eAAe,cAAc,CAAC;AAEpC,QAAA,MAAM,eAAe,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,CAI/C,CAAC;AAEF,QAAA,MAAM,UAAU;;;;;CAKN,CAAC;AAEX,KAAK,cAAc,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AASnE;;;;;;;;GAQG;AACH,QAAA,MAAM,SAAS,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAQtC,CAAC;AAEH;;;;;;;;;;;;;;GAcG;AACH,iBAAS,aAAa,CAAC,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAErF;AAED,OAAO,EACL,QAAQ,EACR,cAAc,EACd,SAAS,EACT,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,qBAAqB,EACrB,UAAU,EACV,eAAe,EACf,aAAa,GACd,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { type ModelKey } from './constants';
2
+ /**
3
+ * Crea una instancia del modelo según su key, detectando automáticamente
4
+ * el provider (Vertex AI o Bedrock). Resuelve qué modelo ejecutar según el entorno
5
+ * (producción/prueba) y etiqueta el objeto para el cálculo de costes.
6
+ *
7
+ * @param modelKey - Clave del modelo: 'FLASH', 'PRO' o 'LITE'
8
+ * @returns Instancia del modelo con _productionModelName y _fallbackModelNames
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const model = createGoogleModel('PRO');
13
+ * const { object } = await generateObject({ model, schema, prompt });
14
+ * ```
15
+ */
16
+ declare function createGoogleModel(modelKey?: ModelKey): any;
17
+ /**
18
+ * Crea una instancia del modelo a partir de un nombre exacto (string).
19
+ * Si el nombre tiene prefijo "aistudio:", usa Google AI Studio (API key).
20
+ * Si no, usa Vertex AI (Service Account).
21
+ *
22
+ * @param modelName - Nombre del modelo, opcionalmente con prefijo "aistudio:"
23
+ * @returns Instancia del modelo compatible con AI SDK
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * const model = createGoogleModelFromString('gemini-2.5-flash');
28
+ * const studioModel = createGoogleModelFromString('aistudio:gemini-2.5-flash');
29
+ * ```
30
+ */
31
+ declare function createGoogleModelFromString(modelName: string): any;
32
+ export { createGoogleModel, createGoogleModelFromString };
33
+ //# sourceMappingURL=googleModel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"googleModel.d.ts","sourceRoot":"","sources":["../../../../src/prompt/googleModel.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAsB5G;;;;;;;;;;;;;GAaG;AACH,iBAAS,iBAAiB,CAAC,QAAQ,GAAE,QAAkB,GAAG,GAAG,CAW5D;AAED;;;;;;;;;;;;;GAaG;AACH,iBAAS,2BAA2B,CAAC,SAAS,EAAE,MAAM,GAAG,GAAG,CAU3D;AAED,OAAO,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,CAAC"}
@@ -1,55 +1,7 @@
1
- import { generateText as originalGenerateText } from 'ai';
2
- type ModelKey = 'LITE' | 'FLASH' | 'PRO';
3
- /**
4
- * Crea una instancia del modelo de Google Gemini con la API key configurada
5
- *
6
- * @param modelKey - Clave del modelo: 'LITE' (rápido/barato), 'FLASH' (equilibrado), 'PRO' (potente)
7
- * @returns Instancia del modelo configurado para usar con generateText
8
- *
9
- * @example
10
- * ```typescript
11
- * const model = createGoogleModel('LITE');
12
- * const { text } = await generateText({ model, prompt: 'Hola' });
13
- * ```
14
- */
15
- declare function createGoogleModel(modelKey?: ModelKey): import("@ai-sdk/provider").LanguageModelV3;
16
- /**
17
- * Wrapper de generateText del Vercel AI SDK con retry automático (1 reintento)
18
- * Soporta texto simple, system prompt y contenido multimodal (imágenes, audio)
19
- *
20
- * @param options - Opciones del Vercel AI SDK: model, system, prompt, messages, temperature, etc.
21
- * @returns Promise<{ text: string }> - Texto generado por la IA
22
- *
23
- * @example
24
- * ```typescript
25
- * // Solo texto
26
- * const { text } = await generateText({
27
- * model: createGoogleModel('LITE'),
28
- * prompt: 'Traduce al inglés: Hola mundo',
29
- * });
30
- *
31
- * // Con system prompt
32
- * const { text } = await generateText({
33
- * model: createGoogleModel('FLASH'),
34
- * system: 'Eres un corrector ortográfico',
35
- * prompt: 'ola como estas',
36
- * });
37
- *
38
- * // Multimodal (imagen)
39
- * const { text } = await generateText({
40
- * model: createGoogleModel('PRO'),
41
- * messages: [{
42
- * role: 'user',
43
- * content: [
44
- * { type: 'file', data: imageBuffer, mimeType: 'image/jpeg' },
45
- * { type: 'text', text: 'Describe esta imagen' },
46
- * ],
47
- * }],
48
- * });
49
- * ```
50
- */
51
- declare function generateText(options: Parameters<typeof originalGenerateText>[0]): Promise<{
52
- text: string;
53
- }>;
54
- export { generateText, createGoogleModel };
1
+ import { generateObject, generateText, runWithCostTracking } from './ai';
2
+ import { createGoogleModel, createGoogleModelFromString } from './googleModel';
3
+ import { AI_MODELS, PRODUCTION_MODELS, SEMI_MODELS, FAST_MODELS, TRIAL_MODELS, FALLBACK_MODELS, BEDROCK_CLAUDE_OPUS, BEDROCK_CLAUDE_SONNET, MODEL_TIER, AISTUDIO_PREFIX, runWithModels } from './constants';
4
+ import { MODEL_PRICING, calculateCost } from './modelPricing';
5
+ import { createBedrockModelFromString } from './bedrockModel';
6
+ export { generateObject, generateText, runWithCostTracking, createGoogleModel, createGoogleModelFromString, createBedrockModelFromString, MODEL_TIER, runWithModels, AI_MODELS, PRODUCTION_MODELS, SEMI_MODELS, FAST_MODELS, TRIAL_MODELS, FALLBACK_MODELS, BEDROCK_CLAUDE_OPUS, BEDROCK_CLAUDE_SONNET, AISTUDIO_PREFIX, MODEL_PRICING, calculateCost, };
55
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/prompt/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,oBAAoB,EAAE,MAAM,IAAI,CAAC;AAG1D,KAAK,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC;AAUzC;;;;;;;;;;;GAWG;AACH,iBAAS,iBAAiB,CAAC,QAAQ,GAAE,QAAkB,8CAEtD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,iBAAe,YAAY,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAa1G;AAED,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/prompt/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,qBAAqB,EACrB,UAAU,EACV,eAAe,EACf,aAAa,EACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAE9D,OAAO,EAEL,cAAc,EACd,YAAY,EACZ,mBAAmB,EAGnB,iBAAiB,EACjB,2BAA2B,EAC3B,4BAA4B,EAG5B,UAAU,EACV,aAAa,EAGb,SAAS,EACT,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,EAGf,aAAa,EACb,aAAa,GACd,CAAC"}
@@ -0,0 +1,31 @@
1
+ interface ModelPrice {
2
+ inputTokenPrice: number;
3
+ outputTokenPrice: number;
4
+ }
5
+ interface CostResult {
6
+ inputTokens: number;
7
+ outputTokens: number;
8
+ cost: number;
9
+ }
10
+ /**
11
+ * Precios por millón de tokens de entrada y salida para cada modelo.
12
+ * Los precios están en USD.
13
+ */
14
+ declare const MODEL_PRICING: Record<string, ModelPrice>;
15
+ /**
16
+ * Calcula el costo de una llamada a IA basado en tokens de entrada y salida
17
+ *
18
+ * @param modelName - Nombre del modelo (ej: 'gemini-3-flash-preview')
19
+ * @param promptTokens - Tokens de entrada
20
+ * @param completionTokens - Tokens de salida
21
+ * @returns Coste en USD con desglose de tokens
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * const cost = calculateCost('gemini-3-flash-preview', 1500, 800);
26
+ * // { inputTokens: 1500, outputTokens: 800, cost: 0.00315 }
27
+ * ```
28
+ */
29
+ declare function calculateCost(modelName: string, promptTokens?: number, completionTokens?: number): CostResult;
30
+ export { MODEL_PRICING, calculateCost, CostResult };
31
+ //# sourceMappingURL=modelPricing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modelPricing.d.ts","sourceRoot":"","sources":["../../../../src/prompt/modelPricing.ts"],"names":[],"mappings":"AAEA,UAAU,UAAU;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,UAAU,UAAU;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,QAAA,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAiB7C,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,iBAAS,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,MAAM,GAAG,UAAU,CAmBtG;AAED,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runnerpro/backend",
3
- "version": "1.19.5",
3
+ "version": "1.19.7",
4
4
  "description": "A collection of common backend functions",
5
5
  "exports": {
6
6
  ".": "./lib/cjs/index.js"
@@ -61,7 +61,9 @@
61
61
  "uuidv4": "^6.2.13"
62
62
  },
63
63
  "dependencies": {
64
+ "@ai-sdk/amazon-bedrock": "^4.0.89",
64
65
  "@ai-sdk/google": "^3.0.43",
66
+ "@ai-sdk/google-vertex": "^4.0.102",
65
67
  "@google-cloud/speech": "^7.2.1",
66
68
  "@google-cloud/storage": "^7.11.3",
67
69
  "@google-cloud/translate": "^8.3.0",