@johpaz/hive-agents 1.0.5 → 1.1.1
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 +17 -11
- package/dist/hive.js +87295 -101789
- package/dist/tool-worker.js +13241 -17001
- package/dist/ui/assets/A2UIPage-F1sUdZV7.js +8 -0
- package/dist/ui/assets/{AgentCreateForm-Bcp3HN8D.js → AgentCreateForm-CN5Gb9UN.js} +1 -1
- package/dist/ui/assets/AgentDetailPage-CzBnoKtH.js +1 -0
- package/dist/ui/assets/AgentNewPage-AGDjfAVf.js +1 -0
- package/dist/ui/assets/AgentsPage-BgKr7pAZ.js +10 -0
- package/dist/ui/assets/{ApiClientPage-DHfIlSAg.js → ApiClientPage-Dq4nPse4.js} +2 -2
- package/dist/ui/assets/ChannelsPage-BuWItmp-.js +8 -0
- package/dist/ui/assets/DashboardPage-CB1aM87o.js +6 -0
- package/dist/ui/assets/{LoginPage-BaX6cAPa.js → LoginPage-DBvwBCG6.js} +1 -1
- package/dist/ui/assets/LogsPage-Bc-oTBwY.js +1 -0
- package/dist/ui/assets/MeetingPage-C2H5SxaQ.js +1 -0
- package/dist/ui/assets/ModelSelector-D0aJvoD9.js +1 -0
- package/dist/ui/assets/NotFound-PUg3gEO0.js +1 -0
- package/dist/ui/assets/{Office3DPage-C3SIzd2H.css → Office3DPage-31AMJ-LN.css} +1 -1
- package/dist/ui/assets/Office3DPage-D5vwZkJa.js +727 -0
- package/dist/ui/assets/ProvidersPage-BBBt4Hcz.js +1 -0
- package/dist/ui/assets/{RecoverPage-C_Id9WM-.js → RecoverPage-nq901JiE.js} +1 -1
- package/dist/ui/assets/SettingsPage-DQ5KZPAd.js +9 -0
- package/dist/ui/assets/SetupPage-DeIGn-Uf.js +1 -0
- package/dist/ui/assets/{Vignette-Cyi27LQH.js → Vignette-BcPWkNhm.js} +17 -17
- package/dist/ui/assets/VoicePage-DJYsOsaU.js +307 -0
- package/dist/ui/assets/WebChatPage-CRDN4OlP.js +29 -0
- package/dist/ui/assets/agentCapabilities-PfTEVxG1.js +1 -0
- package/dist/ui/assets/alert-CjiX20jI.js +1 -0
- package/dist/ui/assets/badge-B5AKge1b.js +1 -0
- package/dist/ui/assets/card-mTJ4oZbL.js +1 -0
- package/dist/ui/assets/conversationsStore-BIs0iMhp.js +1 -0
- package/dist/ui/assets/dialog-DdbsUCv9.js +1 -0
- package/dist/ui/assets/dist-js-Dh18rcg9.js +1 -0
- package/dist/ui/assets/{dist-js-Bg0g3vPS.js → dist-js-q7C_AB0j.js} +1 -1
- package/dist/ui/assets/index-BD7hBA1d.css +2 -0
- package/dist/ui/assets/index-CpzwBwPg.js +116 -0
- package/dist/ui/assets/label-D_fvqJyD.js +1 -0
- package/dist/ui/assets/lock-3IApZyVy.js +1 -0
- package/dist/ui/assets/pencil-L3Li7_pz.js +1 -0
- package/dist/ui/assets/scroll-area-CbH8FOo8.js +1 -0
- package/dist/ui/assets/select-v_3QBYrD.js +1 -0
- package/dist/ui/assets/slider-DXS4h1LB.js +1 -0
- package/dist/ui/assets/switch-ndx8VCpm.js +1 -0
- package/dist/ui/assets/tabs-epu-3Tl4.js +1 -0
- package/dist/ui/assets/textarea-BgZJFZTX.js +1 -0
- package/dist/ui/assets/useAudioDevices-yU-wu-kt.js +41 -0
- package/dist/ui/assets/{useHiveAgentsModelLoad-CHmtvNp4.js → useHiveAgentsModelLoad-29pOYRd9.js} +1 -1
- package/dist/ui/assets/useOfficeModel-BaDn7U-X.js +1 -0
- package/dist/ui/assets/{useProviders-C7FA6z4M.js → useProviders-CiBi4Dt6.js} +1 -1
- package/dist/ui/assets/vendor-react-kUOwxn0g.js +1 -0
- package/dist/ui/index.html +6 -6
- package/package.json +10 -6
- package/packages/cli/src/adapters/config.ts +11 -3
- package/packages/cli/src/commands/causal.ts +1 -1
- package/packages/cli/src/commands/doctor.ts +2 -2
- package/packages/cli/src/commands/onboard.ts +1 -1
- package/packages/core/src/agent/acceptance-checks.ts +25 -0
- package/packages/core/src/agent/agent-catalog.ts +53 -33
- package/packages/core/src/agent/agent-loop.ts +67 -14
- package/packages/core/src/agent/capability-search.ts +2 -1
- package/packages/core/src/agent/compaction.ts +19 -7
- package/packages/core/src/agent/context-compiler.ts +165 -27
- package/packages/core/src/agent/conversation-store.ts +12 -1
- package/packages/core/src/agent/goal-runner.ts +2 -2
- package/packages/core/src/agent/jev-decisions.ts +242 -0
- package/packages/core/src/agent/jev-planner.ts +293 -0
- package/packages/core/src/agent/llm-client.ts +27 -5
- package/packages/core/src/agent/llm-providers/ollama.ts +17 -4
- package/packages/core/src/agent/llm-providers/openai-compat-base.ts +27 -12
- package/packages/core/src/agent/llm-providers/opencode-go.ts +37 -0
- package/packages/core/src/agent/realtime-providers/gemini-live.ts +5 -2
- package/packages/core/src/agent/skill-selector.ts +4 -2
- package/packages/core/src/agent/thread-id.ts +71 -0
- package/packages/core/src/agent/thread-store.ts +230 -0
- package/packages/core/src/agent/tool-selector.ts +42 -0
- package/packages/core/src/agent/tracer.ts +2 -0
- package/packages/core/src/canvas/canvas-manager.ts +17 -1
- package/packages/core/src/canvas/emitter.ts +24 -0
- package/packages/core/src/channels/telegram.ts +19 -1
- package/packages/core/src/channels/webchat.ts +47 -45
- package/packages/core/src/config/loader.ts +3 -2
- package/packages/core/src/gateway/channel-notify.ts +24 -5
- package/packages/core/src/gateway/delegation-groups.ts +3 -3
- package/packages/core/src/gateway/delegation-notify.ts +34 -5
- package/packages/core/src/gateway/durable-queue.ts +22 -0
- package/packages/core/src/gateway/failure-notify.ts +8 -2
- package/packages/core/src/gateway/job-executors.ts +3 -3
- package/packages/core/src/gateway/realtime/bridge-tools.ts +106 -28
- package/packages/core/src/gateway/realtime/index.ts +63 -7
- package/packages/core/src/gateway/realtime/prompt.ts +45 -0
- package/packages/core/src/gateway/realtime/voice-session.ts +1 -0
- package/packages/core/src/gateway/resolver.ts +31 -4
- package/packages/core/src/gateway/routes/artifacts.ts +13 -0
- package/packages/core/src/gateway/routes/chat.ts +20 -4
- package/packages/core/src/gateway/routes/conversations.ts +121 -0
- package/packages/core/src/gateway/routes/providers.ts +15 -0
- package/packages/core/src/gateway/routes/setup.ts +22 -11
- package/packages/core/src/gateway/routes/system.ts +4 -2
- package/packages/core/src/gateway/routes/tts-local.ts +2 -1
- package/packages/core/src/gateway/server.ts +85 -12
- package/packages/core/src/gateway/slash-commands.ts +46 -10
- package/packages/core/src/gateway/tts/src/server.ts +2 -1
- package/packages/core/src/gateway/webchat-turn.ts +68 -10
- package/packages/core/src/index.ts +2 -0
- package/packages/core/src/scheduler/CronScheduler.ts +20 -8
- package/packages/core/src/scheduler/cron/cron-engine.test.ts +295 -0
- package/packages/core/src/scheduler/cron/expression.ts +165 -0
- package/packages/core/src/scheduler/cron/index.ts +10 -0
- package/packages/core/src/scheduler/cron/job.ts +340 -0
- package/packages/core/src/scheduler/cron/next-run.ts +121 -0
- package/packages/core/src/scheduler/cron/zoned-time.ts +139 -0
- package/packages/core/src/scheduler/integration.ts +16 -5
- package/packages/core/src/scheduler/types.ts +3 -18
- package/packages/core/src/storage/bootstrap.ts +24 -1
- package/packages/core/src/storage/collections.ts +29 -1
- package/packages/core/src/storage/crypto.ts +133 -40
- package/packages/core/src/storage/reconcile.ts +6 -1
- package/packages/core/src/storage/seed.ts +101 -7
- package/packages/core/src/storage/usage.ts +53 -1
- package/packages/core/src/tool-runtime/index.ts +19 -1
- package/packages/core/src/tools/a2ui/index.ts +65 -1
- package/packages/core/src/tools/agents/get-available-models.ts +3 -1
- package/packages/core/src/tools/code-agent/adapters.ts +110 -0
- package/packages/core/src/tools/code-agent/index.ts +193 -0
- package/packages/core/src/tools/core/index.ts +39 -4
- package/packages/core/src/tools/cron/index.ts +4 -4
- package/packages/core/src/tools/index.ts +9 -1
- package/packages/core/src/tools/office/office-escribir-xlsx.ts +2 -1
- package/packages/core/src/tools/office/office-leer-xlsx.ts +2 -1
- package/packages/core/src/tools/office/xlsx-loader.ts +19 -0
- package/packages/core/src/tools/web/browser-backend.ts +22 -2
- package/packages/core/src/tools/web/index.ts +4 -0
- package/packages/core/src/tools/web/obscura.ts +860 -0
- package/packages/core/src/tools/web/webview-backend.ts +168 -26
- package/packages/core/src/utils/port.ts +33 -0
- package/packages/core/src/voice/index.ts +2 -1
- package/packages/mcp/src/config.ts +2 -1
- package/packages/mcp/src/manager.ts +9 -0
- package/packages/mcp/src/transports/index.ts +42 -1
- package/packages/mcp/src/transports/sse.ts +11 -5
- package/packages/skills/src/bundled/a2ui/a2ui_dashboard/SKILL.md +2 -2
- package/packages/skills/src/bundled/a2ui/a2ui_form/SKILL.md +2 -2
- package/packages/skills/src/bundled/a2ui/a2ui_interactive/SKILL.md +4 -4
- package/packages/skills/src/bundled/agents/agent_spawner/SKILL.md +7 -7
- package/packages/skills/src/bundled/agents/memory_manager/SKILL.md +9 -9
- package/packages/skills/src/bundled/agents/research_and_remember/SKILL.md +8 -8
- package/packages/skills/src/bundled/agents/task_orchestrator/SKILL.md +8 -8
- package/packages/skills/src/bundled/artifacts/artifact_reader/SKILL.md +104 -0
- package/packages/skills/src/bundled/cli/cli_pipeline/SKILL.md +6 -6
- package/packages/skills/src/bundled/cli/cli_safe_exec/SKILL.md +5 -5
- package/packages/skills/src/bundled/cli/external_code_agent/SKILL.md +69 -0
- package/packages/skills/src/bundled/cron_manager/SKILL.md +29 -19
- package/packages/skills/src/bundled/cron_reminder/SKILL.md +5 -5
- package/packages/skills/src/bundled/filesystem/file_manager/SKILL.md +4 -4
- package/packages/skills/src/bundled/filesystem/file_read_and_summarize/SKILL.md +7 -7
- package/packages/skills/src/bundled/filesystem/file_writer/SKILL.md +10 -10
- package/packages/skills/src/bundled/search_knowledge/capability_discovery/SKILL.md +8 -8
- package/packages/skills/src/bundled/web/browser_automate/SKILL.md +21 -12
- package/packages/skills/src/bundled/web/browser_scrape/SKILL.md +28 -13
- package/packages/skills/src/bundled/web/obscura_browser/SKILL.md +69 -0
- package/packages/skills/src/bundled/web/web_monitor/SKILL.md +6 -6
- package/packages/skills/src/bundled/web/web_research/SKILL.md +5 -5
- package/packages/skills/src/bundled-data.generated.ts +845 -773
- package/dist/ui/assets/A2UIPage-DTW79pyL.js +0 -8
- package/dist/ui/assets/AgentDetailPage-10XptMde.js +0 -1
- package/dist/ui/assets/AgentNewPage-CUt49rVS.js +0 -1
- package/dist/ui/assets/AgentsPage-1_e1a9xa.js +0 -10
- package/dist/ui/assets/ChannelsPage-BnCQAGZL.js +0 -8
- package/dist/ui/assets/DashboardPage-BsCCKHgg.js +0 -6
- package/dist/ui/assets/LogsPage-DiFBQt7o.js +0 -1
- package/dist/ui/assets/MeetingPage-Bpv5zVXf.js +0 -1
- package/dist/ui/assets/ModelSelector-DfExlPzx.js +0 -1
- package/dist/ui/assets/NotFound-C8HBdF73.js +0 -1
- package/dist/ui/assets/Office3DPage-ChsGMapf.js +0 -319
- package/dist/ui/assets/ProvidersPage-B39pfWHf.js +0 -1
- package/dist/ui/assets/SettingsPage-BgFqasyg.js +0 -9
- package/dist/ui/assets/SetupPage-YeJFfgbt.js +0 -1
- package/dist/ui/assets/VoicePage-Cp63Abj4.js +0 -307
- package/dist/ui/assets/WebChatPage-DxFLWgtM.js +0 -29
- package/dist/ui/assets/agentCapabilities-DOeepCty.js +0 -1
- package/dist/ui/assets/alert-Cj4DpKv6.js +0 -1
- package/dist/ui/assets/badge-DKpeVCpY.js +0 -1
- package/dist/ui/assets/card-Cag15G4h.js +0 -1
- package/dist/ui/assets/dialog-7E3EoEt3.js +0 -1
- package/dist/ui/assets/dist-js-DwLn9F4C.js +0 -1
- package/dist/ui/assets/index-Bi8qEmrK.js +0 -116
- package/dist/ui/assets/index-D2UhaSb0.css +0 -2
- package/dist/ui/assets/label-C6atPuIh.js +0 -1
- package/dist/ui/assets/pencil-CUbpCfeG.js +0 -1
- package/dist/ui/assets/scroll-area-CSoG2z53.js +0 -1
- package/dist/ui/assets/select-DlCT21_r.js +0 -1
- package/dist/ui/assets/slider-Bb_PHFJT.js +0 -1
- package/dist/ui/assets/switch-CUsGuBNi.js +0 -1
- package/dist/ui/assets/tabs-Ckfc7DGG.js +0 -1
- package/dist/ui/assets/textarea-BH6pI9Ax.js +0 -1
- package/dist/ui/assets/useAudioDevices-Dpr_hn6i.js +0 -41
- package/dist/ui/assets/useOfficeModel-Cc5VkReZ.js +0 -1
- package/dist/ui/assets/vendor-react-DYyYpuMy.js +0 -1
- /package/dist/ui/assets/{core-Dz04EE_8.js → core-B_5cyOSV.js} +0 -0
- /package/dist/ui/assets/{download-D0aDV8Y_.js → download-BQXrpH0m.js} +0 -0
- /package/dist/ui/assets/{ellipsis-vertical-BOW_iEOO.js → ellipsis-vertical-D7uFJLGh.js} +0 -0
- /package/dist/ui/assets/{external-link-5cujQzfV.js → external-link-6oTH9pUM.js} +0 -0
- /package/dist/ui/assets/{eye-sRPY5qOa.js → eye-CxvxtQT5.js} +0 -0
- /package/dist/ui/assets/{file-text-DNSyNLUh.js → file-text-D5ZJEx3E.js} +0 -0
- /package/dist/ui/assets/{gateway-url-BzQV75Ig.js → gateway-url-BALS_wVh.js} +0 -0
- /package/dist/ui/assets/{gauge-C__zxC3_.js → gauge-CEu7PhTW.js} +0 -0
- /package/dist/ui/assets/{history-BHQWfE-7.js → history-DLK5rTlP.js} +0 -0
- /package/dist/ui/assets/{info-CG1VohyH.js → info-8ReWzubE.js} +0 -0
- /package/dist/ui/assets/{key-BC28VCjO.js → key-DPkOY-J0.js} +0 -0
- /package/dist/ui/assets/{lock-open-Bhp0UJlL.js → lock-open-v0EphssG.js} +0 -0
- /package/dist/ui/assets/{mail-Biwn8WrV.js → mail-vwCEHyhQ.js} +0 -0
- /package/dist/ui/assets/{mic-Rq4BxU1R.js → mic-CpDU_2as.js} +0 -0
- /package/dist/ui/assets/{pause-C2l5G2Py.js → pause-Cm9LzIZK.js} +0 -0
- /package/dist/ui/assets/{play-CMAscR3a.js → play-zqogwA2l.js} +0 -0
- /package/dist/ui/assets/{plus-DzvRxH4U.js → plus-Bm08ABhc.js} +0 -0
- /package/dist/ui/assets/{radio-DfGzov4y.js → radio-Cii1BjMt.js} +0 -0
- /package/dist/ui/assets/{refresh-cw-DZXu5FrG.js → refresh-cw-DXv3XgEt.js} +0 -0
- /package/dist/ui/assets/{rotate-ccw-Dx92orJM.js → rotate-ccw-LoM1AuqK.js} +0 -0
- /package/dist/ui/assets/{search-DB4w9YHW.js → search-BMwCI-pX.js} +0 -0
- /package/dist/ui/assets/{send-xi8HzUdc.js → send-D6fgWV7m.js} +0 -0
- /package/dist/ui/assets/{settings-pV0cF8Kf.js → settings-qV3kVkeG.js} +0 -0
- /package/dist/ui/assets/{shield-nLNsomh_.js → shield-CIarwBvx.js} +0 -0
- /package/dist/ui/assets/{sparkles-CerRDYxk.js → sparkles-DVvY6jDT.js} +0 -0
- /package/dist/ui/assets/{square-CcWzRWyG.js → square-D5zdNkAY.js} +0 -0
- /package/dist/ui/assets/{terminal-C2SUZUAD.js → terminal-BEcTK780.js} +0 -0
- /package/dist/ui/assets/{trash-2-BZsMCfso.js → trash-2-D6oziYAK.js} +0 -0
- /package/dist/ui/assets/{utils-lc8H6VGT.js → utils-DEmd_M8c.js} +0 -0
- /package/dist/ui/assets/{vendor-router-DCsSv_I7.js → vendor-router-DP84b3LQ.js} +0 -0
- /package/dist/ui/assets/{volume-2-CBMYsuF3.js → volume-2-EaA0JRvD.js} +0 -0
- /package/dist/ui/assets/{volume-x-vNFf2e4-.js → volume-x-CROXNMGT.js} +0 -0
- /package/dist/ui/assets/{wifi-DNv53AfN.js → wifi-BUJuOcgP.js} +0 -0
- /package/dist/ui/assets/{zap-Yed86Sh8.js → zap-DSoX9NDk.js} +0 -0
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
import { getHiveDb, getOpenHiveDb } from "./hivedb";
|
|
15
15
|
import { col } from "./hive";
|
|
16
16
|
import { seedAllData } from "./seed";
|
|
17
|
+
import { ensureLegacyThread } from "../agent/thread-store";
|
|
17
18
|
import { ensureSecretsBackend } from "./crypto";
|
|
18
19
|
|
|
19
20
|
interface IndexSpec {
|
|
@@ -60,6 +61,9 @@ const INDEXES: IndexSpec[] = [
|
|
|
60
61
|
{ collection: "traces", field: "success" },
|
|
61
62
|
{ collection: "playbook", field: "active" },
|
|
62
63
|
{ collection: "playbook", field: "category" },
|
|
64
|
+
{ collection: "conversationThreads", field: "user_id" },
|
|
65
|
+
{ collection: "conversationThreads", field: "channel" },
|
|
66
|
+
{ collection: "conversationThreads", field: "archived" },
|
|
63
67
|
// Stage 5 — scheduler
|
|
64
68
|
{ collection: "cronJobs", field: "status" },
|
|
65
69
|
{ collection: "cronJobs", field: "task_type" },
|
|
@@ -128,6 +132,23 @@ async function ensureSeedData(): Promise<void> {
|
|
|
128
132
|
// tests or long-running processes open a fresh instance in the same runtime.
|
|
129
133
|
let bootstrappedDb: Awaited<ReturnType<typeof getHiveDb>> | null = null;
|
|
130
134
|
|
|
135
|
+
/**
|
|
136
|
+
* Antes de la separación por canal todos los canales compartían un solo hilo cuyo
|
|
137
|
+
* `thread_id` era el `userId`. Esa conversación se registra —sin mover un solo
|
|
138
|
+
* mensaje— como una conversación más de la web, para que siga siendo legible desde
|
|
139
|
+
* la lista. Idempotente: no hace nada si ya está registrada o si no hay historial.
|
|
140
|
+
*/
|
|
141
|
+
async function ensureLegacyThreads(): Promise<void> {
|
|
142
|
+
try {
|
|
143
|
+
const users = await col<{ id: string }>("users");
|
|
144
|
+
for (const user of await users.scan({})) {
|
|
145
|
+
await ensureLegacyThread(user.id);
|
|
146
|
+
}
|
|
147
|
+
} catch {
|
|
148
|
+
// Base sin usuarios todavía (onboarding pendiente) — nada que registrar.
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
131
152
|
/**
|
|
132
153
|
* Idempotent entry point: opens the database, ensures indexes, reseeds the
|
|
133
154
|
* static catalogs, and records the schema version. Safe to call on every
|
|
@@ -139,9 +160,11 @@ export async function ensureHiveDb(): Promise<void> {
|
|
|
139
160
|
// Mint the master key before anything can save an API key, so a fresh
|
|
140
161
|
// install is durable from the first keystroke rather than after a restart
|
|
141
162
|
// has already dropped the secret.
|
|
142
|
-
ensureSecretsBackend();
|
|
163
|
+
await ensureSecretsBackend();
|
|
143
164
|
await ensureSeedData();
|
|
144
165
|
|
|
166
|
+
await ensureLegacyThreads();
|
|
167
|
+
|
|
145
168
|
const meta = await col<{ value: number }>("meta");
|
|
146
169
|
const existing = await meta.get("schemaVersion");
|
|
147
170
|
if (!existing) await meta.put("schemaVersion", { value: 1 }, { expectedVersion: 0 });
|
|
@@ -41,7 +41,7 @@ export interface ModelDoc {
|
|
|
41
41
|
provider_id: string
|
|
42
42
|
name: string
|
|
43
43
|
/** "realtime": voz full-duplex (Live API), no confundir con stt+tts encadenados. */
|
|
44
|
-
model_type: "llm" | "stt" | "tts" | "vision" | "embedding" | "realtime"
|
|
44
|
+
model_type: "llm" | "stt" | "tts" | "vision" | "embedding" | "realtime" | "decision"
|
|
45
45
|
context_window: number
|
|
46
46
|
capabilities: string | null
|
|
47
47
|
enabled: boolean
|
|
@@ -307,6 +307,28 @@ export interface SummaryDoc {
|
|
|
307
307
|
last_message_id: string | null
|
|
308
308
|
}
|
|
309
309
|
|
|
310
|
+
/**
|
|
311
|
+
* Una conversación: el registro de un `conversations.thread_id`, con lo necesario
|
|
312
|
+
* para listarla en la web sin escanear los mensajes. `id` ES el threadId
|
|
313
|
+
* (`${user}/${canal}/${peer}` — ver agent/thread-id.ts), salvo la fila del hilo
|
|
314
|
+
* legacy anterior a la separación por canal, cuyo id es el userId pelado.
|
|
315
|
+
*/
|
|
316
|
+
export interface ConversationThreadDoc {
|
|
317
|
+
id: string
|
|
318
|
+
user_id: string
|
|
319
|
+
channel: string
|
|
320
|
+
/** Contacto/grupo del canal, o el id de conversación en la web. */
|
|
321
|
+
peer_id: string
|
|
322
|
+
peer_kind: "direct" | "group"
|
|
323
|
+
/** null hasta el primer mensaje del usuario, de donde se deriva. */
|
|
324
|
+
title: string | null
|
|
325
|
+
/** Borrado suave: sigue en la base pero no se lista ni se reabre. */
|
|
326
|
+
archived: boolean
|
|
327
|
+
created_at: number
|
|
328
|
+
last_message_at: number
|
|
329
|
+
message_count: number
|
|
330
|
+
}
|
|
331
|
+
|
|
310
332
|
export interface TraceDoc {
|
|
311
333
|
id: string
|
|
312
334
|
thread_id: string
|
|
@@ -682,6 +704,12 @@ export interface UsageRollupDoc {
|
|
|
682
704
|
toonJsonBytes: number
|
|
683
705
|
byProvider: Record<string, { inputTokens: number; outputTokens: number; costUsd: number }>
|
|
684
706
|
byModel: Record<string, { inputTokens: number; outputTokens: number; costUsd: number }>
|
|
707
|
+
/** Jev decision plane; absent on hours before it existed. Savings are estimates (chars/4) priced at the advised agent's model. */
|
|
708
|
+
jevDecisions?: number
|
|
709
|
+
jevCostUsd?: number
|
|
710
|
+
jevSavedTokens?: number
|
|
711
|
+
jevSavedCostUsd?: number
|
|
712
|
+
jevByAgent?: Record<string, { jevDecisions: number; jevCostUsd: number; jevSavedTokens: number; jevSavedCostUsd: number }>
|
|
685
713
|
}
|
|
686
714
|
|
|
687
715
|
export interface ActivityRollupDoc {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createCipheriv, createDecipheriv, randomBytes } from "node:crypto"
|
|
2
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from "node:fs"
|
|
3
3
|
import * as path from "node:path"
|
|
4
4
|
import { getHiveDir } from "../config/loader.ts"
|
|
5
5
|
import { logger } from "../utils/logger"
|
|
@@ -15,9 +15,10 @@ interface SecretDoc {
|
|
|
15
15
|
|
|
16
16
|
// ─── Durable secret store ────────────────────────────────────────────────────
|
|
17
17
|
// The `secrets` collection is the source of truth: AES-256-GCM ciphertext in
|
|
18
|
-
// the database
|
|
19
|
-
//
|
|
20
|
-
//
|
|
18
|
+
// the database. The AES key lives in the OS keychain (libsecret / macOS
|
|
19
|
+
// Keychain / Credential Manager); only where no keychain exists (headless
|
|
20
|
+
// Linux, Docker) does it fall back to <HIVE_HOME>/.master.key, next to the
|
|
21
|
+
// database, so a fresh install is still durable without configuration.
|
|
21
22
|
//
|
|
22
23
|
// The OS keychain (Bun.secrets) is only a best-effort mirror. It throws on
|
|
23
24
|
// headless Linux/Docker (no libsecret/D-Bus), and on desktops it can be a
|
|
@@ -27,6 +28,10 @@ interface SecretDoc {
|
|
|
27
28
|
// restart in production.
|
|
28
29
|
|
|
29
30
|
const _mem = new Map<string, string>()
|
|
31
|
+
// Bumped by every write and delete. A read that was already in flight when the
|
|
32
|
+
// secret changed must not cache what it found: that resurrected deleted keys
|
|
33
|
+
// in memory until restart.
|
|
34
|
+
const _epoch = new Map<string, number>()
|
|
30
35
|
let _keychainOk: boolean | null = null // null = untested
|
|
31
36
|
let _keychainApi: unknown = undefined
|
|
32
37
|
|
|
@@ -45,16 +50,22 @@ function _getKeychainApi(): any {
|
|
|
45
50
|
}
|
|
46
51
|
|
|
47
52
|
async function _get(name: string): Promise<string | null> {
|
|
53
|
+
await initMasterKey()
|
|
48
54
|
const cached = _mem.get(name)
|
|
49
55
|
if (cached !== undefined) return cached
|
|
56
|
+
const epoch = _epoch.get(name) ?? 0
|
|
57
|
+
const cache = (value: string) => { if ((_epoch.get(name) ?? 0) === epoch) _mem.set(name, value) }
|
|
50
58
|
|
|
51
59
|
// Durable store first — it is the one every write goes to.
|
|
52
60
|
const stored = await _readCollectionSecret(name)
|
|
53
|
-
if (stored)
|
|
61
|
+
if (stored) {
|
|
62
|
+
cache(stored)
|
|
63
|
+
return stored
|
|
64
|
+
}
|
|
54
65
|
|
|
55
66
|
// Legacy/desktop installs may only have the value in the OS keychain.
|
|
56
67
|
const fromKeychain = await _keychainGet(name)
|
|
57
|
-
if (fromKeychain)
|
|
68
|
+
if (fromKeychain) cache(fromKeychain)
|
|
58
69
|
return fromKeychain
|
|
59
70
|
}
|
|
60
71
|
|
|
@@ -65,6 +76,8 @@ async function _get(name: string): Promise<string | null> {
|
|
|
65
76
|
* silently accepting a secret that dies with the process.
|
|
66
77
|
*/
|
|
67
78
|
async function _set(name: string, value: string): Promise<boolean> {
|
|
79
|
+
await initMasterKey()
|
|
80
|
+
_epoch.set(name, (_epoch.get(name) ?? 0) + 1)
|
|
68
81
|
_mem.set(name, value)
|
|
69
82
|
const durable = await persistSecretToCollection(name, value)
|
|
70
83
|
const mirrored = await _keychainSet(name, value)
|
|
@@ -74,21 +87,13 @@ async function _set(name: string, value: string): Promise<boolean> {
|
|
|
74
87
|
return durable || mirrored
|
|
75
88
|
}
|
|
76
89
|
|
|
77
|
-
/**
|
|
78
|
-
* Read a secret from the `secrets` HiveDB collection — the durable store.
|
|
79
|
-
* Decrypted values are cached in memory for the rest of the process.
|
|
80
|
-
*/
|
|
90
|
+
/** Read a secret from the `secrets` HiveDB collection — the durable store. `_get` caches it. */
|
|
81
91
|
async function _readCollectionSecret(name: string): Promise<string | null> {
|
|
82
92
|
try {
|
|
83
93
|
const secrets = await col<SecretDoc>("secrets")
|
|
84
94
|
const entry = await secrets.get(name)
|
|
85
95
|
if (!entry) return null
|
|
86
|
-
|
|
87
|
-
if (plain) {
|
|
88
|
-
// Cache in memory for subsequent lookups in this process
|
|
89
|
-
_mem.set(name, plain)
|
|
90
|
-
}
|
|
91
|
-
return plain || null
|
|
96
|
+
return decryptSecret(entry.doc.ciphertext, entry.doc.iv) || null
|
|
92
97
|
} catch {
|
|
93
98
|
return null
|
|
94
99
|
}
|
|
@@ -121,6 +126,7 @@ async function _keychainSet(name: string, value: string): Promise<boolean> {
|
|
|
121
126
|
}
|
|
122
127
|
|
|
123
128
|
async function _del(name: string): Promise<void> {
|
|
129
|
+
_epoch.set(name, (_epoch.get(name) ?? 0) + 1)
|
|
124
130
|
_mem.delete(name)
|
|
125
131
|
try {
|
|
126
132
|
await (Bun as any).secrets.delete({ service: SERVICE, name })
|
|
@@ -133,22 +139,27 @@ async function _del(name: string): Promise<void> {
|
|
|
133
139
|
} catch {
|
|
134
140
|
// ignore — might not exist
|
|
135
141
|
}
|
|
142
|
+
// Again once the stores are empty: a read that started inside this window
|
|
143
|
+
// found the old value and must not cache it.
|
|
144
|
+
_epoch.set(name, (_epoch.get(name) ?? 0) + 1)
|
|
145
|
+
_mem.delete(name)
|
|
136
146
|
}
|
|
137
147
|
|
|
138
148
|
/**
|
|
139
|
-
*
|
|
140
|
-
* will be stored. Called once at boot so an operator sees the answer
|
|
141
|
-
* typing an API key, not after a restart lost it.
|
|
149
|
+
* Resolve the master key (minting it on a fresh install) and report where
|
|
150
|
+
* secrets will be stored. Called once at boot so an operator sees the answer
|
|
151
|
+
* before typing an API key, not after a restart lost it.
|
|
142
152
|
*/
|
|
143
|
-
export function ensureSecretsBackend(): { durable: boolean } {
|
|
144
|
-
|
|
153
|
+
export async function ensureSecretsBackend(): Promise<{ durable: boolean; keySource: MasterKeySource }> {
|
|
154
|
+
await initMasterKey()
|
|
155
|
+
const durable = _masterKey !== null
|
|
145
156
|
if (!durable) {
|
|
146
157
|
log.error(
|
|
147
158
|
`[secrets] No master key available — API keys and channel tokens will NOT survive a restart. ` +
|
|
148
159
|
`Set HIVE_MASTER_KEY or make ${getHiveDir()} writable.`
|
|
149
160
|
)
|
|
150
161
|
}
|
|
151
|
-
return { durable }
|
|
162
|
+
return { durable, keySource: _keySource }
|
|
152
163
|
}
|
|
153
164
|
|
|
154
165
|
// ─── Primitive API ────────────────────────────────────────────────────────────
|
|
@@ -181,6 +192,10 @@ export async function loadProviderApiKey(id: string): Promise<string> {
|
|
|
181
192
|
return (await _get(`provider:${id}:api_key`)) ?? ""
|
|
182
193
|
}
|
|
183
194
|
|
|
195
|
+
export async function deleteProviderApiKey(id: string): Promise<void> {
|
|
196
|
+
await _del(`provider:${id}:api_key`)
|
|
197
|
+
}
|
|
198
|
+
|
|
184
199
|
export async function storeProviderHeaders(id: string, headers: Record<string, unknown>): Promise<boolean> {
|
|
185
200
|
return await _set(`provider:${id}:headers`, JSON.stringify(headers))
|
|
186
201
|
}
|
|
@@ -289,52 +304,130 @@ export function decryptSecret(encrypted: string, iv: string): string {
|
|
|
289
304
|
}
|
|
290
305
|
}
|
|
291
306
|
|
|
307
|
+
type MasterKeySource = "env" | "keychain" | "file" | "none"
|
|
308
|
+
|
|
309
|
+
// One entry per data directory: the keychain is per-user, HIVE_HOME is not, and
|
|
310
|
+
// a second instance (tests, another profile) must never adopt this one's key.
|
|
311
|
+
const masterKeyEntry = () =>
|
|
312
|
+
`master-key:${new Bun.CryptoHasher("sha256").update(path.resolve(getHiveDir())).digest("hex").slice(0, 16)}`
|
|
313
|
+
|
|
292
314
|
let _masterKey: Buffer | null = null
|
|
315
|
+
let _keySource: MasterKeySource = "none"
|
|
316
|
+
let _initPromise: Promise<void> | null = null
|
|
293
317
|
|
|
294
318
|
/**
|
|
295
|
-
*
|
|
319
|
+
* Resolve the AES key protecting the `secrets` collection, in order:
|
|
296
320
|
*
|
|
297
|
-
* `HIVE_MASTER_KEY`
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
*
|
|
321
|
+
* 1. `HIVE_MASTER_KEY` — the key never touches the machine's disk.
|
|
322
|
+
* 2. The OS keychain. A key left in `<HIVE_HOME>/.master.key` by an earlier
|
|
323
|
+
* version is moved there, and the file is removed only after the keychain
|
|
324
|
+
* returns the same key.
|
|
325
|
+
* 3. `<HIVE_HOME>/.master.key` (0600) where no keychain exists.
|
|
326
|
+
*
|
|
327
|
+
* Memoized: every secret read/write awaits it, so the sync primitives below
|
|
328
|
+
* can rely on `_masterKey`.
|
|
303
329
|
*/
|
|
304
|
-
function
|
|
305
|
-
|
|
330
|
+
export function initMasterKey(): Promise<void> {
|
|
331
|
+
return (_initPromise ??= resolveMasterKey())
|
|
332
|
+
}
|
|
306
333
|
|
|
334
|
+
async function resolveMasterKey(): Promise<void> {
|
|
307
335
|
const fromEnv = process.env.HIVE_MASTER_KEY
|
|
308
336
|
if (fromEnv) {
|
|
309
337
|
_masterKey = Buffer.from(fromEnv.slice(0, 32).padEnd(32, "0"), "utf8")
|
|
310
|
-
|
|
338
|
+
_keySource = "env"
|
|
339
|
+
return
|
|
311
340
|
}
|
|
312
341
|
|
|
313
342
|
const keyPath = path.join(getHiveDir(), ".master.key")
|
|
343
|
+
const fromKeychain = await _keychainGetKey()
|
|
344
|
+
if (fromKeychain) {
|
|
345
|
+
_masterKey = fromKeychain
|
|
346
|
+
_keySource = "keychain"
|
|
347
|
+
// An earlier version's file must not outlive the key it duplicates.
|
|
348
|
+
if (existsSync(keyPath) && readFileKey(keyPath)?.equals(fromKeychain)) removeKeyFile(keyPath)
|
|
349
|
+
return
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// No key in the keychain: reuse the file's key (migration) or mint a new one.
|
|
353
|
+
const key = (existsSync(keyPath) ? readFileKey(keyPath) : null) ?? randomBytes(32)
|
|
354
|
+
if (await _keychainSetKey(key)) {
|
|
355
|
+
_masterKey = key
|
|
356
|
+
_keySource = "keychain"
|
|
357
|
+
if (existsSync(keyPath)) removeKeyFile(keyPath)
|
|
358
|
+
else log.info("[secrets] Master key generated in the OS keychain")
|
|
359
|
+
return
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// Headless Linux / Docker: no keychain to hold it.
|
|
363
|
+
_masterKey = loadOrMintKeyFile(keyPath)
|
|
364
|
+
_keySource = _masterKey ? "file" : "none"
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/** Read the key from the keychain; null when absent, malformed or no keychain. */
|
|
368
|
+
async function _keychainGetKey(): Promise<Buffer | null> {
|
|
369
|
+
try {
|
|
370
|
+
const hex = await (Bun as any).secrets.get({ service: SERVICE, name: masterKeyEntry() })
|
|
371
|
+
const key = hex ? Buffer.from(String(hex).trim(), "hex") : null
|
|
372
|
+
return key?.length === 32 ? key : null
|
|
373
|
+
} catch {
|
|
374
|
+
return null
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/** Store the key and confirm the keychain gives it back — a write that does not persist is no write. */
|
|
379
|
+
async function _keychainSetKey(key: Buffer): Promise<boolean> {
|
|
380
|
+
try {
|
|
381
|
+
await (Bun as any).secrets.set({ service: SERVICE, name: masterKeyEntry(), value: key.toString("hex") })
|
|
382
|
+
} catch {
|
|
383
|
+
return false
|
|
384
|
+
}
|
|
385
|
+
return (await _keychainGetKey())?.equals(key) ?? false
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
function readFileKey(keyPath: string): Buffer | null {
|
|
389
|
+
try {
|
|
390
|
+
const key = Buffer.from(readFileSync(keyPath, "utf8").trim(), "hex")
|
|
391
|
+
if (key.length === 32) return key
|
|
392
|
+
log.error(`[secrets] ${keyPath} is not a 32-byte hex key — secrets cannot be read or written`)
|
|
393
|
+
} catch (err) {
|
|
394
|
+
log.error(`[secrets] Could not read ${keyPath}: ${(err as Error).message}`)
|
|
395
|
+
}
|
|
396
|
+
return null
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
function removeKeyFile(keyPath: string): void {
|
|
400
|
+
try {
|
|
401
|
+
unlinkSync(keyPath)
|
|
402
|
+
log.info(`[secrets] Master key moved to the OS keychain; removed ${keyPath}`)
|
|
403
|
+
} catch (err) {
|
|
404
|
+
log.warn(`[secrets] Master key is in the OS keychain but ${keyPath} could not be removed: ${(err as Error).message}`)
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
function loadOrMintKeyFile(keyPath: string): Buffer | null {
|
|
314
409
|
try {
|
|
315
410
|
if (!existsSync(keyPath)) {
|
|
316
411
|
mkdirSync(path.dirname(keyPath), { recursive: true })
|
|
317
412
|
try {
|
|
318
413
|
// "wx" so two processes starting at once can't overwrite each other's key
|
|
319
414
|
writeFileSync(keyPath, randomBytes(32).toString("hex"), { mode: 0o600, flag: "wx" })
|
|
320
|
-
log.info(`[secrets]
|
|
415
|
+
log.info(`[secrets] No OS keychain; master key generated at ${keyPath}`)
|
|
321
416
|
} catch (err) {
|
|
322
417
|
if ((err as NodeJS.ErrnoException).code !== "EEXIST") throw err
|
|
323
418
|
}
|
|
324
419
|
}
|
|
325
|
-
|
|
326
|
-
if (key.length !== 32) {
|
|
327
|
-
log.error(`[secrets] ${keyPath} is not a 32-byte hex key — secrets cannot be read or written`)
|
|
328
|
-
return null
|
|
329
|
-
}
|
|
330
|
-
_masterKey = key
|
|
331
|
-
return _masterKey
|
|
420
|
+
return readFileKey(keyPath)
|
|
332
421
|
} catch (err) {
|
|
333
422
|
log.error(`[secrets] Could not read or create ${keyPath}: ${(err as Error).message}`)
|
|
334
423
|
return null
|
|
335
424
|
}
|
|
336
425
|
}
|
|
337
426
|
|
|
427
|
+
function getMasterKey(): Buffer | null {
|
|
428
|
+
return _masterKey
|
|
429
|
+
}
|
|
430
|
+
|
|
338
431
|
/**
|
|
339
432
|
* Encrypt a plaintext string with AES-256-GCM. Format:
|
|
340
433
|
* `<encDataHex>:<authTagHex>`. Used for every document in the `secrets`
|
|
@@ -100,7 +100,12 @@ export async function reconcileOnBoot(bootId: string): Promise<ReconcileResult>
|
|
|
100
100
|
result.runsInterrupted++;
|
|
101
101
|
try {
|
|
102
102
|
if (run.channel && run.user_id) {
|
|
103
|
-
await sendToUserChannel(
|
|
103
|
+
await sendToUserChannel(
|
|
104
|
+
run.channel,
|
|
105
|
+
run.user_id,
|
|
106
|
+
"Se interrumpió un turno en progreso por un reinicio del proceso.",
|
|
107
|
+
{ threadId: run.thread_id }
|
|
108
|
+
);
|
|
104
109
|
}
|
|
105
110
|
} catch {
|
|
106
111
|
// non-critical
|
|
@@ -62,9 +62,46 @@ export const SEED_DATA: SeedData = {
|
|
|
62
62
|
{ id: "browser_extract", name: "browser_extract", category: "web", description: "Extraer texto, enlaces o datos estructurados usando selectores CSS o XPath. Sinónimos: obtener datos, scraping, selectores, extraer información" },
|
|
63
63
|
{ id: "browser_script", name: "browser_script", category: "web", description: "Ejecutar JavaScript arbitrario en el navegador y obtener resultado. Sinónimos: ejecutar javascript, script, código, función, evaluar" },
|
|
64
64
|
{ id: "browser_wait", name: "browser_wait", category: "web", description: "Esperar a que aparezca un elemento o se cumpla una condición. Sinónimos: esperar, condición, elemento, selector, pausa" },
|
|
65
|
+
{ id: "obscura_navigate", name: "obscura_navigate", category: "web", description: "Navigate to a URL and wait for the page to load, keeping a live browser session for subsequent obscura_* tools. Returns the final URL and title only: read the page next with obscura_snapshot or obscura_markdown. Spanish keywords: navegar, abrir página, ir a sitio web, cargar url, visitar" },
|
|
66
|
+
{ id: "obscura_back", name: "obscura_back", category: "web", description: "Navigate back in the page history (browser back button). Requires an active session from obscura_navigate. Spanish keywords: atrás, volver, página anterior, regresar" },
|
|
67
|
+
{ id: "obscura_forward", name: "obscura_forward", category: "web", description: "Navigate forward in the page history. Requires an active session from obscura_navigate. Spanish keywords: adelante, página siguiente, avanzar" },
|
|
68
|
+
{ id: "obscura_reload", name: "obscura_reload", category: "web", description: "Reload the current page. Requires an active session from obscura_navigate. Spanish keywords: recargar, refrescar página, actualizar página, f5" },
|
|
69
|
+
{ id: "obscura_close", name: "obscura_close", category: "web", description: "Close the current browser page and reset the session state. Spanish keywords: cerrar navegador, cerrar página, terminar sesión" },
|
|
70
|
+
{ id: "obscura_snapshot", name: "obscura_snapshot", category: "web", description: "Get the current page as text: URL, title, readable body text and interactive element refs. Preferred first read after navigating. Spanish keywords: snapshot página, contenido página, ver página, texto página, captura textual" },
|
|
71
|
+
{ id: "obscura_markdown", name: "obscura_markdown", category: "web", description: "Extract the current page as Markdown (headings, paragraphs, lists, links, code blocks). Token-dense structured content instead of plain text. Spanish keywords: markdown, extraer markdown, contenido estructurado, página en markdown" },
|
|
72
|
+
{ id: "obscura_links", name: "obscura_links", category: "web", description: "List every anchor link on the current page as one JSON object per line {text, href}. Spanish keywords: listar enlaces, ver links, urls página, hipervínculos, enlaces" },
|
|
73
|
+
{ id: "obscura_interactive_elements", name: "obscura_interactive_elements", category: "web", description: "List every clickable/typeable element with a stable ref ID and a brief description. Use BEFORE clicking or filling to act by ref instead of guessing CSS selectors. Spanish keywords: elementos interactivos, botones, campos, inputs, refs, elementos clicables" },
|
|
74
|
+
{ id: "obscura_detect_forms", name: "obscura_detect_forms", category: "web", description: "List every <form> on the page with its action URL, method and a description of each input/textarea/select. Understand a form before filling it. Spanish keywords: detectar formularios, ver formularios, campos formulario, estructura formulario" },
|
|
75
|
+
{ id: "obscura_extract", name: "obscura_extract", category: "web", description: "Extract a structured object from the page given a map of {field_name: css_selector}. Use 'selector@attr' for attributes (e.g. 'a@href') and 'field[]' suffix for arrays. Spanish keywords: extraer datos, scraping, extraer estructura, datos página, seleccionar campos" },
|
|
76
|
+
{ id: "obscura_get_attribute", name: "obscura_get_attribute", category: "web", description: "Read an attribute of an element (href, src, value, class, data-*). Returns the raw value or empty string. Spanish keywords: leer atributo, obtener atributo, href, valor elemento, atributo html" },
|
|
77
|
+
{ id: "obscura_count", name: "obscura_count", category: "web", description: "Count how many elements on the page match a CSS selector. Cheap existence/pagination probe. Spanish keywords: contar elementos, cuántos, número de elementos, contar coincidencias" },
|
|
78
|
+
{ id: "obscura_search", name: "obscura_search", category: "web", description: "Find substring matches in the visible page text with surrounding context. Spanish keywords: buscar en página, encontrar texto, buscar contenido, texto en página" },
|
|
79
|
+
{ id: "obscura_click", name: "obscura_click", category: "web", description: "Click an element by ref (preferred, from obscura_snapshot/obscura_interactive_elements) or CSS selector. Spanish keywords: hacer clic, presionar botón, clickear, pulsar, click" },
|
|
80
|
+
{ id: "obscura_fill", name: "obscura_fill", category: "web", description: "Set the value of an input element (replaces existing value). Pass ref (preferred) or selector. Spanish keywords: llenar campo, rellenar input, establecer valor, completar campo" },
|
|
81
|
+
{ id: "obscura_type", name: "obscura_type", category: "web", description: "Type text into an input element (appends to existing value). Pass ref (preferred) or selector. Spanish keywords: escribir en campo, teclear texto, introducir texto, escribir input" },
|
|
82
|
+
{ id: "obscura_fill_form", name: "obscura_fill_form", category: "web", description: "Fill multiple inputs in one call: fields is an array of {ref?, selector?, value, type?} where type is text (default), check, uncheck or select. Optional submit_ref/submit_selector clicks after filling. Spanish keywords: llenar formulario, completar formulario, rellenar form, enviar formulario" },
|
|
83
|
+
{ id: "obscura_press_key", name: "obscura_press_key", category: "web", description: "Dispatch a keyboard event (Enter, Tab, Escape…) on an element or the document. Spanish keywords: presionar tecla, pulsar enter, teclado, keydown" },
|
|
84
|
+
{ id: "obscura_select_option", name: "obscura_select_option", category: "web", description: "Select an option from a <select> element by value or visible text. Spanish keywords: seleccionar opción, elegir opción, dropdown, lista desplegable, select" },
|
|
85
|
+
{ id: "obscura_scroll", name: "obscura_scroll", category: "web", description: "Scroll the page or an element: direction top/bottom/up/down/left/right, amount in pixels. Use 'bottom' to trigger infinite-scroll loaders. Spanish keywords: scroll, desplazar, bajar página, subir página, desplazamiento" },
|
|
86
|
+
{ id: "obscura_wait_for", name: "obscura_wait_for", category: "web", description: "Wait for a CSS selector to appear in the DOM (default 30s). Spanish keywords: esperar elemento, aguardar selector, wait selector, esperar carga" },
|
|
87
|
+
{ id: "obscura_wait_for_text", name: "obscura_wait_for_text", category: "web", description: "Wait until a substring appears anywhere in the rendered page text — for result messages and notifications. Spanish keywords: esperar texto, aguardar mensaje, esperar resultado, wait texto" },
|
|
88
|
+
{ id: "obscura_evaluate", name: "obscura_evaluate", category: "web", description: "Evaluate a JavaScript expression in the page context and return the result as JSON. Spanish keywords: ejecutar javascript, evaluar expresión, js en página, script navegador, eval" },
|
|
89
|
+
{ id: "obscura_network_requests", name: "obscura_network_requests", category: "web", description: "List the network requests made by the current page (URLs, statuses, timings). Spanish keywords: ver peticiones red, requests, tráfico red, llamadas http página, network" },
|
|
90
|
+
{ id: "obscura_console_messages", name: "obscura_console_messages", category: "web", description: "List the console messages logged by the current page (logs, warnings, errors). Spanish keywords: ver consola, logs página, mensajes consola, errores javascript, console" },
|
|
91
|
+
{ id: "obscura_screenshot", name: "obscura_screenshot", category: "web", description: "Capture the current rendered viewport as a PNG (saved to ~/.hivecode/screenshots/, returned with path + base64). Use for canvas/visual verification; prefer obscura_snapshot for text. Spanish keywords: captura de pantalla, screenshot, fotografiar página, imagen página, png" },
|
|
92
|
+
{ id: "obscura_pdf", name: "obscura_pdf", category: "web", description: "Export the current rendered document as a paginated PDF (saved to ~/.hivecode/screenshots/). Spanish keywords: exportar pdf, guardar pdf, página a pdf, documento pdf" },
|
|
93
|
+
{ id: "obscura_get_cookies", name: "obscura_get_cookies", category: "web", description: "Return all cookies in the browser's cookie jar as one JSON object per line. Spanish keywords: ver cookies, obtener cookies, cookies sesión, leer cookies" },
|
|
94
|
+
{ id: "obscura_set_cookie", name: "obscura_set_cookie", category: "web", description: "Add or replace a cookie in the jar — skip a login flow when you already have a session token. Spanish keywords: setear cookie, establecer cookie, inyectar cookie, cookie sesión" },
|
|
95
|
+
{ id: "obscura_clear_cookies", name: "obscura_clear_cookies", category: "web", description: "Wipe every cookie from the jar. Spanish keywords: borrar cookies, limpiar cookies, eliminar cookies" },
|
|
96
|
+
{ id: "obscura_storage_state", name: "obscura_storage_state", category: "web", description: "Export the full session state (cookies + localStorage + sessionStorage) as JSON — save it to skip a login on a later run. Spanish keywords: exportar sesión, estado sesión, guardar sesión, storage state" },
|
|
97
|
+
{ id: "obscura_set_storage_state", name: "obscura_set_storage_state", category: "web", description: "Restore a session state previously returned by obscura_storage_state to bring an authenticated session back. Spanish keywords: restaurar sesión, importar sesión, cargar sesión guardada, login guardado" },
|
|
98
|
+
{ id: "obscura_tab_new", name: "obscura_tab_new", category: "web", description: "Open a new tab (isolated browser page); subsequent tool calls operate on the most recent tab. Spanish keywords: nueva pestaña, abrir pestaña, nuevo tab" },
|
|
99
|
+
{ id: "obscura_tab_list", name: "obscura_tab_list", category: "web", description: "List all open tabs with their ID, URL, title and which one is active. Spanish keywords: listar pestañas, ver pestañas, tabs abiertos" },
|
|
100
|
+
{ id: "obscura_tab_switch", name: "obscura_tab_switch", category: "web", description: "Switch the active tab — all subsequent tool calls target this tab. Spanish keywords: cambiar pestaña, cambiar tab, activar pestaña" },
|
|
101
|
+
{ id: "obscura_tab_close", name: "obscura_tab_close", category: "web", description: "Close a tab by ID (default: the active tab). Spanish keywords: cerrar pestaña, cerrar tab" },
|
|
65
102
|
|
|
66
103
|
// ─────────────────────────────────────────
|
|
67
|
-
// 3. CRON — Tareas programadas
|
|
104
|
+
// 3. CRON — Tareas programadas
|
|
68
105
|
// ─────────────────────────────────────────
|
|
69
106
|
{ id: "cron.create", name: "cron.create", category: "cron", description: "Crear una automatización de Hive programada: recurrente (expresión cron) o ejecución futura única (fire_at). Requiere 'task'. Sinónimos: programar tarea, crear automatización, ejecutar después, tarea recurrente, una vez" },
|
|
70
107
|
{ id: "cron.list", name: "cron.list", category: "cron", description: "Listar todas las tareas programadas con próximos horarios de ejecución. Sinónimos: ver tareas programadas, listar cronograma, próximas ejecuciones" },
|
|
@@ -79,6 +116,7 @@ export const SEED_DATA: SeedData = {
|
|
|
79
116
|
// 4. CLI — Ejecución de comandos
|
|
80
117
|
// ─────────────────────────────────────────
|
|
81
118
|
{ id: "cli_exec", name: "cli_exec", category: "cli", description: "Ejecutar comandos shell/bash en el entorno del agente. NOTA: NO usar para tareas programadas, usar cron.create. Sinónimos: ejecutar comando, terminal, bash, script, consola" },
|
|
119
|
+
{ id: "code_agent_run", name: "code_agent_run", category: "cli", description: "Delegar una tarea de programación a un agente de código externo (claude, codex, opencode, kimi) en un git worktree aislado; devuelve resumen, archivos y diff. Sinónimos: agente de código, delegar programación" },
|
|
82
120
|
|
|
83
121
|
// ─────────────────────────────────────────
|
|
84
122
|
// 5. AGENTS — Memoria, workers y delegación
|
|
@@ -114,6 +152,7 @@ export const SEED_DATA: SeedData = {
|
|
|
114
152
|
{ id: "notify", name: "notify", category: "core", description: "Enviar notificación al usuario. Sinónimos: notificar, enviar notificación, alertar, aviso" },
|
|
115
153
|
{ id: "save_note", name: "save_note", category: "core", description: "Guardar nota persistente en el scratchpad. Sinónimos: guardar nota, escribir nota, recordatorio rápido, apuntar" },
|
|
116
154
|
{ id: "report_progress", name: "report_progress", category: "core", description: "Reportar progreso actual al usuario. Sinónimos: reportar progreso, informar estado, actualizar progreso, porcentaje" },
|
|
155
|
+
{ id: "conversation_read", name: "conversation_read", category: "core", description: "Recuperar mensajes anteriores de esta conversación por ID o búsqueda de texto. Sinónimos: leer conversación, recuperar contexto, historial omitido" },
|
|
117
156
|
|
|
118
157
|
// ─────────────────────────────────────────
|
|
119
158
|
// 10. OFFICE — Archivos Office (PDF, DOCX, XLSX, PPTX)
|
|
@@ -180,6 +219,11 @@ export const SEED_DATA: SeedData = {
|
|
|
180
219
|
// Solo la generación 3.x: la familia 2.0 ya está apagada y la 2.5 quedó
|
|
181
220
|
// superada. `gemini-3.5-pro` y `gemini-3.1-flash-lite-preview` se quitaron:
|
|
182
221
|
// el primero no existe en el catálogo y el segundo ya salió de preview.
|
|
222
|
+
// 3.8 Flash tiene precio de lanzamiento hasta el 31-dic-2026 ($0.75 / $3.75).
|
|
223
|
+
// Desde el 1-ene-2027 pasa a $1.50 / $7.50: actualizar aquí ese día o el
|
|
224
|
+
// dashboard subestimará el costo y el ahorro de Jev a la mitad.
|
|
225
|
+
// contextWindow: el que reporta la propia API de modelos de Gemini.
|
|
226
|
+
{ id: "gemini-3.8-flash", providerId: "gemini", name: "Gemini 3.8 Flash", modelType: "llm", contextWindow: 1050000, capabilities: JSON.stringify(["chat", "vision", "json_mode", "function_calling", "streaming", "reasoning"]), inputPer1M: 0.75, outputPer1M: 3.75 },
|
|
183
227
|
{ id: "gemini-3.6-flash", providerId: "gemini", name: "Gemini 3.6 Flash", modelType: "llm", contextWindow: 1048576, capabilities: JSON.stringify(["chat", "vision", "json_mode", "function_calling", "streaming", "reasoning"]), inputPer1M: 1.5, outputPer1M: 7.5 },
|
|
184
228
|
{ id: "gemini-3.5-flash", providerId: "gemini", name: "Gemini 3.5 Flash", modelType: "llm", contextWindow: 1048576, capabilities: JSON.stringify(["chat", "vision", "json_mode", "function_calling", "streaming", "reasoning"]), inputPer1M: 1.5, outputPer1M: 9 },
|
|
185
229
|
{ id: "gemini-3.5-flash-lite", providerId: "gemini", name: "Gemini 3.5 Flash Lite", modelType: "llm", contextWindow: 1048576, capabilities: JSON.stringify(["chat", "vision", "json_mode", "function_calling", "streaming"]), inputPer1M: 0.3, outputPer1M: 2.5 },
|
|
@@ -188,7 +232,11 @@ export const SEED_DATA: SeedData = {
|
|
|
188
232
|
|
|
189
233
|
// Realtime (voz en tiempo real, `bidiGenerateContent`). Audio nativo bidireccional:
|
|
190
234
|
// no es un pipeline STT→LLM→TTS, el modelo oye y habla directo.
|
|
191
|
-
|
|
235
|
+
// Gemini 3.8 Live reemplaza a 3.1 Flash Live (preview, marcado "legacy" por
|
|
236
|
+
// Google) al mismo precio. Al salir 3.1 del catálogo ninguna fila queda
|
|
237
|
+
// activa y resolveRealtimeModel toma el default: la voz pasa sola a 3.8.
|
|
238
|
+
// Para volver atrás basta con restaurar la línea de 3.1.
|
|
239
|
+
{ id: "gemini-3.8-live", providerId: "gemini", name: "Gemini 3.8 Live", modelType: "realtime", contextWindow: 128000, capabilities: JSON.stringify(["realtime", "audio_in", "audio_out", "function_calling", "transcription"]), inputPer1M: 3, outputPer1M: 12 },
|
|
192
240
|
{ id: "gemini-2.5-flash-native-audio-latest", providerId: "gemini", name: "Gemini 2.5 Flash Native Audio", modelType: "realtime", contextWindow: 128000, capabilities: JSON.stringify(["realtime", "audio_in", "audio_out", "function_calling", "async_function_calling", "transcription"]), inputPer1M: 3, outputPer1M: 12 },
|
|
193
241
|
|
|
194
242
|
// TTS
|
|
@@ -219,6 +267,7 @@ export const SEED_DATA: SeedData = {
|
|
|
219
267
|
{ id: "kimi-k2.6", providerId: "kimi", name: "Kimi K2.6", modelType: "llm", contextWindow: 262144, capabilities: JSON.stringify(["chat", "vision", "json_mode", "function_calling", "streaming", "code"]), inputPer1M: 0.6, outputPer1M: 3.41 },
|
|
220
268
|
|
|
221
269
|
// ── OpenRouter (fuente: GET https://openrouter.ai/api/v1/models) ──
|
|
270
|
+
{ id: "typesafe/jev-1.13", providerId: "openrouter", name: "Jev 1.13 (Decisions)", modelType: "decision", contextWindow: 32000, capabilities: JSON.stringify(["choice", "noul", "score"]), inputPer1M: 0.042, outputPer1M: 0 },
|
|
222
271
|
// Solo modelos vivos con `tools` en supported_parameters y publicados desde
|
|
223
272
|
// 2025-07. contextWindow = context_length reportado por el propio catálogo.
|
|
224
273
|
// Anthropic
|
|
@@ -243,7 +292,9 @@ export const SEED_DATA: SeedData = {
|
|
|
243
292
|
// Z.ai / GLM
|
|
244
293
|
{ id: "z-ai/glm-5.2", providerId: "openrouter", name: "GLM 5.2 (OR)", modelType: "llm", contextWindow: 1048576, capabilities: JSON.stringify(["chat", "json_mode", "function_calling", "streaming", "code", "reasoning"]), inputPer1M: 0.63, outputPer1M: 1.98 },
|
|
245
294
|
// Qwen
|
|
246
|
-
|
|
295
|
+
// OpenRouter renombró qwen/qwen3.8-max a su versión fechada: mismo contexto
|
|
296
|
+
// y precio, ahora también con imagen. Verificado 2026-09-10.
|
|
297
|
+
{ id: "qwen/qwen3.8-max-0902", providerId: "openrouter", name: "Qwen3.8 Max (OR)", modelType: "llm", contextWindow: 1000000, capabilities: JSON.stringify(["chat", "vision", "json_mode", "function_calling", "streaming", "reasoning"]), inputPer1M: 2, outputPer1M: 6 },
|
|
247
298
|
{ id: "qwen/qwen3.7-flash", providerId: "openrouter", name: "Qwen3.7 Flash (OR)", modelType: "llm", contextWindow: 1000000, capabilities: JSON.stringify(["chat", "json_mode", "function_calling", "streaming"]), inputPer1M: 0.03, outputPer1M: 0.13 },
|
|
248
299
|
// xAI
|
|
249
300
|
{ id: "x-ai/grok-4.5", providerId: "openrouter", name: "Grok 4.5 (OR)", modelType: "llm", contextWindow: 500000, capabilities: JSON.stringify(["chat", "vision", "json_mode", "function_calling", "streaming", "reasoning"]), inputPer1M: 2, outputPer1M: 6 },
|
|
@@ -303,9 +354,17 @@ export const SEED_DATA: SeedData = {
|
|
|
303
354
|
// DeepSeek V4 Pro (deepseek-ai/deepseek-v4-pro) se sacó: devuelve 404
|
|
304
355
|
// "Function not found for account" en cuentas normales — no está habilitado
|
|
305
356
|
// de forma general aunque figure en el listado público de /v1/models.
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
357
|
+
// GLM 5.2 (z-ai/glm-5.2) y MiniMax M3 (minimaxai/minimax-m3) se sacaron:
|
|
358
|
+
// NVIDIA los retiró, responden 410 Gone y ya no figuran en /v1/models.
|
|
359
|
+
// Kimi K2.6 (moonshotai/kimi-k2.6) se sacó por lo mismo que DeepSeek V4 Pro:
|
|
360
|
+
// 404 "Function not found for account" en dos cuentas distintas.
|
|
361
|
+
// Kimi K3, DeepSeek V4 Flash 0731 y Muse Glimmer entraron: publicados en
|
|
362
|
+
// julio/agosto con "Free Endpoint" en el catálogo de NGC, y responden con
|
|
363
|
+
// tool calling en una cuenta gratuita. Contexto según la referencia de la API
|
|
364
|
+
// de NVIDIA (Kimi K3) y OpenRouter (el resto). Verificado 2026-09-10.
|
|
365
|
+
{ id: "moonshotai/kimi-k3", providerId: "nvidia", name: "Kimi K3 (NVIDIA)", modelType: "llm", contextWindow: 1048576, capabilities: JSON.stringify(["chat", "code", "vision", "function_calling", "streaming", "reasoning"]), inputPer1M: 0, outputPer1M: 0 },
|
|
366
|
+
{ id: "deepseek-ai/deepseek-v4-flash-0731", providerId: "nvidia", name: "DeepSeek V4 Flash (NVIDIA)", modelType: "llm", contextWindow: 1048576, capabilities: JSON.stringify(["chat", "code", "function_calling", "streaming", "reasoning"]), inputPer1M: 0, outputPer1M: 0 },
|
|
367
|
+
{ id: "meta/muse-glimmer-30b", providerId: "nvidia", name: "Muse Glimmer 30B (NVIDIA)", modelType: "llm", contextWindow: 131072, capabilities: JSON.stringify(["chat", "vision", "function_calling", "streaming", "reasoning"]), inputPer1M: 0, outputPer1M: 0 },
|
|
309
368
|
{ id: "nvidia/nemotron-3-ultra-550b-a55b", providerId: "nvidia", name: "Nemotron 3 Ultra 550B", modelType: "llm", contextWindow: 1000000, capabilities: JSON.stringify(["chat", "code", "json_mode", "function_calling", "streaming", "reasoning"]), inputPer1M: 0, outputPer1M: 0 },
|
|
310
369
|
{ id: "nvidia/nemotron-3-super-120b-a12b", providerId: "nvidia", name: "Nemotron 3 Super 120B", modelType: "llm", contextWindow: 1000000, capabilities: JSON.stringify(["chat", "code", "json_mode", "function_calling", "streaming", "reasoning"]), inputPer1M: 0, outputPer1M: 0 },
|
|
311
370
|
|
|
@@ -587,6 +646,38 @@ function migrateLegacyCatalogPersona(existing: AgentDoc, current: AgentDoc): Age
|
|
|
587
646
|
};
|
|
588
647
|
}
|
|
589
648
|
|
|
649
|
+
// Stock catalog prompts used Rioplatense voseo up to 1.0.5. Only the words that
|
|
650
|
+
// appeared in those prompts; the migration below validates every rewrite.
|
|
651
|
+
const VOSEO_TO_NEUTRAL: Record<string, string> = {
|
|
652
|
+
pedís: "pides", ampliás: "amplías", usás: "usas", declarás: "declaras", hablás: "hablas",
|
|
653
|
+
inventás: "inventas", exponés: "expones", automatizás: "automatizas", realizás: "realizas",
|
|
654
|
+
confirmás: "confirmas", ejecutás: "ejecutas", modificás: "modificas", sobrescribís: "sobrescribes",
|
|
655
|
+
publicás: "publicas", editás: "editas", interpretás: "interpretas", conversás: "conversas",
|
|
656
|
+
creás: "creas", consultás: "consultas", repetís: "repites", cambiás: "cambias",
|
|
657
|
+
Devolvé: "Devuelve", Convertí: "Convierte", Contrastá: "Contrasta", Inspeccioná: "Inspecciona",
|
|
658
|
+
Aplicá: "Aplica", Volvé: "Vuelve", Determiná: "Determina", modificá: "modifica",
|
|
659
|
+
Generá: "Genera", extraé: "extrae", Diseñá: "Diseña", Enviá: "Envía", liberá: "libera",
|
|
660
|
+
Normalizá: "Normaliza", Consultá: "Consulta", Validá: "Valida",
|
|
661
|
+
};
|
|
662
|
+
const VOSEO_PATTERN = new RegExp(`(?<!\\p{L})(${Object.keys(VOSEO_TO_NEUTRAL).join("|")})(?!\\p{L})`, "gu");
|
|
663
|
+
|
|
664
|
+
/**
|
|
665
|
+
* Rewrites a stored catalog prompt line only when dropping the voseo turns it
|
|
666
|
+
* into a line of the current stock prompt, so user-written lines stay as they are.
|
|
667
|
+
*/
|
|
668
|
+
function migrateVoseoCatalogPrompt(existing: AgentDoc, current: AgentDoc): AgentDoc {
|
|
669
|
+
const stockLines = new Set(current.system_prompt.split("\n"));
|
|
670
|
+
const systemPrompt = existing.system_prompt
|
|
671
|
+
.split("\n")
|
|
672
|
+
.map((line) => {
|
|
673
|
+
if (stockLines.has(line)) return line;
|
|
674
|
+
const neutral = line.replace(VOSEO_PATTERN, (word) => VOSEO_TO_NEUTRAL[word]!);
|
|
675
|
+
return stockLines.has(neutral) ? neutral : line;
|
|
676
|
+
})
|
|
677
|
+
.join("\n");
|
|
678
|
+
return systemPrompt === existing.system_prompt ? existing : { ...existing, system_prompt: systemPrompt };
|
|
679
|
+
}
|
|
680
|
+
|
|
590
681
|
async function pruneRetired(): Promise<void> {
|
|
591
682
|
const toolsCol = await col<ToolDoc>("tools");
|
|
592
683
|
let removed = 0;
|
|
@@ -838,7 +929,10 @@ export async function seedAllData(): Promise<void> {
|
|
|
838
929
|
continue;
|
|
839
930
|
}
|
|
840
931
|
|
|
841
|
-
let reconciled =
|
|
932
|
+
let reconciled = migrateVoseoCatalogPrompt(
|
|
933
|
+
migrateLegacyCatalogPersona(existing.doc, catalogAgent),
|
|
934
|
+
catalogAgent,
|
|
935
|
+
);
|
|
842
936
|
// Older releases could mark permanent catalog capabilities as archived.
|
|
843
937
|
// Archiving is no longer automatic, and catalog rows are never valid
|
|
844
938
|
// archive targets, so repair only that stale status on every boot while
|