@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.
- package/CHANGELOG.md +27 -1
- package/README.md +179 -57
- package/docs/API-AGENTS.md +9 -9
- package/docs/API-CONTEXT-COMPILER.md +13 -13
- package/docs/API-DAG-SCHEDULER.md +8 -8
- package/docs/API-TOOLS-SKILLS-CHANNELS.md +150 -93
- package/docs/API-WORKERS-EVENTS.md +206 -59
- package/docs/INDEX.md +99 -50
- package/docs/README.md +117 -24
- package/docs/TEMPLATE-HIVE-APP.md +360 -0
- package/package.json +13 -6
- package/packages/cli/bin/hive +2 -0
- package/packages/cli/src/commands/add-skill.ts +42 -0
- package/packages/cli/src/commands/add-tool.ts +45 -0
- package/packages/cli/src/commands/add-worker.ts +49 -0
- package/packages/cli/src/commands/create-app-utils.ts +32 -0
- package/packages/cli/src/commands/create-app.test.ts +151 -0
- package/packages/cli/src/commands/create-app.ts +35 -0
- package/packages/cli/src/index.ts +21 -5
- package/packages/cli/templates/hive-app/.env.example +17 -0
- package/packages/cli/templates/hive-app/docker-compose.yml +20 -0
- package/packages/cli/templates/hive-app/hive.config.ts +19 -0
- package/packages/cli/templates/hive-app/package.json +16 -0
- package/packages/cli/templates/hive-app/src/agents/coordinator.ts +9 -0
- package/packages/cli/templates/hive-app/src/main.ts +56 -0
- package/packages/core/src/auth/auth.ts +108 -0
- package/packages/core/src/auth/index.ts +1 -0
- package/packages/core/src/canvas/canvas.test.ts +32 -0
- package/packages/core/src/canvas/emitter.ts +1 -1
- package/packages/core/src/canvas/index.ts +3 -6
- package/packages/core/src/channels/base.ts +154 -0
- package/packages/core/src/channels/channels.test.ts +18 -0
- package/packages/core/src/channels/discord.ts +273 -0
- package/packages/core/src/channels/index.ts +7 -0
- package/packages/core/src/channels/manager.ts +450 -0
- package/packages/core/src/channels/slack.ts +323 -0
- package/packages/core/src/channels/telegram.ts +612 -0
- package/packages/core/src/channels/webchat.ts +139 -0
- package/packages/core/src/channels/whatsapp.ts +548 -0
- package/packages/core/src/events/agent-bus.ts +460 -0
- package/packages/core/src/events/event-bus.ts +169 -0
- package/packages/core/src/gateway/channel-notify.ts +32 -7
- package/packages/core/src/gateway/gateway.test.ts +38 -0
- package/packages/core/src/gateway/index.ts +2 -1
- package/packages/core/src/gateway/server.ts +139 -0
- package/packages/core/src/heartbeat/index.ts +157 -0
- package/packages/core/src/index.ts +44 -0
- package/packages/core/src/multimodal/index.ts +2 -2
- package/packages/core/src/multimodal/vision-service.ts +283 -0
- package/packages/core/src/plugins/api.ts +128 -0
- package/packages/core/src/plugins/index.ts +2 -0
- package/packages/core/src/plugins/loader.ts +365 -0
- package/packages/core/src/resilience/circuit-breaker.ts +225 -0
- package/packages/core/src/scheduler/CronScheduler.ts +699 -0
- package/packages/core/src/scheduler/dag/AgentExecutor.ts +53 -0
- package/packages/core/src/scheduler/dag/DAGScheduler.ts +250 -0
- package/packages/core/src/scheduler/dag/EventBridge.ts +122 -0
- package/packages/core/src/scheduler/dag/TaskGraph.ts +192 -0
- package/packages/core/src/scheduler/dag/TaskNode.ts +97 -0
- package/packages/core/src/scheduler/dag/TaskResult.ts +22 -0
- package/packages/core/src/scheduler/dag/errors.ts +37 -0
- package/packages/core/src/scheduler/dag/index.ts +26 -0
- package/packages/core/src/scheduler/dag/presets/ResearchPreset.ts +97 -0
- package/packages/core/src/scheduler/dag/strategies/ParallelStrategy.ts +21 -0
- package/packages/core/src/scheduler/dag/strategies/PriorityStrategy.ts +46 -0
- package/packages/core/src/scheduler/index.ts +22 -0
- package/packages/core/src/scheduler/integration.ts +237 -0
- package/packages/core/src/scheduler/scheduler.test.ts +19 -0
- package/packages/core/src/scheduler/types.ts +164 -0
- package/packages/core/src/security/google-chat.ts +269 -0
- package/packages/core/src/security/index.ts +192 -4
- package/packages/core/src/security/rate-limit.ts +270 -0
- package/packages/core/src/security/signal.ts +321 -0
- package/packages/core/src/storage/crypto.ts +198 -66
- package/packages/core/src/storage/storage.test.ts +37 -0
- package/packages/core/src/swarm/swarm.test.ts +24 -0
- package/packages/core/src/tool-runtime/index.ts +522 -0
- package/packages/core/src/tool-runtime/tool-runtime.test.ts +91 -0
- package/packages/core/src/tool-runtime/tool-worker.ts +125 -0
- package/packages/core/src/voice/index.ts +5 -18
- package/packages/core/src/workers/WorkerPool.ts +167 -0
- package/packages/core/src/workers/agent.worker.ts +68 -0
- package/packages/core/src/workers/createWorker.ts +144 -0
- package/packages/core/src/workers/index.ts +5 -0
- package/packages/core/src/workers/workers.test.ts +48 -0
- package/test/setup-db.ts +2 -2
- package/tsconfig.json +2 -1
- package/.github/CODEOWNERS +0 -9
- package/.github/workflows/publish.yml +0 -89
- package/.github/workflows/version-bump.yml +0 -102
- package/bun.lock +0 -543
- package/bunfig.toml +0 -7
- package/packages/core/src/agent/providers.ts +0 -1
- package/packages/core/src/gateway/channel-notify.test.ts +0 -14
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,32 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.0.16] - 2026-05-28
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **Bun Workers individuales**: `createWorker()`, `WorkerPool`, `agent.worker.ts`
|
|
12
|
+
- Workers especializados con system prompt propio
|
|
13
|
+
- Ejecución en threads aislados via `Bun.Worker`
|
|
14
|
+
- Comunicación via `postMessage`/`onmessage`
|
|
15
|
+
- **Gateway simplificado**: HTTP/WebSocket server con `Bun.serve()`
|
|
16
|
+
- Endpoints: `/status`, `/chat`, `/ws`
|
|
17
|
+
- Streaming de respuestas en tiempo real
|
|
18
|
+
- **Channels**: Telegram, Discord, WhatsApp, Slack, Webchat
|
|
19
|
+
- **Tool Runtime**: Ejecución paralela de tools via Bun Workers
|
|
20
|
+
- **CLI mejorado**:
|
|
21
|
+
- `hive create-app <name>` — Generar app harness completa
|
|
22
|
+
- `hive add-tool <name>` — Generar boilerplate de tool
|
|
23
|
+
- `hive add-skill <name>` — Generar boilerplate de skill
|
|
24
|
+
- `hive add-worker <name>` — Generar Bun Worker
|
|
25
|
+
- **Template hive-app**: Proyecto harness completo con Docker, config, gateway
|
|
26
|
+
- **Tests del harness**: 39 tests pasando en 12 archivos
|
|
27
|
+
- Workers, Gateway, Channels, Canvas, Scheduler, Storage, Swarm, Tool Runtime
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
- API pública expandida: exports de gateway, channels, canvas, scheduler, tool-runtime, workers
|
|
31
|
+
- `package.json`: versión 0.0.16, descripción actualizada, bin `hive`
|
|
32
|
+
- Documentación actualizada en `docs/`
|
|
33
|
+
|
|
8
34
|
## [0.0.10] - 2026-05-02
|
|
9
35
|
|
|
10
36
|
### Added
|
|
@@ -35,4 +61,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
35
61
|
- Initial release
|
|
36
62
|
- Agent execution with LLM providers
|
|
37
63
|
- Basic tool and skill system
|
|
38
|
-
- Gateway server
|
|
64
|
+
- Gateway server
|
package/README.md
CHANGED
|
@@ -6,27 +6,73 @@
|
|
|
6
6
|
<img src="https://img.shields.io/badge/License-MIT-green?style=flat">
|
|
7
7
|
</p>
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
**The Hive Agent Harness SDK** — Build, deploy, and scale AI agent applications with multi-channel support, context engineering, and swarm orchestration.
|
|
10
|
+
|
|
11
|
+
> This Hive SDK powers the [Hive Harness](https://github.com/johpaz/hive). Use it to create your own harness instances without building everything from scratch.
|
|
12
|
+
|
|
13
|
+
---
|
|
10
14
|
|
|
11
15
|
## Paquetes
|
|
12
16
|
|
|
13
17
|
| Paquete | Descripción |
|
|
14
18
|
|---------|-------------|
|
|
15
|
-
| `@hive
|
|
16
|
-
| `@hive/cli` | CLI: `hive init`, `hive run`, `hive test`, `hive trace` |
|
|
19
|
+
| `@johpaz/hive-sdk` | Core SDK + CLI — agents, tools, skills, MCP, storage, swarm, gateway, channels |
|
|
17
20
|
|
|
18
21
|
## Instalación
|
|
19
22
|
|
|
20
23
|
```bash
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
# Install globally for the CLI
|
|
25
|
+
bun install -g @johpaz/hive-sdk
|
|
26
|
+
|
|
27
|
+
# Or in a project
|
|
28
|
+
bun add @johpaz/hive-sdk
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## CLI Commands
|
|
32
|
+
|
|
33
|
+
### Create a full harness application
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
hive create-app my-hive
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Generates a complete Hive harness with gateway, channels, and agent configuration.
|
|
40
|
+
|
|
41
|
+
### Create a lightweight agent project
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
hive init my-agent
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Add a tool to your project
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
cd my-hive
|
|
51
|
+
hive add-tool search-docs
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Add a skill to your project
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
cd my-hive
|
|
58
|
+
hive add-skill onboarding
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Run your agent
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
cd my-agent
|
|
65
|
+
hive run
|
|
24
66
|
```
|
|
25
67
|
|
|
26
|
-
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Inicio Rápido — Programmatic API
|
|
71
|
+
|
|
72
|
+
### Create an Agent
|
|
27
73
|
|
|
28
74
|
```typescript
|
|
29
|
-
import { createAgent, defineTool } from "@hive
|
|
75
|
+
import { createAgent, defineTool } from "@johpaz/hive-sdk";
|
|
30
76
|
|
|
31
77
|
const myTool = defineTool({
|
|
32
78
|
name: "saludar",
|
|
@@ -45,10 +91,32 @@ const respuesta = await agent.run("Saluda a Juan");
|
|
|
45
91
|
console.log(respuesta);
|
|
46
92
|
```
|
|
47
93
|
|
|
48
|
-
|
|
94
|
+
### Start a Gateway
|
|
49
95
|
|
|
50
96
|
```typescript
|
|
51
|
-
import {
|
|
97
|
+
import { startGateway, createAgent, initializeDatabase } from "@johpaz/hive-sdk";
|
|
98
|
+
|
|
99
|
+
await initializeDatabase();
|
|
100
|
+
|
|
101
|
+
const agent = await createAgent({
|
|
102
|
+
name: "coordinator",
|
|
103
|
+
provider: "openai",
|
|
104
|
+
model: "gpt-4o-mini",
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
const server = await startGateway({
|
|
108
|
+
host: "127.0.0.1",
|
|
109
|
+
port: 18790,
|
|
110
|
+
agentId: "coordinator",
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
console.log(`Gateway running at http://127.0.0.1:18790`);
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Create a Swarm (DAG)
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
import { DAGScheduler, TaskGraph } from "@johpaz/hive-sdk";
|
|
52
120
|
|
|
53
121
|
const graph = new TaskGraph([
|
|
54
122
|
{ id: "fetch", agentId: "fetcher", taskDescription: "Obtener datos", deps: [] },
|
|
@@ -59,100 +127,154 @@ const graph = new TaskGraph([
|
|
|
59
127
|
const result = await new DAGScheduler().execute(graph);
|
|
60
128
|
```
|
|
61
129
|
|
|
62
|
-
|
|
130
|
+
### Multi-Channel Bot
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
import { ChannelManager, TelegramChannel, DiscordChannel } from "@johpaz/hive-sdk";
|
|
134
|
+
|
|
135
|
+
const manager = new ChannelManager();
|
|
136
|
+
|
|
137
|
+
manager.register("telegram", new TelegramChannel({ botToken: process.env.TELEGRAM_BOT_TOKEN! }));
|
|
138
|
+
manager.register("discord", new DiscordChannel({ botToken: process.env.DISCORD_BOT_TOKEN! }));
|
|
139
|
+
|
|
140
|
+
await manager.startAll();
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Estructura del Proyecto (SDK)
|
|
63
146
|
|
|
64
147
|
```
|
|
65
148
|
hive-sdk/
|
|
66
149
|
├── packages/
|
|
67
|
-
│ ├── core/ # @hive
|
|
150
|
+
│ ├── core/ # @johpaz/hive-sdk core
|
|
68
151
|
│ │ └── src/
|
|
152
|
+
│ │ ├── api/ # createAgent(), Agent interface
|
|
69
153
|
│ │ ├── agent/ # AgentLoop, ContextCompiler, ConversationStore
|
|
70
154
|
│ │ │ ├── providers/ # LLM: OpenAI, Anthropic, Gemini, Ollama
|
|
71
155
|
│ │ │ └── selectors/ # FTS5: ToolSelector, SkillSelector, PlaybookSelector
|
|
72
|
-
│ │ ├── tools/ # ToolRegistry +
|
|
73
|
-
│ │ │ ├── filesystem/ web/ projects/ cron/ cli/ agents/
|
|
74
|
-
│ │ │ ├── canvas/ codebridge/ voice/ core/ office/ meeting/
|
|
75
|
-
│ │ │ ├── ToolRegistry.ts # defineTool()
|
|
76
|
-
│ │ │ └── ToolExecutor.ts
|
|
156
|
+
│ │ ├── tools/ # ToolRegistry + 70+ built-in tools
|
|
77
157
|
│ │ ├── skills/ # SkillLoader, defineSkill()
|
|
78
158
|
│ │ ├── swarm/ # DAGScheduler, TaskGraph, WorkerPool
|
|
79
|
-
│ │
|
|
80
|
-
│ │
|
|
159
|
+
│ │ ├── gateway/ # HTTP/WebSocket server (Bun.serve)
|
|
160
|
+
│ │ ├── channels/ # Telegram, Discord, WhatsApp, Slack, Webchat
|
|
81
161
|
│ │ ├── mcp/ # MCPClientManager, transports (SSE, WS)
|
|
82
162
|
│ │ ├── storage/ # SQLite (bun:sqlite) + FTS5
|
|
83
|
-
│ │ ├──
|
|
84
|
-
│ │ ├──
|
|
85
|
-
│ │ ├── memory/ # Scratchpad
|
|
163
|
+
│ │ ├── canvas/ # CanvasManager + A2UI emitter
|
|
164
|
+
│ │ ├── scheduler/ # CronScheduler + DAG execution
|
|
86
165
|
│ │ ├── ethics/ # EthicsGuard
|
|
166
|
+
│ │ ├── memory/ # Scratchpad
|
|
87
167
|
│ │ ├── config/ # loadConfig, loadEnv
|
|
88
168
|
│ │ ├── utils/ # logger, toon, crypto, retry
|
|
89
|
-
│ │ ├── api/ # createAgent()
|
|
90
169
|
│ │ └── index.ts # Public API barrel
|
|
91
170
|
│ │
|
|
92
|
-
│ └── cli/ #
|
|
171
|
+
│ └── cli/ # Hive CLI
|
|
93
172
|
│ └── src/
|
|
94
|
-
│ ├── index.ts # Entry: hive {init,run,test,trace}
|
|
95
|
-
│
|
|
96
|
-
│
|
|
97
|
-
│
|
|
98
|
-
│
|
|
99
|
-
│
|
|
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
|
|
100
192
|
│
|
|
101
193
|
├── test/ # Test helpers
|
|
102
|
-
|
|
103
|
-
│
|
|
104
|
-
├── docs/ # Documentación
|
|
194
|
+
├── docs/ # Documentation
|
|
105
195
|
├── tsconfig.json
|
|
106
196
|
└── package.json
|
|
107
197
|
```
|
|
108
198
|
|
|
199
|
+
---
|
|
200
|
+
|
|
109
201
|
## API Pública
|
|
110
202
|
|
|
111
203
|
```typescript
|
|
112
204
|
import {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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";
|
|
132
246
|
```
|
|
133
247
|
|
|
248
|
+
---
|
|
249
|
+
|
|
134
250
|
## Testing
|
|
135
251
|
|
|
136
252
|
```bash
|
|
137
|
-
#
|
|
253
|
+
# All tests
|
|
138
254
|
bun test packages/core/src/
|
|
139
255
|
|
|
140
|
-
# Tests
|
|
256
|
+
# Tests with timeout
|
|
141
257
|
bun test --timeout 30000
|
|
142
258
|
|
|
143
|
-
#
|
|
259
|
+
# Specific tests
|
|
144
260
|
bun test packages/core/src/tools/ToolRegistry.test.ts
|
|
145
261
|
```
|
|
146
262
|
|
|
263
|
+
---
|
|
264
|
+
|
|
147
265
|
## Variables de Entorno
|
|
148
266
|
|
|
149
267
|
```bash
|
|
150
268
|
HIVE_DATA_DIR=./data # Directorio de datos
|
|
269
|
+
HIVE_HOST=127.0.0.1 # Gateway host
|
|
270
|
+
HIVE_PORT=18790 # Gateway port
|
|
151
271
|
OPENAI_API_KEY=sk-... # OpenAI
|
|
152
272
|
ANTHROPIC_API_KEY=sk-ant-... # Anthropic
|
|
153
|
-
LOG_LEVEL=info
|
|
273
|
+
LOG_LEVEL=info # debug | info | warn | error
|
|
154
274
|
```
|
|
155
275
|
|
|
276
|
+
---
|
|
277
|
+
|
|
156
278
|
## Licencia
|
|
157
279
|
|
|
158
|
-
MIT © 2024 Anomaly Co.
|
|
280
|
+
MIT © 2024-2025 Anomaly Co. / @Johpaz
|
package/docs/API-AGENTS.md
CHANGED
|
@@ -17,7 +17,7 @@ Función de alto nivel para crear y ejecutar agentes.
|
|
|
17
17
|
### Firma
|
|
18
18
|
|
|
19
19
|
```typescript
|
|
20
|
-
import { createAgent } from "@hive
|
|
20
|
+
import { createAgent } from "@johpaz/hive-sdk";
|
|
21
21
|
|
|
22
22
|
const agent = await createAgent(config: AgentConfig): Promise<Agent>
|
|
23
23
|
```
|
|
@@ -77,7 +77,7 @@ type AgentEvent =
|
|
|
77
77
|
### Ejemplo
|
|
78
78
|
|
|
79
79
|
```typescript
|
|
80
|
-
import { createAgent, defineTool } from "@hive
|
|
80
|
+
import { createAgent, defineTool } from "@johpaz/hive-sdk";
|
|
81
81
|
|
|
82
82
|
const agent = await createAgent({
|
|
83
83
|
name: "asistente",
|
|
@@ -102,7 +102,7 @@ const respuesta = await agent.run("Analiza las ventas del mes");
|
|
|
102
102
|
Define una herramienta que el agente puede invocar.
|
|
103
103
|
|
|
104
104
|
```typescript
|
|
105
|
-
import { defineTool } from "@hive
|
|
105
|
+
import { defineTool } from "@johpaz/hive-sdk";
|
|
106
106
|
|
|
107
107
|
const tool = defineTool({
|
|
108
108
|
name: "saludar",
|
|
@@ -132,7 +132,7 @@ interface ToolDefinition {
|
|
|
132
132
|
Define una composición de herramientas con triggers semánticos.
|
|
133
133
|
|
|
134
134
|
```typescript
|
|
135
|
-
import { defineSkill } from "@hive
|
|
135
|
+
import { defineSkill } from "@johpaz/hive-sdk";
|
|
136
136
|
|
|
137
137
|
const skill = defineSkill({
|
|
138
138
|
name: "analisis-datos",
|
|
@@ -153,7 +153,7 @@ const skill = defineSkill({
|
|
|
153
153
|
Clase de bajo nivel para control directo del bucle del agente.
|
|
154
154
|
|
|
155
155
|
```typescript
|
|
156
|
-
import { AgentLoop, buildAgentLoop } from "@hive
|
|
156
|
+
import { AgentLoop, buildAgentLoop } from "@johpaz/hive-sdk";
|
|
157
157
|
|
|
158
158
|
const loop = buildAgentLoop({ mcpManager });
|
|
159
159
|
|
|
@@ -185,7 +185,7 @@ interface StreamChunk {
|
|
|
185
185
|
### runAgent (bajo nivel)
|
|
186
186
|
|
|
187
187
|
```typescript
|
|
188
|
-
import { runAgent, runAgentIsolated } from "@hive
|
|
188
|
+
import { runAgent, runAgentIsolated } from "@johpaz/hive-sdk";
|
|
189
189
|
|
|
190
190
|
// Streaming
|
|
191
191
|
for await (const chunk of runAgent({
|
|
@@ -211,7 +211,7 @@ const result = await runAgentIsolated({
|
|
|
211
211
|
Selección automática de tools basada en FTS5.
|
|
212
212
|
|
|
213
213
|
```typescript
|
|
214
|
-
import { selectTools, CORE_TOOL_CATALOG } from "@hive
|
|
214
|
+
import { selectTools, CORE_TOOL_CATALOG } from "@johpaz/hive-sdk";
|
|
215
215
|
|
|
216
216
|
// Seleccionar tools relevantes
|
|
217
217
|
const tools = selectTools("Buscar archivos en el proyecto");
|
|
@@ -251,7 +251,7 @@ const MIN_RELEVANCE_THRESHOLD = -30;
|
|
|
251
251
|
## Skill Selector
|
|
252
252
|
|
|
253
253
|
```typescript
|
|
254
|
-
import { selectSkills, getMinimalSkills } from "@hive
|
|
254
|
+
import { selectSkills, getMinimalSkills } from "@johpaz/hive-sdk";
|
|
255
255
|
|
|
256
256
|
// Skills según mensaje
|
|
257
257
|
const skills = selectSkills("Analyze the sales data");
|
|
@@ -276,7 +276,7 @@ const minimal = getMinimalSkills();
|
|
|
276
276
|
### callLLM
|
|
277
277
|
|
|
278
278
|
```typescript
|
|
279
|
-
import { callLLM, resolveProviderConfig } from "@hive
|
|
279
|
+
import { callLLM, resolveProviderConfig } from "@johpaz/hive-sdk";
|
|
280
280
|
|
|
281
281
|
const config = await resolveProviderConfig("openai", "gpt-4o-mini");
|
|
282
282
|
|
|
@@ -18,7 +18,7 @@ Compila todo el contexto necesario para cada ejecución del agente.
|
|
|
18
18
|
### compileContext
|
|
19
19
|
|
|
20
20
|
```typescript
|
|
21
|
-
import { compileContext } from "@hive
|
|
21
|
+
import { compileContext } from "@johpaz/hive-sdk";
|
|
22
22
|
|
|
23
23
|
const ctx = await compileContext({
|
|
24
24
|
agentId: "analyst",
|
|
@@ -52,7 +52,7 @@ El Context Compiler implementa 4 estrategias de Context Engineering:
|
|
|
52
52
|
### addMessage
|
|
53
53
|
|
|
54
54
|
```typescript
|
|
55
|
-
import { addMessage } from "@hive
|
|
55
|
+
import { addMessage } from "@johpaz/hive-sdk";
|
|
56
56
|
|
|
57
57
|
await addMessage(
|
|
58
58
|
threadId: string,
|
|
@@ -68,7 +68,7 @@ await addMessage(
|
|
|
68
68
|
### getRecentMessages
|
|
69
69
|
|
|
70
70
|
```typescript
|
|
71
|
-
import { getRecentMessages } from "@hive
|
|
71
|
+
import { getRecentMessages } from "@johpaz/hive-sdk";
|
|
72
72
|
|
|
73
73
|
const messages = await getRecentMessages(threadId, {
|
|
74
74
|
maxTokens: 32000,
|
|
@@ -81,7 +81,7 @@ const messages = await getRecentMessages(threadId, {
|
|
|
81
81
|
Reduce el historial cuando excede el límite de tokens.
|
|
82
82
|
|
|
83
83
|
```typescript
|
|
84
|
-
import { maybeCompact } from "@hive
|
|
84
|
+
import { maybeCompact } from "@johpaz/hive-sdk";
|
|
85
85
|
|
|
86
86
|
await maybeCompact(threadId, { channel: "slack", userId: "U123" });
|
|
87
87
|
```
|
|
@@ -89,7 +89,7 @@ await maybeCompact(threadId, { channel: "slack", userId: "U123" });
|
|
|
89
89
|
### clearOldToolResults
|
|
90
90
|
|
|
91
91
|
```typescript
|
|
92
|
-
import { clearOldToolResults } from "@hive
|
|
92
|
+
import { clearOldToolResults } from "@johpaz/hive-sdk";
|
|
93
93
|
|
|
94
94
|
const clean = clearOldToolResults(messages);
|
|
95
95
|
```
|
|
@@ -97,7 +97,7 @@ const clean = clearOldToolResults(messages);
|
|
|
97
97
|
### ConversationStore
|
|
98
98
|
|
|
99
99
|
```typescript
|
|
100
|
-
import { getSummary, saveSummary, getScratchpad, saveScratchpadNote } from "@hive
|
|
100
|
+
import { getSummary, saveSummary, getScratchpad, saveScratchpadNote } from "@johpaz/hive-sdk";
|
|
101
101
|
|
|
102
102
|
// Resumen de conversación
|
|
103
103
|
const summary = getSummary(threadId);
|
|
@@ -113,8 +113,8 @@ const notes = getScratchpad(threadId, "worker-1");
|
|
|
113
113
|
Memoria temporal por hilo de conversación.
|
|
114
114
|
|
|
115
115
|
```typescript
|
|
116
|
-
import { Scratchpad } from "@hive
|
|
117
|
-
import { getDb } from "@hive
|
|
116
|
+
import { Scratchpad } from "@johpaz/hive-sdk";
|
|
117
|
+
import { getDb } from "@johpaz/hive-sdk";
|
|
118
118
|
|
|
119
119
|
const db = getDb();
|
|
120
120
|
const pad = new Scratchpad(db);
|
|
@@ -142,8 +142,8 @@ pad.clear("thread-1");
|
|
|
142
142
|
Guardián de reglas de calidad de respuesta desde la base de datos.
|
|
143
143
|
|
|
144
144
|
```typescript
|
|
145
|
-
import { EthicsGuard } from "@hive
|
|
146
|
-
import { getDb } from "@hive
|
|
145
|
+
import { EthicsGuard } from "@johpaz/hive-sdk";
|
|
146
|
+
import { getDb } from "@johpaz/hive-sdk";
|
|
147
147
|
|
|
148
148
|
const db = getDb();
|
|
149
149
|
const guard = new EthicsGuard(db);
|
|
@@ -214,7 +214,7 @@ await runCurator();
|
|
|
214
214
|
### Config
|
|
215
215
|
|
|
216
216
|
```typescript
|
|
217
|
-
import type { MCPConfig, MCPServerConfig } from "@hive
|
|
217
|
+
import type { MCPConfig, MCPServerConfig } from "@johpaz/hive-sdk";
|
|
218
218
|
|
|
219
219
|
const config: MCPConfig = {
|
|
220
220
|
servers: {
|
|
@@ -232,7 +232,7 @@ const config: MCPConfig = {
|
|
|
232
232
|
### Singleton
|
|
233
233
|
|
|
234
234
|
```typescript
|
|
235
|
-
import { setMCPManager, getMCPManager, hasMCPManager } from "@hive
|
|
235
|
+
import { setMCPManager, getMCPManager, hasMCPManager } from "@johpaz/hive-sdk";
|
|
236
236
|
|
|
237
237
|
setMCPManager(mcpManager);
|
|
238
238
|
const mcp = getMCPManager(); // MCPClientManager | undefined
|
|
@@ -242,7 +242,7 @@ const exists = hasMCPManager(); // boolean
|
|
|
242
242
|
### Hot Reload
|
|
243
243
|
|
|
244
244
|
```typescript
|
|
245
|
-
import { startMCPHotReload, stopMCPHotReload } from "@hive
|
|
245
|
+
import { startMCPHotReload, stopMCPHotReload } from "@johpaz/hive-sdk";
|
|
246
246
|
|
|
247
247
|
// Watch de configuración MCP
|
|
248
248
|
startMCPHotReload();
|
|
@@ -35,7 +35,7 @@ Representa una tarea individual en el grafo.
|
|
|
35
35
|
### TaskNodeConfig
|
|
36
36
|
|
|
37
37
|
```typescript
|
|
38
|
-
import { TaskNode } from "@hive
|
|
38
|
+
import { TaskNode } from "@johpaz/hive-sdk";
|
|
39
39
|
|
|
40
40
|
interface TaskNodeConfig {
|
|
41
41
|
id: string;
|
|
@@ -76,7 +76,7 @@ node.markCompleted("datos obtenidos");
|
|
|
76
76
|
Grafo acíclico dirigido de tareas.
|
|
77
77
|
|
|
78
78
|
```typescript
|
|
79
|
-
import { TaskGraph } from "@hive
|
|
79
|
+
import { TaskGraph } from "@johpaz/hive-sdk";
|
|
80
80
|
|
|
81
81
|
const graph = new TaskGraph([
|
|
82
82
|
{ id: "a", agentId: "worker", taskDescription: "Tarea A", deps: [] },
|
|
@@ -109,7 +109,7 @@ const progress = graph.getProgress();
|
|
|
109
109
|
Orquestador principal de la ejecución.
|
|
110
110
|
|
|
111
111
|
```typescript
|
|
112
|
-
import { DAGScheduler, TaskGraph } from "@hive
|
|
112
|
+
import { DAGScheduler, TaskGraph } from "@johpaz/hive-sdk";
|
|
113
113
|
|
|
114
114
|
const graph = new TaskGraph([
|
|
115
115
|
{ id: "fetch", agentId: "fetcher", taskDescription: "Fetch data", deps: [] },
|
|
@@ -162,7 +162,7 @@ scheduler.abort(); // Abortar ejecución en curso
|
|
|
162
162
|
### ParallelStrategy (FIFO)
|
|
163
163
|
|
|
164
164
|
```typescript
|
|
165
|
-
import { ParallelStrategy } from "@hive
|
|
165
|
+
import { ParallelStrategy } from "@johpaz/hive-sdk";
|
|
166
166
|
|
|
167
167
|
const strategy = new ParallelStrategy(); // Orden de llegada
|
|
168
168
|
```
|
|
@@ -170,7 +170,7 @@ const strategy = new ParallelStrategy(); // Orden de llegada
|
|
|
170
170
|
### PriorityStrategy
|
|
171
171
|
|
|
172
172
|
```typescript
|
|
173
|
-
import { PriorityStrategy } from "@hive
|
|
173
|
+
import { PriorityStrategy } from "@johpaz/hive-sdk";
|
|
174
174
|
|
|
175
175
|
const strategy = new PriorityStrategy(); // Por prioridad + path crítico
|
|
176
176
|
```
|
|
@@ -178,7 +178,7 @@ const strategy = new PriorityStrategy(); // Por prioridad + path crítico
|
|
|
178
178
|
### Custom Strategy
|
|
179
179
|
|
|
180
180
|
```typescript
|
|
181
|
-
import type { ExecutionStrategy } from "@hive
|
|
181
|
+
import type { ExecutionStrategy } from "@johpaz/hive-sdk";
|
|
182
182
|
|
|
183
183
|
const myStrategy: ExecutionStrategy = {
|
|
184
184
|
initialize(nodes) { /* precomputar */ },
|
|
@@ -221,7 +221,7 @@ const graph = createHiveLearnGraph({
|
|
|
221
221
|
Puente de eventos entre el scheduler y el resto del sistema.
|
|
222
222
|
|
|
223
223
|
```typescript
|
|
224
|
-
import { EventBridge } from "@hive
|
|
224
|
+
import { EventBridge } from "@johpaz/hive-sdk";
|
|
225
225
|
|
|
226
226
|
const bridge = new EventBridge("swarm-123", "project-1", "coordinator-1");
|
|
227
227
|
|
|
@@ -239,7 +239,7 @@ bridge.onSwarmCompleted = (result) => {
|
|
|
239
239
|
## IAgentExecutor
|
|
240
240
|
|
|
241
241
|
```typescript
|
|
242
|
-
import type { IAgentExecutor } from "@hive
|
|
242
|
+
import type { IAgentExecutor } from "@johpaz/hive-sdk";
|
|
243
243
|
|
|
244
244
|
const myExecutor: IAgentExecutor = {
|
|
245
245
|
async execute(node, depResults, threadId) {
|