@johpaz/hive 1.1.0
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/CONTRIBUTING.md +44 -0
- package/README.md +310 -0
- package/package.json +96 -0
- package/packages/cli/package.json +28 -0
- package/packages/cli/src/commands/agent-run.ts +168 -0
- package/packages/cli/src/commands/agents.ts +398 -0
- package/packages/cli/src/commands/chat.ts +142 -0
- package/packages/cli/src/commands/config.ts +50 -0
- package/packages/cli/src/commands/cron.ts +161 -0
- package/packages/cli/src/commands/dev.ts +95 -0
- package/packages/cli/src/commands/doctor.ts +133 -0
- package/packages/cli/src/commands/gateway.ts +443 -0
- package/packages/cli/src/commands/logs.ts +57 -0
- package/packages/cli/src/commands/mcp.ts +175 -0
- package/packages/cli/src/commands/message.ts +77 -0
- package/packages/cli/src/commands/onboard.ts +1868 -0
- package/packages/cli/src/commands/security.ts +144 -0
- package/packages/cli/src/commands/service.ts +50 -0
- package/packages/cli/src/commands/sessions.ts +116 -0
- package/packages/cli/src/commands/skills.ts +187 -0
- package/packages/cli/src/commands/update.ts +25 -0
- package/packages/cli/src/index.ts +185 -0
- package/packages/cli/src/utils/token.ts +6 -0
- package/packages/code-bridge/README.md +78 -0
- package/packages/code-bridge/package.json +18 -0
- package/packages/code-bridge/src/index.ts +95 -0
- package/packages/code-bridge/src/process-manager.ts +212 -0
- package/packages/code-bridge/src/schemas.ts +133 -0
- package/packages/core/package.json +46 -0
- package/packages/core/src/agent/agent-loop.ts +369 -0
- package/packages/core/src/agent/compaction.ts +140 -0
- package/packages/core/src/agent/context-compiler.ts +378 -0
- package/packages/core/src/agent/context-guard.ts +91 -0
- package/packages/core/src/agent/context.ts +138 -0
- package/packages/core/src/agent/conversation-store.ts +198 -0
- package/packages/core/src/agent/curator.ts +158 -0
- package/packages/core/src/agent/hooks.ts +166 -0
- package/packages/core/src/agent/index.ts +116 -0
- package/packages/core/src/agent/llm-client.ts +503 -0
- package/packages/core/src/agent/native-tools.ts +505 -0
- package/packages/core/src/agent/prompt-builder.ts +532 -0
- package/packages/core/src/agent/providers/index.ts +167 -0
- package/packages/core/src/agent/providers.ts +1 -0
- package/packages/core/src/agent/reflector.ts +170 -0
- package/packages/core/src/agent/service.ts +64 -0
- package/packages/core/src/agent/stuck-loop.ts +133 -0
- package/packages/core/src/agent/supervisor.ts +39 -0
- package/packages/core/src/agent/tracer.ts +102 -0
- package/packages/core/src/agent/workspace.ts +110 -0
- package/packages/core/src/canvas/canvas-manager.test.ts +161 -0
- package/packages/core/src/canvas/canvas-manager.ts +319 -0
- package/packages/core/src/canvas/canvas-tools.ts +420 -0
- package/packages/core/src/canvas/emitter.ts +115 -0
- package/packages/core/src/canvas/index.ts +2 -0
- package/packages/core/src/channels/base.ts +138 -0
- package/packages/core/src/channels/discord.ts +260 -0
- package/packages/core/src/channels/index.ts +7 -0
- package/packages/core/src/channels/manager.ts +383 -0
- package/packages/core/src/channels/slack.ts +287 -0
- package/packages/core/src/channels/telegram.ts +502 -0
- package/packages/core/src/channels/webchat.ts +128 -0
- package/packages/core/src/channels/whatsapp.ts +375 -0
- package/packages/core/src/config/index.ts +12 -0
- package/packages/core/src/config/loader.ts +529 -0
- package/packages/core/src/events/event-bus.ts +169 -0
- package/packages/core/src/gateway/index.ts +5 -0
- package/packages/core/src/gateway/initializer.ts +290 -0
- package/packages/core/src/gateway/lane-queue.ts +169 -0
- package/packages/core/src/gateway/resolver.ts +108 -0
- package/packages/core/src/gateway/router.ts +124 -0
- package/packages/core/src/gateway/server.ts +3317 -0
- package/packages/core/src/gateway/session.ts +95 -0
- package/packages/core/src/gateway/slash-commands.ts +192 -0
- package/packages/core/src/heartbeat/index.ts +157 -0
- package/packages/core/src/index.ts +19 -0
- package/packages/core/src/integrations/catalog.ts +286 -0
- package/packages/core/src/integrations/env.ts +64 -0
- package/packages/core/src/integrations/index.ts +2 -0
- package/packages/core/src/memory/index.ts +1 -0
- package/packages/core/src/memory/notes.ts +68 -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/security/google-chat.ts +269 -0
- package/packages/core/src/security/index.ts +192 -0
- package/packages/core/src/security/pairing.ts +250 -0
- package/packages/core/src/security/rate-limit.ts +270 -0
- package/packages/core/src/security/signal.ts +321 -0
- package/packages/core/src/state/store.ts +312 -0
- package/packages/core/src/storage/bun-sqlite-store.ts +188 -0
- package/packages/core/src/storage/crypto.ts +101 -0
- package/packages/core/src/storage/db-context.ts +333 -0
- package/packages/core/src/storage/onboarding.ts +1087 -0
- package/packages/core/src/storage/schema.ts +541 -0
- package/packages/core/src/storage/seed.ts +571 -0
- package/packages/core/src/storage/sqlite.ts +387 -0
- package/packages/core/src/storage/usage.ts +212 -0
- package/packages/core/src/tools/bridge-events.ts +74 -0
- package/packages/core/src/tools/browser.ts +275 -0
- package/packages/core/src/tools/codebridge.ts +421 -0
- package/packages/core/src/tools/coordinator-tools.ts +179 -0
- package/packages/core/src/tools/cron.ts +611 -0
- package/packages/core/src/tools/exec.ts +140 -0
- package/packages/core/src/tools/fs.ts +364 -0
- package/packages/core/src/tools/index.ts +12 -0
- package/packages/core/src/tools/memory.ts +176 -0
- package/packages/core/src/tools/notify.ts +113 -0
- package/packages/core/src/tools/project-management.ts +376 -0
- package/packages/core/src/tools/project.ts +375 -0
- package/packages/core/src/tools/read.ts +158 -0
- package/packages/core/src/tools/web.ts +436 -0
- package/packages/core/src/tools/workspace.ts +171 -0
- package/packages/core/src/utils/benchmark.ts +80 -0
- package/packages/core/src/utils/crypto.ts +73 -0
- package/packages/core/src/utils/date.ts +42 -0
- package/packages/core/src/utils/index.ts +4 -0
- package/packages/core/src/utils/logger.ts +388 -0
- package/packages/core/src/utils/retry.ts +70 -0
- package/packages/core/src/voice/index.ts +583 -0
- package/packages/core/tsconfig.json +9 -0
- package/packages/mcp/package.json +26 -0
- package/packages/mcp/src/config.ts +13 -0
- package/packages/mcp/src/index.ts +1 -0
- package/packages/mcp/src/logger.ts +42 -0
- package/packages/mcp/src/manager.ts +434 -0
- package/packages/mcp/src/transports/index.ts +67 -0
- package/packages/mcp/src/transports/sse.ts +241 -0
- package/packages/mcp/src/transports/websocket.ts +159 -0
- package/packages/skills/package.json +21 -0
- package/packages/skills/src/bundled/agent_management/SKILL.md +24 -0
- package/packages/skills/src/bundled/browser_automation/SKILL.md +30 -0
- package/packages/skills/src/bundled/context_compact/SKILL.md +35 -0
- package/packages/skills/src/bundled/cron_manager/SKILL.md +52 -0
- package/packages/skills/src/bundled/file_manager/SKILL.md +76 -0
- package/packages/skills/src/bundled/http_client/SKILL.md +24 -0
- package/packages/skills/src/bundled/memory/SKILL.md +42 -0
- package/packages/skills/src/bundled/project_management/SKILL.md +26 -0
- package/packages/skills/src/bundled/shell/SKILL.md +43 -0
- package/packages/skills/src/bundled/system_notify/SKILL.md +52 -0
- package/packages/skills/src/bundled/voice/SKILL.md +25 -0
- package/packages/skills/src/bundled/web_search/SKILL.md +29 -0
- package/packages/skills/src/index.ts +1 -0
- package/packages/skills/src/loader.ts +282 -0
- package/packages/tools/package.json +43 -0
- package/packages/tools/src/browser/browser.test.ts +111 -0
- package/packages/tools/src/browser/index.ts +272 -0
- package/packages/tools/src/canvas/index.ts +220 -0
- package/packages/tools/src/cron/cron.test.ts +164 -0
- package/packages/tools/src/cron/index.ts +304 -0
- package/packages/tools/src/filesystem/filesystem.test.ts +240 -0
- package/packages/tools/src/filesystem/index.ts +379 -0
- package/packages/tools/src/git/index.ts +239 -0
- package/packages/tools/src/index.ts +4 -0
- package/packages/tools/src/shell/detect-env.ts +70 -0
- package/packages/tools/tsconfig.json +9 -0
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
export type TransportType = "stdio" | "sse"
|
|
2
|
+
export type Category = "code" | "deploy" | "database" | "productivity"
|
|
3
|
+
|
|
4
|
+
export interface Integration {
|
|
5
|
+
id: string
|
|
6
|
+
name: string
|
|
7
|
+
description: string
|
|
8
|
+
example: string
|
|
9
|
+
category: Category
|
|
10
|
+
mcp: {
|
|
11
|
+
transport: TransportType
|
|
12
|
+
command?: string
|
|
13
|
+
args?: string[]
|
|
14
|
+
envVar?: string
|
|
15
|
+
envVarLabel?: string
|
|
16
|
+
url?: string
|
|
17
|
+
}
|
|
18
|
+
requires?: {
|
|
19
|
+
command: string
|
|
20
|
+
installHint: string
|
|
21
|
+
}
|
|
22
|
+
tokenInstructions: string
|
|
23
|
+
tokenValidation?: {
|
|
24
|
+
url: string
|
|
25
|
+
method?: "GET" | "POST"
|
|
26
|
+
headers: (token: string) => Record<string, string>
|
|
27
|
+
body?: (token: string) => string
|
|
28
|
+
getUsername: (response: any) => string
|
|
29
|
+
}
|
|
30
|
+
tokenFormat?: RegExp
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const INTEGRATIONS: Integration[] = [
|
|
34
|
+
|
|
35
|
+
// ── CÓDIGO ────────────────────────────────────────────────────────────
|
|
36
|
+
|
|
37
|
+
{
|
|
38
|
+
id: "github",
|
|
39
|
+
name: "GitHub",
|
|
40
|
+
description: "Repositorios y control de versiones",
|
|
41
|
+
example:
|
|
42
|
+
"Bee puede crear repositorios, guardar cambios, " +
|
|
43
|
+
"abrir pull requests y gestionar issues.",
|
|
44
|
+
category: "code",
|
|
45
|
+
mcp: {
|
|
46
|
+
transport: "stdio",
|
|
47
|
+
command: "npx",
|
|
48
|
+
args: ["-y", "@modelcontextprotocol/server-github"],
|
|
49
|
+
envVar: "GITHUB_TOKEN",
|
|
50
|
+
envVarLabel: "Token de GitHub",
|
|
51
|
+
},
|
|
52
|
+
tokenInstructions:
|
|
53
|
+
"1. Ve a github.com → tu foto → Settings\n" +
|
|
54
|
+
"2. Baja hasta Developer settings → Personal access tokens → Tokens (classic)\n" +
|
|
55
|
+
"3. Generate new token (classic)\n" +
|
|
56
|
+
"4. Marca: repo ✓ workflow ✓ read:org ✓\n" +
|
|
57
|
+
"5. Generate token → copiarlo aquí",
|
|
58
|
+
tokenValidation: {
|
|
59
|
+
url: "https://api.github.com/user",
|
|
60
|
+
headers: (t) => ({ Authorization: `Bearer ${t}` }),
|
|
61
|
+
getUsername: (r) => `@${r.login}`,
|
|
62
|
+
},
|
|
63
|
+
tokenFormat: /^(ghp_|github_pat_).{10,}/,
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
{
|
|
67
|
+
id: "gitlab",
|
|
68
|
+
name: "GitLab",
|
|
69
|
+
description: "Alternativa a GitHub para repositorios",
|
|
70
|
+
example:
|
|
71
|
+
"Igual que GitHub pero en GitLab. " +
|
|
72
|
+
"Ideal si tu empresa usa GitLab.",
|
|
73
|
+
category: "code",
|
|
74
|
+
mcp: {
|
|
75
|
+
transport: "stdio",
|
|
76
|
+
command: "npx",
|
|
77
|
+
args: ["-y", "@modelcontextprotocol/server-gitlab"],
|
|
78
|
+
envVar: "GITLAB_TOKEN",
|
|
79
|
+
envVarLabel: "Token de GitLab",
|
|
80
|
+
},
|
|
81
|
+
tokenInstructions:
|
|
82
|
+
"1. Ve a gitlab.com → tu avatar → Edit profile\n" +
|
|
83
|
+
"2. Access Tokens → Add new token\n" +
|
|
84
|
+
"3. Permisos: api ✓ read_user ✓ read_repository ✓\n" +
|
|
85
|
+
"4. Create personal access token → copiarlo aquí",
|
|
86
|
+
tokenValidation: {
|
|
87
|
+
url: "https://gitlab.com/api/v4/user",
|
|
88
|
+
headers: (t) => ({ "PRIVATE-TOKEN": t }),
|
|
89
|
+
getUsername: (r) => `@${r.username}`,
|
|
90
|
+
},
|
|
91
|
+
tokenFormat: /^glpat-.{10,}/,
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
// ── DEPLOY ────────────────────────────────────────────────────────────
|
|
95
|
+
|
|
96
|
+
{
|
|
97
|
+
id: "vercel",
|
|
98
|
+
name: "Vercel",
|
|
99
|
+
description: "Publicar sitios web en internet",
|
|
100
|
+
example:
|
|
101
|
+
"Bee puede publicar tu proyecto con un mensaje, " +
|
|
102
|
+
"ver el estado del sitio y revisar los logs.",
|
|
103
|
+
category: "deploy",
|
|
104
|
+
mcp: {
|
|
105
|
+
transport: "stdio",
|
|
106
|
+
command: "npx",
|
|
107
|
+
args: ["-y", "@vercel/mcp-adapter"],
|
|
108
|
+
envVar: "VERCEL_TOKEN",
|
|
109
|
+
envVarLabel: "Token de Vercel",
|
|
110
|
+
},
|
|
111
|
+
tokenInstructions:
|
|
112
|
+
"1. Ve a vercel.com → tu avatar → Settings → Tokens\n" +
|
|
113
|
+
"2. Create Token\n" +
|
|
114
|
+
"3. Nombre: 'hive', Scope: Full Account\n" +
|
|
115
|
+
"4. Copiarlo aquí",
|
|
116
|
+
tokenValidation: {
|
|
117
|
+
url: "https://api.vercel.com/v2/user",
|
|
118
|
+
headers: (t) => ({ Authorization: `Bearer ${t}` }),
|
|
119
|
+
getUsername: (r) => r.user?.email ?? "cuenta verificada",
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
|
|
123
|
+
{
|
|
124
|
+
id: "netlify",
|
|
125
|
+
name: "Netlify",
|
|
126
|
+
description: "Publicar sitios web (alternativa a Vercel)",
|
|
127
|
+
example:
|
|
128
|
+
"Bee puede crear proyectos en Netlify, hacer deployments " +
|
|
129
|
+
"y gestionar variables de entorno.",
|
|
130
|
+
category: "deploy",
|
|
131
|
+
mcp: {
|
|
132
|
+
transport: "stdio",
|
|
133
|
+
command: "npx",
|
|
134
|
+
args: ["-y", "@netlify/mcp"],
|
|
135
|
+
envVar: "NETLIFY_TOKEN",
|
|
136
|
+
envVarLabel: "Token de Netlify",
|
|
137
|
+
},
|
|
138
|
+
tokenInstructions:
|
|
139
|
+
"1. Ve a app.netlify.com → tu avatar → User settings\n" +
|
|
140
|
+
"2. Applications → Personal access tokens → New access token\n" +
|
|
141
|
+
"3. Descripción: 'hive' → copiarlo aquí",
|
|
142
|
+
tokenValidation: {
|
|
143
|
+
url: "https://api.netlify.com/api/v1/user",
|
|
144
|
+
headers: (t) => ({ Authorization: `Bearer ${t}` }),
|
|
145
|
+
getUsername: (r) => r.email ?? "cuenta verificada",
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
|
|
149
|
+
{
|
|
150
|
+
id: "railway",
|
|
151
|
+
name: "Railway",
|
|
152
|
+
description: "Desplegar aplicaciones y bases de datos en la nube",
|
|
153
|
+
example:
|
|
154
|
+
"Bee puede crear proyectos en Railway, hacer deployments " +
|
|
155
|
+
"y gestionar variables de entorno de tus servicios.",
|
|
156
|
+
category: "deploy",
|
|
157
|
+
mcp: {
|
|
158
|
+
transport: "stdio",
|
|
159
|
+
command: "npx",
|
|
160
|
+
args: ["-y", "@railway/mcp-server"],
|
|
161
|
+
envVar: "RAILWAY_TOKEN",
|
|
162
|
+
envVarLabel: "Token de Railway",
|
|
163
|
+
},
|
|
164
|
+
requires: {
|
|
165
|
+
command: "railway",
|
|
166
|
+
installHint:
|
|
167
|
+
"Railway requiere su CLI instalado en tu sistema.\n" +
|
|
168
|
+
"Instálalo con: npm install -g @railway/cli\n" +
|
|
169
|
+
"Luego: railway login",
|
|
170
|
+
},
|
|
171
|
+
tokenInstructions:
|
|
172
|
+
"1. Ve a railway.app → tu avatar → Account Settings → Tokens\n" +
|
|
173
|
+
"2. Create Token → nombre: 'hive'\n" +
|
|
174
|
+
"3. Copiarlo aquí\n\n" +
|
|
175
|
+
"⚠️ También necesitas el Railway CLI:\n" +
|
|
176
|
+
" npm install -g @railway/cli\n" +
|
|
177
|
+
" railway login",
|
|
178
|
+
tokenValidation: {
|
|
179
|
+
url: "https://backboard.railway.app/graphql/v2",
|
|
180
|
+
method: "POST",
|
|
181
|
+
headers: (t) => ({
|
|
182
|
+
Authorization: `Bearer ${t}`,
|
|
183
|
+
"Content-Type": "application/json",
|
|
184
|
+
}),
|
|
185
|
+
body: () => JSON.stringify({ query: "{ me { email } }" }),
|
|
186
|
+
getUsername: (r) => r.data?.me?.email ?? "cuenta verificada",
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
|
|
190
|
+
// ── DATABASE ──────────────────────────────────────────────────────────
|
|
191
|
+
|
|
192
|
+
{
|
|
193
|
+
id: "supabase",
|
|
194
|
+
name: "Supabase",
|
|
195
|
+
description: "Base de datos para tus aplicaciones",
|
|
196
|
+
example:
|
|
197
|
+
"Bee puede crear tablas, consultar datos y gestionar " +
|
|
198
|
+
"la autenticación de usuarios en Supabase.",
|
|
199
|
+
category: "database",
|
|
200
|
+
mcp: {
|
|
201
|
+
transport: "stdio",
|
|
202
|
+
command: "npx",
|
|
203
|
+
args: ["-y", "@supabase/mcp-server-supabase"],
|
|
204
|
+
envVar: "SUPABASE_ACCESS_TOKEN",
|
|
205
|
+
envVarLabel: "Token de Supabase",
|
|
206
|
+
},
|
|
207
|
+
tokenInstructions:
|
|
208
|
+
"1. Ve a supabase.com → tu avatar → Account → Access Tokens\n" +
|
|
209
|
+
"2. Generate new token → nombre: 'hive'\n" +
|
|
210
|
+
"3. Copiarlo aquí",
|
|
211
|
+
tokenValidation: {
|
|
212
|
+
url: "https://api.supabase.com/v1/projects",
|
|
213
|
+
headers: (t) => ({ Authorization: `Bearer ${t}` }),
|
|
214
|
+
getUsername: (_r) => "cuenta verificada",
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
|
|
218
|
+
// ── PRODUCTIVIDAD ─────────────────────────────────────────────────────
|
|
219
|
+
|
|
220
|
+
{
|
|
221
|
+
id: "notion",
|
|
222
|
+
name: "Notion",
|
|
223
|
+
description: "Documentos, wikis y bases de conocimiento",
|
|
224
|
+
example:
|
|
225
|
+
"Bee puede crear páginas, actualizar documentos " +
|
|
226
|
+
"y leer tu base de conocimiento en Notion.",
|
|
227
|
+
category: "productivity",
|
|
228
|
+
mcp: {
|
|
229
|
+
transport: "stdio",
|
|
230
|
+
command: "npx",
|
|
231
|
+
args: ["-y", "@notionhq/notion-mcp-server"],
|
|
232
|
+
envVar: "NOTION_API_TOKEN",
|
|
233
|
+
envVarLabel: "Token de Notion",
|
|
234
|
+
},
|
|
235
|
+
tokenInstructions:
|
|
236
|
+
"1. Ve a notion.so/my-integrations\n" +
|
|
237
|
+
"2. New integration → nombre: 'hive'\n" +
|
|
238
|
+
"3. Permisos: Read ✓ Update ✓ Insert ✓\n" +
|
|
239
|
+
"4. Submit → copiar 'Internal Integration Token'\n\n" +
|
|
240
|
+
"⚠️ Para cada página que quieras que Bee lea:\n" +
|
|
241
|
+
" Abre la página → '...' → Connections → 'hive'",
|
|
242
|
+
tokenValidation: {
|
|
243
|
+
url: "https://api.notion.com/v1/users/me",
|
|
244
|
+
headers: (t) => ({
|
|
245
|
+
Authorization: `Bearer ${t}`,
|
|
246
|
+
"Notion-Version": "2022-06-28",
|
|
247
|
+
}),
|
|
248
|
+
getUsername: (r) => r.name ?? "bot verificado",
|
|
249
|
+
},
|
|
250
|
+
tokenFormat: /^secret_.{40,}/,
|
|
251
|
+
},
|
|
252
|
+
|
|
253
|
+
{
|
|
254
|
+
id: "linear",
|
|
255
|
+
name: "Linear",
|
|
256
|
+
description: "Gestión de tareas y proyectos de desarrollo",
|
|
257
|
+
example:
|
|
258
|
+
"Bee puede crear issues, actualizar tareas y hacer " +
|
|
259
|
+
"seguimiento del progreso en Linear.",
|
|
260
|
+
category: "productivity",
|
|
261
|
+
mcp: {
|
|
262
|
+
transport: "sse",
|
|
263
|
+
url: "https://mcp.linear.app/sse",
|
|
264
|
+
},
|
|
265
|
+
tokenInstructions:
|
|
266
|
+
"Linear usa autenticación automática (OAuth).\n" +
|
|
267
|
+
"No necesitas copiar ningún token.\n" +
|
|
268
|
+
"Cuando Bee use Linear por primera vez, te pedirá\n" +
|
|
269
|
+
"que autorices el acceso desde tu navegador.",
|
|
270
|
+
},
|
|
271
|
+
|
|
272
|
+
]
|
|
273
|
+
|
|
274
|
+
export function getIntegration(id: string): Integration | undefined {
|
|
275
|
+
return INTEGRATIONS.find(i => i.id === id)
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
export function getIntegrationsByCategory(): Map<Category, Integration[]> {
|
|
279
|
+
const map = new Map<Category, Integration[]>()
|
|
280
|
+
for (const i of INTEGRATIONS) {
|
|
281
|
+
const list = map.get(i.category) ?? []
|
|
282
|
+
list.push(i)
|
|
283
|
+
map.set(i.category, list)
|
|
284
|
+
}
|
|
285
|
+
return map
|
|
286
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import * as fs from "node:fs"
|
|
2
|
+
import * as path from "node:path"
|
|
3
|
+
|
|
4
|
+
const ENV_PATH = path.join(process.env.HOME ?? "~", ".hive", ".env")
|
|
5
|
+
|
|
6
|
+
export function saveToken(key: string, value: string): void {
|
|
7
|
+
let content = ""
|
|
8
|
+
|
|
9
|
+
if (fs.existsSync(ENV_PATH)) {
|
|
10
|
+
content = fs.readFileSync(ENV_PATH, "utf-8")
|
|
11
|
+
if (new RegExp(`^${key}=`, "m").test(content)) {
|
|
12
|
+
content = content.replace(new RegExp(`^${key}=.*$`, "m"), `${key}=${value}`)
|
|
13
|
+
fs.writeFileSync(ENV_PATH, content)
|
|
14
|
+
fs.chmodSync(ENV_PATH, 0o600)
|
|
15
|
+
return
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
fs.mkdirSync(path.dirname(ENV_PATH), { recursive: true })
|
|
20
|
+
fs.appendFileSync(ENV_PATH, `${key}=${value}\n`)
|
|
21
|
+
fs.chmodSync(ENV_PATH, 0o600)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function removeToken(key: string): void {
|
|
25
|
+
if (!fs.existsSync(ENV_PATH)) return
|
|
26
|
+
const content = fs.readFileSync(ENV_PATH, "utf-8")
|
|
27
|
+
const updated = content
|
|
28
|
+
.split("\n")
|
|
29
|
+
.filter(line => !line.startsWith(`${key}=`))
|
|
30
|
+
.join("\n")
|
|
31
|
+
fs.writeFileSync(ENV_PATH, updated)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function loadHiveEnv(): Record<string, string> {
|
|
35
|
+
const loaded: Record<string, string> = {}
|
|
36
|
+
if (!fs.existsSync(ENV_PATH)) return loaded
|
|
37
|
+
|
|
38
|
+
for (const line of fs.readFileSync(ENV_PATH, "utf-8").split("\n")) {
|
|
39
|
+
const trimmed = line.trim()
|
|
40
|
+
if (!trimmed || trimmed.startsWith("#")) continue
|
|
41
|
+
const eq = trimmed.indexOf("=")
|
|
42
|
+
if (eq === -1) continue
|
|
43
|
+
const key = trimmed.slice(0, eq).trim()
|
|
44
|
+
const value = trimmed.slice(eq + 1).trim()
|
|
45
|
+
if (key && value && !process.env[key]) {
|
|
46
|
+
process.env[key] = value
|
|
47
|
+
loaded[key] = value
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return loaded
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function resolveEnvVars(obj: Record<string, string>): Record<string, string> {
|
|
54
|
+
return Object.fromEntries(
|
|
55
|
+
Object.entries(obj).map(([k, v]) => [
|
|
56
|
+
k,
|
|
57
|
+
v.replace(/\$\{(\w+)\}/g, (_, name) => process.env[name] ?? ""),
|
|
58
|
+
])
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function getEnvPath(): string {
|
|
63
|
+
return ENV_PATH
|
|
64
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./notes.ts";
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Config } from "../config/loader.ts";
|
|
2
|
+
import { logger } from "../utils/logger.ts";
|
|
3
|
+
import { dbService } from "../storage/sqlite.ts";
|
|
4
|
+
|
|
5
|
+
export interface Note {
|
|
6
|
+
title: string;
|
|
7
|
+
content: string;
|
|
8
|
+
createdAt: Date;
|
|
9
|
+
updatedAt: Date;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class MemoryStore {
|
|
13
|
+
private log = logger.child("memory");
|
|
14
|
+
|
|
15
|
+
constructor(config: Config) {
|
|
16
|
+
// Configuration can remain unused as sqlite db handles path resolution
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
write(title: string, content: string): Note {
|
|
20
|
+
const row = dbService.writeNote(title, content);
|
|
21
|
+
this.log.debug(`Wrote note: ${title}`);
|
|
22
|
+
return {
|
|
23
|
+
title: row.title,
|
|
24
|
+
content: row.content,
|
|
25
|
+
createdAt: new Date(row.createdAt),
|
|
26
|
+
updatedAt: new Date(row.updatedAt)
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
read(title: string): Note | null {
|
|
31
|
+
const row = dbService.readNote(title);
|
|
32
|
+
if (!row) return null;
|
|
33
|
+
return {
|
|
34
|
+
title: row.title,
|
|
35
|
+
content: row.content,
|
|
36
|
+
createdAt: new Date(row.createdAt),
|
|
37
|
+
updatedAt: new Date(row.updatedAt)
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
list(): Array<{ title: string; path: string }> {
|
|
42
|
+
return dbService.listNotes().map(row => ({
|
|
43
|
+
title: row.title,
|
|
44
|
+
path: `sqlite://notes/${row.id}`
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
delete(title: string): boolean {
|
|
49
|
+
const deleted = dbService.deleteNote(title);
|
|
50
|
+
if (deleted) {
|
|
51
|
+
this.log.debug(`Deleted note: ${title}`);
|
|
52
|
+
}
|
|
53
|
+
return deleted;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
search(query: string): Note[] {
|
|
57
|
+
return dbService.searchNotes(query).map(row => ({
|
|
58
|
+
title: row.title,
|
|
59
|
+
content: row.content,
|
|
60
|
+
createdAt: new Date(row.createdAt),
|
|
61
|
+
updatedAt: new Date(row.updatedAt)
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function createMemoryStore(config: Config): MemoryStore {
|
|
67
|
+
return new MemoryStore(config);
|
|
68
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import type { Logger, ChildLogger } from "../utils/logger.ts";
|
|
2
|
+
import type { eventBus, EventMap, EventKey } from "../events/event-bus.ts";
|
|
3
|
+
import type { StateStore } from "../state/store.ts";
|
|
4
|
+
|
|
5
|
+
export interface PluginManifest {
|
|
6
|
+
name: string;
|
|
7
|
+
version: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
author?: string;
|
|
10
|
+
dependencies?: string[];
|
|
11
|
+
hiveVersion?: string;
|
|
12
|
+
main?: string;
|
|
13
|
+
enabled?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ToolDefinition {
|
|
17
|
+
name: string;
|
|
18
|
+
description: string;
|
|
19
|
+
parameters: Record<string, ParameterDefinition>;
|
|
20
|
+
execute: (args: Record<string, unknown>) => Promise<unknown>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface ParameterDefinition {
|
|
24
|
+
type: "string" | "number" | "boolean" | "object" | "array";
|
|
25
|
+
description?: string;
|
|
26
|
+
required?: boolean;
|
|
27
|
+
default?: unknown;
|
|
28
|
+
enum?: string[];
|
|
29
|
+
items?: ParameterDefinition;
|
|
30
|
+
properties?: Record<string, ParameterDefinition>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface ChannelDefinition {
|
|
34
|
+
name: string;
|
|
35
|
+
type: string;
|
|
36
|
+
config: Record<string, unknown>;
|
|
37
|
+
start: () => Promise<void>;
|
|
38
|
+
stop: () => Promise<void>;
|
|
39
|
+
send: (sessionId: string, message: unknown) => Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface CLICommand {
|
|
43
|
+
name: string;
|
|
44
|
+
description: string;
|
|
45
|
+
handler: (args: string[], options: Record<string, unknown>) => Promise<void>;
|
|
46
|
+
options?: Record<string, CommandOption>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface CommandOption {
|
|
50
|
+
alias?: string;
|
|
51
|
+
description?: string;
|
|
52
|
+
type?: "string" | "boolean" | "number";
|
|
53
|
+
default?: unknown;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface PluginContext {
|
|
57
|
+
pluginName: string;
|
|
58
|
+
logger: ChildLogger;
|
|
59
|
+
config: Record<string, unknown>;
|
|
60
|
+
registerTool: (tool: ToolDefinition) => void;
|
|
61
|
+
unregisterTool: (name: string) => void;
|
|
62
|
+
registerChannel: (channel: ChannelDefinition) => void;
|
|
63
|
+
unregisterChannel: (name: string) => void;
|
|
64
|
+
registerCommand: (command: CLICommand) => void;
|
|
65
|
+
unregisterCommand: (name: string) => void;
|
|
66
|
+
events: {
|
|
67
|
+
emit: <K extends EventKey>(event: K, data: EventMap[K]) => void;
|
|
68
|
+
on: <K extends EventKey>(event: K, handler: (data: EventMap[K]) => void | Promise<void>) => () => void;
|
|
69
|
+
once: <K extends EventKey>(event: K, handler: (data: EventMap[K]) => void | Promise<void>) => void;
|
|
70
|
+
};
|
|
71
|
+
state: {
|
|
72
|
+
get: () => ReturnType<StateStore["getState"]>;
|
|
73
|
+
subscribe: (listener: (state: ReturnType<StateStore["getState"]>) => void) => () => void;
|
|
74
|
+
};
|
|
75
|
+
getTool: (name: string) => ToolDefinition | undefined;
|
|
76
|
+
getTools: () => ToolDefinition[];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface InboundMessage {
|
|
80
|
+
sessionId: string;
|
|
81
|
+
channel: string;
|
|
82
|
+
userId: string;
|
|
83
|
+
content: string;
|
|
84
|
+
timestamp: number;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface AgentResponse {
|
|
88
|
+
sessionId: string;
|
|
89
|
+
content: string;
|
|
90
|
+
toolsUsed: string[];
|
|
91
|
+
duration: number;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface PluginToolCall {
|
|
95
|
+
name: string;
|
|
96
|
+
args: Record<string, unknown>;
|
|
97
|
+
sessionId: string;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export type MiddlewareNext = () => Promise<void>;
|
|
101
|
+
export type MiddlewareResult = Promise<void>;
|
|
102
|
+
|
|
103
|
+
export interface HivePlugin {
|
|
104
|
+
name: string;
|
|
105
|
+
version: string;
|
|
106
|
+
dependencies?: string[];
|
|
107
|
+
manifest?: PluginManifest;
|
|
108
|
+
|
|
109
|
+
activate(context: PluginContext): Promise<void>;
|
|
110
|
+
deactivate(): Promise<void>;
|
|
111
|
+
|
|
112
|
+
onMessage?: (message: InboundMessage, next: MiddlewareNext) => MiddlewareResult;
|
|
113
|
+
onAgentResponse?: (response: AgentResponse, next: MiddlewareNext) => MiddlewareResult;
|
|
114
|
+
onToolCall?: (call: PluginToolCall, next: () => Promise<unknown>) => Promise<unknown>;
|
|
115
|
+
onError?: (error: Error, context: Record<string, unknown>) => Promise<void>;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface PluginState {
|
|
119
|
+
name: string;
|
|
120
|
+
status: "inactive" | "activating" | "active" | "deactivating" | "error";
|
|
121
|
+
version: string;
|
|
122
|
+
enabled: boolean;
|
|
123
|
+
error?: string;
|
|
124
|
+
loadedAt?: number;
|
|
125
|
+
activatedAt?: number;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export type PluginConstructor = new () => HivePlugin;
|