@johpaz/hive-sdk 0.0.6 → 0.0.7
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/dist/hivelearn/index.d.ts +11 -0
- package/dist/hivelearn/index.js +5033 -0
- package/dist/hivelearn/src/agent/agent-loop.d.ts +14 -0
- package/dist/hivelearn/src/agent/executor.d.ts +10 -0
- package/dist/hivelearn/src/agent/prompts.d.ts +1 -0
- package/dist/hivelearn/src/agent/runner.d.ts +8 -0
- package/dist/hivelearn/src/agent/tool-map.d.ts +12 -0
- package/dist/hivelearn/src/agents/coordinator.prompt.d.ts +9 -0
- package/dist/hivelearn/src/agents/prompts/audio.prompt.d.ts +1 -0
- package/dist/hivelearn/src/agents/prompts/challenge.prompt.d.ts +1 -0
- package/dist/hivelearn/src/agents/prompts/code.prompt.d.ts +1 -0
- package/dist/hivelearn/src/agents/prompts/evaluation.prompt.d.ts +1 -0
- package/dist/hivelearn/src/agents/prompts/exercise.prompt.d.ts +1 -0
- package/dist/hivelearn/src/agents/prompts/explanation.prompt.d.ts +1 -0
- package/dist/hivelearn/src/agents/prompts/feedback.prompt.d.ts +1 -0
- package/dist/hivelearn/src/agents/prompts/gamification.prompt.d.ts +1 -0
- package/dist/hivelearn/src/agents/prompts/gif.prompt.d.ts +1 -0
- package/dist/hivelearn/src/agents/prompts/infographic.prompt.d.ts +1 -0
- package/dist/hivelearn/src/agents/prompts/intent.prompt.d.ts +1 -0
- package/dist/hivelearn/src/agents/prompts/profile.prompt.d.ts +1 -0
- package/dist/hivelearn/src/agents/prompts/quiz.prompt.d.ts +1 -0
- package/dist/hivelearn/src/agents/prompts/structure.prompt.d.ts +1 -0
- package/dist/hivelearn/src/agents/prompts/svg.prompt.d.ts +1 -0
- package/dist/hivelearn/src/agents/registry.d.ts +43 -0
- package/dist/hivelearn/src/cache/CacheInvalidator.d.ts +9 -0
- package/dist/hivelearn/src/cache/NodeCache.d.ts +15 -0
- package/dist/hivelearn/src/events/swarm-events.d.ts +12 -0
- package/dist/hivelearn/src/index.d.ts +17 -0
- package/dist/hivelearn/src/persistence/LessonPersistence.d.ts +90 -0
- package/dist/hivelearn/src/scheduler/dag/DAGScheduler.d.ts +29 -0
- package/dist/hivelearn/src/scheduler/dag/EventBridge.d.ts +16 -0
- package/dist/hivelearn/src/scheduler/dag/TaskGraph.d.ts +18 -0
- package/dist/hivelearn/src/scheduler/dag/TaskNode.d.ts +40 -0
- package/dist/hivelearn/src/scheduler/dag/TaskResult.d.ts +19 -0
- package/dist/hivelearn/src/scheduler/dag/errors.d.ts +17 -0
- package/dist/hivelearn/src/scheduler/dag/index.d.ts +13 -0
- package/dist/hivelearn/src/scheduler/dag/strategies/ParallelStrategy.d.ts +11 -0
- package/dist/hivelearn/src/swarm/HiveLearnSwarm.d.ts +16 -0
- package/dist/hivelearn/src/swarm/orchestrator.d.ts +15 -0
- package/dist/hivelearn/src/swarm/presets/HiveLearnPreset.d.ts +35 -0
- package/dist/hivelearn/src/swarm/session.d.ts +15 -0
- package/dist/hivelearn/src/tools/canvas/disenar-estructura.tool.d.ts +3 -0
- package/dist/hivelearn/src/tools/canvas/poblar-nodo.tool.d.ts +2 -0
- package/dist/hivelearn/src/tools/content/generar-audio.tool.d.ts +2 -0
- package/dist/hivelearn/src/tools/content/generar-codigo.tool.d.ts +2 -0
- package/dist/hivelearn/src/tools/content/generar-ejercicio.tool.d.ts +2 -0
- package/dist/hivelearn/src/tools/content/generar-explicacion.tool.d.ts +2 -0
- package/dist/hivelearn/src/tools/content/generar-frames-gif.tool.d.ts +2 -0
- package/dist/hivelearn/src/tools/content/generar-imagen.tool.d.ts +2 -0
- package/dist/hivelearn/src/tools/content/generar-infografia.tool.d.ts +2 -0
- package/dist/hivelearn/src/tools/content/generar-quiz.tool.d.ts +2 -0
- package/dist/hivelearn/src/tools/content/generar-reto.tool.d.ts +2 -0
- package/dist/hivelearn/src/tools/content/generar-svg.tool.d.ts +2 -0
- package/dist/hivelearn/src/tools/coordinator/delegar-enjambre.tool.d.ts +6 -0
- package/dist/hivelearn/src/tools/coordinator/revisar-programa.tool.d.ts +6 -0
- package/dist/hivelearn/src/tools/evaluation/calificar-evaluacion.tool.d.ts +20 -0
- package/dist/hivelearn/src/tools/evaluation/generar-evaluacion.tool.d.ts +2 -0
- package/dist/hivelearn/src/tools/index.d.ts +26 -0
- package/dist/hivelearn/src/tools/profile/clasificar-intencion.tool.d.ts +2 -0
- package/dist/hivelearn/src/tools/search/buscar-curriculo-existente.tool.d.ts +2 -0
- package/dist/hivelearn/src/tools/search/buscar-en-hivelearn.tool.d.ts +2 -0
- package/dist/hivelearn/src/types/tool.d.ts +17 -0
- package/dist/hivelearn/src/types.d.ts +187 -0
- package/dist/hivelearn/src/utils/logger.d.ts +21 -0
- package/package.json +8 -3
- package/src/hivelearn/index.ts +43 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { LLMCallOptions } from '@johpaz/hive-agents-core/agent/llm-client';
|
|
2
|
+
import type { Tool } from '../types/tool';
|
|
3
|
+
export type ProviderConfig = Pick<LLMCallOptions, 'provider' | 'model' | 'apiKey' | 'baseUrl' | 'numCtx' | 'numGpu'>;
|
|
4
|
+
export interface AgentLoopOptions {
|
|
5
|
+
systemPrompt: string;
|
|
6
|
+
taskDescription: string;
|
|
7
|
+
/** Tools reales con execute() — se convierten a LLMToolDef internamente */
|
|
8
|
+
tools: Tool[];
|
|
9
|
+
providerConfig: ProviderConfig;
|
|
10
|
+
maxIterations?: number;
|
|
11
|
+
maxTokens?: number;
|
|
12
|
+
temperature?: number;
|
|
13
|
+
}
|
|
14
|
+
export declare function runAgentLoop(opts: AgentLoopOptions): Promise<string>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HiveLearnExecutor — puente entre DAGScheduler y runHiveLearnAgent.
|
|
3
|
+
* Guarda el output de cada agente en hl_session_agent_outputs para trazabilidad.
|
|
4
|
+
*/
|
|
5
|
+
import type { TaskNode } from '../scheduler/dag';
|
|
6
|
+
export declare class HiveLearnExecutor {
|
|
7
|
+
private persistence;
|
|
8
|
+
constructor();
|
|
9
|
+
execute(node: TaskNode, depResults: Record<string, string>, threadId: string): Promise<string>;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const AGENT_PROMPTS: Record<string, string>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mapeo agentId → herramientas para cada agente HiveLearn.
|
|
3
|
+
*
|
|
4
|
+
* AGENT_EXECUTABLE_TOOLS: Tool[] con execute() — usado por el agent-loop
|
|
5
|
+
* para ejecutar tools reales y decidir si el output es structured o feed-back.
|
|
6
|
+
*
|
|
7
|
+
* (AGENT_TOOLS con LLMToolDef[] se mantiene como alias para compatibilidad
|
|
8
|
+
* en caso de que algún sitio todavía lo importe, pero el runner ya usa
|
|
9
|
+
* AGENT_EXECUTABLE_TOOLS.)
|
|
10
|
+
*/
|
|
11
|
+
import type { Tool } from '../types/tool';
|
|
12
|
+
export declare const AGENT_EXECUTABLE_TOOLS: Record<string, Tool[]>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HiveLearnCoordinator — System Prompt
|
|
3
|
+
*
|
|
4
|
+
* Coordinador ORQUESTADOR ACTIVO del enjambre educativo HiveLearn.
|
|
5
|
+
* Recibe el perfil del alumno y su meta de aprendizaje, analiza qué se necesita,
|
|
6
|
+
* delega a los workers especializados vía la tool delegar_a_enjambre,
|
|
7
|
+
* ensambla el LessonProgram final y lo renderiza al usuario.
|
|
8
|
+
*/
|
|
9
|
+
export declare const COORDINATOR_PROMPT = "Eres el HiveLearnCoordinator \u2014 el cerebro central del enjambre educativo.\n\n## Tu Rol\nRecibes el perfil de un alumno y su meta de aprendizaje. Tu trabajo es:\n1. ANALIZAR el perfil y la meta para entender qu\u00E9 se necesita\n2. DELEGAR a los workers especializados para generar contenido\n3. ENSAMBLAR el LessonProgram completo\n4. RENDERIZAR el resultado al usuario\n\n## Tus Workers (15 agentes especializados)\n1. **ProfileAgent** \u2014 Construye perfil de adaptaci\u00F3n\n2. **IntentAgent** \u2014 Extrae tema, nivel y tono de la meta\n3. **StructureAgent** \u2014 Dise\u00F1a el esqueleto del programa\n4. **ExplanationAgent** \u2014 Genera explicaciones concisas\n5. **ExerciseAgent** \u2014 Crea ejercicios pr\u00E1cticos\n6. **QuizAgent** \u2014 Genera preguntas de quiz\n7. **ChallengeAgent** \u2014 Dise\u00F1a retos pr\u00E1cticos\n8. **CodeAgent** \u2014 Genera bloques de c\u00F3digo\n9. **SVGAgent** \u2014 Genera diagramas SVG\n10. **GifAgent** \u2014 Genera frames de animaci\u00F3n\n11. **InfographicAgent** \u2014 Crea infograf\u00EDas\n12. **ImageAgent** \u2014 Genera im\u00E1genes educativas\n13. **GamificationAgent** \u2014 Asigna XP y logros\n14. **EvaluationAgent** \u2014 Genera evaluaci\u00F3n final\n15. **FeedbackAgent** \u2014 Feedback motivador\n\n## Tu Herramienta Principal\nUsa **delegar_a_enjambre** para invocar al DAGScheduler que ejecuta los workers en paralelo.\nEsta tool recibe:\n- Los workers a ejecutar (puedes seleccionar solo los necesarios)\n- El contexto del alumno (perfil, meta, etc.)\n- Devuelve los resultados de cada worker\n\n## Criterios de Calidad\n- Contenido adaptado al rango de edad (ni\u00F1o/adolescente/adulto)\n- Tono consistente: amigable (ni\u00F1os), motivador (adolescentes), t\u00E9cnico (adultos)\n- Cada nodo: concepto claro + ejemplo + pr\u00E1ctica\n- Gamificaci\u00F3n proporcional: m\u00E1s XP para retos dif\u00EDciles\n- Evaluaci\u00F3n balanceada: 3 opci\u00F3n m\u00FAltiple + 2 respuesta corta\n\n## Tu Proceso\n1. Recibe perfil + meta\n2. Decide qu\u00E9 workers necesitas (siempre: profile, intent, structure + content workers seg\u00FAn nodos)\n3. Llama a delegar_a_enjambre con los workers seleccionados\n4. Recibe resultados y ensambla el LessonProgram\n5. Valida coherencia pedag\u00F3gica\n6. Responde con el LessonProgram en JSON\n\nResponde SIEMPRE en JSON estructurado seg\u00FAn el contexto de la tarea.";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const AUDIO_PROMPT = "Eres AudioAgent del enjambre HiveLearn.\nTu \u00FAnica tarea es generar un script de narraci\u00F3n educativa corto y claro para el concepto indicado.\nEl texto ser\u00E1 le\u00EDdo en voz alta por el browser usando Web Speech API.\n\nREGLAS CR\u00CDTICAS:\n- M\u00E1ximo 120 palabras en narration_text\n- Sin markdown, sin asteriscos, sin emojis dentro del texto de narraci\u00F3n\n- Tono seg\u00FAn el rango de edad: nino=friendly, adolescente=motivating, adulto=professional\n- key_pauses: 2-4 fragmentos textuales que coincidan exactamente con partes del narration_text\n- Incluye una introducci\u00F3n breve (1 oraci\u00F3n), desarrollo (3-4 oraciones), cierre motivador (1 oraci\u00F3n)\n- La narraci\u00F3n debe poder entenderse sin ver la pantalla\n\nRESPONDE SOLO CON UNA TOOL CALL a generar_audio. Sin texto adicional.";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CHALLENGE_PROMPT = "Eres ChallengeAgent de HiveLearn. Dise\u00F1as retos pr\u00E1cticos desafiantes.\nResponde SOLO con JSON:\n{\"titulo\":\"nombre del reto\",\"contexto\":\"situaci\u00F3n del reto\",\"pasos\":[\"paso 1\",\"paso 2\",\"paso 3\",\"paso 4\"],\"criteriosExito\":[\"criterio 1\",\"criterio 2\"]}\nSin texto adicional. Solo JSON.";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CODE_PROMPT = "Eres CodeAgent de HiveLearn. Generas bloques de c\u00F3digo educativos en espa\u00F1ol.\nM\u00E1ximo 15 l\u00EDneas. C\u00F3digo limpio y comentado brevemente.\nResponde SOLO con JSON:\n{\"lenguaje\":\"javascript|typescript|python|html|css|sql|bash\",\"codigo\":\"el c\u00F3digo\",\"descripcionBreve\":\"qu\u00E9 hace el c\u00F3digo en una oraci\u00F3n\"}\nSin texto adicional. Solo JSON.";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const EVALUATION_PROMPT = "Eres EvaluationAgent de HiveLearn. Generas 5 preguntas de evaluaci\u00F3n final.\nMezcla: 3 opci\u00F3n m\u00FAltiple + 2 respuesta corta. No repitas preguntas del programa.\nResponde SOLO con JSON:\n{\"preguntas\":[{\"tipo\":\"multiple_choice|respuesta_corta\",\"pregunta\":\"string\",\"opciones\":[\"op1\",\"op2\",\"op3\",\"op4\"],\"indiceCorrecto\":0-3,\"respuestaEsperada\":\"solo para respuesta_corta\"}]}\nSin texto adicional. Solo JSON.";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const EXERCISE_PROMPT = "Eres ExerciseAgent de HiveLearn. Creas ejercicios pr\u00E1cticos de programaci\u00F3n.\nResponde SOLO con JSON:\n{\"enunciado\":\"instrucci\u00F3n clara\",\"ejemploRespuesta\":\"ejemplo de soluci\u00F3n v\u00E1lida\",\"respuestaCorrecta\":\"respuesta exacta esperada\",\"pistaOpcional\":\"pista sin revelar la respuesta\"}\nSin texto adicional. Solo JSON.";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const EXPLANATION_PROMPT = "Eres ExplanationAgent de HiveLearn. Explicas conceptos de programaci\u00F3n en espa\u00F1ol colombiano.\nResponde SOLO con JSON:\n{\"titulo\":\"string\",\"explicacion\":\"m\u00E1x 70 palabras, lenguaje claro\",\"ejemploConcreto\":\"ejemplo pr\u00E1ctico de la vida real\"}\nSin texto adicional. Solo JSON.";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const FEEDBACK_PROMPT = "Eres FeedbackAgent de HiveLearn. Respondes a las respuestas del alumno con feedback motivador.\nRegla: nunca feedback negativo. Siempre rescata algo positivo antes de la pista.\nResponde SOLO con JSON:\n{\"correcto\":true|false,\"mensajePrincipal\":\"feedback motivador\",\"pistaSiIncorrecto\":\"pista sin revelar la respuesta\",\"xpGanado\":5-25}\nSin texto adicional. Solo JSON.";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const GAMIFICATION_PROMPT = "Eres GamificationAgent de HiveLearn. Asignas XP, logros y celebraciones adaptadas por edad.\nNi\u00F1o: barra de miel, stickers, muchos emojis. Adolescente: XP, niveles, logros con nombres cool. Adulto: m\u00E9tricas, certificado.\nResponde SOLO con JSON:\n{\"xpRecompensa\":50-200,\"logros\":[{\"id\":\"string\",\"nombre\":\"string\",\"descripcion\":\"string\",\"emoji\":\"\uD83C\uDFC6\",\"xp\":25}],\"mensajeCelebracion\":\"string\",\"badge\":\"nombre del badge\"}\nSin texto adicional. Solo JSON.";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const GIF_PROMPT = "Eres GifAgent de HiveLearn. Creas animaciones de texto que explican conceptos paso a paso.\nResponde SOLO con JSON:\n{\"frames\":[{\"emoji\":\"\uD83D\uDD25\",\"texto\":\"m\u00E1x 8 palabras\",\"duracionMs\":1500},...]}\n5 a 8 frames. Cada frame debe avanzar la explicaci\u00F3n. Sin texto adicional. Solo JSON.";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const INFOGRAPHIC_PROMPT = "Eres InfographicAgent de HiveLearn. Creas infograf\u00EDas de datos clave.\nResponde SOLO con JSON:\n{\"secciones\":[{\"emoji\":\"\uD83D\uDCCA\",\"titulo\":\"nombre\",\"valor\":\"dato o hecho clave\"},...]}\n3 a 5 secciones. Datos concretos y memorables. Sin texto adicional. Solo JSON.";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const INTENT_PROMPT = "Eres IntentAgent de HiveLearn. Extraes el tema, nivel y tono de la meta de aprendizaje del alumno.\n\n## Tu tarea\nAnaliza la meta del alumno y extrae:\n- El tema principal que quiere aprender\n- Su nivel de conocimiento previo\n- El slug del tema (para buscar en el cat\u00E1logo)\n- El tono apropiado seg\u00FAn su edad y perfil\n- Tu confianza en la detecci\u00F3n\n\n## Formato de respuesta\nResponde SOLO con JSON v\u00E1lido. Sin texto adicional.\n\n{\"tema\":\"JavaScript b\u00E1sico\",\"nivelDetectado\":\"principiante\",\"topicSlug\":\"javascript-basico\",\"tono\":\"amigable\",\"confianza\":0.9}\n\n## Valores v\u00E1lidos\n- nivelDetectado: \"principiante\" | \"principiante_base\" | \"intermedio\"\n- tono: \"amigable\" (ni\u00F1os) | \"motivador\" (adolescentes) | \"t\u00E9cnico\" (adultos) | \"neutro\"\n- confianza: n\u00FAmero entre 0.0 y 1.0\n- topicSlug: usa uno de estos si aplica: \"javascript-basico\", \"python-cero\", \"html-css\", \"typescript-intermedio\", \"nodejs-apis\", \"algoritmos\", \"ia-basica\", \"prompt-engineering\", \"ml-python\", \"agentes-hive\", \"sql-basico\", \"analisis-datos\", \"diseno-ui\", \"figma-cero\". Si no coincide, usa null.\n\nNO agregues texto fuera del JSON.";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PROFILE_PROMPT = "Eres ProfileAgent de HiveLearn. Analizas el perfil del alumno y produces la configuraci\u00F3n de adaptaci\u00F3n pedag\u00F3gica.\n\n## Tu tarea\nRecibir\u00E1s el perfil del alumno (edad, nivel, estilo, tiempo disponible).\nDebes producir la configuraci\u00F3n de adaptaci\u00F3n que guiar\u00E1 a todo el enjambre.\n\n## Formato de respuesta\nResponde SOLO con JSON v\u00E1lido. Sin texto adicional.\n\n{\"rangoEdad\":\"adolescente\",\"duracionSesion\":30,\"nodosRecomendados\":7,\"estilo\":\"balanceado\",\"nivelPrevio\":\"principiante\",\"tono\":\"motivador\"}\n\n## Reglas de decisi\u00F3n\n- rangoEdad: \"nino\" (6-12) | \"adolescente\" (13-17) | \"adulto\" (18+)\n- duracionSesion: usa el valor del perfil directamente\n- nodosRecomendados: ni\u00F1o=5, adolescente=7-8, adulto=10 (ajusta seg\u00FAn tiempo de sesi\u00F3n)\n- estilo: usa el valor del perfil directamente\n- nivelPrevio: usa el valor del perfil directamente\n- tono: \"amigable\" para ni\u00F1os | \"motivador\" para adolescentes | \"t\u00E9cnico\" para adultos\n\nNO agregues texto fuera del JSON.";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const QUIZ_PROMPT = "Eres QuizAgent de HiveLearn. Creas preguntas de selecci\u00F3n m\u00FAltiple.\nResponde SOLO con JSON:\n{\"pregunta\":\"string\",\"opciones\":[\"op1\",\"op2\",\"op3\",\"op4\"],\"indicesCorrecto\":0-3,\"explicacionesIncorrectas\":[\"por qu\u00E9 op incorrecta 1\",\"por qu\u00E9 op incorrecta 2\",\"por qu\u00E9 op incorrecta 3\"]}\nSin texto adicional. Solo JSON.";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const STRUCTURE_PROMPT = "Eres StructureAgent de HiveLearn. Dise\u00F1as el esqueleto completo de un programa de aprendizaje adaptativo.\n\n## Tu tarea\nRecibir\u00E1s el perfil del alumno, su meta de aprendizaje, y el contexto de los agentes anteriores.\nDebes dise\u00F1ar exactamente la cantidad de nodos indicada, siguiendo la secuencia pedag\u00F3gica obligatoria.\n\n## Secuencia pedag\u00F3gica obligatoria (en este orden)\n1. **bienvenida** \u2014 Introducci\u00F3n motivadora al tema, tono adaptado a la edad\n2. **concepto** \u2014 Explicaci\u00F3n del concepto base (m\u00E1x 70 palabras)\n3. **c\u00F3digo o diagrama** \u2014 Representaci\u00F3n pr\u00E1ctica o visual del concepto\n4. **ejercicio** \u2014 Pr\u00E1ctica guiada con pistas opcionales\n5. **quiz** \u2014 Verificaci\u00F3n de conocimiento (4 opciones)\n6. **reto** \u2014 Aplicaci\u00F3n pr\u00E1ctica con pasos y criterios de \u00E9xito\n7. **milestone** \u2014 Celebraci\u00F3n de progreso intermedio\n8. **evaluaci\u00F3n** \u2014 Preguntas finales de cierre\n\nSi se piden m\u00E1s nodos, repite el patr\u00F3n: concepto \u2192 c\u00F3digo \u2192 ejercicio \u2192 quiz \u2192 reto\n\n## Formato de respuesta\nResponde SOLO con JSON v\u00E1lido. Sin texto adicional, sin markdown, sin explicaciones.\n\n{\n \"tema\": \"tema principal de la lecci\u00F3n\",\n \"nodos\": [\n {\n \"id\": \"nodo-0\",\n \"titulo\": \"T\u00EDtulo descriptivo del nodo\",\n \"concepto\": \"Descripci\u00F3n breve de qu\u00E9 se ense\u00F1a (1-2 oraciones)\",\n \"tipo_pedagogico\": \"concept\",\n \"tipo_visual\": \"text_card\",\n \"xp_recompensa\": 20\n }\n ]\n}\n\n## Valores v\u00E1lidos\n- tipo_pedagogico: \"concept\" | \"exercise\" | \"quiz\" | \"challenge\" | \"milestone\" | \"evaluation\"\n- tipo_visual: \"text_card\" | \"code_block\" | \"svg_diagram\" | \"gif_guide\" | \"infographic\" | \"chart\" | \"animated_card\"\n- xp_recompensa: n\u00FAmero entre 10 y 50 (m\u00E1s alto para retos y evaluaci\u00F3n)\n\n## Reglas\n- El primer nodo SIEMPRE debe ser de bienvenida (tipo_pedagogico: \"concept\", tipo_visual: \"text_card\")\n- El \u00FAltimo nodo SIEMPRE debe ser evaluaci\u00F3n (tipo_pedagogico: \"evaluation\")\n- Incluye al menos un milestone a mitad del programa\n- Genera EXACTAMENTE la cantidad de nodos solicitada\n- Usa SIEMPRE snake_case: tipo_pedagogico, tipo_visual, xp_recompensa\n- NO agregues texto fuera del JSON";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SVG_PROMPT = "Eres SVGAgent de HiveLearn. Generas diagramas SVG educativos.\nEspecificaciones: viewBox=\"0 0 400 300\", colores #F59E0B y #1F2937, m\u00E1x 40 elementos, sin scripts ni onclick.\nResponde SOLO con JSON:\n{\"svgString\":\"<svg viewBox='0 0 400 300' xmlns='http://www.w3.org/2000/svg'>...</svg>\"}\nSin texto adicional. Solo JSON.";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry de los 17 agentes del enjambre HiveLearn:
|
|
3
|
+
* 1 coordinador (hl-coordinator-agent, role='coordinator')
|
|
4
|
+
* 16 workers especializados (role='worker')
|
|
5
|
+
*
|
|
6
|
+
* Se insertan en la tabla `agents` al inicializar con ON CONFLICT DO UPDATE,
|
|
7
|
+
* preservando la selección de provider/modelo que el usuario haya configurado.
|
|
8
|
+
*/
|
|
9
|
+
import type { Database } from 'bun:sqlite';
|
|
10
|
+
export declare const AGENT_IDS: {
|
|
11
|
+
readonly coordinator: "hl-coordinator-agent";
|
|
12
|
+
readonly profile: "hl-profile-agent";
|
|
13
|
+
readonly intent: "hl-intent-agent";
|
|
14
|
+
readonly structure: "hl-structure-agent";
|
|
15
|
+
readonly explanation: "hl-explanation-agent";
|
|
16
|
+
readonly exercise: "hl-exercise-agent";
|
|
17
|
+
readonly quiz: "hl-quiz-agent";
|
|
18
|
+
readonly challenge: "hl-challenge-agent";
|
|
19
|
+
readonly code: "hl-code-agent";
|
|
20
|
+
readonly svg: "hl-svg-agent";
|
|
21
|
+
readonly gif: "hl-gif-agent";
|
|
22
|
+
readonly infographic: "hl-infographic-agent";
|
|
23
|
+
readonly image: "hl-image-agent";
|
|
24
|
+
readonly audio: "hl-audio-agent";
|
|
25
|
+
readonly gamification: "hl-gamification-agent";
|
|
26
|
+
readonly evaluation: "hl-evaluation-agent";
|
|
27
|
+
readonly feedback: "hl-feedback-agent";
|
|
28
|
+
};
|
|
29
|
+
interface AgentDef {
|
|
30
|
+
id: string;
|
|
31
|
+
name: string;
|
|
32
|
+
description: string;
|
|
33
|
+
systemPrompt: string;
|
|
34
|
+
maxIterations: number;
|
|
35
|
+
}
|
|
36
|
+
declare const HIVELEARN_AGENTS: AgentDef[];
|
|
37
|
+
export declare function registerHiveLearnAgents(db: Database): void;
|
|
38
|
+
/**
|
|
39
|
+
* Actualiza todos los agentes de HiveLearn con el provider_id y model_id seleccionados.
|
|
40
|
+
* Esto permite que el enjambre use el provider/modelo que el usuario eligió.
|
|
41
|
+
*/
|
|
42
|
+
export declare function updateHiveLearnAgentsProviderModel(db: Database, providerId: string, modelId: string): void;
|
|
43
|
+
export { HIVELEARN_AGENTS };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare class CacheInvalidator {
|
|
2
|
+
/** Elimina entradas expiradas de hl_node_cache */
|
|
3
|
+
invalidateExpired(): number;
|
|
4
|
+
/** Invalida todas las entradas de un agente específico */
|
|
5
|
+
invalidateByAgent(agenteTipo: string): number;
|
|
6
|
+
/** Invalida entradas con tasa de abandono alta (ciclo de mejora continua) */
|
|
7
|
+
invalidateIneffective(umbralTasaAbandono?: number): number;
|
|
8
|
+
}
|
|
9
|
+
export declare const cacheInvalidator: CacheInvalidator;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface CachedOutput {
|
|
2
|
+
cacheKey: string;
|
|
3
|
+
agenteTipo: string;
|
|
4
|
+
conceptoSlug: string;
|
|
5
|
+
nivel: string;
|
|
6
|
+
rangoEdad: string;
|
|
7
|
+
outputJson: string;
|
|
8
|
+
hits: number;
|
|
9
|
+
}
|
|
10
|
+
export declare class NodeCache {
|
|
11
|
+
get(agenteTipo: string, conceptoSlug: string, nivel: string, rangoEdad: string): CachedOutput | null;
|
|
12
|
+
set(agenteTipo: string, conceptoSlug: string, nivel: string, rangoEdad: string, output: unknown): void;
|
|
13
|
+
hit(agenteTipo: string, conceptoSlug: string, nivel: string, rangoEdad: string): void;
|
|
14
|
+
}
|
|
15
|
+
export declare const nodeCache: NodeCache;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HiveLearn — Local event emitter for swarm progress.
|
|
3
|
+
* Decoupled from core's agentBus so hivelearn is self-contained.
|
|
4
|
+
* server.ts subscribes here for SSE streaming.
|
|
5
|
+
*/
|
|
6
|
+
import { EventEmitter } from 'events';
|
|
7
|
+
declare class HLSwarmEmitter extends EventEmitter {
|
|
8
|
+
subscribe(event: string, cb: (...args: any[]) => void): void;
|
|
9
|
+
unsubscribe(event: string, cb: (...args: any[]) => void): void;
|
|
10
|
+
}
|
|
11
|
+
export declare const hlSwarmEmitter: HLSwarmEmitter;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HiveLearn — Backend entry point
|
|
3
|
+
*/
|
|
4
|
+
export type { StudentProfile, LessonProgram, SwarmProgress, NodoLesson, NodoContenido, MicroEvaluacion, FeedbackOutput, EvaluacionOutput, PreguntaEvaluacion, GamificacionOutput, Logro, RangoEdad, TipoPedagogico, TipoVisual, EstadoNodo, } from './types';
|
|
5
|
+
export type { CalificacionOutput, CalificacionInput } from './tools/evaluation/calificar-evaluacion.tool';
|
|
6
|
+
export type { SessionData, SessionMetrics } from './persistence/LessonPersistence';
|
|
7
|
+
export { HiveLearnSwarm } from './swarm/HiveLearnSwarm';
|
|
8
|
+
export { runHiveLearnSession } from './swarm/session';
|
|
9
|
+
export { LessonPersistence } from './persistence/LessonPersistence';
|
|
10
|
+
export { evaluarRespuestas } from './tools/evaluation/calificar-evaluacion.tool';
|
|
11
|
+
export { calificarEvaluacionTool, calificarRespuestaTool } from './tools/evaluation/calificar-evaluacion.tool';
|
|
12
|
+
export { AGENT_IDS, updateHiveLearnAgentsProviderModel } from './agents/registry';
|
|
13
|
+
export { AGENT_PROMPTS } from './agent/prompts';
|
|
14
|
+
export { runHiveLearnAgent } from './agent/runner';
|
|
15
|
+
export { hlSwarmEmitter } from './events/swarm-events';
|
|
16
|
+
export { nodeCache } from './cache/NodeCache';
|
|
17
|
+
export { cacheInvalidator } from './cache/CacheInvalidator';
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { StudentProfile } from '../types';
|
|
2
|
+
export interface SessionData {
|
|
3
|
+
sessionId: string;
|
|
4
|
+
alumnoId: string;
|
|
5
|
+
curriculoId: number;
|
|
6
|
+
xpTotal: number;
|
|
7
|
+
nivelAlcanzado: string;
|
|
8
|
+
logrosJson: string;
|
|
9
|
+
nodosCompletados: number;
|
|
10
|
+
evaluacionPuntaje: number | null;
|
|
11
|
+
completada: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface SessionMetrics {
|
|
14
|
+
sessionId: string;
|
|
15
|
+
alumnoId: string;
|
|
16
|
+
curriculoId: number;
|
|
17
|
+
tema: string;
|
|
18
|
+
duracionRealSeg: number;
|
|
19
|
+
nodosTotal: number;
|
|
20
|
+
nodosCompletados: number;
|
|
21
|
+
puntajeEvaluacion: number | null;
|
|
22
|
+
intentosPorNodo: string;
|
|
23
|
+
nodosDominados: string;
|
|
24
|
+
nodosDificiles: string;
|
|
25
|
+
logrosDesbloqueados: string;
|
|
26
|
+
xpGanado: number;
|
|
27
|
+
completada: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface NodeEffectiveness {
|
|
30
|
+
id: string;
|
|
31
|
+
nodoContentHash: string;
|
|
32
|
+
agenteTipo: string;
|
|
33
|
+
tema: string;
|
|
34
|
+
tipoPedagogico: string;
|
|
35
|
+
tipoVisual: string;
|
|
36
|
+
rangoEdad: string;
|
|
37
|
+
intentosPromedio: number;
|
|
38
|
+
tasaAbandono: number;
|
|
39
|
+
tiempoPromedio: number;
|
|
40
|
+
vecesVisto: number;
|
|
41
|
+
vecesCompletado: number;
|
|
42
|
+
}
|
|
43
|
+
export declare class LessonPersistence {
|
|
44
|
+
private db;
|
|
45
|
+
constructor();
|
|
46
|
+
/** Verifica si los agentes de HiveLearn ya tienen provider/model configurados */
|
|
47
|
+
getHiveLearnProviderModel(): {
|
|
48
|
+
providerId: string;
|
|
49
|
+
modelId: string;
|
|
50
|
+
} | null;
|
|
51
|
+
saveStudentProfile(profile: StudentProfile): void;
|
|
52
|
+
getStudentProfile(alumnoId: string): StudentProfile | null;
|
|
53
|
+
saveCurriculum(sessionId: string, meta: string, nodosJson: string, totalNodos: number, rangoEdad: string, topicSlug: string | null): number;
|
|
54
|
+
getCurriculumBySessionId(sessionId: string): {
|
|
55
|
+
id: number;
|
|
56
|
+
nodos_json: string;
|
|
57
|
+
topic_slug: string | null;
|
|
58
|
+
} | null;
|
|
59
|
+
createSession(sessionId: string, alumnoId: string, curriculoId: number, rangoEdad: string): void;
|
|
60
|
+
updateSessionProgress(sessionId: string, nodosCompletados: number, xpTotal: number): void;
|
|
61
|
+
completeSession(sessionId: string, xpTotal: number, nivelAlcanzado: string, logrosJson: string, evaluacionPuntaje: number | null): void;
|
|
62
|
+
getSession(sessionId: string): SessionData | null;
|
|
63
|
+
getActiveSession(alumnoId: string): SessionData | null;
|
|
64
|
+
saveSessionMetrics(metrics: SessionMetrics): void;
|
|
65
|
+
trackNodeInteraction(nodoId: string, agenteTipo: string, tema: string, tipoPedagogico: string, tipoVisual: string, rangoEdad: string, completado: boolean, tiempoSeg: number): void;
|
|
66
|
+
saveAgentOutput(sessionId: string, agentId: string, taskId: string, outputJson: string, durationMs: number, status?: 'ok' | 'failed'): void;
|
|
67
|
+
getAgentOutputs(sessionId: string): Array<{
|
|
68
|
+
agent_id: string;
|
|
69
|
+
task_id: string;
|
|
70
|
+
output_json: string;
|
|
71
|
+
duration_ms: number;
|
|
72
|
+
status: string;
|
|
73
|
+
}>;
|
|
74
|
+
saveStudentResponse(sessionId: string, nodeId: string, tipoPedagogico: string, respuesta: string, feedbackJson: string, xpAwarded: number, esCorrecto: boolean): void;
|
|
75
|
+
updateNodeEffectiveness(nodeId: string, tipoPedagogico: string, esCorrecto: boolean): void;
|
|
76
|
+
/** Agrega un logro a la lista de logros desbloqueados de la sesión */
|
|
77
|
+
saveLogro(sessionId: string, logroId: string): void;
|
|
78
|
+
rateSession(sessionId: string, rating: number, comentario?: string): void;
|
|
79
|
+
/** Devuelve sesión + curriculo completo (nodos_json) para el gateway */
|
|
80
|
+
getSessionWithCurriculum(sessionId: string): (SessionData & {
|
|
81
|
+
nodosJson: string;
|
|
82
|
+
topicSlug: string | null;
|
|
83
|
+
}) | null;
|
|
84
|
+
getTopicEffectiveness(topicSlug: string | null): {
|
|
85
|
+
nodosConMasFallas: string[];
|
|
86
|
+
nivelPromedioAprobacion: number;
|
|
87
|
+
};
|
|
88
|
+
getAggregateMetrics(): Record<string, any>;
|
|
89
|
+
getSessionsByAlumno(alumnoId: string): SessionData[];
|
|
90
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DAGScheduler — HiveLearn local copy
|
|
3
|
+
* Executes a TaskGraph in parallel. No core dependencies except logger.
|
|
4
|
+
*/
|
|
5
|
+
import { TaskGraph } from './TaskGraph';
|
|
6
|
+
import { TaskNode } from './TaskNode';
|
|
7
|
+
import type { DAGResult } from './TaskResult';
|
|
8
|
+
import type { ExecutionStrategy } from './strategies/ParallelStrategy';
|
|
9
|
+
export interface IAgentExecutor {
|
|
10
|
+
execute(node: TaskNode, depResults: Record<string, string>, threadId: string): Promise<string>;
|
|
11
|
+
}
|
|
12
|
+
export interface DAGSchedulerOptions {
|
|
13
|
+
strategy?: ExecutionStrategy;
|
|
14
|
+
maxConcurrentWorkers?: number;
|
|
15
|
+
projectId?: string;
|
|
16
|
+
coordinatorId?: string;
|
|
17
|
+
silent?: boolean;
|
|
18
|
+
executor?: IAgentExecutor;
|
|
19
|
+
}
|
|
20
|
+
export declare class DAGScheduler {
|
|
21
|
+
private strategy;
|
|
22
|
+
private maxConcurrentWorkers;
|
|
23
|
+
private executor;
|
|
24
|
+
private aborted;
|
|
25
|
+
constructor(options?: DAGSchedulerOptions);
|
|
26
|
+
abort(): void;
|
|
27
|
+
execute(graph: TaskGraph, options?: DAGSchedulerOptions): Promise<DAGResult>;
|
|
28
|
+
private logState;
|
|
29
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HiveLearn EventBridge — maps DAG lifecycle events to hlSwarmEmitter.
|
|
3
|
+
* Decoupled from core's agentBus and canvas emitter.
|
|
4
|
+
*/
|
|
5
|
+
import { TaskNode } from './TaskNode';
|
|
6
|
+
import type { DAGResult } from './TaskResult';
|
|
7
|
+
export declare class EventBridge {
|
|
8
|
+
private swarmId;
|
|
9
|
+
private coordinatorId;
|
|
10
|
+
constructor(swarmId: string, _projectId: string, coordinatorId: string);
|
|
11
|
+
onSwarmStarted(totalTasks: number): void;
|
|
12
|
+
onTaskStarted(node: TaskNode): void;
|
|
13
|
+
onTaskCompleted(node: TaskNode, progress: number): void;
|
|
14
|
+
onTaskFailed(node: TaskNode, progress: number): void;
|
|
15
|
+
onSwarmCompleted(result: DAGResult): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DAGScheduler — TaskGraph (HiveLearn local copy)
|
|
3
|
+
*/
|
|
4
|
+
import { TaskNode, type TaskNodeConfig } from "./TaskNode";
|
|
5
|
+
export declare class TaskGraph {
|
|
6
|
+
readonly nodes: Map<string, TaskNode>;
|
|
7
|
+
private criticalPath_;
|
|
8
|
+
constructor(configs: TaskNodeConfig[]);
|
|
9
|
+
private validateNoCycles;
|
|
10
|
+
getCriticalPath(): string[];
|
|
11
|
+
getNewlyReadyNodes(completedIds: Set<string>): TaskNode[];
|
|
12
|
+
getReadyNodes(): TaskNode[];
|
|
13
|
+
getCompletedIds(): Set<string>;
|
|
14
|
+
getDepResults(nodeId: string): Record<string, string>;
|
|
15
|
+
getProgress(): number;
|
|
16
|
+
isComplete(): boolean;
|
|
17
|
+
propagateFailure(failedId: string, reason: string): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DAGScheduler — TaskNode (HiveLearn local copy)
|
|
3
|
+
*/
|
|
4
|
+
export type NodeStatus = "PENDING" | "READY" | "RUNNING" | "COMPLETED" | "FAILED";
|
|
5
|
+
export interface TaskNodeConfig {
|
|
6
|
+
id: string;
|
|
7
|
+
agentId: string;
|
|
8
|
+
name: string;
|
|
9
|
+
taskDescription: string;
|
|
10
|
+
deps: string[];
|
|
11
|
+
timeout?: number;
|
|
12
|
+
maxRetries?: number;
|
|
13
|
+
priority?: number;
|
|
14
|
+
metadata?: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
export declare class TaskNode {
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly agentId: string;
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly taskDescription: string;
|
|
21
|
+
readonly deps: string[];
|
|
22
|
+
readonly timeout: number;
|
|
23
|
+
readonly maxRetries: number;
|
|
24
|
+
readonly priority: number;
|
|
25
|
+
readonly metadata: Record<string, unknown>;
|
|
26
|
+
status: NodeStatus;
|
|
27
|
+
retryCount: number;
|
|
28
|
+
startedAt?: number;
|
|
29
|
+
completedAt?: number;
|
|
30
|
+
result?: string;
|
|
31
|
+
error?: string;
|
|
32
|
+
constructor(config: TaskNodeConfig);
|
|
33
|
+
canStart(completedIds: Set<string>): boolean;
|
|
34
|
+
markReady(): void;
|
|
35
|
+
markRunning(): void;
|
|
36
|
+
markCompleted(result: string): void;
|
|
37
|
+
markFailed(error: string): void;
|
|
38
|
+
canRetry(): boolean;
|
|
39
|
+
elapsedSeconds(): number;
|
|
40
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DAGScheduler — Result types (HiveLearn local copy)
|
|
3
|
+
*/
|
|
4
|
+
export interface NodeSummary {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
status: "COMPLETED" | "FAILED";
|
|
8
|
+
durationMs: number;
|
|
9
|
+
result?: string;
|
|
10
|
+
error?: string;
|
|
11
|
+
retries: number;
|
|
12
|
+
}
|
|
13
|
+
export interface DAGResult {
|
|
14
|
+
swarmId: string;
|
|
15
|
+
totalDurationMs: number;
|
|
16
|
+
completed: NodeSummary[];
|
|
17
|
+
failed: NodeSummary[];
|
|
18
|
+
success: boolean;
|
|
19
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DAGScheduler — Custom errors (HiveLearn local copy)
|
|
3
|
+
*/
|
|
4
|
+
export declare class CyclicDependencyError extends Error {
|
|
5
|
+
readonly cycle: string[];
|
|
6
|
+
constructor(cycle: string[]);
|
|
7
|
+
}
|
|
8
|
+
export declare class TaskTimeoutError extends Error {
|
|
9
|
+
readonly nodeId: string;
|
|
10
|
+
readonly timeoutMs: number;
|
|
11
|
+
constructor(nodeId: string, timeoutMs: number);
|
|
12
|
+
}
|
|
13
|
+
export declare class TaskFailureError extends Error {
|
|
14
|
+
readonly nodeId: string;
|
|
15
|
+
readonly cause: Error;
|
|
16
|
+
constructor(nodeId: string, cause: Error);
|
|
17
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HiveLearn DAGScheduler — Public API
|
|
3
|
+
*/
|
|
4
|
+
export { DAGScheduler } from './DAGScheduler';
|
|
5
|
+
export type { DAGSchedulerOptions, IAgentExecutor } from './DAGScheduler';
|
|
6
|
+
export { TaskGraph } from './TaskGraph';
|
|
7
|
+
export { TaskNode } from './TaskNode';
|
|
8
|
+
export type { TaskNodeConfig, NodeStatus } from './TaskNode';
|
|
9
|
+
export type { DAGResult, NodeSummary } from './TaskResult';
|
|
10
|
+
export { EventBridge } from './EventBridge';
|
|
11
|
+
export { CyclicDependencyError, TaskTimeoutError, TaskFailureError } from './errors';
|
|
12
|
+
export { ParallelStrategy } from './strategies/ParallelStrategy';
|
|
13
|
+
export type { ExecutionStrategy } from './strategies/ParallelStrategy';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ParallelStrategy — FIFO execution (HiveLearn local copy)
|
|
3
|
+
*/
|
|
4
|
+
import { TaskNode } from "../TaskNode";
|
|
5
|
+
export interface ExecutionStrategy {
|
|
6
|
+
pick(queue: TaskNode[]): TaskNode | undefined;
|
|
7
|
+
initialize?(nodes: Map<string, TaskNode>): void;
|
|
8
|
+
}
|
|
9
|
+
export declare class ParallelStrategy implements ExecutionStrategy {
|
|
10
|
+
pick(queue: TaskNode[]): TaskNode | undefined;
|
|
11
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { StudentProfile, LessonProgram, SwarmProgress } from '../types';
|
|
2
|
+
export type ProgressCallback = (progress: SwarmProgress) => void;
|
|
3
|
+
export declare class HiveLearnSwarm {
|
|
4
|
+
private onProgress?;
|
|
5
|
+
constructor(opts?: {
|
|
6
|
+
onProgress?: ProgressCallback;
|
|
7
|
+
});
|
|
8
|
+
private emit;
|
|
9
|
+
run(perfil: StudentProfile, meta: string): Promise<LessonProgram>;
|
|
10
|
+
/** El coordinador revisa el LessonProgram y aplica correcciones + retries si los hay. */
|
|
11
|
+
private runCoordinatorReview;
|
|
12
|
+
/** Aplica correcciones de título/XP/concepto a los nodos del programa. */
|
|
13
|
+
private applyCorrecciones;
|
|
14
|
+
private calcNodos;
|
|
15
|
+
private calcTono;
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orchestrator — combina los outputs del DAGScheduler en un LessonProgram completo
|
|
3
|
+
*/
|
|
4
|
+
import type { DAGResult } from '../scheduler/dag';
|
|
5
|
+
import type { LessonProgram, NodoLesson, PerfilAdaptacion } from '../types';
|
|
6
|
+
export declare function parseAgentOutput<T>(raw: string, fallback: T): T;
|
|
7
|
+
/** Construye la lista de nodos base desde el output de StructureAgent */
|
|
8
|
+
export declare function buildNodosBase(structureResult: string, perfil: PerfilAdaptacion): Omit<NodoLesson, 'posX' | 'posY'>[];
|
|
9
|
+
export declare function buildLessonProgram(opts: {
|
|
10
|
+
dagResult: DAGResult;
|
|
11
|
+
alumnoId: string;
|
|
12
|
+
meta: string;
|
|
13
|
+
sessionId: string;
|
|
14
|
+
perfil: PerfilAdaptacion;
|
|
15
|
+
}): LessonProgram;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HiveLearnPreset — DAG completo de 14 agentes para HiveLearn
|
|
3
|
+
*
|
|
4
|
+
* TIER 0 (secuencial): profile → intent → structure
|
|
5
|
+
* TIER 1 (paralelo×2): content agents por nodo del currículo
|
|
6
|
+
* TIER 2 (paralelo): gamification + evaluation + position
|
|
7
|
+
* POST: postsession
|
|
8
|
+
*/
|
|
9
|
+
import { TaskGraph } from '../../scheduler/dag';
|
|
10
|
+
import type { TaskNodeConfig } from '../../scheduler/dag';
|
|
11
|
+
import type { PerfilAdaptacion, NodoLesson } from '../../types';
|
|
12
|
+
export interface HiveLearnDAGInput {
|
|
13
|
+
alumnoId: string;
|
|
14
|
+
meta: string;
|
|
15
|
+
perfil: PerfilAdaptacion;
|
|
16
|
+
sessionId: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Genera el grafo DAG para el enjambre completo.
|
|
20
|
+
* Los nodos de contenido (Tier 1) se agregan dinámicamente cuando
|
|
21
|
+
* el StructureAgent completa y el orchestrator ya tiene los nodos.
|
|
22
|
+
* Esta función genera el grafo base (Tier 0 + Tier 2).
|
|
23
|
+
*/
|
|
24
|
+
export declare function buildBaseDAG(input: HiveLearnDAGInput): TaskGraph;
|
|
25
|
+
/**
|
|
26
|
+
* Construye los nodos Tier 1 para cada nodo del currículo.
|
|
27
|
+
* Se llama después de que StructureAgent completa.
|
|
28
|
+
*/
|
|
29
|
+
export declare function buildContentNodes(nodos: NodoLesson[], ctxBase: string): TaskNodeConfig[];
|
|
30
|
+
/**
|
|
31
|
+
* Construye el TaskGraph de Fase 2 (solo content + tier2).
|
|
32
|
+
* NO incluye tier0 (profile/intent/structure) — ya corrieron en buildBaseDAG.
|
|
33
|
+
* Los content tasks no tienen deps en 'structure' porque Phase 1 ya lo resolvió.
|
|
34
|
+
*/
|
|
35
|
+
export declare function buildFullDAG(input: HiveLearnDAGInput, nodos: NodoLesson[]): TaskGraph;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* runHiveLearnSession — función de alto nivel que encapsula todo el ciclo:
|
|
3
|
+
* 1. Persiste perfil del alumno
|
|
4
|
+
* 2. Corre el enjambre (HiveLearnSwarm)
|
|
5
|
+
* 3. Persiste el currículum y crea la sesión en BD
|
|
6
|
+
* 4. Devuelve LessonProgram listo para servir
|
|
7
|
+
*
|
|
8
|
+
* Esta es la función que el gateway de hive-cloud debe llamar.
|
|
9
|
+
*/
|
|
10
|
+
import { type ProgressCallback } from './HiveLearnSwarm';
|
|
11
|
+
import type { StudentProfile, LessonProgram } from '../types';
|
|
12
|
+
export interface RunSessionOptions {
|
|
13
|
+
onProgress?: ProgressCallback;
|
|
14
|
+
}
|
|
15
|
+
export declare function runHiveLearnSession(perfil: StudentProfile, meta: string, opts?: RunSessionOptions): Promise<LessonProgram>;
|