@johpaz/hive-agents 1.1.5 → 1.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/hive.js +229813 -162547
- package/dist/tool-worker.js +68298 -1620
- package/dist/ui/assets/{A2UIPage-Dr3p75oE.js → A2UIPage-CxE3jH4_.js} +1 -1
- package/dist/ui/assets/{AgentCreateForm-DqYhH_gm.js → AgentCreateForm-SGj5AqAX.js} +1 -1
- package/dist/ui/assets/{AgentDetailPage-BVtE88U5.js → AgentDetailPage-CyYbqzHr.js} +1 -1
- package/dist/ui/assets/{AgentNewPage-BRpFxJIT.js → AgentNewPage-xvAmX6kw.js} +1 -1
- package/dist/ui/assets/{AgentsPage-BOIJ55cj.js → AgentsPage-CEWNs4Lt.js} +1 -1
- package/dist/ui/assets/{ApiClientPage-R9UDWfR2.js → ApiClientPage-NLw2wHjH.js} +1 -1
- package/dist/ui/assets/{ChannelsPage-C5V2BmjL.js → ChannelsPage-CmeXP-hI.js} +1 -1
- package/dist/ui/assets/{DashboardPage-B18gMzNj.js → DashboardPage-C3z4kZXD.js} +1 -1
- package/dist/ui/assets/{LoginPage-nrsYF9AY.js → LoginPage-DDisP8hm.js} +1 -1
- package/dist/ui/assets/{LogsPage-DICMU_7m.js → LogsPage-G9d2G1nL.js} +1 -1
- package/dist/ui/assets/{MeetingPage-xslJGfIz.js → MeetingPage-CKyjxtFr.js} +1 -1
- package/dist/ui/assets/{ModelSelector-BX4IvuYY.js → ModelSelector-VVwpDrYF.js} +1 -1
- package/dist/ui/assets/{Office3DPage-a6cuzt5X.js → Office3DPage-CYxB6z2p.js} +1 -1
- package/dist/ui/assets/ProvidersPage-CM9-E-Pf.js +1 -0
- package/dist/ui/assets/{RecoverPage-Blms3NBa.js → RecoverPage-Dr6qKgV5.js} +1 -1
- package/dist/ui/assets/{SettingsPage-BBeeq_QS.js → SettingsPage-BvD-vs5g.js} +1 -1
- package/dist/ui/assets/{SetupPage-CAjLseE_.js → SetupPage-BoVKIf4r.js} +1 -1
- package/dist/ui/assets/{VoicePage-BeSSYstD.js → VoicePage-CmudxYny.js} +1 -1
- package/dist/ui/assets/WebChatPage-CnoXpEOl.js +29 -0
- package/dist/ui/assets/{conversationsStore-DhM07qYi.js → conversationsStore-ns_ZfKgg.js} +1 -1
- package/dist/ui/assets/{dialog-BP3GTCPn.js → dialog-C3n2xYF2.js} +1 -1
- package/dist/ui/assets/{index-BG3nUPKq.js → index-C0W6p0lk.js} +3 -3
- package/dist/ui/assets/{useAudioDevices-zj0fuGwZ.js → useAudioDevices-CsPrtpWY.js} +1 -1
- package/dist/ui/assets/{useHiveAgentsModelLoad-Cd9p-bjs.js → useHiveAgentsModelLoad-nn4gON9g.js} +1 -1
- package/dist/ui/assets/{useProviders-Dj1k5PCk.js → useProviders-9tvEC3hX.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/package.json +1 -1
- package/packages/cli/src/commands/onboard.ts +3 -2
- package/packages/core/src/agent/minimal-loadout.ts +1 -0
- package/packages/core/src/agent/tool-selector.ts +4 -0
- package/packages/core/src/artifacts/store.ts +8 -2
- package/packages/core/src/channels/base.ts +26 -0
- package/packages/core/src/channels/discord.ts +18 -2
- package/packages/core/src/channels/slack.ts +37 -7
- package/packages/core/src/channels/telegram.ts +39 -11
- package/packages/core/src/channels/whatsapp.ts +16 -1
- package/packages/core/src/gateway/channel-notify.ts +42 -0
- package/packages/core/src/gateway/routes/artifacts.ts +4 -0
- package/packages/core/src/gateway/routes/multimodal.ts +19 -0
- package/packages/core/src/gateway/server.ts +40 -17
- package/packages/core/src/gateway/webchat-turn.ts +15 -13
- package/packages/core/src/multimodal/attachment-ingest.ts +175 -0
- package/packages/core/src/multimodal/vision-analyzer.ts +94 -0
- package/packages/core/src/multimodal/vision-service.ts +25 -0
- package/packages/core/src/storage/seed.ts +26 -6
- package/packages/core/src/tool-runtime/index.ts +2 -0
- package/packages/core/src/tools/core/index.ts +79 -1
- package/packages/core/src/tools/office/index.ts +9 -0
- package/packages/core/src/tools/office/office-editar-docx.ts +184 -0
- package/packages/core/src/tools/office/office-editar-pptx.ts +126 -0
- package/packages/core/src/tools/office/office-editar-xlsx.ts +122 -0
- package/packages/core/src/tools/office/office-escribir-docx.ts +3 -2
- package/packages/core/src/tools/office/office-escribir-pdf.ts +3 -2
- package/packages/core/src/tools/office/office-escribir-pptx.ts +3 -2
- package/packages/core/src/tools/office/office-escribir-xlsx.ts +3 -2
- package/packages/core/src/tools/office/office-leer-docx.ts +6 -2
- package/packages/core/src/tools/office/office-leer-pdf.ts +41 -57
- package/packages/core/src/tools/office/office-leer-pptx.ts +51 -88
- package/packages/core/src/tools/office/office-leer-xlsx.ts +6 -2
- package/packages/core/src/tools/office/pdf-text.ts +186 -0
- package/packages/core/src/tools/office/pptx-slides.ts +83 -0
- package/packages/core/src/tools/office/resolve-input.ts +49 -0
- package/dist/ui/assets/ProvidersPage-C8-xGoeh.js +0 -1
- package/dist/ui/assets/WebChatPage-Bat7uUfd.js +0 -29
|
@@ -64,7 +64,7 @@ import { handleGetRuntimeStatus } from "./routes/runtime";
|
|
|
64
64
|
import { handleGetEthics, handleActivateEthics, handleDeleteEthics } from "./routes/ethics";
|
|
65
65
|
import { handleGetTools, handleActivateTool, handleUpdateTool } from "./routes/tools";
|
|
66
66
|
import { handleGetTasks, handleUpdateTask } from "./routes/tasks";
|
|
67
|
-
import { setChannelSendFn } from "./channel-notify";
|
|
67
|
+
import { setChannelSendFn, setChannelFileFn } from "./channel-notify";
|
|
68
68
|
import {
|
|
69
69
|
acknowledgeNotification,
|
|
70
70
|
listPendingNotifications,
|
|
@@ -100,7 +100,7 @@ import { handleGetChannels, handleGetChannelConfig, handleActivateChannel, handl
|
|
|
100
100
|
import { handleGetMcpServers, handleGetMcpServerDetail, handleCreateMcpServer, handleUpdateMcpServer, handleDeleteMcpServer, handleToggleMcpServer, handleGetMCPServerTools } from "./routes/mcp";
|
|
101
101
|
import { handleGetModels, handleCreateModel, handleToggleModel, handleGetModelsConfig, handleUpdateModelsConfig, handleDeleteModel, handleUpdateModel } from "./routes/models";
|
|
102
102
|
import { handleGetVoiceProviders, handleGetConfiguredVoiceProviders, handleSaveVoiceProviderKey, handleTestVoice, handleGetChannelVoice, handleUpdateChannelVoice, handleGetVoiceProviderVoices } from "./routes/voice";
|
|
103
|
-
import { handleGetVisionProviders, handleGetChannelVision, handleUpdateChannelVision, handleOcrImage } from "./routes/multimodal";
|
|
103
|
+
import { handleGetVisionProviders, handleGetChannelVision, handleUpdateChannelVision, handleOcrImage, handleGetVisionAnalyzer, handleSetVisionAnalyzer } from "./routes/multimodal";
|
|
104
104
|
import { handleGetLocalTTSStatus, handleGetLocalTTSLogs, handleInstallLocalTTS, handleStartLocalTTS, handleStopLocalTTS, handleSpeakLocalTTS, handleGetAvailableModels, handleGetInstalledVoices, handleDownloadModel, handleGetDownloadLogs, initializeLocalTTS } from "./routes/tts-local";
|
|
105
105
|
import { handleCreateMeeting, handleListMeetings, handleGetMeeting, handleAddMeetingSegment, handleStopMeeting, handleGenerateMeetingReport, handleDownloadMeetingReport } from "./routes/meeting";
|
|
106
106
|
import { handleDownloadArtifact } from "./routes/artifacts";
|
|
@@ -262,6 +262,21 @@ export async function startGateway(
|
|
|
262
262
|
notificationId: metadata?.notificationId,
|
|
263
263
|
}, metadata?.accountId);
|
|
264
264
|
});
|
|
265
|
+
setChannelFileFn(async (channel, sessionId, file, metadata) => {
|
|
266
|
+
await channelManager.send(channel, sessionId, {
|
|
267
|
+
type: "message",
|
|
268
|
+
sessionId,
|
|
269
|
+
content: "",
|
|
270
|
+
document: {
|
|
271
|
+
artifactId: file.artifactId,
|
|
272
|
+
// La web descarga por HTTP; los canales de servidor leen el artifact del disco.
|
|
273
|
+
url: `/api/artifacts/${file.artifactId}/download?name=${encodeURIComponent(file.filename)}`,
|
|
274
|
+
filename: file.filename,
|
|
275
|
+
mimeType: file.mimeType,
|
|
276
|
+
caption: file.caption,
|
|
277
|
+
},
|
|
278
|
+
}, metadata?.accountId);
|
|
279
|
+
});
|
|
265
280
|
setNarrationDelivery(async (event) => {
|
|
266
281
|
// Voz en tiempo real: el hito se le inyecta al modelo para que lo cuente
|
|
267
282
|
// hablando. No corta el resto de la entrega — el usuario ve el proceso
|
|
@@ -535,31 +550,28 @@ export async function startGateway(
|
|
|
535
550
|
await channelManager.send(message.channel, message.sessionId, {
|
|
536
551
|
content: `⚠️ Error al procesar la imagen: ${(imgError as Error).message}`,
|
|
537
552
|
});
|
|
553
|
+
if (!messageContent?.trim()) return;
|
|
538
554
|
}
|
|
539
555
|
}
|
|
540
556
|
|
|
541
557
|
if (message.document) {
|
|
542
558
|
try {
|
|
543
|
-
const
|
|
544
|
-
const
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
caption: docInput.fileName,
|
|
551
|
-
};
|
|
552
|
-
const ocrText = await multimodalService.ocrImage(docImage, ocrProvider);
|
|
553
|
-
messageContent = ocrText
|
|
554
|
-
? `[Documento adjunto: ${docInput.fileName || "unknown"}]\n${ocrText}\n\n${messageContent || ""}`
|
|
555
|
-
: messageContent || "";
|
|
559
|
+
const { ingestDocument, formatAttachmentManifest } = await import("../multimodal/attachment-ingest");
|
|
560
|
+
const att = await ingestDocument({
|
|
561
|
+
...message.document,
|
|
562
|
+
userId: `${message.channel}:${message.peerId}`,
|
|
563
|
+
});
|
|
564
|
+
const manifest = formatAttachmentManifest(att);
|
|
565
|
+
messageContent = `${manifest}\n\n${messageContent || ""}`;
|
|
556
566
|
inputType = "document";
|
|
557
|
-
log.info(`📄
|
|
567
|
+
log.info(`📄 Documento ingerido: ${att.fileName} (${att.kind}, ${att.size} bytes)`);
|
|
558
568
|
} catch (docError) {
|
|
559
569
|
log.error(`❌ Document processing failed: ${(docError as Error).message}`);
|
|
560
570
|
await channelManager.send(message.channel, message.sessionId, {
|
|
561
|
-
content: `⚠️
|
|
571
|
+
content: `⚠️ No pude procesar el documento: ${(docError as Error).message}`,
|
|
562
572
|
});
|
|
573
|
+
// Sin texto del usuario no hay nada más que responder: ya se le avisó del fallo.
|
|
574
|
+
if (!messageContent?.trim()) return;
|
|
563
575
|
}
|
|
564
576
|
}
|
|
565
577
|
}
|
|
@@ -1914,6 +1926,14 @@ export async function startGateway(
|
|
|
1914
1926
|
return await handleGetVisionProviders(req, addCorsHeaders)
|
|
1915
1927
|
}
|
|
1916
1928
|
|
|
1929
|
+
if (url.pathname === "/api/multimodal/analyzer" && req.method === "GET") {
|
|
1930
|
+
return await handleGetVisionAnalyzer(req, addCorsHeaders)
|
|
1931
|
+
}
|
|
1932
|
+
|
|
1933
|
+
if (url.pathname === "/api/multimodal/analyzer" && req.method === "PUT") {
|
|
1934
|
+
return await handleSetVisionAnalyzer(req, addCorsHeaders)
|
|
1935
|
+
}
|
|
1936
|
+
|
|
1917
1937
|
if (url.pathname === "/api/multimodal/ocr" && req.method === "POST") {
|
|
1918
1938
|
return await handleOcrImage(req, addCorsHeaders)
|
|
1919
1939
|
}
|
|
@@ -2105,6 +2125,9 @@ export async function startGateway(
|
|
|
2105
2125
|
},
|
|
2106
2126
|
|
|
2107
2127
|
websocket: {
|
|
2128
|
+
// Bun corta el socket en silencio por encima de 16 MB y un adjunto viaja en base64 (+33 %):
|
|
2129
|
+
// un .pptx de 10 MB ya no entraba. 80 MB cubre el tope de 50 MB de MAX_ATTACHMENT_BYTES.
|
|
2130
|
+
maxPayloadLength: 80 * 1024 * 1024,
|
|
2108
2131
|
async open(ws) {
|
|
2109
2132
|
const data = ws.data;
|
|
2110
2133
|
|
|
@@ -278,26 +278,28 @@ export async function runWebchatTurn(
|
|
|
278
278
|
}
|
|
279
279
|
} catch (imgError) {
|
|
280
280
|
log.error(`❌ Image processing failed: ${(imgError as Error).message}`);
|
|
281
|
+
// El agente debe saber que SÍ llegó una imagen y por qué no se pudo leer, para
|
|
282
|
+
// decírselo al usuario en vez de pedirle que describa un archivo "sin contenido".
|
|
283
|
+
finalMessageContent = `[El usuario adjuntó una imagen pero no se pudo leer: ${(imgError as Error).message}]\n\n${finalMessageContent || ""}`;
|
|
281
284
|
}
|
|
282
285
|
}
|
|
283
286
|
|
|
284
287
|
if (payload.document) {
|
|
285
288
|
try {
|
|
286
|
-
const
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
? `[Documento adjunto]\n${ocrText}\n\n${finalMessageContent || ""}`
|
|
297
|
-
: finalMessageContent || "";
|
|
298
|
-
log.info(`📄 Document OCR result: ${ocrText.substring(0, 100)}...`);
|
|
289
|
+
const { ingestDocument, formatAttachmentManifest } = await import("../multimodal/attachment-ingest");
|
|
290
|
+
const att = await ingestDocument({
|
|
291
|
+
base64: payload.document.base64,
|
|
292
|
+
mimeType: payload.document.mimeType,
|
|
293
|
+
fileName: payload.document.fileName,
|
|
294
|
+
userId,
|
|
295
|
+
});
|
|
296
|
+
const manifest = formatAttachmentManifest(att);
|
|
297
|
+
finalMessageContent = `${manifest}\n\n${finalMessageContent || ""}`;
|
|
298
|
+
log.info(`📄 Documento ingerido desde WebChat: ${att.fileName} (${att.kind}, ${att.size} bytes)`);
|
|
299
299
|
} catch (docError) {
|
|
300
300
|
log.error(`❌ Document processing failed: ${(docError as Error).message}`);
|
|
301
|
+
processReporter?.step({ type: "tool_result" });
|
|
302
|
+
finalMessageContent = `[El usuario adjuntó un documento pero no se pudo procesar: ${(docError as Error).message}]\n\n${finalMessageContent || ""}`;
|
|
301
303
|
}
|
|
302
304
|
}
|
|
303
305
|
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ingesta única de documentos adjuntos (pdf, docx, xlsx, pptx, csv, txt…).
|
|
3
|
+
*
|
|
4
|
+
* Antes cada canal mandaba el documento a un modelo de visión como si fuera una
|
|
5
|
+
* imagen (falla con Word/Excel y recorta los PDF). Ahora el archivo se guarda en
|
|
6
|
+
* el artifact store, se extrae una vista previa corta de forma nativa y el
|
|
7
|
+
* agente recibe un manifiesto; el contenido completo lo lee bajo demanda con
|
|
8
|
+
* las tools office_leer_* / fs_read usando la ruta que figura en el manifiesto.
|
|
9
|
+
*/
|
|
10
|
+
import { extname } from "node:path"
|
|
11
|
+
import { createArtifact } from "../artifacts/store"
|
|
12
|
+
import { cargarXlsx } from "../tools/office/xlsx-loader"
|
|
13
|
+
import { extraerTextoPdf } from "../tools/office/pdf-text"
|
|
14
|
+
import { listarSlides, textoDeXml } from "../tools/office/pptx-slides"
|
|
15
|
+
import { logger } from "../utils/logger"
|
|
16
|
+
|
|
17
|
+
const log = logger.child("attachment-ingest")
|
|
18
|
+
|
|
19
|
+
/** Tope duro de tamaño de un adjunto (los canales ya limitan antes, esto es la red de seguridad). */
|
|
20
|
+
export const MAX_ATTACHMENT_BYTES = 50 * 1024 * 1024
|
|
21
|
+
const PREVIEW_CHARS = 1500
|
|
22
|
+
|
|
23
|
+
export type AttachmentKind = "pdf" | "docx" | "xlsx" | "pptx" | "text" | "other"
|
|
24
|
+
|
|
25
|
+
export interface IngestedAttachment {
|
|
26
|
+
fileName: string
|
|
27
|
+
mimeType: string
|
|
28
|
+
size: number
|
|
29
|
+
kind: AttachmentKind
|
|
30
|
+
artifactId: string
|
|
31
|
+
/** Ruta absoluta en disco, con la extensión original. */
|
|
32
|
+
path: string
|
|
33
|
+
/** Primeros caracteres del contenido; vacío si no hay texto extraíble. */
|
|
34
|
+
preview: string
|
|
35
|
+
/** Páginas del PDF (solo PDF). */
|
|
36
|
+
pages?: number
|
|
37
|
+
/** true si es un PDF sin capa de texto (escaneado): no se puede leer sin OCR. */
|
|
38
|
+
scanned: boolean
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const EXT_KIND: Record<string, AttachmentKind> = {
|
|
42
|
+
".pdf": "pdf", ".docx": "docx", ".xlsx": "xlsx", ".xlsm": "xlsx", ".pptx": "pptx",
|
|
43
|
+
".txt": "text", ".md": "text", ".csv": "text", ".tsv": "text", ".json": "text",
|
|
44
|
+
".xml": "text", ".yaml": "text", ".yml": "text", ".log": "text", ".html": "text",
|
|
45
|
+
}
|
|
46
|
+
const EXT_MIME: Record<string, string> = {
|
|
47
|
+
".pdf": "application/pdf",
|
|
48
|
+
".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
49
|
+
".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
50
|
+
".xlsm": "application/vnd.ms-excel.sheet.macroEnabled.12",
|
|
51
|
+
".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
52
|
+
".csv": "text/csv", ".md": "text/markdown", ".txt": "text/plain", ".json": "application/json",
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** La extensión manda sobre el mime: WhatsApp, por ejemplo, declara pdf por defecto. */
|
|
56
|
+
export function classifyAttachment(fileName: string, mimeType: string): { kind: AttachmentKind; mimeType: string } {
|
|
57
|
+
const ext = extname(fileName).toLowerCase()
|
|
58
|
+
if (EXT_KIND[ext]) return { kind: EXT_KIND[ext], mimeType: EXT_MIME[ext] ?? mimeType }
|
|
59
|
+
if (/pdf/i.test(mimeType)) return { kind: "pdf", mimeType }
|
|
60
|
+
if (/wordprocessingml/i.test(mimeType)) return { kind: "docx", mimeType }
|
|
61
|
+
if (/spreadsheetml|ms-excel/i.test(mimeType)) return { kind: "xlsx", mimeType }
|
|
62
|
+
if (/presentationml/i.test(mimeType)) return { kind: "pptx", mimeType }
|
|
63
|
+
if (/^text\//i.test(mimeType)) return { kind: "text", mimeType }
|
|
64
|
+
return { kind: "other", mimeType }
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function clip(text: string): string {
|
|
68
|
+
const t = text.replace(/\r/g, "").replace(/\n{3,}/g, "\n\n").trim()
|
|
69
|
+
return t.length > PREVIEW_CHARS ? `${t.slice(0, PREVIEW_CHARS)}…` : t
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async function extractPreview(kind: AttachmentKind, bytes: Buffer, info: { pages?: number; sinTexto?: boolean }): Promise<string> {
|
|
73
|
+
try {
|
|
74
|
+
switch (kind) {
|
|
75
|
+
case "text":
|
|
76
|
+
return clip(bytes.toString("utf8"))
|
|
77
|
+
case "docx": {
|
|
78
|
+
const mammoth = await import("mammoth")
|
|
79
|
+
return clip((await mammoth.extractRawText({ buffer: bytes })).value)
|
|
80
|
+
}
|
|
81
|
+
case "xlsx": {
|
|
82
|
+
const XLSX = await cargarXlsx()
|
|
83
|
+
const wb = XLSX.read(bytes, { type: "buffer" })
|
|
84
|
+
const parts = wb.SheetNames.slice(0, 3).map((name) => {
|
|
85
|
+
const csv = XLSX.utils.sheet_to_csv(wb.Sheets[name]).split("\n").slice(0, 15).join("\n")
|
|
86
|
+
return `# Hoja "${name}"\n${csv}`
|
|
87
|
+
})
|
|
88
|
+
const extra = wb.SheetNames.length > 3 ? `\n(+${wb.SheetNames.length - 3} hojas más)` : ""
|
|
89
|
+
return clip(parts.join("\n\n") + extra)
|
|
90
|
+
}
|
|
91
|
+
case "pdf": {
|
|
92
|
+
const r = await extraerTextoPdf(new Uint8Array(bytes), { hasta: 3, maxCaracteres: PREVIEW_CHARS * 2 })
|
|
93
|
+
info.pages = r.totalPaginas
|
|
94
|
+
info.sinTexto = r.sinTexto
|
|
95
|
+
return r.sinTexto ? "" : clip(r.texto.replace(/--- Página \d+ ---\n?/g, ""))
|
|
96
|
+
}
|
|
97
|
+
case "pptx": {
|
|
98
|
+
const JSZip = (await import("jszip")).default
|
|
99
|
+
const zip = await JSZip.loadAsync(bytes)
|
|
100
|
+
const slides = await listarSlides(zip)
|
|
101
|
+
info.pages = slides.length
|
|
102
|
+
const partes: string[] = []
|
|
103
|
+
for (const slide of slides.slice(0, 5)) {
|
|
104
|
+
const t = textoDeXml(await zip.file(slide.archivo)!.async("string"))
|
|
105
|
+
partes.push(`# Diapositiva ${slide.numero}\n${t}`)
|
|
106
|
+
}
|
|
107
|
+
return clip(partes.join("\n\n"))
|
|
108
|
+
}
|
|
109
|
+
default:
|
|
110
|
+
return ""
|
|
111
|
+
}
|
|
112
|
+
} catch (err) {
|
|
113
|
+
log.warn(`No se pudo extraer vista previa (${kind}): ${(err as Error).message}`)
|
|
114
|
+
return ""
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async function toBytes(input: { buffer?: Buffer; base64?: string; url?: string }): Promise<Buffer> {
|
|
119
|
+
if (input.buffer) return Buffer.from(input.buffer)
|
|
120
|
+
if (input.base64) return Buffer.from(input.base64.replace(/^data:[^,]+,/, ""), "base64")
|
|
121
|
+
if (input.url) {
|
|
122
|
+
const res = await fetch(input.url, { signal: AbortSignal.timeout(60_000) })
|
|
123
|
+
if (!res.ok) throw new Error(`no se pudo descargar el archivo (HTTP ${res.status})`)
|
|
124
|
+
return Buffer.from(await res.arrayBuffer())
|
|
125
|
+
}
|
|
126
|
+
throw new Error("el adjunto no trae contenido (ni buffer, ni base64, ni url)")
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export async function ingestDocument(input: {
|
|
130
|
+
buffer?: Buffer
|
|
131
|
+
base64?: string
|
|
132
|
+
url?: string
|
|
133
|
+
mimeType?: string
|
|
134
|
+
fileName?: string
|
|
135
|
+
userId: string
|
|
136
|
+
}): Promise<IngestedAttachment> {
|
|
137
|
+
const bytes = await toBytes(input)
|
|
138
|
+
if (bytes.byteLength === 0) throw new Error("el archivo está vacío")
|
|
139
|
+
if (bytes.byteLength > MAX_ATTACHMENT_BYTES) {
|
|
140
|
+
throw new Error(`el archivo pesa ${(bytes.byteLength / 1048576).toFixed(1)} MB y el máximo es ${MAX_ATTACHMENT_BYTES / 1048576} MB`)
|
|
141
|
+
}
|
|
142
|
+
const fileName = (input.fileName || "adjunto").replace(/[\\/\0]/g, "_")
|
|
143
|
+
const { kind, mimeType } = classifyAttachment(fileName, input.mimeType || "application/octet-stream")
|
|
144
|
+
const artifact = await createArtifact({
|
|
145
|
+
bytes, mimeType, kind: "attachment", userId: input.userId, extension: extname(fileName),
|
|
146
|
+
})
|
|
147
|
+
const info: { pages?: number; sinTexto?: boolean } = {}
|
|
148
|
+
const preview = await extractPreview(kind, bytes, info)
|
|
149
|
+
return {
|
|
150
|
+
fileName, mimeType: artifact.mime_type, size: bytes.byteLength, kind,
|
|
151
|
+
artifactId: artifact.id, path: artifact.path, preview,
|
|
152
|
+
pages: info.pages, scanned: !!info.sinTexto,
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const READER: Record<AttachmentKind, string> = {
|
|
157
|
+
pdf: "office_leer_pdf", docx: "office_leer_docx", xlsx: "office_leer_xlsx",
|
|
158
|
+
pptx: "office_leer_pptx", text: "fs_read", other: "",
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** Texto que se antepone al mensaje del usuario para que el agente sepa qué recibió y cómo leerlo. */
|
|
162
|
+
export function formatAttachmentManifest(a: IngestedAttachment): string {
|
|
163
|
+
const kb = a.size < 1048576 ? `${Math.max(1, Math.round(a.size / 1024))} KB` : `${(a.size / 1048576).toFixed(1)} MB`
|
|
164
|
+
const reader = READER[a.kind]
|
|
165
|
+
const lines = [
|
|
166
|
+
`[Archivo adjunto: ${a.fileName} · ${a.mimeType} · ${kb}${a.pages ? ` · ${a.pages} ${a.kind === "pptx" ? "diapositivas" : "páginas"}` : ""}]`,
|
|
167
|
+
`Ruta: ${a.path}`,
|
|
168
|
+
`artifact_id: ${a.artifactId}`,
|
|
169
|
+
reader ? `Para leerlo completo usa la tool ${reader} con esa ruta.` : "Formato sin lector nativo.",
|
|
170
|
+
]
|
|
171
|
+
if (a.preview) lines.push(`Vista previa:\n${a.preview}`)
|
|
172
|
+
else if (a.scanned) lines.push("Este PDF no tiene texto extraíble (parece escaneado, solo imágenes) y no se puede leer sin OCR. Dile al usuario que lo envíe en formato editable o que pegue el texto.")
|
|
173
|
+
else lines.push("No se pudo extraer texto.")
|
|
174
|
+
return lines.join("\n")
|
|
175
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Modelo analizador de imágenes del sistema.
|
|
3
|
+
*
|
|
4
|
+
* Es independiente del modelo de chat: cuando el modelo del agente no ve
|
|
5
|
+
* imágenes (o hay que leer un adjunto), se le pide a ESTE modelo que describa y
|
|
6
|
+
* transcriba la imagen, y el agente recibe el texto. Un solo modelo para todos
|
|
7
|
+
* los canales, elegido en la pestaña Imagen de Providers.
|
|
8
|
+
*/
|
|
9
|
+
import { col } from "../storage/hive"
|
|
10
|
+
import type { ModelDoc } from "../storage/collections"
|
|
11
|
+
import { logger } from "../utils/logger"
|
|
12
|
+
import type { ImageInput } from "./types"
|
|
13
|
+
|
|
14
|
+
const log = logger.child("vision-analyzer")
|
|
15
|
+
|
|
16
|
+
const SETTINGS_COLLECTION = "system_settings"
|
|
17
|
+
const SETTING_ID = "vision_analyzer"
|
|
18
|
+
const IMAGE_MIME = /^image\/(png|jpe?g|webp|gif)$/i
|
|
19
|
+
|
|
20
|
+
export const ANALYZER_PROMPT =
|
|
21
|
+
"Describe el contenido de esta imagen en detalle. Si hay texto, tablas o números, transcríbelos exactamente. " +
|
|
22
|
+
"Si es un documento, un recibo o una captura de pantalla, resume su estructura y lo importante."
|
|
23
|
+
|
|
24
|
+
function hasVision(model: ModelDoc): boolean {
|
|
25
|
+
try { return (JSON.parse(model.capabilities || "[]") as string[]).includes("vision") } catch { return false }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export async function getVisionAnalyzerModelId(): Promise<string | null> {
|
|
29
|
+
const entry = await (await col<{ model_id: string | null }>(SETTINGS_COLLECTION)).get(SETTING_ID)
|
|
30
|
+
return entry?.doc.model_id || null
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Guarda el modelo analizador (null lo quita). Solo acepta modelos LLM con visión. */
|
|
34
|
+
export async function setVisionAnalyzerModelId(modelId: string | null): Promise<void> {
|
|
35
|
+
if (modelId) {
|
|
36
|
+
const entry = await (await col<ModelDoc>("models")).get(modelId)
|
|
37
|
+
if (!entry) throw new Error(`El modelo ${modelId} no existe`)
|
|
38
|
+
if (entry.doc.model_type !== "llm" || !hasVision(entry.doc)) {
|
|
39
|
+
throw new Error(`El modelo ${entry.doc.name} no tiene capacidad de visión`)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const settings = await col<{ model_id: string | null }>(SETTINGS_COLLECTION)
|
|
43
|
+
const current = await settings.get(SETTING_ID)
|
|
44
|
+
await settings.put(SETTING_ID, { model_id: modelId }, { expectedVersion: current?.version ?? 0 })
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function toDataUrl(image: ImageInput): Promise<string | null> {
|
|
48
|
+
const mime = image.mimeType || "image/jpeg"
|
|
49
|
+
if (!IMAGE_MIME.test(mime)) return null // PDF y otros formatos: los atiende el OCR de siempre
|
|
50
|
+
if (image.type === "url") return image.data as string
|
|
51
|
+
const base64 = image.type === "buffer" ? Buffer.from(image.data as Buffer).toString("base64") : (image.data as string)
|
|
52
|
+
return `data:${mime};base64,${base64}`
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Describe la imagen con el modelo analizador. Devuelve null si no hay modelo
|
|
57
|
+
* configurado o la entrada no es una imagen (el llamador usa su respaldo);
|
|
58
|
+
* lanza si el modelo configurado falla, para que el fallo quede en el log.
|
|
59
|
+
*/
|
|
60
|
+
export async function analyzeImage(image: ImageInput): Promise<string | null> {
|
|
61
|
+
const modelId = await getVisionAnalyzerModelId()
|
|
62
|
+
if (!modelId) return null
|
|
63
|
+
const url = await toDataUrl(image)
|
|
64
|
+
if (!url) return null
|
|
65
|
+
|
|
66
|
+
const entry = await (await col<ModelDoc>("models")).get(modelId)
|
|
67
|
+
if (!entry) throw new Error(`El modelo analizador ${modelId} ya no existe`)
|
|
68
|
+
|
|
69
|
+
const { callLLM, resolveProviderConfig, LLM_ERROR_PREFIX } = await import("../agent/llm-client")
|
|
70
|
+
const cfg = await resolveProviderConfig(entry.doc.provider_id, modelId)
|
|
71
|
+
if (!cfg.apiKey && entry.doc.provider_id !== "ollama") {
|
|
72
|
+
throw new Error(`Falta la API key de ${entry.doc.provider_id} para el modelo analizador`)
|
|
73
|
+
}
|
|
74
|
+
const res = await callLLM({
|
|
75
|
+
...cfg,
|
|
76
|
+
// La clave tal cual: el adaptador del provider ya quita su propio prefijo al armar el request.
|
|
77
|
+
// Quitarlo aquí también lo recortaba dos veces (nvidia/nvidia/x → x) y daba 404.
|
|
78
|
+
model: modelId,
|
|
79
|
+
maxTokens: 2000,
|
|
80
|
+
temperature: 0.1,
|
|
81
|
+
messages: [{
|
|
82
|
+
role: "user",
|
|
83
|
+
content: [
|
|
84
|
+
{ type: "text", text: image.caption ? `${ANALYZER_PROMPT}\nContexto del usuario: ${image.caption}` : ANALYZER_PROMPT },
|
|
85
|
+
{ type: "image_url", image_url: { url } },
|
|
86
|
+
],
|
|
87
|
+
}],
|
|
88
|
+
})
|
|
89
|
+
if (res.stop_reason === "error" || res.content.startsWith(LLM_ERROR_PREFIX)) {
|
|
90
|
+
throw new Error(res.content.replace(LLM_ERROR_PREFIX, "").trim() || "el modelo analizador falló")
|
|
91
|
+
}
|
|
92
|
+
log.info(`Imagen analizada con ${entry.doc.provider_id}/${modelId} (${res.content.length} caracteres)`)
|
|
93
|
+
return res.content
|
|
94
|
+
}
|
|
@@ -63,6 +63,31 @@ class MultimodalService {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
async ocrImage(image: ImageInput, providerId?: string): Promise<string> {
|
|
66
|
+
// Primero el modelo analizador del sistema (elegido en la pestaña Imagen); si no hay
|
|
67
|
+
// uno o no es una imagen, se usa el OCR por provider de siempre.
|
|
68
|
+
let analyzerError: string | null = null
|
|
69
|
+
try {
|
|
70
|
+
const { analyzeImage } = await import("./vision-analyzer")
|
|
71
|
+
const text = await analyzeImage(image)
|
|
72
|
+
if (text !== null) return text
|
|
73
|
+
} catch (err) {
|
|
74
|
+
analyzerError = (err as Error).message
|
|
75
|
+
log.warn(`El modelo analizador falló, pruebo el OCR por provider: ${analyzerError}`)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
try {
|
|
79
|
+
return await this.ocrWithProvider(image, providerId)
|
|
80
|
+
} catch (err) {
|
|
81
|
+
// Si el analizador ya había fallado, el error útil es ese: el del respaldo (casi siempre
|
|
82
|
+
// "falta la clave de OpenAI") solo confunde.
|
|
83
|
+
if (analyzerError) {
|
|
84
|
+
throw new Error(`El modelo analizador falló: ${analyzerError} Además el OCR de respaldo no está disponible (${(err as Error).message}).`)
|
|
85
|
+
}
|
|
86
|
+
throw err
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
private async ocrWithProvider(image: ImageInput, providerId?: string): Promise<string> {
|
|
66
91
|
const resolved = providerId || "openai"
|
|
67
92
|
|
|
68
93
|
if (resolved === "openai") {
|
|
@@ -150,6 +150,7 @@ export const SEED_DATA: SeedData = {
|
|
|
150
150
|
|
|
151
151
|
// 9. CORE — Notificaciones y notas
|
|
152
152
|
{ id: "notify", name: "notify", category: "core", description: "Enviar notificación al usuario. Sinónimos: notificar, enviar notificación, alertar, aviso" },
|
|
153
|
+
{ id: "send_file", name: "send_file", category: "core", description: "Enviar un archivo (Word, Excel, PDF, imagen) al usuario por el chat actual. Sinónimos: enviar archivo, enviar documento, devolver archivo corregido, mandar excel, mandar word, mandar pdf" },
|
|
153
154
|
{ id: "save_note", name: "save_note", category: "core", description: "Guardar nota persistente en el scratchpad. Sinónimos: guardar nota, escribir nota, recordatorio rápido, apuntar" },
|
|
154
155
|
{ id: "report_progress", name: "report_progress", category: "core", description: "Reportar progreso actual al usuario. Sinónimos: reportar progreso, informar estado, actualizar progreso, porcentaje" },
|
|
155
156
|
{ id: "conversation_read", name: "conversation_read", category: "core", description: "Recuperar mensajes anteriores de esta conversación por ID o búsqueda de texto. Sinónimos: leer conversación, recuperar contexto, historial omitido" },
|
|
@@ -163,6 +164,9 @@ export const SEED_DATA: SeedData = {
|
|
|
163
164
|
{ id: "office_escribir_docx", name: "office_escribir_docx", category: "office", description: "Generar un archivo Word (.docx) con párrafos, títulos y tablas. Sinónimos: crear word, generar docx, escribir documento word, exportar a docx" },
|
|
164
165
|
{ id: "office_leer_xlsx", name: "office_leer_xlsx", category: "office", description: "Leer un archivo Excel (.xlsx) y retornar hojas con datos en JSON (filas y columnas). Sinónimos: leer excel, abrir xlsx, extraer datos de excel, hojas excel" },
|
|
165
166
|
{ id: "office_escribir_xlsx", name: "office_escribir_xlsx", category: "office", description: "Generar un archivo Excel (.xlsx) desde un objeto JSON con hojas, filas y columnas. Sinónimos: crear excel, generar xlsx, escribir excel, exportar a xlsx" },
|
|
167
|
+
{ id: "office_editar_xlsx", name: "office_editar_xlsx", category: "office", description: "Editar un Excel (.xlsx) existente cambiando solo celdas indicadas y conservando el formato; guarda una copia. Sinónimos: editar excel, corregir excel, modificar celdas, mejorar planilla" },
|
|
168
|
+
{ id: "office_editar_docx", name: "office_editar_docx", category: "office", description: "Editar un Word (.docx) existente: reemplazar texto y añadir párrafos conservando estilos; guarda una copia. Sinónimos: editar word, corregir word, reemplazar texto en documento, mejorar documento" },
|
|
169
|
+
{ id: "office_editar_pptx", name: "office_editar_pptx", category: "office", description: "Editar un PowerPoint (.pptx) existente reemplazando texto en diapositivas y notas, conservando diseño e imágenes; guarda una copia. Sinónimos: editar powerpoint, corregir presentación, reemplazar texto en diapositivas, mejorar pptx" },
|
|
166
170
|
{ id: "office_leer_pptx", name: "office_leer_pptx", category: "office", description: "Leer un archivo PowerPoint (.pptx) y retornar el texto de cada diapositiva como array estructurado. Sinónimos: leer powerpoint, abrir pptx, extraer texto de presentacion, contenido slides" },
|
|
167
171
|
{ id: "office_escribir_pptx", name: "office_escribir_pptx", category: "office", description: "Generar un archivo PowerPoint (.pptx) desde un array de diapositivas con título y contenido. Sinónimos: crear powerpoint, generar pptx, escribir presentacion, exportar a pptx" },
|
|
168
172
|
|
|
@@ -295,7 +299,14 @@ export const SEED_DATA: SeedData = {
|
|
|
295
299
|
// OpenRouter renombró qwen/qwen3.8-max a su versión fechada: mismo contexto
|
|
296
300
|
// y precio, ahora también con imagen. Verificado 2026-09-10.
|
|
297
301
|
{ id: "qwen/qwen3.8-max-0902", providerId: "openrouter", name: "Qwen3.8 Max (OR)", modelType: "llm", contextWindow: 1000000, capabilities: JSON.stringify(["chat", "vision", "json_mode", "function_calling", "streaming", "reasoning"]), inputPer1M: 2, outputPer1M: 6 },
|
|
298
|
-
{ id: "qwen/qwen3.7-flash", providerId: "openrouter", name: "Qwen3.7 Flash (OR)", modelType: "llm", contextWindow: 1000000, capabilities: JSON.stringify(["chat", "json_mode", "function_calling", "streaming"]), inputPer1M: 0.03, outputPer1M: 0.13 },
|
|
302
|
+
{ id: "qwen/qwen3.7-flash", providerId: "openrouter", name: "Qwen3.7 Flash (OR)", modelType: "llm", contextWindow: 1000000, capabilities: JSON.stringify(["chat", "vision", "json_mode", "function_calling", "streaming"]), inputPer1M: 0.03, outputPer1M: 0.13 },
|
|
303
|
+
{ id: "qwen/qwen4-max", providerId: "openrouter", name: "Qwen4 Max (OR)", modelType: "llm", contextWindow: 1000000, capabilities: JSON.stringify(["chat", "vision", "json_mode", "function_calling", "streaming", "reasoning"]), inputPer1M: 1.425, outputPer1M: 4.275 },
|
|
304
|
+
{ id: "qwen/qwen3.8-flash", providerId: "openrouter", name: "Qwen3.8 Flash (OR)", modelType: "llm", contextWindow: 1000000, capabilities: JSON.stringify(["chat", "vision", "json_mode", "function_calling", "streaming", "reasoning"]), inputPer1M: 0.15, outputPer1M: 0.47 },
|
|
305
|
+
{ id: "qwen/qwen3.8-omni-flash", providerId: "openrouter", name: "Qwen3.8 Omni Flash (OR)", modelType: "llm", contextWindow: 1000000, capabilities: JSON.stringify(["chat", "vision", "json_mode", "function_calling", "streaming", "reasoning"]), inputPer1M: 0.15, outputPer1M: 0.47 },
|
|
306
|
+
{ id: "qwen/qwen3.8-27b", providerId: "openrouter", name: "Qwen3.8 27B (OR)", modelType: "llm", contextWindow: 1024000, capabilities: JSON.stringify(["chat", "vision", "json_mode", "function_calling", "streaming", "reasoning"]), inputPer1M: 0.06, outputPer1M: 1.96 },
|
|
307
|
+
{ id: "qwen/qwen3.6-plus", providerId: "openrouter", name: "Qwen3.6 Plus (OR)", modelType: "llm", contextWindow: 1000000, capabilities: JSON.stringify(["chat", "vision", "json_mode", "function_calling", "streaming", "reasoning"]), inputPer1M: 0.325, outputPer1M: 1.95 },
|
|
308
|
+
{ id: "qwen/qwen3.6-35b-a3b", providerId: "openrouter", name: "Qwen3.6 35B A3B (OR)", modelType: "llm", contextWindow: 262144, capabilities: JSON.stringify(["chat", "vision", "json_mode", "function_calling", "streaming", "reasoning"]), inputPer1M: 0.1, outputPer1M: 0.9 },
|
|
309
|
+
{ id: "qwen/qwen3-vl-235b-a22b-instruct", providerId: "openrouter", name: "Qwen3 VL 235B (OR)", modelType: "llm", contextWindow: 262144, capabilities: JSON.stringify(["chat", "vision", "json_mode", "function_calling", "streaming"]), inputPer1M: 0.21, outputPer1M: 1.9 },
|
|
299
310
|
// xAI
|
|
300
311
|
{ id: "x-ai/grok-4.5", providerId: "openrouter", name: "Grok 4.5 (OR)", modelType: "llm", contextWindow: 500000, capabilities: JSON.stringify(["chat", "vision", "json_mode", "function_calling", "streaming", "reasoning"]), inputPer1M: 2, outputPer1M: 6 },
|
|
301
312
|
// Mistral
|
|
@@ -336,8 +347,8 @@ export const SEED_DATA: SeedData = {
|
|
|
336
347
|
// estaba sembrado con 32768 en realidad tiene 262144.
|
|
337
348
|
{ id: "qwen3.7-max", providerId: "qwen", name: "Qwen 3.7 Max", modelType: "llm", contextWindow: 1000000, capabilities: JSON.stringify(["chat", "vision", "json_mode", "function_calling", "streaming", "reasoning"]), inputPer1M: 1.475, outputPer1M: 4.425 },
|
|
338
349
|
{ id: "qwen3.7-plus", providerId: "qwen", name: "Qwen 3.7 Plus", modelType: "llm", contextWindow: 1000000, capabilities: JSON.stringify(["chat", "vision", "json_mode", "function_calling", "streaming", "reasoning"]), inputPer1M: 0.32, outputPer1M: 1.28 },
|
|
339
|
-
{ id: "qwen3.6-flash", providerId: "qwen", name: "Qwen 3.6 Flash", modelType: "llm", contextWindow: 1000000, capabilities: JSON.stringify(["chat", "json_mode", "function_calling", "streaming"]), inputPer1M: 0.1875, outputPer1M: 1.125 },
|
|
340
|
-
{ id: "qwen3.5-omni-plus", providerId: "qwen", name: "Qwen 3.5 Omni Plus", modelType: "llm", contextWindow: 131072, capabilities: JSON.stringify(["chat", "json_mode", "function_calling", "streaming"]), inputPer1M: 0.32, outputPer1M: 1.28 },
|
|
350
|
+
{ id: "qwen3.6-flash", providerId: "qwen", name: "Qwen 3.6 Flash", modelType: "llm", contextWindow: 1000000, capabilities: JSON.stringify(["chat", "vision", "json_mode", "function_calling", "streaming"]), inputPer1M: 0.1875, outputPer1M: 1.125 },
|
|
351
|
+
{ id: "qwen3.5-omni-plus", providerId: "qwen", name: "Qwen 3.5 Omni Plus", modelType: "llm", contextWindow: 131072, capabilities: JSON.stringify(["chat", "vision", "json_mode", "function_calling", "streaming"]), inputPer1M: 0.32, outputPer1M: 1.28 },
|
|
341
352
|
|
|
342
353
|
// ── Qwen (TTS) ──
|
|
343
354
|
{ id: "qwen3-tts-instruct-flash", providerId: "qwen", name: "Qwen TTS Instruct Flash", modelType: "tts", contextWindow: 0, capabilities: JSON.stringify(["tts", "speech"]) },
|
|
@@ -399,7 +410,11 @@ export const SEED_DATA: SeedData = {
|
|
|
399
410
|
{ id: "Qwen-Ambassador/Qwen3.7-Max", providerId: "modelscope", name: "Qwen3.7 Max (Embajador)", modelType: "llm", contextWindow: 1000000, capabilities: JSON.stringify(["chat", "code", "vision", "json_mode", "function_calling", "streaming", "reasoning"]), inputPer1M: 0, outputPer1M: 0 },
|
|
400
411
|
{ id: "Qwen-Ambassador/Qwen3.7-Plus", providerId: "modelscope", name: "Qwen3.7 Plus (Embajador)", modelType: "llm", contextWindow: 1000000, capabilities: JSON.stringify(["chat", "code", "vision", "json_mode", "function_calling", "streaming", "reasoning"]), inputPer1M: 0, outputPer1M: 0 },
|
|
401
412
|
// Open-weight del mismo endpoint, para cuentas sin permiso de embajador.
|
|
402
|
-
{ id: "Qwen/Qwen3.5-397B-A17B", providerId: "modelscope", name: "Qwen3.5 397B (ModelScope)", modelType: "llm", contextWindow: 262144, capabilities: JSON.stringify(["chat", "code", "json_mode", "function_calling", "streaming", "reasoning"]), inputPer1M: 0, outputPer1M: 0 },
|
|
413
|
+
{ id: "Qwen/Qwen3.5-397B-A17B", providerId: "modelscope", name: "Qwen3.5 397B (ModelScope)", modelType: "llm", contextWindow: 262144, capabilities: JSON.stringify(["chat", "vision", "code", "json_mode", "function_calling", "streaming", "reasoning"]), inputPer1M: 0, outputPer1M: 0 },
|
|
414
|
+
{ id: "Qwen/Qwen3.8-27B", providerId: "modelscope", name: "Qwen3.8 27B (ModelScope)", modelType: "llm", contextWindow: 262144, capabilities: JSON.stringify(["chat", "code", "vision", "json_mode", "function_calling", "streaming", "reasoning"]), inputPer1M: 0, outputPer1M: 0 },
|
|
415
|
+
{ id: "Qwen/Qwen3.5-122B-A10B", providerId: "modelscope", name: "Qwen3.5 122B (ModelScope)", modelType: "llm", contextWindow: 262144, capabilities: JSON.stringify(["chat", "code", "vision", "json_mode", "function_calling", "streaming", "reasoning"]), inputPer1M: 0, outputPer1M: 0 },
|
|
416
|
+
{ id: "Qwen/Qwen3.5-35B-A3B", providerId: "modelscope", name: "Qwen3.5 35B (ModelScope)", modelType: "llm", contextWindow: 262144, capabilities: JSON.stringify(["chat", "code", "vision", "json_mode", "function_calling", "streaming", "reasoning"]), inputPer1M: 0, outputPer1M: 0 },
|
|
417
|
+
{ id: "Qwen/Qwen3.5-27B", providerId: "modelscope", name: "Qwen3.5 27B (ModelScope)", modelType: "llm", contextWindow: 262144, capabilities: JSON.stringify(["chat", "code", "vision", "json_mode", "function_calling", "streaming", "reasoning"]), inputPer1M: 0, outputPer1M: 0 },
|
|
403
418
|
{ id: "Qwen/Qwen3-Next-80B-A3B-Instruct", providerId: "modelscope", name: "Qwen3 Next 80B (ModelScope)", modelType: "llm", contextWindow: 262144, capabilities: JSON.stringify(["chat", "code", "json_mode", "function_calling", "streaming"]), inputPer1M: 0, outputPer1M: 0 },
|
|
404
419
|
{ id: "Qwen/Qwen3-Coder-30B-A3B-Instruct", providerId: "modelscope", name: "Qwen3 Coder 30B (ModelScope)", modelType: "llm", contextWindow: 262144, capabilities: JSON.stringify(["chat", "code", "json_mode", "function_calling", "streaming"]), inputPer1M: 0, outputPer1M: 0 },
|
|
405
420
|
{ id: "Qwen/Qwen3-VL-235B-A22B-Instruct", providerId: "modelscope", name: "Qwen3 VL 235B (ModelScope)", modelType: "llm", contextWindow: 131072, capabilities: JSON.stringify(["chat", "vision", "json_mode", "function_calling", "streaming"]), inputPer1M: 0, outputPer1M: 0 },
|
|
@@ -448,8 +463,13 @@ export const SEED_DATA: SeedData = {
|
|
|
448
463
|
// context_window es el ctx que se pide en POST /api/load, no un tope del
|
|
449
464
|
// modelo: DeepSeek va a 32K porque sus 90.9 GB de pesos dejan poco margen
|
|
450
465
|
// de memoria para el KV cache.
|
|
451
|
-
|
|
452
|
-
|
|
466
|
+
// Los Qwen 3.5/3.6/3.8 son multimodales nativos (aceptan imagen), por eso llevan `vision`: así
|
|
467
|
+
// aparecen en la pestaña de imagen. Inventario verificado contra GET /api/models el 2026-11-20;
|
|
468
|
+
// se omiten a propósito los de ciberseguridad (Cyber*, StagAI, Uraion, wolfram) y las piezas de MiniMax-Music3.
|
|
469
|
+
// Sin verificar y fuera del catálogo: Ornith 1.0 9B, Sage A1.5 y Gemma 4 12B.
|
|
470
|
+
{ id: "Qwen3.6-35B-A3B-UD-Q4_K_M.gguf", providerId: "hiveagents", name: "Qwen3.6 35B MoE (Recomendado)", modelType: "llm", contextWindow: 50000, capabilities: JSON.stringify(["chat", "vision", "streaming", "reasoning", "function_calling"]), inputPer1M: 0, outputPer1M: 0 },
|
|
471
|
+
{ id: "Qwen3.8-27B-UD-Q6_K_XL.gguf", providerId: "hiveagents", name: "Qwen3.8 27B Dense + MTP", modelType: "llm", contextWindow: 50000, capabilities: JSON.stringify(["chat", "vision", "streaming", "reasoning", "function_calling"]), inputPer1M: 0, outputPer1M: 0 },
|
|
472
|
+
{ id: "Qwen3.5-9B-UD-Q8_K_XL.gguf", providerId: "hiveagents", name: "Qwen3.5 9B + MTP (ligero)", modelType: "llm", contextWindow: 50000, capabilities: JSON.stringify(["chat", "vision", "streaming", "reasoning", "function_calling"]), inputPer1M: 0, outputPer1M: 0 },
|
|
453
473
|
// Se carga por el primer shard: llama.cpp descubre los otros dos solo.
|
|
454
474
|
// Sólo texto, y el más lento del inventario: ~91 s de carga y 12.8 t/s.
|
|
455
475
|
{ id: "DeepSeek-V4-Flash-UD-IQ2_XXS-00001-of-00003.gguf", providerId: "hiveagents", name: "DeepSeek V4 Flash 90 GB (lento)", modelType: "llm", contextWindow: 32768, capabilities: JSON.stringify(["chat", "streaming", "reasoning", "function_calling"]), inputPer1M: 0, outputPer1M: 0 },
|
|
@@ -236,6 +236,8 @@ const DEFAULT_MAIN_THREAD_TOOL_NAMES = new Set([
|
|
|
236
236
|
"cron.trigger",
|
|
237
237
|
"cron.history",
|
|
238
238
|
"notify",
|
|
239
|
+
// Entrega archivos por el canal: usa el sender y la base de datos del proceso principal.
|
|
240
|
+
"send_file",
|
|
239
241
|
"report_progress",
|
|
240
242
|
"task_delegate",
|
|
241
243
|
"task_list",
|