@johpaz/hive-sdk 0.0.9 → 0.0.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.
Files changed (115) hide show
  1. package/package.json +81 -78
  2. package/src/agents.ts +1 -0
  3. package/src/canvas.ts +1 -0
  4. package/src/channels.ts +1 -0
  5. package/src/config.ts +1 -0
  6. package/src/events.ts +1 -0
  7. package/src/gateway.ts +1 -0
  8. package/src/index.ts +129 -90
  9. package/src/mcp.ts +1 -0
  10. package/src/multimodal.ts +1 -0
  11. package/src/scheduler.ts +1 -0
  12. package/src/security.ts +1 -0
  13. package/src/skills.ts +1 -0
  14. package/src/state.ts +1 -0
  15. package/src/storage.ts +1 -0
  16. package/src/tools.ts +1 -0
  17. package/src/tts.ts +1 -0
  18. package/src/types.ts +82 -0
  19. package/src/utils.ts +1 -0
  20. package/src/voice.ts +1 -0
  21. package/README.md +0 -538
  22. package/dist/agents/index.d.ts +0 -30
  23. package/dist/agents/index.js +0 -175901
  24. package/dist/channels/index.d.ts +0 -18
  25. package/dist/channels/index.js +0 -11025
  26. package/dist/cron/index.d.ts +0 -15
  27. package/dist/cron/index.js +0 -3262
  28. package/dist/database/index.d.ts +0 -19
  29. package/dist/database/index.js +0 -8385
  30. package/dist/ethics/index.d.ts +0 -12
  31. package/dist/ethics/index.js +0 -8348
  32. package/dist/hivelearn/index.d.ts +0 -11
  33. package/dist/hivelearn/index.js +0 -5033
  34. package/dist/hivelearn/src/agent/agent-loop.d.ts +0 -14
  35. package/dist/hivelearn/src/agent/executor.d.ts +0 -10
  36. package/dist/hivelearn/src/agent/prompts.d.ts +0 -1
  37. package/dist/hivelearn/src/agent/runner.d.ts +0 -8
  38. package/dist/hivelearn/src/agent/tool-map.d.ts +0 -12
  39. package/dist/hivelearn/src/agents/coordinator.prompt.d.ts +0 -9
  40. package/dist/hivelearn/src/agents/prompts/audio.prompt.d.ts +0 -1
  41. package/dist/hivelearn/src/agents/prompts/challenge.prompt.d.ts +0 -1
  42. package/dist/hivelearn/src/agents/prompts/code.prompt.d.ts +0 -1
  43. package/dist/hivelearn/src/agents/prompts/evaluation.prompt.d.ts +0 -1
  44. package/dist/hivelearn/src/agents/prompts/exercise.prompt.d.ts +0 -1
  45. package/dist/hivelearn/src/agents/prompts/explanation.prompt.d.ts +0 -1
  46. package/dist/hivelearn/src/agents/prompts/feedback.prompt.d.ts +0 -1
  47. package/dist/hivelearn/src/agents/prompts/gamification.prompt.d.ts +0 -1
  48. package/dist/hivelearn/src/agents/prompts/gif.prompt.d.ts +0 -1
  49. package/dist/hivelearn/src/agents/prompts/infographic.prompt.d.ts +0 -1
  50. package/dist/hivelearn/src/agents/prompts/intent.prompt.d.ts +0 -1
  51. package/dist/hivelearn/src/agents/prompts/profile.prompt.d.ts +0 -1
  52. package/dist/hivelearn/src/agents/prompts/quiz.prompt.d.ts +0 -1
  53. package/dist/hivelearn/src/agents/prompts/structure.prompt.d.ts +0 -1
  54. package/dist/hivelearn/src/agents/prompts/svg.prompt.d.ts +0 -1
  55. package/dist/hivelearn/src/agents/registry.d.ts +0 -43
  56. package/dist/hivelearn/src/cache/CacheInvalidator.d.ts +0 -9
  57. package/dist/hivelearn/src/cache/NodeCache.d.ts +0 -15
  58. package/dist/hivelearn/src/events/swarm-events.d.ts +0 -12
  59. package/dist/hivelearn/src/index.d.ts +0 -17
  60. package/dist/hivelearn/src/persistence/LessonPersistence.d.ts +0 -90
  61. package/dist/hivelearn/src/scheduler/dag/DAGScheduler.d.ts +0 -29
  62. package/dist/hivelearn/src/scheduler/dag/EventBridge.d.ts +0 -16
  63. package/dist/hivelearn/src/scheduler/dag/TaskGraph.d.ts +0 -18
  64. package/dist/hivelearn/src/scheduler/dag/TaskNode.d.ts +0 -40
  65. package/dist/hivelearn/src/scheduler/dag/TaskResult.d.ts +0 -19
  66. package/dist/hivelearn/src/scheduler/dag/errors.d.ts +0 -17
  67. package/dist/hivelearn/src/scheduler/dag/index.d.ts +0 -13
  68. package/dist/hivelearn/src/scheduler/dag/strategies/ParallelStrategy.d.ts +0 -11
  69. package/dist/hivelearn/src/swarm/HiveLearnSwarm.d.ts +0 -16
  70. package/dist/hivelearn/src/swarm/orchestrator.d.ts +0 -15
  71. package/dist/hivelearn/src/swarm/presets/HiveLearnPreset.d.ts +0 -35
  72. package/dist/hivelearn/src/swarm/session.d.ts +0 -15
  73. package/dist/hivelearn/src/tools/canvas/disenar-estructura.tool.d.ts +0 -3
  74. package/dist/hivelearn/src/tools/canvas/poblar-nodo.tool.d.ts +0 -2
  75. package/dist/hivelearn/src/tools/content/generar-audio.tool.d.ts +0 -2
  76. package/dist/hivelearn/src/tools/content/generar-codigo.tool.d.ts +0 -2
  77. package/dist/hivelearn/src/tools/content/generar-ejercicio.tool.d.ts +0 -2
  78. package/dist/hivelearn/src/tools/content/generar-explicacion.tool.d.ts +0 -2
  79. package/dist/hivelearn/src/tools/content/generar-frames-gif.tool.d.ts +0 -2
  80. package/dist/hivelearn/src/tools/content/generar-imagen.tool.d.ts +0 -2
  81. package/dist/hivelearn/src/tools/content/generar-infografia.tool.d.ts +0 -2
  82. package/dist/hivelearn/src/tools/content/generar-quiz.tool.d.ts +0 -2
  83. package/dist/hivelearn/src/tools/content/generar-reto.tool.d.ts +0 -2
  84. package/dist/hivelearn/src/tools/content/generar-svg.tool.d.ts +0 -2
  85. package/dist/hivelearn/src/tools/coordinator/delegar-enjambre.tool.d.ts +0 -6
  86. package/dist/hivelearn/src/tools/coordinator/revisar-programa.tool.d.ts +0 -6
  87. package/dist/hivelearn/src/tools/evaluation/calificar-evaluacion.tool.d.ts +0 -20
  88. package/dist/hivelearn/src/tools/evaluation/generar-evaluacion.tool.d.ts +0 -2
  89. package/dist/hivelearn/src/tools/index.d.ts +0 -26
  90. package/dist/hivelearn/src/tools/profile/clasificar-intencion.tool.d.ts +0 -2
  91. package/dist/hivelearn/src/tools/search/buscar-curriculo-existente.tool.d.ts +0 -2
  92. package/dist/hivelearn/src/tools/search/buscar-en-hivelearn.tool.d.ts +0 -2
  93. package/dist/hivelearn/src/types/tool.d.ts +0 -17
  94. package/dist/hivelearn/src/types.d.ts +0 -187
  95. package/dist/hivelearn/src/utils/logger.d.ts +0 -21
  96. package/dist/index.d.ts +0 -35
  97. package/dist/index.js +0 -179740
  98. package/dist/mcp/index.d.ts +0 -14
  99. package/dist/mcp/index.js +0 -728
  100. package/dist/skills/index.d.ts +0 -12
  101. package/dist/skills/index.js +0 -5877
  102. package/dist/tools/index.d.ts +0 -25
  103. package/dist/tools/index.js +0 -175794
  104. package/dist/types/index.d.ts +0 -17
  105. package/dist/types/index.js +0 -1
  106. package/src/agents/index.ts +0 -61
  107. package/src/channels/index.ts +0 -31
  108. package/src/cron/index.ts +0 -40
  109. package/src/database/index.ts +0 -41
  110. package/src/ethics/index.ts +0 -16
  111. package/src/hivelearn/index.ts +0 -43
  112. package/src/mcp/index.ts +0 -17
  113. package/src/skills/index.ts +0 -23
  114. package/src/tools/index.ts +0 -111
  115. package/src/types/index.ts +0 -58
package/README.md DELETED
@@ -1,538 +0,0 @@
1
- # @johpaz/hive-sdk
2
-
3
- SDK oficial para construir sobre [Hive](https://github.com/johpaz/hive) — el runtime de agentes IA local-first multi-canal.
4
-
5
- Expone toda la funcionalidad interna de Hive como una API organizada por módulos, pensada para integraciones enterprise, extensiones personalizadas y proyectos que necesitan construir sobre el núcleo de Hive.
6
-
7
- ## Instalación
8
-
9
- ```bash
10
- npm install @johpaz/hive-sdk
11
- # o
12
- bun add @johpaz/hive-sdk
13
- ```
14
-
15
- > **Requisito:** Hive debe estar inicializado en el sistema (base de datos, onboarding). El SDK opera sobre la instalación existente de Hive.
16
-
17
- ---
18
-
19
- ## Módulos
20
-
21
- El SDK está dividido en módulos independientes que se pueden importar por separado:
22
-
23
- | Módulo | Import | Descripción |
24
- |---|---|---|
25
- | [agents](#agents) | `@johpaz/hive-sdk/agents` | Ejecución de agentes, loop nativo, LLM |
26
- | [tools](#tools) | `@johpaz/hive-sdk/tools` | Todas las herramientas nativas por categoría |
27
- | [channels](#channels) | `@johpaz/hive-sdk/channels` | Adaptadores de canales (Telegram, Discord…) |
28
- | [database](#database) | `@johpaz/hive-sdk/database` | Acceso a SQLite, esquemas, crypto |
29
- | [mcp](#mcp) | `@johpaz/hive-sdk/mcp` | Cliente MCP (Model Context Protocol) |
30
- | [skills](#skills) | `@johpaz/hive-sdk/skills` | Carga y gestión de skills |
31
- | [cron](#cron) | `@johpaz/hive-sdk/cron` | Scheduler de tareas programadas |
32
- | [ethics](#ethics) | `@johpaz/hive-sdk/ethics` | Sistema de ética constitucional |
33
- | [types](#types) | `@johpaz/hive-sdk/types` | Todos los tipos TypeScript |
34
-
35
- También puedes importar todo de una vez:
36
-
37
- ```ts
38
- import * as HiveSDK from "@johpaz/hive-sdk";
39
- ```
40
-
41
- ---
42
-
43
- ## agents
44
-
45
- ```ts
46
- import {
47
- runAgent,
48
- runAgentIsolated,
49
- AgentService,
50
- compileContext,
51
- callLLM,
52
- } from "@johpaz/hive-sdk/agents";
53
- ```
54
-
55
- ### Ejecutar un agente
56
-
57
- ```ts
58
- import { runAgent } from "@johpaz/hive-sdk/agents";
59
-
60
- const response = await runAgent({
61
- agentId: "main", // ID del agente en la DB
62
- message: "Hola, agente",
63
- threadId: "thread-abc", // sesión de conversación
64
- });
65
-
66
- console.log(response.text);
67
- ```
68
-
69
- ### Ejecutar un agente aislado (worker)
70
-
71
- Corre el agente en un worker separado sin acceso al estado del coordinador:
72
-
73
- ```ts
74
- import { runAgentIsolated } from "@johpaz/hive-sdk/agents";
75
-
76
- const result = await runAgentIsolated({
77
- agentId: "researcher",
78
- message: "Investiga X y devuelve un resumen",
79
- threadId: "isolated-thread",
80
- });
81
- ```
82
-
83
- ### Llamar al LLM directamente
84
-
85
- ```ts
86
- import { callLLM, resolveProviderConfig } from "@johpaz/hive-sdk/agents";
87
- import type { LLMMessage } from "@johpaz/hive-sdk/agents";
88
-
89
- const messages: LLMMessage[] = [
90
- { role: "user", content: "¿Cuál es la capital de Colombia?" },
91
- ];
92
-
93
- const config = await resolveProviderConfig(agentId);
94
- const response = await callLLM({ messages, ...config });
95
-
96
- console.log(response.content);
97
- ```
98
-
99
- ### Historial de conversación
100
-
101
- ```ts
102
- import {
103
- addMessage,
104
- getHistory,
105
- getRecentMessages,
106
- } from "@johpaz/hive-sdk/agents";
107
-
108
- // Agregar mensaje
109
- await addMessage("thread-abc", "user", "Hola");
110
-
111
- // Leer historial completo
112
- const history = await getHistory("thread-abc");
113
-
114
- // Leer los últimos N mensajes
115
- const recent = await getRecentMessages("thread-abc", 10);
116
- ```
117
-
118
- ### Compilar contexto del sistema
119
-
120
- ```ts
121
- import { compileContext } from "@johpaz/hive-sdk/agents";
122
-
123
- const { systemPrompt, tools } = await compileContext({
124
- agentId: "main",
125
- userId: "user-1",
126
- threadId: "thread-abc",
127
- });
128
- ```
129
-
130
- ### Gestión de AgentService
131
-
132
- ```ts
133
- import { createAgentService, getAgentService } from "@johpaz/hive-sdk/agents";
134
-
135
- const service = await createAgentService({ agentId: "main" });
136
- // o
137
- const existing = getAgentService("main");
138
- ```
139
-
140
- ---
141
-
142
- ## tools
143
-
144
- ```ts
145
- import { createAllTools, createToolsByCategory } from "@johpaz/hive-sdk/tools";
146
- ```
147
-
148
- ### Crear todas las herramientas
149
-
150
- ```ts
151
- import { createAllTools } from "@johpaz/hive-sdk/tools";
152
-
153
- const tools = createAllTools({ userId: "user-1", agentId: "main" });
154
- ```
155
-
156
- ### Por categoría
157
-
158
- ```ts
159
- import { createToolsByCategory } from "@johpaz/hive-sdk/tools";
160
-
161
- const fsTools = createToolsByCategory("filesystem", config);
162
- const webTools = createToolsByCategory("web", config);
163
- ```
164
-
165
- ### Herramientas disponibles
166
-
167
- **Filesystem**
168
- ```ts
169
- import { fsReadTool, fsWriteTool, fsEditTool, fsDeleteTool, fsListTool, fsGlobTool, fsExistsTool } from "@johpaz/hive-sdk/tools";
170
- ```
171
-
172
- **Web**
173
- ```ts
174
- import { webSearchTool, webFetchTool, browserNavigateTool, browserScreenshotTool, browserClickTool, browserTypeTool } from "@johpaz/hive-sdk/tools";
175
- ```
176
-
177
- **Proyectos y tareas**
178
- ```ts
179
- import { projectCreateTool, projectListTool, projectUpdateTool, projectDoneTool, projectFailTool, taskCreateTool, taskUpdateTool, taskEvaluateTool } from "@johpaz/hive-sdk/tools";
180
- ```
181
-
182
- **Agentes y memoria**
183
- ```ts
184
- import { agentCreateTool, agentFindTool, agentArchiveTool, taskDelegateTool, taskDelegateCodeTool, taskStatusTool, memoryWriteTool, memoryReadTool, memoryListTool, memorySearchTool, memoryDeleteTool, busPublishTool, busReadTool, projectUpdatesTool } from "@johpaz/hive-sdk/tools";
185
- ```
186
-
187
- **Canvas (UI)**
188
- ```ts
189
- import { canvasRenderTool, canvasAskTool, canvasConfirmTool, canvasShowCardTool, canvasShowProgressTool, canvasShowListTool, canvasClearTool } from "@johpaz/hive-sdk/tools";
190
- ```
191
-
192
- **Code Bridge**
193
- ```ts
194
- import { codebridgeLaunchTool, codebridgeStatusTool, codebridgeCancelTool } from "@johpaz/hive-sdk/tools";
195
- ```
196
-
197
- **Voz**
198
- ```ts
199
- import { voiceTranscribeTool, voiceSpeakTool } from "@johpaz/hive-sdk/tools";
200
- ```
201
-
202
- **Core**
203
- ```ts
204
- import { searchKnowledgeTool, notifyTool, saveNoteTool, reportProgressTool } from "@johpaz/hive-sdk/tools";
205
- ```
206
-
207
- **Cron**
208
- ```ts
209
- import { cronAddTool, cronListTool, cronEditTool, cronRemoveTool } from "@johpaz/hive-sdk/tools";
210
- ```
211
-
212
- **CLI**
213
- ```ts
214
- import { cliExecTool } from "@johpaz/hive-sdk/tools";
215
- ```
216
-
217
- ---
218
-
219
- ## channels
220
-
221
- ```ts
222
- import { ChannelManager, TelegramChannel, DiscordChannel } from "@johpaz/hive-sdk/channels";
223
- ```
224
-
225
- ### Registrar un canal personalizado
226
-
227
- ```ts
228
- import { ChannelManager } from "@johpaz/hive-sdk/channels";
229
- import type { IncomingMessage, MessageHandler } from "@johpaz/hive-sdk/channels";
230
-
231
- const manager = new ChannelManager(config);
232
-
233
- manager.onMessage(async (msg: IncomingMessage) => {
234
- console.log("Mensaje recibido:", msg.text);
235
- });
236
-
237
- await manager.startAll();
238
- ```
239
-
240
- ### Canales disponibles
241
-
242
- ```ts
243
- import {
244
- TelegramChannel, // Bot de Telegram (grammy)
245
- DiscordChannel, // Bot de Discord
246
- WhatsAppChannel, // WhatsApp (Baileys)
247
- SlackChannel, // Slack (Bolt)
248
- WebChatChannel, // WebChat HTTP/WS
249
- } from "@johpaz/hive-sdk/channels";
250
- ```
251
-
252
- ---
253
-
254
- ## database
255
-
256
- ```ts
257
- import { getDb, initializeDatabase, dbService } from "@johpaz/hive-sdk/database";
258
- ```
259
-
260
- ### Acceder a la base de datos
261
-
262
- ```ts
263
- import { getDb, initializeDatabase } from "@johpaz/hive-sdk/database";
264
-
265
- // Inicializar (crear tablas si no existen)
266
- initializeDatabase();
267
-
268
- // Instancia raw de bun:sqlite
269
- const db = getDb();
270
- const rows = db.query("SELECT * FROM agents").all();
271
- ```
272
-
273
- ### Usar el servicio de DB
274
-
275
- ```ts
276
- import { dbService } from "@johpaz/hive-sdk/database";
277
-
278
- const agents = dbService.getUserAgents(userId);
279
- const project = dbService.getProjectWithTasks(projectId);
280
- ```
281
-
282
- ### Queries de onboarding
283
-
284
- ```ts
285
- import {
286
- getAllProviders,
287
- getAllModels,
288
- getAllChannels,
289
- getAllMcpServers,
290
- getActiveTools,
291
- getUserAgents,
292
- getCoordinatorAgentId,
293
- resolveUserId,
294
- resolveAgentId,
295
- } from "@johpaz/hive-sdk/database";
296
-
297
- const providers = getAllProviders();
298
- const agentId = await resolveAgentId("main");
299
- ```
300
-
301
- ### Crypto
302
-
303
- ```ts
304
- import { encryptApiKey, decryptApiKey, hashPassword, verifyPassword } from "@johpaz/hive-sdk/database";
305
-
306
- const encrypted = encryptApiKey("sk-...");
307
- const decrypted = decryptApiKey(encrypted);
308
-
309
- const hash = hashPassword("secret");
310
- const valid = verifyPassword("secret", hash);
311
- ```
312
-
313
- ### Seed / Reset
314
-
315
- ```ts
316
- import { seedAllData, seedToolsAndSkills } from "@johpaz/hive-sdk/database";
317
-
318
- // Poblar la DB con datos iniciales (idempotente)
319
- await seedAllData();
320
-
321
- // Solo tools y skills
322
- await seedToolsAndSkills();
323
- ```
324
-
325
- ---
326
-
327
- ## mcp
328
-
329
- ```ts
330
- import { MCPClientManager } from "@johpaz/hive-sdk/mcp";
331
- import type { MCPConfig } from "@johpaz/hive-sdk/mcp";
332
- ```
333
-
334
- ### Conectar a un servidor MCP
335
-
336
- ```ts
337
- import { MCPClientManager } from "@johpaz/hive-sdk/mcp";
338
-
339
- const manager = new MCPClientManager({
340
- servers: {
341
- filesystem: {
342
- command: "npx",
343
- args: ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
344
- },
345
- },
346
- });
347
-
348
- await manager.connect();
349
-
350
- const tools = manager.getTools(); // herramientas del servidor
351
- const resources = manager.getResources(); // recursos disponibles
352
- ```
353
-
354
- ---
355
-
356
- ## skills
357
-
358
- ```ts
359
- import { SkillLoader, createSkillLoader } from "@johpaz/hive-sdk/skills";
360
- ```
361
-
362
- ### Cargar skills
363
-
364
- ```ts
365
- import { createSkillLoader } from "@johpaz/hive-sdk/skills";
366
-
367
- const loader = createSkillLoader({
368
- workspacePath: "/path/to/workspace",
369
- });
370
-
371
- const skills = await loader.loadAll();
372
-
373
- for (const skill of skills) {
374
- console.log(skill.name, skill.description);
375
- }
376
- ```
377
-
378
- ### Ejecutar un skill
379
-
380
- ```ts
381
- const result = await loader.run("my-skill", {
382
- input: "contexto del agente",
383
- });
384
- ```
385
-
386
- ---
387
-
388
- ## cron
389
-
390
- ```ts
391
- import { initCronScheduler, resolveBestChannel, createCronTools } from "@johpaz/hive-sdk/cron";
392
- ```
393
-
394
- ### Inicializar el scheduler
395
-
396
- ```ts
397
- import { initCronScheduler } from "@johpaz/hive-sdk/cron";
398
-
399
- initCronScheduler(async (job) => {
400
- // Se ejecuta cuando vence un cron job
401
- console.log("Ejecutando job:", job.name);
402
- await runAgent({ agentId: job.agentId, message: job.prompt, threadId: job.id });
403
- });
404
- ```
405
-
406
- ### Herramientas de cron
407
-
408
- ```ts
409
- import { cronAddTool, cronListTool, cronEditTool, cronRemoveTool } from "@johpaz/hive-sdk/cron";
410
- ```
411
-
412
- ---
413
-
414
- ## ethics
415
-
416
- ```ts
417
- import { getAllEthics, activateEthics } from "@johpaz/hive-sdk/ethics";
418
- ```
419
-
420
- ### Gestionar reglas éticas
421
-
422
- ```ts
423
- import { getAllEthics, activateEthics } from "@johpaz/hive-sdk/ethics";
424
-
425
- // Leer todas las reglas
426
- const rules = getAllEthics();
427
-
428
- // Activar/desactivar un conjunto de reglas
429
- activateEthics("default");
430
- ```
431
-
432
- ---
433
-
434
- ## types
435
-
436
- Importa cualquier tipo de TypeScript sin traer código de ejecución:
437
-
438
- ```ts
439
- import type {
440
- // Agentes
441
- AgentDBRecord,
442
- AgentServiceConfig,
443
- AgentLoopOptions,
444
- StepEvent,
445
- StreamChunk,
446
-
447
- // LLM
448
- LLMMessage,
449
- LLMResponse,
450
- LLMCallOptions,
451
- LLMToolCall,
452
-
453
- // Canales
454
- IncomingMessage,
455
- OutboundMessage,
456
- ChannelConfig,
457
- IChannel,
458
-
459
- // MCP
460
- MCPTool,
461
- MCPResource,
462
- MCPPrompt,
463
- MCPConfig,
464
- MCPServerConfig,
465
-
466
- // Skills
467
- Skill,
468
- SkillMetadata,
469
- SkillStep,
470
- SkillExample,
471
- SkillsConfig,
472
-
473
- // Conversación
474
- StoredMessage,
475
- } from "@johpaz/hive-sdk/types";
476
- ```
477
-
478
- ---
479
-
480
- ## Ejemplo completo
481
-
482
- Agente personalizado que escucha en Telegram y responde usando el loop nativo:
483
-
484
- ```ts
485
- import { initializeDatabase } from "@johpaz/hive-sdk/database";
486
- import { TelegramChannel } from "@johpaz/hive-sdk/channels";
487
- import { runAgent } from "@johpaz/hive-sdk/agents";
488
-
489
- // 1. Inicializar DB
490
- initializeDatabase();
491
-
492
- // 2. Crear canal
493
- const telegram = new TelegramChannel({
494
- token: process.env.TELEGRAM_BOT_TOKEN!,
495
- });
496
-
497
- // 3. Manejar mensajes
498
- telegram.onMessage(async (msg) => {
499
- const response = await runAgent({
500
- agentId: "main",
501
- message: msg.text,
502
- threadId: `telegram:${msg.chatId}`,
503
- });
504
-
505
- await telegram.send({ chatId: msg.chatId, text: response.text });
506
- });
507
-
508
- await telegram.start();
509
- console.log("Bot activo");
510
- ```
511
-
512
- ---
513
-
514
- ## Publicación
515
-
516
- ```bash
517
- # Publicar la versión actual
518
- bun run publish:sdk
519
-
520
- # Bump y publicar
521
- bun run publish:sdk patch
522
- bun run publish:sdk minor
523
- bun run publish:sdk major
524
-
525
- # Versión explícita
526
- bun run publish:sdk 2.0.0
527
-
528
- # Simular sin publicar
529
- bun run publish:sdk patch --dry-run
530
- ```
531
-
532
- El script (`scripts/publish-sdk.ts`) ejecuta typecheck, actualiza `package.json`, verifica la sesión npm, publica y crea un git tag `sdk-vX.Y.Z` automáticamente.
533
-
534
- ---
535
-
536
- ## Licencia
537
-
538
- MIT — construido desde Colombia para el mundo.
@@ -1,30 +0,0 @@
1
- /**
2
- * Hive SDK - Agents Module
3
- *
4
- * Exposes agent execution, context compilation, and agent loop functionality.
5
- *
6
- * @example
7
- * import { runAgent, AgentService, compileContext } from "@johpaz/hive-agents-sdk/agents";
8
- *
9
- * // Run an agent with a message
10
- * const response = await runAgent({
11
- * agentId: "main",
12
- * message: "Hello, agent!",
13
- * threadId: "thread-123"
14
- * });
15
- */
16
- export { AgentService, getAgentService, createAgentService } from "@johpaz/hive-agents-core/agent/service";
17
- export type { AgentServiceConfig, AgentDBRecord } from "@johpaz/hive-agents-core/agent/service";
18
- export { runAgent, runAgentIsolated, rebuildAgentLoop, getAgentLoop } from "@johpaz/hive-agents-core/agent/agent-loop";
19
- export type { AgentLoopOptions, StepEvent, StreamChunk } from "@johpaz/hive-agents-core/agent/agent-loop";
20
- export { compileContext } from "@johpaz/hive-agents-core/agent/context-compiler";
21
- export { buildSystemPromptWithProjects } from "@johpaz/hive-agents-core/agent/prompt-builder";
22
- export { addMessage, getHistory, getRecentMessages, getMessageCount, getTotalTokens, getMessagesAfter } from "@johpaz/hive-agents-core/agent/conversation-store";
23
- export type { StoredMessage } from "@johpaz/hive-agents-core/agent/conversation-store";
24
- export { selectTools } from "@johpaz/hive-agents-core/agent/tool-selector";
25
- export { selectSkills } from "@johpaz/hive-agents-core/agent/skill-selector";
26
- export { selectPlaybookRules } from "@johpaz/hive-agents-core/agent/playbook-selector";
27
- export { callLLM, resolveProviderConfig } from "@johpaz/hive-agents-core/agent/llm-client";
28
- export type { LLMMessage, LLMResponse, LLMCallOptions, LLMToolCall } from "@johpaz/hive-agents-core/agent/llm-client";
29
- export { resolveAgentId, resolveUserId } from "@johpaz/hive-agents-core/storage/onboarding";
30
- export { memoryWriteTool, memoryReadTool, memoryListTool, memorySearchTool, memoryDeleteTool, agentCreateTool, agentFindTool, agentArchiveTool, taskDelegateTool, taskDelegateCodeTool, taskStatusTool, busPublishTool, busReadTool, projectUpdatesTool, createTools as createAgentTools, } from "@johpaz/hive-agents-core/tools/agents";