@johpaz/hive-agents 0.0.44 → 0.0.47
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 +88 -38
- package/dist/hive.js +1273 -846
- package/dist/tool-worker.js +30 -0
- package/dist/ui/assets/{AgentCreateForm-DyeTdXUs.js → AgentCreateForm-DzaIT-dA.js} +1 -1
- package/dist/ui/assets/{AgentDetailPage-dmLgf2x5.js → AgentDetailPage-DgqcJceY.js} +1 -1
- package/dist/ui/assets/AgentNewPage-CNSpoOSA.js +1 -0
- package/dist/ui/assets/{AgentsPage-ilEW_WjD.js → AgentsPage-BMUJzTD6.js} +1 -1
- package/dist/ui/assets/{ApiClientPage-CYur6xIG.js → ApiClientPage-Cum_a_3j.js} +1 -1
- package/dist/ui/assets/{CanvasPage-CvMRvq84.js → CanvasPage-o6oCP6uq.js} +1 -1
- package/dist/ui/assets/{ChannelsPage-D4PgfYd2.js → ChannelsPage-WrB0zwLq.js} +1 -1
- package/dist/ui/assets/{DashboardPage-a5UQKJCG.js → DashboardPage-BCd6kNw0.js} +1 -1
- package/dist/ui/assets/{LoginPage-BtMt11D2.js → LoginPage-BTxJdFVG.js} +1 -1
- package/dist/ui/assets/{LogsPage-BeuKjg7-.js → LogsPage-DVV2eHbh.js} +1 -1
- package/dist/ui/assets/{MeetingPage-ClhToyd9.js → MeetingPage-BULIAWzq.js} +1 -1
- package/dist/ui/assets/{ModelSelector-DoMPQbsp.js → ModelSelector-BMYOChYb.js} +1 -1
- package/dist/ui/assets/{ProvidersPage-D6YX7qH4.js → ProvidersPage-BVN5UZrI.js} +1 -1
- package/dist/ui/assets/{RecoverPage-CzouUsK3.js → RecoverPage-7YDQysBL.js} +1 -1
- package/dist/ui/assets/SettingsPage-CYmpFfDn.js +9 -0
- package/dist/ui/assets/{SetupPage-DhyJWZkx.js → SetupPage-Dnmb1Lbv.js} +1 -1
- package/dist/ui/assets/{WebChatPage-DJVJDa6u.js → WebChatPage-DmmdFhIC.js} +1 -1
- package/dist/ui/assets/{alert-CwfjnQnX.js → alert-B9J6KHmt.js} +1 -1
- package/dist/ui/assets/{alert-dialog-BModLupB.js → alert-dialog-KcYQWcJ6.js} +1 -1
- package/dist/ui/assets/{badge-Cn9me8rp.js → badge-88dRb4M8.js} +1 -1
- package/dist/ui/assets/{dialog-BVdxpXxW.js → dialog-Jk4bieO4.js} +1 -1
- package/dist/ui/assets/{es-Ce6Cl5pC.js → es-4I-joeZz.js} +1 -1
- package/dist/ui/assets/{index-CaoDouMU.js → index-Cyw7L0Li.js} +2 -2
- package/dist/ui/assets/{label-CRcJ7SgM.js → label-B_15zZlR.js} +1 -1
- package/dist/ui/assets/{useHiveAgentsModelLoad-mAw1534H.js → useHiveAgentsModelLoad-BnC4jLE-.js} +1 -1
- package/dist/ui/assets/{useProviders-am-lsXGu.js → useProviders-C1xVKLxB.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/package.json +1 -1
- package/packages/core/src/agent/goal-runner.ts +31 -2
- package/packages/core/src/agent/llm-client.ts +22 -1
- package/packages/core/src/agent/proof-packet.ts +59 -0
- package/packages/core/src/agent/run-epoch.ts +33 -0
- package/packages/core/src/agent/run-store.ts +50 -8
- package/packages/core/src/channels/telegram.ts +31 -2
- package/packages/core/src/config/loader.ts +34 -0
- package/packages/core/src/gateway/durable-queue.ts +49 -4
- package/packages/core/src/gateway/job-executors.ts +50 -11
- package/packages/core/src/gateway/job-store.ts +142 -4
- package/packages/core/src/gateway/routes/cron-api.ts +3 -2
- package/packages/core/src/gateway/routes/users.ts +1 -0
- package/packages/core/src/gateway/server.ts +24 -2
- package/packages/core/src/resilience/retry.ts +95 -0
- package/packages/core/src/scheduler/integration.ts +19 -0
- package/packages/core/src/storage/bootstrap.ts +3 -0
- package/packages/core/src/storage/collections.ts +36 -0
- package/packages/core/src/storage/seed.ts +26 -22
- package/packages/core/src/tools/agents/get-available-models.ts +11 -3
- package/packages/core/src/tools/agents/index.ts +12 -3
- package/dist/ui/assets/AgentNewPage-CgGzBw7_.js +0 -1
- package/dist/ui/assets/SettingsPage-BtXGg87M.js +0 -9
|
@@ -25,10 +25,11 @@ import { ensureHiveDb } from "../storage/bootstrap";
|
|
|
25
25
|
import { col, fromIndexable, nextId } from "../storage/hive";
|
|
26
26
|
import { reconcileOnBoot } from "../storage/reconcile";
|
|
27
27
|
import { getBootId } from "../storage/boot-id";
|
|
28
|
-
import { stopAllLeaseRenewals, interruptRun } from "../agent/run-store";
|
|
28
|
+
import { stopAllLeaseRenewals, interruptRun, findRunsByStatus } from "../agent/run-store";
|
|
29
29
|
import { shutdownToolRuntime } from "../tool-runtime";
|
|
30
30
|
import { initDurableQueue, getDurableQueue } from "./durable-queue";
|
|
31
31
|
import { initJobExecutors, setJobExecutorMCPManager } from "./job-executors";
|
|
32
|
+
import { findAllPendingJobs, findExpiredLeases, loadJobRetryPolicy } from "./job-store";
|
|
32
33
|
import { initTaskDriver } from "../scheduler/task-driver";
|
|
33
34
|
import type { UserDoc, AgentDoc } from "../storage/collections";
|
|
34
35
|
import { canvasManager } from "../canvas/canvas-manager.ts";
|
|
@@ -227,7 +228,12 @@ export async function startGateway(
|
|
|
227
228
|
|
|
228
229
|
// Initialize durable queue + executors
|
|
229
230
|
initJobExecutors();
|
|
230
|
-
const
|
|
231
|
+
const harnessCfg = config.harness;
|
|
232
|
+
const durableQueue = initDurableQueue({
|
|
233
|
+
maxGlobalConcurrency: harnessCfg?.maxGlobalConcurrency ?? 4,
|
|
234
|
+
taskTimeoutMs: harnessCfg?.taskTimeoutMs ?? 30 * 60 * 1000,
|
|
235
|
+
jobRetryPolicy: loadJobRetryPolicy(),
|
|
236
|
+
});
|
|
231
237
|
setJobExecutorMCPManager(agent?.getMCPManager() ?? null);
|
|
232
238
|
// chat_turn jobs re-execute through this runner (live or post-crash)
|
|
233
239
|
initWebchatTurnRunner({
|
|
@@ -793,11 +799,27 @@ export async function startGateway(
|
|
|
793
799
|
// ── Health (must be before UI routing so it works in dev mode too) ───
|
|
794
800
|
if (url.pathname === "/health" || url.pathname === "/health/") {
|
|
795
801
|
const uptime = Math.floor((Date.now() - startTime) / 1000);
|
|
802
|
+
const dq = getDurableQueue();
|
|
803
|
+
const [pending, expiredLeases, activeRuns] = await Promise.all([
|
|
804
|
+
findAllPendingJobs().catch(() => []),
|
|
805
|
+
findExpiredLeases().catch(() => []),
|
|
806
|
+
findRunsByStatus("running").catch(() => []),
|
|
807
|
+
]);
|
|
796
808
|
return addCorsHeaders(Response.json({
|
|
797
809
|
status: "ok",
|
|
798
810
|
version: _pkgVersion,
|
|
799
811
|
uptime,
|
|
812
|
+
bootId: getBootId(),
|
|
800
813
|
circuitBreakers: circuitBreakerRegistry.getAllStats(),
|
|
814
|
+
queue: {
|
|
815
|
+
running: dq.getRunningCount(),
|
|
816
|
+
maxGlobalConcurrency: dq.getMaxGlobalConcurrency(),
|
|
817
|
+
pending: pending.length,
|
|
818
|
+
expiredLeases: expiredLeases.length,
|
|
819
|
+
},
|
|
820
|
+
runs: {
|
|
821
|
+
active: activeRuns.length,
|
|
822
|
+
},
|
|
801
823
|
}), req);
|
|
802
824
|
}
|
|
803
825
|
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic retry-with-backoff helper for transient failures (LLM provider
|
|
3
|
+
* calls, network/tool errors). Complements CircuitBreaker (circuit-breaker.ts),
|
|
4
|
+
* which sits one layer out and trips on sustained failure rates — this module
|
|
5
|
+
* only decides whether a single call should be retried and how long to wait.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { logger } from "../utils/logger";
|
|
9
|
+
|
|
10
|
+
const log = logger.child("retry");
|
|
11
|
+
|
|
12
|
+
export interface RetryPolicy {
|
|
13
|
+
maxAttempts: number;
|
|
14
|
+
initialDelayMs: number;
|
|
15
|
+
backoffMultiplier: number;
|
|
16
|
+
maxDelayMs: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const DEFAULT_RETRY_POLICY: RetryPolicy = {
|
|
20
|
+
maxAttempts: 3,
|
|
21
|
+
initialDelayMs: 1000,
|
|
22
|
+
backoffMultiplier: 2,
|
|
23
|
+
maxDelayMs: 30_000,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/** Exponential backoff with full jitter, capped at policy.maxDelayMs. */
|
|
27
|
+
export function computeRetryDelay(attempt: number, policy: RetryPolicy, retryAfterMs?: number): number {
|
|
28
|
+
if (retryAfterMs !== undefined) return Math.min(retryAfterMs, policy.maxDelayMs);
|
|
29
|
+
const base = Math.min(policy.maxDelayMs, policy.initialDelayMs * Math.pow(policy.backoffMultiplier, attempt));
|
|
30
|
+
return Math.round(base * (0.5 + Math.random() * 0.5));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* HTTP-status-aware transient classifier: 408/429/5xx/network/timeout are
|
|
35
|
+
* retryable, 400/401/403/404 (and anything else) are terminal. Looks for a
|
|
36
|
+
* `status`/`statusCode` property (most provider SDKs set one) or common
|
|
37
|
+
* network/timeout error names/messages as a fallback.
|
|
38
|
+
*/
|
|
39
|
+
export function isRetryableError(err: unknown): boolean {
|
|
40
|
+
const status = extractStatus(err);
|
|
41
|
+
if (status !== undefined) {
|
|
42
|
+
if (status === 408 || status === 429) return true;
|
|
43
|
+
if (status >= 500 && status < 600) return true;
|
|
44
|
+
if (status >= 400 && status < 500) return false;
|
|
45
|
+
}
|
|
46
|
+
const name = (err as { name?: string })?.name ?? "";
|
|
47
|
+
const message = (err as { message?: string })?.message ?? String(err);
|
|
48
|
+
if (name === "AbortError") return false;
|
|
49
|
+
if (/timeout|timed out|ECONNRESET|ECONNREFUSED|ETIMEDOUT|EAI_AGAIN|network|fetch failed/i.test(`${name} ${message}`)) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function extractStatus(err: unknown): number | undefined {
|
|
56
|
+
const e = err as { status?: number; statusCode?: number; response?: { status?: number } };
|
|
57
|
+
return e?.status ?? e?.statusCode ?? e?.response?.status;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Extract a `Retry-After` value (seconds or HTTP-date) if the error/response carries one. */
|
|
61
|
+
function extractRetryAfterMs(err: unknown): number | undefined {
|
|
62
|
+
const headers = (err as { headers?: Record<string, string>; response?: { headers?: Record<string, string> } })?.headers
|
|
63
|
+
?? (err as { response?: { headers?: Record<string, string> } })?.response?.headers;
|
|
64
|
+
const raw = headers?.["retry-after"] ?? headers?.["Retry-After"];
|
|
65
|
+
if (!raw) return undefined;
|
|
66
|
+
const seconds = Number(raw);
|
|
67
|
+
if (!Number.isNaN(seconds)) return seconds * 1000;
|
|
68
|
+
const dateMs = Date.parse(raw);
|
|
69
|
+
return Number.isNaN(dateMs) ? undefined : Math.max(0, dateMs - Date.now());
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Run `fn`, retrying on transient failure per `policy`. `isRetryable`
|
|
74
|
+
* defaults to {@link isRetryableError}; pass a custom classifier for
|
|
75
|
+
* domain-specific errors (e.g. job executors).
|
|
76
|
+
*/
|
|
77
|
+
export async function withRetry<T>(
|
|
78
|
+
fn: (attempt: number) => Promise<T>,
|
|
79
|
+
policy: RetryPolicy = DEFAULT_RETRY_POLICY,
|
|
80
|
+
isRetryable: (err: unknown) => boolean = isRetryableError
|
|
81
|
+
): Promise<T> {
|
|
82
|
+
let lastErr: unknown;
|
|
83
|
+
for (let attempt = 0; attempt < policy.maxAttempts; attempt++) {
|
|
84
|
+
try {
|
|
85
|
+
return await fn(attempt);
|
|
86
|
+
} catch (err) {
|
|
87
|
+
lastErr = err;
|
|
88
|
+
if (attempt === policy.maxAttempts - 1 || !isRetryable(err)) throw err;
|
|
89
|
+
const delay = computeRetryDelay(attempt, policy, extractRetryAfterMs(err));
|
|
90
|
+
log.warn(`[withRetry] Attempt ${attempt + 1}/${policy.maxAttempts} failed (${(err as Error).message}); retrying in ${delay}ms`);
|
|
91
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
throw lastErr;
|
|
95
|
+
}
|
|
@@ -10,6 +10,7 @@ import { logger } from "../utils/logger";
|
|
|
10
10
|
import { buildAgentLoop } from "../agent/agent-loop";
|
|
11
11
|
import { resolveAgentId } from "../storage/onboarding";
|
|
12
12
|
import { sendToUserChannel } from "../gateway/channel-notify";
|
|
13
|
+
import { getNarration } from "../gateway/helpers";
|
|
13
14
|
import { addMessage } from "../agent/conversation-store";
|
|
14
15
|
import { resolveBestChannel } from "../tools/cron/index";
|
|
15
16
|
import { col } from "../storage/hive";
|
|
@@ -128,6 +129,23 @@ ${prompt || `Execute tool: ${job.tool_name}`}`;
|
|
|
128
129
|
? job.channel
|
|
129
130
|
: await resolveBestChannel(user?.id || "");
|
|
130
131
|
|
|
132
|
+
// Narrate progress to the user's channel as the task runs, same as a
|
|
133
|
+
// live chat turn (server.ts onStep) — without this, scheduled tasks
|
|
134
|
+
// execute silently and only the final completion message is sent.
|
|
135
|
+
const onStep = async (step: { type: string; message?: string; toolName?: string }) => {
|
|
136
|
+
if (!agentChannel) return;
|
|
137
|
+
try {
|
|
138
|
+
if (step.type === "tool_call" && step.toolName) {
|
|
139
|
+
await sendToUserChannel(agentChannel, user?.id || "", getNarration(step.toolName));
|
|
140
|
+
} else if (step.type === "text" && step.message) {
|
|
141
|
+
const trimmed = step.message.trim();
|
|
142
|
+
if (trimmed) await sendToUserChannel(agentChannel, user?.id || "", trimmed);
|
|
143
|
+
}
|
|
144
|
+
} catch (err) {
|
|
145
|
+
log.warn(`[execute] Narration send failed: ${(err as Error).message}`);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
|
|
131
149
|
const messages = [{ role: "user", content: contextPrompt }];
|
|
132
150
|
const stream = agentLoop.stream({ messages }, {
|
|
133
151
|
configurable: {
|
|
@@ -138,6 +156,7 @@ ${prompt || `Execute tool: ${job.tool_name}`}`;
|
|
|
138
156
|
system_prompt: undefined,
|
|
139
157
|
raw_user_message: contextPrompt,
|
|
140
158
|
},
|
|
159
|
+
onStep,
|
|
141
160
|
});
|
|
142
161
|
|
|
143
162
|
let response = "";
|
|
@@ -68,6 +68,9 @@ const INDEXES: IndexSpec[] = [
|
|
|
68
68
|
{ collection: "jobQueue", field: "lane" },
|
|
69
69
|
{ collection: "jobQueue", field: "type" },
|
|
70
70
|
{ collection: "jobQueue", field: "run_id" },
|
|
71
|
+
{ collection: "jobQueue", field: "idempotency_key" },
|
|
72
|
+
{ collection: "proofPackets", field: "run_id" },
|
|
73
|
+
{ collection: "proofPackets", field: "agent_id" },
|
|
71
74
|
// Stage 6 — orchestration
|
|
72
75
|
{ collection: "projects", field: "user_id" },
|
|
73
76
|
{ collection: "projects", field: "agent_id" },
|
|
@@ -296,6 +296,11 @@ export interface AgentRunDoc {
|
|
|
296
296
|
lease_expires_at: number
|
|
297
297
|
resume_policy: "resume" | "mark_interrupted" | "discard"
|
|
298
298
|
|
|
299
|
+
/** Whole-job acceptance criteria (harness-engineering "proof" concept): JSON array of {id, description, checkTool?}. */
|
|
300
|
+
acceptance_json: string | null
|
|
301
|
+
/** Fixed-worker epoch recorded at run creation: {provider, model, app_version, tool_catalog_hash}. */
|
|
302
|
+
epoch_json: string | null
|
|
303
|
+
|
|
299
304
|
error: string | null
|
|
300
305
|
created_at: number
|
|
301
306
|
updated_at: number
|
|
@@ -320,6 +325,12 @@ export interface JobDoc {
|
|
|
320
325
|
created_at: number
|
|
321
326
|
started_at: number | null
|
|
322
327
|
finished_at: number | null
|
|
328
|
+
/** Logical-failure retries (executor returned {ok:false, retryable:true}). Separate from `attempts` (crash/lease-expiry only). */
|
|
329
|
+
retry_count: number
|
|
330
|
+
/** Error from the most recent logical-failure retry; `error` stays null until the job is terminal. */
|
|
331
|
+
last_error: string | null
|
|
332
|
+
/** `toIndexable`-encoded — `NO_PARENT` when unset. Client-supplied dedup key for job creation. */
|
|
333
|
+
idempotency_key: string
|
|
323
334
|
}
|
|
324
335
|
|
|
325
336
|
export interface CronJobDoc {
|
|
@@ -354,6 +365,31 @@ export interface CronJobDoc {
|
|
|
354
365
|
completed_at: string | null
|
|
355
366
|
}
|
|
356
367
|
|
|
368
|
+
/**
|
|
369
|
+
* Compressed evidence artifact for a completed goal/project run — the
|
|
370
|
+
* "proof packet" concept from harness-engineering's proof/verification
|
|
371
|
+
* practice: what was intended, what was checked, what evidence backs the
|
|
372
|
+
* verdict, and known limits. Written once per run by the goal_run /
|
|
373
|
+
* project_task executors after verification.
|
|
374
|
+
*/
|
|
375
|
+
export interface ProofPacketDoc {
|
|
376
|
+
id: string
|
|
377
|
+
run_id: string
|
|
378
|
+
agent_id: string
|
|
379
|
+
intended_outcome: string
|
|
380
|
+
/** Per-acceptance-criterion verdicts: [{id, description, met, evidence}]. */
|
|
381
|
+
acceptance_results_json: string
|
|
382
|
+
/** Names of checks executed (tool ids, LLM verifier, etc). */
|
|
383
|
+
checks_run_json: string
|
|
384
|
+
/** Free-form evidence snippets backing the verdict (tool outputs, verifier reasons). */
|
|
385
|
+
evidence_json: string
|
|
386
|
+
known_limits: string | null
|
|
387
|
+
/** Fixed-worker epoch this run executed under — copied from AgentRunDoc.epoch_json. */
|
|
388
|
+
epoch_json: string | null
|
|
389
|
+
met: boolean
|
|
390
|
+
created_at: number
|
|
391
|
+
}
|
|
392
|
+
|
|
357
393
|
export interface TaskRunDoc {
|
|
358
394
|
id: string
|
|
359
395
|
task_id: string
|
|
@@ -168,6 +168,8 @@ export const SEED_DATA: SeedData = {
|
|
|
168
168
|
{ id: "es_MX-claude-14947-epoch-high", providerId: "piper", name: "Piper Spanish (Claude)", modelType: "tts", contextWindow: 0, capabilities: JSON.stringify(["tts", "speech", "local"]) },
|
|
169
169
|
|
|
170
170
|
// ── Google Gemini (fuente: openrouter.ai/google + ai.google.dev) ──
|
|
171
|
+
{ id: "gemini-3.6-flash", name: "Gemini 3.6 Flash", providerId: "gemini", modelType: "llm", contextWindow: 1048576, capabilities: JSON.stringify(["chat", "vision", "json_mode", "function_calling", "streaming", "reasoning"]) },
|
|
172
|
+
{ id: "gemini-3.5-pro", providerId: "gemini", name: "Gemini 3.5 Pro", modelType: "llm", contextWindow: 1048576, capabilities: JSON.stringify(["chat", "vision", "json_mode", "function_calling", "streaming", "reasoning"]) },
|
|
171
173
|
{ 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"]) },
|
|
172
174
|
{ id: "gemini-3.1-pro-preview", providerId: "gemini", name: "Gemini 3.1 Pro Preview", modelType: "llm", contextWindow: 1048576, capabilities: JSON.stringify(["chat", "vision", "json_mode", "function_calling", "streaming", "reasoning"]) },
|
|
173
175
|
{ id: "gemini-3.1-flash-lite-preview", providerId: "gemini", name: "Gemini 3.1 Flash Lite Preview", modelType: "llm", contextWindow: 1048576, capabilities: JSON.stringify(["chat", "vision", "json_mode", "function_calling", "streaming"]) },
|
|
@@ -288,20 +290,20 @@ export const SEED_DATA: SeedData = {
|
|
|
288
290
|
{ id: "MiniMax-M2.5-highspeed", providerId: "minimax", name: "MiniMax M2.5 Highspeed", modelType: "llm", contextWindow: 1000000, capabilities: JSON.stringify(["chat", "code", "function_calling", "streaming"]) },
|
|
289
291
|
|
|
290
292
|
// ── OpenCode Go (fuente: opencode.ai) — OpenAI-compatible endpoint ──
|
|
291
|
-
{ id: "opencode-go/minimax-m3",
|
|
292
|
-
{ id: "opencode-go/minimax-m2.7",
|
|
293
|
-
{ id: "opencode-go/minimax-m2.5",
|
|
294
|
-
{ id: "opencode-go/kimi-k2.6",
|
|
295
|
-
{ id: "opencode-go/kimi-k2.5",
|
|
296
|
-
{ id: "opencode-go/glm-5.1",
|
|
297
|
-
{ id: "opencode-go/glm-5",
|
|
298
|
-
{ id: "opencode-go/deepseek-v4-pro",
|
|
299
|
-
{ id: "opencode-go/deepseek-v4-flash",
|
|
300
|
-
{ id: "opencode-go/mimo-v2-pro",
|
|
301
|
-
{ id: "opencode-go/mimo-v2-omni",
|
|
302
|
-
{ id: "opencode-go/mimo-v2.5-pro",
|
|
303
|
-
{ id: "opencode-go/mimo-v2.5",
|
|
304
|
-
{ id: "opencode-go/hy3-preview",
|
|
293
|
+
{ id: "opencode-go/minimax-m3", providerId: "opencode-go", name: "MiniMax M3", modelType: "llm", contextWindow: 1000000, capabilities: JSON.stringify(["chat", "code", "vision", "function_calling", "streaming", "reasoning"]) },
|
|
294
|
+
{ id: "opencode-go/minimax-m2.7", providerId: "opencode-go", name: "MiniMax M2.7", modelType: "llm", contextWindow: 1000000, capabilities: JSON.stringify(["chat", "code", "function_calling", "streaming"]) },
|
|
295
|
+
{ id: "opencode-go/minimax-m2.5", providerId: "opencode-go", name: "MiniMax M2.5", modelType: "llm", contextWindow: 1000000, capabilities: JSON.stringify(["chat", "code", "function_calling", "streaming"]) },
|
|
296
|
+
{ id: "opencode-go/kimi-k2.6", providerId: "opencode-go", name: "Kimi K2.6", modelType: "llm", contextWindow: 262144, capabilities: JSON.stringify(["chat", "code", "function_calling", "streaming"]) },
|
|
297
|
+
{ id: "opencode-go/kimi-k2.5", providerId: "opencode-go", name: "Kimi K2.5", modelType: "llm", contextWindow: 262144, capabilities: JSON.stringify(["chat", "code", "function_calling", "streaming"]) },
|
|
298
|
+
{ id: "opencode-go/glm-5.1", providerId: "opencode-go", name: "GLM-5.1", modelType: "llm", contextWindow: 128000, capabilities: JSON.stringify(["chat", "code", "function_calling", "streaming"]) },
|
|
299
|
+
{ id: "opencode-go/glm-5", providerId: "opencode-go", name: "GLM-5", modelType: "llm", contextWindow: 128000, capabilities: JSON.stringify(["chat", "code", "function_calling", "streaming"]) },
|
|
300
|
+
{ id: "opencode-go/deepseek-v4-pro", providerId: "opencode-go", name: "DeepSeek V4 Pro", modelType: "llm", contextWindow: 128000, capabilities: JSON.stringify(["chat", "code", "function_calling", "streaming", "reasoning"]) },
|
|
301
|
+
{ id: "opencode-go/deepseek-v4-flash", providerId: "opencode-go", name: "DeepSeek V4 Flash", modelType: "llm", contextWindow: 128000, capabilities: JSON.stringify(["chat", "code", "function_calling", "streaming"]) },
|
|
302
|
+
{ id: "opencode-go/mimo-v2-pro", providerId: "opencode-go", name: "MiMo-V2 Pro", modelType: "llm", contextWindow: 128000, capabilities: JSON.stringify(["chat", "code", "function_calling", "streaming", "reasoning"]) },
|
|
303
|
+
{ id: "opencode-go/mimo-v2-omni", providerId: "opencode-go", name: "MiMo-V2 Omni", modelType: "llm", contextWindow: 128000, capabilities: JSON.stringify(["chat", "code", "function_calling", "streaming"]) },
|
|
304
|
+
{ id: "opencode-go/mimo-v2.5-pro", providerId: "opencode-go", name: "MiMo-V2.5 Pro", modelType: "llm", contextWindow: 128000, capabilities: JSON.stringify(["chat", "code", "function_calling", "streaming", "reasoning"]) },
|
|
305
|
+
{ id: "opencode-go/mimo-v2.5", providerId: "opencode-go", name: "MiMo-V2.5", modelType: "llm", contextWindow: 128000, capabilities: JSON.stringify(["chat", "code", "function_calling", "streaming"]) },
|
|
306
|
+
{ id: "opencode-go/hy3-preview", providerId: "opencode-go", name: "Hunyuan 3 Preview", modelType: "llm", contextWindow: 128000, capabilities: JSON.stringify(["chat", "code", "function_calling", "streaming"]) },
|
|
305
307
|
|
|
306
308
|
// ── HiveAgents (llama.cpp local servido vía Cloudflare) ──
|
|
307
309
|
// Modelo único recomendado para distribución Hive single-machine.
|
|
@@ -510,27 +512,29 @@ export async function seedAllData(): Promise<void> {
|
|
|
510
512
|
}
|
|
511
513
|
log.info(`[seed] ✅ ${providerCount} providers procesados`);
|
|
512
514
|
|
|
513
|
-
// 5️⃣ Models (re-seed: overwrite in place,
|
|
515
|
+
// 5️⃣ Models (re-seed: overwrite catalog fields in place, preserve the user's own
|
|
516
|
+
// enabled/active activation state, remove entries no longer in the catalog)
|
|
514
517
|
log.info("[seed] 🔄 Re-seeding models...");
|
|
515
518
|
const modelsCol = await col<ModelDoc>("models");
|
|
516
|
-
const
|
|
519
|
+
const existingModels = new Map((await modelsCol.scan({})).map((e) => [e.id, e]));
|
|
517
520
|
|
|
518
521
|
let modelCount = 0;
|
|
519
522
|
for (const model of SEED_DATA.models) {
|
|
523
|
+
const existing = existingModels.get(model.id);
|
|
520
524
|
await modelsCol.put(model.id, {
|
|
521
525
|
id: model.id, provider_id: model.providerId, name: model.name,
|
|
522
526
|
model_type: model.modelType as ModelDoc["model_type"],
|
|
523
527
|
context_window: model.contextWindow || 0, capabilities: model.capabilities || null,
|
|
524
|
-
enabled: true, active: false,
|
|
528
|
+
enabled: existing?.doc.enabled ?? true, active: existing?.doc.active ?? false,
|
|
525
529
|
});
|
|
526
|
-
|
|
530
|
+
existingModels.delete(model.id);
|
|
527
531
|
modelCount++;
|
|
528
532
|
}
|
|
529
|
-
// Whatever remains in
|
|
533
|
+
// Whatever remains in existingModels was dropped from the catalog (e.g. a
|
|
530
534
|
// consolidated HiveAgents GGUF variant) — remove it.
|
|
531
|
-
for (const staleId of
|
|
532
|
-
if (
|
|
533
|
-
log.info(`[seed] 🗑️ Removed ${
|
|
535
|
+
for (const [staleId] of existingModels) await modelsCol.delete(staleId);
|
|
536
|
+
if (existingModels.size > 0) {
|
|
537
|
+
log.info(`[seed] 🗑️ Removed ${existingModels.size} model(s) no longer in the catalog.`);
|
|
534
538
|
}
|
|
535
539
|
|
|
536
540
|
// An agent pointing at a model that just got removed would otherwise keep
|
|
@@ -13,7 +13,7 @@ import type { ProviderDoc, ModelDoc } from "../../storage/collections.ts";
|
|
|
13
13
|
|
|
14
14
|
export const getAvailableModelsTool: Tool = {
|
|
15
15
|
name: "get_available_models",
|
|
16
|
-
description: "Obtener
|
|
16
|
+
description: "Obtener el catálogo completo de modelos de los providers configurados (con credenciales activas) para elegir el más adecuado según capacidad, contexto o costo — no solo el modelo por defecto del usuario. Sinónimos: ver modelos, listar providers, modelos disponibles, consultar modelos, provider activo, qué modelos tengo, modelos para código, modelos para chat",
|
|
17
17
|
parameters: {
|
|
18
18
|
type: "object",
|
|
19
19
|
properties: {
|
|
@@ -47,10 +47,17 @@ export const getAvailableModelsTool: Tool = {
|
|
|
47
47
|
.map(p => [p.id, p])
|
|
48
48
|
);
|
|
49
49
|
|
|
50
|
+
// Gate on the *provider* being configured (enabled + active, i.e. it has valid
|
|
51
|
+
// credentials) — not on the individual model's own `active` flag. `active` on a
|
|
52
|
+
// ModelDoc only marks the single model onboarding/voice-setup picked as the
|
|
53
|
+
// user's current default; it is not "this model is unusable". Once a provider is
|
|
54
|
+
// configured, every model under it should be visible so the caller can pick the
|
|
55
|
+
// one that actually fits the task (capability, context window, cost), instead of
|
|
56
|
+
// being stuck with whichever model happened to be flagged as the default.
|
|
50
57
|
const modelsCol = await col<ModelDoc>("models");
|
|
51
58
|
let models = (await modelsCol.scan({}))
|
|
52
59
|
.map(e => e.doc)
|
|
53
|
-
.filter(m => m.enabled &&
|
|
60
|
+
.filter(m => m.enabled && providersById.has(m.provider_id));
|
|
54
61
|
|
|
55
62
|
if (providerId) models = models.filter(m => m.provider_id === providerId);
|
|
56
63
|
if (modelType) models = models.filter(m => m.model_type === modelType);
|
|
@@ -69,9 +76,10 @@ export const getAvailableModelsTool: Tool = {
|
|
|
69
76
|
modelType: m.model_type,
|
|
70
77
|
contextWindow: m.context_window,
|
|
71
78
|
capabilities: m.capabilities ? JSON.parse(m.capabilities) : null,
|
|
79
|
+
isDefault: m.active,
|
|
72
80
|
};
|
|
73
81
|
})
|
|
74
|
-
.sort((a, b) => a.providerName.localeCompare(b.providerName) || a.modelName.localeCompare(b.modelName));
|
|
82
|
+
.sort((a, b) => (Number(b.isDefault) - Number(a.isDefault)) || a.providerName.localeCompare(b.providerName) || a.modelName.localeCompare(b.modelName));
|
|
75
83
|
|
|
76
84
|
return {
|
|
77
85
|
ok: true,
|
|
@@ -238,7 +238,9 @@ export const agentCreateTool: Tool = {
|
|
|
238
238
|
};
|
|
239
239
|
}
|
|
240
240
|
|
|
241
|
-
// Validar que el modelo existe y
|
|
241
|
+
// Validar que el modelo existe y pertenece al provider ya validado. `active` en un
|
|
242
|
+
// ModelDoc solo marca el modelo por defecto del usuario (elegido en onboarding), no
|
|
243
|
+
// si el modelo es utilizable — cualquier modelo del provider configurado sirve.
|
|
242
244
|
const modelsCol = await col<ModelDoc>("models");
|
|
243
245
|
const modelEntry = await modelsCol.get(modelId);
|
|
244
246
|
|
|
@@ -249,10 +251,17 @@ export const agentCreateTool: Tool = {
|
|
|
249
251
|
};
|
|
250
252
|
}
|
|
251
253
|
|
|
252
|
-
if (!modelEntry.doc.enabled
|
|
254
|
+
if (!modelEntry.doc.enabled) {
|
|
253
255
|
return {
|
|
254
256
|
ok: false,
|
|
255
|
-
error: `Modelo '${modelId}' no está
|
|
257
|
+
error: `Modelo '${modelId}' no está habilitado. Usá get_available_models para ver modelos disponibles.`
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (modelEntry.doc.provider_id !== providerId) {
|
|
262
|
+
return {
|
|
263
|
+
ok: false,
|
|
264
|
+
error: `Modelo '${modelId}' pertenece al provider '${modelEntry.doc.provider_id}', no a '${providerId}'.`
|
|
256
265
|
};
|
|
257
266
|
}
|
|
258
267
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./vendor-query-DsWPbQdG.js";import{t}from"./AgentCreateForm-DyeTdXUs.js";var n=e();function r(){return(0,n.jsx)(t,{})}export{r as AgentNewPage};
|