@johpaz/hive-agents 0.0.45 → 0.0.47

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@johpaz/hive-agents",
3
- "version": "0.0.45",
3
+ "version": "0.0.47",
4
4
  "description": "Tu colmena de agentes IA. Local-first. Multi-canal. Open source. Construido desde Colombia para el mundo.",
5
5
  "private": false,
6
6
  "bin": {
@@ -512,27 +512,29 @@ export async function seedAllData(): Promise<void> {
512
512
  }
513
513
  log.info(`[seed] ✅ ${providerCount} providers procesados`);
514
514
 
515
- // 5️⃣ Models (re-seed: overwrite in place, remove entries no longer in the catalog)
515
+ // 5️⃣ Models (re-seed: overwrite catalog fields in place, preserve the user's own
516
+ // enabled/active activation state, remove entries no longer in the catalog)
516
517
  log.info("[seed] 🔄 Re-seeding models...");
517
518
  const modelsCol = await col<ModelDoc>("models");
518
- const existingModelIds = new Set((await modelsCol.scan({})).map((e) => e.id));
519
+ const existingModels = new Map((await modelsCol.scan({})).map((e) => [e.id, e]));
519
520
 
520
521
  let modelCount = 0;
521
522
  for (const model of SEED_DATA.models) {
523
+ const existing = existingModels.get(model.id);
522
524
  await modelsCol.put(model.id, {
523
525
  id: model.id, provider_id: model.providerId, name: model.name,
524
526
  model_type: model.modelType as ModelDoc["model_type"],
525
527
  context_window: model.contextWindow || 0, capabilities: model.capabilities || null,
526
- enabled: true, active: false,
528
+ enabled: existing?.doc.enabled ?? true, active: existing?.doc.active ?? false,
527
529
  });
528
- existingModelIds.delete(model.id);
530
+ existingModels.delete(model.id);
529
531
  modelCount++;
530
532
  }
531
- // Whatever remains in existingModelIds was dropped from the catalog (e.g. a
533
+ // Whatever remains in existingModels was dropped from the catalog (e.g. a
532
534
  // consolidated HiveAgents GGUF variant) — remove it.
533
- for (const staleId of existingModelIds) await modelsCol.delete(staleId);
534
- if (existingModelIds.size > 0) {
535
- log.info(`[seed] 🗑️ Removed ${existingModelIds.size} model(s) no longer in the catalog.`);
535
+ for (const [staleId] of existingModels) await modelsCol.delete(staleId);
536
+ if (existingModels.size > 0) {
537
+ log.info(`[seed] 🗑️ Removed ${existingModels.size} model(s) no longer in the catalog.`);
536
538
  }
537
539
 
538
540
  // An agent pointing at a model that just got removed would otherwise keep
@@ -13,7 +13,7 @@ import type { ProviderDoc, ModelDoc } from "../../storage/collections.ts";
13
13
 
14
14
  export const getAvailableModelsTool: Tool = {
15
15
  name: "get_available_models",
16
- description: "Obtener lista de providers y modelos activos de la base de datos. Sinónimos: ver modelos, listar providers, modelos disponibles, consultar modelos, provider activo, qué modelos tengo, modelos para código, modelos para chat",
16
+ description: "Obtener el catálogo completo de modelos de los providers configurados (con credenciales activas) para elegir el más adecuado según capacidad, contexto o costo — no solo el modelo por defecto del usuario. Sinónimos: ver modelos, listar providers, modelos disponibles, consultar modelos, provider activo, qué modelos tengo, modelos para código, modelos para chat",
17
17
  parameters: {
18
18
  type: "object",
19
19
  properties: {
@@ -47,10 +47,17 @@ export const getAvailableModelsTool: Tool = {
47
47
  .map(p => [p.id, p])
48
48
  );
49
49
 
50
+ // Gate on the *provider* being configured (enabled + active, i.e. it has valid
51
+ // credentials) — not on the individual model's own `active` flag. `active` on a
52
+ // ModelDoc only marks the single model onboarding/voice-setup picked as the
53
+ // user's current default; it is not "this model is unusable". Once a provider is
54
+ // configured, every model under it should be visible so the caller can pick the
55
+ // one that actually fits the task (capability, context window, cost), instead of
56
+ // being stuck with whichever model happened to be flagged as the default.
50
57
  const modelsCol = await col<ModelDoc>("models");
51
58
  let models = (await modelsCol.scan({}))
52
59
  .map(e => e.doc)
53
- .filter(m => m.enabled && m.active && providersById.has(m.provider_id));
60
+ .filter(m => m.enabled && providersById.has(m.provider_id));
54
61
 
55
62
  if (providerId) models = models.filter(m => m.provider_id === providerId);
56
63
  if (modelType) models = models.filter(m => m.model_type === modelType);
@@ -69,9 +76,10 @@ export const getAvailableModelsTool: Tool = {
69
76
  modelType: m.model_type,
70
77
  contextWindow: m.context_window,
71
78
  capabilities: m.capabilities ? JSON.parse(m.capabilities) : null,
79
+ isDefault: m.active,
72
80
  };
73
81
  })
74
- .sort((a, b) => a.providerName.localeCompare(b.providerName) || a.modelName.localeCompare(b.modelName));
82
+ .sort((a, b) => (Number(b.isDefault) - Number(a.isDefault)) || a.providerName.localeCompare(b.providerName) || a.modelName.localeCompare(b.modelName));
75
83
 
76
84
  return {
77
85
  ok: true,
@@ -238,7 +238,9 @@ export const agentCreateTool: Tool = {
238
238
  };
239
239
  }
240
240
 
241
- // Validar que el modelo existe y está activo
241
+ // Validar que el modelo existe y pertenece al provider ya validado. `active` en un
242
+ // ModelDoc solo marca el modelo por defecto del usuario (elegido en onboarding), no
243
+ // si el modelo es utilizable — cualquier modelo del provider configurado sirve.
242
244
  const modelsCol = await col<ModelDoc>("models");
243
245
  const modelEntry = await modelsCol.get(modelId);
244
246
 
@@ -249,10 +251,17 @@ export const agentCreateTool: Tool = {
249
251
  };
250
252
  }
251
253
 
252
- if (!modelEntry.doc.enabled || !modelEntry.doc.active) {
254
+ if (!modelEntry.doc.enabled) {
253
255
  return {
254
256
  ok: false,
255
- error: `Modelo '${modelId}' no está activo. Usá get_available_models para ver modelos activos.`
257
+ error: `Modelo '${modelId}' no está habilitado. Usá get_available_models para ver modelos disponibles.`
258
+ };
259
+ }
260
+
261
+ if (modelEntry.doc.provider_id !== providerId) {
262
+ return {
263
+ ok: false,
264
+ error: `Modelo '${modelId}' pertenece al provider '${modelEntry.doc.provider_id}', no a '${providerId}'.`
256
265
  };
257
266
  }
258
267