@johpaz/hive-agents 1.1.6 → 1.1.11
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 +4 -10
- package/dist/hive.js +5258 -2985
- package/dist/tool-worker.js +197 -75
- package/dist/ui/assets/{A2UIPage-CxE3jH4_.js → A2UIPage-v-VggXW3.js} +4 -4
- package/dist/ui/assets/{AgentCreateForm-SGj5AqAX.js → AgentCreateForm-Dr1l4Cvg.js} +1 -1
- package/dist/ui/assets/AgentDetailPage-Dsh_grrr.js +1 -0
- package/dist/ui/assets/{AgentNewPage-xvAmX6kw.js → AgentNewPage-D7557C0J.js} +1 -1
- package/dist/ui/assets/AgentsPage-C_Z56LL1.js +10 -0
- package/dist/ui/assets/{ApiClientPage-NLw2wHjH.js → ApiClientPage-uuBnrh0y.js} +1 -1
- package/dist/ui/assets/ChannelsPage-BI4mAgRU.js +8 -0
- package/dist/ui/assets/DashboardPage-BjAxvzYP.js +6 -0
- package/dist/ui/assets/LoginPage-D7IZKON0.js +1 -0
- package/dist/ui/assets/{LogsPage-G9d2G1nL.js → LogsPage-mcqOYvGw.js} +1 -1
- package/dist/ui/assets/MeetingPage-qPJ1z5HA.js +1 -0
- package/dist/ui/assets/ModelSelector-njfNhkng.js +1 -0
- package/dist/ui/assets/{NotFound-D4ZlDVg9.js → NotFound-DY8e1RKh.js} +1 -1
- package/dist/ui/assets/{Office3DPage-31AMJ-LN.css → Office3DPage-C3SIzd2H.css} +1 -1
- package/dist/ui/assets/Office3DPage-Du42LRwi.js +319 -0
- package/dist/ui/assets/ProvidersPage-GDCJs8Zb.js +1 -0
- package/dist/ui/assets/{RecoverPage-Dr6qKgV5.js → RecoverPage-B6qvBBIl.js} +1 -1
- package/dist/ui/assets/SettingsPage-Br4PfWuc.js +9 -0
- package/dist/ui/assets/{SetupPage-BoVKIf4r.js → SetupPage-OaouFLGD.js} +1 -1
- package/dist/ui/assets/{Vignette-DrI2yK2m.js → Vignette-GSZ-owcN.js} +17 -17
- package/dist/ui/assets/VoicePage-DRQZBl3j.js +307 -0
- package/dist/ui/assets/WebChatPage-Cypq-SYi.js +29 -0
- package/dist/ui/assets/{agentCapabilities-CDSfJWhw.js → agentCapabilities-Bf71Gir4.js} +1 -1
- package/dist/ui/assets/{alert-CjiX20jI.js → alert-Dn604uVs.js} +1 -1
- package/dist/ui/assets/{badge-B5AKge1b.js → badge-C6H33ePv.js} +1 -1
- package/dist/ui/assets/{card-mTJ4oZbL.js → card-D0qneq1i.js} +1 -1
- package/dist/ui/assets/{conversationsStore-ns_ZfKgg.js → conversationsStore-D6XgjMr1.js} +1 -1
- package/dist/ui/assets/{dialog-C3n2xYF2.js → dialog-DO1fQCF7.js} +1 -1
- package/dist/ui/assets/dist-js-C2MfmbEW.js +1 -0
- package/dist/ui/assets/{dist-js-CkNhvsFc.js → dist-js-Djxbxbst.js} +1 -1
- package/dist/ui/assets/google-external-e9lvWjy4.js +1 -0
- package/dist/ui/assets/index-BKNFH2al.css +2 -0
- package/dist/ui/assets/index-U0e4e5mL.js +156 -0
- package/dist/ui/assets/{key-DPkOY-J0.js → key-round-Ca0Ns34v.js} +1 -1
- package/dist/ui/assets/{label-D_fvqJyD.js → label-CvAtVE-v.js} +1 -1
- package/dist/ui/assets/{scroll-area-CbH8FOo8.js → scroll-area-CYMu7sU0.js} +1 -1
- package/dist/ui/assets/select-BjBXxyxL.js +1 -0
- package/dist/ui/assets/{slider-DXS4h1LB.js → slider-DR31eN3r.js} +1 -1
- package/dist/ui/assets/{switch-ndx8VCpm.js → switch-B5dAwb54.js} +1 -1
- package/dist/ui/assets/{tabs-epu-3Tl4.js → tabs-Ct92cLXr.js} +1 -1
- package/dist/ui/assets/{earth-BJRGJbVn.js → terminal-CpBDERBE.js} +1 -1
- package/dist/ui/assets/{textarea-BgZJFZTX.js → textarea-xtFAVuPf.js} +1 -1
- package/dist/ui/assets/{useAudioDevices-CsPrtpWY.js → useAudioDevices-wZArmV3m.js} +1 -1
- package/dist/ui/assets/{useHiveAgentsModelLoad-nn4gON9g.js → useHiveAgentsModelLoad-CqJkzTOT.js} +1 -1
- package/dist/ui/assets/useOfficeModel-DZvwZRCw.js +1 -0
- package/dist/ui/assets/{useProviders-9tvEC3hX.js → useProviders-CeSzDnx-.js} +1 -1
- package/dist/ui/assets/vendor-router-DxU0Uf4R.js +3 -0
- package/dist/ui/index.html +5 -5
- package/package.json +1 -3
- package/packages/core/src/agent/agent-catalog.ts +98 -1
- package/packages/core/src/agent/agent-loop.ts +5 -44
- package/packages/core/src/agent/context-compiler.ts +6 -94
- package/packages/core/src/agent/conversation-store.ts +23 -1
- package/packages/core/src/agent/llm-providers/openai-compat-base.ts +1 -1
- package/packages/core/src/agent/prompt-builder.ts +17 -1
- package/packages/core/src/agent/tool-selector.ts +8 -0
- package/packages/core/src/artifacts/store.ts +66 -8
- package/packages/core/src/canvas/emitter.ts +0 -19
- package/packages/core/src/gateway/google-host.ts +228 -0
- package/packages/core/src/gateway/initializer.ts +8 -0
- package/packages/core/src/gateway/routes/agents.ts +14 -0
- package/packages/core/src/gateway/routes/auth.ts +25 -3
- package/packages/core/src/gateway/routes/chat.ts +14 -1
- package/packages/core/src/gateway/routes/google.ts +252 -0
- package/packages/core/src/gateway/routes/meeting.ts +11 -3
- package/packages/core/src/gateway/routes/models.ts +27 -11
- package/packages/core/src/gateway/routes/multimodal.ts +19 -0
- package/packages/core/src/gateway/routes/providers.ts +19 -18
- package/packages/core/src/gateway/routes/system.ts +1 -3
- package/packages/core/src/gateway/routes/tts-local.ts +20 -374
- package/packages/core/src/gateway/routes/voice.ts +29 -35
- package/packages/core/src/gateway/server.ts +58 -32
- package/packages/core/src/gateway/tts/README.md +7 -86
- package/packages/core/src/gateway/tts/build.py +105 -0
- package/packages/core/src/gateway/tts/kitten.ts +282 -0
- package/packages/core/src/gateway/tts/python.d.ts +4 -0
- package/packages/core/src/gateway/tts/src/detect.ts +33 -39
- package/packages/core/src/gateway/tts/worker.py +80 -0
- package/packages/core/src/google/client.ts +123 -0
- package/packages/core/src/google/config.ts +60 -0
- package/packages/core/src/google/google.test.ts +287 -0
- package/packages/core/src/google/index.ts +5 -0
- package/packages/core/src/google/oauth.ts +144 -0
- package/packages/core/src/google/scopes.ts +41 -0
- package/packages/core/src/google/token-store.ts +33 -0
- package/packages/core/src/multimodal/attachment-ingest.ts +19 -4
- package/packages/core/src/multimodal/image-generation.ts +244 -0
- package/packages/core/src/storage/collections.ts +8 -8
- package/packages/core/src/storage/google-capabilities.ts +91 -0
- package/packages/core/src/storage/model-activation.ts +18 -0
- package/packages/core/src/storage/model-sync.ts +66 -14
- package/packages/core/src/storage/onboarding.ts +10 -2
- package/packages/core/src/storage/seed.ts +81 -18
- package/packages/core/src/storage/usage.ts +0 -52
- package/packages/core/src/tools/agents/get-available-models.ts +1 -3
- package/packages/core/src/tools/core/index.ts +1 -1
- package/packages/core/src/tools/google/calendar.ts +204 -0
- package/packages/core/src/tools/google/drive.ts +160 -0
- package/packages/core/src/tools/google/gmail.ts +579 -0
- package/packages/core/src/tools/google/index.ts +18 -0
- package/packages/core/src/tools/google/shared.ts +80 -0
- package/packages/core/src/tools/image/image-generate.ts +90 -0
- package/packages/core/src/tools/image/index.ts +13 -0
- package/packages/core/src/tools/image/office-leer-imagenes.ts +198 -0
- package/packages/core/src/tools/index.ts +27 -0
- package/packages/core/src/tools/office/office-images.ts +137 -0
- package/packages/core/src/tools/office/office-leer-docx.ts +10 -1
- package/packages/core/src/tools/office/office-leer-pdf.ts +1 -1
- package/packages/core/src/tools/office/office-leer-pptx.ts +4 -1
- package/packages/core/src/tools/office/office-pdf-images.ts +225 -0
- package/packages/core/src/tools/office/pdf-text.ts +2 -2
- package/packages/core/src/tools/web/browser-screenshot.ts +7 -0
- package/packages/core/src/voice/index.ts +123 -155
- package/packages/core/src/voice/local-model.ts +8 -0
- package/packages/core/src/voice/stt-models.ts +39 -0
- package/packages/skills/src/bundled/google/google_calendar/SKILL.md +51 -0
- package/packages/skills/src/bundled/google/google_drive/SKILL.md +50 -0
- package/packages/skills/src/bundled/google/google_gmail/SKILL.md +61 -0
- package/packages/skills/src/bundled-data.generated.ts +45 -0
- package/dist/ui/assets/AgentDetailPage-CyYbqzHr.js +0 -1
- package/dist/ui/assets/AgentsPage-CEWNs4Lt.js +0 -10
- package/dist/ui/assets/ChannelsPage-CmeXP-hI.js +0 -8
- package/dist/ui/assets/DashboardPage-C3z4kZXD.js +0 -6
- package/dist/ui/assets/LoginPage-DDisP8hm.js +0 -1
- package/dist/ui/assets/MeetingPage-CKyjxtFr.js +0 -1
- package/dist/ui/assets/ModelSelector-VVwpDrYF.js +0 -1
- package/dist/ui/assets/Office3DPage-CYxB6z2p.js +0 -727
- package/dist/ui/assets/ProvidersPage-CM9-E-Pf.js +0 -1
- package/dist/ui/assets/SettingsPage-BvD-vs5g.js +0 -9
- package/dist/ui/assets/VoicePage-CmudxYny.js +0 -307
- package/dist/ui/assets/WebChatPage-CnoXpEOl.js +0 -29
- package/dist/ui/assets/dist-js-jWCEHSkB.js +0 -1
- package/dist/ui/assets/index-C0W6p0lk.js +0 -156
- package/dist/ui/assets/index-DmFPF9xQ.css +0 -2
- package/dist/ui/assets/lock-open-v0EphssG.js +0 -1
- package/dist/ui/assets/select-v_3QBYrD.js +0 -1
- package/dist/ui/assets/terminal-BEcTK780.js +0 -1
- package/dist/ui/assets/useOfficeModel-BaDn7U-X.js +0 -1
- package/dist/ui/assets/vendor-router-DSMCk-Ka.js +0 -3
- package/packages/core/src/agent/jev-decisions.ts +0 -242
- package/packages/core/src/agent/jev-planner.ts +0 -293
- package/packages/core/src/gateway/tts/package.json +0 -25
- package/packages/core/src/gateway/tts/src/client.ts +0 -59
- package/packages/core/src/gateway/tts/src/index.ts +0 -15
- package/packages/core/src/gateway/tts/src/install.ts +0 -137
- package/packages/core/src/gateway/tts/src/models.ts +0 -50
- package/packages/core/src/gateway/tts/src/server.ts +0 -253
- /package/dist/ui/assets/{core-p4c5dns5.js → core-npANj14X.js} +0 -0
- /package/dist/ui/assets/{download-BQXrpH0m.js → download-D0aDV8Y_.js} +0 -0
- /package/dist/ui/assets/{ellipsis-vertical-D7uFJLGh.js → ellipsis-vertical-BOW_iEOO.js} +0 -0
- /package/dist/ui/assets/{external-link-6oTH9pUM.js → external-link-DNJH7epD.js} +0 -0
- /package/dist/ui/assets/{eye-CxvxtQT5.js → eye-BVfTWOME.js} +0 -0
- /package/dist/ui/assets/{file-text-D5ZJEx3E.js → file-text-ByqNMpXm.js} +0 -0
- /package/dist/ui/assets/{gateway-url-BALS_wVh.js → gateway-url-BzQV75Ig.js} +0 -0
- /package/dist/ui/assets/{gauge-CEu7PhTW.js → gauge-CB4np0Vz.js} +0 -0
- /package/dist/ui/assets/{history-DLK5rTlP.js → history-CbhJX41s.js} +0 -0
- /package/dist/ui/assets/{info-8ReWzubE.js → info-BCD3-QX9.js} +0 -0
- /package/dist/ui/assets/{lock-3IApZyVy.js → lock-DpBean4K.js} +0 -0
- /package/dist/ui/assets/{mail-vwCEHyhQ.js → mail-Biwn8WrV.js} +0 -0
- /package/dist/ui/assets/{mic-CpDU_2as.js → mic-Rq4BxU1R.js} +0 -0
- /package/dist/ui/assets/{pause-BAMsNQkh.js → pause-87NGXbsz.js} +0 -0
- /package/dist/ui/assets/{pencil-CKritjT_.js → pencil-BG8EFaS3.js} +0 -0
- /package/dist/ui/assets/{play-Cwpe4tp6.js → play-D3De6YsQ.js} +0 -0
- /package/dist/ui/assets/{plus-RD44ce15.js → plus-Bp8-V68t.js} +0 -0
- /package/dist/ui/assets/{radio-lFPMHi6-.js → radio-m7rzuDKK.js} +0 -0
- /package/dist/ui/assets/{refresh-cw-DtJMHRHO.js → refresh-cw-D6F1zoC6.js} +0 -0
- /package/dist/ui/assets/{rotate-ccw-b3E_4PoX.js → rotate-ccw-DUlEC1_D.js} +0 -0
- /package/dist/ui/assets/{search-z2oZt00P.js → search-CfNwwpMW.js} +0 -0
- /package/dist/ui/assets/{send-CpoY_2F-.js → send-CI868CBV.js} +0 -0
- /package/dist/ui/assets/{settings-qV3kVkeG.js → settings-AEM2uWiD.js} +0 -0
- /package/dist/ui/assets/{shield-CIarwBvx.js → shield-DvVIcbzd.js} +0 -0
- /package/dist/ui/assets/{sparkles-DVvY6jDT.js → sparkles-DRe4GbSH.js} +0 -0
- /package/dist/ui/assets/{square-D5zdNkAY.js → square-DTWkjTT3.js} +0 -0
- /package/dist/ui/assets/{trash-2-D6oziYAK.js → trash-2-BZsMCfso.js} +0 -0
- /package/dist/ui/assets/{utils-DEmd_M8c.js → utils-lc8H6VGT.js} +0 -0
- /package/dist/ui/assets/{volume-2-EaA0JRvD.js → volume-2-CBMYsuF3.js} +0 -0
- /package/dist/ui/assets/{volume-x-CROXNMGT.js → volume-x-vNFf2e4-.js} +0 -0
- /package/dist/ui/assets/{wifi-BUJuOcgP.js → wifi-DNv53AfN.js} +0 -0
- /package/dist/ui/assets/{zap-DSoX9NDk.js → zap-Yed86Sh8.js} +0 -0
|
@@ -2,7 +2,9 @@ import { col, toIndexable, nextId } from "./hive"
|
|
|
2
2
|
import type { Collection } from "@johpaz/hive-db"
|
|
3
3
|
import { logger } from "../utils/logger"
|
|
4
4
|
import { catalogModelKey } from "./model-id"
|
|
5
|
+
import { voiceModelActivation } from "./model-activation"
|
|
5
6
|
import { invalidateModelPricingCache } from "./usage"
|
|
7
|
+
import { DEFAULT_LOCAL_VOICE, isLegacyPiper, LOCAL_TTS_MODEL, LOCAL_TTS_PROVIDER } from "../voice/local-model"
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Seed de datos predeterminados para Hive
|
|
@@ -49,6 +51,37 @@ export const SEED_DATA: SeedData = {
|
|
|
49
51
|
// ─────────────────────────────────────────
|
|
50
52
|
// 2. WEB — Búsqueda, navegación + automatización
|
|
51
53
|
// ─────────────────────────────────────────
|
|
54
|
+
// ─────────────────────────────────────────
|
|
55
|
+
// GOOGLE — requieren conectar la cuenta en Ajustes → Perfil
|
|
56
|
+
// ─────────────────────────────────────────
|
|
57
|
+
{ id: "gmail_search", name: "gmail_search", category: "google", description: "Buscar correos en Gmail con la sintaxis de Gmail (from:, subject:, is:unread). Sinónimos: buscar correos, correos sin leer, bandeja de entrada (Requiere conectar tu cuenta de Google en tu perfil.)" },
|
|
58
|
+
{ id: "gmail_read", name: "gmail_read", category: "google", description: "Leer un correo completo de Gmail por id. Sinónimos: abrir correo, leer email, contenido del correo (Requiere conectar tu cuenta de Google en tu perfil.)" },
|
|
59
|
+
{ id: "gmail_thread", name: "gmail_thread", category: "google", description: "Leer una conversación completa de Gmail. Sinónimos: hilo de correos, historial del correo (Requiere conectar tu cuenta de Google en tu perfil.)" },
|
|
60
|
+
{ id: "gmail_send", name: "gmail_send", category: "google", description: "Enviar un correo nuevo desde Gmail, con adjuntos; pide confirmación. Sinónimos: mandar email, escribir correo (Requiere conectar tu cuenta de Google en tu perfil.)" },
|
|
61
|
+
{ id: "gmail_reply", name: "gmail_reply", category: "google", description: "Responder un correo manteniendo el hilo, o responder a todos; pide confirmación. Sinónimos: contestar email (Requiere conectar tu cuenta de Google en tu perfil.)" },
|
|
62
|
+
{ id: "gmail_forward", name: "gmail_forward", category: "google", description: "Reenviar un correo con su texto y adjuntos; pide confirmación. Sinónimos: forward, pasar correo (Requiere conectar tu cuenta de Google en tu perfil.)" },
|
|
63
|
+
{ id: "gmail_draft_save", name: "gmail_draft_save", category: "google", description: "Crear o editar un borrador de Gmail sin enviarlo. Sinónimos: guardar borrador, editar borrador (Requiere conectar tu cuenta de Google en tu perfil.)" },
|
|
64
|
+
{ id: "gmail_draft_list", name: "gmail_draft_list", category: "google", description: "Listar los borradores de Gmail. Sinónimos: ver borradores (Requiere conectar tu cuenta de Google en tu perfil.)" },
|
|
65
|
+
{ id: "gmail_draft_send", name: "gmail_draft_send", category: "google", description: "Enviar un borrador existente de Gmail; pide confirmación. Sinónimos: enviar borrador (Requiere conectar tu cuenta de Google en tu perfil.)" },
|
|
66
|
+
{ id: "gmail_draft_delete", name: "gmail_draft_delete", category: "google", description: "Borrar un borrador de Gmail; pide confirmación. Sinónimos: eliminar borrador (Requiere conectar tu cuenta de Google en tu perfil.)" },
|
|
67
|
+
{ id: "gmail_modify", name: "gmail_modify", category: "google", description: "Marcar leído o no leído, destacar, archivar, mandar a la papelera o etiquetar correos. Sinónimos: marcar como leído, archivar correo (Requiere conectar tu cuenta de Google en tu perfil.)" },
|
|
68
|
+
{ id: "gmail_labels", name: "gmail_labels", category: "google", description: "Listar, crear, renombrar o borrar etiquetas de Gmail. Sinónimos: carpetas de gmail (Requiere conectar tu cuenta de Google en tu perfil.)" },
|
|
69
|
+
{ id: "gmail_attachment_download", name: "gmail_attachment_download", category: "google", description: "Descargar un adjunto de un correo recibido a un artifact. Sinónimos: guardar adjunto (Requiere conectar tu cuenta de Google en tu perfil.)" },
|
|
70
|
+
{ id: "gcal_list_events", name: "gcal_list_events", category: "google", description: "Listar eventos de Google Calendar en un rango. Sinónimos: ver agenda, próximos eventos, reuniones de la semana (Requiere conectar tu cuenta de Google en tu perfil.)" },
|
|
71
|
+
{ id: "gcal_create_event", name: "gcal_create_event", category: "google", description: "Crear un evento en Google Calendar, con invitados y Meet; con invitados pide confirmación. Sinónimos: agendar reunión, programar cita (Requiere conectar tu cuenta de Google en tu perfil.)" },
|
|
72
|
+
{ id: "gcal_update_event", name: "gcal_update_event", category: "google", description: "Modificar un evento de Google Calendar; pide confirmación. Sinónimos: mover reunión, reprogramar (Requiere conectar tu cuenta de Google en tu perfil.)" },
|
|
73
|
+
{ id: "gcal_delete_event", name: "gcal_delete_event", category: "google", description: "Cancelar un evento de Google Calendar; pide confirmación. Sinónimos: borrar evento (Requiere conectar tu cuenta de Google en tu perfil.)" },
|
|
74
|
+
{ id: "gcal_freebusy", name: "gcal_freebusy", category: "google", description: "Consultar disponibilidad (ocupado/libre) de uno o varios calendarios. Sinónimos: horarios libres (Requiere conectar tu cuenta de Google en tu perfil.)" },
|
|
75
|
+
{ id: "gdrive_search", name: "gdrive_search", category: "google", description: "Buscar archivos en Google Drive por nombre o contenido. Sinónimos: buscar en drive (Requiere conectar tu cuenta de Google en tu perfil.)" },
|
|
76
|
+
{ id: "gdrive_download", name: "gdrive_download", category: "google", description: "Descargar o exportar un archivo de Google Drive a un artifact. Sinónimos: leer documento de google (Requiere conectar tu cuenta de Google en tu perfil.)" },
|
|
77
|
+
{ id: "gdrive_upload", name: "gdrive_upload", category: "google", description: "Subir un archivo nuevo a Google Drive. Sinónimos: guardar en drive (Requiere conectar tu cuenta de Google en tu perfil.)" },
|
|
78
|
+
|
|
79
|
+
// ─────────────────────────────────────────
|
|
80
|
+
// IMAGEN — usa el modelo elegido en Providers → Imagen
|
|
81
|
+
// ─────────────────────────────────────────
|
|
82
|
+
{ id: "image_generate", name: "image_generate", category: "image", description: "Crear una imagen nueva a partir de una descripción (ilustración, logo, póster, arte conceptual) con el modelo elegido en Providers → Imagen. Sinónimos: crear imagen, generar imagen, dibujar, hazme una imagen" },
|
|
83
|
+
{ id: "office_leer_imagenes", name: "office_leer_imagenes", category: "image", description: "Leer las imágenes dentro de un Word (.docx) o PowerPoint (.pptx): capturas, gráficos, diagramas, escaneos. Las describe y transcribe con el modelo de visión de Providers → Imagen. Sinónimos: leer imágenes de un documento, ocr de word, ocr de powerpoint, capturas dentro de un documento" },
|
|
84
|
+
|
|
52
85
|
{ id: "api_request", name: "api_request", category: "api", description: "Ejecutar una petición HTTP autorizada contra un endpoint REST y validar la respuesta. Sinónimos: llamar api, request rest, consumir endpoint, petición http, hacer get, hacer post" },
|
|
53
86
|
{ id: "web_search", name: "web_search", category: "web", description: "Buscar en la web información actual y noticias. Sinónimos: búsqueda web, noticias, información, buscar en internet, google" },
|
|
54
87
|
{ id: "web_fetch", name: "web_fetch", category: "web", description: "Obtener contenido de texto de una URL (ligero, sin JS). Sinónimos: descargar página, extraer texto, obtener contenido, leer url" },
|
|
@@ -193,7 +226,7 @@ export const SEED_DATA: SeedData = {
|
|
|
193
226
|
// no valida la key; el 401 recién aparece al invocar el modelo.
|
|
194
227
|
{ id: "modelscope", name: "ModelScope Qwen", baseUrl: "https://api-inference.modelscope.ai/v1" },
|
|
195
228
|
{ id: "opencode-go", name: "OpenCode Go", baseUrl: "https://opencode.ai/zen/go/v1" },
|
|
196
|
-
{ id:
|
|
229
|
+
{ id: LOCAL_TTS_PROVIDER, name: "Kitten (Local TTS)", category: "tts" },
|
|
197
230
|
{ id: "hiveagents", name: "HiveAgents LLM (Cloudflare)", baseUrl: "https://llm.hiveagents.io/v1", category: "llm" },
|
|
198
231
|
],
|
|
199
232
|
|
|
@@ -214,10 +247,11 @@ export const SEED_DATA: SeedData = {
|
|
|
214
247
|
{ id: "gpt-5.6-sol", providerId: "openai", name: "GPT-5.6 Sol", modelType: "llm", contextWindow: 1050000, capabilities: JSON.stringify(["chat", "vision", "json_mode", "function_calling", "streaming", "code", "reasoning"]), inputPer1M: 5, outputPer1M: 30 },
|
|
215
248
|
// STT / TTS
|
|
216
249
|
{ id: "whisper-1", providerId: "openai", name: "Whisper 1", modelType: "stt", contextWindow: 0, capabilities: JSON.stringify(["transcription", "translation"]) },
|
|
250
|
+
{ id: "gpt-transcribe", providerId: "openai", name: "GPT Transcribe", modelType: "stt", contextWindow: 0, capabilities: JSON.stringify(["transcription"]) },
|
|
217
251
|
{ id: "tts-1", providerId: "openai", name: "TTS-1", modelType: "tts", contextWindow: 0, capabilities: JSON.stringify(["tts", "speech"]) },
|
|
218
252
|
{ id: "tts-1-hd", providerId: "openai", name: "TTS-1 HD", modelType: "tts", contextWindow: 0, capabilities: JSON.stringify(["tts", "speech", "high_quality"]) },
|
|
219
253
|
{ id: "gpt-4o-mini-tts", providerId: "openai", name: "GPT-4o Mini TTS", modelType: "tts", contextWindow: 0, capabilities: JSON.stringify(["tts", "speech"]) },
|
|
220
|
-
{ id:
|
|
254
|
+
{ id: LOCAL_TTS_MODEL, providerId: LOCAL_TTS_PROVIDER, name: "Kitten TTS 2 Mini (Español)", modelType: "tts", contextWindow: 0, capabilities: JSON.stringify(["tts", "speech", "local"]) },
|
|
221
255
|
|
|
222
256
|
// ── Google Gemini (fuente: ai.google.dev/gemini-api/docs/models) ──
|
|
223
257
|
// Solo la generación 3.x: la familia 2.0 ya está apagada y la 2.5 quedó
|
|
@@ -225,7 +259,7 @@ export const SEED_DATA: SeedData = {
|
|
|
225
259
|
// el primero no existe en el catálogo y el segundo ya salió de preview.
|
|
226
260
|
// 3.8 Flash tiene precio de lanzamiento hasta el 31-dic-2026 ($0.75 / $3.75).
|
|
227
261
|
// Desde el 1-ene-2027 pasa a $1.50 / $7.50: actualizar aquí ese día o el
|
|
228
|
-
// dashboard subestimará el costo
|
|
262
|
+
// dashboard subestimará el costo a la mitad.
|
|
229
263
|
// contextWindow: el que reporta la propia API de modelos de Gemini.
|
|
230
264
|
{ id: "gemini-3.8-flash", providerId: "gemini", name: "Gemini 3.8 Flash", modelType: "llm", contextWindow: 1050000, capabilities: JSON.stringify(["chat", "vision", "json_mode", "function_calling", "streaming", "reasoning"]), inputPer1M: 0.75, outputPer1M: 3.75 },
|
|
231
265
|
{ id: "gemini-3.6-flash", providerId: "gemini", name: "Gemini 3.6 Flash", modelType: "llm", contextWindow: 1048576, capabilities: JSON.stringify(["chat", "vision", "json_mode", "function_calling", "streaming", "reasoning"]), inputPer1M: 1.5, outputPer1M: 7.5 },
|
|
@@ -271,7 +305,6 @@ export const SEED_DATA: SeedData = {
|
|
|
271
305
|
{ id: "kimi-k2.6", providerId: "kimi", name: "Kimi K2.6", modelType: "llm", contextWindow: 262144, capabilities: JSON.stringify(["chat", "vision", "json_mode", "function_calling", "streaming", "code"]), inputPer1M: 0.6, outputPer1M: 3.41 },
|
|
272
306
|
|
|
273
307
|
// ── OpenRouter (fuente: GET https://openrouter.ai/api/v1/models) ──
|
|
274
|
-
{ id: "typesafe/jev-1.13", providerId: "openrouter", name: "Jev 1.13 (Decisions)", modelType: "decision", contextWindow: 32000, capabilities: JSON.stringify(["choice", "noul", "score"]), inputPer1M: 0.042, outputPer1M: 0 },
|
|
275
308
|
// Solo modelos vivos con `tools` en supported_parameters y publicados desde
|
|
276
309
|
// 2025-07. contextWindow = context_length reportado por el propio catálogo.
|
|
277
310
|
// Anthropic
|
|
@@ -337,6 +370,8 @@ export const SEED_DATA: SeedData = {
|
|
|
337
370
|
|
|
338
371
|
// ── ElevenLabs (TTS) ──
|
|
339
372
|
{ id: "eleven_flash_v2_5", providerId: "elevenlabs", name: "Eleven Flash V2.5", modelType: "tts", contextWindow: 0, capabilities: JSON.stringify(["tts", "speech", "fast"]) },
|
|
373
|
+
{ id: "scribe_v3", providerId: "elevenlabs", name: "ElevenLabs Scribe v3", modelType: "stt", contextWindow: 0, capabilities: JSON.stringify(["transcription"]) },
|
|
374
|
+
{ id: "scribe_v2", providerId: "elevenlabs", name: "ElevenLabs Scribe v2", modelType: "stt", contextWindow: 0, capabilities: JSON.stringify(["transcription"]) },
|
|
340
375
|
{ id: "eleven_turbo_v2_5", providerId: "elevenlabs", name: "Eleven Turbo V2.5", modelType: "tts", contextWindow: 0, capabilities: JSON.stringify(["tts", "speech", "balanced"]) },
|
|
341
376
|
{ id: "eleven_multilingual_v2", providerId: "elevenlabs", name: "Eleven Multilingual V2", modelType: "tts", contextWindow: 0, capabilities: JSON.stringify(["tts", "multilingual"]) },
|
|
342
377
|
{ id: "eleven_v3", providerId: "elevenlabs", name: "Eleven V3", modelType: "tts", contextWindow: 0, capabilities: JSON.stringify(["tts", "speech", "expressive"]) },
|
|
@@ -373,6 +408,13 @@ export const SEED_DATA: SeedData = {
|
|
|
373
408
|
// julio/agosto con "Free Endpoint" en el catálogo de NGC, y responden con
|
|
374
409
|
// tool calling en una cuenta gratuita. Contexto según la referencia de la API
|
|
375
410
|
// de NVIDIA (Kimi K3) y OpenRouter (el resto). Verificado 2026-09-10.
|
|
411
|
+
// ── Generación de imágenes (NVIDIA, endpoints alojados ai.api.nvidia.com/v1/genai) ──
|
|
412
|
+
// Solo entran los verificados con una cuenta gratuita el 2026-11-23: responden con una
|
|
413
|
+
// imagen JPEG en `artifacts[0].base64`. flux.1-dev se colgó (>150 s) y su licencia es no
|
|
414
|
+
// comercial; los de edición (Kontext, klein con imagen) solo admiten imágenes de ejemplo
|
|
415
|
+
// predefinidas y Qwen-Image no tiene endpoint alojado, así que no se listan.
|
|
416
|
+
{ id: "black-forest-labs/flux.2-klein-4b", providerId: "nvidia", name: "FLUX.2 Klein 4B (NVIDIA)", modelType: "image", contextWindow: 0, capabilities: JSON.stringify(["image_generation"]), inputPer1M: 0, outputPer1M: 0 },
|
|
417
|
+
{ id: "black-forest-labs/flux.1-schnell", providerId: "nvidia", name: "FLUX.1 Schnell (NVIDIA)", modelType: "image", contextWindow: 0, capabilities: JSON.stringify(["image_generation"]), inputPer1M: 0, outputPer1M: 0 },
|
|
376
418
|
{ id: "meta/muse-glimmer-30b", providerId: "nvidia", name: "Muse Glimmer 30B (NVIDIA)", modelType: "llm", contextWindow: 131072, capabilities: JSON.stringify(["chat", "vision", "function_calling", "streaming", "reasoning"]), inputPer1M: 0, outputPer1M: 0 },
|
|
377
419
|
{ id: "nvidia/nemotron-3-ultra-550b-a55b", providerId: "nvidia", name: "Nemotron 3 Ultra 550B", modelType: "llm", contextWindow: 1000000, capabilities: JSON.stringify(["chat", "code", "json_mode", "function_calling", "streaming", "reasoning"]), inputPer1M: 0, outputPer1M: 0 },
|
|
378
420
|
// Revisado el 2026-11-16 con llamadas reales a /v1/models y a cada modelo (nivel gratuito, "Free Endpoint"): de 23
|
|
@@ -532,6 +574,7 @@ import type {
|
|
|
532
574
|
ToolDoc, SkillDoc, EthicsDoc, ProviderDoc, ModelDoc, McpServerDoc, ChannelDoc, PlaybookDoc, AgentDoc,
|
|
533
575
|
} from "./collections"
|
|
534
576
|
import { createSeedCatalogAgents, ensureAgentsConfigured } from "../agent/agent-catalog"
|
|
577
|
+
import { syncGoogleCapabilities } from "./google-capabilities.ts"
|
|
535
578
|
|
|
536
579
|
const log = logger.child("seed");
|
|
537
580
|
|
|
@@ -777,6 +820,8 @@ async function reseedToolsAndSkills(): Promise<void> {
|
|
|
777
820
|
toolCount++;
|
|
778
821
|
}
|
|
779
822
|
log.info(`[seed] ✅ ${toolCount} tools re-seeded`);
|
|
823
|
+
// Las tools de Google nacen activas en SEED_DATA: se alinean con la conexión real.
|
|
824
|
+
await syncGoogleCapabilities("seed").catch((err) => log.warn(`[seed] google: ${(err as Error).message}`));
|
|
780
825
|
|
|
781
826
|
// ── Skills: re-seed from the bundled skill files ──
|
|
782
827
|
const skillsCol = await col<SkillDoc>("skills");
|
|
@@ -836,10 +881,11 @@ export async function seedAllData(): Promise<void> {
|
|
|
836
881
|
const providersCol = await col<ProviderDoc>("providers");
|
|
837
882
|
let providerCount = 0;
|
|
838
883
|
for (const provider of SEED_DATA.providers) {
|
|
884
|
+
const localByDefault = provider.id === LOCAL_TTS_PROVIDER;
|
|
839
885
|
await putIfAbsent(providersCol, provider.id, {
|
|
840
886
|
id: provider.id, name: provider.name, base_url: provider.baseUrl || null,
|
|
841
887
|
category: (provider.category || "llm") as ProviderDoc["category"],
|
|
842
|
-
num_ctx: null, num_gpu: -1, enabled:
|
|
888
|
+
num_ctx: null, num_gpu: -1, enabled: localByDefault, active: localByDefault, created_at: now,
|
|
843
889
|
});
|
|
844
890
|
providerCount++;
|
|
845
891
|
}
|
|
@@ -875,39 +921,49 @@ export async function seedAllData(): Promise<void> {
|
|
|
875
921
|
// (context_window, capabilities, precio) sobrevive a una entrada renombrada
|
|
876
922
|
// o corregida. Un upsert en sitio no daba esa garantía.
|
|
877
923
|
//
|
|
878
|
-
//
|
|
879
|
-
// - enabled/active por id, para
|
|
880
|
-
// eligió cada vez que se publica un catálogo nuevo;
|
|
924
|
+
// Se preservan a propósito:
|
|
925
|
+
// - enabled/active por id, salvo para voz, que hereda el estado del proveedor;
|
|
881
926
|
// - las filas source != "catalog" (Ollama tags, /v1/models), que no tienen
|
|
882
927
|
// origen canónico desde el que recrearse.
|
|
928
|
+
// - el resultado de la última consulta al proveedor sobre disponibilidad.
|
|
883
929
|
log.info("[seed] 🔄 Re-seeding models (wipe & recreate)...");
|
|
884
930
|
const modelsCol = await col<ModelDoc>("models");
|
|
885
931
|
const beforeWipe = await modelsCol.scan({});
|
|
932
|
+
const providersById = new Map((await providersCol.scan({})).map(({ id, doc }) => [id, doc]));
|
|
886
933
|
|
|
887
|
-
const
|
|
888
|
-
beforeWipe.map((e) => [e.id, { enabled: e.doc.enabled, active: e.doc.active }])
|
|
889
|
-
);
|
|
934
|
+
const previousModels = new Map(beforeWipe.map(({ id, doc }) => [id, doc]));
|
|
890
935
|
|
|
936
|
+
const piperModelIds = new Set(beforeWipe.filter(row => row.doc.provider_id === "piper").map(row => row.id));
|
|
891
937
|
let wipedModels = 0;
|
|
892
938
|
for (const row of beforeWipe) {
|
|
893
|
-
if (row.
|
|
894
|
-
|
|
895
|
-
|
|
939
|
+
if (piperModelIds.has(row.id)) continue;
|
|
940
|
+
if (row.doc.source === "catalog") {
|
|
941
|
+
await modelsCol.delete(row.id);
|
|
942
|
+
wipedModels++;
|
|
943
|
+
continue;
|
|
944
|
+
}
|
|
945
|
+
const activation = voiceModelActivation(row.doc, providersById.get(row.doc.provider_id));
|
|
946
|
+
if (activation && (row.doc.active !== activation.active || row.doc.enabled !== activation.enabled)) {
|
|
947
|
+
await modelsCol.put(row.id, { ...row.doc, ...activation }, { expectedVersion: row.version });
|
|
948
|
+
}
|
|
896
949
|
}
|
|
897
950
|
|
|
898
951
|
let modelCount = 0;
|
|
899
952
|
for (const model of SEED_DATA.models) {
|
|
900
953
|
const key = catalogModelKey(model.providerId, model.id);
|
|
901
|
-
const previous =
|
|
902
|
-
|
|
954
|
+
const previous = previousModels.get(key);
|
|
955
|
+
const doc: ModelDoc = {
|
|
903
956
|
id: key, provider_id: model.providerId, name: model.name,
|
|
904
957
|
model_type: model.modelType as ModelDoc["model_type"],
|
|
905
958
|
context_window: model.contextWindow || 0, capabilities: model.capabilities || null,
|
|
906
|
-
enabled: previous?.enabled ?? true, active: previous?.active ??
|
|
959
|
+
enabled: previous?.enabled ?? true, active: previous?.active ?? (key === LOCAL_TTS_MODEL),
|
|
960
|
+
...(previous?.unlisted ? { unlisted: true } : {}),
|
|
961
|
+
...(previous?.synced_at ? { synced_at: previous.synced_at } : {}),
|
|
907
962
|
source: "catalog",
|
|
908
963
|
input_per_1m: model.inputPer1M ?? null,
|
|
909
964
|
output_per_1m: model.outputPer1M ?? null,
|
|
910
|
-
}
|
|
965
|
+
};
|
|
966
|
+
await modelsCol.put(key, { ...doc, ...voiceModelActivation(doc, providersById.get(model.providerId)) });
|
|
911
967
|
modelCount++;
|
|
912
968
|
}
|
|
913
969
|
log.info(`[seed] 🗑️ ${wipedModels} modelo(s) de catálogo borrados y recreados desde SEED_DATA`);
|
|
@@ -942,6 +998,11 @@ export async function seedAllData(): Promise<void> {
|
|
|
942
998
|
patch[field] = RETIRED_VOICE_MODELS[current];
|
|
943
999
|
}
|
|
944
1000
|
}
|
|
1001
|
+
const tts = c.doc.tts_provider;
|
|
1002
|
+
if (tts && (piperModelIds.has(tts) || isLegacyPiper(tts))) {
|
|
1003
|
+
patch.tts_provider = LOCAL_TTS_MODEL;
|
|
1004
|
+
patch.tts_voice_id = DEFAULT_LOCAL_VOICE;
|
|
1005
|
+
}
|
|
945
1006
|
if (Object.keys(patch).length === 0) continue;
|
|
946
1007
|
await voiceChannelsCol.put(c.id, { ...c.doc, ...patch }, { expectedVersion: c.version });
|
|
947
1008
|
migratedVoice++;
|
|
@@ -950,6 +1011,8 @@ export async function seedAllData(): Promise<void> {
|
|
|
950
1011
|
if (migratedVoice > 0) {
|
|
951
1012
|
log.info(`[seed] 🎙️ ${migratedVoice} canal(es) repuntados a modelos de voz vigentes`);
|
|
952
1013
|
}
|
|
1014
|
+
for (const id of piperModelIds) await modelsCol.delete(id);
|
|
1015
|
+
if (await providersCol.get("piper")) await providersCol.delete("piper");
|
|
953
1016
|
|
|
954
1017
|
log.info(`[seed] ✅ ${modelCount} models procesados`);
|
|
955
1018
|
|
|
@@ -154,15 +154,6 @@ export interface UsageRecord {
|
|
|
154
154
|
created_at: number;
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
export interface JevUsageSummary {
|
|
158
|
-
decisions: number;
|
|
159
|
-
costUsd: number;
|
|
160
|
-
/** Estimated main-model input tokens avoided; negative when Jev added more than it removed. */
|
|
161
|
-
savedTokens: number;
|
|
162
|
-
savedCostUsd: number;
|
|
163
|
-
byAgent: Record<string, { decisions: number; costUsd: number; savedTokens: number; savedCostUsd: number }>;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
157
|
export interface UsageSummary {
|
|
167
158
|
totalTokens: number;
|
|
168
159
|
totalInputTokens: number;
|
|
@@ -177,7 +168,6 @@ export interface UsageSummary {
|
|
|
177
168
|
toonSavingsPercent: number;
|
|
178
169
|
byProvider: Record<string, { tokens: number; costUsd: number; inputTokens: number; outputTokens: number }>;
|
|
179
170
|
byModel: Record<string, { tokens: number; costUsd: number; provider: string; inputTokens: number; outputTokens: number }>;
|
|
180
|
-
jev: JevUsageSummary;
|
|
181
171
|
recentRecords: UsageRecord[];
|
|
182
172
|
}
|
|
183
173
|
|
|
@@ -250,7 +240,6 @@ export async function getUsageStats(hours: number = 24): Promise<UsageSummary> {
|
|
|
250
240
|
let totalInput = 0, totalOutput = 0, totalCost = 0;
|
|
251
241
|
let toonSavedTokens = 0, toonSavedCost = 0, toonSavedBytes = 0;
|
|
252
242
|
let toonJsonTokens = 0, toonToonTokens = 0, toonJsonBytes = 0;
|
|
253
|
-
const jev: JevUsageSummary = { decisions: 0, costUsd: 0, savedTokens: 0, savedCostUsd: 0, byAgent: {} };
|
|
254
243
|
|
|
255
244
|
for (const r of rollups) {
|
|
256
245
|
totalInput += r.inputTokens;
|
|
@@ -262,18 +251,6 @@ export async function getUsageStats(hours: number = 24): Promise<UsageSummary> {
|
|
|
262
251
|
toonJsonTokens += r.toonJsonTokens;
|
|
263
252
|
toonToonTokens += r.toonToonTokens;
|
|
264
253
|
toonJsonBytes += r.toonJsonBytes;
|
|
265
|
-
jev.decisions += r.jevDecisions ?? 0;
|
|
266
|
-
jev.costUsd += r.jevCostUsd ?? 0;
|
|
267
|
-
jev.savedTokens += r.jevSavedTokens ?? 0;
|
|
268
|
-
jev.savedCostUsd += r.jevSavedCostUsd ?? 0;
|
|
269
|
-
for (const [agentId, a] of Object.entries(r.jevByAgent ?? {})) {
|
|
270
|
-
const cur = jev.byAgent[agentId] ?? { decisions: 0, costUsd: 0, savedTokens: 0, savedCostUsd: 0 };
|
|
271
|
-
cur.decisions += a.jevDecisions ?? 0;
|
|
272
|
-
cur.costUsd += a.jevCostUsd ?? 0;
|
|
273
|
-
cur.savedTokens += a.jevSavedTokens ?? 0;
|
|
274
|
-
cur.savedCostUsd += a.jevSavedCostUsd ?? 0;
|
|
275
|
-
jev.byAgent[agentId] = cur;
|
|
276
|
-
}
|
|
277
254
|
|
|
278
255
|
for (const [provider, p] of Object.entries(r.byProvider ?? {})) {
|
|
279
256
|
const cur = providerMap[provider] ?? { tokens: 0, costUsd: 0, inputTokens: 0, outputTokens: 0 };
|
|
@@ -324,39 +301,10 @@ export async function getUsageStats(hours: number = 24): Promise<UsageSummary> {
|
|
|
324
301
|
toonSavingsPercent,
|
|
325
302
|
byProvider: providerMap,
|
|
326
303
|
byModel: modelMap,
|
|
327
|
-
jev,
|
|
328
304
|
recentRecords
|
|
329
305
|
};
|
|
330
306
|
}
|
|
331
307
|
|
|
332
|
-
/**
|
|
333
|
-
* Persists one Jev decision into the hourly rollup. The avoided tokens are
|
|
334
|
-
* priced with the advised agent's own model (input rate), through the same
|
|
335
|
-
* catalog lookup as real usage, so "saved" and "spent" are comparable.
|
|
336
|
-
*/
|
|
337
|
-
export function recordJevDecision(options: {
|
|
338
|
-
agentId: string;
|
|
339
|
-
provider: string;
|
|
340
|
-
model: string;
|
|
341
|
-
savedTokens: number;
|
|
342
|
-
costUsd: number;
|
|
343
|
-
}): void {
|
|
344
|
-
Promise.resolve().then(async () => {
|
|
345
|
-
try {
|
|
346
|
-
const unitCost = await calculateCost(options.provider, options.model, Math.abs(options.savedTokens), 0);
|
|
347
|
-
const savedCostUsd = Math.sign(options.savedTokens) * unitCost;
|
|
348
|
-
await bumpRollup("usageRollups", hourBucket(Date.now()), {
|
|
349
|
-
jevDecisions: 1,
|
|
350
|
-
jevCostUsd: options.costUsd,
|
|
351
|
-
jevSavedTokens: options.savedTokens,
|
|
352
|
-
jevSavedCostUsd: savedCostUsd,
|
|
353
|
-
}, { field: "jevByAgent", key: options.agentId });
|
|
354
|
-
} catch (error) {
|
|
355
|
-
log.warn(`[JEV] Failed to record decision:`, error);
|
|
356
|
-
}
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
|
|
360
308
|
/**
|
|
361
309
|
* Record TOON savings for metrics tracking
|
|
362
310
|
* This updates the usage_records table with complete TOON compression metrics
|
|
@@ -60,9 +60,7 @@ export const getAvailableModelsTool: Tool = {
|
|
|
60
60
|
.filter(m => m.enabled && providersById.has(m.provider_id));
|
|
61
61
|
|
|
62
62
|
if (providerId) models = models.filter(m => m.provider_id === providerId);
|
|
63
|
-
|
|
64
|
-
// agent assigned one would fail every turn.
|
|
65
|
-
models = modelType ? models.filter(m => m.model_type === modelType) : models.filter(m => m.model_type !== "decision");
|
|
63
|
+
if (modelType) models = models.filter(m => m.model_type === modelType);
|
|
66
64
|
if (capabilities) models = models.filter(m => (m.capabilities ?? "").includes(capabilities));
|
|
67
65
|
|
|
68
66
|
// Transformar a formato amigable
|
|
@@ -541,7 +541,7 @@ export const reportProgressTool: Tool = {
|
|
|
541
541
|
/** Máximo de mensajes que devuelve conversation_read. */
|
|
542
542
|
const MESSAGE_LIMIT = 8;
|
|
543
543
|
|
|
544
|
-
/** Recover a small, scoped slice of conversation omitted
|
|
544
|
+
/** Recover a small, scoped slice of conversation omitted from the context window. */
|
|
545
545
|
export const conversationReadTool: Tool = {
|
|
546
546
|
name: "conversation_read",
|
|
547
547
|
description: "Read earlier messages from the current conversation by message IDs or text query when selected context is insufficient. Searches by meaning across the whole history, including messages already compacted into the summary.",
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Google Calendar: consultar, crear, modificar y borrar eventos; disponibilidad.
|
|
3
|
+
*
|
|
4
|
+
* @category google
|
|
5
|
+
* @spanish calendario, agenda, evento, reunión, cita, disponibilidad
|
|
6
|
+
*/
|
|
7
|
+
import { googleJson } from "../../google/client.ts";
|
|
8
|
+
import { CONFIRMED_PARAM, googleTool, needsConfirmation, num, str } from "./shared.ts";
|
|
9
|
+
|
|
10
|
+
const API = "https://www.googleapis.com/calendar/v3";
|
|
11
|
+
const cal = (p: Record<string, unknown>) => encodeURIComponent(str(p.calendar_id) ?? "primary");
|
|
12
|
+
|
|
13
|
+
function slim(e: any) {
|
|
14
|
+
return {
|
|
15
|
+
id: e.id,
|
|
16
|
+
summary: e.summary,
|
|
17
|
+
start: e.start?.dateTime ?? e.start?.date,
|
|
18
|
+
end: e.end?.dateTime ?? e.end?.date,
|
|
19
|
+
location: e.location,
|
|
20
|
+
description: e.description?.slice(0, 500),
|
|
21
|
+
attendees: (e.attendees ?? []).map((a: any) => ({ email: a.email, status: a.responseStatus })),
|
|
22
|
+
meet_link: e.hangoutLink,
|
|
23
|
+
link: e.htmlLink,
|
|
24
|
+
status: e.status,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Acepta "2026-12-01T10:00:00-05:00" (con zona) o fecha sin hora (evento de día completo). */
|
|
29
|
+
function when(value: string, timeZone?: string) {
|
|
30
|
+
return /^\d{4}-\d{2}-\d{2}$/.test(value)
|
|
31
|
+
? { date: value }
|
|
32
|
+
: { dateTime: value, ...(timeZone ? { timeZone } : {}) };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const ISO = "ISO 8601. Prefer an explicit offset (2026-12-01T10:00:00-05:00); a bare date creates an all-day event.";
|
|
36
|
+
|
|
37
|
+
export const gcalListEventsTool = googleTool({
|
|
38
|
+
name: "gcal_list_events",
|
|
39
|
+
description:
|
|
40
|
+
"List Google Calendar events in a time range (default: the next 7 days). Spanish: ver agenda, qué tengo hoy, próximos eventos, reuniones de la semana",
|
|
41
|
+
parameters: {
|
|
42
|
+
type: "object",
|
|
43
|
+
properties: {
|
|
44
|
+
time_min: { type: "string", description: `Range start. ${ISO} Default: now.` },
|
|
45
|
+
time_max: { type: "string", description: `Range end. ${ISO} Default: +7 days.` },
|
|
46
|
+
query: { type: "string", description: "Free-text filter." },
|
|
47
|
+
calendar_id: { type: "string", description: "Default: primary." },
|
|
48
|
+
max_results: { type: "number", minimum: 1, maximum: 50, description: "Default 20." },
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
run: async (p, { userId }) => {
|
|
52
|
+
const now = Date.now();
|
|
53
|
+
const data = await googleJson<any>(userId, "calendar", `${API}/calendars/${cal(p)}/events`, {
|
|
54
|
+
query: {
|
|
55
|
+
timeMin: str(p.time_min) ?? new Date(now).toISOString(),
|
|
56
|
+
timeMax: str(p.time_max) ?? new Date(now + 7 * 864e5).toISOString(),
|
|
57
|
+
q: str(p.query),
|
|
58
|
+
maxResults: num(p.max_results, 20, 1, 50),
|
|
59
|
+
singleEvents: true,
|
|
60
|
+
orderBy: "startTime",
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
const events = (data.items ?? []).map(slim);
|
|
64
|
+
return { ok: true, count: events.length, time_zone: data.timeZone, events };
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
export const gcalCreateEventTool = googleTool({
|
|
69
|
+
name: "gcal_create_event",
|
|
70
|
+
description:
|
|
71
|
+
"Create a Google Calendar event. If it has attendees, Google emails them invitations, so the first call returns needs_confirmation; repeat with confirmed=true after the user approves. " +
|
|
72
|
+
"Spanish: agendar reunión, crear evento, programar cita, invitar asistentes",
|
|
73
|
+
parameters: {
|
|
74
|
+
type: "object",
|
|
75
|
+
properties: {
|
|
76
|
+
summary: { type: "string", description: "Event title." },
|
|
77
|
+
start: { type: "string", description: ISO },
|
|
78
|
+
end: { type: "string", description: ISO },
|
|
79
|
+
time_zone: { type: "string", description: "IANA zone, e.g. America/Bogota. Needed only when start/end have no offset." },
|
|
80
|
+
description: { type: "string" },
|
|
81
|
+
location: { type: "string" },
|
|
82
|
+
attendees: { type: "array", items: { type: "string" }, description: "Attendee emails." },
|
|
83
|
+
add_meet: { type: "boolean", description: "Attach a Google Meet link." },
|
|
84
|
+
calendar_id: { type: "string" },
|
|
85
|
+
confirmed: CONFIRMED_PARAM,
|
|
86
|
+
},
|
|
87
|
+
required: ["summary", "start", "end"],
|
|
88
|
+
},
|
|
89
|
+
run: async (p, { userId }) => {
|
|
90
|
+
const summary = str(p.summary), start = str(p.start), end = str(p.end);
|
|
91
|
+
if (!summary || !start || !end) return { ok: false, error: "summary, start y end son obligatorios." };
|
|
92
|
+
const attendees = Array.isArray(p.attendees) ? p.attendees.filter((a): a is string => typeof a === "string" && a.includes("@")) : [];
|
|
93
|
+
if (attendees.length) {
|
|
94
|
+
const pending = needsConfirmation(p, { summary, start, end, attendees, location: str(p.location) });
|
|
95
|
+
if (pending) return pending;
|
|
96
|
+
}
|
|
97
|
+
const tz = str(p.time_zone);
|
|
98
|
+
const body: Record<string, unknown> = {
|
|
99
|
+
summary,
|
|
100
|
+
start: when(start, tz),
|
|
101
|
+
end: when(end, tz),
|
|
102
|
+
description: str(p.description),
|
|
103
|
+
location: str(p.location),
|
|
104
|
+
attendees: attendees.map((email) => ({ email })),
|
|
105
|
+
};
|
|
106
|
+
if (p.add_meet === true) {
|
|
107
|
+
body.conferenceData = { createRequest: { requestId: crypto.randomUUID(), conferenceSolutionKey: { type: "hangoutsMeet" } } };
|
|
108
|
+
}
|
|
109
|
+
const ev = await googleJson<any>(userId, "calendar", `${API}/calendars/${cal(p)}/events`, {
|
|
110
|
+
method: "POST",
|
|
111
|
+
query: { conferenceDataVersion: p.add_meet === true ? 1 : undefined, sendUpdates: attendees.length ? "all" : "none" },
|
|
112
|
+
body,
|
|
113
|
+
});
|
|
114
|
+
return { ok: true, event: slim(ev) };
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
export const gcalUpdateEventTool = googleTool({
|
|
119
|
+
name: "gcal_update_event",
|
|
120
|
+
description:
|
|
121
|
+
"Modify fields of an existing Google Calendar event (only the ones provided). Needs user confirmation (needs_confirmation, then confirmed=true). Spanish: mover reunión, cambiar evento, reprogramar cita",
|
|
122
|
+
parameters: {
|
|
123
|
+
type: "object",
|
|
124
|
+
properties: {
|
|
125
|
+
event_id: { type: "string" },
|
|
126
|
+
summary: { type: "string" },
|
|
127
|
+
start: { type: "string", description: ISO },
|
|
128
|
+
end: { type: "string", description: ISO },
|
|
129
|
+
time_zone: { type: "string" },
|
|
130
|
+
description: { type: "string" },
|
|
131
|
+
location: { type: "string" },
|
|
132
|
+
calendar_id: { type: "string" },
|
|
133
|
+
confirmed: CONFIRMED_PARAM,
|
|
134
|
+
},
|
|
135
|
+
required: ["event_id"],
|
|
136
|
+
},
|
|
137
|
+
run: async (p, { userId }) => {
|
|
138
|
+
const id = str(p.event_id);
|
|
139
|
+
if (!id) return { ok: false, error: "event_id es obligatorio." };
|
|
140
|
+
const tz = str(p.time_zone);
|
|
141
|
+
const patch: Record<string, unknown> = {};
|
|
142
|
+
for (const k of ["summary", "description", "location"] as const) if (str(p[k]) !== undefined) patch[k] = str(p[k]);
|
|
143
|
+
if (str(p.start)) patch.start = when(str(p.start)!, tz);
|
|
144
|
+
if (str(p.end)) patch.end = when(str(p.end)!, tz);
|
|
145
|
+
if (!Object.keys(patch).length) return { ok: false, error: "No hay ningún campo para modificar." };
|
|
146
|
+
const pending = needsConfirmation(p, { event_id: id, changes: patch });
|
|
147
|
+
if (pending) return pending;
|
|
148
|
+
const ev = await googleJson<any>(userId, "calendar", `${API}/calendars/${cal(p)}/events/${encodeURIComponent(id)}`, {
|
|
149
|
+
method: "PATCH", query: { sendUpdates: "all" }, body: patch,
|
|
150
|
+
});
|
|
151
|
+
return { ok: true, event: slim(ev) };
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
export const gcalDeleteEventTool = googleTool({
|
|
156
|
+
name: "gcal_delete_event",
|
|
157
|
+
description:
|
|
158
|
+
"Delete a Google Calendar event (attendees are notified). IRREVERSIBLE: needs_confirmation first, then confirmed=true. Spanish: cancelar reunión, borrar evento",
|
|
159
|
+
parameters: {
|
|
160
|
+
type: "object",
|
|
161
|
+
properties: { event_id: { type: "string" }, calendar_id: { type: "string" }, confirmed: CONFIRMED_PARAM },
|
|
162
|
+
required: ["event_id"],
|
|
163
|
+
},
|
|
164
|
+
run: async (p, { userId }) => {
|
|
165
|
+
const id = str(p.event_id);
|
|
166
|
+
if (!id) return { ok: false, error: "event_id es obligatorio." };
|
|
167
|
+
const pending = needsConfirmation(p, { event_id: id, action: "delete" });
|
|
168
|
+
if (pending) return pending;
|
|
169
|
+
await googleJson(userId, "calendar", `${API}/calendars/${cal(p)}/events/${encodeURIComponent(id)}`, {
|
|
170
|
+
method: "DELETE", query: { sendUpdates: "all" },
|
|
171
|
+
});
|
|
172
|
+
return { ok: true, deleted: id };
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
export const gcalFreebusyTool = googleTool({
|
|
177
|
+
name: "gcal_freebusy",
|
|
178
|
+
description:
|
|
179
|
+
"Check busy intervals for one or more calendars in a time range to find free slots. Spanish: disponibilidad, horarios libres, cuándo estoy libre",
|
|
180
|
+
parameters: {
|
|
181
|
+
type: "object",
|
|
182
|
+
properties: {
|
|
183
|
+
time_min: { type: "string", description: ISO },
|
|
184
|
+
time_max: { type: "string", description: ISO },
|
|
185
|
+
calendar_ids: { type: "array", items: { type: "string" }, description: "Default: [primary]. Other people's emails work if they share their calendar." },
|
|
186
|
+
},
|
|
187
|
+
required: ["time_min", "time_max"],
|
|
188
|
+
},
|
|
189
|
+
run: async (p, { userId }) => {
|
|
190
|
+
const timeMin = str(p.time_min), timeMax = str(p.time_max);
|
|
191
|
+
if (!timeMin || !timeMax) return { ok: false, error: "time_min y time_max son obligatorios." };
|
|
192
|
+
const ids = Array.isArray(p.calendar_ids) && p.calendar_ids.length ? (p.calendar_ids as string[]).slice(0, 10) : ["primary"];
|
|
193
|
+
const data = await googleJson<any>(userId, "calendar", `${API}/freeBusy`, {
|
|
194
|
+
method: "POST",
|
|
195
|
+
body: { timeMin, timeMax, items: ids.map((id) => ({ id })) },
|
|
196
|
+
});
|
|
197
|
+
const calendars = Object.fromEntries(Object.entries<any>(data.calendars ?? {}).map(([id, c]) => [id, { busy: c.busy ?? [], errors: c.errors }]));
|
|
198
|
+
return { ok: true, calendars };
|
|
199
|
+
},
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
export const calendarTools = [
|
|
203
|
+
gcalListEventsTool, gcalCreateEventTool, gcalUpdateEventTool, gcalDeleteEventTool, gcalFreebusyTool,
|
|
204
|
+
];
|