@runnerpro/backend 1.21.12 → 1.21.14
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/achievements/catalog.js +204 -0
- package/lib/cjs/achievements/index.js +805 -0
- package/lib/cjs/achievements/streak.js +126 -0
- package/lib/cjs/chat/api/conversation.js +21 -29
- package/lib/cjs/chat/exposed/conversation.js +0 -7
- package/lib/cjs/chat/index.js +0 -7
- package/lib/cjs/index.js +34 -5
- package/lib/cjs/locale/en.js +0 -4
- package/lib/cjs/locale/es.js +0 -4
- package/lib/cjs/locale/fr.js +0 -4
- package/lib/cjs/locale/it.js +0 -4
- package/lib/cjs/prompt/azureModel.js +7 -35
- package/lib/cjs/prompt/constants.js +12 -67
- package/lib/cjs/prompt/googleModel.js +6 -11
- package/lib/cjs/prompt/index.js +1 -4
- package/lib/cjs/prompt/modelPricing.js +1 -22
- package/lib/cjs/sendNotification/index.js +4 -88
- package/lib/cjs/types/achievements/catalog.d.ts +104 -0
- package/lib/cjs/types/achievements/catalog.d.ts.map +1 -0
- package/lib/cjs/types/achievements/index.d.ts +41 -0
- package/lib/cjs/types/achievements/index.d.ts.map +1 -0
- package/lib/cjs/types/achievements/streak.d.ts +20 -0
- package/lib/cjs/types/achievements/streak.d.ts.map +1 -0
- package/lib/cjs/types/chat/api/conversation.d.ts.map +1 -1
- package/lib/cjs/types/chat/exposed/conversation.d.ts.map +1 -1
- package/lib/cjs/types/chat/index.d.ts.map +1 -1
- package/lib/cjs/types/index.d.ts +4 -2
- package/lib/cjs/types/index.d.ts.map +1 -1
- package/lib/cjs/types/locale/en.d.ts +0 -4
- package/lib/cjs/types/locale/en.d.ts.map +1 -1
- package/lib/cjs/types/locale/es.d.ts +0 -4
- package/lib/cjs/types/locale/es.d.ts.map +1 -1
- package/lib/cjs/types/locale/fr.d.ts +0 -4
- package/lib/cjs/types/locale/fr.d.ts.map +1 -1
- package/lib/cjs/types/locale/it.d.ts +0 -4
- package/lib/cjs/types/locale/it.d.ts.map +1 -1
- package/lib/cjs/types/prompt/azureModel.d.ts.map +1 -1
- package/lib/cjs/types/prompt/constants.d.ts +7 -28
- package/lib/cjs/types/prompt/constants.d.ts.map +1 -1
- package/lib/cjs/types/prompt/googleModel.d.ts.map +1 -1
- package/lib/cjs/types/prompt/index.d.ts +2 -2
- package/lib/cjs/types/prompt/index.d.ts.map +1 -1
- package/lib/cjs/types/prompt/modelPricing.d.ts.map +1 -1
- package/lib/cjs/types/sendNotification/index.d.ts +1 -20
- package/lib/cjs/types/sendNotification/index.d.ts.map +1 -1
- package/lib/cjs/types/workout/planificacionPrueba7dias/index.d.ts.map +1 -1
- package/lib/cjs/types/workout/saveWorkoutAplication.d.ts.map +1 -1
- package/lib/cjs/workout/planificacionPrueba7dias/index.js +7 -3
- package/lib/cjs/workout/saveWorkoutAplication.js +10 -0
- package/package.json +1 -1
|
@@ -0,0 +1,126 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.computeStreakStats = exports.requiredFromPlanned = exports.STREAK_COMPLETION_THRESHOLD = void 0;
|
|
16
|
+
const db_1 = require("../db");
|
|
17
|
+
const moment_1 = __importDefault(require("moment"));
|
|
18
|
+
/**
|
|
19
|
+
* Regla de racha: una semana cuenta como completada si el usuario hace al menos
|
|
20
|
+
* el 80% de los entrenamientos planificados de esa semana (regla 80%). Tipos
|
|
21
|
+
* entrenables, semanas ISO. La semana actual incompleta no rompe la racha.
|
|
22
|
+
*/
|
|
23
|
+
exports.STREAK_COMPLETION_THRESHOLD = 0.8;
|
|
24
|
+
const requiredFromPlanned = (plannedWorkouts) => {
|
|
25
|
+
const planned = Number(plannedWorkouts) || 0;
|
|
26
|
+
if (planned <= 0)
|
|
27
|
+
return 0;
|
|
28
|
+
return Math.max(1, Math.ceil(planned * exports.STREAK_COMPLETION_THRESHOLD));
|
|
29
|
+
};
|
|
30
|
+
exports.requiredFromPlanned = requiredFromPlanned;
|
|
31
|
+
/**
|
|
32
|
+
* Racha actual (current) y récord histórico (longest), en semanas.
|
|
33
|
+
*
|
|
34
|
+
* @param userId ID del cliente.
|
|
35
|
+
* @param sinceDate Si se pasa, solo cuentan workouts con "DATE" >= sinceDate
|
|
36
|
+
* (ancla "empezar de cero" para logros). Sin él, comportamiento sobre todo el
|
|
37
|
+
* historial.
|
|
38
|
+
*/
|
|
39
|
+
const computeStreakStats = (userId, sinceDate = null) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
+
const params = [userId];
|
|
41
|
+
let sinceFilter = '';
|
|
42
|
+
if (sinceDate) {
|
|
43
|
+
sinceFilter = ' AND "DATE"::date >= ?::date';
|
|
44
|
+
params.push(sinceDate);
|
|
45
|
+
}
|
|
46
|
+
const rows = yield (0, db_1.query)(`SELECT date_trunc('week', "DATE"::date) AS "WEEK START",
|
|
47
|
+
COUNT(*) FILTER (WHERE "DONE" = true) AS completed,
|
|
48
|
+
COUNT(*) AS planned
|
|
49
|
+
FROM "WORKOUT"
|
|
50
|
+
WHERE "ID CLIENTE" = ?
|
|
51
|
+
AND "TYPE" IN ('CORRER','FUERZA','SPORT','BIKE','SWIM','TRAIL','WALK')
|
|
52
|
+
AND "SHOW CLIENT" IS TRUE${sinceFilter}
|
|
53
|
+
GROUP BY 1
|
|
54
|
+
ORDER BY 1 ASC`, params);
|
|
55
|
+
if (rows.length === 0)
|
|
56
|
+
return { current: 0, longest: 0 };
|
|
57
|
+
const byWeek = new Map();
|
|
58
|
+
for (const row of rows) {
|
|
59
|
+
const weekKey = (0, moment_1.default)(row.weekStart).startOf('isoWeek').format('YYYY-MM-DD');
|
|
60
|
+
byWeek.set(weekKey, {
|
|
61
|
+
completed: Number(row.completed) || 0,
|
|
62
|
+
planned: Number(row.planned) || 0,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
const now = (0, moment_1.default)();
|
|
66
|
+
const currentWeek = now.clone().startOf('isoWeek');
|
|
67
|
+
// ── Récord histórico ───────────────────────────────────────────────
|
|
68
|
+
const firstWeek = (0, moment_1.default)(rows[0].weekStart).startOf('isoWeek');
|
|
69
|
+
const lastWeek = currentWeek.clone();
|
|
70
|
+
let longest = 0;
|
|
71
|
+
let segment = 0;
|
|
72
|
+
const fwd = firstWeek.clone();
|
|
73
|
+
const MAX_WEEKS_FORWARD = 520;
|
|
74
|
+
for (let i = 0; i < MAX_WEEKS_FORWARD && fwd.isSameOrBefore(lastWeek, 'day'); i++) {
|
|
75
|
+
const k = fwd.format('YYYY-MM-DD');
|
|
76
|
+
const data = byWeek.get(k);
|
|
77
|
+
const required = data ? (0, exports.requiredFromPlanned)(data.planned) : 0;
|
|
78
|
+
const isCurrent = fwd.isSame(currentWeek, 'day');
|
|
79
|
+
const cumple = !!data && required > 0 && data.completed >= required;
|
|
80
|
+
if (cumple) {
|
|
81
|
+
segment++;
|
|
82
|
+
if (segment > longest)
|
|
83
|
+
longest = segment;
|
|
84
|
+
}
|
|
85
|
+
else if (!isCurrent) {
|
|
86
|
+
segment = 0;
|
|
87
|
+
}
|
|
88
|
+
fwd.add(1, 'week');
|
|
89
|
+
}
|
|
90
|
+
// ── Racha actual ───────────────────────────────────────────────────
|
|
91
|
+
const cursor = currentWeek.clone();
|
|
92
|
+
const currentData = byWeek.get(cursor.format('YYYY-MM-DD'));
|
|
93
|
+
let current = 0;
|
|
94
|
+
if (currentData) {
|
|
95
|
+
const required = (0, exports.requiredFromPlanned)(currentData.planned);
|
|
96
|
+
if (required > 0 && currentData.completed >= required) {
|
|
97
|
+
current++;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
cursor.subtract(1, 'week');
|
|
101
|
+
const MAX_LOOKBACK_WEEKS = 520;
|
|
102
|
+
let broken = false;
|
|
103
|
+
for (let i = 0; i < MAX_LOOKBACK_WEEKS && !broken; i++) {
|
|
104
|
+
const data = byWeek.get(cursor.format('YYYY-MM-DD'));
|
|
105
|
+
if (!data) {
|
|
106
|
+
broken = true;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
const required = (0, exports.requiredFromPlanned)(data.planned);
|
|
110
|
+
if (required === 0) {
|
|
111
|
+
cursor.subtract(1, 'week');
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
if (data.completed >= required) {
|
|
115
|
+
current++;
|
|
116
|
+
cursor.subtract(1, 'week');
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
broken = true;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (current > longest)
|
|
123
|
+
longest = current;
|
|
124
|
+
return { current, longest };
|
|
125
|
+
});
|
|
126
|
+
exports.computeStreakStats = computeStreakStats;
|
|
@@ -368,18 +368,22 @@ const sendMessage = (req, res, { sendNotification, firebaseMessaging, isClient }
|
|
|
368
368
|
}
|
|
369
369
|
}
|
|
370
370
|
const [message] = yield (0, index_1.query)('INSERT INTO [CHAT MESSAGE] ([ID CLIENTE], [ID SENDER], [TEXT], [TEXT PREFERRED LANGUAGE], [PREFERRED LANGUAGE], [REPLY MESSAGE ID], [ID WORKOUT], [TYPE]) VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING [ID]', [isClient ? userid : idCliente, userid, textSpanish, textPreferredLanguage, preferredLanguage, replyMessageId, idWorkout, type]);
|
|
371
|
-
|
|
371
|
+
// Logros: mensaje enviado por el cliente → coach_1er_msg/coach_10_msg. Await
|
|
372
|
+
// acotado (1500 ms) para devolver los recién desbloqueados al FE (push). El
|
|
373
|
+
// bounded aísla fallo/lentitud: si vence, persiste en background y el FE lo
|
|
374
|
+
// recupera en el siguiente refetch.
|
|
375
|
+
let logrosDesbloqueados = [];
|
|
376
|
+
if (isClient) {
|
|
377
|
+
logrosDesbloqueados = yield (0, index_1.evaluateAchievementsBounded)(userid, 'chat', {}, 1500);
|
|
378
|
+
}
|
|
379
|
+
res.send({ idMessage: message.id, text: textSpanish, logrosDesbloqueados });
|
|
372
380
|
if (!isClient) {
|
|
373
|
-
// Recuperamos el nombre del entrenador para firmar el push con su nombre real (no genérico).
|
|
374
|
-
const [entrenadorRow] = yield (0, index_1.query)('SELECT [NAME] FROM [ENTRENADOR] WHERE [ID] = ?', [userid]);
|
|
375
|
-
const entrenador = ((entrenadorRow === null || entrenadorRow === void 0 ? void 0 : entrenadorRow.name) || 'Tu entrenador').split(' ')[0];
|
|
376
381
|
sendNotification({
|
|
377
382
|
firebaseMessaging,
|
|
378
383
|
idCliente,
|
|
379
|
-
title:
|
|
384
|
+
title: '💬 Nuevo mensaje de tu entrenador',
|
|
380
385
|
body: textPreferredLanguage || textSpanish,
|
|
381
386
|
screen: common_1.NOTIFICATION_SCREEN_TYPES.CHAT,
|
|
382
|
-
channelId: common_1.NOTIFICATION_CHANNELS.COACH,
|
|
383
387
|
});
|
|
384
388
|
// Enviar a N8N lo que ha escrito el entrenador
|
|
385
389
|
// const [lastSuggestionMsg] = await query(
|
|
@@ -431,20 +435,11 @@ const sendEmoji = (req, res, { sendNotification, firebaseMessaging, isClient })
|
|
|
431
435
|
]);
|
|
432
436
|
res.send({ idReaction: reaction.id });
|
|
433
437
|
if (!isClient) {
|
|
434
|
-
const [[entrenadorRow], [clienteRow]] = yield Promise.all([
|
|
435
|
-
(0, index_1.query)('SELECT [NAME] FROM [ENTRENADOR] WHERE [ID] = ?', [userid]),
|
|
436
|
-
(0, index_1.query)('SELECT [PREFERRED LANGUAGE] FROM [CLIENTE] WHERE [ID] = ?', [idCliente]),
|
|
437
|
-
]);
|
|
438
|
-
const entrenador = ((entrenadorRow === null || entrenadorRow === void 0 ? void 0 : entrenadorRow.name) || 'Tu entrenador').split(' ')[0];
|
|
439
|
-
const lang = (clienteRow === null || clienteRow === void 0 ? void 0 : clienteRow.preferredLanguage) || common_1.LANGUAGES.ES;
|
|
440
438
|
sendNotification({
|
|
441
439
|
firebaseMessaging,
|
|
442
440
|
idCliente,
|
|
443
|
-
body:
|
|
444
|
-
.replace('{{ entrenador }}', entrenador)
|
|
445
|
-
.replace('{{ emoji }}', emoji),
|
|
441
|
+
body: `El entrenador ha reaccionado a un mensaje '${emoji}'`,
|
|
446
442
|
screen: common_1.NOTIFICATION_SCREEN_TYPES.CHAT,
|
|
447
|
-
channelId: common_1.NOTIFICATION_CHANNELS.COACH,
|
|
448
443
|
});
|
|
449
444
|
}
|
|
450
445
|
});
|
|
@@ -486,6 +481,12 @@ const sendFile = (req, res, { sendNotification, firebaseMessaging, isClient, buc
|
|
|
486
481
|
thumbnail = yield getThumbnailFromVideo(filePath, duration);
|
|
487
482
|
}
|
|
488
483
|
const [{ id: idFile }] = yield (0, index_1.query)('INSERT INTO [CHAT MESSAGE] ([ID CLIENTE], [ID SENDER], [TEXT], [MIMETYPE], [DURATION], [TYPE]) VALUES (?, ?, ?, ?, ?, ?) RETURNING [ID]', [isClient ? userid : idCliente, userid, req.file.originalname, req.file.mimetype, duration || null, type || 2]);
|
|
484
|
+
// Logros: adjunto enviado por el cliente también cuenta como mensaje. Await
|
|
485
|
+
// acotado para devolver los recién desbloqueados al FE en la respuesta (push).
|
|
486
|
+
let logrosDesbloqueados = [];
|
|
487
|
+
if (isClient) {
|
|
488
|
+
logrosDesbloqueados = yield (0, index_1.evaluateAchievementsBounded)(userid, 'chat', {}, 1500);
|
|
489
|
+
}
|
|
489
490
|
const fileData = fs_1.default.readFileSync(filePath);
|
|
490
491
|
const files = [];
|
|
491
492
|
if (req.file.mimetype.includes('image')) {
|
|
@@ -506,7 +507,7 @@ const sendFile = (req, res, { sendNotification, firebaseMessaging, isClient, buc
|
|
|
506
507
|
else {
|
|
507
508
|
files.push({ data: fileData, id: idFile });
|
|
508
509
|
}
|
|
509
|
-
res.send({ idFile });
|
|
510
|
+
res.send({ idFile, logrosDesbloqueados });
|
|
510
511
|
for (const file of files) {
|
|
511
512
|
yield bucket.file(`Chat/${file.id}`).save(file.data);
|
|
512
513
|
}
|
|
@@ -519,22 +520,13 @@ const sendFile = (req, res, { sendNotification, firebaseMessaging, isClient, buc
|
|
|
519
520
|
textFile = 'Vídeo';
|
|
520
521
|
if (req.file.mimetype.includes('image'))
|
|
521
522
|
textFile = 'Imagen';
|
|
522
|
-
const [
|
|
523
|
-
(0, index_1.query)('SELECT [NAME] FROM [ENTRENADOR] WHERE [ID] = ?', [userid]),
|
|
524
|
-
(0, index_1.query)('SELECT [PREFERRED LANGUAGE] FROM [CLIENTE] WHERE [ID] = ?', [idCliente]),
|
|
525
|
-
]);
|
|
526
|
-
const entrenador = ((entrenadorRow === null || entrenadorRow === void 0 ? void 0 : entrenadorRow.name) || 'Tu entrenador').split(' ')[0];
|
|
527
|
-
const lang = (clienteRow === null || clienteRow === void 0 ? void 0 : clienteRow.preferredLanguage) || common_1.LANGUAGES.ES;
|
|
528
|
-
const tipoArchivo = (0, index_2.t)(textFile, lang);
|
|
523
|
+
const [cliente] = yield (0, index_1.query)('SELECT [PREFERRED LANGUAGE] FROM [CLIENTE] WHERE [ID] = ?', [idCliente]);
|
|
529
524
|
sendNotification({
|
|
530
525
|
firebaseMessaging,
|
|
531
526
|
idCliente,
|
|
532
|
-
title: (0, index_2.t)('
|
|
533
|
-
|
|
534
|
-
.replace('{{ tipoArchivo }}', tipoArchivo),
|
|
535
|
-
body: (0, index_2.t)('Ábrelo en el chat.', lang),
|
|
527
|
+
title: (0, index_2.t)('💬 Nuevo mensaje de tu entrenador', cliente.preferredLanguage),
|
|
528
|
+
body: (0, index_2.t)(textFile, cliente.preferredLanguage),
|
|
536
529
|
screen: common_1.NOTIFICATION_SCREEN_TYPES.CHAT,
|
|
537
|
-
channelId: common_1.NOTIFICATION_CHANNELS.COACH,
|
|
538
530
|
});
|
|
539
531
|
yield updateSenderView({ userid, idCliente, idMessage: idFile });
|
|
540
532
|
}
|
|
@@ -30,13 +30,6 @@ exports.conversationRoute = conversationRoute;
|
|
|
30
30
|
const socketConversation = (req, res, { isClient }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
31
|
const { idCliente } = req.body;
|
|
32
32
|
const ioEmitter = req.app.get('socketIo');
|
|
33
|
-
// El backend de la app ya no monta socket.io (la app recibe por push + recarga HTTP, no por
|
|
34
|
-
// websocket). Sin emisor no hay a quién emitir: respondemos ok y salimos. Antes esto caía al
|
|
35
|
-
// vacío igualmente porque la app no escuchaba el socket; ahora evitamos el 500 por undefined.
|
|
36
|
-
if (!ioEmitter) {
|
|
37
|
-
res.send({ status: 'ok' });
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
33
|
const room = (0, getRoom_1.getRoom)(isClient, idCliente);
|
|
41
34
|
ioEmitter.sockets.in(room).emit('message', req.body);
|
|
42
35
|
res.send({ status: 'ok' });
|
package/lib/cjs/chat/index.js
CHANGED
|
@@ -15,13 +15,6 @@ Object.defineProperty(exports, "chatExposed", { enumerable: true, get: function
|
|
|
15
15
|
const getCountNotificaciones_1 = require("./utils/getCountNotificaciones");
|
|
16
16
|
Object.defineProperty(exports, "getCountNotificaciones", { enumerable: true, get: function () { return getCountNotificaciones_1.getCountNotificaciones; } });
|
|
17
17
|
const chat = ({ server, app, verify_access_token, tokenExposed, backendExtremeUrl, frontendUrl, isClient }) => {
|
|
18
|
-
// El backend de la APP (isClient) NO usa websockets: la app recibe los mensajes por avisos
|
|
19
|
-
// push (FCM) + recarga HTTP de la conversación, nunca por socket.io (no tiene cliente de
|
|
20
|
-
// websocket). Montarlo aquí era código muerto — el emit caía al vacío — y además inflaba la
|
|
21
|
-
// latencia p95 del servicio con conexiones de larga duración. El dashboard de coaches
|
|
22
|
-
// (isClient=false) sí consume el socket, así que ahí se mantiene intacto.
|
|
23
|
-
if (isClient)
|
|
24
|
-
return;
|
|
25
18
|
// @ts-ignore
|
|
26
19
|
const io = (0, socket_io_1.default)(server, {
|
|
27
20
|
cors: {
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,7 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.calculateCost = exports.MODEL_PRICING = exports.AISTUDIO_PREFIX = exports.BEDROCK_CLAUDE_HAIKU = exports.BEDROCK_CLAUDE_SONNET_4 = exports.BEDROCK_CLAUDE_SONNET_4_5 = exports.BEDROCK_CLAUDE_OPUS_4_1 = exports.BEDROCK_CLAUDE_OPUS_4_5 = exports.BEDROCK_CLAUDE_SONNET = exports.BEDROCK_CLAUDE_OPUS = exports.FALLBACK_MODELS = exports.PRODUCTION_MODELS = exports.AZURE_PRIMARY_MODELS = exports.
|
|
26
|
+
exports.describeImage = exports.transcribeAudio = exports.updateSenderView = exports.saveResponseTime = exports.getZone = exports.saveDoneStructuraWorkout = exports.computeStreakStats = exports.getUnlockedAchievements = exports.evaluateAchievementsBounded = exports.evaluateAchievements = exports.saveWorkoutLaps = exports.saveWorkoutAplication = 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 = exports.achievementsCatalog = void 0;
|
|
27
|
+
exports.calculateCost = exports.MODEL_PRICING = exports.AISTUDIO_PREFIX = exports.BEDROCK_CLAUDE_HAIKU = exports.BEDROCK_CLAUDE_SONNET_4 = exports.BEDROCK_CLAUDE_SONNET_4_5 = exports.BEDROCK_CLAUDE_OPUS_4_1 = exports.BEDROCK_CLAUDE_OPUS_4_5 = exports.BEDROCK_CLAUDE_SONNET = exports.BEDROCK_CLAUDE_OPUS = exports.FALLBACK_MODELS = exports.PRODUCTION_MODELS = exports.AZURE_PRIMARY_MODELS = exports.AZURE_GPT_5_4_NANO = exports.AZURE_GPT_5_4_MINI = exports.AZURE_GPT_5_5 = exports.AZURE_GPT_5_4_NANO_DEPLOYMENT = exports.AZURE_GPT_5_4_MINI_DEPLOYMENT = exports.AZURE_GPT_5_5_DEPLOYMENT = exports.AZURE_PREFIX = exports.GOOGLE_MODELS = exports.AI_MODELS = exports.MODEL_TIER = exports.runWithModels = exports.runWithCostTracking = exports.createModelFromString = exports.createAzureModelFromString = exports.createBedrockModelFromString = exports.createGoogleModelFromString = exports.createGoogleModel = exports.generateText = exports.generateObject = exports.reprocessRecentMedia = exports.processMediaFile = void 0;
|
|
5
28
|
const sendNotification_1 = require("./sendNotification");
|
|
6
29
|
Object.defineProperty(exports, "sendNotification", { enumerable: true, get: function () { return sendNotification_1.sendNotification; } });
|
|
7
30
|
const sleep_1 = require("./sleep");
|
|
@@ -59,6 +82,15 @@ const saveWorkoutAplication_1 = require("./workout/saveWorkoutAplication");
|
|
|
59
82
|
Object.defineProperty(exports, "saveWorkoutAplication", { enumerable: true, get: function () { return saveWorkoutAplication_1.saveWorkoutAplication; } });
|
|
60
83
|
const saveWorkoutLaps_1 = require("./workout/saveWorkoutLaps");
|
|
61
84
|
Object.defineProperty(exports, "saveWorkoutLaps", { enumerable: true, get: function () { return saveWorkoutLaps_1.saveWorkoutLaps; } });
|
|
85
|
+
const achievements_1 = require("./achievements");
|
|
86
|
+
Object.defineProperty(exports, "evaluateAchievements", { enumerable: true, get: function () { return achievements_1.evaluateAchievements; } });
|
|
87
|
+
Object.defineProperty(exports, "evaluateAchievementsBounded", { enumerable: true, get: function () { return achievements_1.evaluateAchievementsBounded; } });
|
|
88
|
+
Object.defineProperty(exports, "getUnlockedAchievements", { enumerable: true, get: function () { return achievements_1.getUnlockedAchievements; } });
|
|
89
|
+
Object.defineProperty(exports, "computeStreakStats", { enumerable: true, get: function () { return achievements_1.computeStreakStats; } });
|
|
90
|
+
// Catálogo de REGLAS de logros (umbrales + IDs). Fuente única de verdad para
|
|
91
|
+
// los consumidores del paquete (backfill, herramientas, tests). El catálogo de
|
|
92
|
+
// PRESENTACIÓN (labels/iconos) vive en el frontend.
|
|
93
|
+
exports.achievementsCatalog = __importStar(require("./achievements/catalog"));
|
|
62
94
|
const estructuraWorkout_1 = require("./workout/estructuraWorkout");
|
|
63
95
|
Object.defineProperty(exports, "saveDoneStructuraWorkout", { enumerable: true, get: function () { return estructuraWorkout_1.saveDoneStructuraWorkout; } });
|
|
64
96
|
const paceZone_1 = require("./workout/paceZone");
|
|
@@ -86,15 +118,12 @@ Object.defineProperty(exports, "MODEL_TIER", { enumerable: true, get: function (
|
|
|
86
118
|
Object.defineProperty(exports, "AI_MODELS", { enumerable: true, get: function () { return prompt_1.AI_MODELS; } });
|
|
87
119
|
Object.defineProperty(exports, "GOOGLE_MODELS", { enumerable: true, get: function () { return prompt_1.GOOGLE_MODELS; } });
|
|
88
120
|
Object.defineProperty(exports, "AZURE_PREFIX", { enumerable: true, get: function () { return prompt_1.AZURE_PREFIX; } });
|
|
89
|
-
Object.defineProperty(exports, "AZURE_GPT_5_6_DEPLOYMENT", { enumerable: true, get: function () { return prompt_1.AZURE_GPT_5_6_DEPLOYMENT; } });
|
|
90
121
|
Object.defineProperty(exports, "AZURE_GPT_5_5_DEPLOYMENT", { enumerable: true, get: function () { return prompt_1.AZURE_GPT_5_5_DEPLOYMENT; } });
|
|
91
122
|
Object.defineProperty(exports, "AZURE_GPT_5_4_MINI_DEPLOYMENT", { enumerable: true, get: function () { return prompt_1.AZURE_GPT_5_4_MINI_DEPLOYMENT; } });
|
|
92
123
|
Object.defineProperty(exports, "AZURE_GPT_5_4_NANO_DEPLOYMENT", { enumerable: true, get: function () { return prompt_1.AZURE_GPT_5_4_NANO_DEPLOYMENT; } });
|
|
93
|
-
Object.defineProperty(exports, "AZURE_GPT_5_6", { enumerable: true, get: function () { return prompt_1.AZURE_GPT_5_6; } });
|
|
94
124
|
Object.defineProperty(exports, "AZURE_GPT_5_5", { enumerable: true, get: function () { return prompt_1.AZURE_GPT_5_5; } });
|
|
95
125
|
Object.defineProperty(exports, "AZURE_GPT_5_4_MINI", { enumerable: true, get: function () { return prompt_1.AZURE_GPT_5_4_MINI; } });
|
|
96
126
|
Object.defineProperty(exports, "AZURE_GPT_5_4_NANO", { enumerable: true, get: function () { return prompt_1.AZURE_GPT_5_4_NANO; } });
|
|
97
|
-
Object.defineProperty(exports, "AZURE_MODELS", { enumerable: true, get: function () { return prompt_1.AZURE_MODELS; } });
|
|
98
127
|
Object.defineProperty(exports, "AZURE_PRIMARY_MODELS", { enumerable: true, get: function () { return prompt_1.AZURE_PRIMARY_MODELS; } });
|
|
99
128
|
Object.defineProperty(exports, "PRODUCTION_MODELS", { enumerable: true, get: function () { return prompt_1.PRODUCTION_MODELS; } });
|
|
100
129
|
Object.defineProperty(exports, "FALLBACK_MODELS", { enumerable: true, get: function () { return prompt_1.FALLBACK_MODELS; } });
|
package/lib/cjs/locale/en.js
CHANGED
|
@@ -7,9 +7,5 @@ const en = {
|
|
|
7
7
|
Vídeo: 'Video',
|
|
8
8
|
Imagen: 'Image',
|
|
9
9
|
'💬 Nuevo mensaje de tu entrenador': '💬 New message from your trainer',
|
|
10
|
-
'{{ entrenador }} 💬': '{{ entrenador }} 💬',
|
|
11
|
-
'{{ entrenador }} te ha enviado {{ tipoArchivo }} 📎': '{{ entrenador }} sent you {{ tipoArchivo }} 📎',
|
|
12
|
-
'Ábrelo en el chat.': 'Open it in the chat.',
|
|
13
|
-
'{{ entrenador }} reaccionó {{ emoji }} a tu mensaje': '{{ entrenador }} reacted {{ emoji }} to your message',
|
|
14
10
|
};
|
|
15
11
|
exports.en = en;
|
package/lib/cjs/locale/es.js
CHANGED
|
@@ -7,9 +7,5 @@ const es = {
|
|
|
7
7
|
Vídeo: 'Vídeo',
|
|
8
8
|
Imagen: 'Imagen',
|
|
9
9
|
'💬 Nuevo mensaje de tu entrenador': '💬 Nuevo mensaje de tu entrenador',
|
|
10
|
-
'{{ entrenador }} 💬': '{{ entrenador }} 💬',
|
|
11
|
-
'{{ entrenador }} te ha enviado {{ tipoArchivo }} 📎': '{{ entrenador }} te ha enviado {{ tipoArchivo }} 📎',
|
|
12
|
-
'Ábrelo en el chat.': 'Ábrelo en el chat.',
|
|
13
|
-
'{{ entrenador }} reaccionó {{ emoji }} a tu mensaje': '{{ entrenador }} reaccionó {{ emoji }} a tu mensaje',
|
|
14
10
|
};
|
|
15
11
|
exports.es = es;
|
package/lib/cjs/locale/fr.js
CHANGED
|
@@ -7,9 +7,5 @@ const fr = {
|
|
|
7
7
|
Vídeo: 'Vidéo',
|
|
8
8
|
Imagen: 'Image',
|
|
9
9
|
'💬 Nuevo mensaje de tu entrenador': '💬 Nouveau message de votre entraîneur',
|
|
10
|
-
'{{ entrenador }} 💬': '{{ entrenador }} 💬',
|
|
11
|
-
'{{ entrenador }} te ha enviado {{ tipoArchivo }} 📎': '{{ entrenador }} t’a envoyé {{ tipoArchivo }} 📎',
|
|
12
|
-
'Ábrelo en el chat.': 'Ouvre-le dans le chat.',
|
|
13
|
-
'{{ entrenador }} reaccionó {{ emoji }} a tu mensaje': '{{ entrenador }} a réagi {{ emoji }} à ton message',
|
|
14
10
|
};
|
|
15
11
|
exports.fr = fr;
|
package/lib/cjs/locale/it.js
CHANGED
|
@@ -7,9 +7,5 @@ const it = {
|
|
|
7
7
|
Vídeo: 'Video',
|
|
8
8
|
Imagen: 'Immagine',
|
|
9
9
|
'💬 Nuevo mensaje de tu entrenador': '💬 Nuovo messaggio da tuo allenatore',
|
|
10
|
-
'{{ entrenador }} 💬': '{{ entrenador }} 💬',
|
|
11
|
-
'{{ entrenador }} te ha enviado {{ tipoArchivo }} 📎': '{{ entrenador }} ti ha inviato {{ tipoArchivo }} 📎',
|
|
12
|
-
'Ábrelo en el chat.': 'Aprilo nella chat.',
|
|
13
|
-
'{{ entrenador }} reaccionó {{ emoji }} a tu mensaje': '{{ entrenador }} ha reagito {{ emoji }} al tuo messaggio',
|
|
14
10
|
};
|
|
15
11
|
exports.it = it;
|
|
@@ -2,51 +2,23 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createAzureModelFromString = void 0;
|
|
4
4
|
const azure_1 = require("@ai-sdk/azure");
|
|
5
|
-
/**
|
|
6
|
-
* Fetch envoltorio que elimina el query param `api-version` en las rutas /v1.
|
|
7
|
-
*
|
|
8
|
-
* El endpoint de proyecto de Foundry (acceso instantáneo) sirve los modelos por la API v1
|
|
9
|
-
* (…/api/projects/<proyecto>/openai/v1/responses) y RECHAZA con HTTP 400 cualquier
|
|
10
|
-
* `?api-version=…` en esa ruta ("api-version query parameter is not allowed when using /v1
|
|
11
|
-
* path"). Pero el provider de @ai-sdk/azure SIEMPRE añade `?api-version=<apiVersion|v1>`
|
|
12
|
-
* (ver azure-openai-provider). Por eso lo quitamos aquí en las rutas /v1; en cualquier otra
|
|
13
|
-
* ruta se respeta tal cual, y ante un error de parseo no bloqueamos la llamada.
|
|
14
|
-
*/
|
|
15
|
-
function stripV1ApiVersionFetch(input, init) {
|
|
16
|
-
try {
|
|
17
|
-
const rawUrl = typeof input === 'string' ? input : input instanceof URL ? input.href : undefined;
|
|
18
|
-
if (rawUrl) {
|
|
19
|
-
const u = new URL(rawUrl);
|
|
20
|
-
if (u.pathname.includes('/v1/') && u.searchParams.has('api-version')) {
|
|
21
|
-
u.searchParams.delete('api-version');
|
|
22
|
-
return fetch(u.href, init);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
catch (_a) {
|
|
27
|
-
// URL no parseable → seguimos con el fetch normal
|
|
28
|
-
}
|
|
29
|
-
return fetch(input, init);
|
|
30
|
-
}
|
|
31
5
|
/**
|
|
32
6
|
* Crea el provider de Azure OpenAI con autenticación por API Key.
|
|
33
7
|
*
|
|
34
8
|
* Variables de entorno:
|
|
35
|
-
* - AZURE_BASE_URL: endpoint del recurso hasta "/openai"
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* - AZURE_API_VERSION: opcional. En la API v1 NO se aplica — el provider lo añadiría pero
|
|
42
|
-
* stripV1ApiVersionFetch lo elimina. Déjalo sin definir para el endpoint de proyecto.
|
|
9
|
+
* - AZURE_BASE_URL: endpoint del recurso hasta "/openai" (ej:
|
|
10
|
+
* https://<name>.cognitiveservices.azure.com/openai). Alternativa: AZURE_RESOURCE_NAME
|
|
11
|
+
* para recursos con dominio clásico *.openai.azure.com.
|
|
12
|
+
* - AZURE_API_KEY: clave del recurso.
|
|
13
|
+
* - AZURE_API_VERSION: versión de la API. Para los recursos nuevos (Cognitive Services /
|
|
14
|
+
* modelos GPT-5.x) usar "preview" → enruta a la API v1 (/openai/v1/responses).
|
|
43
15
|
*
|
|
44
16
|
* @returns Provider de Azure configurado
|
|
45
17
|
*/
|
|
46
18
|
function getAzureProvider() {
|
|
47
19
|
const apiVersion = process.env.AZURE_API_VERSION;
|
|
48
20
|
const baseURL = process.env.AZURE_BASE_URL;
|
|
49
|
-
return (0, azure_1.createAzure)(Object.assign(Object.assign(
|
|
21
|
+
return (0, azure_1.createAzure)(Object.assign(Object.assign({ apiKey: process.env.AZURE_API_KEY }, (baseURL ? { baseURL } : { resourceName: process.env.AZURE_RESOURCE_NAME })), (apiVersion ? { apiVersion } : {})));
|
|
50
22
|
}
|
|
51
23
|
/**
|
|
52
24
|
* Crea una instancia del modelo de Azure OpenAI a partir del nombre del deployment.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.runWithModels = exports.AISTUDIO_PREFIX = exports.MODEL_TIER = exports.BEDROCK_CLAUDE_HAIKU = exports.BEDROCK_CLAUDE_SONNET_4 = exports.BEDROCK_CLAUDE_SONNET_4_5 = exports.BEDROCK_CLAUDE_OPUS_4_1 = exports.BEDROCK_CLAUDE_OPUS_4_5 = exports.BEDROCK_CLAUDE_SONNET = exports.BEDROCK_CLAUDE_OPUS = exports.FALLBACK_MODELS = exports.TRIAL_MODELS = exports.FAST_MODELS = exports.SEMI_MODELS = exports.PRODUCTION_MODELS = exports.
|
|
3
|
+
exports.runWithModels = exports.AISTUDIO_PREFIX = exports.MODEL_TIER = exports.BEDROCK_CLAUDE_HAIKU = exports.BEDROCK_CLAUDE_SONNET_4 = exports.BEDROCK_CLAUDE_SONNET_4_5 = exports.BEDROCK_CLAUDE_OPUS_4_1 = exports.BEDROCK_CLAUDE_OPUS_4_5 = exports.BEDROCK_CLAUDE_SONNET = exports.BEDROCK_CLAUDE_OPUS = exports.FALLBACK_MODELS = exports.TRIAL_MODELS = exports.FAST_MODELS = exports.SEMI_MODELS = exports.PRODUCTION_MODELS = exports.AZURE_PRIMARY_MODELS = exports.AZURE_GPT_5_4_NANO = exports.AZURE_GPT_5_4_MINI = exports.AZURE_GPT_5_5 = exports.AZURE_GPT_5_4_NANO_DEPLOYMENT = exports.AZURE_GPT_5_4_MINI_DEPLOYMENT = exports.AZURE_GPT_5_5_DEPLOYMENT = exports.AZURE_PREFIX = exports.GOOGLE_MODELS = exports.AI_MODELS = void 0;
|
|
4
4
|
const node_async_hooks_1 = require("node:async_hooks");
|
|
5
5
|
const modelContextStorage = new node_async_hooks_1.AsyncLocalStorage();
|
|
6
6
|
const BEDROCK_CLAUDE_OPUS = 'us.anthropic.claude-opus-4-6-v1';
|
|
@@ -29,88 +29,33 @@ exports.GOOGLE_MODELS = GOOGLE_MODELS;
|
|
|
29
29
|
// string de enrutado. Se mapean a tiers como Gemini/Claude: PRO el más potente, LITE el más barato.
|
|
30
30
|
const AZURE_PREFIX = 'azure:';
|
|
31
31
|
exports.AZURE_PREFIX = AZURE_PREFIX;
|
|
32
|
-
|
|
33
|
-
// (terra/luna/sol) tienen los mismos límites y están en AZURE_MODELS.
|
|
34
|
-
const AZURE_GPT_5_6_DEPLOYMENT = 'gpt-5.6-terra';
|
|
35
|
-
exports.AZURE_GPT_5_6_DEPLOYMENT = AZURE_GPT_5_6_DEPLOYMENT;
|
|
36
|
-
const AZURE_GPT_5_5_DEPLOYMENT = 'gpt-5.5';
|
|
32
|
+
const AZURE_GPT_5_5_DEPLOYMENT = process.env.AZURE_GPT_5_5_DEPLOYMENT || 'gpt-5.5';
|
|
37
33
|
exports.AZURE_GPT_5_5_DEPLOYMENT = AZURE_GPT_5_5_DEPLOYMENT;
|
|
38
|
-
const AZURE_GPT_5_4_MINI_DEPLOYMENT = 'gpt-5.4-mini';
|
|
34
|
+
const AZURE_GPT_5_4_MINI_DEPLOYMENT = process.env.AZURE_GPT_5_4_MINI_DEPLOYMENT || 'gpt-5.4-mini';
|
|
39
35
|
exports.AZURE_GPT_5_4_MINI_DEPLOYMENT = AZURE_GPT_5_4_MINI_DEPLOYMENT;
|
|
40
|
-
const AZURE_GPT_5_4_NANO_DEPLOYMENT = 'gpt-5.4-nano';
|
|
36
|
+
const AZURE_GPT_5_4_NANO_DEPLOYMENT = process.env.AZURE_GPT_5_4_NANO_DEPLOYMENT || 'gpt-5.4-nano';
|
|
41
37
|
exports.AZURE_GPT_5_4_NANO_DEPLOYMENT = AZURE_GPT_5_4_NANO_DEPLOYMENT;
|
|
42
|
-
const AZURE_GPT_5_6 = `${AZURE_PREFIX}${AZURE_GPT_5_6_DEPLOYMENT}`;
|
|
43
|
-
exports.AZURE_GPT_5_6 = AZURE_GPT_5_6;
|
|
44
38
|
const AZURE_GPT_5_5 = `${AZURE_PREFIX}${AZURE_GPT_5_5_DEPLOYMENT}`;
|
|
45
39
|
exports.AZURE_GPT_5_5 = AZURE_GPT_5_5;
|
|
46
40
|
const AZURE_GPT_5_4_MINI = `${AZURE_PREFIX}${AZURE_GPT_5_4_MINI_DEPLOYMENT}`;
|
|
47
41
|
exports.AZURE_GPT_5_4_MINI = AZURE_GPT_5_4_MINI;
|
|
48
42
|
const AZURE_GPT_5_4_NANO = `${AZURE_PREFIX}${AZURE_GPT_5_4_NANO_DEPLOYMENT}`;
|
|
49
43
|
exports.AZURE_GPT_5_4_NANO = AZURE_GPT_5_4_NANO;
|
|
50
|
-
// Catálogo completo de modelos que el proyecto Foundry sirve por acceso instantáneo
|
|
51
|
-
// (invocables por nombre sin desplegar). Úsalos con createModelFromString(AZURE_MODELS.X)
|
|
52
|
-
// o directamente como model string "azure:<name>" en generateText/generateObject.
|
|
53
|
-
const AZURE_MODELS = {
|
|
54
|
-
GPT_5_6_TERRA: `${AZURE_PREFIX}gpt-5.6-terra`,
|
|
55
|
-
GPT_5_6_LUNA: `${AZURE_PREFIX}gpt-5.6-luna`,
|
|
56
|
-
GPT_5_6_SOL: `${AZURE_PREFIX}gpt-5.6-sol`,
|
|
57
|
-
GPT_5_5: `${AZURE_PREFIX}gpt-5.5`,
|
|
58
|
-
GPT_5_4: `${AZURE_PREFIX}gpt-5.4`,
|
|
59
|
-
GPT_5_4_MINI: `${AZURE_PREFIX}gpt-5.4-mini`,
|
|
60
|
-
GPT_5_4_NANO: `${AZURE_PREFIX}gpt-5.4-nano`,
|
|
61
|
-
GPT_5_3_CODEX: `${AZURE_PREFIX}gpt-5.3-codex`,
|
|
62
|
-
GPT_5_2: `${AZURE_PREFIX}gpt-5.2`,
|
|
63
|
-
GPT_5_2_CODEX: `${AZURE_PREFIX}gpt-5.2-codex`,
|
|
64
|
-
GPT_5_1: `${AZURE_PREFIX}gpt-5.1`,
|
|
65
|
-
GPT_5_1_CODEX: `${AZURE_PREFIX}gpt-5.1-codex`,
|
|
66
|
-
GPT_5_1_CODEX_MINI: `${AZURE_PREFIX}gpt-5.1-codex-mini`,
|
|
67
|
-
GPT_5: `${AZURE_PREFIX}gpt-5`,
|
|
68
|
-
GPT_5_NANO: `${AZURE_PREFIX}gpt-5-nano`,
|
|
69
|
-
GPT_5_MINI: `${AZURE_PREFIX}gpt-5-mini`,
|
|
70
|
-
};
|
|
71
|
-
exports.AZURE_MODELS = AZURE_MODELS;
|
|
72
44
|
// Primario Azure por tier (antes que Gemini en todos los tiers → Azure > Gemini).
|
|
73
45
|
// El modelo Gemini que el tier resuelve (PRODUCTION_MODELS/FAST_MODELS/... vía AI_MODELS)
|
|
74
46
|
// se conserva como PRIMER fallback.
|
|
75
47
|
//
|
|
76
|
-
//
|
|
77
|
-
//
|
|
78
|
-
//
|
|
79
|
-
// PRO
|
|
48
|
+
// ⚠️ TEMPORAL: la cuenta de Azure solo tiene cuota para gpt-5.4-mini de momento,
|
|
49
|
+
// así que los TRES tiers apuntan a él. Cuando se apruebe cuota de gpt-5.5 y gpt-5.4-nano
|
|
50
|
+
// y se desplieguen en Azure, restaurar el mapeo por tier:
|
|
51
|
+
// PRO → AZURE_GPT_5_5 (frontier)
|
|
52
|
+
// LITE → AZURE_GPT_5_4_NANO (ultra-barato)
|
|
80
53
|
const AZURE_PRIMARY_MODELS = {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
LITE:
|
|
54
|
+
FLASH: AZURE_GPT_5_4_MINI,
|
|
55
|
+
PRO: AZURE_GPT_5_4_MINI,
|
|
56
|
+
LITE: AZURE_GPT_5_4_MINI,
|
|
84
57
|
};
|
|
85
58
|
exports.AZURE_PRIMARY_MODELS = AZURE_PRIMARY_MODELS;
|
|
86
|
-
// Fallbacks GPT (Azure) por tier: se agotan ANTES de caer a Gemini. Orden definido a mano.
|
|
87
|
-
// NO se incluyen las variantes -codex (especializadas en código); están en AZURE_MODELS.
|
|
88
|
-
const AZURE_FALLBACK_MODELS = {
|
|
89
|
-
// PRO (primario gpt-5.6-sol) → NO cae a gpt-5.6-luna
|
|
90
|
-
PRO: [
|
|
91
|
-
AZURE_MODELS.GPT_5_6_TERRA,
|
|
92
|
-
AZURE_MODELS.GPT_5_5,
|
|
93
|
-
AZURE_MODELS.GPT_5_4,
|
|
94
|
-
AZURE_MODELS.GPT_5_2,
|
|
95
|
-
AZURE_MODELS.GPT_5_1,
|
|
96
|
-
AZURE_MODELS.GPT_5,
|
|
97
|
-
],
|
|
98
|
-
// FLASH (primario gpt-5.6-terra)
|
|
99
|
-
FLASH: [
|
|
100
|
-
AZURE_MODELS.GPT_5_4_MINI,
|
|
101
|
-
AZURE_MODELS.GPT_5_MINI,
|
|
102
|
-
AZURE_MODELS.GPT_5_4,
|
|
103
|
-
AZURE_MODELS.GPT_5_2,
|
|
104
|
-
],
|
|
105
|
-
// LITE (primario gpt-5.6-luna)
|
|
106
|
-
LITE: [
|
|
107
|
-
AZURE_MODELS.GPT_5_4_NANO,
|
|
108
|
-
AZURE_MODELS.GPT_5_NANO,
|
|
109
|
-
AZURE_MODELS.GPT_5_4_MINI,
|
|
110
|
-
AZURE_MODELS.GPT_5_MINI,
|
|
111
|
-
],
|
|
112
|
-
};
|
|
113
|
-
exports.AZURE_FALLBACK_MODELS = AZURE_FALLBACK_MODELS;
|
|
114
59
|
// ⚠️ Bedrock/Claude retirado del enrutado: el provider, las constantes BEDROCK_CLAUDE_*
|
|
115
60
|
// y su pricing siguen disponibles (compat de exports), pero ningún tier ni fallback los
|
|
116
61
|
// referencia, así que Bedrock nunca se selecciona. Cascada efectiva: Azure → Gemini.
|
|
@@ -38,19 +38,14 @@ function getAIStudioApiKey() {
|
|
|
38
38
|
* ```
|
|
39
39
|
*/
|
|
40
40
|
function createGoogleModel(modelKey = 'FLASH') {
|
|
41
|
-
var _a
|
|
42
|
-
// Primario: Azure gpt-5
|
|
41
|
+
var _a;
|
|
42
|
+
// Primario: Azure gpt-5 en todos los tiers (orden global Azure > Claude > Gemini).
|
|
43
43
|
const primaryName = constants_1.AZURE_PRIMARY_MODELS[modelKey];
|
|
44
|
-
// El modelo
|
|
45
|
-
|
|
44
|
+
// El modelo Claude que resuelve el tier actual (PRODUCTION/SEMI/FAST/TRIAL vía AI_MODELS)
|
|
45
|
+
// se conserva como PRIMER fallback, manteniendo el control de coste por tier en la cascada.
|
|
46
|
+
const claudeFallbackHead = constants_1.AI_MODELS[modelKey];
|
|
46
47
|
const model = createModelFromString(primaryName);
|
|
47
|
-
|
|
48
|
-
// si TODA la gama GPT falla, se cae a Gemini (Vertex + AI Studio).
|
|
49
|
-
model._fallbackModelNames = [
|
|
50
|
-
...((_a = constants_1.AZURE_FALLBACK_MODELS[modelKey]) !== null && _a !== void 0 ? _a : []),
|
|
51
|
-
geminiFallbackHead,
|
|
52
|
-
...((_b = constants_1.FALLBACK_MODELS[modelKey]) !== null && _b !== void 0 ? _b : []),
|
|
53
|
-
];
|
|
48
|
+
model._fallbackModelNames = [claudeFallbackHead, ...((_a = constants_1.FALLBACK_MODELS[modelKey]) !== null && _a !== void 0 ? _a : [])];
|
|
54
49
|
return model;
|
|
55
50
|
}
|
|
56
51
|
exports.createGoogleModel = createGoogleModel;
|
package/lib/cjs/prompt/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.calculateCost = exports.MODEL_PRICING = exports.AISTUDIO_PREFIX = exports.BEDROCK_CLAUDE_HAIKU = exports.BEDROCK_CLAUDE_SONNET_4 = exports.BEDROCK_CLAUDE_SONNET_4_5 = exports.BEDROCK_CLAUDE_OPUS_4_1 = exports.BEDROCK_CLAUDE_OPUS_4_5 = exports.BEDROCK_CLAUDE_SONNET = exports.BEDROCK_CLAUDE_OPUS = exports.FALLBACK_MODELS = exports.TRIAL_MODELS = exports.FAST_MODELS = exports.SEMI_MODELS = exports.PRODUCTION_MODELS = exports.AZURE_PRIMARY_MODELS = exports.
|
|
3
|
+
exports.calculateCost = exports.MODEL_PRICING = exports.AISTUDIO_PREFIX = exports.BEDROCK_CLAUDE_HAIKU = exports.BEDROCK_CLAUDE_SONNET_4 = exports.BEDROCK_CLAUDE_SONNET_4_5 = exports.BEDROCK_CLAUDE_OPUS_4_1 = exports.BEDROCK_CLAUDE_OPUS_4_5 = exports.BEDROCK_CLAUDE_SONNET = exports.BEDROCK_CLAUDE_OPUS = exports.FALLBACK_MODELS = exports.TRIAL_MODELS = exports.FAST_MODELS = exports.SEMI_MODELS = exports.PRODUCTION_MODELS = exports.AZURE_PRIMARY_MODELS = exports.AZURE_GPT_5_4_NANO = exports.AZURE_GPT_5_4_MINI = exports.AZURE_GPT_5_5 = exports.AZURE_GPT_5_4_NANO_DEPLOYMENT = exports.AZURE_GPT_5_4_MINI_DEPLOYMENT = exports.AZURE_GPT_5_5_DEPLOYMENT = exports.AZURE_PREFIX = exports.GOOGLE_MODELS = exports.AI_MODELS = exports.runWithModels = exports.MODEL_TIER = exports.createModelFromString = exports.createAzureModelFromString = exports.createBedrockModelFromString = exports.createGoogleModelFromString = exports.createGoogleModel = exports.runWithCostTracking = exports.generateText = exports.generateObject = void 0;
|
|
4
4
|
const ai_1 = require("./ai");
|
|
5
5
|
Object.defineProperty(exports, "generateObject", { enumerable: true, get: function () { return ai_1.generateObject; } });
|
|
6
6
|
Object.defineProperty(exports, "generateText", { enumerable: true, get: function () { return ai_1.generateText; } });
|
|
@@ -13,15 +13,12 @@ const constants_1 = require("./constants");
|
|
|
13
13
|
Object.defineProperty(exports, "AI_MODELS", { enumerable: true, get: function () { return constants_1.AI_MODELS; } });
|
|
14
14
|
Object.defineProperty(exports, "GOOGLE_MODELS", { enumerable: true, get: function () { return constants_1.GOOGLE_MODELS; } });
|
|
15
15
|
Object.defineProperty(exports, "AZURE_PREFIX", { enumerable: true, get: function () { return constants_1.AZURE_PREFIX; } });
|
|
16
|
-
Object.defineProperty(exports, "AZURE_GPT_5_6_DEPLOYMENT", { enumerable: true, get: function () { return constants_1.AZURE_GPT_5_6_DEPLOYMENT; } });
|
|
17
16
|
Object.defineProperty(exports, "AZURE_GPT_5_5_DEPLOYMENT", { enumerable: true, get: function () { return constants_1.AZURE_GPT_5_5_DEPLOYMENT; } });
|
|
18
17
|
Object.defineProperty(exports, "AZURE_GPT_5_4_MINI_DEPLOYMENT", { enumerable: true, get: function () { return constants_1.AZURE_GPT_5_4_MINI_DEPLOYMENT; } });
|
|
19
18
|
Object.defineProperty(exports, "AZURE_GPT_5_4_NANO_DEPLOYMENT", { enumerable: true, get: function () { return constants_1.AZURE_GPT_5_4_NANO_DEPLOYMENT; } });
|
|
20
|
-
Object.defineProperty(exports, "AZURE_GPT_5_6", { enumerable: true, get: function () { return constants_1.AZURE_GPT_5_6; } });
|
|
21
19
|
Object.defineProperty(exports, "AZURE_GPT_5_5", { enumerable: true, get: function () { return constants_1.AZURE_GPT_5_5; } });
|
|
22
20
|
Object.defineProperty(exports, "AZURE_GPT_5_4_MINI", { enumerable: true, get: function () { return constants_1.AZURE_GPT_5_4_MINI; } });
|
|
23
21
|
Object.defineProperty(exports, "AZURE_GPT_5_4_NANO", { enumerable: true, get: function () { return constants_1.AZURE_GPT_5_4_NANO; } });
|
|
24
|
-
Object.defineProperty(exports, "AZURE_MODELS", { enumerable: true, get: function () { return constants_1.AZURE_MODELS; } });
|
|
25
22
|
Object.defineProperty(exports, "AZURE_PRIMARY_MODELS", { enumerable: true, get: function () { return constants_1.AZURE_PRIMARY_MODELS; } });
|
|
26
23
|
Object.defineProperty(exports, "PRODUCTION_MODELS", { enumerable: true, get: function () { return constants_1.PRODUCTION_MODELS; } });
|
|
27
24
|
Object.defineProperty(exports, "SEMI_MODELS", { enumerable: true, get: function () { return constants_1.SEMI_MODELS; } });
|