@johpaz/hive-agents 1.1.3 → 1.1.5
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 +52087 -4376
- package/dist/tool-worker.js +49660 -1160
- package/dist/ui/assets/{A2UIPage-EDS7lN-K.js → A2UIPage-Dr3p75oE.js} +1 -1
- package/dist/ui/assets/{AgentCreateForm-KvhVhAFP.js → AgentCreateForm-DqYhH_gm.js} +1 -1
- package/dist/ui/assets/{AgentDetailPage-B2dCpO92.js → AgentDetailPage-BVtE88U5.js} +1 -1
- package/dist/ui/assets/{AgentNewPage-CF2B4dbu.js → AgentNewPage-BRpFxJIT.js} +1 -1
- package/dist/ui/assets/{AgentsPage-CMvz-CtA.js → AgentsPage-BOIJ55cj.js} +1 -1
- package/dist/ui/assets/{ApiClientPage-tzzL3rZC.js → ApiClientPage-R9UDWfR2.js} +1 -1
- package/dist/ui/assets/{ChannelsPage-fE2vRwup.js → ChannelsPage-C5V2BmjL.js} +1 -1
- package/dist/ui/assets/{DashboardPage-57SaHnBL.js → DashboardPage-B18gMzNj.js} +1 -1
- package/dist/ui/assets/{LoginPage-Fag9Bp5h.js → LoginPage-nrsYF9AY.js} +1 -1
- package/dist/ui/assets/{LogsPage-GVJd_a65.js → LogsPage-DICMU_7m.js} +1 -1
- package/dist/ui/assets/{MeetingPage-TKQu8Nr-.js → MeetingPage-xslJGfIz.js} +1 -1
- package/dist/ui/assets/{ModelSelector-DciHLo7R.js → ModelSelector-BX4IvuYY.js} +1 -1
- package/dist/ui/assets/Office3DPage-a6cuzt5X.js +727 -0
- package/dist/ui/assets/{ProvidersPage-BsWFvzqz.js → ProvidersPage-C8-xGoeh.js} +1 -1
- package/dist/ui/assets/{RecoverPage-BkdOyljs.js → RecoverPage-Blms3NBa.js} +1 -1
- package/dist/ui/assets/{SettingsPage-D_43Rc2I.js → SettingsPage-BBeeq_QS.js} +1 -1
- package/dist/ui/assets/{SetupPage-D6Z3SYZu.js → SetupPage-CAjLseE_.js} +1 -1
- package/dist/ui/assets/{Vignette-bSrGVyRd.js → Vignette-DrI2yK2m.js} +1 -1
- package/dist/ui/assets/VoicePage-BeSSYstD.js +307 -0
- package/dist/ui/assets/{WebChatPage-Dzk3FhiR.js → WebChatPage-Bat7uUfd.js} +1 -1
- package/dist/ui/assets/{bia-csMImkVQ.glb → bia-qdLMQRFi.glb} +0 -0
- package/dist/ui/assets/{conversationsStore-5hf5grlP.js → conversationsStore-DhM07qYi.js} +1 -1
- package/dist/ui/assets/{dialog-DKnsGLwr.js → dialog-BP3GTCPn.js} +1 -1
- package/dist/ui/assets/{index-mBw9Tl7u.js → index-BG3nUPKq.js} +2 -2
- package/dist/ui/assets/{useAudioDevices-BYFaA0X-.js → useAudioDevices-zj0fuGwZ.js} +1 -1
- package/dist/ui/assets/{useHiveAgentsModelLoad-RRQ6-ANC.js → useHiveAgentsModelLoad-Cd9p-bjs.js} +1 -1
- package/dist/ui/assets/{useProviders-DXr4pJ57.js → useProviders-Dj1k5PCk.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/package.json +1 -1
- package/packages/cli/src/commands/onboard.ts +8 -7
- package/packages/core/src/agent/agent-catalog.ts +2 -2
- package/packages/core/src/gateway/routes/providers.ts +26 -79
- package/packages/core/src/gateway/server.ts +20 -0
- package/packages/core/src/scheduler/integration.ts +26 -20
- package/packages/core/src/storage/collections.ts +7 -0
- package/packages/core/src/storage/model-sync.ts +404 -0
- package/packages/core/src/storage/seed.ts +33 -3
- package/packages/core/src/tools/a2ui/index.ts +76 -0
- package/packages/core/src/tools/cron/index.ts +25 -3
- package/packages/core/src/tools/office/office-escribir-docx.ts +275 -97
- package/packages/core/src/tools/office/office-escribir-pdf.ts +489 -99
- package/packages/core/src/tools/office/office-escribir-pptx.ts +86 -84
- package/packages/core/src/tools/office/office-escribir-xlsx.ts +196 -40
- package/packages/core/src/tools/office/office-style.ts +452 -0
- package/packages/core/src/tools/web/obscura-install.ts +119 -0
- package/packages/core/src/tools/web/obscura.ts +26 -4
- package/packages/core/src/utils/date.ts +29 -0
- package/packages/skills/src/bundled-data.generated.ts +780 -780
- package/dist/ui/assets/Office3DPage-CQnO522l.js +0 -727
- package/dist/ui/assets/VoicePage-CCE2EOE9.js +0 -307
|
@@ -362,11 +362,29 @@ export const SEED_DATA: SeedData = {
|
|
|
362
362
|
// julio/agosto con "Free Endpoint" en el catálogo de NGC, y responden con
|
|
363
363
|
// tool calling en una cuenta gratuita. Contexto según la referencia de la API
|
|
364
364
|
// de NVIDIA (Kimi K3) y OpenRouter (el resto). Verificado 2026-09-10.
|
|
365
|
-
{ id: "moonshotai/kimi-k3", providerId: "nvidia", name: "Kimi K3 (NVIDIA)", modelType: "llm", contextWindow: 1048576, capabilities: JSON.stringify(["chat", "code", "vision", "function_calling", "streaming", "reasoning"]), inputPer1M: 0, outputPer1M: 0 },
|
|
366
|
-
{ id: "deepseek-ai/deepseek-v4-flash-0731", providerId: "nvidia", name: "DeepSeek V4 Flash (NVIDIA)", modelType: "llm", contextWindow: 1048576, capabilities: JSON.stringify(["chat", "code", "function_calling", "streaming", "reasoning"]), inputPer1M: 0, outputPer1M: 0 },
|
|
367
365
|
{ 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 },
|
|
368
366
|
{ 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 },
|
|
369
|
-
|
|
367
|
+
// Revisado el 2026-11-16 con llamadas reales a /v1/models y a cada modelo (nivel gratuito, "Free Endpoint"): de 23
|
|
368
|
+
// LLMs listados respondieron 11, y 10 de ellos también con herramientas. Que el proveedor liste un modelo NO
|
|
369
|
+
// garantiza que funcione: varios devuelven 404 "Function not found for account" o 500.
|
|
370
|
+
// Solo se declaran las capacidades comprobadas ese día, y SOLO quedan los que llamaron herramientas (tool_calls): sin
|
|
371
|
+
// eso un modelo no sirve para un agente. Retirados (410 Gone) y por eso quitados de esta lista:
|
|
372
|
+
// moonshotai/kimi-k3 (2026-10-15), deepseek-ai/deepseek-v4-flash-0731 (2026-09-21) y
|
|
373
|
+
// nvidia/nemotron-3-super-120b-a12b (2026-10-03). z-ai/glm-5.3 también se retiró (2026-10-28).
|
|
374
|
+
// Quedaron fuera por no responder hoy, aunque figuran en /v1/models: z-ai/glm-5.3-flash (agota 170 s, dos veces) y
|
|
375
|
+
// minimaxai/minimax-m3.1-flash (503 "content safety screening is temporarily unavailable", dos veces). Funcionaron
|
|
376
|
+
// en una prueba anterior: si vuelven, se pueden añadir de nuevo.
|
|
377
|
+
// deepseek-ai/deepseek-v4.1-flash respondió bien en las pruebas, pero /v1/models ya no lo lista: no entra (esta lista
|
|
378
|
+
// se valida contra el listado vivo; `storage/model-sync.ts` lo marcaría `unlisted`).
|
|
379
|
+
{ id: "nvidia/nemotron-3.5-super-vl-120b-a12b", providerId: "nvidia", name: "Nemotron 3.5 Super VL 120B", modelType: "llm", contextWindow: 1000000, capabilities: JSON.stringify(["chat", "vision", "reasoning", "function_calling"]), inputPer1M: 0, outputPer1M: 0 },
|
|
380
|
+
{ id: "nvidia/nemotron-3.5-bolt-e4b", providerId: "nvidia", name: "Nemotron 3.5 Bolt E4B", modelType: "llm", contextWindow: 65536, capabilities: JSON.stringify(["chat", "vision", "function_calling"]), inputPer1M: 0, outputPer1M: 0 },
|
|
381
|
+
{ id: "nvidia/nemotron-3-nano-omni-30b-a3b-reasoning", providerId: "nvidia", name: "Nemotron 3 Nano Omni 30B", modelType: "llm", contextWindow: 262144, capabilities: JSON.stringify(["chat", "vision", "reasoning", "function_calling"]), inputPer1M: 0, outputPer1M: 0 },
|
|
382
|
+
// Con ventana de contexto 0 (NVIDIA no la publica y no se inventa): el runtime ya la trata como desconocida.
|
|
383
|
+
{ id: "nvidia/nemotron-3.5-lightning-30b-a3b", providerId: "nvidia", name: "Nemotron 3.5 Lightning 30B", modelType: "llm", contextWindow: 0, capabilities: JSON.stringify(["chat", "reasoning", "function_calling"]), inputPer1M: 0, outputPer1M: 0 },
|
|
384
|
+
{ id: "mistralai/mistral-large-4-1t-a52b", providerId: "nvidia", name: "Mistral Large 4 (NVIDIA)", modelType: "llm", contextWindow: 0, capabilities: JSON.stringify(["chat", "reasoning", "function_calling"]), inputPer1M: 0, outputPer1M: 0 },
|
|
385
|
+
{ id: "google/gemma-4-31b-it", providerId: "nvidia", name: "Gemma 4 31B IT (NVIDIA)", modelType: "llm", contextWindow: 0, capabilities: JSON.stringify(["chat", "function_calling"]), inputPer1M: 0, outputPer1M: 0 },
|
|
386
|
+
{ id: "poolside/laguna-xs-2.1", providerId: "nvidia", name: "Laguna XS 2.1 (NVIDIA)", modelType: "llm", contextWindow: 0, capabilities: JSON.stringify(["chat", "function_calling"]), inputPer1M: 0, outputPer1M: 0 },
|
|
387
|
+
{ id: "stepfun-ai/step-5-preview", providerId: "nvidia", name: "Step 5 Preview (NVIDIA)", modelType: "llm", contextWindow: 0, capabilities: JSON.stringify(["chat", "reasoning", "function_calling"]), inputPer1M: 0, outputPer1M: 0 },
|
|
370
388
|
|
|
371
389
|
// ── ModelScope Qwen (fuente: GET https://api-inference.modelscope.ai/v1/models) ──
|
|
372
390
|
// Endpoint gratuito dentro de cuota (2000 llamadas/día, ≤500 por modelo), por
|
|
@@ -435,6 +453,18 @@ export const SEED_DATA: SeedData = {
|
|
|
435
453
|
// Se carga por el primer shard: llama.cpp descubre los otros dos solo.
|
|
436
454
|
// Sólo texto, y el más lento del inventario: ~91 s de carga y 12.8 t/s.
|
|
437
455
|
{ 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 },
|
|
456
|
+
|
|
457
|
+
// ── Voz y tiempo real del catálogo revisado el 2026-11-13 (mismo catálogo que usa el gateway Rust) ──
|
|
458
|
+
// Solo entran los que este proyecto sabe ejecutar: TTS con gemini, qwen y elevenlabs, y tiempo real con gemini.
|
|
459
|
+
// Quedan fuera, por no tener adaptador aquí: STT de gemini/qwen/elevenlabs/openai (solo hay groq y Whisper),
|
|
460
|
+
// TTS de mistral y minimax, tiempo real de openai y qwen, y el OCR de mistral.
|
|
461
|
+
{ id: "gemini-3.8-live-extended-thinking", providerId: "gemini", name: "Gemini 3.8 Live Extended Thinking", modelType: "realtime", contextWindow: 131072, capabilities: JSON.stringify(["realtime", "audio_in", "audio_out", "transcription", "function_calling"]) },
|
|
462
|
+
{ id: "gemini-3.8-flash-tts", providerId: "gemini", name: "Gemini 3.8 Flash TTS", modelType: "tts", contextWindow: 0, capabilities: JSON.stringify(["tts", "speech"]) },
|
|
463
|
+
{ id: "gemini-3.8-flash-lite-tts", providerId: "gemini", name: "Gemini 3.8 Flash Lite TTS", modelType: "tts", contextWindow: 0, capabilities: JSON.stringify(["tts", "speech"]) },
|
|
464
|
+
{ id: "qwen-audio-3.1-tts-flash", providerId: "qwen", name: "Qwen Audio 3.1 TTS Flash", modelType: "tts", contextWindow: 0, capabilities: JSON.stringify(["tts", "speech"]) },
|
|
465
|
+
{ id: "eleven_v4", providerId: "elevenlabs", name: "Eleven V4", modelType: "tts", contextWindow: 0, capabilities: JSON.stringify(["tts", "speech"]) },
|
|
466
|
+
{ id: "eleven_v4_turbo", providerId: "elevenlabs", name: "Eleven V4 Turbo", modelType: "tts", contextWindow: 0, capabilities: JSON.stringify(["tts", "speech"]) },
|
|
467
|
+
{ id: "eleven_v3_conversational", providerId: "elevenlabs", name: "Eleven V3 Conversational", modelType: "tts", contextWindow: 0, capabilities: JSON.stringify(["tts", "speech"]) },
|
|
438
468
|
],
|
|
439
469
|
|
|
440
470
|
|
|
@@ -57,6 +57,55 @@ export function findComponentCycle(components: unknown[]): string[] | null {
|
|
|
57
57
|
return null
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
/**
|
|
61
|
+
* What each component type must carry to render anything. Each entry is a list of alternatives:
|
|
62
|
+
* at least one key of every list has to be present. Unknown types are not checked (the client
|
|
63
|
+
* draws a placeholder for them).
|
|
64
|
+
*/
|
|
65
|
+
const REQUIRED_PROPS: Record<string, string[][]> = {
|
|
66
|
+
Column: [["children"]],
|
|
67
|
+
Row: [["children"]],
|
|
68
|
+
List: [["children", "child"]],
|
|
69
|
+
Card: [["child"]],
|
|
70
|
+
Text: [["text"]],
|
|
71
|
+
Button: [["child", "text"]],
|
|
72
|
+
TextField: [["label", "value"]],
|
|
73
|
+
CheckBox: [["label"]],
|
|
74
|
+
ChoicePicker: [["options"]],
|
|
75
|
+
Slider: [["value", "label"]],
|
|
76
|
+
DateTimeInput: [["value", "label"]],
|
|
77
|
+
Tabs: [["tabs", "tabItems"]],
|
|
78
|
+
Modal: [["trigger", "entryPointChild"], ["content", "contentChild"]],
|
|
79
|
+
Image: [["url"]],
|
|
80
|
+
Video: [["url"]],
|
|
81
|
+
AudioPlayer: [["url"]],
|
|
82
|
+
Icon: [["name"]],
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Components that would render empty ("root (Column) necesita children"). A skeleton with only
|
|
87
|
+
* `id` and `component` publishes a blank surface and the agent then believes it is done, so a batch
|
|
88
|
+
* must arrive complete. Both the flat and the nested (`{ Card: {...} }`) forms are understood.
|
|
89
|
+
*/
|
|
90
|
+
export function findIncompleteComponents(components: unknown[]): string[] {
|
|
91
|
+
const problems: string[] = []
|
|
92
|
+
for (const raw of components) {
|
|
93
|
+
if (!raw || typeof raw !== "object") continue
|
|
94
|
+
const def = raw as Record<string, unknown>
|
|
95
|
+
const nested = def.component && typeof def.component === "object" && !Array.isArray(def.component)
|
|
96
|
+
? Object.entries(def.component as Record<string, unknown>)[0]
|
|
97
|
+
: undefined
|
|
98
|
+
const type = nested ? nested[0] : typeof def.component === "string" ? def.component.trim() : ""
|
|
99
|
+
const props = nested && nested[1] && typeof nested[1] === "object" ? { ...def, ...(nested[1] as Record<string, unknown>) } : def
|
|
100
|
+
for (const alternatives of REQUIRED_PROPS[type] ?? []) {
|
|
101
|
+
if (!alternatives.some((key) => props[key] !== undefined && props[key] !== null)) {
|
|
102
|
+
problems.push(`${String(def.id)} (${type}) necesita ${alternatives.join(" o ")}`)
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return problems
|
|
107
|
+
}
|
|
108
|
+
|
|
60
109
|
export function createA2UISurfaceTool(_config: Config): Tool {
|
|
61
110
|
const log = logger.child("a2ui-surface");
|
|
62
111
|
|
|
@@ -115,6 +164,21 @@ export function createA2UISurfaceTool(_config: Config): Tool {
|
|
|
115
164
|
log.warn(`No visual sessions connected. Rendering to ${sessionId} anyway. Available: ${connected.join(", ")}`);
|
|
116
165
|
}
|
|
117
166
|
|
|
167
|
+
// Creating a surface that already has components resets it to empty (client and replay cache
|
|
168
|
+
// alike). An agent that repeated the call after building the form left the user an empty panel.
|
|
169
|
+
// There is deliberately no "replace" flag: offering one, the model used it right away. Starting
|
|
170
|
+
// over is a2ui_delete_surface and then create, two explicit steps.
|
|
171
|
+
const built = canvasManager.getCachedComponents(sessionId, params.surfaceId as string)
|
|
172
|
+
if (built.length > 0) {
|
|
173
|
+
return JSON.stringify({
|
|
174
|
+
status: "exists",
|
|
175
|
+
surfaceId: params.surfaceId,
|
|
176
|
+
sessionId,
|
|
177
|
+
componentCount: built.length,
|
|
178
|
+
hint: `La superficie '${params.surfaceId}' ya existe con ${built.length} componentes y NO se volvió a crear: hacerlo la vaciaría. Para cambiarla usa a2ui_update_components con los mismos ids (reemplaza por id) o a2ui_update_data_model. Si de verdad necesitas empezar de cero: a2ui_delete_surface y luego crearla, y reenvía TODOS los componentes.`,
|
|
179
|
+
})
|
|
180
|
+
}
|
|
181
|
+
|
|
118
182
|
await canvasManager.sendA2UIMessage(sessionId, "a2ui:createSurface", {
|
|
119
183
|
surfaceId: params.surfaceId as string,
|
|
120
184
|
catalogId: params.catalogId as string,
|
|
@@ -127,6 +191,7 @@ export function createA2UISurfaceTool(_config: Config): Tool {
|
|
|
127
191
|
status: "created",
|
|
128
192
|
surfaceId: params.surfaceId,
|
|
129
193
|
sessionId,
|
|
194
|
+
next: "La superficie está VACÍA: envía ahora TODOS los componentes completos con a2ui_update_components (y luego el data model). No des la tarea por terminada antes.",
|
|
130
195
|
});
|
|
131
196
|
},
|
|
132
197
|
};
|
|
@@ -139,6 +204,8 @@ export function createA2UIUpdateComponentsTool(_config: Config): Tool {
|
|
|
139
204
|
name: "a2ui_update_components",
|
|
140
205
|
description: `Send A2UI v0.9 components to an existing surface. Components are a FLAT list with ID references (adjacency list).
|
|
141
206
|
|
|
207
|
+
ENVÍA TODO COMPLETO EN UNA SOLA LLAMADA: cada componente con sus propiedades (children, text, label, options, action…) según su tipo. Un componente con solo id y component se rechaza y no se publica nada; no mandes un esqueleto para rellenarlo después.
|
|
208
|
+
|
|
142
209
|
CHILDREN (spec oficial A2UI v0.9):
|
|
143
210
|
Static: "children": ["id1", "id2"] ← array crudo, formato oficial
|
|
144
211
|
Template: "children": {"path": "/items", "componentId": "item_tmpl"} ← formato oficial
|
|
@@ -190,6 +257,11 @@ Root component: usar id="root" explícito.`,
|
|
|
190
257
|
component: { type: "string", description: "Component type: Text, Button, Row, Column, Card, List, Divider, Image, Icon, Video, AudioPlayer, TextField, CheckBox, ChoicePicker, Slider, DateTimeInput, Tabs, Modal" },
|
|
191
258
|
weight: { type: "number", description: "Flex weight for proportional sizing inside Row/Column" },
|
|
192
259
|
},
|
|
260
|
+
required: ["id", "component"],
|
|
261
|
+
// Each type has its own props (children, text, label, options, action…), listed in the tool
|
|
262
|
+
// description. Without this, a model whose output is constrained to the schema can only emit
|
|
263
|
+
// the three keys above and every component arrives empty.
|
|
264
|
+
additionalProperties: true,
|
|
193
265
|
},
|
|
194
266
|
},
|
|
195
267
|
},
|
|
@@ -203,6 +275,10 @@ Root component: usar id="root" explícito.`,
|
|
|
203
275
|
: (userId ? `canvas:${userId}` : (() => { throw new Error("No session or user ID provided"); })());
|
|
204
276
|
|
|
205
277
|
if (!Array.isArray(params.components)) throw new Error("components must be an array")
|
|
278
|
+
const incomplete = findIncompleteComponents(params.components)
|
|
279
|
+
if (incomplete.length > 0) {
|
|
280
|
+
throw new Error(`Componentes incompletos: ${incomplete.join("; ")}. Envía TODOS los componentes COMPLETOS en una sola llamada a a2ui_update_components (con children, text, label, options, action… según el tipo), no un esqueleto con solo id y component. No se publicó nada.`)
|
|
281
|
+
}
|
|
206
282
|
// Checked on the merged tree the client will render, not only this batch.
|
|
207
283
|
const cycle = findComponentCycle(mergeComponentsById(
|
|
208
284
|
canvasManager.getCachedComponents(sessionId, params.surfaceId as string),
|
|
@@ -13,6 +13,7 @@ import { col, toIndexable } from "../../storage/hive";
|
|
|
13
13
|
import type { UserDoc, UserIdentityDoc, ChannelDoc, CronJobDoc, TaskRunDoc } from "../../storage/collections";
|
|
14
14
|
import { logger } from "../../utils/logger";
|
|
15
15
|
import { Cron } from "../../scheduler/cron";
|
|
16
|
+
import { formatUserDateTime } from "../../utils/date";
|
|
16
17
|
|
|
17
18
|
const log = logger.child("CronTools");
|
|
18
19
|
|
|
@@ -32,6 +33,25 @@ async function getUserTimezone(): Promise<string> {
|
|
|
32
33
|
return userEntry?.doc.timezone || "UTC";
|
|
33
34
|
}
|
|
34
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Todos los canales activos (conectados) del usuario, sin priorizar ninguno.
|
|
38
|
+
* Si no hay ninguno conectado cae a los que tengan identidad, y en último caso a webchat.
|
|
39
|
+
*/
|
|
40
|
+
export async function resolveActiveChannels(userId: string): Promise<string[]> {
|
|
41
|
+
const identitiesCol = await col<UserIdentityDoc>("userIdentities");
|
|
42
|
+
const identityEntries = await identitiesCol.scan({ prefix: `${userId}:` });
|
|
43
|
+
const all = [...new Set(identityEntries.map(e => e.doc.channel))];
|
|
44
|
+
|
|
45
|
+
const channelsCol = await col<ChannelDoc>("channels");
|
|
46
|
+
const active: string[] = [];
|
|
47
|
+
for (const channel of all) {
|
|
48
|
+
const entry = await channelsCol.get(channel);
|
|
49
|
+
if (entry?.doc.active && entry.doc.status === "connected") active.push(channel);
|
|
50
|
+
}
|
|
51
|
+
const result = active.length > 0 ? active : all;
|
|
52
|
+
return result.length > 0 ? result : ["webchat"];
|
|
53
|
+
}
|
|
54
|
+
|
|
35
55
|
export async function resolveBestChannel(userId: string, explicitChannel?: string): Promise<string> {
|
|
36
56
|
const usersCol = await col<UserDoc>("users");
|
|
37
57
|
const userEntry = await usersCol.get(userId);
|
|
@@ -201,7 +221,7 @@ export const cronCreateTool: Tool = {
|
|
|
201
221
|
ok: true,
|
|
202
222
|
task_id: result.id,
|
|
203
223
|
next_run: result.nextRun,
|
|
204
|
-
message: `Job "${name}" scheduled. Next run: ${result.nextRun
|
|
224
|
+
message: `Job "${name}" scheduled. Next run: ${formatUserDateTime(result.nextRun, timezone) ?? "unknown"} (${timezone})`,
|
|
205
225
|
};
|
|
206
226
|
} else {
|
|
207
227
|
const cronJobsCol = await col<CronJobDoc>("cronJobs");
|
|
@@ -272,6 +292,7 @@ export const cronListTool: Tool = {
|
|
|
272
292
|
if (task_type) tasks = tasks.filter(t => t.task_type === task_type);
|
|
273
293
|
|
|
274
294
|
tasks.sort((a, b) => (a.next_run_at ?? "").localeCompare(b.next_run_at ?? ""));
|
|
295
|
+
const tz = await getUserTimezone();
|
|
275
296
|
|
|
276
297
|
return {
|
|
277
298
|
ok: true,
|
|
@@ -285,8 +306,9 @@ export const cronListTool: Tool = {
|
|
|
285
306
|
fire_at: t.fire_at,
|
|
286
307
|
start_at: t.start_at,
|
|
287
308
|
stop_at: t.stop_at,
|
|
288
|
-
next_run: t.next_run_at,
|
|
289
|
-
last_run: t.last_run_at,
|
|
309
|
+
next_run: formatUserDateTime(t.next_run_at, tz),
|
|
310
|
+
last_run: formatUserDateTime(t.last_run_at, tz),
|
|
311
|
+
timezone: tz,
|
|
290
312
|
run_count: t.run_count,
|
|
291
313
|
channel: t.channel,
|
|
292
314
|
})),
|