@johpaz/hive-sdk 0.0.15 → 0.0.16

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 (94) hide show
  1. package/CHANGELOG.md +27 -1
  2. package/README.md +179 -57
  3. package/docs/API-AGENTS.md +9 -9
  4. package/docs/API-CONTEXT-COMPILER.md +13 -13
  5. package/docs/API-DAG-SCHEDULER.md +8 -8
  6. package/docs/API-TOOLS-SKILLS-CHANNELS.md +150 -93
  7. package/docs/API-WORKERS-EVENTS.md +206 -59
  8. package/docs/INDEX.md +99 -50
  9. package/docs/README.md +117 -24
  10. package/docs/TEMPLATE-HIVE-APP.md +360 -0
  11. package/package.json +13 -6
  12. package/packages/cli/bin/hive +2 -0
  13. package/packages/cli/src/commands/add-skill.ts +42 -0
  14. package/packages/cli/src/commands/add-tool.ts +45 -0
  15. package/packages/cli/src/commands/add-worker.ts +49 -0
  16. package/packages/cli/src/commands/create-app-utils.ts +32 -0
  17. package/packages/cli/src/commands/create-app.test.ts +151 -0
  18. package/packages/cli/src/commands/create-app.ts +35 -0
  19. package/packages/cli/src/index.ts +21 -5
  20. package/packages/cli/templates/hive-app/.env.example +17 -0
  21. package/packages/cli/templates/hive-app/docker-compose.yml +20 -0
  22. package/packages/cli/templates/hive-app/hive.config.ts +19 -0
  23. package/packages/cli/templates/hive-app/package.json +16 -0
  24. package/packages/cli/templates/hive-app/src/agents/coordinator.ts +9 -0
  25. package/packages/cli/templates/hive-app/src/main.ts +56 -0
  26. package/packages/core/src/auth/auth.ts +108 -0
  27. package/packages/core/src/auth/index.ts +1 -0
  28. package/packages/core/src/canvas/canvas.test.ts +32 -0
  29. package/packages/core/src/canvas/emitter.ts +1 -1
  30. package/packages/core/src/canvas/index.ts +3 -6
  31. package/packages/core/src/channels/base.ts +154 -0
  32. package/packages/core/src/channels/channels.test.ts +18 -0
  33. package/packages/core/src/channels/discord.ts +273 -0
  34. package/packages/core/src/channels/index.ts +7 -0
  35. package/packages/core/src/channels/manager.ts +450 -0
  36. package/packages/core/src/channels/slack.ts +323 -0
  37. package/packages/core/src/channels/telegram.ts +612 -0
  38. package/packages/core/src/channels/webchat.ts +139 -0
  39. package/packages/core/src/channels/whatsapp.ts +548 -0
  40. package/packages/core/src/events/agent-bus.ts +460 -0
  41. package/packages/core/src/events/event-bus.ts +169 -0
  42. package/packages/core/src/gateway/channel-notify.ts +32 -7
  43. package/packages/core/src/gateway/gateway.test.ts +38 -0
  44. package/packages/core/src/gateway/index.ts +2 -1
  45. package/packages/core/src/gateway/server.ts +139 -0
  46. package/packages/core/src/heartbeat/index.ts +157 -0
  47. package/packages/core/src/index.ts +44 -0
  48. package/packages/core/src/multimodal/index.ts +2 -2
  49. package/packages/core/src/multimodal/vision-service.ts +283 -0
  50. package/packages/core/src/plugins/api.ts +128 -0
  51. package/packages/core/src/plugins/index.ts +2 -0
  52. package/packages/core/src/plugins/loader.ts +365 -0
  53. package/packages/core/src/resilience/circuit-breaker.ts +225 -0
  54. package/packages/core/src/scheduler/CronScheduler.ts +699 -0
  55. package/packages/core/src/scheduler/dag/AgentExecutor.ts +53 -0
  56. package/packages/core/src/scheduler/dag/DAGScheduler.ts +250 -0
  57. package/packages/core/src/scheduler/dag/EventBridge.ts +122 -0
  58. package/packages/core/src/scheduler/dag/TaskGraph.ts +192 -0
  59. package/packages/core/src/scheduler/dag/TaskNode.ts +97 -0
  60. package/packages/core/src/scheduler/dag/TaskResult.ts +22 -0
  61. package/packages/core/src/scheduler/dag/errors.ts +37 -0
  62. package/packages/core/src/scheduler/dag/index.ts +26 -0
  63. package/packages/core/src/scheduler/dag/presets/ResearchPreset.ts +97 -0
  64. package/packages/core/src/scheduler/dag/strategies/ParallelStrategy.ts +21 -0
  65. package/packages/core/src/scheduler/dag/strategies/PriorityStrategy.ts +46 -0
  66. package/packages/core/src/scheduler/index.ts +22 -0
  67. package/packages/core/src/scheduler/integration.ts +237 -0
  68. package/packages/core/src/scheduler/scheduler.test.ts +19 -0
  69. package/packages/core/src/scheduler/types.ts +164 -0
  70. package/packages/core/src/security/google-chat.ts +269 -0
  71. package/packages/core/src/security/index.ts +192 -4
  72. package/packages/core/src/security/rate-limit.ts +270 -0
  73. package/packages/core/src/security/signal.ts +321 -0
  74. package/packages/core/src/storage/crypto.ts +198 -66
  75. package/packages/core/src/storage/storage.test.ts +37 -0
  76. package/packages/core/src/swarm/swarm.test.ts +24 -0
  77. package/packages/core/src/tool-runtime/index.ts +522 -0
  78. package/packages/core/src/tool-runtime/tool-runtime.test.ts +91 -0
  79. package/packages/core/src/tool-runtime/tool-worker.ts +125 -0
  80. package/packages/core/src/voice/index.ts +5 -18
  81. package/packages/core/src/workers/WorkerPool.ts +167 -0
  82. package/packages/core/src/workers/agent.worker.ts +68 -0
  83. package/packages/core/src/workers/createWorker.ts +144 -0
  84. package/packages/core/src/workers/index.ts +5 -0
  85. package/packages/core/src/workers/workers.test.ts +48 -0
  86. package/test/setup-db.ts +2 -2
  87. package/tsconfig.json +2 -1
  88. package/.github/CODEOWNERS +0 -9
  89. package/.github/workflows/publish.yml +0 -89
  90. package/.github/workflows/version-bump.yml +0 -102
  91. package/bun.lock +0 -543
  92. package/bunfig.toml +0 -7
  93. package/packages/core/src/agent/providers.ts +0 -1
  94. package/packages/core/src/gateway/channel-notify.test.ts +0 -14
package/docs/README.md CHANGED
@@ -1,29 +1,58 @@
1
1
  # Documentación — Hive SDK
2
2
 
3
+ > **Agent Harness SDK** — Build, deploy, and scale AI agent applications with multi-channel support, Bun Workers, and swarm orchestration.
4
+
3
5
  ## Documentos
4
6
 
5
7
  | Documento | Descripción |
6
8
  |-----------|-------------|
7
- | [API-AGENTS.md](API-AGENTS.md) | createAgent, defineTool, defineSkill, AgentLoop, Tool/Skill Selector, LLM Providers |
8
- | [API-DAG-SCHEDULER.md](API-DAG-SCHEDULER.md) | DAGScheduler, TaskGraph, TaskNode, Estrategias, Presets, EventBridge |
9
- | [API-WORKERS-EVENTS.md](API-WORKERS-EVENTS.md) | Workers, AgentBus, EventBus, Canvas Events |
10
- | [API-TOOLS-SKILLS-CHANNELS.md](API-TOOLS-SKILLS-CHANNELS.md) | ToolRegistry, ToolExecutor, SkillLoader, MCP, Canvas, Storage, Config |
11
- | [API-CONTEXT-COMPILER.md](API-CONTEXT-COMPILER.md) | compileContext, Message History, Scratchpad, EthicsGuard, ACE, MCP Internals |
9
+ | [API-AGENTS.md](API-AGENTS.md) | createAgent, AgentLoop, Tool/Skill Selector, LLM Providers |
10
+ | [API-DAG-SCHEDULER.md](API-DAG-SCHEDULER.md) | DAGScheduler, TaskGraph, TaskNode, Estrategias, Presets |
11
+ | [API-WORKERS-EVENTS.md](API-WORKERS-EVENTS.md) | **Bun Workers**, createWorker, WorkerPool, AgentBus, EventBus, Canvas |
12
+ | [API-TOOLS-SKILLS-CHANNELS.md](API-TOOLS-SKILLS-CHANNELS.md) | Tools, Skills, MCP, **Gateway**, **Channels**, **Tool Runtime**, Storage |
13
+ | [API-CONTEXT-COMPILER.md](API-CONTEXT-COMPILER.md) | Context Compiler, Message History, Scratchpad, EthicsGuard, ACE |
14
+ | [TEMPLATE-HIVE-APP.md](TEMPLATE-HIVE-APP.md) | **Template hive-app** — estructura, opciones, personalización |
15
+ | [HIVE-HARNESS.md](../docs/HIVE-HARNESS.md) | Posicionamiento de producto: Hive como Agent Harness |
16
+
17
+ ## Instalación
18
+
19
+ ```bash
20
+ # Instalar globalmente para el CLI
21
+ bun install -g @johpaz/hive-sdk
22
+
23
+ # O en un proyecto
24
+ bun add @johpaz/hive-sdk
25
+ ```
26
+
27
+ ## CLI Commands
28
+
29
+ ```bash
30
+ hive init <name> # Inicializar proyecto agente
31
+ hive create-app <name> # Crear aplicación harness completa
32
+ hive add-tool <name> # Añadir tool
33
+ hive add-skill <name> # Añadir skill
34
+ hive add-worker <name> # Añadir Bun Worker
35
+ hive run # Ejecutar agente
36
+ hive test # Test tools/skills
37
+ hive trace # Ver logs de ejecución
38
+ ```
12
39
 
13
40
  ## Inicio Rápido
14
41
 
42
+ ### 1. Crear una app harness completa
43
+
15
44
  ```bash
16
- # Instalar
17
- git clone https://github.com/anomalyco/hive-sdk.git
18
- cd hive-sdk
45
+ hive create-app my-hive
46
+ cd my-hive
19
47
  bun install
20
-
21
- # Test
22
- bun test packages/core/src/
48
+ cp .env.example .env
49
+ bun run dev
23
50
  ```
24
51
 
52
+ ### 2. Crear un agente simple
53
+
25
54
  ```typescript
26
- import { createAgent, defineTool } from "@hive/core";
55
+ import { createAgent, defineTool } from "@johpaz/hive-sdk";
27
56
 
28
57
  const tool = defineTool({
29
58
  name: "saludar",
@@ -42,27 +71,91 @@ const respuesta = await agent.run("Saluda a Juan");
42
71
  console.log(respuesta);
43
72
  ```
44
73
 
74
+ ### 3. Crear un worker especializado
75
+
76
+ ```typescript
77
+ import { createWorker } from "@johpaz/hive-sdk";
78
+
79
+ const researcher = createWorker({
80
+ name: "researcher",
81
+ systemPrompt: "You are a research specialist. Provide concise, factual summaries.",
82
+ });
83
+
84
+ const result = await researcher.run("Research quantum computing advances");
85
+ console.log(result);
86
+ researcher.terminate();
87
+ ```
88
+
89
+ ### 4. Ejecutar workers en paralelo
90
+
91
+ ```typescript
92
+ import { WorkerPool } from "@johpaz/hive-sdk";
93
+
94
+ const pool = new WorkerPool({ maxWorkers: 4 });
95
+
96
+ const tasks = [
97
+ { id: "t1", message: "Summarize article A" },
98
+ { id: "t2", message: "Summarize article B" },
99
+ { id: "t3", message: "Summarize article C" },
100
+ ];
101
+
102
+ const results = await pool.executeBatch(tasks);
103
+ console.log(results);
104
+ pool.shutdown();
105
+ ```
106
+
107
+ ### 5. Gateway HTTP/WebSocket
108
+
109
+ ```typescript
110
+ import { startGateway } from "@johpaz/hive-sdk";
111
+
112
+ const server = await startGateway({
113
+ host: "127.0.0.1",
114
+ port: 18790,
115
+ agentId: "coordinator",
116
+ });
117
+
118
+ console.log(`Gateway at http://127.0.0.1:18790`);
119
+ ```
120
+
45
121
  ## Variables de Entorno
46
122
 
47
123
  ```bash
48
124
  HIVE_DATA_DIR=./data # Directorio de datos SQLite
125
+ HIVE_HOST=127.0.0.1 # Gateway host
126
+ HIVE_PORT=18790 # Gateway port
49
127
  OPENAI_API_KEY=sk-... # OpenAI
50
128
  ANTHROPIC_API_KEY=sk-ant-... # Anthropic
51
- LOG_LEVEL=info # debug | info | warn | error
129
+ GOOGLE_API_KEY=... # Gemini
130
+ LOG_LEVEL=info # debug | info | warn | error
131
+ ```
132
+
133
+ ## Tests
134
+
135
+ ```bash
136
+ # Todos los tests (paralelo)
137
+ bun test
138
+
139
+ # Tests con timeout extendido
140
+ bun test --timeout 60000
52
141
  ```
53
142
 
54
143
  ## Changelog
55
144
 
56
- ### v2.0.0
57
- - Restructura completa a @hive/core, @hive/cli
58
- - Nueva API: createAgent, defineTool, defineSkill
59
- - Eliminados: gateway, channels, tts, voice service (migrados a hive-app)
60
- - FTS5 preservado como ventaja competitiva
145
+ ### v0.0.16
146
+ - **Bun Workers individuales**: `createWorker()`, `WorkerPool`, `agent.worker.ts`
147
+ - **Gateway simplificado**: HTTP/WebSocket server con `Bun.serve()`
148
+ - **Channels**: Telegram, Discord, WhatsApp, Slack, Webchat
149
+ - **Tool Runtime**: Ejecución paralela de tools vía Bun Workers
150
+ - **CLI mejorado**: `hive create-app`, `hive add-tool`, `hive add-skill`, `hive add-worker`
151
+ - **Template hive-app**: Proyecto harness completo con Docker
152
+ - **39 tests pasando** en 12 archivos
153
+
154
+ ### v0.0.15
155
+ - Core de agentes con Context Engineering, FTS5, ACE
156
+ - DAGScheduler con ejecución paralela
157
+ - API pública: `createAgent`, `defineTool`, `defineSkill`
61
158
 
62
- ### v1.1.0
63
- - Streaming TTFT benchmarks
64
- - Worker performance metrics
65
- - DAGScheduler executor option fix
159
+ ---
66
160
 
67
- ### v1.0.0
68
- - Lanzamiento inicial
161
+ *Documentación Hive SDK v0.0.16*
@@ -0,0 +1,360 @@
1
+ # Template `hive-app` — Documentación Completa
2
+
3
+ El template `hive-app` genera una **aplicación harness completa** lista para ejecutar. Incluye gateway HTTP/WebSocket, agente coordinador, configuración de canales, base de datos SQLite, y deployment con Docker.
4
+
5
+ ---
6
+
7
+ ## Generar una app
8
+
9
+ ```bash
10
+ hive create-app my-hive
11
+ ```
12
+
13
+ Esto crea el directorio `my-hive/` con la estructura completa.
14
+
15
+ ---
16
+
17
+ ## Estructura generada
18
+
19
+ ```
20
+ my-hive/
21
+ ├── package.json # Dependencias y scripts
22
+ ├── hive.config.ts # Configuración del harness
23
+ ├── docker-compose.yml # Deployment con Docker
24
+ ├── .env.example # Variables de entorno de ejemplo
25
+ ├── .gitignore # Archivos ignorados por git
26
+ └── src/
27
+ ├── main.ts # Entry point — arranca gateway + agente
28
+ └── agents/
29
+ └── coordinator.ts # Definición del agente coordinador
30
+ ```
31
+
32
+ ---
33
+
34
+ ## Archivos y opciones
35
+
36
+ ### `package.json`
37
+
38
+ ```json
39
+ {
40
+ "name": "my-hive",
41
+ "version": "0.1.0",
42
+ "type": "module",
43
+ "scripts": {
44
+ "dev": "bun run src/main.ts",
45
+ "start": "bun run src/main.ts",
46
+ "build": "bun build src/main.ts --outdir dist --target bun"
47
+ },
48
+ "dependencies": {
49
+ "@johpaz/hive-sdk": "latest"
50
+ }
51
+ }
52
+ ```
53
+
54
+ | Script | Comando | Descripción |
55
+ |--------|---------|-------------|
56
+ | `dev` | `bun run src/main.ts` | Ejecutar en desarrollo |
57
+ | `start` | `bun run src/main.ts` | Ejecutar en producción |
58
+ | `build` | `bun build ...` | Compilar a `dist/` |
59
+
60
+ ---
61
+
62
+ ### `hive.config.ts`
63
+
64
+ Configuración central del harness.
65
+
66
+ ```typescript
67
+ import type { Config } from "@johpaz/hive-sdk";
68
+
69
+ export default {
70
+ name: "my-hive",
71
+ gateway: {
72
+ host: process.env.HIVE_HOST ?? "127.0.0.1",
73
+ port: Number(process.env.HIVE_PORT ?? 18790),
74
+ },
75
+ channels: {
76
+ webchat: { enabled: true }, // Siempre habilitado
77
+ telegram: { enabled: false }, // Requiere TELEGRAM_BOT_TOKEN
78
+ discord: { enabled: false }, // Requiere DISCORD_BOT_TOKEN
79
+ whatsapp: { enabled: false }, // Requiere configuración adicional
80
+ slack: { enabled: false }, // Requiere SLACK_BOT_TOKEN
81
+ },
82
+ database: {
83
+ path: process.env.HIVE_DATA_DIR ?? "./data/hive.db",
84
+ },
85
+ } satisfies Config;
86
+ ```
87
+
88
+ #### Opciones de configuración
89
+
90
+ | Opción | Tipo | Default | Descripción |
91
+ |--------|------|---------|-------------|
92
+ | `name` | `string` | `"my-hive"` | Nombre de la aplicación |
93
+ | `gateway.host` | `string` | `"127.0.0.1"` | Host del gateway |
94
+ | `gateway.port` | `number` | `18790` | Puerto del gateway |
95
+ | `channels.webchat.enabled` | `boolean` | `true` | Canal webchat integrado |
96
+ | `channels.telegram.enabled` | `boolean` | `false` | Bot de Telegram |
97
+ | `channels.discord.enabled` | `boolean` | `false` | Bot de Discord |
98
+ | `channels.whatsapp.enabled` | `boolean` | `false` | Bot de WhatsApp |
99
+ | `channels.slack.enabled` | `boolean` | `false` | Bot de Slack |
100
+ | `database.path` | `string` | `"./data/hive.db"` | Ruta de la base de datos SQLite |
101
+
102
+ ---
103
+
104
+ ### `src/main.ts`
105
+
106
+ Entry point de la aplicación. Realiza:
107
+
108
+ 1. Inicializa la base de datos (`initializeDatabase`)
109
+ 2. Crea el agente coordinador (`createAgent`)
110
+ 3. Inicializa el ChannelManager
111
+ 4. Arranca el gateway (`startGateway`)
112
+ 5. Maneja shutdown graceful (`SIGINT`)
113
+
114
+ ```typescript
115
+ import {
116
+ createAgent,
117
+ startGateway,
118
+ initializeDatabase,
119
+ ChannelManager,
120
+ logger,
121
+ } from "@johpaz/hive-sdk";
122
+ import config from "../hive.config.ts";
123
+
124
+ const log = logger.child("app");
125
+
126
+ async function main() {
127
+ log.info(`Starting my-hive...`);
128
+
129
+ await initializeDatabase();
130
+
131
+ const agent = await createAgent({
132
+ name: "coordinator",
133
+ provider: "openai",
134
+ model: "gpt-4o-mini",
135
+ systemPrompt: "You are a helpful AI assistant...",
136
+ });
137
+
138
+ const channelManager = new ChannelManager();
139
+ // TODO: configure channels from hive.config.ts
140
+
141
+ const gateway = await startGateway({
142
+ host: config.gateway?.host,
143
+ port: config.gateway?.port,
144
+ agentId: "coordinator",
145
+ });
146
+
147
+ log.info(`my-hive is running at http://${gateway.hostname}:${gateway.port}`);
148
+ }
149
+
150
+ main().catch((err) => {
151
+ log.error("Fatal error:", err);
152
+ process.exit(1);
153
+ });
154
+ ```
155
+
156
+ #### Personalizar el agente
157
+
158
+ Puedes cambiar el `provider`, `model`, y `systemPrompt`:
159
+
160
+ ```typescript
161
+ const agent = await createAgent({
162
+ name: "coordinator",
163
+ provider: "anthropic", // "openai" | "anthropic" | "gemini" | "ollama"
164
+ model: "claude-3-5-sonnet-20241022",
165
+ systemPrompt: "Tu system prompt personalizado...",
166
+ });
167
+ ```
168
+
169
+ #### Añadir tools al agente
170
+
171
+ ```typescript
172
+ import { defineTool } from "@johpaz/hive-sdk";
173
+
174
+ const searchTool = defineTool({
175
+ name: "search",
176
+ description: "Search the web",
177
+ execute: async (args: { query: string }) => {
178
+ // Implementation
179
+ return { results: [] };
180
+ },
181
+ });
182
+
183
+ const agent = await createAgent({
184
+ name: "coordinator",
185
+ provider: "openai",
186
+ model: "gpt-4o-mini",
187
+ tools: [searchTool],
188
+ });
189
+ ```
190
+
191
+ ---
192
+
193
+ ### `src/agents/coordinator.ts`
194
+
195
+ Definición standalone del agente coordinador. Puedes importarlo desde `main.ts` o usarlo directamente.
196
+
197
+ ```typescript
198
+ import { createAgent } from "@johpaz/hive-sdk";
199
+
200
+ export const coordinatorAgent = await createAgent({
201
+ name: "coordinator",
202
+ provider: "openai",
203
+ model: "gpt-4o-mini",
204
+ systemPrompt: "You are the coordinator agent...",
205
+ });
206
+ ```
207
+
208
+ ---
209
+
210
+ ### `docker-compose.yml`
211
+
212
+ Deployment containerizado.
213
+
214
+ ```yaml
215
+ services:
216
+ app:
217
+ image: oven/bun:latest
218
+ working_dir: /app
219
+ volumes:
220
+ - .:/app
221
+ - hive-data:/app/data
222
+ ports:
223
+ - "${HIVE_PORT:-18790}:18790"
224
+ environment:
225
+ - HIVE_HOST=0.0.0.0
226
+ - HIVE_PORT=18790
227
+ - HIVE_DATA_DIR=/app/data
228
+ - OPENAI_API_KEY=${OPENAI_API_KEY}
229
+ - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
230
+ command: ["bun", "run", "src/main.ts"]
231
+ restart: unless-stopped
232
+
233
+ volumes:
234
+ hive-data:
235
+ ```
236
+
237
+ #### Deployment
238
+
239
+ ```bash
240
+ # Copiar variables de entorno
241
+ cp .env.example .env
242
+ # Editar .env con tus API keys
243
+
244
+ # Levantar con Docker
245
+ docker compose up -d
246
+
247
+ # Ver logs
248
+ docker compose logs -f
249
+ ```
250
+
251
+ ---
252
+
253
+ ### `.env.example`
254
+
255
+ Variables de entorno disponibles:
256
+
257
+ ```bash
258
+ # Hive Harness Configuration
259
+ HIVE_HOST=127.0.0.1
260
+ HIVE_PORT=18790
261
+ HIVE_DATA_DIR=./data
262
+
263
+ # LLM Providers
264
+ OPENAI_API_KEY=sk-...
265
+ ANTHROPIC_API_KEY=sk-ant-...
266
+ GOOGLE_API_KEY=...
267
+
268
+ # Channels (enable as needed)
269
+ TELEGRAM_BOT_TOKEN=
270
+ DISCORD_BOT_TOKEN=
271
+ SLACK_BOT_TOKEN=
272
+
273
+ # Logging
274
+ LOG_LEVEL=info
275
+ ```
276
+
277
+ | Variable | Requerida | Descripción |
278
+ |----------|-----------|-------------|
279
+ | `HIVE_HOST` | No | Host del gateway |
280
+ | `HIVE_PORT` | No | Puerto del gateway |
281
+ | `HIVE_DATA_DIR` | No | Directorio de datos SQLite |
282
+ | `OPENAI_API_KEY` | Sí* | API key de OpenAI |
283
+ | `ANTHROPIC_API_KEY` | Sí* | API key de Anthropic |
284
+ | `GOOGLE_API_KEY` | Sí* | API key de Gemini |
285
+ | `TELEGRAM_BOT_TOKEN` | No | Token del bot de Telegram |
286
+ | `DISCORD_BOT_TOKEN` | No | Token del bot de Discord |
287
+ | `SLACK_BOT_TOKEN` | No | Token del bot de Slack |
288
+ | `LOG_LEVEL` | No | `debug` \| `info` \| `warn` \| `error` |
289
+
290
+ \* Al menos una API key de LLM es requerida.
291
+
292
+ ---
293
+
294
+ ## Personalización avanzada
295
+
296
+ ### Añadir canales
297
+
298
+ ```typescript
299
+ // src/main.ts
300
+ import { TelegramChannel, DiscordChannel } from "@johpaz/hive-sdk";
301
+
302
+ const channelManager = new ChannelManager(config);
303
+
304
+ if (config.channels.telegram.enabled) {
305
+ channelManager.register("telegram", new TelegramChannel({
306
+ botToken: process.env.TELEGRAM_BOT_TOKEN!,
307
+ }));
308
+ }
309
+
310
+ if (config.channels.discord.enabled) {
311
+ channelManager.register("discord", new DiscordChannel({
312
+ botToken: process.env.DISCORD_BOT_TOKEN!,
313
+ }));
314
+ }
315
+
316
+ await channelManager.initialize();
317
+ ```
318
+
319
+ ### Añadir workers especializados
320
+
321
+ ```bash
322
+ cd my-hive
323
+ hive add-worker researcher
324
+ hive add-worker coder
325
+ ```
326
+
327
+ Esto genera `src/workers/researcher.worker.ts` y `src/workers/coder.worker.ts`.
328
+
329
+ ### Añadir tools
330
+
331
+ ```bash
332
+ cd my-hive
333
+ hive add-tool search-docs
334
+ ```
335
+
336
+ Genera `src/tools/search-docs.ts`.
337
+
338
+ ### Añadir skills
339
+
340
+ ```bash
341
+ cd my-hive
342
+ hive add-skill onboarding
343
+ ```
344
+
345
+ Genera `src/skills/onboarding.ts`.
346
+
347
+ ---
348
+
349
+ ## Tests del template
350
+
351
+ El template incluye tests para verificar que la estructura se genera correctamente.
352
+
353
+ ```bash
354
+ cd my-hive
355
+ bun test
356
+ ```
357
+
358
+ ---
359
+
360
+ *Documentación Hive SDK v0.0.16*
package/package.json CHANGED
@@ -1,29 +1,36 @@
1
1
  {
2
2
  "name": "@johpaz/hive-sdk",
3
- "version": "0.0.15",
4
- "description": "Hive SDK — Agentes AI con Context Engineering, FTS5, ACE, Swarm",
3
+ "version": "0.0.16",
4
+ "private": false,
5
+ "description": "Hive SDK — The Agent Harness SDK. Build, deploy, and scale AI agent applications with multi-channel support, context engineering, and swarm orchestration.",
5
6
  "license": "MIT",
6
- "homepage": "https://github.com/anomalyco/hive-sdk#readme",
7
+ "homepage": "https://github.com/johpaz/hive-sdk#readme",
7
8
  "repository": {
8
9
  "type": "git",
9
- "url": "https://github.com/anomalyco/hive-sdk.git"
10
+ "url": "https://github.com/johpaz/hive-sdk.git"
10
11
  },
11
12
  "bugs": {
12
- "url": "https://github.com/anomalyco/hive-sdk/issues"
13
+ "url": "https://github.com/johpaz/hive-sdk/issues"
13
14
  },
14
15
  "keywords": [
15
16
  "ai",
16
17
  "agent",
17
18
  "llm",
19
+ "harness",
18
20
  "context-engineering",
19
21
  "fts5",
20
22
  "swarm",
21
23
  "ace",
22
24
  "bun",
23
- "langchain-alternative"
25
+ "langchain-alternative",
26
+ "multi-channel",
27
+ "gateway"
24
28
  ],
25
29
  "main": "./packages/core/src/index.ts",
26
30
  "types": "./packages/core/src/index.ts",
31
+ "bin": {
32
+ "hive": "./packages/cli/bin/hive"
33
+ },
27
34
  "workspaces": [
28
35
  "packages/core",
29
36
  "packages/cli"
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import("../src/index.ts");
@@ -0,0 +1,42 @@
1
+ import { existsSync, mkdirSync, writeFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import * as process from "node:process";
4
+
5
+ async function runAddSkill() {
6
+ const skillName = process.argv[3];
7
+
8
+ if (!skillName) {
9
+ console.error("Usage: hive add-skill <name>");
10
+ process.exit(1);
11
+ }
12
+
13
+ const skillsDir = join(process.cwd(), "src", "skills");
14
+ const filePath = join(skillsDir, `${skillName}.ts`);
15
+
16
+ if (existsSync(filePath)) {
17
+ console.error(`Skill '${skillName}' already exists.`);
18
+ process.exit(1);
19
+ }
20
+
21
+ mkdirSync(skillsDir, { recursive: true });
22
+
23
+ const content = `import { defineSkill } from "@johpaz/hive-sdk";
24
+
25
+ export const ${skillName}Skill = defineSkill({
26
+ name: "${skillName}",
27
+ description: "Description of what ${skillName} skill does.",
28
+ steps: [
29
+ {
30
+ name: "step-1",
31
+ description: "First step of the skill",
32
+ tool: "notify",
33
+ },
34
+ ],
35
+ });
36
+ `;
37
+
38
+ writeFileSync(filePath, content);
39
+ console.log(`✅ Created skill: ${filePath}`);
40
+ }
41
+
42
+ runAddSkill();
@@ -0,0 +1,45 @@
1
+ import { existsSync, mkdirSync, writeFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import * as process from "node:process";
4
+
5
+ function toPascalCase(str: string): string {
6
+ return str.replace(/[-_](.)/g, (_, char) => char.toUpperCase()).replace(/^(.)/, (_, char) => char.toUpperCase());
7
+ }
8
+
9
+ async function runAddTool() {
10
+ const toolName = process.argv[3];
11
+
12
+ if (!toolName) {
13
+ console.error("Usage: hive add-tool <name>");
14
+ process.exit(1);
15
+ }
16
+
17
+ const toolsDir = join(process.cwd(), "src", "tools");
18
+ const filePath = join(toolsDir, `${toolName}.ts`);
19
+
20
+ if (existsSync(filePath)) {
21
+ console.error(`Tool '${toolName}' already exists.`);
22
+ process.exit(1);
23
+ }
24
+
25
+ mkdirSync(toolsDir, { recursive: true });
26
+
27
+ const className = toPascalCase(toolName) + "Tool";
28
+
29
+ const content = `import { defineTool } from "@johpaz/hive-sdk";
30
+
31
+ export const ${toolName} = defineTool({
32
+ name: "${toolName}",
33
+ description: "Description of what ${toolName} does.",
34
+ execute: async (args: { input: string }) => {
35
+ // TODO: implement tool logic
36
+ return { result: args.input };
37
+ },
38
+ });
39
+ `;
40
+
41
+ writeFileSync(filePath, content);
42
+ console.log(`✅ Created tool: ${filePath}`);
43
+ }
44
+
45
+ runAddTool();