@johpaz/hive-agents 1.0.3 → 1.0.5
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 +4 -4
- package/dist/hive.js +49133 -48182
- package/dist/tool-worker.js +2 -1
- package/dist/ui/assets/A2UIPage-DTW79pyL.js +8 -0
- package/dist/ui/assets/AgentCreateForm-Bcp3HN8D.js +1 -0
- package/dist/ui/assets/AgentDetailPage-10XptMde.js +1 -0
- package/dist/ui/assets/AgentNewPage-CUt49rVS.js +1 -0
- package/dist/ui/assets/AgentsPage-1_e1a9xa.js +10 -0
- package/dist/ui/assets/ApiClientPage-DHfIlSAg.js +3 -0
- package/dist/ui/assets/ChannelsPage-BnCQAGZL.js +8 -0
- package/dist/ui/assets/DashboardPage-BsCCKHgg.js +6 -0
- package/dist/ui/assets/LoginPage-BaX6cAPa.js +1 -0
- package/dist/ui/assets/{LogsPage-DyJOGQNy.js → LogsPage-DiFBQt7o.js} +1 -1
- package/dist/ui/assets/MeetingPage-Bpv5zVXf.js +1 -0
- package/dist/ui/assets/ModelSelector-DfExlPzx.js +1 -0
- package/dist/ui/assets/{NotFound-Bpr12V51.js → NotFound-C8HBdF73.js} +1 -1
- package/dist/ui/assets/Office3DPage-ChsGMapf.js +319 -0
- package/dist/ui/assets/ProvidersPage-B39pfWHf.js +1 -0
- package/dist/ui/assets/RecoverPage-C_Id9WM-.js +1 -0
- package/dist/ui/assets/SettingsPage-BgFqasyg.js +9 -0
- package/dist/ui/assets/SetupPage-YeJFfgbt.js +1 -0
- package/dist/ui/assets/Vignette-Cyi27LQH.js +4302 -0
- package/dist/ui/assets/VoicePage-Cp63Abj4.js +307 -0
- package/dist/ui/assets/VoicePage-uLWdtoD4.css +1 -0
- package/dist/ui/assets/WebChatPage-DxFLWgtM.js +29 -0
- package/dist/ui/assets/activity-C_GS5wrG.js +1 -0
- package/dist/ui/assets/agentCapabilities-DOeepCty.js +1 -0
- package/dist/ui/assets/{alert-CQlRq6sv.js → alert-Cj4DpKv6.js} +1 -1
- package/dist/ui/assets/arrow-left-WyDPYZXU.js +1 -0
- package/dist/ui/assets/arrow-right-BuNjN-bk.js +1 -0
- package/dist/ui/assets/arrow-up-right-DWzTsCXj.js +1 -0
- package/dist/ui/assets/{badge-DKGZbVZJ.js → badge-DKpeVCpY.js} +1 -1
- package/dist/ui/assets/bia-4LFKOyxR.webp +0 -0
- package/dist/ui/assets/bia-BFcUpOu3.glb +0 -0
- package/dist/ui/assets/calendar-B6x9cw-q.js +1 -0
- package/dist/ui/assets/{card-D3Nw3kh3.js → card-Cag15G4h.js} +1 -1
- package/dist/ui/assets/check-C8pw-7Fx.js +1 -0
- package/dist/ui/assets/chevron-down-8GjmTjLR.js +1 -0
- package/dist/ui/assets/chevron-left-GK4EQOyZ.js +1 -0
- package/dist/ui/assets/chevron-right-BupZqrxu.js +1 -0
- package/dist/ui/assets/chevron-up-DZrzJIW8.js +1 -0
- package/dist/ui/assets/circle-alert-CtDbK2nl.js +1 -0
- package/dist/ui/assets/circle-check-BKNT2_q6.js +1 -0
- package/dist/ui/assets/circle-x-DfBjbztU.js +1 -0
- package/dist/ui/assets/copy-wR7o7Ly8.js +1 -0
- package/dist/ui/assets/core-Dz04EE_8.js +1 -0
- package/dist/ui/assets/createLucideIcon-BRaPSYgN.js +1 -0
- package/dist/ui/assets/{dialog-Dn9hGPYl.js → dialog-7E3EoEt3.js} +1 -1
- package/dist/ui/assets/dist-js-Bg0g3vPS.js +1 -0
- package/dist/ui/assets/dist-js-DwLn9F4C.js +1 -0
- package/dist/ui/assets/download-D0aDV8Y_.js +1 -0
- package/dist/ui/assets/earth-BJRGJbVn.js +1 -0
- package/dist/ui/assets/ellipsis-vertical-BOW_iEOO.js +1 -0
- package/dist/ui/assets/external-link-5cujQzfV.js +1 -0
- package/dist/ui/assets/eye-sRPY5qOa.js +1 -0
- package/dist/ui/assets/file-text-DNSyNLUh.js +1 -0
- package/dist/ui/assets/gauge-C__zxC3_.js +1 -0
- package/dist/ui/assets/history-BHQWfE-7.js +1 -0
- package/dist/ui/assets/index-Bi8qEmrK.js +116 -0
- package/dist/ui/assets/index-D2UhaSb0.css +2 -0
- package/dist/ui/assets/info-CG1VohyH.js +1 -0
- package/dist/ui/assets/key-BC28VCjO.js +1 -0
- package/dist/ui/assets/{label-k0jYxoWW.js → label-C6atPuIh.js} +1 -1
- package/dist/ui/assets/lock-open-Bhp0UJlL.js +1 -0
- package/dist/ui/assets/mail-Biwn8WrV.js +1 -0
- package/dist/ui/assets/mic-Rq4BxU1R.js +1 -0
- package/dist/ui/assets/pause-C2l5G2Py.js +1 -0
- package/dist/ui/assets/pencil-CUbpCfeG.js +1 -0
- package/dist/ui/assets/play-CMAscR3a.js +1 -0
- package/dist/ui/assets/plus-DzvRxH4U.js +1 -0
- package/dist/ui/assets/radio-DfGzov4y.js +1 -0
- package/dist/ui/assets/refresh-cw-DZXu5FrG.js +1 -0
- package/dist/ui/assets/rotate-ccw-Dx92orJM.js +1 -0
- package/dist/ui/assets/scroll-area-CSoG2z53.js +1 -0
- package/dist/ui/assets/search-DB4w9YHW.js +1 -0
- package/dist/ui/assets/{select-ot0a6art.js → select-DlCT21_r.js} +1 -1
- package/dist/ui/assets/send-xi8HzUdc.js +1 -0
- package/dist/ui/assets/settings-pV0cF8Kf.js +1 -0
- package/dist/ui/assets/shield-nLNsomh_.js +1 -0
- package/dist/ui/assets/slider-Bb_PHFJT.js +1 -0
- package/dist/ui/assets/sparkles-CerRDYxk.js +1 -0
- package/dist/ui/assets/square-CcWzRWyG.js +1 -0
- package/dist/ui/assets/{switch-DXcELPsM.js → switch-CUsGuBNi.js} +1 -1
- package/dist/ui/assets/tabs-Ckfc7DGG.js +1 -0
- package/dist/ui/assets/terminal-C2SUZUAD.js +1 -0
- package/dist/ui/assets/{textarea-rp6vsOZl.js → textarea-BH6pI9Ax.js} +1 -1
- package/dist/ui/assets/trash-2-BZsMCfso.js +1 -0
- package/dist/ui/assets/useAudioDevices-Dpr_hn6i.js +41 -0
- package/dist/ui/assets/useHiveAgentsModelLoad-CHmtvNp4.js +1 -0
- package/dist/ui/assets/useProviders-C7FA6z4M.js +1 -0
- package/dist/ui/assets/vendor-radix-DUug7irY.js +63 -0
- package/dist/ui/assets/{vendor-react-CPJEWbIG.js → vendor-react-DYyYpuMy.js} +1 -1
- package/dist/ui/assets/volume-2-CBMYsuF3.js +1 -0
- package/dist/ui/assets/volume-x-vNFf2e4-.js +1 -0
- package/dist/ui/assets/wifi-DNv53AfN.js +1 -0
- package/dist/ui/assets/zap-Yed86Sh8.js +1 -0
- package/dist/ui/index.html +8 -7
- package/package.json +1 -1
- package/packages/cli/src/commands/doctor.ts +99 -44
- package/packages/cli/src/commands/onboard.ts +4 -2
- package/packages/core/src/agent/agent-catalog.ts +23 -23
- package/packages/core/src/agent/agent-loop.ts +48 -0
- package/packages/core/src/agent/context-compiler.ts +1 -1
- package/packages/core/src/agent/conversation-store.ts +14 -1
- package/packages/core/src/agent/llm-client.ts +41 -6
- package/packages/core/src/agent/llm-providers/nvidia.ts +39 -0
- package/packages/core/src/agent/llm-providers/openai-compat-base.ts +38 -2
- package/packages/core/src/agent/mcp-result-normalizer.ts +42 -0
- package/packages/core/src/agent/prompt-builder.ts +1 -1
- package/packages/core/src/agent/realtime-providers/gemini-live.ts +230 -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/skill-selector.ts +1 -1
- package/packages/core/src/agent/tool-selector.ts +2 -0
- package/packages/core/src/artifacts/store.ts +65 -0
- package/packages/core/src/canvas/canvas-manager.ts +128 -26
- package/packages/core/src/config/loader.ts +6 -4
- package/packages/core/src/events/tool-narration.ts +4 -0
- package/packages/core/src/gateway/delegation-groups.ts +4 -4
- package/packages/core/src/gateway/initializer.ts +17 -10
- package/packages/core/src/gateway/realtime/bridge-tools.ts +392 -0
- package/packages/core/src/gateway/realtime/index.ts +249 -0
- package/packages/core/src/gateway/realtime/prompt.ts +137 -0
- package/packages/core/src/gateway/realtime/protocol.ts +60 -0
- package/packages/core/src/gateway/realtime/voice-session.ts +441 -0
- package/packages/core/src/gateway/routes/providers.ts +1 -1
- package/packages/core/src/gateway/routes/setup.ts +3 -3
- package/packages/core/src/gateway/routes/system.ts +9 -4
- package/packages/core/src/gateway/server.ts +86 -1
- package/packages/core/src/gateway/slash-commands.ts +3 -1
- package/packages/core/src/gateway/webchat-turn.ts +34 -1
- package/packages/core/src/storage/collections.ts +10 -1
- package/packages/core/src/storage/onboarding.ts +39 -39
- package/packages/core/src/storage/seed.ts +21 -2
- package/packages/core/src/tool-runtime/embedded-worker.generated.ts +20 -0
- package/packages/core/src/tool-runtime/index.ts +56 -14
- package/packages/core/src/tools/index.ts +4 -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 +439 -21
- package/packages/skills/src/bundled-data.generated.ts +752 -752
- package/dist/ui/assets/A2UIPage-DExwevBV.js +0 -8
- package/dist/ui/assets/AgentCreateForm-7PPShsUn.js +0 -1
- package/dist/ui/assets/AgentDetailPage-CiV4tz4P.js +0 -1
- package/dist/ui/assets/AgentNewPage-D3TtVwQf.js +0 -1
- package/dist/ui/assets/AgentsPage-C2DThet7.js +0 -10
- package/dist/ui/assets/ApiClientPage-Cowdq-0f.js +0 -3
- package/dist/ui/assets/ChannelsPage-D4IgglwJ.js +0 -8
- package/dist/ui/assets/DashboardPage-DAgVB7Iy.js +0 -6
- package/dist/ui/assets/LoginPage-CpU61b3u.js +0 -1
- package/dist/ui/assets/MeetingPage-DLmqHmm2.js +0 -1
- package/dist/ui/assets/ModelSelector-D4OaICwN.js +0 -1
- package/dist/ui/assets/Office3DPage-BvO66B0h.js +0 -4614
- package/dist/ui/assets/ProvidersPage-Bhb6Qr87.js +0 -1
- package/dist/ui/assets/RecoverPage-DaZrCpdB.js +0 -1
- package/dist/ui/assets/SettingsPage-BRD2F7up.js +0 -9
- package/dist/ui/assets/SetupPage-DKppgTja.js +0 -1
- package/dist/ui/assets/WebChatPage-CPtETNL5.js +0 -29
- package/dist/ui/assets/activity-BSosMryb.js +0 -1
- package/dist/ui/assets/agentCapabilities-VqxLmrF6.js +0 -1
- package/dist/ui/assets/arrow-left-C9Y6p4Jt.js +0 -1
- package/dist/ui/assets/arrow-right-BYfOLnTB.js +0 -1
- package/dist/ui/assets/arrow-up-right-D2trA3Ob.js +0 -1
- package/dist/ui/assets/calendar-rdd4nvY1.js +0 -1
- package/dist/ui/assets/check-DUq9uoNQ.js +0 -1
- package/dist/ui/assets/chevron-down-rPF4Pr1n.js +0 -1
- package/dist/ui/assets/chevron-left-Crzzf2sY.js +0 -1
- package/dist/ui/assets/chevron-right-DtMIvG9A.js +0 -1
- package/dist/ui/assets/chevron-up-CG0_KGBy.js +0 -1
- package/dist/ui/assets/circle-alert-CYt6gsDA.js +0 -1
- package/dist/ui/assets/circle-check-Zl32-jCa.js +0 -1
- package/dist/ui/assets/circle-x-BJXzKGmx.js +0 -1
- package/dist/ui/assets/copy-BmtJXmDe.js +0 -1
- package/dist/ui/assets/download-D3mYhuuL.js +0 -1
- package/dist/ui/assets/earth-BZzdDXFC.js +0 -1
- package/dist/ui/assets/ellipsis-vertical-BF705XvB.js +0 -1
- package/dist/ui/assets/external-link-gdpMTHUV.js +0 -1
- package/dist/ui/assets/eye-lSG04hI7.js +0 -1
- package/dist/ui/assets/file-text-CjQxcJvN.js +0 -1
- package/dist/ui/assets/gauge-DBryKhDK.js +0 -1
- package/dist/ui/assets/history-BC6ir9qU.js +0 -1
- package/dist/ui/assets/index-DyxoAvTq.js +0 -116
- package/dist/ui/assets/index-wML8DaUo.css +0 -2
- package/dist/ui/assets/info-BGBaIyKc.js +0 -1
- package/dist/ui/assets/key-D_CNJTY2.js +0 -1
- package/dist/ui/assets/loader-circle-RXdrfPsH.js +0 -1
- package/dist/ui/assets/lock-open-UB61lorP.js +0 -1
- package/dist/ui/assets/mail-C5bJ_dBt.js +0 -1
- package/dist/ui/assets/pause-BSTJvxDu.js +0 -1
- package/dist/ui/assets/pencil-C2B1Q7y2.js +0 -1
- package/dist/ui/assets/play-tcMbj-0p.js +0 -1
- package/dist/ui/assets/plus-BSZvyMND.js +0 -1
- package/dist/ui/assets/progress-DrI2UDu-.js +0 -1
- package/dist/ui/assets/radio-D9CrjAar.js +0 -1
- package/dist/ui/assets/refresh-cw-D7EB_fVv.js +0 -1
- package/dist/ui/assets/scroll-area-CfHn94Vb.js +0 -1
- package/dist/ui/assets/search-5S6LY69I.js +0 -1
- package/dist/ui/assets/send-Dax1tJ5b.js +0 -1
- package/dist/ui/assets/settings-97CL32lC.js +0 -1
- package/dist/ui/assets/shield-DwbCEZbF.js +0 -1
- package/dist/ui/assets/slider-CmE_z1Ii.js +0 -1
- package/dist/ui/assets/sparkles-CWMAzkpD.js +0 -1
- package/dist/ui/assets/square-B4dgTXI3.js +0 -1
- package/dist/ui/assets/tabs-CxiybXcw.js +0 -1
- package/dist/ui/assets/terminal-DoLedTPM.js +0 -1
- package/dist/ui/assets/trash-2-DxnVYOz8.js +0 -1
- package/dist/ui/assets/triangle-alert-Cka-BeIE.js +0 -1
- package/dist/ui/assets/useHiveAgentsModelLoad-BjnIsQKR.js +0 -1
- package/dist/ui/assets/useProviders-CueMz_mL.js +0 -1
- package/dist/ui/assets/vendor-radix-D0s_k6Gp.js +0 -63
- package/dist/ui/assets/volume-x-DLsli9cf.js +0 -1
- package/dist/ui/assets/wifi-BQRJGfLZ.js +0 -1
- package/dist/ui/assets/zap-DSR3CEce.js +0 -1
- /package/dist/ui/assets/{gateway-url-BlnabM5e.js → gateway-url-BzQV75Ig.js} +0 -0
- /package/dist/ui/assets/{useOfficeModel-Cy7cAyEn.js → useOfficeModel-Cc5VkReZ.js} +0 -0
- /package/dist/ui/assets/{utils-Dyb7SC2_.js → utils-lc8H6VGT.js} +0 -0
- /package/dist/ui/assets/{vendor-router-zpB-76nT.js → vendor-router-DCsSv_I7.js} +0 -0
|
@@ -4,6 +4,8 @@ import { dirname, join } from "node:path"
|
|
|
4
4
|
import { availableParallelism } from "node:os"
|
|
5
5
|
import type { Config } from "../config/loader.ts"
|
|
6
6
|
import { loadConfig } from "../config/loader.ts"
|
|
7
|
+
import { logger } from "../utils/logger.ts"
|
|
8
|
+
import { embeddedToolWorkerPath } from "./embedded-worker.generated.ts"
|
|
7
9
|
|
|
8
10
|
export type ToolCallLike = {
|
|
9
11
|
id: string
|
|
@@ -105,7 +107,19 @@ type WorkerSlot = {
|
|
|
105
107
|
job?: QueuedJob
|
|
106
108
|
}
|
|
107
109
|
|
|
108
|
-
|
|
110
|
+
let cachedWorkerEntry: string | null | undefined
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Locate the tool worker entry, or null when this build ships without one.
|
|
114
|
+
*
|
|
115
|
+
* Returning null instead of throwing is deliberate: workers are an
|
|
116
|
+
* optimization, and a packaging gap must never take a whole turn down with it
|
|
117
|
+
* (it did until v1.0.3 — every desktop install failed each multi-tool turn
|
|
118
|
+
* with "Tool worker entry not found"). The caller degrades to the main thread.
|
|
119
|
+
*/
|
|
120
|
+
function resolveWorkerEntry(): string | null {
|
|
121
|
+
if (cachedWorkerEntry !== undefined) return cachedWorkerEntry
|
|
122
|
+
|
|
109
123
|
const candidates = [
|
|
110
124
|
new URL("./tool-worker.js", import.meta.url),
|
|
111
125
|
new URL("./tool-worker.ts", import.meta.url),
|
|
@@ -115,7 +129,8 @@ function resolveWorkerEntry(): string {
|
|
|
115
129
|
|
|
116
130
|
for (const candidate of candidates) {
|
|
117
131
|
if (existsSync(fileURLToPath(candidate))) {
|
|
118
|
-
|
|
132
|
+
cachedWorkerEntry = candidate.href
|
|
133
|
+
return cachedWorkerEntry
|
|
119
134
|
}
|
|
120
135
|
}
|
|
121
136
|
|
|
@@ -135,13 +150,25 @@ function resolveWorkerEntry(): string {
|
|
|
135
150
|
|
|
136
151
|
for (const filePath of fallbacks) {
|
|
137
152
|
if (existsSync(filePath)) {
|
|
138
|
-
|
|
153
|
+
cachedWorkerEntry = filePath
|
|
154
|
+
return cachedWorkerEntry
|
|
139
155
|
}
|
|
140
156
|
}
|
|
141
157
|
|
|
142
|
-
|
|
143
|
-
|
|
158
|
+
// Standalone executable: the worker was embedded at compile time and lives in
|
|
159
|
+
// the virtual bunfs, where existsSync() reports false — so it is taken on
|
|
160
|
+
// trust. It is only ever set by scripts/build-gateway.ts.
|
|
161
|
+
if (embeddedToolWorkerPath) {
|
|
162
|
+
cachedWorkerEntry = embeddedToolWorkerPath
|
|
163
|
+
return cachedWorkerEntry
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
logger.warn(
|
|
167
|
+
"[tool-runtime] No tool worker entry found — running tool batches on the main thread (sequentially)",
|
|
168
|
+
{ tried: [...candidates.map((candidate) => fileURLToPath(candidate)), ...fallbacks] }
|
|
144
169
|
)
|
|
170
|
+
cachedWorkerEntry = null
|
|
171
|
+
return null
|
|
145
172
|
}
|
|
146
173
|
|
|
147
174
|
function serializeError(error: unknown): SerializedError {
|
|
@@ -187,6 +214,7 @@ const DEFAULT_MAIN_THREAD_TOOL_NAMES = new Set([
|
|
|
187
214
|
"browser_navigate",
|
|
188
215
|
"browser_screenshot",
|
|
189
216
|
"artifact_inspect",
|
|
217
|
+
"artifact_read",
|
|
190
218
|
"browser_click",
|
|
191
219
|
"browser_type",
|
|
192
220
|
"browser_extract",
|
|
@@ -255,10 +283,12 @@ class ToolWorkerPool {
|
|
|
255
283
|
private workers: WorkerSlot[] = []
|
|
256
284
|
private queue: QueuedJob[] = []
|
|
257
285
|
private readonly maxWorkers: number
|
|
286
|
+
private readonly workerEntry: string
|
|
258
287
|
private disposed = false
|
|
259
288
|
|
|
260
|
-
constructor(maxWorkers: number) {
|
|
289
|
+
constructor(maxWorkers: number, workerEntry: string) {
|
|
261
290
|
this.maxWorkers = Math.max(1, maxWorkers)
|
|
291
|
+
this.workerEntry = workerEntry
|
|
262
292
|
}
|
|
263
293
|
|
|
264
294
|
execute(job: Omit<QueuedJob, "resolve" | "settled" | "startedAt">): Promise<ToolBatchResult> {
|
|
@@ -385,7 +415,7 @@ class ToolWorkerPool {
|
|
|
385
415
|
}
|
|
386
416
|
|
|
387
417
|
private createSlot(): WorkerSlot {
|
|
388
|
-
const worker = new Worker(
|
|
418
|
+
const worker = new Worker(this.workerEntry, { type: "module" })
|
|
389
419
|
const slot: WorkerSlot = { worker, busy: false }
|
|
390
420
|
|
|
391
421
|
worker.onmessage = (event: MessageEvent<WorkerMessage>) => {
|
|
@@ -500,11 +530,15 @@ class ToolWorkerPool {
|
|
|
500
530
|
job.resolve(result)
|
|
501
531
|
|
|
502
532
|
if (restart) {
|
|
533
|
+
// Un worker que abortó o murió se descarta, y el reemplazo lo crea
|
|
534
|
+
// `drain()` solo si queda trabajo. Antes se levantaba uno nuevo en el
|
|
535
|
+
// acto: sobre un aborto —el caso típico al terminar un turno o una
|
|
536
|
+
// suite— eso deja un worker recién arrancado que nadie va a usar y que
|
|
537
|
+
// hay que terminar a mitad del arranque. Bun se cae con SIGSEGV al
|
|
538
|
+
// cerrar el proceso en ese estado (CI: workers_spawned 13, terminated 11).
|
|
503
539
|
slot.worker.terminate()
|
|
504
540
|
const index = this.workers.indexOf(slot)
|
|
505
|
-
if (index >= 0)
|
|
506
|
-
this.workers[index] = this.createSlot()
|
|
507
|
-
}
|
|
541
|
+
if (index >= 0) this.workers.splice(index, 1)
|
|
508
542
|
} else {
|
|
509
543
|
slot.busy = false
|
|
510
544
|
slot.job = undefined
|
|
@@ -550,9 +584,12 @@ function resolveToolTimeout(
|
|
|
550
584
|
return baseTimeoutMs
|
|
551
585
|
}
|
|
552
586
|
|
|
553
|
-
function getPool(maxWorkers: number): ToolWorkerPool {
|
|
587
|
+
function getPool(maxWorkers: number): ToolWorkerPool | null {
|
|
588
|
+
const workerEntry = resolveWorkerEntry()
|
|
589
|
+
if (!workerEntry) return null
|
|
590
|
+
|
|
554
591
|
if (!sharedPool || sharedPoolSize !== maxWorkers) {
|
|
555
|
-
sharedPool = new ToolWorkerPool(maxWorkers)
|
|
592
|
+
sharedPool = new ToolWorkerPool(maxWorkers, workerEntry)
|
|
556
593
|
sharedPoolSize = maxWorkers
|
|
557
594
|
}
|
|
558
595
|
return sharedPool
|
|
@@ -578,7 +615,13 @@ export async function executeToolBatch(options: ExecuteToolBatchOptions): Promis
|
|
|
578
615
|
}))
|
|
579
616
|
}
|
|
580
617
|
|
|
581
|
-
|
|
618
|
+
// A null pool means workers are disabled, unnecessary (single call), or
|
|
619
|
+
// unavailable in this build — all three degrade to the main thread.
|
|
620
|
+
const pool = runtimeConfig.enabled && runtimeConfig.parallelToolCalls && options.toolCalls.length > 1
|
|
621
|
+
? getPool(runtimeConfig.maxWorkers)
|
|
622
|
+
: null
|
|
623
|
+
|
|
624
|
+
if (!pool) {
|
|
582
625
|
const results: ToolBatchResult[] = []
|
|
583
626
|
for (const toolCall of options.toolCalls) {
|
|
584
627
|
const startedAt = performance.now()
|
|
@@ -605,7 +648,6 @@ export async function executeToolBatch(options: ExecuteToolBatchOptions): Promis
|
|
|
605
648
|
return results
|
|
606
649
|
}
|
|
607
650
|
|
|
608
|
-
const pool = getPool(runtimeConfig.maxWorkers)
|
|
609
651
|
const batchId = crypto.randomUUID()
|
|
610
652
|
const abortHandler = () => pool.abortBatch(batchId, "Tool execution aborted")
|
|
611
653
|
options.signal?.addEventListener("abort", abortHandler, { once: true })
|
|
@@ -11,7 +11,7 @@ import type { Config } from "../config/loader.ts";
|
|
|
11
11
|
// Filesystem (7)
|
|
12
12
|
import * as filesystem from "./filesystem/index.ts";
|
|
13
13
|
|
|
14
|
-
// Web (
|
|
14
|
+
// Web (11)
|
|
15
15
|
import * as web from "./web/index.ts";
|
|
16
16
|
|
|
17
17
|
// Cron (8) - Croner-based scheduler tools
|
|
@@ -43,7 +43,7 @@ export function createAllTools(config: Config): Tool[] {
|
|
|
43
43
|
// FILESYSTEM (7)
|
|
44
44
|
...filesystem.createTools(),
|
|
45
45
|
|
|
46
|
-
// WEB (
|
|
46
|
+
// WEB (11)
|
|
47
47
|
...web.createTools(),
|
|
48
48
|
|
|
49
49
|
// CRON (8)
|
|
@@ -118,12 +118,14 @@ export {
|
|
|
118
118
|
webFetchTool,
|
|
119
119
|
browserNavigateTool,
|
|
120
120
|
browserScreenshotTool,
|
|
121
|
+
computerUseTaskTool,
|
|
121
122
|
browserClickTool,
|
|
122
123
|
browserTypeTool,
|
|
123
124
|
browserExtractTool,
|
|
124
125
|
browserScriptTool,
|
|
125
126
|
browserWaitTool,
|
|
126
127
|
artifactInspectTool,
|
|
128
|
+
artifactReadTool,
|
|
127
129
|
} from "./web/index.ts";
|
|
128
130
|
|
|
129
131
|
export {
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* artifact_read — reads back the content an artifact_ref points at.
|
|
3
|
+
*
|
|
4
|
+
* mcp-result-normalizer.ts keeps oversized MCP text results out of the context
|
|
5
|
+
* window: the model gets `{ type: "artifact_ref", artifact_id, size, preview }`
|
|
6
|
+
* with a blind 500-char preview. That is the right call for the context, but
|
|
7
|
+
* without a way to read the artifact back it left the agent stuck — it would
|
|
8
|
+
* call artifact_inspect (metadata only), find no content, and burn its
|
|
9
|
+
* iterations until the turn died on an empty synthesis. This is the way back in.
|
|
10
|
+
*
|
|
11
|
+
* Slicing is by characters, not lines: the case this was built for is a single
|
|
12
|
+
* 245 KB JSON line from a Gmail MCP server, where line-based paging returns
|
|
13
|
+
* everything or nothing. `search` exists for the same reason — jumping straight
|
|
14
|
+
* to the three relevant messages beats paging through 245 KB in 20 KB chunks.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import type { Tool } from "../types";
|
|
18
|
+
import { readArtifactText } from "../../artifacts/store";
|
|
19
|
+
|
|
20
|
+
const DEFAULT_LIMIT = 20_000;
|
|
21
|
+
const MAX_LIMIT = 50_000;
|
|
22
|
+
const MAX_MATCHES = 10;
|
|
23
|
+
const DEFAULT_MATCH_CONTEXT = 600;
|
|
24
|
+
const MAX_MATCH_CONTEXT = 8_000;
|
|
25
|
+
/**
|
|
26
|
+
* What a search may return in total. Capping the per-match window alone would
|
|
27
|
+
* be the wrong knob: a record whose fields are 2 KB of mail headers needs a
|
|
28
|
+
* wide window to show its id, while ten such windows would put back into the
|
|
29
|
+
* context exactly what the artifact was created to keep out.
|
|
30
|
+
*/
|
|
31
|
+
const MAX_SEARCH_CHARS = 40_000;
|
|
32
|
+
|
|
33
|
+
function clampNumber(value: unknown, fallback: number, min: number, max: number): number {
|
|
34
|
+
const parsed = typeof value === "number" ? value : Number(value);
|
|
35
|
+
if (!Number.isFinite(parsed)) return fallback;
|
|
36
|
+
return Math.min(max, Math.max(min, Math.floor(parsed)));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function findMatches(text: string, query: string, context: number): Array<{ offset: number; excerpt: string }> {
|
|
40
|
+
const haystack = text.toLowerCase();
|
|
41
|
+
const needle = query.toLowerCase();
|
|
42
|
+
const matches: Array<{ offset: number; excerpt: string }> = [];
|
|
43
|
+
const half = Math.floor(context / 2);
|
|
44
|
+
let from = 0;
|
|
45
|
+
|
|
46
|
+
let used = 0;
|
|
47
|
+
|
|
48
|
+
while (matches.length < MAX_MATCHES) {
|
|
49
|
+
const at = haystack.indexOf(needle, from);
|
|
50
|
+
if (at === -1) break;
|
|
51
|
+
const start = Math.max(0, at - half);
|
|
52
|
+
const end = Math.min(text.length, at + needle.length + half);
|
|
53
|
+
const excerpt = text.slice(start, end);
|
|
54
|
+
// The first match always comes back, however wide it is — returning zero
|
|
55
|
+
// results for a query that did match would be the worst possible answer.
|
|
56
|
+
if (matches.length > 0 && used + excerpt.length > MAX_SEARCH_CHARS) break;
|
|
57
|
+
matches.push({ offset: at, excerpt });
|
|
58
|
+
used += excerpt.length;
|
|
59
|
+
from = at + needle.length;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return matches;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function countMatches(text: string, query: string): number {
|
|
66
|
+
const haystack = text.toLowerCase();
|
|
67
|
+
const needle = query.toLowerCase();
|
|
68
|
+
let total = 0;
|
|
69
|
+
let from = 0;
|
|
70
|
+
for (;;) {
|
|
71
|
+
const at = haystack.indexOf(needle, from);
|
|
72
|
+
if (at === -1) return total;
|
|
73
|
+
total++;
|
|
74
|
+
from = at + needle.length;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export const artifactReadTool: Tool = {
|
|
79
|
+
name: "artifact_read",
|
|
80
|
+
description:
|
|
81
|
+
"Read the text content of a managed artifact in slices, or search inside it. Use this on any artifact_ref a tool returned instead of guessing from its preview. Spanish: leer artefacto, ver contenido del artefacto, abrir resultado grande, buscar dentro del artefacto",
|
|
82
|
+
parameters: {
|
|
83
|
+
type: "object",
|
|
84
|
+
properties: {
|
|
85
|
+
artifactId: {
|
|
86
|
+
type: "string",
|
|
87
|
+
description: "Managed artifact identifier (the artifact_id of an artifact_ref).",
|
|
88
|
+
},
|
|
89
|
+
offset: {
|
|
90
|
+
type: "number",
|
|
91
|
+
description: "Character position to start reading from (default: 0). Use next_offset from the previous call to continue.",
|
|
92
|
+
},
|
|
93
|
+
limit: {
|
|
94
|
+
type: "number",
|
|
95
|
+
description: `Characters to return (default: ${DEFAULT_LIMIT}, max: ${MAX_LIMIT}).`,
|
|
96
|
+
},
|
|
97
|
+
search: {
|
|
98
|
+
type: "string",
|
|
99
|
+
description: "Return excerpts around each case-insensitive match instead of a contiguous slice. Far cheaper than paging a large artifact.",
|
|
100
|
+
},
|
|
101
|
+
context: {
|
|
102
|
+
type: "number",
|
|
103
|
+
description: `Characters of surrounding text per match (default: ${DEFAULT_MATCH_CONTEXT}, max: ${MAX_MATCH_CONTEXT}). Widen it when records carry long fields and the excerpt cuts off the data you need.`,
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
required: ["artifactId"],
|
|
107
|
+
},
|
|
108
|
+
execute: async (params, config) => {
|
|
109
|
+
const artifactId = String(params.artifactId ?? "").trim();
|
|
110
|
+
if (!artifactId) return { ok: false, error: "artifactId is required" };
|
|
111
|
+
|
|
112
|
+
const userId = config?.configurable?.user_id as string | undefined;
|
|
113
|
+
const result = await readArtifactText(artifactId, { userId });
|
|
114
|
+
if (!result.ok || !result.artifact) {
|
|
115
|
+
return { ok: false, artifact_id: artifactId, error: result.error, status: result.status };
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const artifact = result.artifact;
|
|
119
|
+
const text = result.text ?? "";
|
|
120
|
+
const search = typeof params.search === "string" ? params.search.trim() : "";
|
|
121
|
+
|
|
122
|
+
if (search) {
|
|
123
|
+
const context = clampNumber(params.context, DEFAULT_MATCH_CONTEXT, 40, MAX_MATCH_CONTEXT);
|
|
124
|
+
const matches = findMatches(text, search, context);
|
|
125
|
+
// Always the real count, never the number returned: collection stops at
|
|
126
|
+
// MAX_MATCHES or at the character budget, and an agent told "4 matches"
|
|
127
|
+
// when there are 8 stops looking.
|
|
128
|
+
const total = countMatches(text, search);
|
|
129
|
+
return {
|
|
130
|
+
ok: true,
|
|
131
|
+
artifact_id: artifact.id,
|
|
132
|
+
mime_type: artifact.mime_type,
|
|
133
|
+
total_chars: text.length,
|
|
134
|
+
query: search,
|
|
135
|
+
total_matches: total,
|
|
136
|
+
returned_matches: matches.length,
|
|
137
|
+
truncated: total > matches.length,
|
|
138
|
+
context,
|
|
139
|
+
matches,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const offset = clampNumber(params.offset, 0, 0, Math.max(0, text.length));
|
|
144
|
+
const limit = clampNumber(params.limit, DEFAULT_LIMIT, 1, MAX_LIMIT);
|
|
145
|
+
const content = text.slice(offset, offset + limit);
|
|
146
|
+
const nextOffset = offset + content.length;
|
|
147
|
+
const eof = nextOffset >= text.length;
|
|
148
|
+
|
|
149
|
+
return {
|
|
150
|
+
ok: true,
|
|
151
|
+
artifact_id: artifact.id,
|
|
152
|
+
mime_type: artifact.mime_type,
|
|
153
|
+
kind: artifact.kind,
|
|
154
|
+
total_chars: text.length,
|
|
155
|
+
offset,
|
|
156
|
+
returned_chars: content.length,
|
|
157
|
+
next_offset: eof ? null : nextOffset,
|
|
158
|
+
eof,
|
|
159
|
+
content,
|
|
160
|
+
};
|
|
161
|
+
},
|
|
162
|
+
};
|
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* BrowserBackend — el contrato que consumen las browser tools.
|
|
3
3
|
*
|
|
4
|
-
* Hay
|
|
4
|
+
* Hay una sola implementación: `WebViewBackend` (webview-backend.ts), sobre
|
|
5
|
+
* `Bun.WebView`. In-process, sin instalación y sin subprocesos: ~0,3 ms un
|
|
6
|
+
* `evaluate`, ~2 ms un `snapshot`. Con motor chrome corre headless de verdad
|
|
7
|
+
* —Bun lanza el navegador con `--headless`—, así que sirve en un servidor sin
|
|
8
|
+
* display; lo único que necesita es un navegador Chromium instalado (o
|
|
9
|
+
* `BUN_CHROME_PATH`).
|
|
5
10
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* un `Bun.spawn` por operación —medido en ~68 ms de piso— más una
|
|
10
|
-
* instalación diferida de ~75 MB y la descarga de Chrome.
|
|
11
|
+
* El contrato sigue existiendo aunque el backend sea uno solo: es lo que hace
|
|
12
|
+
* que las tools no dependan del motor, y lo que deja al motor WebKit de macOS
|
|
13
|
+
* —que no tiene CDP— entrar por la misma puerta con menos capacidades.
|
|
11
14
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* El default sigue siendo agent-browser: es el único de los dos que funciona
|
|
18
|
-
* donde suele correr el gateway. WebView se elige explícitamente.
|
|
15
|
+
* Dos cosas que hay que saber del WebView y que están resueltas adentro: el
|
|
16
|
+
* perfil de Chrome que abre Bun es efímero (`/tmp/.<hash>.bun-chrome`, y el
|
|
17
|
+
* hash cambia entre procesos), por eso las cookies se guardan y restauran a
|
|
18
|
+
* mano desde `browser-session.ts`; y como root sin `--no-sandbox` Chromium no
|
|
19
|
+
* arranca, por eso el Dockerfile apunta `BUN_CHROME_PATH` a un wrapper.
|
|
19
20
|
*/
|
|
20
21
|
|
|
22
|
+
import { logger } from "../../utils/logger.ts";
|
|
23
|
+
|
|
24
|
+
const log = logger.child("browser-backend");
|
|
25
|
+
|
|
21
26
|
export interface ScreenshotOptions {
|
|
22
27
|
encoding?: "blob" | "buffer" | "base64" | "shmem";
|
|
23
28
|
format?: "png" | "jpeg" | "webp";
|
|
@@ -62,55 +67,126 @@ export interface BrowserBackend {
|
|
|
62
67
|
resize(width: number, height: number): Promise<void>;
|
|
63
68
|
/** Captura de un elemento puntual; el backend puede recortar sobre el viewport. */
|
|
64
69
|
screenshotElement(selector: string): Promise<string>;
|
|
70
|
+
/**
|
|
71
|
+
* Puente CDP crudo. Opcional a propósito: lo tienen los backends con Chrome,
|
|
72
|
+
* no el motor WebKit de macOS. Quien lo use tiene que traer una alternativa.
|
|
73
|
+
*/
|
|
74
|
+
cdp?<T = unknown>(method: string, params?: Record<string, unknown>): Promise<T>;
|
|
65
75
|
close(): void;
|
|
66
76
|
}
|
|
67
77
|
|
|
68
|
-
|
|
78
|
+
/** Ya no hay más de uno; el tipo se conserva porque lo reportan doctor y el gateway. */
|
|
79
|
+
export type BrowserBackendKind = "webview";
|
|
69
80
|
|
|
70
|
-
/**
|
|
71
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Lo que se puede pedir por config. `"agent-browser"` era el backend por CLI que
|
|
83
|
+
* se retiró: se sigue aceptando para no romper un `hive.json` viejo, pero avisa
|
|
84
|
+
* y usa el WebView.
|
|
85
|
+
*/
|
|
86
|
+
export type BrowserBackendPreference = BrowserBackendKind | "auto" | "agent-browser";
|
|
72
87
|
|
|
73
88
|
/** Motor que usa `Bun.WebView` por debajo. */
|
|
74
89
|
export type WebViewEngine = "webkit" | "chrome";
|
|
75
90
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
91
|
+
/**
|
|
92
|
+
* Binarios que valen: cualquier Chromium sirve, porque lo que Bun necesita es
|
|
93
|
+
* `--remote-debugging-pipe`, que todos implementan. Edge y Brave son los que más
|
|
94
|
+
* aparecen en máquinas donde no hay Chrome "de marca".
|
|
95
|
+
*/
|
|
96
|
+
const CHROME_BINARIES = [
|
|
97
|
+
"google-chrome",
|
|
98
|
+
"google-chrome-stable",
|
|
99
|
+
"chromium",
|
|
100
|
+
"chromium-browser",
|
|
101
|
+
"brave-browser",
|
|
102
|
+
"microsoft-edge",
|
|
103
|
+
"microsoft-edge-stable",
|
|
104
|
+
"vivaldi",
|
|
105
|
+
"vivaldi-stable",
|
|
106
|
+
"opera",
|
|
86
107
|
];
|
|
87
108
|
|
|
88
|
-
/**
|
|
109
|
+
/** Rutas conocidas por plataforma, en orden de preferencia. */
|
|
110
|
+
function chromePathsForPlatform(): string[] {
|
|
111
|
+
const home = process.env.HOME ?? "";
|
|
112
|
+
|
|
113
|
+
if (process.platform === "darwin") {
|
|
114
|
+
return [
|
|
115
|
+
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
|
116
|
+
"/Applications/Chromium.app/Contents/MacOS/Chromium",
|
|
117
|
+
"/Applications/Brave Browser.app/Contents/MacOS/Brave Browser",
|
|
118
|
+
"/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge",
|
|
119
|
+
"/Applications/Vivaldi.app/Contents/MacOS/Vivaldi",
|
|
120
|
+
`${home}/Applications/Google Chrome.app/Contents/MacOS/Google Chrome`,
|
|
121
|
+
];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (process.platform === "win32") {
|
|
125
|
+
const programFiles = process.env["ProgramFiles"] ?? "C:\\Program Files";
|
|
126
|
+
const programFilesX86 = process.env["ProgramFiles(x86)"] ?? "C:\\Program Files (x86)";
|
|
127
|
+
const localAppData = process.env.LOCALAPPDATA ?? "";
|
|
128
|
+
return [
|
|
129
|
+
`${programFiles}\\Google\\Chrome\\Application\\chrome.exe`,
|
|
130
|
+
`${programFilesX86}\\Google\\Chrome\\Application\\chrome.exe`,
|
|
131
|
+
`${localAppData}\\Google\\Chrome\\Application\\chrome.exe`,
|
|
132
|
+
`${programFilesX86}\\Microsoft\\Edge\\Application\\msedge.exe`,
|
|
133
|
+
`${programFiles}\\Microsoft\\Edge\\Application\\msedge.exe`,
|
|
134
|
+
`${programFiles}\\BraveSoftware\\Brave-Browser\\Application\\brave.exe`,
|
|
135
|
+
];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Linux: paquetes del sistema, snap y los wrappers que exporta flatpak —que
|
|
139
|
+
// en la práctica son el único Chrome de muchas máquinas.
|
|
140
|
+
const flatpakDirs = ["/var/lib/flatpak/exports/bin", `${home}/.local/share/flatpak/exports/bin`];
|
|
141
|
+
const flatpakApps = ["com.google.Chrome", "org.chromium.Chromium", "com.brave.Browser", "com.microsoft.Edge"];
|
|
142
|
+
return [
|
|
143
|
+
"/usr/bin/google-chrome",
|
|
144
|
+
"/usr/bin/google-chrome-stable",
|
|
145
|
+
"/usr/bin/chromium",
|
|
146
|
+
"/usr/bin/chromium-browser",
|
|
147
|
+
"/usr/bin/brave-browser",
|
|
148
|
+
"/usr/bin/microsoft-edge",
|
|
149
|
+
"/usr/bin/microsoft-edge-stable",
|
|
150
|
+
"/usr/bin/vivaldi",
|
|
151
|
+
"/usr/bin/opera",
|
|
152
|
+
"/snap/bin/chromium",
|
|
153
|
+
"/snap/bin/brave",
|
|
154
|
+
...flatpakDirs.flatMap((dir) => flatpakApps.map((app) => `${dir}/${app}`)),
|
|
155
|
+
];
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** Navegador instalado — `Bun.WebView` con motor chrome lo necesita. */
|
|
89
159
|
export function findChrome(): string | null {
|
|
90
160
|
if (process.env.BUN_CHROME_PATH) return process.env.BUN_CHROME_PATH;
|
|
161
|
+
|
|
91
162
|
const { existsSync } = require("node:fs") as typeof import("node:fs");
|
|
92
|
-
for (const candidate of
|
|
93
|
-
if (existsSync(candidate)) return candidate;
|
|
163
|
+
for (const candidate of chromePathsForPlatform()) {
|
|
164
|
+
if (candidate && existsSync(candidate)) return candidate;
|
|
94
165
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
166
|
+
|
|
167
|
+
// Último recurso: lo que haya en el PATH, que cubre instalaciones a mano y
|
|
168
|
+
// los wrappers que el usuario tenga en ~/.local/bin.
|
|
169
|
+
const which = (globalThis as { Bun?: { which?: (cmd: string) => string | null } }).Bun?.which;
|
|
170
|
+
if (which) {
|
|
171
|
+
for (const name of CHROME_BINARIES) {
|
|
172
|
+
const found = which(name);
|
|
173
|
+
if (found) return found;
|
|
101
174
|
}
|
|
102
175
|
}
|
|
103
176
|
return null;
|
|
104
177
|
}
|
|
105
178
|
|
|
106
179
|
/**
|
|
107
|
-
* Motor a usar.
|
|
108
|
-
*
|
|
109
|
-
*
|
|
180
|
+
* Motor a usar.
|
|
181
|
+
*
|
|
182
|
+
* Chrome primero **también en macOS**: es el único que trae CDP, y de CDP
|
|
183
|
+
* dependen el árbol de accesibilidad del snapshot, la sesión persistente y los
|
|
184
|
+
* clics reales de `computer_use_task`. WebKit queda como respaldo para un mac
|
|
185
|
+
* sin ningún Chromium instalado: no necesita nada, pero da menos.
|
|
110
186
|
*/
|
|
111
187
|
export function resolveWebViewEngine(): WebViewEngine | null {
|
|
112
|
-
if (
|
|
113
|
-
return
|
|
188
|
+
if (findChrome()) return "chrome";
|
|
189
|
+
return process.platform === "darwin" ? "webkit" : null;
|
|
114
190
|
}
|
|
115
191
|
|
|
116
192
|
/** `Bun.WebView` existe desde Bun 1.3; además hace falta un motor utilizable. */
|
|
@@ -119,11 +195,32 @@ export function isWebViewSupported(): boolean {
|
|
|
119
195
|
return resolveWebViewEngine() !== null;
|
|
120
196
|
}
|
|
121
197
|
|
|
198
|
+
/**
|
|
199
|
+
* Qué decirle a alguien que no tiene navegador. Lo usan el arranque del gateway
|
|
200
|
+
* y `hive doctor`, para que el mensaje sea el mismo en los dos lados.
|
|
201
|
+
*/
|
|
202
|
+
export function browserInstallHint(): string {
|
|
203
|
+
if (process.platform === "darwin") {
|
|
204
|
+
return "Instala Google Chrome (brew install --cask google-chrome) o define BUN_CHROME_PATH.";
|
|
205
|
+
}
|
|
206
|
+
if (process.platform === "win32") {
|
|
207
|
+
return "Instala Google Chrome o Microsoft Edge, o define BUN_CHROME_PATH.";
|
|
208
|
+
}
|
|
209
|
+
return "Instala Chromium o Chrome (apt install chromium · dnf install chromium) o define BUN_CHROME_PATH.";
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
let avisoBackendRetirado = false;
|
|
213
|
+
|
|
122
214
|
export function resolveBackendKind(
|
|
123
215
|
preference: BrowserBackendPreference | undefined,
|
|
124
216
|
): BrowserBackendKind {
|
|
125
|
-
const wanted = process.env.HIVE_BROWSER_BACKEND ?? preference
|
|
126
|
-
if (wanted === "
|
|
127
|
-
|
|
128
|
-
|
|
217
|
+
const wanted = process.env.HIVE_BROWSER_BACKEND ?? preference;
|
|
218
|
+
if (wanted === "agent-browser" && !avisoBackendRetirado) {
|
|
219
|
+
avisoBackendRetirado = true;
|
|
220
|
+
log.warn(
|
|
221
|
+
'tools.browser.backend: "agent-browser" ya no existe — se usa Bun.WebView. ' +
|
|
222
|
+
"Puedes quitar esa clave de la config.",
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
return "webview";
|
|
129
226
|
}
|
|
@@ -43,7 +43,7 @@ export const browserClickTool: Tool = {
|
|
|
43
43
|
log.warn("Browser not available");
|
|
44
44
|
return {
|
|
45
45
|
ok: false,
|
|
46
|
-
error: "Browser automation not available. Install
|
|
46
|
+
error: "Browser automation not available. Install Chrome or Chromium (or run `hive doctor`).",
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -51,7 +51,7 @@ export const browserClickTool: Tool = {
|
|
|
51
51
|
|
|
52
52
|
try {
|
|
53
53
|
const view = await browserService.getView();
|
|
54
|
-
if (!view) return { ok: false, error: "Browser automation not available. Install
|
|
54
|
+
if (!view) return { ok: false, error: "Browser automation not available. Install Chrome or Chromium (or run `hive doctor`)." };
|
|
55
55
|
|
|
56
56
|
if (url) {
|
|
57
57
|
await view.navigate(url);
|
|
@@ -53,7 +53,7 @@ export const browserExtractTool: Tool = {
|
|
|
53
53
|
log.warn("Browser not available");
|
|
54
54
|
return {
|
|
55
55
|
ok: false,
|
|
56
|
-
error: "Browser automation not available. Install
|
|
56
|
+
error: "Browser automation not available. Install Chrome or Chromium (or run `hive doctor`).",
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -61,7 +61,7 @@ export const browserExtractTool: Tool = {
|
|
|
61
61
|
|
|
62
62
|
try {
|
|
63
63
|
const view = await browserService.getView();
|
|
64
|
-
if (!view) return { ok: false, error: "Browser automation not available. Install
|
|
64
|
+
if (!view) return { ok: false, error: "Browser automation not available. Install Chrome or Chromium (or run `hive doctor`)." };
|
|
65
65
|
|
|
66
66
|
if (url) {
|
|
67
67
|
await view.navigate(url);
|
|
@@ -49,7 +49,7 @@ export const browserNavigateTool: Tool = {
|
|
|
49
49
|
log.warn("Browser not available");
|
|
50
50
|
return {
|
|
51
51
|
ok: false,
|
|
52
|
-
error: "Browser automation not available. Install
|
|
52
|
+
error: "Browser automation not available. Install Chrome or Chromium (or run `hive doctor`).",
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -57,7 +57,7 @@ export const browserNavigateTool: Tool = {
|
|
|
57
57
|
|
|
58
58
|
try {
|
|
59
59
|
const view = await browserService.getView();
|
|
60
|
-
if (!view) return { ok: false, error: "Browser automation not available. Install
|
|
60
|
+
if (!view) return { ok: false, error: "Browser automation not available. Install Chrome or Chromium (or run `hive doctor`)." };
|
|
61
61
|
|
|
62
62
|
await view.navigate(url);
|
|
63
63
|
|