@johpaz/hive-sdk 0.1.4 → 0.1.6
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 +129 -0
- package/README.md +78 -23
- package/bun.lock +55 -29
- package/bunfig.toml +4 -2
- package/docs/API-AGENTS.md +78 -27
- package/docs/API-CONTEXT-COMPILER.md +31 -34
- package/docs/API-TOOLS-SKILLS-CHANNELS.md +58 -22
- package/docs/HIVE-HARNESS.md +1 -1
- package/docs/INDEX.md +4 -4
- package/docs/TEMPLATE-HIVE-APP.md +10 -10
- package/package.json +17 -12
- package/packages/cli/package.json +2 -2
- package/packages/cli/src/commands/create-app.test.ts +36 -7
- package/packages/cli/src/commands/init.ts +3 -3
- package/packages/cli/src/commands/run.ts +1 -1
- package/packages/cli/src/commands/test.ts +37 -25
- package/packages/cli/src/commands/trace.ts +30 -28
- package/packages/cli/templates/hive-app/.env.example +10 -2
- package/packages/cli/templates/hive-app/README.md +103 -0
- package/packages/cli/templates/hive-app/hive.config.ts +9 -3
- package/packages/cli/templates/hive-app/src/agents/coordinator.ts +8 -1
- package/packages/cli/templates/hive-app/src/main.ts +12 -19
- package/packages/core/package.json +13 -12
- package/packages/core/src/agent/acceptance-checks.ts +172 -0
- package/packages/core/src/agent/agent-catalog.ts +348 -0
- package/packages/core/src/agent/agent-loop.ts +1373 -0
- package/packages/core/src/agent/capability-search.ts +186 -0
- package/packages/core/src/agent/catalog-selector.ts +103 -0
- package/packages/core/src/agent/{Compaction.ts → compaction.ts} +86 -63
- package/packages/core/src/agent/context-compiler.ts +689 -0
- package/packages/core/src/agent/conversation-store.ts +381 -0
- package/packages/core/src/agent/curator.ts +276 -0
- package/packages/core/src/agent/delegation-runtime.ts +241 -0
- package/packages/core/src/agent/goal-runner.ts +323 -0
- package/packages/core/src/agent/index.ts +17 -12
- package/packages/core/src/agent/llm-client.ts +266 -0
- package/packages/core/src/agent/llm-providers/anthropic.ts +264 -0
- package/packages/core/src/agent/llm-providers/deepseek.ts +8 -0
- package/packages/core/src/agent/{providers → llm-providers}/gemini.ts +98 -60
- package/packages/core/src/agent/llm-providers/groq.ts +5 -0
- package/packages/core/src/agent/llm-providers/hiveagents.ts +253 -0
- package/packages/core/src/agent/{providers → llm-providers}/interface.ts +73 -13
- package/packages/core/src/agent/llm-providers/kimi.ts +8 -0
- package/packages/core/src/agent/llm-providers/minimax.ts +13 -0
- package/packages/core/src/agent/llm-providers/mistral.ts +5 -0
- package/packages/core/src/agent/llm-providers/modelscope.ts +5 -0
- package/packages/core/src/agent/llm-providers/nvidia.ts +5 -0
- package/packages/core/src/agent/{providers → llm-providers}/ollama.ts +31 -5
- package/packages/core/src/agent/llm-providers/openai-compat-base.ts +418 -0
- package/packages/core/src/agent/llm-providers/openai.ts +5 -0
- package/packages/core/src/agent/llm-providers/opencode-go.ts +9 -0
- package/packages/core/src/agent/llm-providers/openrouter.ts +5 -0
- package/packages/core/src/agent/llm-providers/qwen.ts +5 -0
- package/packages/core/src/agent/llm-providers/z-ai.ts +5 -0
- package/packages/core/src/agent/minimal-loadout.ts +47 -0
- package/packages/core/src/agent/playbook-selector.ts +119 -0
- package/packages/core/src/agent/{PromptBuilder.ts → prompt-builder.ts} +21 -22
- package/packages/core/src/{harness → agent}/proof-packet.ts +16 -21
- package/packages/core/src/agent/providers/index.ts +35 -16
- package/packages/core/src/agent/reflector.ts +320 -0
- package/packages/core/src/agent/routing-intent.ts +22 -0
- package/packages/core/src/{harness → agent}/run-epoch.ts +4 -3
- package/packages/core/src/{harness → agent}/run-store.ts +142 -81
- package/packages/core/src/agent/{Service.ts → service.ts} +37 -26
- package/packages/core/src/agent/skill-selector.ts +374 -0
- package/packages/core/src/agent/stuck-loop.ts +209 -0
- package/packages/core/src/agent/{selectors/ToolSelector.ts → tool-selector.ts} +188 -178
- package/packages/core/src/{ace/Tracer.ts → agent/tracer.ts} +37 -27
- package/packages/core/src/api/createAgent.test.ts +139 -27
- package/packages/core/src/api/createAgent.ts +232 -44
- package/packages/core/src/artifacts/store.ts +162 -0
- package/packages/core/src/canvas/canvas-manager.ts +161 -0
- package/packages/core/src/canvas/canvas.test.ts +8 -4
- package/packages/core/src/canvas/emitter.ts +131 -80
- package/packages/core/src/canvas/index.ts +1 -3
- package/packages/core/src/channels/base.ts +9 -1
- package/packages/core/src/channels/discord.ts +5 -4
- package/packages/core/src/channels/manager.ts +122 -30
- package/packages/core/src/channels/slack.ts +5 -4
- package/packages/core/src/channels/telegram.ts +36 -6
- package/packages/core/src/channels/webchat.ts +11 -10
- package/packages/core/src/channels/whatsapp.ts +23 -7
- package/packages/core/src/config/index.ts +13 -2
- package/packages/core/src/config/loader.ts +76 -29
- package/packages/core/src/ethics/EthicsGuard.test.ts +90 -36
- package/packages/core/src/ethics/EthicsGuard.ts +51 -47
- package/packages/core/src/events/agent-bus.ts +44 -68
- package/packages/core/src/events/channel-narration.ts +150 -0
- package/packages/core/src/events/narration.ts +82 -0
- package/packages/core/src/events/tool-narration.ts +62 -0
- package/packages/core/src/gateway/delegation-groups.ts +258 -0
- package/packages/core/src/{harness → gateway}/durable-queue.ts +102 -42
- package/packages/core/src/{harness → gateway}/job-store.ts +85 -48
- package/packages/core/src/gateway/lane-queue.ts +173 -0
- package/packages/core/src/gateway/notification-inbox.ts +57 -0
- package/packages/core/src/gateway/server.ts +1 -1
- package/packages/core/src/harness/index.ts +46 -27
- package/packages/core/src/index.ts +33 -27
- package/packages/core/src/mcp/hot-reload.ts +32 -23
- package/packages/core/src/mcp/index.ts +6 -3
- package/packages/core/src/mcp/singleton.ts +1 -4
- package/packages/core/src/mcp/tool-sync.ts +138 -0
- package/packages/core/src/memory/Scratchpad.test.ts +39 -20
- package/packages/core/src/memory/Scratchpad.ts +27 -34
- package/packages/core/src/multimodal/vision-service.ts +44 -38
- package/packages/core/src/resilience/retry.ts +95 -0
- package/packages/core/src/scheduler/CronScheduler.ts +334 -287
- package/packages/core/src/scheduler/index.ts +9 -7
- package/packages/core/src/scheduler/integration.ts +46 -26
- package/packages/core/src/scheduler/scheduler.test.ts +9 -13
- package/packages/core/src/scheduler/types.ts +7 -2
- package/packages/core/src/security/Pairing.ts +1 -1
- package/packages/core/src/skills/bundled/a2ui/a2ui_dashboard/SKILL.md +176 -0
- package/packages/core/src/skills/bundled/a2ui/a2ui_form/SKILL.md +202 -0
- package/packages/core/src/skills/bundled/a2ui/a2ui_interactive/SKILL.md +206 -0
- package/packages/core/src/skills/bundled/agents/agent_spawner/SKILL.md +173 -0
- package/packages/core/src/skills/bundled/agents/memory_manager/SKILL.md +143 -0
- package/packages/core/src/skills/bundled/agents/research_and_remember/SKILL.md +139 -0
- package/packages/core/src/skills/bundled/agents/task_orchestrator/SKILL.md +98 -0
- package/packages/core/src/skills/bundled/api/api_client/SKILL.md +132 -0
- package/packages/core/src/skills/bundled/cli/cli_pipeline/SKILL.md +135 -0
- package/packages/core/src/skills/bundled/cli/cli_safe_exec/SKILL.md +125 -0
- package/packages/core/src/skills/bundled/cli/software_engineering/SKILL.md +23 -0
- package/packages/core/src/skills/bundled/cron_manager/SKILL.md +188 -0
- package/packages/core/src/skills/bundled/cron_reminder/SKILL.md +112 -0
- package/packages/core/src/skills/bundled/filesystem/file_manager/SKILL.md +118 -0
- package/packages/core/src/skills/bundled/filesystem/file_read_and_summarize/SKILL.md +109 -0
- package/packages/core/src/skills/bundled/filesystem/file_writer/SKILL.md +129 -0
- package/packages/core/src/skills/bundled/filesystem/workspace_file_operator/SKILL.md +22 -0
- package/packages/core/src/skills/bundled/office/office_document_manager/SKILL.md +262 -0
- package/packages/core/src/skills/bundled/search_knowledge/capability_discovery/SKILL.md +75 -0
- package/packages/core/src/skills/bundled/web/browser_automate/SKILL.md +120 -0
- package/packages/core/src/skills/bundled/web/browser_scrape/SKILL.md +109 -0
- package/packages/core/src/skills/bundled/web/web_monitor/SKILL.md +127 -0
- package/packages/core/src/skills/bundled/web/web_research/SKILL.md +119 -0
- package/packages/core/src/skills/bundled-data.generated.ts +731 -2678
- package/packages/core/src/skills/skills.test.ts +52 -11
- package/packages/core/src/{harness → storage}/boot-id.ts +5 -2
- package/packages/core/src/storage/bootstrap.ts +151 -0
- package/packages/core/src/storage/causal-events.ts +84 -0
- package/packages/core/src/storage/collections.ts +680 -0
- package/packages/core/src/storage/crypto.ts +205 -74
- package/packages/core/src/{harness/db-helpers.ts → storage/hive.ts} +63 -7
- package/packages/core/src/storage/hivedb.ts +61 -0
- package/packages/core/src/storage/index.ts +111 -18
- package/packages/core/src/storage/model-id.ts +53 -0
- package/packages/core/src/storage/onboarding.ts +540 -972
- package/packages/core/src/storage/reconcile.ts +238 -0
- package/packages/core/src/storage/seed.ts +572 -406
- package/packages/core/src/storage/usage.ts +285 -225
- package/packages/core/src/storage/user-email.ts +11 -0
- package/packages/core/src/swarm/AgentExecutor.ts +1 -1
- package/packages/core/src/swarm/EventBridge.ts +1 -1
- package/packages/core/src/swarm/index.ts +12 -9
- package/packages/core/src/tool-runtime/index.ts +146 -23
- package/packages/core/src/tool-runtime/tool-worker.ts +2 -2
- package/packages/core/src/tool-runtime/worker-tools.ts +27 -0
- package/packages/core/src/{canvas/a2ui-tools.ts → tools/a2ui/index.ts} +17 -8
- package/packages/core/src/tools/agents/get-available-models.ts +36 -54
- package/packages/core/src/tools/agents/index.ts +784 -292
- package/packages/core/src/tools/api/api-request.test.ts +164 -0
- package/packages/core/src/tools/api/api-request.ts +174 -0
- package/packages/core/src/tools/api/index.ts +16 -0
- package/packages/core/src/tools/cli/index.ts +4 -0
- package/packages/core/src/tools/core/index.ts +281 -112
- package/packages/core/src/tools/cron/index.ts +121 -124
- package/packages/core/src/tools/index.ts +63 -78
- package/packages/core/src/tools/office/office-escribir-xlsx.ts +3 -1
- package/packages/core/src/tools/types.ts +3 -1
- package/packages/core/src/tools/web/artifact-inspect.ts +23 -0
- package/packages/core/src/tools/web/browser-backend.ts +129 -0
- package/packages/core/src/tools/web/browser-screenshot.ts +26 -5
- package/packages/core/src/tools/web/browser-service.ts +80 -35
- package/packages/core/src/tools/web/browser-type.ts +3 -8
- package/packages/core/src/tools/web/index.ts +4 -4
- package/packages/core/src/tools/web/webview-backend.ts +412 -0
- package/packages/core/src/voice/index.ts +89 -63
- package/packages/core/src/workers/agent.worker.ts +2 -2
- package/packages/core/src/workers/workers.test.ts +3 -10
- package/scripts/bump-version.ts +248 -0
- package/scripts/generate-skill-bundle.ts +108 -0
- package/test/acceptance-checks.test.ts +403 -0
- package/test/agent-loop-terminal-synthesis.test.ts +32 -0
- package/test/browser-backend.test.ts +308 -0
- package/test/catalog-agents-stay-enabled.test.ts +117 -0
- package/test/causal-events.test.ts +117 -0
- package/test/compaction.test.ts +105 -0
- package/test/context-compiler.test.ts +269 -0
- package/test/curator.test.ts +130 -0
- package/test/durable-queue.test.ts +114 -0
- package/test/harness-barrel.test.ts +64 -0
- package/test/hive-helpers.test.ts +130 -0
- package/test/hivedb-search.test.ts +189 -0
- package/test/internal-turns.test.ts +166 -0
- package/test/job-idempotency.test.ts +68 -0
- package/test/job-retry-backoff.test.ts +184 -0
- package/test/job-store.test.ts +381 -0
- package/test/llm-retry.test.ts +97 -0
- package/test/memory-perf.test.ts +774 -0
- package/test/minimal-loadout.test.ts +78 -0
- package/test/model-catalog.test.ts +105 -0
- package/test/preload.ts +12 -0
- package/test/reflector.test.ts +320 -0
- package/test/retention-cap.test.ts +91 -0
- package/test/retired-capabilities-pruned.test.ts +192 -0
- package/test/run-store.test.ts +355 -0
- package/test/scratchpad.test.ts +74 -0
- package/test/secrets-durability.test.ts +119 -0
- package/test/seed-model-reseed.test.ts +155 -0
- package/test/setup-agent-seed.test.ts +264 -0
- package/test/tool-inventory.test.ts +65 -0
- package/test/tool-runtime.test.ts +258 -0
- package/test/tool-selector-runtime-tools.test.ts +117 -0
- package/test/toon.test.ts +429 -0
- package/tsconfig.json +2 -0
- package/packages/core/src/ace/Curator.ts +0 -158
- package/packages/core/src/ace/Reflector.ts +0 -200
- package/packages/core/src/ace/index.ts +0 -4
- package/packages/core/src/agent/AgentRunner.ts +0 -711
- package/packages/core/src/agent/ContextCompiler.ts +0 -567
- package/packages/core/src/agent/ContextGuard.ts +0 -91
- package/packages/core/src/agent/ConversationStore.ts +0 -254
- package/packages/core/src/agent/Hooks.ts +0 -166
- package/packages/core/src/agent/StuckLoop.ts +0 -133
- package/packages/core/src/agent/providers/LLMClient.ts +0 -149
- package/packages/core/src/agent/providers/anthropic.ts +0 -212
- package/packages/core/src/agent/providers/openai-compat.ts +0 -231
- package/packages/core/src/agent/selectors/PlaybookSelector.ts +0 -121
- package/packages/core/src/agent/selectors/SkillSelector.ts +0 -322
- package/packages/core/src/agent/selectors/index.ts +0 -6
- package/packages/core/src/auth/auth.ts +0 -121
- package/packages/core/src/auth/index.ts +0 -1
- package/packages/core/src/canvas/CanvasManager.ts +0 -390
- package/packages/core/src/canvas/canvas-tools.ts +0 -448
- package/packages/core/src/harness/collections.ts +0 -98
- package/packages/core/src/harness/goal-verifier.ts +0 -141
- package/packages/core/src/harness/harness.test.ts +0 -236
- package/packages/core/src/harness/reconcile.ts +0 -149
- package/packages/core/src/mcp/MCPToolAdapter.ts +0 -176
- package/packages/core/src/multimodal/VisionService.ts +0 -293
- package/packages/core/src/scheduler/dag/AgentExecutor.ts +0 -53
- package/packages/core/src/scheduler/dag/DAGScheduler.ts +0 -250
- package/packages/core/src/scheduler/dag/EventBridge.ts +0 -122
- package/packages/core/src/scheduler/dag/TaskGraph.ts +0 -192
- package/packages/core/src/scheduler/dag/TaskNode.ts +0 -97
- package/packages/core/src/scheduler/dag/TaskResult.ts +0 -22
- package/packages/core/src/scheduler/dag/errors.ts +0 -37
- package/packages/core/src/scheduler/dag/index.ts +0 -26
- package/packages/core/src/scheduler/dag/presets/ResearchPreset.ts +0 -97
- package/packages/core/src/scheduler/dag/strategies/ParallelStrategy.ts +0 -21
- package/packages/core/src/scheduler/dag/strategies/PriorityStrategy.ts +0 -46
- package/packages/core/src/storage/HiveDBStorage.ts +0 -64
- package/packages/core/src/storage/SQLiteStorage.ts +0 -414
- package/packages/core/src/storage/hiveSeed.ts +0 -308
- package/packages/core/src/storage/hiveStorage.test.ts +0 -38
- package/packages/core/src/storage/schema.ts +0 -689
- package/packages/core/src/storage/storage.test.ts +0 -37
- package/packages/core/src/swarm/AgentBus.ts +0 -460
- package/packages/core/src/swarm/EventBus.ts +0 -169
- package/packages/core/src/swarm/WorkerPool.ts +0 -236
- package/packages/core/src/tools/bridge-events.ts +0 -26
- package/packages/core/src/tools/canvas/index.ts +0 -375
- package/packages/core/src/tools/codebridge/index.ts +0 -342
- package/packages/core/src/tools/meeting/index.ts +0 -353
- package/packages/core/src/tools/projects/index.ts +0 -37
- package/packages/core/src/tools/projects/project-create.ts +0 -94
- package/packages/core/src/tools/projects/project-done.ts +0 -66
- package/packages/core/src/tools/projects/project-fail.ts +0 -66
- package/packages/core/src/tools/projects/project-list.ts +0 -96
- package/packages/core/src/tools/projects/project-update.ts +0 -72
- package/packages/core/src/tools/projects/task-create.ts +0 -68
- package/packages/core/src/tools/projects/task-evaluate.ts +0 -93
- package/packages/core/src/tools/projects/task-update.ts +0 -93
- package/packages/core/src/tools/voice/index.ts +0 -104
- package/packages/core/src/tools/web/api-request.test.ts +0 -170
- package/packages/core/src/tools/web/api-request.ts +0 -239
- package/test/setup-db.ts +0 -216
- /package/packages/core/src/agent/{NativeTools.ts → native-tools.ts} +0 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
export type TaskStatus = "pending" | "running" | "completed" | "failed" | "cancelled";
|
|
2
|
+
|
|
3
|
+
export interface Task {
|
|
4
|
+
id: string;
|
|
5
|
+
sessionId: string;
|
|
6
|
+
status: TaskStatus;
|
|
7
|
+
priority: number;
|
|
8
|
+
createdAt: Date;
|
|
9
|
+
startedAt?: Date;
|
|
10
|
+
completedAt?: Date;
|
|
11
|
+
error?: string;
|
|
12
|
+
abortController: AbortController;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface LaneQueueOptions {
|
|
16
|
+
maxConcurrency?: number;
|
|
17
|
+
taskTimeoutMs?: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type TaskHandler<T> = (task: Task, signal: AbortSignal) => Promise<T>;
|
|
21
|
+
|
|
22
|
+
class LaneQueue {
|
|
23
|
+
private queues: Map<string, Task[]> = new Map();
|
|
24
|
+
private running: Map<string, Task> = new Map();
|
|
25
|
+
private handlers: Map<string, TaskHandler<unknown>> = new Map();
|
|
26
|
+
private taskIdCounter = 0;
|
|
27
|
+
private options: Required<LaneQueueOptions>;
|
|
28
|
+
|
|
29
|
+
constructor(options: LaneQueueOptions = {}) {
|
|
30
|
+
this.options = {
|
|
31
|
+
maxConcurrency: options.maxConcurrency ?? 1,
|
|
32
|
+
// Last-resort safety net for a runaway session, not the primary timeout
|
|
33
|
+
// mechanism — that now lives per-operation in agent-loop.ts (per LLM call)
|
|
34
|
+
// and tool-runtime/index.ts (per tool call), which can each fail fast
|
|
35
|
+
// without killing an otherwise-healthy multi-step turn.
|
|
36
|
+
taskTimeoutMs: options.taskTimeoutMs ?? 30 * 60 * 1000,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
private generateTaskId(): string {
|
|
41
|
+
return `task-${Date.now()}-${++this.taskIdCounter}`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private getQueue(sessionId: string): Task[] {
|
|
45
|
+
let queue = this.queues.get(sessionId);
|
|
46
|
+
if (!queue) {
|
|
47
|
+
queue = [];
|
|
48
|
+
this.queues.set(sessionId, queue);
|
|
49
|
+
}
|
|
50
|
+
return queue;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
enqueue<T>(
|
|
54
|
+
sessionId: string,
|
|
55
|
+
handler: TaskHandler<T>,
|
|
56
|
+
priority = 0
|
|
57
|
+
): Task {
|
|
58
|
+
const task: Task = {
|
|
59
|
+
id: this.generateTaskId(),
|
|
60
|
+
sessionId,
|
|
61
|
+
status: "pending",
|
|
62
|
+
priority,
|
|
63
|
+
createdAt: new Date(),
|
|
64
|
+
abortController: new AbortController(),
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
this.handlers.set(task.id, handler as TaskHandler<unknown>);
|
|
68
|
+
|
|
69
|
+
const queue = this.getQueue(sessionId);
|
|
70
|
+
queue.push(task);
|
|
71
|
+
queue.sort((a, b) => b.priority - a.priority);
|
|
72
|
+
|
|
73
|
+
this.processQueue(sessionId);
|
|
74
|
+
|
|
75
|
+
return task;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private async processQueue(sessionId: string): Promise<void> {
|
|
79
|
+
const running = this.running.get(sessionId);
|
|
80
|
+
if (running) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const queue = this.getQueue(sessionId);
|
|
85
|
+
if (queue.length === 0) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const task = queue.shift();
|
|
90
|
+
if (!task) return;
|
|
91
|
+
|
|
92
|
+
task.status = "running";
|
|
93
|
+
task.startedAt = new Date();
|
|
94
|
+
this.running.set(sessionId, task);
|
|
95
|
+
|
|
96
|
+
const handler = this.handlers.get(task.id);
|
|
97
|
+
|
|
98
|
+
const timeoutId = setTimeout(() => {
|
|
99
|
+
task.abortController.abort();
|
|
100
|
+
}, this.options.taskTimeoutMs);
|
|
101
|
+
|
|
102
|
+
try {
|
|
103
|
+
if (handler) {
|
|
104
|
+
await handler(task, task.abortController.signal);
|
|
105
|
+
}
|
|
106
|
+
task.status = "completed";
|
|
107
|
+
task.completedAt = new Date();
|
|
108
|
+
} catch (error) {
|
|
109
|
+
if ((error as Error).name === "AbortError") {
|
|
110
|
+
task.status = "cancelled";
|
|
111
|
+
} else {
|
|
112
|
+
task.status = "failed";
|
|
113
|
+
task.error = (error as Error).message;
|
|
114
|
+
}
|
|
115
|
+
task.completedAt = new Date();
|
|
116
|
+
} finally {
|
|
117
|
+
clearTimeout(timeoutId);
|
|
118
|
+
this.running.delete(sessionId);
|
|
119
|
+
this.handlers.delete(task.id);
|
|
120
|
+
|
|
121
|
+
if (queue.length > 0) {
|
|
122
|
+
this.processQueue(sessionId);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
cancel(sessionId: string): boolean {
|
|
128
|
+
const task = this.running.get(sessionId);
|
|
129
|
+
if (task) {
|
|
130
|
+
task.abortController.abort();
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const queue = this.getQueue(sessionId);
|
|
135
|
+
const index = queue.findIndex((t) => t.status === "pending");
|
|
136
|
+
if (index >= 0) {
|
|
137
|
+
const cancelled = queue.splice(index, 1)[0];
|
|
138
|
+
if (cancelled) {
|
|
139
|
+
cancelled.status = "cancelled";
|
|
140
|
+
cancelled.completedAt = new Date();
|
|
141
|
+
}
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
getStatus(sessionId: string): {
|
|
149
|
+
queueLength: number;
|
|
150
|
+
running?: Task;
|
|
151
|
+
} {
|
|
152
|
+
const queue = this.getQueue(sessionId);
|
|
153
|
+
const running = this.running.get(sessionId);
|
|
154
|
+
|
|
155
|
+
return {
|
|
156
|
+
queueLength: queue.length,
|
|
157
|
+
running,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
isProcessing(sessionId: string): boolean {
|
|
162
|
+
return this.running.has(sessionId);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
prune(sessionId: string): void {
|
|
166
|
+
const queue = this.getQueue(sessionId);
|
|
167
|
+
if (queue.length === 0 && !this.running.has(sessionId)) {
|
|
168
|
+
this.queues.delete(sessionId);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export const laneQueue = new LaneQueue();
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import type { NotificationDoc } from "../storage/collections";
|
|
3
|
+
import { col, updateDoc } from "../storage/hive";
|
|
4
|
+
|
|
5
|
+
export async function createNotification(input: {
|
|
6
|
+
userId: string;
|
|
7
|
+
channel: string;
|
|
8
|
+
message: string;
|
|
9
|
+
}): Promise<NotificationDoc> {
|
|
10
|
+
const notifications = await col<NotificationDoc>("notifications");
|
|
11
|
+
const id = randomUUID();
|
|
12
|
+
const notification: NotificationDoc = {
|
|
13
|
+
id,
|
|
14
|
+
user_id: input.userId,
|
|
15
|
+
channel: input.channel,
|
|
16
|
+
message: input.message,
|
|
17
|
+
created_at: Date.now(),
|
|
18
|
+
delivered_at: null,
|
|
19
|
+
read_at: null,
|
|
20
|
+
};
|
|
21
|
+
await notifications.put(id, notification, { expectedVersion: 0 });
|
|
22
|
+
return notification;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export async function listPendingNotifications(
|
|
26
|
+
userId: string,
|
|
27
|
+
channel: string,
|
|
28
|
+
): Promise<NotificationDoc[]> {
|
|
29
|
+
const notifications = await col<NotificationDoc>("notifications");
|
|
30
|
+
const rows = await notifications.findBy("user_id", userId);
|
|
31
|
+
return rows
|
|
32
|
+
.map((row) => row.doc)
|
|
33
|
+
.filter((notification) => notification.channel === channel && notification.read_at === null)
|
|
34
|
+
.sort((a, b) => a.created_at - b.created_at);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export async function markNotificationDelivered(id: string, userId: string): Promise<boolean> {
|
|
38
|
+
const notifications = await col<NotificationDoc>("notifications");
|
|
39
|
+
const existing = await notifications.get(id);
|
|
40
|
+
if (!existing || existing.doc.user_id !== userId) return false;
|
|
41
|
+
if (existing.doc.delivered_at !== null) return true;
|
|
42
|
+
await updateDoc<NotificationDoc>("notifications", id, { delivered_at: Date.now() });
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function acknowledgeNotification(id: string, userId: string): Promise<boolean> {
|
|
47
|
+
const notifications = await col<NotificationDoc>("notifications");
|
|
48
|
+
const existing = await notifications.get(id);
|
|
49
|
+
if (!existing || existing.doc.user_id !== userId) return false;
|
|
50
|
+
if (existing.doc.read_at !== null) return true;
|
|
51
|
+
const now = Date.now();
|
|
52
|
+
await updateDoc<NotificationDoc>("notifications", id, {
|
|
53
|
+
delivered_at: existing.doc.delivered_at ?? now,
|
|
54
|
+
read_at: now,
|
|
55
|
+
});
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
@@ -1,34 +1,53 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Hive Harness — durable
|
|
2
|
+
* Hive Harness — ejecución durable de tareas.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* crash recovery, idempotent job submission, goal verification, and proof
|
|
7
|
-
* packets. See docs/HIVE-HARNESS.md for the full write-up.
|
|
4
|
+
* Cola de jobs con retry/backoff, recuperación por lease tras un crash, envío
|
|
5
|
+
* idempotente, verificación de objetivos y proof packets. Ver docs/HIVE-HARNESS.md.
|
|
8
6
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
7
|
+
* **Esto es un barrel, no una implementación.** Hasta 0.1.5 `harness/` tenía su
|
|
8
|
+
* propia copia de `db-helpers`, `boot-id`, `reconcile`, `collections`, `run-store`,
|
|
9
|
+
* `run-epoch` y `proof-packet`, en paralelo con las de `storage/` y `agent/`. Dos
|
|
10
|
+
* almacenes de jobs sobre las mismas colecciones de HiveDB son una sola cosa con
|
|
11
|
+
* dos estados posibles, así que ahora esto re-exporta la implementación única y el
|
|
12
|
+
* subpath `@johpaz/hive-sdk/harness` sigue funcionando igual.
|
|
13
|
+
*
|
|
14
|
+
* El módulo no se cablea solo dentro del agent loop: la app decide qué significa
|
|
15
|
+
* "durable" para sus tipos de job y registra ejecutores con `registerExecutor()`.
|
|
12
16
|
*/
|
|
13
17
|
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export * from "
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export * from "
|
|
22
|
-
export * from "
|
|
23
|
-
export * from "
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export {
|
|
27
|
-
export {
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
import { ensureHiveDb } from "../storage/bootstrap.ts";
|
|
19
|
+
|
|
20
|
+
// ─── Cola y almacén de jobs ──────────────────────────────────────────────────
|
|
21
|
+
export * from "../gateway/job-store.ts";
|
|
22
|
+
export * from "../gateway/durable-queue.ts";
|
|
23
|
+
|
|
24
|
+
// ─── Runs: checkpoint, lease, epoch, proof ───────────────────────────────────
|
|
25
|
+
export * from "../agent/run-store.ts";
|
|
26
|
+
export * from "../agent/run-epoch.ts";
|
|
27
|
+
export * from "../agent/proof-packet.ts";
|
|
28
|
+
|
|
29
|
+
// ─── Verificación de objetivos ───────────────────────────────────────────────
|
|
30
|
+
export { runGoal, verifyGoal, interpretCheckResult } from "../agent/goal-runner.ts";
|
|
31
|
+
export type { AcceptanceResult, GoalRunOptions, GoalRunResult } from "../agent/goal-runner.ts";
|
|
32
|
+
|
|
33
|
+
// ─── Durabilidad entre arranques ─────────────────────────────────────────────
|
|
34
|
+
export { getBootId, resetBootId } from "../storage/boot-id.ts";
|
|
35
|
+
export { reconcileOnBoot } from "../storage/reconcile.ts";
|
|
36
|
+
export type { ReconcileResult } from "../storage/reconcile.ts";
|
|
37
|
+
|
|
38
|
+
// ─── Shapes ──────────────────────────────────────────────────────────────────
|
|
39
|
+
export type { JobDoc, AgentRunDoc, ProofPacketDoc } from "../storage/collections.ts";
|
|
40
|
+
|
|
41
|
+
// ─── Primitivas de colección ─────────────────────────────────────────────────
|
|
42
|
+
export { col, nextId, updateDoc, findByAny, toIndexable, fromIndexable, NO_PARENT } from "../storage/hive.ts";
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Crea los índices que necesitan las colecciones del harness.
|
|
46
|
+
*
|
|
47
|
+
* Los índices ahora se declaran en un solo lugar (`INDEXES` en storage/bootstrap.ts)
|
|
48
|
+
* y los crea `ensureHiveDb()`. Se mantiene la función porque era pública; es
|
|
49
|
+
* idempotente y llamarla en cada arranque sigue siendo seguro.
|
|
50
|
+
*/
|
|
30
51
|
export async function ensureHarnessIndexes(): Promise<void> {
|
|
31
|
-
await
|
|
32
|
-
await ensureRunStoreIndexes();
|
|
33
|
-
await ensureProofPacketIndexes();
|
|
52
|
+
await ensureHiveDb();
|
|
34
53
|
}
|
|
@@ -8,19 +8,9 @@ export type { ToolDefinition } from "./tools/ToolRegistry.ts";
|
|
|
8
8
|
export { ToolRegistry } from "./tools/ToolRegistry.ts";
|
|
9
9
|
export { ToolExecutor } from "./tools/ToolExecutor.ts";
|
|
10
10
|
export type { ToolExecutionResult } from "./tools/ToolExecutor.ts";
|
|
11
|
-
export {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
apiRequestTool,
|
|
15
|
-
browserNavigateTool,
|
|
16
|
-
browserScreenshotTool,
|
|
17
|
-
browserClickTool,
|
|
18
|
-
browserTypeTool,
|
|
19
|
-
browserExtractTool,
|
|
20
|
-
browserScriptTool,
|
|
21
|
-
browserWaitTool,
|
|
22
|
-
} from "./tools/index.ts";
|
|
23
|
-
export type { ApiAuth, HttpMethod, ResponseFormat } from "./tools/web/api-request.ts";
|
|
11
|
+
export { createAllTools, createToolsByCategory, registerAppTool, clearAppTools, listAppTools } from "./tools/index.ts";
|
|
12
|
+
export type { Tool, ToolParameter, ToolResult } from "./tools/types.ts";
|
|
13
|
+
export { apiRequestTool } from "./tools/api/index.ts";
|
|
24
14
|
|
|
25
15
|
// ─── Skills ──────────────────────────────────────────────────────────────────
|
|
26
16
|
export { defineSkill } from "./skills/defineSkill.ts";
|
|
@@ -29,9 +19,25 @@ export { SkillLoader } from "./skills/index.ts";
|
|
|
29
19
|
export type { Skill, SkillStep, OutputFormat, SkillsConfig } from "./skills/index.ts";
|
|
30
20
|
|
|
31
21
|
// ─── Agent ───────────────────────────────────────────────────────────────────
|
|
32
|
-
export {
|
|
33
|
-
export type { AgentLoopOptions, StepEvent, StreamChunk } from "./agent/
|
|
34
|
-
export type {
|
|
22
|
+
export { runAgent, runAgentIsolated, AgentLoop, getAgentLoop, buildAgentLoop, rebuildAgentLoop } from "./agent/agent-loop.ts";
|
|
23
|
+
export type { AgentLoopOptions, StepEvent, StreamChunk } from "./agent/agent-loop.ts";
|
|
24
|
+
export type { Provider } from "./agent/providers/index.ts";
|
|
25
|
+
|
|
26
|
+
// El cliente LLM es parte de la superficie pública: hasta 0.1.5 sólo se exportaba
|
|
27
|
+
// el wrapper `AgentRunner`, así que no había forma de llamar a un provider ni de
|
|
28
|
+
// leer el error tipado sin importar por ruta profunda.
|
|
29
|
+
export { callLLM, getDefaultLLM, resolveProviderConfig } from "./agent/llm-client.ts";
|
|
30
|
+
export type { LLMMessage, LLMToolCall, LLMToolDef, LLMCallOptions, LLMResponse, ContentPart } from "./agent/llm-client.ts";
|
|
31
|
+
|
|
32
|
+
// Control de prompt y contexto.
|
|
33
|
+
export { buildSystemPrompt, buildSystemPromptWithProjects } from "./agent/prompt-builder.ts";
|
|
34
|
+
export { compileContext } from "./agent/context-compiler.ts";
|
|
35
|
+
export type { CompiledContext } from "./agent/context-compiler.ts";
|
|
36
|
+
export { maybeCompact, clearOldToolResults } from "./agent/compaction.ts";
|
|
37
|
+
export { selectTools } from "./agent/tool-selector.ts";
|
|
38
|
+
export { selectSkills, getMinimalSkills } from "./agent/skill-selector.ts";
|
|
39
|
+
export { selectPlaybookRules } from "./agent/playbook-selector.ts";
|
|
40
|
+
export { MINIMAL_TOOLS } from "./agent/minimal-loadout.ts";
|
|
35
41
|
|
|
36
42
|
// ─── Swarm / Scheduler ───────────────────────────────────────────────────────
|
|
37
43
|
export { DAGScheduler } from "./swarm/index.ts";
|
|
@@ -54,14 +60,14 @@ export { Scratchpad } from "./memory/index.ts";
|
|
|
54
60
|
export type { IStorage } from "./memory/index.ts";
|
|
55
61
|
|
|
56
62
|
// ─── Storage ─────────────────────────────────────────────────────────────────
|
|
57
|
-
|
|
58
|
-
//
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
export {
|
|
63
|
+
// `ensureHiveDb()` reemplaza a `initializeDatabase()`: abre HiveDB, crea los
|
|
64
|
+
// índices y siembra el catálogo. Idempotente — se llama en cada arranque.
|
|
65
|
+
export { ensureHiveDb, col, seedAllData, SEED_DATA } from "./storage/index.ts";
|
|
66
|
+
export type { SeedData } from "./storage/index.ts";
|
|
67
|
+
export { catalogModelKey, wireModelId, isResellerProvider } from "./storage/index.ts";
|
|
68
|
+
export { calculateCost, invalidateModelPricingCache, recordUsage, getUsageStats } from "./storage/index.ts";
|
|
69
|
+
export type { UsageRecord, UsageSummary } from "./storage/index.ts";
|
|
70
|
+
export type { AgentDoc, ModelDoc, ProviderDoc, SkillDoc, ToolDoc, EthicsDoc, UserDoc } from "./storage/collections.ts";
|
|
65
71
|
|
|
66
72
|
// ─── Config ──────────────────────────────────────────────────────────────────
|
|
67
73
|
export { loadConfig, loadEnv, getHiveDir } from "./config/index.ts";
|
|
@@ -81,8 +87,8 @@ export { SlackChannel } from "./channels/slack.ts";
|
|
|
81
87
|
export { WebChatChannel } from "./channels/webchat.ts";
|
|
82
88
|
|
|
83
89
|
// ─── Canvas ──────────────────────────────────────────────────────────────────
|
|
84
|
-
export { CanvasManager } from "./canvas/
|
|
85
|
-
export { emitCanvas
|
|
90
|
+
export { CanvasManager } from "./canvas/canvas-manager.ts";
|
|
91
|
+
export { emitCanvas } from "./canvas/emitter.ts";
|
|
86
92
|
|
|
87
93
|
// ─── Tool Runtime ────────────────────────────────────────────────────────────
|
|
88
94
|
export { executeToolBatch } from "./tool-runtime/index.ts";
|
|
@@ -97,7 +103,7 @@ export { createWorker, WorkerPool } from "./workers/index.ts";
|
|
|
97
103
|
export type { WorkerConfig, WorkerInstance, WorkerChunk, WorkerPoolConfig, PoolTask, PoolTaskResult } from "./workers/index.ts";
|
|
98
104
|
|
|
99
105
|
// ─── Utils ───────────────────────────────────────────────────────────────────
|
|
100
|
-
export { logger } from "./utils/
|
|
106
|
+
export { logger } from "./utils/logger.ts";
|
|
101
107
|
export { retry } from "./utils/retry.ts";
|
|
102
108
|
|
|
103
109
|
// ─── Harness (durable task execution) ───────────────────────────────────────
|
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
* MCP Hot Reload
|
|
3
3
|
*
|
|
4
4
|
* Watches for MCP server changes in DB and updates MCP Manager automatically
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
6
|
* Architecture: Direct Connection
|
|
7
|
-
* - MCP servers are tracked in
|
|
7
|
+
* - MCP servers are tracked in the `mcpServers` HiveDB collection
|
|
8
8
|
* - MCP tools are loaded at runtime from connected servers (not stored in DB)
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import
|
|
11
|
+
import { col, updateDoc } from "../storage/hive";
|
|
12
|
+
import type { McpServerDoc } from "../storage/collections";
|
|
13
|
+
import { logger } from "../utils/logger";
|
|
14
|
+
import { loadMcpHeaders } from "../storage/crypto";
|
|
15
|
+
import { syncMCPToolsToDB, syncMCPToolsToIndex, clearMCPToolsFromDB } from "./tool-sync";
|
|
16
|
+
import type { MCPClientManager } from "./MCPClient.ts";
|
|
16
17
|
|
|
17
18
|
const log = logger.child("mcp:hot-reload");
|
|
18
19
|
|
|
@@ -61,8 +62,8 @@ export function stopMCPHotReload(): void {
|
|
|
61
62
|
*/
|
|
62
63
|
async function syncMCPServers(mcpManager: MCPClientManager): Promise<void> {
|
|
63
64
|
try {
|
|
64
|
-
const
|
|
65
|
-
const dbServers =
|
|
65
|
+
const mcpServersCol = await col<McpServerDoc>("mcpServers");
|
|
66
|
+
const dbServers = (await mcpServersCol.scan({})).map(e => e.doc).filter(s => s.enabled);
|
|
66
67
|
|
|
67
68
|
const currentServerNames = new Set(dbServers.map(s => s.id || s.name));
|
|
68
69
|
|
|
@@ -82,11 +83,12 @@ async function syncMCPServers(mcpManager: MCPClientManager): Promise<void> {
|
|
|
82
83
|
enabled: true,
|
|
83
84
|
};
|
|
84
85
|
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
const mcpHeaders = await loadMcpHeaders(server.id || server.name);
|
|
87
|
+
if (Object.keys(mcpHeaders).length > 0) {
|
|
88
|
+
mcpServerConfig.headers = mcpHeaders;
|
|
87
89
|
}
|
|
88
90
|
|
|
89
|
-
//
|
|
91
|
+
// Register (or refresh) the server's config in the manager.
|
|
90
92
|
const currentConfig = (mcpManager as any).config || { servers: {} };
|
|
91
93
|
await mcpManager.updateConfig({
|
|
92
94
|
...currentConfig,
|
|
@@ -96,22 +98,29 @@ async function syncMCPServers(mcpManager: MCPClientManager): Promise<void> {
|
|
|
96
98
|
},
|
|
97
99
|
});
|
|
98
100
|
|
|
99
|
-
//
|
|
100
|
-
|
|
101
|
+
// updateConfig() only reconnects a server whose config changed AND was
|
|
102
|
+
// already connected — it never connects a server that's merely registered
|
|
103
|
+
// (true for both a brand-new server and one restored from DB on boot).
|
|
104
|
+
// Connect explicitly so "new to this process" always means "usable now".
|
|
105
|
+
await mcpManager.connectServer(serverName).catch((err) => {
|
|
106
|
+
log.error(`Failed to connect MCP server ${serverName}: ${err.message}`);
|
|
107
|
+
});
|
|
101
108
|
|
|
102
|
-
// Get tools count and update status
|
|
109
|
+
// Get tools count and update status from the manager's real state —
|
|
110
|
+
// never assume success.
|
|
103
111
|
const tools = mcpManager.getServerTools(serverName) || [];
|
|
104
|
-
|
|
112
|
+
const connected = mcpManager.getServerStatus(serverName) === "connected";
|
|
113
|
+
await updateDoc<McpServerDoc>("mcpServers", server.id, { status: connected ? "connected" : "error", tools_count: tools.length }).catch(() => { /* not found */ });
|
|
105
114
|
|
|
106
|
-
// Persist MCP tool definitions to DB and
|
|
115
|
+
// Persist MCP tool definitions to DB and the HiveDB index
|
|
107
116
|
// Use server.name (human-readable) for mcpToolId consistency with context-compiler
|
|
108
|
-
syncMCPToolsToDB(server.id || server.name, server.name || serverName, tools);
|
|
109
|
-
await
|
|
117
|
+
await syncMCPToolsToDB(server.id || server.name, server.name || serverName, tools);
|
|
118
|
+
await syncMCPToolsToIndex();
|
|
110
119
|
|
|
111
120
|
log.info(`MCP server ${serverName} connected: ${tools.length} tools available`);
|
|
112
121
|
} catch (err) {
|
|
113
122
|
log.error(`Failed to connect MCP server ${serverName}: ${(err as Error).message}`);
|
|
114
|
-
|
|
123
|
+
await updateDoc<McpServerDoc>("mcpServers", server.id, { status: "error" }).catch(() => { /* not found */ });
|
|
115
124
|
}
|
|
116
125
|
}
|
|
117
126
|
}
|
|
@@ -127,11 +136,11 @@ async function syncMCPServers(mcpManager: MCPClientManager): Promise<void> {
|
|
|
127
136
|
delete currentConfig.servers[oldServerName];
|
|
128
137
|
await mcpManager.updateConfig(currentConfig);
|
|
129
138
|
|
|
130
|
-
// Delete MCP tool definitions from DB and
|
|
131
|
-
clearMCPToolsFromDB(oldServerName);
|
|
139
|
+
// Delete MCP tool definitions from DB and the HiveDB index
|
|
140
|
+
await clearMCPToolsFromDB(oldServerName);
|
|
132
141
|
|
|
133
142
|
// Update DB status
|
|
134
|
-
|
|
143
|
+
await updateDoc<McpServerDoc>("mcpServers", oldServerName, { status: "disconnected", tools_count: 0 }).catch(() => { /* not found */ });
|
|
135
144
|
|
|
136
145
|
log.info(`MCP server ${oldServerName} disconnected`);
|
|
137
146
|
} catch (err) {
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
export type { MCPTool, MCPResource, MCPPrompt } from "./MCPClient.ts";
|
|
2
2
|
export { MCPClientManager } from "./MCPClient.ts";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
// `tool-sync.ts` reemplaza al viejo `MCPToolAdapter.ts`: aquel escribía a SQLite
|
|
4
|
+
// y sincronizaba a FTS5; éste escribe a la colección `mcpTools` de HiveDB y
|
|
5
|
+
// reindexa con `syncMCPToolsToIndex`.
|
|
6
|
+
export type { MCPToolDefinition } from "./tool-sync.ts";
|
|
7
|
+
export { syncMCPToolsToDB, syncMCPToolsToIndex, clearMCPToolsFromDB } from "./tool-sync.ts";
|
|
5
8
|
export type { MCPConfig, MCPServerConfig } from "./config.ts";
|
|
6
|
-
export { setMCPManager, getMCPManager
|
|
9
|
+
export { setMCPManager, getMCPManager } from "./singleton.ts";
|
|
7
10
|
export { startMCPHotReload, stopMCPHotReload } from "./hot-reload.ts";
|
|
8
11
|
export type { LogLevel as MCPLogLevel, LogHandler as MCPLogHandler } from "./logger.ts";
|
|
9
12
|
export { logger as mcpLogger } from "./logger.ts";
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Provides global access to the MCP Manager instance
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import type { MCPClientManager } from "
|
|
7
|
+
import type { MCPClientManager } from "./MCPClient.ts";
|
|
8
8
|
|
|
9
9
|
let _mcpManager: MCPClientManager | null = null;
|
|
10
10
|
|
|
@@ -16,6 +16,3 @@ export function getMCPManager(): MCPClientManager | null {
|
|
|
16
16
|
return _mcpManager;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export function hasMCPManager(): boolean {
|
|
20
|
-
return _mcpManager !== null;
|
|
21
|
-
}
|