@johpaz/hive-sdk 0.0.17 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +83 -203
- package/bun.lock +833 -0
- package/bunfig.toml +7 -0
- package/docs/API-TOOLS-SKILLS-CHANNELS.md +60 -0
- package/docs/HIVE-HARNESS.md +113 -0
- package/package.json +36 -2
- package/packages/cli/package.json +1 -1
- package/packages/core/package.json +13 -2
- package/packages/core/src/ace/Tracer.ts +1 -1
- package/packages/core/src/agent/AgentRunner.ts +12 -0
- package/packages/core/src/agent/ContextCompiler.ts +4 -4
- package/packages/core/src/agent/ConversationStore.ts +30 -20
- package/packages/core/src/agent/selectors/PlaybookSelector.ts +50 -76
- package/packages/core/src/agent/selectors/SkillSelector.ts +106 -262
- package/packages/core/src/agent/selectors/ToolSelector.ts +54 -89
- package/packages/core/src/api/createAgent.ts +10 -0
- package/packages/core/src/auth/auth.ts +36 -23
- package/packages/core/src/config/loader.ts +2 -2
- package/packages/core/src/harness/boot-id.ts +20 -0
- package/packages/core/src/harness/collections.ts +98 -0
- package/packages/core/src/harness/db-helpers.ts +87 -0
- package/packages/core/src/harness/durable-queue.ts +337 -0
- package/packages/core/src/harness/goal-verifier.ts +141 -0
- package/packages/core/src/harness/harness.test.ts +236 -0
- package/packages/core/src/harness/index.ts +34 -0
- package/packages/core/src/harness/job-store.ts +399 -0
- package/packages/core/src/harness/proof-packet.ts +69 -0
- package/packages/core/src/harness/reconcile.ts +149 -0
- package/packages/core/src/harness/run-epoch.ts +32 -0
- package/packages/core/src/harness/run-store.ts +334 -0
- package/packages/core/src/index.ts +19 -0
- package/packages/core/src/memory/Scratchpad.test.ts +23 -21
- package/packages/core/src/memory/Scratchpad.ts +41 -24
- package/packages/core/src/skills/bundled-data.generated.ts +50 -0
- package/packages/core/src/skills/skills.test.ts +21 -0
- package/packages/core/src/storage/HiveDBStorage.ts +64 -0
- package/packages/core/src/storage/SQLiteStorage.ts +7 -0
- package/packages/core/src/storage/hiveSeed.ts +308 -0
- package/packages/core/src/storage/hiveStorage.test.ts +38 -0
- package/packages/core/src/storage/index.ts +10 -0
- package/packages/core/src/storage/seed.ts +5 -1
- package/packages/core/src/storage/usage.ts +106 -167
- package/packages/core/src/tool-runtime/tool-runtime.test.ts +11 -3
- package/packages/core/src/tools/agents/get-available-models.ts +52 -56
- package/packages/core/src/tools/agents/index.ts +77 -60
- package/packages/core/src/tools/core/index.ts +106 -291
- package/packages/core/src/tools/index.ts +1 -0
- package/packages/core/src/tools/meeting/index.ts +83 -93
- package/packages/core/src/tools/web/api-request.test.ts +170 -0
- package/packages/core/src/tools/web/api-request.ts +239 -0
- package/packages/core/src/tools/web/browser-click.ts +2 -2
- package/packages/core/src/tools/web/browser-extract.ts +22 -6
- package/packages/core/src/tools/web/browser-navigate.ts +34 -18
- package/packages/core/src/tools/web/browser-screenshot.ts +40 -8
- package/packages/core/src/tools/web/browser-script.ts +2 -2
- package/packages/core/src/tools/web/browser-service.test.ts +83 -0
- package/packages/core/src/tools/web/browser-service.ts +290 -341
- package/packages/core/src/tools/web/browser-type.ts +2 -2
- package/packages/core/src/tools/web/browser-wait.ts +2 -2
- package/packages/core/src/tools/web/index.ts +3 -0
- package/packages/core/src/utils/toon.ts +4 -4
- package/CHANGELOG.md +0 -72
- package/docs/README.md +0 -161
package/README.md
CHANGED
|
@@ -1,80 +1,74 @@
|
|
|
1
|
-
# Hive SDK
|
|
1
|
+
# Documentación — Hive SDK
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
<img src="https://img.shields.io/badge/Bun-v1.3.13-000000?style=flat&logo=bun" alt="Bun">
|
|
5
|
-
<img src="https://img.shields.io/badge/TypeScript-6.0-blue?style=flat&logo=typescript">
|
|
6
|
-
<img src="https://img.shields.io/badge/License-MIT-green?style=flat">
|
|
7
|
-
</p>
|
|
3
|
+
> **Hive Agent Harness SDK** — Build, deploy, and scale AI agent applications with multi-channel support, Bun Workers, and swarm orchestration.
|
|
8
4
|
|
|
9
|
-
|
|
5
|
+
## Documentos
|
|
10
6
|
|
|
11
|
-
|
|
7
|
+
| Documento | Descripción |
|
|
8
|
+
|-----------|-------------|
|
|
9
|
+
| [API-AGENTS.md](docs/API-AGENTS.md) | createAgent, AgentLoop, Tool/Skill Selector, LLM Providers |
|
|
10
|
+
| [API-DAG-SCHEDULER.md](docs/API-DAG-SCHEDULER.md) | DAGScheduler, TaskGraph, TaskNode, Estrategias, Presets |
|
|
11
|
+
| [API-WORKERS-EVENTS.md](docs/API-WORKERS-EVENTS.md) | **Bun Workers**, createWorker, WorkerPool, AgentBus, EventBus, Canvas |
|
|
12
|
+
| [API-TOOLS-SKILLS-CHANNELS.md](docs/API-TOOLS-SKILLS-CHANNELS.md) | Tools, Skills, MCP, **Gateway**, **Channels**, **Tool Runtime**, Storage |
|
|
13
|
+
| [API-CONTEXT-COMPILER.md](docs/API-CONTEXT-COMPILER.md) | Context Compiler, Message History, Scratchpad, EthicsGuard, ACE |
|
|
14
|
+
| [TEMPLATE-HIVE-APP.md](docs/TEMPLATE-HIVE-APP.md) | **Template hive-app** — estructura, opciones, personalización |
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
## ¿Qué es Hive SDK?
|
|
14
17
|
|
|
15
|
-
|
|
18
|
+
**Hive SDK es un Agent Harness**: un marco de trabajo completo para construir, desplegar y escalar aplicaciones de agentes de IA. A diferencia de un simple wrapper de LLM, un *harness* provee todo lo necesario para que un agente opere en producción:
|
|
16
19
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
- **Agentes**: ciclo ReAct, selección dinámica de tools/skills vía FTS5, múltiples providers (OpenAI, Anthropic, Gemini, Ollama).
|
|
21
|
+
- **Tools**: 70+ tools incluidas — filesystem, web search, browser automation (`agent-browser`), APIs (`api_request`), canvas, voz, office, cron.
|
|
22
|
+
- **Skills**: workflows reutilizables con `defineSkill` y `SkillLoader`.
|
|
23
|
+
- **Canales**: Telegram, Discord, WhatsApp, Slack y WebChat con `ChannelManager`.
|
|
24
|
+
- **Swarm**: orquestación multi-agente con `DAGScheduler`, `TaskGraph` y `WorkerPool`.
|
|
25
|
+
- **Runtime**: ejecución paralela de tools vía Bun Workers.
|
|
26
|
+
- **Gateway**: servidor HTTP/WebSocket para exponer agentes como API.
|
|
27
|
+
- **Memoria y estado**: SQLite + FTS5, scratchpad, context compiler.
|
|
28
|
+
|
|
29
|
+
Con Hive SDK no montas un agente desde cero: **enganchas tu lógica de negocio en un harness ya armado**.
|
|
20
30
|
|
|
21
31
|
## Instalación
|
|
22
32
|
|
|
23
33
|
```bash
|
|
24
|
-
#
|
|
34
|
+
# Instalar globalmente para el CLI
|
|
25
35
|
bun install -g @johpaz/hive-sdk
|
|
26
36
|
|
|
27
|
-
#
|
|
37
|
+
# O en un proyecto
|
|
28
38
|
bun add @johpaz/hive-sdk
|
|
29
39
|
```
|
|
30
40
|
|
|
31
41
|
## CLI Commands
|
|
32
42
|
|
|
33
|
-
### Create a full harness application
|
|
34
|
-
|
|
35
43
|
```bash
|
|
36
|
-
hives
|
|
44
|
+
hives init <name> # Inicializar proyecto agente
|
|
45
|
+
hives create-app <name> # Crear aplicación harness completa
|
|
46
|
+
hives add-tool <name> # Añadir tool
|
|
47
|
+
hives add-skill <name> # Añadir skill
|
|
48
|
+
hives add-worker <name> # Añadir Bun Worker
|
|
49
|
+
hives run # Ejecutar agente
|
|
50
|
+
hives test # Test tools/skills
|
|
51
|
+
hives trace # Ver logs de ejecución
|
|
37
52
|
```
|
|
38
53
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
### Create a lightweight agent project
|
|
54
|
+
## Inicio Rápido
|
|
42
55
|
|
|
43
|
-
|
|
44
|
-
hives init my-agent
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
### Add a tool to your project
|
|
48
|
-
|
|
49
|
-
```bash
|
|
50
|
-
cd my-hive
|
|
51
|
-
hives add-tool search-docs
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
### Add a skill to your project
|
|
56
|
+
### 1. Crear una app harness completa
|
|
55
57
|
|
|
56
58
|
```bash
|
|
59
|
+
hives create-app my-hive
|
|
57
60
|
cd my-hive
|
|
58
|
-
|
|
61
|
+
bun install
|
|
62
|
+
cp .env.example .env
|
|
63
|
+
bun run dev
|
|
59
64
|
```
|
|
60
65
|
|
|
61
|
-
###
|
|
62
|
-
|
|
63
|
-
```bash
|
|
64
|
-
cd my-agent
|
|
65
|
-
hives run
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
---
|
|
69
|
-
|
|
70
|
-
## Inicio Rápido — Programmatic API
|
|
71
|
-
|
|
72
|
-
### Create an Agent
|
|
66
|
+
### 2. Crear un agente simple
|
|
73
67
|
|
|
74
68
|
```typescript
|
|
75
69
|
import { createAgent, defineTool } from "@johpaz/hive-sdk";
|
|
76
70
|
|
|
77
|
-
const
|
|
71
|
+
const tool = defineTool({
|
|
78
72
|
name: "saludar",
|
|
79
73
|
description: "Saluda a alguien",
|
|
80
74
|
execute: async (args: { nombre: string }) => `¡Hola ${args.nombre}!`,
|
|
@@ -84,197 +78,83 @@ const agent = await createAgent({
|
|
|
84
78
|
name: "asistente",
|
|
85
79
|
provider: "openai",
|
|
86
80
|
model: "gpt-4o-mini",
|
|
87
|
-
tools: [
|
|
81
|
+
tools: [tool],
|
|
88
82
|
});
|
|
89
83
|
|
|
90
84
|
const respuesta = await agent.run("Saluda a Juan");
|
|
91
85
|
console.log(respuesta);
|
|
92
86
|
```
|
|
93
87
|
|
|
94
|
-
###
|
|
88
|
+
### 3. Crear un worker especializado
|
|
95
89
|
|
|
96
90
|
```typescript
|
|
97
|
-
import {
|
|
98
|
-
|
|
99
|
-
await initializeDatabase();
|
|
100
|
-
|
|
101
|
-
const agent = await createAgent({
|
|
102
|
-
name: "coordinator",
|
|
103
|
-
provider: "openai",
|
|
104
|
-
model: "gpt-4o-mini",
|
|
105
|
-
});
|
|
91
|
+
import { createWorker } from "@johpaz/hive-sdk";
|
|
106
92
|
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
agentId: "coordinator",
|
|
93
|
+
const researcher = createWorker({
|
|
94
|
+
name: "researcher",
|
|
95
|
+
systemPrompt: "You are a research specialist. Provide concise, factual summaries.",
|
|
111
96
|
});
|
|
112
97
|
|
|
113
|
-
|
|
98
|
+
const result = await researcher.run("Research quantum computing advances");
|
|
99
|
+
console.log(result);
|
|
100
|
+
researcher.terminate();
|
|
114
101
|
```
|
|
115
102
|
|
|
116
|
-
###
|
|
103
|
+
### 4. Ejecutar workers en paralelo
|
|
117
104
|
|
|
118
105
|
```typescript
|
|
119
|
-
import {
|
|
106
|
+
import { WorkerPool } from "@johpaz/hive-sdk";
|
|
120
107
|
|
|
121
|
-
const
|
|
122
|
-
{ id: "fetch", agentId: "fetcher", taskDescription: "Obtener datos", deps: [] },
|
|
123
|
-
{ id: "process", agentId: "processor", taskDescription: "Procesar", deps: ["fetch"] },
|
|
124
|
-
{ id: "report", agentId: "reporter", taskDescription: "Reportar", deps: ["process"] },
|
|
125
|
-
]);
|
|
108
|
+
const pool = new WorkerPool({ maxWorkers: 4 });
|
|
126
109
|
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
```typescript
|
|
133
|
-
import { ChannelManager, TelegramChannel, DiscordChannel } from "@johpaz/hive-sdk";
|
|
110
|
+
const tasks = [
|
|
111
|
+
{ id: "t1", message: "Summarize article A" },
|
|
112
|
+
{ id: "t2", message: "Summarize article B" },
|
|
113
|
+
{ id: "t3", message: "Summarize article C" },
|
|
114
|
+
];
|
|
134
115
|
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
manager.register("discord", new DiscordChannel({ botToken: process.env.DISCORD_BOT_TOKEN! }));
|
|
139
|
-
|
|
140
|
-
await manager.startAll();
|
|
116
|
+
const results = await pool.executeBatch(tasks);
|
|
117
|
+
console.log(results);
|
|
118
|
+
pool.shutdown();
|
|
141
119
|
```
|
|
142
120
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
## Estructura del Proyecto (SDK)
|
|
146
|
-
|
|
147
|
-
```
|
|
148
|
-
hive-sdk/
|
|
149
|
-
├── packages/
|
|
150
|
-
│ ├── core/ # @johpaz/hive-sdk core
|
|
151
|
-
│ │ └── src/
|
|
152
|
-
│ │ ├── api/ # createAgent(), Agent interface
|
|
153
|
-
│ │ ├── agent/ # AgentLoop, ContextCompiler, ConversationStore
|
|
154
|
-
│ │ │ ├── providers/ # LLM: OpenAI, Anthropic, Gemini, Ollama
|
|
155
|
-
│ │ │ └── selectors/ # FTS5: ToolSelector, SkillSelector, PlaybookSelector
|
|
156
|
-
│ │ ├── tools/ # ToolRegistry + 70+ built-in tools
|
|
157
|
-
│ │ ├── skills/ # SkillLoader, defineSkill()
|
|
158
|
-
│ │ ├── swarm/ # DAGScheduler, TaskGraph, WorkerPool
|
|
159
|
-
│ │ ├── gateway/ # HTTP/WebSocket server (Bun.serve)
|
|
160
|
-
│ │ ├── channels/ # Telegram, Discord, WhatsApp, Slack, Webchat
|
|
161
|
-
│ │ ├── mcp/ # MCPClientManager, transports (SSE, WS)
|
|
162
|
-
│ │ ├── storage/ # SQLite (bun:sqlite) + FTS5
|
|
163
|
-
│ │ ├── canvas/ # CanvasManager + A2UI emitter
|
|
164
|
-
│ │ ├── scheduler/ # CronScheduler + DAG execution
|
|
165
|
-
│ │ ├── ethics/ # EthicsGuard
|
|
166
|
-
│ │ ├── memory/ # Scratchpad
|
|
167
|
-
│ │ ├── config/ # loadConfig, loadEnv
|
|
168
|
-
│ │ ├── utils/ # logger, toon, crypto, retry
|
|
169
|
-
│ │ └── index.ts # Public API barrel
|
|
170
|
-
│ │
|
|
171
|
-
│ └── cli/ # Hive CLI
|
|
172
|
-
│ └── src/
|
|
173
|
-
│ ├── index.ts # Entry: hive {init,create-app,add-tool,add-skill,run,test,trace}
|
|
174
|
-
│ ├── commands/
|
|
175
|
-
│ │ ├── init.ts
|
|
176
|
-
│ │ ├── create-app.ts
|
|
177
|
-
│ │ ├── add-tool.ts
|
|
178
|
-
│ │ ├── add-skill.ts
|
|
179
|
-
│ │ ├── run.ts
|
|
180
|
-
│ │ ├── test.ts
|
|
181
|
-
│ │ └── trace.ts
|
|
182
|
-
│ └── templates/
|
|
183
|
-
│ └── hive-app/ # Full harness template
|
|
184
|
-
│ ├── package.json
|
|
185
|
-
│ ├── hive.config.ts
|
|
186
|
-
│ ├── docker-compose.yml
|
|
187
|
-
│ ├── .env.example
|
|
188
|
-
│ └── src/
|
|
189
|
-
│ ├── main.ts
|
|
190
|
-
│ └── agents/
|
|
191
|
-
│ └── coordinator.ts
|
|
192
|
-
│
|
|
193
|
-
├── test/ # Test helpers
|
|
194
|
-
├── docs/ # Documentation
|
|
195
|
-
├── tsconfig.json
|
|
196
|
-
└── package.json
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
---
|
|
200
|
-
|
|
201
|
-
## API Pública
|
|
121
|
+
### 5. Gateway HTTP/WebSocket
|
|
202
122
|
|
|
203
123
|
```typescript
|
|
204
|
-
import {
|
|
205
|
-
// Agent
|
|
206
|
-
createAgent,
|
|
207
|
-
defineTool,
|
|
208
|
-
defineSkill,
|
|
209
|
-
runAgent,
|
|
210
|
-
runAgentIsolated,
|
|
211
|
-
|
|
212
|
-
// Gateway
|
|
213
|
-
startGateway,
|
|
214
|
-
|
|
215
|
-
// Channels
|
|
216
|
-
ChannelManager,
|
|
217
|
-
TelegramChannel,
|
|
218
|
-
DiscordChannel,
|
|
219
|
-
WhatsAppChannel,
|
|
220
|
-
SlackChannel,
|
|
221
|
-
WebChatChannel,
|
|
222
|
-
|
|
223
|
-
// Swarm
|
|
224
|
-
DAGScheduler,
|
|
225
|
-
TaskGraph,
|
|
226
|
-
TaskNode,
|
|
227
|
-
|
|
228
|
-
// MCP
|
|
229
|
-
MCPClientManager,
|
|
230
|
-
|
|
231
|
-
// Tools
|
|
232
|
-
ToolRegistry,
|
|
233
|
-
ToolExecutor,
|
|
234
|
-
executeToolBatch,
|
|
235
|
-
|
|
236
|
-
// Storage
|
|
237
|
-
initializeDatabase,
|
|
238
|
-
|
|
239
|
-
// Config
|
|
240
|
-
loadConfig,
|
|
241
|
-
|
|
242
|
-
// Utils
|
|
243
|
-
logger,
|
|
244
|
-
retry,
|
|
245
|
-
} from "@johpaz/hive-sdk";
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
---
|
|
249
|
-
|
|
250
|
-
## Testing
|
|
124
|
+
import { startGateway } from "@johpaz/hive-sdk";
|
|
251
125
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
bun test --timeout 30000
|
|
126
|
+
const server = await startGateway({
|
|
127
|
+
host: "127.0.0.1",
|
|
128
|
+
port: 18790,
|
|
129
|
+
agentId: "coordinator",
|
|
130
|
+
});
|
|
258
131
|
|
|
259
|
-
|
|
260
|
-
bun test packages/core/src/tools/ToolRegistry.test.ts
|
|
132
|
+
console.log(`Gateway at http://127.0.0.1:18790`);
|
|
261
133
|
```
|
|
262
134
|
|
|
263
|
-
---
|
|
264
|
-
|
|
265
135
|
## Variables de Entorno
|
|
266
136
|
|
|
267
137
|
```bash
|
|
268
|
-
HIVE_DATA_DIR=./data # Directorio de datos
|
|
138
|
+
HIVE_DATA_DIR=./data # Directorio de datos SQLite
|
|
269
139
|
HIVE_HOST=127.0.0.1 # Gateway host
|
|
270
140
|
HIVE_PORT=18790 # Gateway port
|
|
271
141
|
OPENAI_API_KEY=sk-... # OpenAI
|
|
272
142
|
ANTHROPIC_API_KEY=sk-ant-... # Anthropic
|
|
143
|
+
GOOGLE_API_KEY=... # Gemini
|
|
273
144
|
LOG_LEVEL=info # debug | info | warn | error
|
|
274
145
|
```
|
|
275
146
|
|
|
276
|
-
|
|
147
|
+
## Tests
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# Todos los tests (paralelo)
|
|
151
|
+
bun test
|
|
152
|
+
|
|
153
|
+
# Tests con timeout extendido
|
|
154
|
+
bun test --timeout 60000
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
|
|
277
158
|
|
|
278
|
-
## Licencia
|
|
279
159
|
|
|
280
|
-
|
|
160
|
+
*Documentación Hive SDK v0.0.18*
|