@johpaz/hive-sdk 0.1.6 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +135 -0
- package/README.md +11 -1
- package/package.json +18 -2
- package/packages/core/src/agent/acceptance-checks.ts +9 -9
- package/packages/core/src/agent/agent-catalog.ts +3 -3
- package/packages/core/src/agent/agent-loop.ts +115 -26
- package/packages/core/src/agent/capability-search.ts +2 -2
- package/packages/core/src/agent/catalog-selector.ts +4 -4
- package/packages/core/src/agent/compaction.ts +10 -9
- package/packages/core/src/agent/context-compiler.ts +58 -34
- package/packages/core/src/agent/conversation-store.ts +31 -7
- package/packages/core/src/agent/curator.ts +4 -4
- package/packages/core/src/agent/delegation-runtime.ts +5 -5
- package/packages/core/src/agent/goal-runner.ts +9 -9
- package/packages/core/src/agent/index.ts +1 -0
- package/packages/core/src/agent/llm-client.ts +98 -37
- package/packages/core/src/agent/llm-providers/anthropic.ts +4 -4
- package/packages/core/src/agent/llm-providers/deepseek.ts +1 -1
- package/packages/core/src/agent/llm-providers/gemini.ts +4 -4
- package/packages/core/src/agent/llm-providers/groq.ts +1 -1
- package/packages/core/src/agent/llm-providers/hiveagents.ts +3 -3
- package/packages/core/src/agent/llm-providers/interface.ts +2 -2
- package/packages/core/src/agent/llm-providers/kimi.ts +1 -1
- package/packages/core/src/agent/llm-providers/minimax.ts +1 -1
- package/packages/core/src/agent/llm-providers/mistral.ts +1 -1
- package/packages/core/src/agent/llm-providers/modelscope.ts +1 -1
- package/packages/core/src/agent/llm-providers/nvidia.ts +1 -1
- package/packages/core/src/agent/llm-providers/ollama.ts +4 -4
- package/packages/core/src/agent/llm-providers/openai-compat-base.ts +9 -5
- package/packages/core/src/agent/llm-providers/openai.ts +1 -1
- package/packages/core/src/agent/llm-providers/opencode-go.ts +1 -1
- package/packages/core/src/agent/llm-providers/openrouter.ts +1 -1
- package/packages/core/src/agent/llm-providers/qwen.ts +1 -1
- package/packages/core/src/agent/llm-providers/z-ai.ts +1 -1
- package/packages/core/src/agent/mcp-result-normalizer.ts +192 -0
- package/packages/core/src/agent/playbook-selector.ts +4 -4
- package/packages/core/src/agent/prompt-builder.ts +5 -5
- package/packages/core/src/agent/proof-packet.ts +5 -5
- package/packages/core/src/agent/providers/index.ts +4 -4
- package/packages/core/src/agent/realtime-providers/gemini-live.ts +238 -0
- package/packages/core/src/agent/realtime-providers/index.ts +29 -0
- package/packages/core/src/agent/realtime-providers/interface.ts +108 -0
- package/packages/core/src/agent/reflector.ts +6 -6
- package/packages/core/src/agent/run-store.ts +8 -8
- package/packages/core/src/agent/service.ts +10 -10
- package/packages/core/src/agent/skill-selector.ts +6 -6
- package/packages/core/src/agent/thread-id.ts +71 -0
- package/packages/core/src/agent/thread-store.ts +250 -0
- package/packages/core/src/agent/tool-selector.ts +7 -5
- package/packages/core/src/agent/tracer.ts +5 -5
- package/packages/core/src/api/createAgent.ts +1 -1
- package/packages/core/src/artifacts/store.ts +84 -3
- package/packages/core/src/canvas/emitter.ts +2 -2
- package/packages/core/src/channels/telegram.ts +1 -1
- package/packages/core/src/channels/webchat.ts +1 -1
- package/packages/core/src/config/loader.ts +14 -5
- package/packages/core/src/events/agent-bus.ts +3 -3
- package/packages/core/src/events/channel-narration.ts +3 -3
- package/packages/core/src/events/event-bus.ts +1 -1
- package/packages/core/src/events/narration.ts +3 -3
- package/packages/core/src/gateway/delegation-groups.ts +4 -4
- package/packages/core/src/gateway/durable-queue.ts +5 -5
- package/packages/core/src/gateway/job-store.ts +5 -5
- package/packages/core/src/gateway/notification-inbox.ts +2 -2
- package/packages/core/src/gateway/server.ts +2 -2
- package/packages/core/src/mcp/MCPClient.ts +3 -3
- package/packages/core/src/mcp/hot-reload.ts +5 -5
- package/packages/core/src/mcp/tool-sync.ts +5 -5
- package/packages/core/src/mcp/transports/index.ts +2 -2
- package/packages/core/src/mcp/transports/sse.ts +1 -1
- package/packages/core/src/models/index.ts +36 -0
- package/packages/core/src/multimodal/index.ts +2 -2
- package/packages/core/src/multimodal/vision-service.ts +6 -6
- package/packages/core/src/plugins/loader.ts +4 -1
- package/packages/core/src/resilience/circuit-breaker.ts +16 -5
- package/packages/core/src/resilience/retry.ts +1 -1
- package/packages/core/src/scheduler/CronScheduler.ts +6 -6
- package/packages/core/src/scheduler/integration.ts +9 -9
- package/packages/core/src/sessions/index.ts +266 -0
- package/packages/core/src/storage/bootstrap.ts +34 -8
- package/packages/core/src/storage/causal-events.ts +1 -1
- package/packages/core/src/storage/collections.ts +32 -1
- package/packages/core/src/storage/crypto.ts +16 -2
- package/packages/core/src/storage/hive.ts +1 -1
- package/packages/core/src/storage/hivedb.ts +10 -1
- package/packages/core/src/storage/onboarding.ts +6 -6
- package/packages/core/src/storage/reconcile.ts +5 -5
- package/packages/core/src/storage/seed.ts +103 -13
- package/packages/core/src/storage/usage.ts +3 -3
- package/packages/core/src/swarm/AgentExecutor.ts +2 -2
- package/packages/core/src/swarm/Coordinator.ts +8 -8
- package/packages/core/src/swarm/EventBridge.ts +2 -2
- package/packages/core/src/swarm/RoleSwarm.ts +234 -0
- package/packages/core/src/swarm/TaskGraph.ts +2 -2
- package/packages/core/src/swarm/index.ts +7 -0
- package/packages/core/src/swarm/presets/HiveLearnPreset.ts +2 -2
- package/packages/core/src/swarm/presets/ResearchPreset.ts +2 -2
- package/packages/core/src/swarm/strategies/ParallelStrategy.ts +1 -1
- package/packages/core/src/swarm/strategies/PriorityStrategy.ts +3 -3
- package/packages/core/src/tools/ToolExecutor.ts +7 -3
- package/packages/core/src/tools/core/index.ts +2 -2
- package/packages/core/src/tools/cron/index.ts +4 -4
- package/packages/core/src/tools/web/artifact-inspect.ts +2 -2
- package/packages/core/src/tools/web/artifact-read.ts +162 -0
- package/packages/core/src/tools/web/browser-backend.ts +141 -44
- package/packages/core/src/tools/web/browser-click.ts +2 -2
- package/packages/core/src/tools/web/browser-extract.ts +2 -2
- package/packages/core/src/tools/web/browser-navigate.ts +2 -2
- package/packages/core/src/tools/web/browser-screenshot.ts +12 -5
- package/packages/core/src/tools/web/browser-script.ts +2 -2
- package/packages/core/src/tools/web/browser-service.ts +63 -384
- package/packages/core/src/tools/web/browser-session.ts +125 -0
- package/packages/core/src/tools/web/browser-type.ts +2 -2
- package/packages/core/src/tools/web/browser-wait.ts +2 -2
- package/packages/core/src/tools/web/computer-use.ts +553 -0
- package/packages/core/src/tools/web/index.ts +8 -1
- package/packages/core/src/tools/web/webview-backend.ts +460 -21
- package/packages/core/src/utils/index.ts +1 -0
- package/packages/core/src/utils/logger.ts +12 -4
- package/packages/core/src/utils/redact-binary.ts +17 -0
- package/packages/core/src/utils/toon.ts +1 -1
- package/packages/core/src/voice/index.ts +6 -6
- package/bun.lock +0 -859
- package/bunfig.toml +0 -9
- package/docs/API-AGENTS.md +0 -367
- package/docs/API-CONTEXT-COMPILER.md +0 -249
- package/docs/API-DAG-SCHEDULER.md +0 -273
- package/docs/API-TOOLS-SKILLS-CHANNELS.md +0 -446
- package/docs/API-WORKERS-EVENTS.md +0 -299
- package/docs/HIVE-HARNESS.md +0 -113
- package/docs/INDEX.md +0 -190
- package/docs/TEMPLATE-HIVE-APP.md +0 -360
- package/packages/cli/package.json +0 -17
- package/packages/cli/src/commands/create-app.test.ts +0 -180
- package/packages/core/package.json +0 -70
- package/packages/core/src/api/createAgent.test.ts +0 -160
- package/packages/core/src/canvas/canvas.test.ts +0 -36
- package/packages/core/src/channels/channels.test.ts +0 -18
- package/packages/core/src/ethics/EthicsGuard.test.ts +0 -108
- package/packages/core/src/gateway/gateway.test.ts +0 -38
- package/packages/core/src/memory/Scratchpad.test.ts +0 -68
- package/packages/core/src/scheduler/scheduler.test.ts +0 -15
- package/packages/core/src/skills/skills.test.ts +0 -62
- package/packages/core/src/swarm/swarm.test.ts +0 -24
- package/packages/core/src/tool-runtime/tool-runtime.test.ts +0 -99
- package/packages/core/src/tools/ToolRegistry.test.ts +0 -98
- package/packages/core/src/tools/api/api-request.test.ts +0 -164
- package/packages/core/src/tools/web/browser-service.test.ts +0 -83
- package/packages/core/src/workers/workers.test.ts +0 -41
- package/scripts/bump-version.ts +0 -248
- package/scripts/generate-skill-bundle.ts +0 -108
- package/test/acceptance-checks.test.ts +0 -403
- package/test/agent-loop-terminal-synthesis.test.ts +0 -32
- package/test/browser-backend.test.ts +0 -308
- package/test/catalog-agents-stay-enabled.test.ts +0 -117
- package/test/causal-events.test.ts +0 -117
- package/test/compaction.test.ts +0 -105
- package/test/context-compiler.test.ts +0 -269
- package/test/curator.test.ts +0 -130
- package/test/durable-queue.test.ts +0 -114
- package/test/harness-barrel.test.ts +0 -64
- package/test/hive-helpers.test.ts +0 -130
- package/test/hivedb-search.test.ts +0 -189
- package/test/internal-turns.test.ts +0 -166
- package/test/job-idempotency.test.ts +0 -68
- package/test/job-retry-backoff.test.ts +0 -184
- package/test/job-store.test.ts +0 -381
- package/test/llm-retry.test.ts +0 -97
- package/test/memory-perf.test.ts +0 -774
- package/test/minimal-loadout.test.ts +0 -78
- package/test/model-catalog.test.ts +0 -105
- package/test/preload.ts +0 -12
- package/test/reflector.test.ts +0 -320
- package/test/retention-cap.test.ts +0 -91
- package/test/retired-capabilities-pruned.test.ts +0 -192
- package/test/run-store.test.ts +0 -355
- package/test/scratchpad.test.ts +0 -74
- package/test/secrets-durability.test.ts +0 -119
- package/test/seed-model-reseed.test.ts +0 -155
- package/test/setup-agent-seed.test.ts +0 -264
- package/test/tool-inventory.test.ts +0 -65
- package/test/tool-runtime.test.ts +0 -258
- package/test/tool-selector-runtime-tools.test.ts +0 -117
- package/test/toon.test.ts +0 -429
- package/tsconfig.json +0 -42
|
@@ -20,7 +20,14 @@ export function loadEnv(hiveDir: string): void {
|
|
|
20
20
|
const [key, ...valueParts] = trimmed.split("=");
|
|
21
21
|
if (key && valueParts.length > 0) {
|
|
22
22
|
const value = valueParts.join("=").trim().replace(/^['"]|['"]$/g, "");
|
|
23
|
-
|
|
23
|
+
const normalizedKey = key.trim();
|
|
24
|
+
// Explicit process environment values (for example the random
|
|
25
|
+
// port assigned by the desktop shell) must take precedence over the
|
|
26
|
+
// persisted .env file. This follows dotenv conventions and prevents
|
|
27
|
+
// a previous CLI port from breaking desktop startup.
|
|
28
|
+
if (process.env[normalizedKey] === undefined) {
|
|
29
|
+
process.env[normalizedKey] = value;
|
|
30
|
+
}
|
|
24
31
|
}
|
|
25
32
|
}
|
|
26
33
|
} catch (e) {
|
|
@@ -120,11 +127,13 @@ const BrowserConfigSchema = z.object({
|
|
|
120
127
|
headless: z.boolean().optional(),
|
|
121
128
|
timeoutMs: z.number().optional(),
|
|
122
129
|
sessionName: z.string().optional(),
|
|
123
|
-
//
|
|
124
|
-
//
|
|
125
|
-
//
|
|
126
|
-
// sólo si hay motor. Lo pisa HIVE_BROWSER_BACKEND.
|
|
130
|
+
// Queda un solo backend: Bun.WebView in-process. La clave sobrevive para no
|
|
131
|
+
// romper configs viejas —"agent-browser" se acepta, avisa y usa el WebView—
|
|
132
|
+
// y se puede quitar sin más. Lo pisa HIVE_BROWSER_BACKEND.
|
|
127
133
|
backend: z.enum(["agent-browser", "webview", "auto"]).optional(),
|
|
134
|
+
// Guarda las cookies para que los logins sobrevivan a un reinicio. Default
|
|
135
|
+
// activo; apagarlo hace que cada arranque empiece sin historia.
|
|
136
|
+
persistSession: z.boolean().optional(),
|
|
128
137
|
});
|
|
129
138
|
|
|
130
139
|
const CanvasConfigSchema = z.object({
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { EventEmitter } from "events";
|
|
13
|
-
import { logger } from "../utils/logger";
|
|
14
|
-
import { col, nextId, toIndexable, fromIndexable, BROADCAST } from "../storage/hive";
|
|
15
|
-
import type { AgentBusMessageDoc, TaskDoc } from "../storage/collections";
|
|
13
|
+
import { logger } from "../utils/logger.ts";
|
|
14
|
+
import { col, nextId, toIndexable, fromIndexable, BROADCAST } from "../storage/hive.ts";
|
|
15
|
+
import type { AgentBusMessageDoc, TaskDoc } from "../storage/collections.ts";
|
|
16
16
|
|
|
17
17
|
const log = logger.child("agent-bus");
|
|
18
18
|
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
// messages before the actual answer — noise for the user and a rate-limit /
|
|
7
7
|
// ban risk on WhatsApp. This module decides what reaches those channels.
|
|
8
8
|
|
|
9
|
-
import { col } from "../storage/hive";
|
|
10
|
-
import type { ChannelDoc, NarrationEventDoc } from "../storage/collections";
|
|
11
|
-
import { logger } from "../utils/logger";
|
|
9
|
+
import { col } from "../storage/hive.ts";
|
|
10
|
+
import type { ChannelDoc, NarrationEventDoc } from "../storage/collections.ts";
|
|
11
|
+
import { logger } from "../utils/logger.ts";
|
|
12
12
|
|
|
13
13
|
const log = logger.child("narration:channel");
|
|
14
14
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import { col } from "../storage/hive";
|
|
3
|
-
import type { NarrationEventDoc } from "../storage/collections";
|
|
4
|
-
import { logger } from "../utils/logger";
|
|
2
|
+
import { col } from "../storage/hive.ts";
|
|
3
|
+
import type { NarrationEventDoc } from "../storage/collections.ts";
|
|
4
|
+
import { logger } from "../utils/logger.ts";
|
|
5
5
|
|
|
6
6
|
const log = logger.child("narration");
|
|
7
7
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { col } from "../storage/hive";
|
|
1
|
+
import { col } from "../storage/hive.ts";
|
|
2
2
|
import type {
|
|
3
3
|
DelegationGroupDoc,
|
|
4
4
|
DelegationGroupOutcome,
|
|
5
|
-
} from "../storage/collections";
|
|
6
|
-
import { logger } from "../utils/logger";
|
|
7
|
-
import { publishNarration } from "../events/narration";
|
|
5
|
+
} from "../storage/collections.ts";
|
|
6
|
+
import { logger } from "../utils/logger.ts";
|
|
7
|
+
import { publishNarration } from "../events/narration.ts";
|
|
8
8
|
|
|
9
9
|
const log = logger.child("delegation-groups");
|
|
10
10
|
const MAX_RETRIES = 8;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* is preserved, while all queue state is mirrored to the DB.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { logger } from "../utils/logger";
|
|
17
|
+
import { logger } from "../utils/logger.ts";
|
|
18
18
|
import {
|
|
19
19
|
createJob,
|
|
20
20
|
claimJob,
|
|
@@ -30,9 +30,9 @@ import {
|
|
|
30
30
|
loadJobRetryPolicy,
|
|
31
31
|
DEFAULT_JOB_RETRY_POLICY,
|
|
32
32
|
type JobRetryPolicy,
|
|
33
|
-
} from "./job-store";
|
|
34
|
-
import type { JobDoc } from "../storage/collections";
|
|
35
|
-
import { getBootId } from "../storage/boot-id";
|
|
33
|
+
} from "./job-store.ts";
|
|
34
|
+
import type { JobDoc } from "../storage/collections.ts";
|
|
35
|
+
import { getBootId } from "../storage/boot-id.ts";
|
|
36
36
|
|
|
37
37
|
const log = logger.child("durable-queue");
|
|
38
38
|
|
|
@@ -287,7 +287,7 @@ export class DurableLaneQueue {
|
|
|
287
287
|
let leasedHere = true;
|
|
288
288
|
const leaseRenewer = setInterval(async () => {
|
|
289
289
|
if (leasedHere) {
|
|
290
|
-
const { renewLease } = await import("./job-store");
|
|
290
|
+
const { renewLease } = await import("./job-store.ts");
|
|
291
291
|
await renewLease(job.id, this.bootId).catch(() => {});
|
|
292
292
|
}
|
|
293
293
|
}, 30_000);
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
* path guarantees only one process wins the race for the same job.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { col, nextId, updateDoc, toIndexable } from "../storage/hive";
|
|
9
|
-
import type { JobDoc } from "../storage/collections";
|
|
10
|
-
import { getBootId } from "../storage/boot-id";
|
|
11
|
-
import { logger } from "../utils/logger";
|
|
12
|
-
import { loadConfig } from "../config/loader";
|
|
8
|
+
import { col, nextId, updateDoc, toIndexable } from "../storage/hive.ts";
|
|
9
|
+
import type { JobDoc } from "../storage/collections.ts";
|
|
10
|
+
import { getBootId } from "../storage/boot-id.ts";
|
|
11
|
+
import { logger } from "../utils/logger.ts";
|
|
12
|
+
import { loadConfig } from "../config/loader.ts";
|
|
13
13
|
|
|
14
14
|
const log = logger.child("job-store");
|
|
15
15
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
|
-
import type { NotificationDoc } from "../storage/collections";
|
|
3
|
-
import { col, updateDoc } from "../storage/hive";
|
|
2
|
+
import type { NotificationDoc } from "../storage/collections.ts";
|
|
3
|
+
import { col, updateDoc } from "../storage/hive.ts";
|
|
4
4
|
|
|
5
5
|
export async function createNotification(input: {
|
|
6
6
|
userId: string;
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
* - WebSocket /ws — real-time streaming
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { logger } from "../utils/logger";
|
|
10
|
+
import { logger } from "../utils/logger.ts";
|
|
11
11
|
import { runAgent } from "../agent/agent-loop.ts";
|
|
12
|
-
import type { MCPClientManager } from "../mcp/index";
|
|
12
|
+
import type { MCPClientManager } from "../mcp/index.ts";
|
|
13
13
|
|
|
14
14
|
const log = logger.child("gateway");
|
|
15
15
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
2
2
|
import type { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
3
|
-
import type { MCPConfig, MCPServerConfig } from "./config";
|
|
4
|
-
import { logger, type LogHandler } from "./logger";
|
|
3
|
+
import type { MCPConfig, MCPServerConfig } from "./config.ts";
|
|
4
|
+
import { logger, type LogHandler } from "./logger.ts";
|
|
5
5
|
import * as path from "node:path";
|
|
6
6
|
import {
|
|
7
7
|
createTransport,
|
|
8
8
|
type TransportType,
|
|
9
|
-
} from "./transports/index";
|
|
9
|
+
} from "./transports/index.ts";
|
|
10
10
|
|
|
11
11
|
export interface MCPTool {
|
|
12
12
|
name: string;
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
* - MCP tools are loaded at runtime from connected servers (not stored in DB)
|
|
9
9
|
*/
|
|
10
10
|
|
|
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";
|
|
11
|
+
import { col, updateDoc } from "../storage/hive.ts";
|
|
12
|
+
import type { McpServerDoc } from "../storage/collections.ts";
|
|
13
|
+
import { logger } from "../utils/logger.ts";
|
|
14
|
+
import { loadMcpHeaders } from "../storage/crypto.ts";
|
|
15
|
+
import { syncMCPToolsToDB, syncMCPToolsToIndex, clearMCPToolsFromDB } from "./tool-sync.ts";
|
|
16
16
|
import type { MCPClientManager } from "./MCPClient.ts";
|
|
17
17
|
|
|
18
18
|
const log = logger.child("mcp:hot-reload");
|
|
@@ -13,15 +13,15 @@
|
|
|
13
13
|
* 3. Offline visibility of what MCP tools were available
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
import { col } from "../storage/hive"
|
|
17
|
-
import type { McpToolDoc } from "../storage/collections"
|
|
18
|
-
import { logger } from "../utils/logger"
|
|
19
|
-
import { mcpToolFullName } from "../agent/tool-selector"
|
|
16
|
+
import { col } from "../storage/hive.ts"
|
|
17
|
+
import type { McpToolDoc } from "../storage/collections.ts"
|
|
18
|
+
import { logger } from "../utils/logger.ts"
|
|
19
|
+
import { mcpToolFullName } from "../agent/tool-selector.ts"
|
|
20
20
|
import {
|
|
21
21
|
replaceCapabilityDocs,
|
|
22
22
|
deleteCapabilitiesByServer,
|
|
23
23
|
type CapabilityDoc,
|
|
24
|
-
} from "../agent/capability-search"
|
|
24
|
+
} from "../agent/capability-search.ts"
|
|
25
25
|
|
|
26
26
|
const log = logger.child("mcp:tool-sync")
|
|
27
27
|
|
|
@@ -4,8 +4,8 @@ import type { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
|
4
4
|
// CORRECCIÓN 1 — quitar extensión .ts de los imports
|
|
5
5
|
// Bun resuelve los módulos sin extensión correctamente
|
|
6
6
|
// Con .ts puede fallar en algunos contextos de build/bundle
|
|
7
|
-
import { SSETransport, type SSETransportConfig } from "./sse";
|
|
8
|
-
import { WebSocketTransport, type WebSocketTransportConfig } from "./websocket";
|
|
7
|
+
import { SSETransport, type SSETransportConfig } from "./sse.ts";
|
|
8
|
+
import { WebSocketTransport, type WebSocketTransportConfig } from "./websocket.ts";
|
|
9
9
|
|
|
10
10
|
export { SSETransport, type SSETransportConfig };
|
|
11
11
|
export { WebSocketTransport, type WebSocketTransportConfig };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Models — el catálogo de proveedores y modelos con el que arranca una colmena.
|
|
3
|
+
*
|
|
4
|
+
* El "seed de modelos" ya existÃa, pero repartido en `storage/`: los datos en
|
|
5
|
+
* `seed.ts`, las claves en `model-id.ts`, el precio en `usage.ts`. Quien querÃa
|
|
6
|
+
* consumirlo tenÃa que saber que un catálogo de modelos vive bajo "storage".
|
|
7
|
+
* Esto le da nombre y un punto de entrada; no mueve la implementación ni
|
|
8
|
+
* duplica nada.
|
|
9
|
+
*
|
|
10
|
+
* `SEED_DATA` es la fuente de verdad del catálogo (18 proveedores, ~110 modelos)
|
|
11
|
+
* y `seedAllData()` la aplica de forma idempotente en cada arranque — la llama
|
|
12
|
+
* `ensureHiveDb()`, asà que normalmente no hace falta invocarla a mano.
|
|
13
|
+
*
|
|
14
|
+
* Nota de precios: cada modelo LLM declara `inputPer1M`/`outputPer1M`. Un modelo
|
|
15
|
+
* sin ellos no es "gratis", es un modelo cuyo costo no se puede calcular.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
// ─── Catálogo ────────────────────────────────────────────────────────────────
|
|
19
|
+
export { SEED_DATA, seedAllData, seedToolsAndSkills } from "../storage/seed.ts";
|
|
20
|
+
export type { SeedData } from "../storage/seed.ts";
|
|
21
|
+
export { activateElement, deactivateElement, getAllElements, getActiveElements } from "../storage/seed.ts";
|
|
22
|
+
|
|
23
|
+
// ─── Identidad de modelo ─────────────────────────────────────────────────────
|
|
24
|
+
/**
|
|
25
|
+
* Los revendedores (openrouter, nvidia, groq, opencode-go, modelscope) sirven
|
|
26
|
+
* modelos de terceros bajo su propio endpoint, asà que el id del wire colisiona
|
|
27
|
+
* entre proveedores. `catalogModelKey` prefija; `wireModelId` deshace el prefijo
|
|
28
|
+
* antes de salir a la API.
|
|
29
|
+
*/
|
|
30
|
+
export { catalogModelKey, wireModelId, isResellerProvider } from "../storage/model-id.ts";
|
|
31
|
+
|
|
32
|
+
// ─── Costos ──────────────────────────────────────────────────────────────────
|
|
33
|
+
export { calculateCost, invalidateModelPricingCache } from "../storage/usage.ts";
|
|
34
|
+
|
|
35
|
+
// ─── Shapes ──────────────────────────────────────────────────────────────────
|
|
36
|
+
export type { ModelDoc, ProviderDoc } from "../storage/collections.ts";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { ContentPart, ImageInput, DocumentInput, VisionConfig, MultimodalMessageType } from "./types"
|
|
2
|
-
export { multimodalService } from "./vision-service"
|
|
1
|
+
export type { ContentPart, ImageInput, DocumentInput, VisionConfig, MultimodalMessageType } from "./types.ts"
|
|
2
|
+
export { multimodalService } from "./vision-service.ts"
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { col } from "../storage/hive"
|
|
2
|
-
import type { ChannelDoc, ModelDoc, ProviderDoc } from "../storage/collections"
|
|
3
|
-
import { loadProviderApiKey } from "../storage/crypto"
|
|
4
|
-
import { logger } from "../utils/logger"
|
|
5
|
-
import type { ImageInput, DocumentInput, VisionConfig } from "./types"
|
|
6
|
-
import type { ContentPart } from "./types"
|
|
1
|
+
import { col } from "../storage/hive.ts"
|
|
2
|
+
import type { ChannelDoc, ModelDoc, ProviderDoc } from "../storage/collections.ts"
|
|
3
|
+
import { loadProviderApiKey } from "../storage/crypto.ts"
|
|
4
|
+
import { logger } from "../utils/logger.ts"
|
|
5
|
+
import type { ImageInput, DocumentInput, VisionConfig } from "./types.ts"
|
|
6
|
+
import type { ContentPart } from "./types.ts"
|
|
7
7
|
|
|
8
8
|
const log = logger.child("multimodal")
|
|
9
9
|
|
|
@@ -30,7 +30,10 @@ export class PluginLoader {
|
|
|
30
30
|
private commands: Map<string, CLICommand> = new Map();
|
|
31
31
|
private log = logger.child("plugins");
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
private options: PluginLoaderOptions;
|
|
34
|
+
|
|
35
|
+
constructor(options: PluginLoaderOptions) {
|
|
36
|
+
this.options = options;
|
|
34
37
|
if (!existsSync(options.pluginDir)) {
|
|
35
38
|
mkdirSync(options.pluginDir, { recursive: true });
|
|
36
39
|
}
|
|
@@ -39,10 +39,16 @@ export class CircuitBreaker {
|
|
|
39
39
|
private totalFailures = 0;
|
|
40
40
|
private totalSuccesses = 0;
|
|
41
41
|
|
|
42
|
+
private readonly name: string;
|
|
43
|
+
private readonly options: CircuitBreakerOptions;
|
|
44
|
+
|
|
42
45
|
constructor(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
) {
|
|
46
|
+
name: string,
|
|
47
|
+
options: CircuitBreakerOptions = defaultOptions
|
|
48
|
+
) {
|
|
49
|
+
this.name = name;
|
|
50
|
+
this.options = options;
|
|
51
|
+
}
|
|
46
52
|
|
|
47
53
|
async execute<T>(fn: () => Promise<T>): Promise<T> {
|
|
48
54
|
if (this.state === "open") {
|
|
@@ -175,12 +181,17 @@ export class CircuitBreaker {
|
|
|
175
181
|
}
|
|
176
182
|
|
|
177
183
|
export class CircuitBreakerOpenError extends Error {
|
|
184
|
+
public readonly circuitName: string;
|
|
185
|
+
public readonly retryAfterMs: number;
|
|
186
|
+
|
|
178
187
|
constructor(
|
|
179
188
|
message: string,
|
|
180
|
-
|
|
181
|
-
|
|
189
|
+
circuitName: string,
|
|
190
|
+
retryAfterMs: number
|
|
182
191
|
) {
|
|
183
192
|
super(message);
|
|
193
|
+
this.circuitName = circuitName;
|
|
194
|
+
this.retryAfterMs = retryAfterMs;
|
|
184
195
|
this.name = "CircuitBreakerOpenError";
|
|
185
196
|
}
|
|
186
197
|
}
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { Cron } from "croner";
|
|
9
|
-
import { logger } from "../utils/logger";
|
|
10
|
-
import { notifyTaskCompletion } from "./integration";
|
|
11
|
-
import { col, toIndexable, fromIndexable } from "../storage/hive";
|
|
12
|
-
import type { CronJobDoc, TaskRunDoc } from "../storage/collections";
|
|
13
|
-
import { expireArtifacts } from "../artifacts/store";
|
|
9
|
+
import { logger } from "../utils/logger.ts";
|
|
10
|
+
import { notifyTaskCompletion } from "./integration.ts";
|
|
11
|
+
import { col, toIndexable, fromIndexable } from "../storage/hive.ts";
|
|
12
|
+
import type { CronJobDoc, TaskRunDoc } from "../storage/collections.ts";
|
|
13
|
+
import { expireArtifacts } from "../artifacts/store.ts";
|
|
14
14
|
import type {
|
|
15
15
|
CronJob,
|
|
16
16
|
TaskRun,
|
|
@@ -18,7 +18,7 @@ import type {
|
|
|
18
18
|
UpdateCronJobInput,
|
|
19
19
|
CronJobStatus,
|
|
20
20
|
CronJobExecutionHandler,
|
|
21
|
-
} from "./types";
|
|
21
|
+
} from "./types.ts";
|
|
22
22
|
|
|
23
23
|
const log = logger.child("CronScheduler");
|
|
24
24
|
|
|
@@ -5,16 +5,16 @@
|
|
|
5
5
|
* Converts cron jobs into system messages that flow through the agent system.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type { CronJob, CronJobExecutionResult } from "./types";
|
|
9
|
-
import { logger } from "../utils/logger";
|
|
10
|
-
import { buildAgentLoop } from "../agent/agent-loop";
|
|
11
|
-
import { resolveAgentId } from "../storage/onboarding";
|
|
12
|
-
import { sendToUserChannel } from "../gateway/channel-notify";
|
|
8
|
+
import type { CronJob, CronJobExecutionResult } from "./types.ts";
|
|
9
|
+
import { logger } from "../utils/logger.ts";
|
|
10
|
+
import { buildAgentLoop } from "../agent/agent-loop.ts";
|
|
11
|
+
import { resolveAgentId } from "../storage/onboarding.ts";
|
|
12
|
+
import { sendToUserChannel } from "../gateway/channel-notify.ts";
|
|
13
13
|
import { getNarration } from "../events/tool-narration.ts";
|
|
14
|
-
import { addMessage } from "../agent/conversation-store";
|
|
15
|
-
import { resolveBestChannel } from "../tools/cron/index";
|
|
16
|
-
import { col } from "../storage/hive";
|
|
17
|
-
import type { UserDoc, CronJobDoc } from "../storage/collections";
|
|
14
|
+
import { addMessage } from "../agent/conversation-store.ts";
|
|
15
|
+
import { resolveBestChannel } from "../tools/cron/index.ts";
|
|
16
|
+
import { col } from "../storage/hive.ts";
|
|
17
|
+
import type { UserDoc, CronJobDoc } from "../storage/collections.ts";
|
|
18
18
|
|
|
19
19
|
const log = logger.child("SchedulerIntegration");
|
|
20
20
|
|