@johpaz/hive-agents 0.0.31 → 0.0.32

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.
Files changed (3) hide show
  1. package/README.md +16 -16
  2. package/dist/hive.js +431 -282
  3. package/package.json +1 -1
package/dist/hive.js CHANGED
@@ -476869,19 +476869,192 @@ var init_install = __esm(() => {
476869
476869
  if (false) {}
476870
476870
  });
476871
476871
 
476872
- // packages/core/src/gateway/routes/tts-local.ts
476872
+ // packages/tts/src/server.ts
476873
476873
  import { existsSync as existsSync26, readdirSync as readdirSync5, readFileSync as readFileSync12 } from "fs";
476874
476874
  import { join as join19 } from "path";
476875
476875
  import { homedir as homedir3 } from "os";
476876
+ function getPiperPath() {
476877
+ const platform2 = detectPlatform();
476878
+ const binaryName = getPiperBinaryName(platform2);
476879
+ const binaryPath = join19(BIN_DIR, binaryName);
476880
+ if (!existsSync26(binaryPath)) {
476881
+ throw new Error("Piper no instalado. Ejecuta: bun run src/install.ts");
476882
+ }
476883
+ return binaryPath;
476884
+ }
476885
+ function listVoices() {
476886
+ if (!existsSync26(VOICES_DIR))
476887
+ return [];
476888
+ return readdirSync5(VOICES_DIR).filter((f2) => f2.endsWith(".onnx")).map((f2) => f2.replace(".onnx", ""));
476889
+ }
476890
+ async function synthesize(text2, voice) {
476891
+ const piperPath = getPiperPath();
476892
+ const modelPath = join19(VOICES_DIR, `${voice}.onnx`);
476893
+ const configPath = join19(VOICES_DIR, `${voice}.onnx.json`);
476894
+ if (!existsSync26(modelPath)) {
476895
+ throw new Error(`Voz no encontrada: ${voice}`);
476896
+ }
476897
+ let lengthScale = 0.95;
476898
+ let noiseScale = 0.6;
476899
+ let noiseW = 0.75;
476900
+ let sentenceSilence = 0.2;
476901
+ if (existsSync26(configPath)) {
476902
+ try {
476903
+ const config2 = JSON.parse(readFileSync12(configPath, "utf-8"));
476904
+ const inference = config2.inference || {};
476905
+ lengthScale = (inference.length_scale ?? 1) * 0.95;
476906
+ noiseScale = (inference.noise_scale ?? 0.667) * 0.9;
476907
+ noiseW = (inference.noise_w ?? 0.8) * 0.95;
476908
+ } catch (err) {
476909
+ log77.warn(`No se pudo leer configuraci\xF3n del modelo: ${err}`);
476910
+ }
476911
+ }
476912
+ lengthScale = Number(process.env.PIPER_LENGTH_SCALE ?? lengthScale);
476913
+ noiseScale = Number(process.env.PIPER_NOISE_SCALE ?? noiseScale);
476914
+ noiseW = Number(process.env.PIPER_NOISE_W ?? noiseW);
476915
+ sentenceSilence = Number(process.env.PIPER_SENTENCE_SILENCE ?? sentenceSilence);
476916
+ const args = [
476917
+ piperPath,
476918
+ "--model",
476919
+ modelPath,
476920
+ "--output-raw",
476921
+ "--length_scale",
476922
+ String(lengthScale),
476923
+ "--noise_scale",
476924
+ String(noiseScale),
476925
+ "--noise_w",
476926
+ String(noiseW),
476927
+ "--sentence_silence",
476928
+ String(sentenceSilence)
476929
+ ];
476930
+ const proc = Bun.spawn(args, {
476931
+ stdin: "pipe",
476932
+ stdout: "pipe",
476933
+ stderr: "pipe"
476934
+ });
476935
+ proc.stdin.write(new TextEncoder().encode(text2));
476936
+ proc.stdin.end();
476937
+ const [audioBuffer, exitCode] = await Promise.all([
476938
+ new Response(proc.stdout).arrayBuffer(),
476939
+ proc.exited
476940
+ ]);
476941
+ if (exitCode !== 0) {
476942
+ const errText = await new Response(proc.stderr).text();
476943
+ throw new Error(`Piper error (exit ${exitCode}): ${errText}`);
476944
+ }
476945
+ return wrapInWav(audioBuffer, 22050, 1, 16);
476946
+ }
476947
+ function wrapInWav(pcm, sampleRate, channels, bitsPerSample) {
476948
+ const dataSize = pcm.byteLength;
476949
+ const header = new ArrayBuffer(44);
476950
+ const view = new DataView(header);
476951
+ const writeStr = (offset, str2) => {
476952
+ for (let i3 = 0;i3 < str2.length; i3++)
476953
+ view.setUint8(offset + i3, str2.charCodeAt(i3));
476954
+ };
476955
+ writeStr(0, "RIFF");
476956
+ view.setUint32(4, 36 + dataSize, true);
476957
+ writeStr(8, "WAVE");
476958
+ writeStr(12, "fmt ");
476959
+ view.setUint32(16, 16, true);
476960
+ view.setUint16(20, 1, true);
476961
+ view.setUint16(22, channels, true);
476962
+ view.setUint32(24, sampleRate, true);
476963
+ view.setUint32(28, sampleRate * channels * bitsPerSample / 8, true);
476964
+ view.setUint16(32, channels * bitsPerSample / 8, true);
476965
+ view.setUint16(34, bitsPerSample, true);
476966
+ writeStr(36, "data");
476967
+ view.setUint32(40, dataSize, true);
476968
+ const wav = new Uint8Array(44 + dataSize);
476969
+ wav.set(new Uint8Array(header), 0);
476970
+ wav.set(new Uint8Array(pcm), 44);
476971
+ return wav.buffer;
476972
+ }
476973
+ function startTTSServer(opts) {
476974
+ const listenPort = opts?.port ?? PORT;
476975
+ const server = Bun.serve({
476976
+ port: listenPort,
476977
+ async fetch(req) {
476978
+ const url2 = new URL(req.url);
476979
+ if (req.method === "OPTIONS") {
476980
+ return new Response(null, { status: 204, headers: CORS });
476981
+ }
476982
+ if (req.method === "GET" && url2.pathname === "/health") {
476983
+ return Response.json({ ok: true, voice: DEFAULT_VOICE_ENV, voices: listVoices() }, { headers: CORS });
476984
+ }
476985
+ if (req.method === "GET" && url2.pathname === "/voices") {
476986
+ return Response.json({ voices: listVoices() }, { headers: CORS });
476987
+ }
476988
+ if (req.method === "POST" && url2.pathname === "/tts") {
476989
+ let body;
476990
+ try {
476991
+ body = await req.json();
476992
+ } catch {
476993
+ return Response.json({ error: "Body JSON inv\xE1lido" }, { status: 400, headers: CORS });
476994
+ }
476995
+ const { text: text2, voice = DEFAULT_VOICE_ENV } = body;
476996
+ if (!text2 || typeof text2 !== "string" || text2.trim().length === 0) {
476997
+ return Response.json({ error: "Campo 'text' requerido" }, { status: 400, headers: CORS });
476998
+ }
476999
+ if (text2.length > 2000) {
477000
+ return Response.json({ error: "Texto demasiado largo (m\xE1x 2000 chars)" }, { status: 400, headers: CORS });
477001
+ }
477002
+ try {
477003
+ const audio = await synthesize(text2.trim(), voice);
477004
+ return new Response(audio, {
477005
+ headers: {
477006
+ ...CORS,
477007
+ "Content-Type": "audio/wav",
477008
+ "Content-Length": String(audio.byteLength)
477009
+ }
477010
+ });
477011
+ } catch (err) {
477012
+ const message = err instanceof Error ? err.message : "Error interno";
477013
+ return Response.json({ error: message }, { status: 500, headers: CORS });
477014
+ }
477015
+ }
477016
+ return Response.json({ error: "Not found" }, { status: 404, headers: CORS });
477017
+ }
477018
+ });
477019
+ log77.info(`Hive TTS Server escuchando en http://localhost:${listenPort}`);
477020
+ log77.info(`Voz por defecto: ${DEFAULT_VOICE_ENV}`);
477021
+ log77.info(`Voces disponibles: ${listVoices().join(", ") || "ninguna (ejecuta install.ts primero)"}`);
477022
+ return server;
477023
+ }
477024
+ var log77, TTS_ROOT, BIN_DIR, VOICES_DIR, PORT, DEFAULT_VOICE_ENV, CORS;
477025
+ var init_server = __esm(() => {
477026
+ init_detect();
477027
+ log77 = {
477028
+ info: (msg) => console.log(`[TTS] ${msg}`),
477029
+ warn: (msg) => console.warn(`[TTS] ${msg}`),
477030
+ error: (msg) => console.error(`[TTS] ${msg}`)
477031
+ };
477032
+ TTS_ROOT = process.env.HIVE_TTS_ROOT ?? join19(process.env.HIVE_HOME ?? join19(homedir3(), ".hive"), "tts");
477033
+ BIN_DIR = join19(TTS_ROOT, "bin");
477034
+ VOICES_DIR = join19(TTS_ROOT, "voices");
477035
+ PORT = Number(process.env.TTS_PORT ?? 5500);
477036
+ DEFAULT_VOICE_ENV = process.env.TTS_VOICE ?? DEFAULT_VOICE;
477037
+ CORS = {
477038
+ "Access-Control-Allow-Origin": "*",
477039
+ "Access-Control-Allow-Methods": "GET, POST, OPTIONS",
477040
+ "Access-Control-Allow-Headers": "Content-Type"
477041
+ };
477042
+ if (false) {}
477043
+ });
477044
+
477045
+ // packages/core/src/gateway/routes/tts-local.ts
477046
+ import { existsSync as existsSync27, readdirSync as readdirSync6, readFileSync as readFileSync13 } from "fs";
477047
+ import { join as join20 } from "path";
477048
+ import { homedir as homedir4 } from "os";
476876
477049
  function isInstalled() {
476877
- const piperExists = existsSync26(BIN_PATH);
477050
+ const piperExists = existsSync27(BIN_PATH);
476878
477051
  const voiceExists = getInstalledVoices().length > 0;
476879
477052
  return { piperExists, voiceExists, installed: piperExists && voiceExists };
476880
477053
  }
476881
477054
  function getInstalledVoices() {
476882
- if (!existsSync26(VOICES_DIR))
477055
+ if (!existsSync27(VOICES_DIR2))
476883
477056
  return [];
476884
- const files = readdirSync5(VOICES_DIR);
477057
+ const files = readdirSync6(VOICES_DIR2);
476885
477058
  return files.filter((f2) => f2.endsWith(".onnx")).map((f2) => f2.replace(".onnx", ""));
476886
477059
  }
476887
477060
  async function isRunning() {
@@ -476909,7 +477082,7 @@ async function handleGetLocalTTSStatus(req, addCors) {
476909
477082
  }), req);
476910
477083
  }
476911
477084
  async function handleGetLocalTTSLogs(req, addCors) {
476912
- return addCors(Response.json({ logs: installLogs.slice(-100), ttsRoot: TTS_ROOT, bunPath: process.execPath }), req);
477085
+ return addCors(Response.json({ logs: installLogs.slice(-100), ttsRoot: TTS_ROOT2, bunPath: process.execPath }), req);
476913
477086
  }
476914
477087
  async function handleInstallLocalTTS(req, addCors) {
476915
477088
  if (installing) {
@@ -476920,7 +477093,7 @@ async function handleInstallLocalTTS(req, addCors) {
476920
477093
  }
476921
477094
  installing = true;
476922
477095
  installLogs = [`[${new Date().toISOString()}] Iniciando instalaci\xF3n de Piper...`];
476923
- installLogs.push(` TTS_ROOT: ${TTS_ROOT}`);
477096
+ installLogs.push(` TTS_ROOT: ${TTS_ROOT2}`);
476924
477097
  const origLog = console.log;
476925
477098
  const origWarn = console.warn;
476926
477099
  console.log = (...args) => {
@@ -476931,7 +477104,7 @@ async function handleInstallLocalTTS(req, addCors) {
476931
477104
  installLogs.push(`[warn] ${args.join(" ")}`);
476932
477105
  origWarn(...args);
476933
477106
  };
476934
- runInstall(TTS_ROOT).then(() => {
477107
+ runInstall(TTS_ROOT2).then(() => {
476935
477108
  installLogs.push(`[${new Date().toISOString()}] Instalaci\xF3n completada`);
476936
477109
  }).catch((err) => {
476937
477110
  installLogs.push(`[error] ${err instanceof Error ? err.message : String(err)}`);
@@ -476950,48 +477123,27 @@ async function handleStartLocalTTS(req, addCors) {
476950
477123
  if (!isInstalled().installed) {
476951
477124
  return addCors(Response.json({ started: false, reason: "Piper no est\xE1 instalado. Inst\xE1lalo primero." }, { status: 400 }), req);
476952
477125
  }
476953
- const serverScript = join19(TTS_ROOT, "src", "server.ts");
476954
- ttsProcess = Bun.spawn([process.execPath, serverScript], {
476955
- stdout: "pipe",
476956
- stderr: "pipe",
476957
- env: { ...process.env, TTS_PORT: String(TTS_PORT) },
476958
- cwd: TTS_ROOT
476959
- });
476960
- (async () => {
476961
- const reader = ttsProcess.stderr.getReader();
476962
- const decoder = new TextDecoder;
476963
- while (true) {
476964
- const { done, value } = await reader.read();
476965
- if (done)
476966
- break;
476967
- const line = decoder.decode(value).trim();
476968
- if (line) {
476969
- installLogs.push(`[tts-server] ${line}`);
476970
- console.error(`[tts-server] ${line}`);
476971
- }
476972
- }
476973
- })();
477126
+ try {
477127
+ ttsServer = startTTSServer({ port: TTS_PORT });
477128
+ installLogs.push(`[tts-server] Servidor TTS iniciado en puerto ${TTS_PORT}`);
477129
+ } catch (err) {
477130
+ const msg = err instanceof Error ? err.message : String(err);
477131
+ console.error(`[tts-server] Fall\xF3 al iniciar: ${msg}`);
477132
+ installLogs.push(`[error] Servidor TTS fall\xF3 al iniciar: ${msg}`);
477133
+ return addCors(Response.json({ started: false, reason: msg }), req);
477134
+ }
476974
477135
  for (let i3 = 0;i3 < 6; i3++) {
476975
477136
  await Bun.sleep(500);
476976
477137
  if (await isRunning())
476977
477138
  break;
476978
477139
  }
476979
477140
  const running = await isRunning();
476980
- if (!running) {
476981
- const exitCode = await ttsProcess.exited;
476982
- console.error(`[tts-server] Fall\xF3 al iniciar, exit code: ${exitCode}`);
476983
- installLogs.push(`[error] Servidor TTS fall\xF3 al iniciar (c\xF3digo ${exitCode})`);
476984
- }
476985
477141
  return addCors(Response.json({ started: running }), req);
476986
477142
  }
476987
477143
  async function handleStopLocalTTS(req, addCors) {
476988
- if (ttsProcess) {
476989
- ttsProcess.kill();
476990
- ttsProcess = null;
476991
- } else {
476992
- try {
476993
- Bun.spawn(["pkill", "-f", "tts/src/server.ts"]);
476994
- } catch {}
477144
+ if (ttsServer) {
477145
+ ttsServer.stop(true);
477146
+ ttsServer = null;
476995
477147
  }
476996
477148
  return addCors(Response.json({ stopped: true }), req);
476997
477149
  }
@@ -477000,15 +477152,11 @@ async function ensureTTSRunning() {
477000
477152
  return true;
477001
477153
  if (!isInstalled().installed)
477002
477154
  return false;
477003
- const serverScript = join19(TTS_ROOT, "src", "server.ts");
477004
- if (!existsSync26(serverScript))
477155
+ try {
477156
+ ttsServer = startTTSServer({ port: TTS_PORT });
477157
+ } catch {
477005
477158
  return false;
477006
- ttsProcess = Bun.spawn([process.execPath, serverScript], {
477007
- stdout: "pipe",
477008
- stderr: "pipe",
477009
- env: { ...process.env, TTS_PORT: String(TTS_PORT) },
477010
- cwd: TTS_ROOT
477011
- });
477159
+ }
477012
477160
  for (let i3 = 0;i3 < 10; i3++) {
477013
477161
  await Bun.sleep(500);
477014
477162
  if (await isRunning())
@@ -477065,10 +477213,10 @@ async function handleGetInstalledVoices(req, addCors) {
477065
477213
  const voices = getInstalledVoices().map((id) => {
477066
477214
  const model = getModelById(id);
477067
477215
  let inferenceConfig = { length_scale: 1, noise_scale: 0.667, noise_w: 0.8 };
477068
- const configPath = join19(VOICES_DIR, `${id}.onnx.json`);
477069
- if (existsSync26(configPath)) {
477216
+ const configPath = join20(VOICES_DIR2, `${id}.onnx.json`);
477217
+ if (existsSync27(configPath)) {
477070
477218
  try {
477071
- const config2 = JSON.parse(readFileSync12(configPath, "utf-8"));
477219
+ const config2 = JSON.parse(readFileSync13(configPath, "utf-8"));
477072
477220
  inferenceConfig = { ...inferenceConfig, ...config2.inference };
477073
477221
  } catch {}
477074
477222
  }
@@ -477110,8 +477258,8 @@ async function handleDownloadModel(req, addCors) {
477110
477258
  downloadLogs = [`[${new Date().toISOString()}] Iniciando descarga de ${model.name}...`];
477111
477259
  (async () => {
477112
477260
  try {
477113
- const modelDest = join19(VOICES_DIR, `${modelId}.onnx`);
477114
- const configDest = join19(VOICES_DIR, `${modelId}.onnx.json`);
477261
+ const modelDest = join20(VOICES_DIR2, `${modelId}.onnx`);
477262
+ const configDest = join20(VOICES_DIR2, `${modelId}.onnx.json`);
477115
477263
  downloadLogs.push(` Descargando modelo: ${model.size}`);
477116
477264
  downloadLogs.push(` URL: ${model.modelUrl}`);
477117
477265
  const modelRes = await fetch(model.modelUrl);
@@ -477146,13 +477294,14 @@ async function handleGetDownloadLogs(req, addCors) {
477146
477294
  currentModelId: downloadingModelId
477147
477295
  }), req);
477148
477296
  }
477149
- var TTS_ROOT, BIN_PATH, VOICES_DIR, TTS_PORT, ttsProcess = null, installing = false, installLogs, downloadingModelId = null, downloadLogs;
477297
+ var TTS_ROOT2, BIN_PATH, VOICES_DIR2, TTS_PORT, ttsServer = null, installing = false, installLogs, downloadingModelId = null, downloadLogs;
477150
477298
  var init_tts_local = __esm(() => {
477151
477299
  init_models5();
477152
477300
  init_install();
477153
- TTS_ROOT = process.env.HIVE_TTS_ROOT ?? join19(process.env.HIVE_HOME ?? join19(homedir3(), ".hive"), "tts");
477154
- BIN_PATH = join19(TTS_ROOT, "bin", process.platform === "win32" ? "piper.exe" : "piper");
477155
- VOICES_DIR = join19(TTS_ROOT, "voices");
477301
+ init_server();
477302
+ TTS_ROOT2 = process.env.HIVE_TTS_ROOT ?? join20(process.env.HIVE_HOME ?? join20(homedir4(), ".hive"), "tts");
477303
+ BIN_PATH = join20(TTS_ROOT2, "bin", process.platform === "win32" ? "piper.exe" : "piper");
477304
+ VOICES_DIR2 = join20(TTS_ROOT2, "voices");
477156
477305
  TTS_PORT = Number(process.env.TTS_PORT ?? 5500);
477157
477306
  installLogs = [];
477158
477307
  downloadLogs = [];
@@ -477168,10 +477317,10 @@ async function handleCreateMeeting(req, addCorsHeaders) {
477168
477317
  const result = db.query(`INSERT INTO meeting_sessions (title, stt_model)
477169
477318
  VALUES (?, ?)
477170
477319
  RETURNING id, title, status, stt_model, started_at`).get(title, sttModel);
477171
- log77.info(`Meeting session created: ${result.id}`);
477320
+ log78.info(`Meeting session created: ${result.id}`);
477172
477321
  return addCorsHeaders(Response.json({ ok: true, session: result }), req);
477173
477322
  } catch (error54) {
477174
- log77.error(`handleCreateMeeting: ${error54.message}`);
477323
+ log78.error(`handleCreateMeeting: ${error54.message}`);
477175
477324
  return addCorsHeaders(Response.json({ ok: false, error: error54.message }, { status: 500 }), req);
477176
477325
  }
477177
477326
  }
@@ -477186,7 +477335,7 @@ async function handleListMeetings(req, addCorsHeaders) {
477186
477335
  LIMIT 50`).all();
477187
477336
  return addCorsHeaders(Response.json({ ok: true, sessions }), req);
477188
477337
  } catch (error54) {
477189
- log77.error(`handleListMeetings: ${error54.message}`);
477338
+ log78.error(`handleListMeetings: ${error54.message}`);
477190
477339
  return addCorsHeaders(Response.json({ ok: false, error: error54.message }, { status: 500 }), req);
477191
477340
  }
477192
477341
  }
@@ -477201,7 +477350,7 @@ async function handleGetMeeting(req, addCorsHeaders, sessionId) {
477201
477350
  WHERE session_id = ? ORDER BY seq ASC`).all(sessionId);
477202
477351
  return addCorsHeaders(Response.json({ ok: true, session, segments }), req);
477203
477352
  } catch (error54) {
477204
- log77.error(`handleGetMeeting: ${error54.message}`);
477353
+ log78.error(`handleGetMeeting: ${error54.message}`);
477205
477354
  return addCorsHeaders(Response.json({ ok: false, error: error54.message }, { status: 500 }), req);
477206
477355
  }
477207
477356
  }
@@ -477229,7 +477378,7 @@ async function handleAddMeetingSegment(req, addCorsHeaders, sessionId) {
477229
477378
  db.query(`INSERT INTO meeting_segments (session_id, seq, speaker, text) VALUES (?, ?, ?, ?)`).run(sessionId, seq, speaker, transcription);
477230
477379
  return addCorsHeaders(Response.json({ ok: true, seq, speaker, text: transcription }), req);
477231
477380
  } catch (error54) {
477232
- log77.error(`handleAddMeetingSegment: ${error54.message}`);
477381
+ log78.error(`handleAddMeetingSegment: ${error54.message}`);
477233
477382
  return addCorsHeaders(Response.json({ ok: false, error: error54.message }, { status: 500 }), req);
477234
477383
  }
477235
477384
  }
@@ -477246,7 +477395,7 @@ async function handleStopMeeting(req, addCorsHeaders, sessionId) {
477246
477395
  }
477247
477396
  db.query(`UPDATE meeting_sessions SET status = 'stopped', stopped_at = unixepoch() WHERE id = ?`).run(sessionId);
477248
477397
  const countResult = db.query(`SELECT COUNT(*) as count FROM meeting_segments WHERE session_id = ?`).get(sessionId);
477249
- log77.info(`Meeting stopped: ${sessionId} \u2014 ${countResult.count} segments`);
477398
+ log78.info(`Meeting stopped: ${sessionId} \u2014 ${countResult.count} segments`);
477250
477399
  return addCorsHeaders(Response.json({
477251
477400
  ok: true,
477252
477401
  session_id: sessionId,
@@ -477254,16 +477403,16 @@ async function handleStopMeeting(req, addCorsHeaders, sessionId) {
477254
477403
  segment_count: countResult.count
477255
477404
  }), req);
477256
477405
  } catch (error54) {
477257
- log77.error(`handleStopMeeting: ${error54.message}`);
477406
+ log78.error(`handleStopMeeting: ${error54.message}`);
477258
477407
  return addCorsHeaders(Response.json({ ok: false, error: error54.message }, { status: 500 }), req);
477259
477408
  }
477260
477409
  }
477261
- var log77;
477410
+ var log78;
477262
477411
  var init_meeting2 = __esm(() => {
477263
477412
  init_sqlite();
477264
477413
  init_voice();
477265
477414
  init_logger();
477266
- log77 = logger.child("meeting-routes");
477415
+ log78 = logger.child("meeting-routes");
477267
477416
  });
477268
477417
 
477269
477418
  // package.json
@@ -477271,7 +477420,7 @@ var package_default;
477271
477420
  var init_package = __esm(() => {
477272
477421
  package_default = {
477273
477422
  name: "@johpaz/hive-agents",
477274
- version: "0.0.31",
477423
+ version: "0.0.32",
477275
477424
  description: "Tu colmena de agentes IA. Local-first. Multi-canal. Open source. Construido desde Colombia para el mundo.",
477276
477425
  private: false,
477277
477426
  bin: {
@@ -477768,7 +477917,7 @@ async function handleChat(req, addCorsHeaders) {
477768
477917
  const finalUserId = userId || resolveUserId({ channel }) || "default";
477769
477918
  const finalAgentId = agentId || resolveAgentId(null) || "main";
477770
477919
  const threadId = thread_id || `${finalUserId}-${Date.now()}`;
477771
- log78.info(`[chat] Processing message from user=${finalUserId} agent=${finalAgentId} thread=${threadId}`);
477920
+ log79.info(`[chat] Processing message from user=${finalUserId} agent=${finalAgentId} thread=${threadId}`);
477772
477921
  const userRow = db.query("SELECT timezone FROM users WHERE id = ?").get(finalUserId);
477773
477922
  const userTimezone = userRow?.timezone || "UTC";
477774
477923
  const now = new Date;
@@ -477801,7 +477950,7 @@ ${message}`;
477801
477950
  if (signal2.aborted)
477802
477951
  return;
477803
477952
  try {
477804
- log78.info(`[chat] Generating response for thread ${threadId}...`);
477953
+ log79.info(`[chat] Generating response for thread ${threadId}...`);
477805
477954
  const response = await runner.generate({
477806
477955
  provider,
477807
477956
  messages: messages2,
@@ -477813,17 +477962,17 @@ ${message}`;
477813
477962
  channel,
477814
477963
  onStep: async (step) => {
477815
477964
  if (step.type === "text" && step.message) {
477816
- log78.debug(`[chat] Step: ${step.message.substring(0, 100)}`);
477965
+ log79.debug(`[chat] Step: ${step.message.substring(0, 100)}`);
477817
477966
  }
477818
477967
  if (step.type === "tool_result" && step.message) {
477819
- log78.debug(`[chat] Tool result: ${step.message.substring(0, 100)}`);
477968
+ log79.debug(`[chat] Tool result: ${step.message.substring(0, 100)}`);
477820
477969
  }
477821
477970
  }
477822
477971
  });
477823
477972
  responseContent = response.content?.trim() || "Task completed.";
477824
- log78.info(`[chat] Response generated: ${responseContent.substring(0, 100)}...`);
477973
+ log79.info(`[chat] Response generated: ${responseContent.substring(0, 100)}...`);
477825
477974
  } catch (error54) {
477826
- log78.error(`[chat] Error for thread ${threadId}: ${error54.message}`);
477975
+ log79.error(`[chat] Error for thread ${threadId}: ${error54.message}`);
477827
477976
  responseError = error54.message;
477828
477977
  }
477829
477978
  });
@@ -477852,7 +478001,7 @@ ${message}`;
477852
478001
  content: responseContent
477853
478002
  }), req);
477854
478003
  } catch (error54) {
477855
- log78.error(`[chat] Handler error: ${error54.message}`);
478004
+ log79.error(`[chat] Handler error: ${error54.message}`);
477856
478005
  return addCorsHeaders(Response.json({
477857
478006
  success: false,
477858
478007
  error: error54.message,
@@ -477881,7 +478030,7 @@ async function handleGetNotes(req, addCorsHeaders) {
477881
478030
  `).all();
477882
478031
  return addCorsHeaders(Response.json({ notes }), req);
477883
478032
  }
477884
- var log78;
478033
+ var log79;
477885
478034
  var init_chat3 = __esm(() => {
477886
478035
  init_sqlite();
477887
478036
  init_onboarding();
@@ -477889,7 +478038,7 @@ var init_chat3 = __esm(() => {
477889
478038
  init_conversation_store();
477890
478039
  init_providers3();
477891
478040
  init_logger();
477892
- log78 = logger.child("api:chat");
478041
+ log79 = logger.child("api:chat");
477893
478042
  });
477894
478043
 
477895
478044
  // packages/core/src/gateway/helpers/redact.ts
@@ -477945,7 +478094,7 @@ async function handleGetConfig(req, addCorsHeaders, config2) {
477945
478094
  var init_config = () => {};
477946
478095
 
477947
478096
  // packages/core/src/gateway/routes/workspace.ts
477948
- import { mkdirSync as mkdirSync16, existsSync as existsSync27, accessSync, constants as constants2 } from "fs";
478097
+ import { mkdirSync as mkdirSync16, existsSync as existsSync28, accessSync, constants as constants2 } from "fs";
477949
478098
  import * as path28 from "path";
477950
478099
  import { exec as exec2 } from "child_process";
477951
478100
  import { promisify as promisify4 } from "util";
@@ -477971,7 +478120,7 @@ async function handleValidateWorkspace(req, addCorsHeaders) {
477971
478120
  isAbsolute: false
477972
478121
  }), req);
477973
478122
  }
477974
- const exists = existsSync27(workspacePath);
478123
+ const exists = existsSync28(workspacePath);
477975
478124
  if (!exists) {
477976
478125
  return addCorsHeaders(Response.json({
477977
478126
  ok: true,
@@ -478053,7 +478202,7 @@ async function handleOpenWorkspace(req, addCorsHeaders) {
478053
478202
  error: "El path debe ser absoluto"
478054
478203
  }), req);
478055
478204
  }
478056
- if (!existsSync27(workspacePath)) {
478205
+ if (!existsSync28(workspacePath)) {
478057
478206
  return addCorsHeaders(Response.json({
478058
478207
  ok: false,
478059
478208
  error: "El directorio no existe"
@@ -478212,7 +478361,7 @@ var init_helpers = __esm(() => {
478212
478361
  });
478213
478362
 
478214
478363
  // packages/core/src/gateway/server.ts
478215
- import { mkdirSync as mkdirSync17, unlinkSync as unlinkSync4, existsSync as existsSync28, writeFileSync as writeFileSync11, readFileSync as readFileSync13 } from "fs";
478364
+ import { mkdirSync as mkdirSync17, unlinkSync as unlinkSync4, existsSync as existsSync29, writeFileSync as writeFileSync11, readFileSync as readFileSync14 } from "fs";
478216
478365
  import * as path30 from "path";
478217
478366
  import { cpus as osCpus } from "os";
478218
478367
  import { randomUUID as randomUUID2 } from "crypto";
@@ -478224,23 +478373,23 @@ async function startGateway(config2) {
478224
478373
  const numCores = osCpus().length || 1;
478225
478374
  let lastCpuSample = process.cpuUsage();
478226
478375
  let lastCpuSampleTime = Date.now();
478227
- const log79 = logger.child("gateway");
478228
- log79.info(`Starting gateway on ${host}:${port}`);
478376
+ const log80 = logger.child("gateway");
478377
+ log80.info(`Starting gateway on ${host}:${port}`);
478229
478378
  const tokenFile = path30.join(getHiveDir(), ".auth_token");
478230
478379
  if (!process.env.HIVE_AUTH_TOKEN) {
478231
- if (existsSync28(tokenFile)) {
478232
- process.env.HIVE_AUTH_TOKEN = readFileSync13(tokenFile, "utf-8").trim();
478233
- log79.info("\uD83D\uDD11 Auth token loaded from persistent storage");
478380
+ if (existsSync29(tokenFile)) {
478381
+ process.env.HIVE_AUTH_TOKEN = readFileSync14(tokenFile, "utf-8").trim();
478382
+ log80.info("\uD83D\uDD11 Auth token loaded from persistent storage");
478234
478383
  } else {
478235
478384
  const generated = randomUUID2().replace(/-/g, "");
478236
478385
  process.env.HIVE_AUTH_TOKEN = generated;
478237
478386
  mkdirSync17(path30.dirname(tokenFile), { recursive: true });
478238
478387
  writeFileSync11(tokenFile, generated, { mode: 384 });
478239
- log79.info("\uD83D\uDD11 Auth token auto-generated and persisted");
478388
+ log80.info("\uD83D\uDD11 Auth token auto-generated and persisted");
478240
478389
  }
478241
478390
  } else {
478242
478391
  writeFileSync11(tokenFile, process.env.HIVE_AUTH_TOKEN, { mode: 384 });
478243
- log79.info("\uD83D\uDD11 Auth token loaded from environment variable");
478392
+ log80.info("\uD83D\uDD11 Auth token loaded from environment variable");
478244
478393
  }
478245
478394
  let agent;
478246
478395
  let runner;
@@ -478270,7 +478419,7 @@ async function startGateway(config2) {
478270
478419
  },
478271
478420
  websocket: { open() {}, message() {}, close() {} }
478272
478421
  });
478273
- log79.info(`Port ${port} bound (initializing gateway...)`);
478422
+ log80.info(`Port ${port} bound (initializing gateway...)`);
478274
478423
  try {
478275
478424
  const db = initializeDatabase();
478276
478425
  seedAllData();
@@ -478293,9 +478442,9 @@ async function startGateway(config2) {
478293
478442
  await channelManager.send(channel, sessionId, { content, type: "progress" });
478294
478443
  });
478295
478444
  if (gatewaySetupMode) {
478296
- log79.info("\uD83C\uDF89 Setup mode: gateway running \u2014 open http://localhost:" + port + "/setup to configure");
478445
+ log80.info("\uD83C\uDF89 Setup mode: gateway running \u2014 open http://localhost:" + port + "/setup to configure");
478297
478446
  } else {
478298
- log79.info("\u2705 Gateway initialization completed successfully");
478447
+ log80.info("\u2705 Gateway initialization completed successfully");
478299
478448
  try {
478300
478449
  const db = getDb();
478301
478450
  db.query(`
@@ -478309,21 +478458,21 @@ async function startGateway(config2) {
478309
478458
  setSchedulerInstance(scheduler);
478310
478459
  setSchedulerInstance2(scheduler);
478311
478460
  setSchedulerForCleanup(scheduler);
478312
- log79.info(`\uD83D\uDCC5 CronScheduler initialized with ${scheduler.getStatus().length} task(s)`);
478461
+ log80.info(`\uD83D\uDCC5 CronScheduler initialized with ${scheduler.getStatus().length} task(s)`);
478313
478462
  const dagScheduler = new DAGScheduler({ strategy: new ParallelStrategy, maxConcurrentWorkers: 2 });
478314
478463
  globalThis.__dagScheduler = dagScheduler;
478315
- log79.info("\uD83D\uDD00 DAGScheduler ready");
478464
+ log80.info("\uD83D\uDD00 DAGScheduler ready");
478316
478465
  } catch (err) {
478317
- log79.error(`\u274C CronScheduler initialization failed: ${err.message}`);
478466
+ log80.error(`\u274C CronScheduler initialization failed: ${err.message}`);
478318
478467
  }
478319
478468
  }
478320
478469
  } catch (error54) {
478321
- log79.error(`\u274C Gateway initialization failed: ${error54.message}`);
478322
- log79.error("Stack trace:", error54.stack);
478470
+ log80.error(`\u274C Gateway initialization failed: ${error54.message}`);
478471
+ log80.error("Stack trace:", error54.stack);
478323
478472
  process.exit(1);
478324
478473
  }
478325
478474
  if (host === "0.0.0.0" && config2.security?.warnOnInsecureConfig !== false) {
478326
- log79.warn("Gateway binding to 0.0.0.0 exposes server to all network interfaces!");
478475
+ log80.warn("Gateway binding to 0.0.0.0 exposes server to all network interfaces!");
478327
478476
  }
478328
478477
  function prepareTools(agentInstance, sessionId) {
478329
478478
  return;
@@ -478331,8 +478480,8 @@ async function startGateway(config2) {
478331
478480
  const watchers = [];
478332
478481
  if (!gatewaySetupMode)
478333
478482
  channelManager.onMessage(async (message) => {
478334
- log79.info(`\uD83D\uDCE5 Message from ${message.channel}:${message.accountId}`);
478335
- log79.info(` Session: ${message.sessionId}`);
478483
+ log80.info(`\uD83D\uDCE5 Message from ${message.channel}:${message.accountId}`);
478484
+ log80.info(` Session: ${message.sessionId}`);
478336
478485
  const voiceConfig = voiceService.getChannelVoiceConfig(message.channel);
478337
478486
  const visionConfig = multimodalService.getChannelVisionConfig(message.channel);
478338
478487
  let messageContent = message.content;
@@ -478341,9 +478490,9 @@ async function startGateway(config2) {
478341
478490
  let sttProviderUsed = null;
478342
478491
  let contentParts;
478343
478492
  if (voiceConfig.voiceEnabled && message.audio) {
478344
- log79.info(`\uD83C\uDF99\uFE0F Voice enabled, processing audio...`);
478493
+ log80.info(`\uD83C\uDF99\uFE0F Voice enabled, processing audio...`);
478345
478494
  if (!voiceConfig.sttProvider) {
478346
- log79.warn(`\u26A0\uFE0F STT provider not configured for channel ${message.channel}`);
478495
+ log80.warn(`\u26A0\uFE0F STT provider not configured for channel ${message.channel}`);
478347
478496
  await channelManager.send(message.channel, message.sessionId, {
478348
478497
  content: `\uD83C\uDF99\uFE0F Para usar notas de voz, necesitas configurar el proveedor STT en la configuraci\xF3n del canal. Ve a Configuraci\xF3n > Canales > [Tu canal] y configura "Prov. STT" (ej: groq-whisper o openai)`
478349
478498
  });
@@ -478353,7 +478502,7 @@ async function startGateway(config2) {
478353
478502
  const audioInput = voiceService.normalizeAudioFromChannel(message.channel, message.audio);
478354
478503
  sttProviderUsed = voiceConfig.sttProvider || "groq-whisper";
478355
478504
  messageContent = await voiceService.transcribe(audioInput, sttProviderUsed);
478356
- log79.info(`\uD83D\uDCDD Transcribed: ${messageContent.substring(0, 100)}...`);
478505
+ log80.info(`\uD83D\uDCDD Transcribed: ${messageContent.substring(0, 100)}...`);
478357
478506
  inputType = "audio_transcribed";
478358
478507
  preferAudioResponse = !!voiceConfig.ttsProvider;
478359
478508
  await channelManager.send(message.channel, message.sessionId, {
@@ -478361,7 +478510,7 @@ async function startGateway(config2) {
478361
478510
  type: "message"
478362
478511
  });
478363
478512
  } catch (error54) {
478364
- log79.error(`\u274C Transcription failed: ${error54.message}`);
478513
+ log80.error(`\u274C Transcription failed: ${error54.message}`);
478365
478514
  await channelManager.send(message.channel, message.sessionId, {
478366
478515
  content: `Error al transcribir audio: ${error54.message}`
478367
478516
  });
@@ -478369,7 +478518,7 @@ async function startGateway(config2) {
478369
478518
  }
478370
478519
  }
478371
478520
  if (message.image || message.document) {
478372
- log79.info(`\uD83D\uDDBC\uFE0F Multimodal content detected on channel ${message.channel}`);
478521
+ log80.info(`\uD83D\uDDBC\uFE0F Multimodal content detected on channel ${message.channel}`);
478373
478522
  if (message.image) {
478374
478523
  try {
478375
478524
  const imageInput = multimodalService.normalizeImageFromChannel(message.channel, message.image);
@@ -478379,20 +478528,20 @@ async function startGateway(config2) {
478379
478528
  if (visionConfig.visionEnabled && modelHasVision) {
478380
478529
  contentParts = await multimodalService.processImage(imageInput, visionConfig.visionModelId || undefined);
478381
478530
  inputType = "image";
478382
- log79.info(`\uD83D\uDDBC\uFE0F Image sent as vision ContentParts (model supports vision)`);
478531
+ log80.info(`\uD83D\uDDBC\uFE0F Image sent as vision ContentParts (model supports vision)`);
478383
478532
  } else {
478384
478533
  const ocrProvider = visionConfig.ocrProvider || "openai";
478385
- log79.info(`\uD83D\uDDBC\uFE0F Model lacks vision, using OCR via ${ocrProvider}...`);
478534
+ log80.info(`\uD83D\uDDBC\uFE0F Model lacks vision, using OCR via ${ocrProvider}...`);
478386
478535
  const ocrText = await multimodalService.ocrImage(imageInput, ocrProvider);
478387
478536
  messageContent = ocrText ? `[Imagen adjunta \u2014 contenido extra\xEDdo por OCR]
478388
478537
  ${ocrText}
478389
478538
 
478390
478539
  ${messageContent || ""}` : messageContent || "";
478391
478540
  inputType = "image";
478392
- log79.info(`\uD83D\uDDBC\uFE0F OCR result: ${ocrText.substring(0, 100)}...`);
478541
+ log80.info(`\uD83D\uDDBC\uFE0F OCR result: ${ocrText.substring(0, 100)}...`);
478393
478542
  }
478394
478543
  } catch (imgError) {
478395
- log79.error(`\u274C Image processing failed: ${imgError.message}`);
478544
+ log80.error(`\u274C Image processing failed: ${imgError.message}`);
478396
478545
  await channelManager.send(message.channel, message.sessionId, {
478397
478546
  content: `\u26A0\uFE0F Error al procesar la imagen: ${imgError.message}`
478398
478547
  });
@@ -478402,7 +478551,7 @@ ${messageContent || ""}` : messageContent || "";
478402
478551
  try {
478403
478552
  const docInput = multimodalService.normalizeDocumentFromChannel(message.channel, message.document);
478404
478553
  const ocrProvider = visionConfig.ocrProvider || "openai";
478405
- log79.info(`\uD83D\uDCC4 Document detected, extracting text via OCR (${ocrProvider})...`);
478554
+ log80.info(`\uD83D\uDCC4 Document detected, extracting text via OCR (${ocrProvider})...`);
478406
478555
  const docImage = {
478407
478556
  type: docInput.type,
478408
478557
  data: docInput.data,
@@ -478415,16 +478564,16 @@ ${ocrText}
478415
478564
 
478416
478565
  ${messageContent || ""}` : messageContent || "";
478417
478566
  inputType = "document";
478418
- log79.info(`\uD83D\uDCC4 Document OCR result: ${ocrText.substring(0, 100)}...`);
478567
+ log80.info(`\uD83D\uDCC4 Document OCR result: ${ocrText.substring(0, 100)}...`);
478419
478568
  } catch (docError) {
478420
- log79.error(`\u274C Document processing failed: ${docError.message}`);
478569
+ log80.error(`\u274C Document processing failed: ${docError.message}`);
478421
478570
  await channelManager.send(message.channel, message.sessionId, {
478422
478571
  content: `\u26A0\uFE0F Error al procesar el documento: ${docError.message}`
478423
478572
  });
478424
478573
  }
478425
478574
  }
478426
478575
  }
478427
- log79.info(` Content: ${messageContent.substring(0, 150)}${messageContent.length > 150 ? "..." : ""}`);
478576
+ log80.info(` Content: ${messageContent.substring(0, 150)}${messageContent.length > 150 ? "..." : ""}`);
478428
478577
  const { userId } = resolveContext({
478429
478578
  channel: message.channel,
478430
478579
  channelUserId: message.sessionId
@@ -478455,7 +478604,7 @@ ${messageContent || ""}` : messageContent || "";
478455
478604
  ${messageContent}`;
478456
478605
  const messages2 = contentParts ? [{ role: "user", content: [{ type: "text", text: messageContentWithTime }, ...contentParts] }] : [{ role: "user", content: messageContentWithTime }];
478457
478606
  try {
478458
- log79.info(`\uD83E\uDD16 Routing to agent loop...`);
478607
+ log80.info(`\uD83E\uDD16 Routing to agent loop...`);
478459
478608
  const response = await runner.generate({
478460
478609
  provider: dbProvider,
478461
478610
  messages: messages2,
@@ -478470,28 +478619,28 @@ ${messageContent}`;
478470
478619
  if (step.type === "text" && step.message) {
478471
478620
  const trimmedMessage = (typeof step.message === "string" ? step.message : "").trim();
478472
478621
  if (trimmedMessage) {
478473
- log79.debug(`[NARRATION] ${trimmedMessage.substring(0, 100)}`);
478622
+ log80.debug(`[NARRATION] ${trimmedMessage.substring(0, 100)}`);
478474
478623
  try {
478475
478624
  await channelManager.send(message.channel, routingSessionId, {
478476
478625
  content: trimmedMessage,
478477
478626
  type: "progress"
478478
478627
  });
478479
478628
  } catch (err) {
478480
- log79.warn(`[onStep] Narration send failed: ${err.message}`);
478629
+ log80.warn(`[onStep] Narration send failed: ${err.message}`);
478481
478630
  }
478482
478631
  }
478483
478632
  return;
478484
478633
  }
478485
478634
  if (step.type === "tool_call" && step.toolName) {
478486
478635
  const narration = getNarration(step.toolName);
478487
- log79.debug(`[TOOL] ${step.toolName} \u2192 "${narration}"`);
478636
+ log80.debug(`[TOOL] ${step.toolName} \u2192 "${narration}"`);
478488
478637
  try {
478489
478638
  await channelManager.send(message.channel, routingSessionId, {
478490
478639
  content: narration,
478491
478640
  type: "progress"
478492
478641
  });
478493
478642
  } catch (err) {
478494
- log79.warn(`[onStep] Tool narration send failed: ${err.message}`);
478643
+ log80.warn(`[onStep] Tool narration send failed: ${err.message}`);
478495
478644
  }
478496
478645
  return;
478497
478646
  }
@@ -478506,7 +478655,7 @@ ${messageContent}`;
478506
478655
  type: "progress"
478507
478656
  });
478508
478657
  } catch (err) {
478509
- log79.warn(`[onStep] Tool result send failed: ${err.message}`);
478658
+ log80.warn(`[onStep] Tool result send failed: ${err.message}`);
478510
478659
  }
478511
478660
  }
478512
478661
  } catch {}
@@ -478516,10 +478665,10 @@ ${messageContent}`;
478516
478665
  });
478517
478666
  const responseContent = response.content?.trim() || "";
478518
478667
  if (!responseContent) {
478519
- log79.warn(`\uD83D\uDCE4 LLM response: empty \u2014 skipping send`);
478668
+ log80.warn(`\uD83D\uDCE4 LLM response: empty \u2014 skipping send`);
478520
478669
  return;
478521
478670
  }
478522
- log79.info(`\uD83D\uDCE4 LLM response: ${responseContent.substring(0, 100)}${responseContent.length > 100 ? "..." : ""}`);
478671
+ log80.info(`\uD83D\uDCE4 LLM response: ${responseContent.substring(0, 100)}${responseContent.length > 100 ? "..." : ""}`);
478523
478672
  const shouldSpeak = preferAudioResponse;
478524
478673
  let responseType = "text";
478525
478674
  let ttsProviderUsed = null;
@@ -478527,7 +478676,7 @@ ${messageContent}`;
478527
478676
  if (responseContent) {
478528
478677
  if (shouldSpeak) {
478529
478678
  if (!voiceConfig.ttsProvider) {
478530
- log79.warn(`\u26A0\uFE0F TTS provider not configured, user requested audio`);
478679
+ log80.warn(`\u26A0\uFE0F TTS provider not configured, user requested audio`);
478531
478680
  await channelManager.send(message.channel, routingSessionId, {
478532
478681
  content: `${responseContent}
478533
478682
 
@@ -478535,7 +478684,7 @@ ${messageContent}`;
478535
478684
  });
478536
478685
  } else {
478537
478686
  try {
478538
- log79.info(`\uD83D\uDD0A TTS enabled, synthesizing audio...`);
478687
+ log80.info(`\uD83D\uDD0A TTS enabled, synthesizing audio...`);
478539
478688
  const audioOutput = await voiceService.speak(responseContent, voiceConfig.ttsProvider, voiceConfig.ttsVoiceId || undefined);
478540
478689
  ttsProviderUsed = voiceConfig.ttsProvider;
478541
478690
  ttsMimeType = audioOutput.mimeType;
@@ -478544,17 +478693,17 @@ ${messageContent}`;
478544
478693
  const channel = channelManager.getChannel(message.channel);
478545
478694
  if (channel?.sendAudio) {
478546
478695
  await channel.sendAudio(routingSessionId, audioOutput.data, audioOutput.mimeType);
478547
- log79.info(`\u2705 Audio sent to ${routingSessionId}`);
478696
+ log80.info(`\u2705 Audio sent to ${routingSessionId}`);
478548
478697
  } else {
478549
- log79.warn(`Channel ${message.channel} does not support audio, sending text`);
478698
+ log80.warn(`Channel ${message.channel} does not support audio, sending text`);
478550
478699
  await channelManager.send(message.channel, routingSessionId, { content: responseContent });
478551
478700
  }
478552
478701
  } catch (audioError) {
478553
- log79.error(`\u274C Audio send failed: ${audioError.message}, sending text instead`);
478702
+ log80.error(`\u274C Audio send failed: ${audioError.message}, sending text instead`);
478554
478703
  await channelManager.send(message.channel, routingSessionId, { content: responseContent });
478555
478704
  }
478556
478705
  } catch (ttsError) {
478557
- log79.error(`\u274C TTS failed: ${ttsError.message}, sending text instead`);
478706
+ log80.error(`\u274C TTS failed: ${ttsError.message}, sending text instead`);
478558
478707
  await channelManager.send(message.channel, routingSessionId, { content: responseContent });
478559
478708
  }
478560
478709
  }
@@ -478569,10 +478718,10 @@ ${messageContent}`;
478569
478718
  channel: message.channel
478570
478719
  };
478571
478720
  await channelManager.stopTyping(message.channel, routingSessionId);
478572
- log79.info(`\u2705 Response sent to ${routingSessionId} via ${message.channel}`);
478721
+ log80.info(`\u2705 Response sent to ${routingSessionId} via ${message.channel}`);
478573
478722
  } catch (error54) {
478574
478723
  await channelManager.stopTyping(message.channel, routingSessionId);
478575
- log79.error(`\u274C Error: ${error54.message} `);
478724
+ log80.error(`\u274C Error: ${error54.message} `);
478576
478725
  await channelManager.send(message.channel, routingSessionId, {
478577
478726
  content: `Error: ${error54.message} `
478578
478727
  });
@@ -478620,9 +478769,9 @@ ${messageContent}`;
478620
478769
  const method = req.method;
478621
478770
  const logRequest = (status, duration3) => {
478622
478771
  if (url2.pathname === "/health" || url2.pathname === "/health/") {
478623
- log79.debug(`${method} ${url2.pathname} - ${status} (${duration3}ms)`);
478772
+ log80.debug(`${method} ${url2.pathname} - ${status} (${duration3}ms)`);
478624
478773
  } else {
478625
- log79.info(`${method} ${url2.pathname} - ${status} (${duration3}ms)`);
478774
+ log80.info(`${method} ${url2.pathname} - ${status} (${duration3}ms)`);
478626
478775
  }
478627
478776
  };
478628
478777
  const handleRequest = async () => {
@@ -478700,7 +478849,7 @@ ${messageContent}`;
478700
478849
  if (isDev) {
478701
478850
  const uiDir2 = path30.join(process.cwd(), "packages/hive-ui/dist");
478702
478851
  const indexPath = path30.join(uiDir2, "index.html");
478703
- if (!existsSync28(indexPath)) {
478852
+ if (!existsSync29(indexPath)) {
478704
478853
  return new Response(`UI build not found. Please run: cd packages/hive-ui && bun run build
478705
478854
 
478706
478855
  ` + "Or use: bun run dev (from root) which builds automatically.", { status: 503, headers: { "Content-Type": "text/plain" } });
@@ -478740,7 +478889,7 @@ ${messageContent}`;
478740
478889
  const uiDirFromHive = path30.join(getHiveDir(), "ui");
478741
478890
  const uiDirFromDist = process.env.HIVE_DIST_DIR ? path30.join(process.env.HIVE_DIST_DIR, "ui") : null;
478742
478891
  const uiDirFromCwd = path30.join(process.cwd(), "packages/hive-ui/dist");
478743
- const uiDir = uiDirFromEnv || (existsSync28(path30.join(uiDirFromHive, "index.html")) ? uiDirFromHive : uiDirFromDist && existsSync28(path30.join(uiDirFromDist, "index.html")) ? uiDirFromDist : uiDirFromCwd);
478892
+ const uiDir = uiDirFromEnv || (existsSync29(path30.join(uiDirFromHive, "index.html")) ? uiDirFromHive : uiDirFromDist && existsSync29(path30.join(uiDirFromDist, "index.html")) ? uiDirFromDist : uiDirFromCwd);
478744
478893
  let subPath = url2.pathname;
478745
478894
  if (gatewaySetupMode && (subPath === "/" || subPath === "/ui" || subPath === "/ui/")) {
478746
478895
  const _publicBase = process.env.HIVE_PUBLIC_URL?.replace(/\/$/, "") ?? `http://${host === "0.0.0.0" ? "localhost" : host}:${port}`;
@@ -478786,7 +478935,7 @@ ${messageContent}`;
478786
478935
  return Response.redirect(`/ ui${tokenParam} `, 301);
478787
478936
  }
478788
478937
  if (!checkAuth(req, url2)) {
478789
- log79.warn(`[AUTH] Unauthorized request to ${url2.pathname} from ${req.headers.get("origin")} `);
478938
+ log80.warn(`[AUTH] Unauthorized request to ${url2.pathname} from ${req.headers.get("origin")} `);
478790
478939
  return addCorsHeaders(new Response("Unauthorized", { status: 401 }), req);
478791
478940
  }
478792
478941
  if (url2.pathname === "/api/setup/status" || url2.pathname === "/api/setup/status/") {
@@ -479006,7 +479155,7 @@ ${messageContent}`;
479006
479155
  return await handleApiReload(req, addCorsHeaders, agent);
479007
479156
  }
479008
479157
  if (url2.pathname === "/api/user/channels" && req.method === "POST") {
479009
- return await handleLinkUserChannel(req, addCorsHeaders, config2, log79);
479158
+ return await handleLinkUserChannel(req, addCorsHeaders, config2, log80);
479010
479159
  }
479011
479160
  if (url2.pathname === "/api/user/channels" && req.method === "GET") {
479012
479161
  return await handleGetUserChannels(req, addCorsHeaders, config2);
@@ -479136,16 +479285,16 @@ ${messageContent}`;
479136
479285
  if (active === undefined) {
479137
479286
  return addCorsHeaders(Response.json({ success: false, error: "Missing active field" }, { status: 400 }), req);
479138
479287
  }
479139
- log79.info(`[MCP] Toggle connection for ${mcpName}, active=${active}`);
479288
+ log80.info(`[MCP] Toggle connection for ${mcpName}, active=${active}`);
479140
479289
  getDb().query(`UPDATE mcp_servers SET active = ?, enabled = ? WHERE id = ? OR name = ?`).run(active ? 1 : 0, active ? 1 : 0, mcpName, mcpName);
479141
479290
  try {
479142
479291
  const mcp = agent?.getMCPManager() ?? null;
479143
479292
  if (mcp) {
479144
- log79.info(`[MCP] Manager found, connecting ${mcpName}...`);
479293
+ log80.info(`[MCP] Manager found, connecting ${mcpName}...`);
479145
479294
  if (active) {
479146
479295
  const server3 = getDb().query(`SELECT * FROM mcp_servers WHERE id = ? OR name = ?`).get(mcpName, mcpName);
479147
479296
  if (server3) {
479148
- log79.info(`[MCP] Server config: transport=${server3.transport}, url=${server3.url}`);
479297
+ log80.info(`[MCP] Server config: transport=${server3.transport}, url=${server3.url}`);
479149
479298
  const mcpServerConfig = {
479150
479299
  transport: server3.transport,
479151
479300
  command: server3.command,
@@ -479157,7 +479306,7 @@ ${messageContent}`;
479157
479306
  try {
479158
479307
  mcpServerConfig.headers = decryptConfig(server3.headers_encrypted, server3.headers_iv);
479159
479308
  } catch (e) {
479160
- log79.warn(`Failed to decrypt headers for ${mcpName}`);
479309
+ log80.warn(`Failed to decrypt headers for ${mcpName}`);
479161
479310
  }
479162
479311
  }
479163
479312
  const currentConfig = mcp.config || { servers: {} };
@@ -479167,22 +479316,22 @@ ${messageContent}`;
479167
479316
  ...currentConfig,
479168
479317
  servers: newServersConfig
479169
479318
  });
479170
- log79.info(`[MCP] Server registered in MCP Manager`);
479319
+ log80.info(`[MCP] Server registered in MCP Manager`);
479171
479320
  const tools = mcp.getServerTools(mcpName) || [];
479172
- log79.info(`[MCP] Connected! Tools: ${tools.length}`);
479321
+ log80.info(`[MCP] Connected! Tools: ${tools.length}`);
479173
479322
  getDb().query(`UPDATE mcp_servers SET status = ?, tools_count = ? WHERE id = ? OR name = ?`).run("connected", tools.length, mcpName, mcpName);
479174
479323
  } else {
479175
- log79.error(`[MCP] Server not found in DB: ${mcpName}`);
479324
+ log80.error(`[MCP] Server not found in DB: ${mcpName}`);
479176
479325
  }
479177
479326
  } else {
479178
479327
  await mcp.disconnectServer(mcpName);
479179
479328
  getDb().query(`UPDATE mcp_servers SET status = ? WHERE id = ? OR name = ?`).run("disconnected", mcpName, mcpName);
479180
479329
  }
479181
479330
  } else {
479182
- log79.error(`[MCP] No MCP Manager found`);
479331
+ log80.error(`[MCP] No MCP Manager found`);
479183
479332
  }
479184
479333
  } catch (error54) {
479185
- log79.error(`[MCP] Failed to connect ${mcpName}: ${error54.message}`);
479334
+ log80.error(`[MCP] Failed to connect ${mcpName}: ${error54.message}`);
479186
479335
  }
479187
479336
  return addCorsHeaders(Response.json({ success: true, active, message: active ? "Servidor MCP conectado" : "Servidor MCP desconectado" }), req);
479188
479337
  }
@@ -479209,7 +479358,7 @@ ${messageContent}`;
479209
479358
  if (active) {
479210
479359
  const server3 = getDb().query(`SELECT * FROM mcp_servers WHERE id = ? OR name = ?`).get(mcpName, mcpName);
479211
479360
  if (server3) {
479212
- log79.info(`[MCP] Server config: transport=${server3.transport}, url=${server3.url}`);
479361
+ log80.info(`[MCP] Server config: transport=${server3.transport}, url=${server3.url}`);
479213
479362
  const mcpServerConfig = {
479214
479363
  transport: server3.transport,
479215
479364
  command: server3.command,
@@ -479221,7 +479370,7 @@ ${messageContent}`;
479221
479370
  try {
479222
479371
  mcpServerConfig.headers = decryptConfig(server3.headers_encrypted, server3.headers_iv);
479223
479372
  } catch (e) {
479224
- log79.warn(`Failed to decrypt headers for ${mcpName}`);
479373
+ log80.warn(`Failed to decrypt headers for ${mcpName}`);
479225
479374
  }
479226
479375
  }
479227
479376
  const currentConfig = mcp.config || { servers: {} };
@@ -479231,12 +479380,12 @@ ${messageContent}`;
479231
479380
  ...currentConfig,
479232
479381
  servers: newServersConfig
479233
479382
  });
479234
- log79.info(`[MCP] Server registered in MCP Manager`);
479383
+ log80.info(`[MCP] Server registered in MCP Manager`);
479235
479384
  const tools = mcp.getServerTools(mcpName) || [];
479236
- log79.info(`[MCP] Connected! Tools: ${tools.length}`);
479385
+ log80.info(`[MCP] Connected! Tools: ${tools.length}`);
479237
479386
  getDb().query(`UPDATE mcp_servers SET status = ?, tools_count = ? WHERE id = ? OR name = ?`).run("connected", tools.length, mcpName, mcpName);
479238
479387
  } else {
479239
- log79.error(`[MCP] Server not found in DB: ${mcpName}`);
479388
+ log80.error(`[MCP] Server not found in DB: ${mcpName}`);
479240
479389
  }
479241
479390
  } else {
479242
479391
  await mcp.disconnectServer(mcpName);
@@ -479244,7 +479393,7 @@ ${messageContent}`;
479244
479393
  }
479245
479394
  }
479246
479395
  } catch (error54) {
479247
- log79.error(`[MCP] Failed to connect ${mcpName}: ${error54.message}`);
479396
+ log80.error(`[MCP] Failed to connect ${mcpName}: ${error54.message}`);
479248
479397
  }
479249
479398
  return addCorsHeaders(Response.json({ success: true, active, message: active ? "Servidor MCP conectado" : "Servidor MCP desconectado" }), req);
479250
479399
  }
@@ -479433,12 +479582,12 @@ ${messageContent}`;
479433
479582
  if (response) {
479434
479583
  logRequest(response.status, duration3);
479435
479584
  } else {
479436
- log79.info(`${method} ${url2.pathname} - 101 Switching Protocols(${duration3}ms)`);
479585
+ log80.info(`${method} ${url2.pathname} - 101 Switching Protocols(${duration3}ms)`);
479437
479586
  }
479438
479587
  return response;
479439
479588
  } catch (error54) {
479440
479589
  const duration3 = Date.now() - start;
479441
- log79.error(`${method} ${url2.pathname} - Internal Error(${duration3}ms): ${error54.message} `);
479590
+ log80.error(`${method} ${url2.pathname} - Internal Error(${duration3}ms): ${error54.message} `);
479442
479591
  return addCorsHeaders(Response.json({ success: false, error: error54.message, message: "Error interno del servidor" }, { status: 500 }), req);
479443
479592
  }
479444
479593
  },
@@ -479447,17 +479596,17 @@ ${messageContent}`;
479447
479596
  const data = ws.data;
479448
479597
  const isBridge = data.sessionId.startsWith("bridge:");
479449
479598
  if (isBridge) {
479450
- log79.info(`Bridge events client connected: ${data.sessionId}`);
479599
+ log80.info(`Bridge events client connected: ${data.sessionId}`);
479451
479600
  subscribeBridge(ws);
479452
479601
  ws.send(JSON.stringify({ type: "bridge:connected", sessionId: data.sessionId }));
479453
479602
  return;
479454
479603
  }
479455
479604
  if (data.sessionId.startsWith("meeting:")) {
479456
- log79.info(`Meeting stream client connected: ${data.sessionId}`);
479605
+ log80.info(`Meeting stream client connected: ${data.sessionId}`);
479457
479606
  ws.send(JSON.stringify({ type: "meeting:connected", sessionId: data.sessionId, meetingSessionId: data.meetingSessionId }));
479458
479607
  return;
479459
479608
  }
479460
- log79.debug(`WebSocket connected: ${data.sessionId} `);
479609
+ log80.debug(`WebSocket connected: ${data.sessionId} `);
479461
479610
  sessionManager.create(data.sessionId, ws);
479462
479611
  const channel = channelManager?.getChannel("webchat");
479463
479612
  if (channel?.registerConnection)
@@ -479488,7 +479637,7 @@ ${messageContent}`;
479488
479637
  codeBridge: codeBridge.map((cb) => cb.id)
479489
479638
  }));
479490
479639
  } catch (err) {
479491
- log79.error("Error sending welcome message:", err);
479640
+ log80.error("Error sending welcome message:", err);
479492
479641
  }
479493
479642
  },
479494
479643
  async message(ws, message) {
@@ -479585,7 +479734,7 @@ ${messageContent}`;
479585
479734
  const sourceComponentId = actionData.sourceComponentId ?? "unknown";
479586
479735
  const context = actionData.context ?? {};
479587
479736
  const interactionMsg = `[a2ui:action] surface=${surfaceId} action=${actionName} component=${sourceComponentId}${Object.keys(context).length > 0 ? ` context=${JSON.stringify(context)}` : ""}`;
479588
- log79.info(`A2UI action forwarded to agent: ${interactionMsg}`);
479737
+ log80.info(`A2UI action forwarded to agent: ${interactionMsg}`);
479589
479738
  const sessionId = data.sessionId;
479590
479739
  ws.send(JSON.stringify({ type: "typing", isTyping: true, sessionId }));
479591
479740
  laneQueue.enqueue(sessionId, async (_task, signal2) => {
@@ -479615,7 +479764,7 @@ ${messageContent}`;
479615
479764
  onStep: async (step) => {
479616
479765
  if (signal2.aborted)
479617
479766
  return;
479618
- log79.debug(`[a2ui:action TOOL] ${step.type}: ${step.toolName || ""}`);
479767
+ log80.debug(`[a2ui:action TOOL] ${step.type}: ${step.toolName || ""}`);
479619
479768
  }
479620
479769
  });
479621
479770
  ws.send(JSON.stringify({ type: "typing", isTyping: false, sessionId }));
@@ -479626,7 +479775,7 @@ ${messageContent}`;
479626
479775
  } catch (error54) {
479627
479776
  ws.send(JSON.stringify({ type: "typing", isTyping: false, sessionId }));
479628
479777
  ws.send(JSON.stringify({ type: "error", sessionId, error: error54.message }));
479629
- log79.error(`A2UI action agent error: ${error54.message}`);
479778
+ log80.error(`A2UI action agent error: ${error54.message}`);
479630
479779
  }
479631
479780
  });
479632
479781
  return;
@@ -479647,7 +479796,7 @@ ${messageContent}`;
479647
479796
  if (interactionData && Object.keys(interactionData).length > 0) {
479648
479797
  interactionMsg += `, data=${JSON.stringify(interactionData)}`;
479649
479798
  }
479650
- log79.info(`Canvas interaction forwarded to agent: ${interactionMsg}`);
479799
+ log80.info(`Canvas interaction forwarded to agent: ${interactionMsg}`);
479651
479800
  const sessionId = data.sessionId;
479652
479801
  ws.send(JSON.stringify({ type: "typing", isTyping: true, sessionId }));
479653
479802
  laneQueue.enqueue(sessionId, async (_task, signal2) => {
@@ -479677,7 +479826,7 @@ ${messageContent}`;
479677
479826
  onStep: async (step) => {
479678
479827
  if (signal2.aborted)
479679
479828
  return;
479680
- log79.debug(`[canvas:interact TOOL] ${step.type}: ${step.toolName || ""}`);
479829
+ log80.debug(`[canvas:interact TOOL] ${step.type}: ${step.toolName || ""}`);
479681
479830
  }
479682
479831
  });
479683
479832
  ws.send(JSON.stringify({ type: "typing", isTyping: false, sessionId }));
@@ -479688,7 +479837,7 @@ ${messageContent}`;
479688
479837
  } catch (error54) {
479689
479838
  ws.send(JSON.stringify({ type: "typing", isTyping: false, sessionId }));
479690
479839
  ws.send(JSON.stringify({ type: "error", sessionId, error: error54.message }));
479691
- log79.error(`Canvas interact agent error: ${error54.message}`);
479840
+ log80.error(`Canvas interact agent error: ${error54.message}`);
479692
479841
  }
479693
479842
  });
479694
479843
  }
@@ -479703,17 +479852,17 @@ ${messageContent}`;
479703
479852
  }
479704
479853
  if (msg.type === "logs_subscribe") {
479705
479854
  logSubscribers.add(data.sessionId);
479706
- log79.debug(`Session ${data.sessionId} subscribed to logs`);
479855
+ log80.debug(`Session ${data.sessionId} subscribed to logs`);
479707
479856
  return;
479708
479857
  }
479709
479858
  if (msg.type === "logs_unsubscribe") {
479710
479859
  logSubscribers.delete(data.sessionId);
479711
- log79.debug(`Session ${data.sessionId} unsubscribed from logs`);
479860
+ log80.debug(`Session ${data.sessionId} unsubscribed from logs`);
479712
479861
  return;
479713
479862
  }
479714
479863
  if (msg.type === "stop") {
479715
479864
  const cancelled = laneQueue.cancel(msg.sessionId);
479716
- log79.info(`[stop] Session ${msg.sessionId} \u2014 cancelled: ${cancelled}`);
479865
+ log80.info(`[stop] Session ${msg.sessionId} \u2014 cancelled: ${cancelled}`);
479717
479866
  ws.send(JSON.stringify({
479718
479867
  type: "typing",
479719
479868
  isTyping: false,
@@ -479730,7 +479879,7 @@ ${messageContent}`;
479730
479879
  }
479731
479880
  let webchatPreferAudio = false;
479732
479881
  if (msg.type === "audio" && msg.audio) {
479733
- log79.info(`WebChat audio from session ${msg.sessionId}`);
479882
+ log80.info(`WebChat audio from session ${msg.sessionId}`);
479734
479883
  const voiceConfig = voiceService.getChannelVoiceConfig("webchat");
479735
479884
  if (!voiceConfig.voiceEnabled) {
479736
479885
  ws.send(JSON.stringify({
@@ -479757,7 +479906,7 @@ ${messageContent}`;
479757
479906
  const audioInput = { type: "base64", data: msg.audio, mimeType: "audio/webm" };
479758
479907
  const sttProvider = voiceConfig.sttProvider || "groq-whisper";
479759
479908
  const messageContent = await voiceService.transcribe(audioInput, sttProvider);
479760
- log79.info(`\uD83D\uDCDD Transcribed: ${messageContent.substring(0, 100)}...`);
479909
+ log80.info(`\uD83D\uDCDD Transcribed: ${messageContent.substring(0, 100)}...`);
479761
479910
  webchatPreferAudio = true;
479762
479911
  ws.send(JSON.stringify({
479763
479912
  type: "message",
@@ -479778,7 +479927,7 @@ ${messageContent}`;
479778
479927
  try {
479779
479928
  const unifiedSessionId = msg.sessionId;
479780
479929
  const messages2 = [{ role: "user", content: messageContent }];
479781
- log79.info(`Generating response for session ${unifiedSessionId}...`);
479930
+ log80.info(`Generating response for session ${unifiedSessionId}...`);
479782
479931
  const { userId } = resolveContext({
479783
479932
  channel: "webchat",
479784
479933
  channelUserId: msg.sessionId
@@ -479848,7 +479997,7 @@ ${messageContent}`;
479848
479997
  }
479849
479998
  });
479850
479999
  const content = streamedContent || response.content?.trim() || "";
479851
- log79.info(`Response sent to session ${unifiedSessionId} (${content.length} chars)`);
480000
+ log80.info(`Response sent to session ${unifiedSessionId} (${content.length} chars)`);
479852
480001
  const voiceCfg = voiceService.getChannelVoiceConfig("webchat");
479853
480002
  const shouldSpeak = webchatPreferAudio;
479854
480003
  let responseType = "text";
@@ -479869,13 +480018,13 @@ ${messageContent}`;
479869
480018
  }));
479870
480019
  } else {
479871
480020
  try {
479872
- log79.info(`\uD83D\uDD0A TTS enabled, synthesizing audio for WebChat...`);
480021
+ log80.info(`\uD83D\uDD0A TTS enabled, synthesizing audio for WebChat...`);
479873
480022
  const audioOutput = await voiceService.speak(content, voiceCfg.ttsProvider, voiceCfg.ttsVoiceId || undefined);
479874
480023
  ttsProviderUsed = voiceCfg.ttsProvider;
479875
480024
  ttsMimeType = audioOutput.mimeType;
479876
480025
  responseType = "audio";
479877
480026
  const base64Audio = audioOutput.data.toString("base64");
479878
- log79.info(`Audio generated: ${base64Audio.length} bytes, mimeType: ${audioOutput.mimeType}`);
480027
+ log80.info(`Audio generated: ${base64Audio.length} bytes, mimeType: ${audioOutput.mimeType}`);
479879
480028
  ws.send(JSON.stringify({
479880
480029
  type: "message",
479881
480030
  sessionId: unifiedSessionId,
@@ -479885,7 +480034,7 @@ ${messageContent}`;
479885
480034
  isStep: false
479886
480035
  }));
479887
480036
  } catch (ttsError) {
479888
- log79.error(`TTS failed: ${ttsError.message}), sending text instead`);
480037
+ log80.error(`TTS failed: ${ttsError.message}), sending text instead`);
479889
480038
  ws.send(JSON.stringify({ type: "message", sessionId: unifiedSessionId, content, isStep: false }));
479890
480039
  }
479891
480040
  }
@@ -479894,10 +480043,10 @@ ${messageContent}`;
479894
480043
  }
479895
480044
  } else if (alreadyStreamed && shouldSpeak && voiceCfg.ttsProvider) {
479896
480045
  try {
479897
- log79.info(`\uD83D\uDD0A TTS enabled, synthesizing audio after streaming...`);
480046
+ log80.info(`\uD83D\uDD0A TTS enabled, synthesizing audio after streaming...`);
479898
480047
  const audioOutput = await voiceService.speak(content, voiceCfg.ttsProvider, voiceCfg.ttsVoiceId || undefined);
479899
480048
  const base64Audio = audioOutput.data.toString("base64");
479900
- log79.info(`Audio generated after streaming: ${base64Audio.length} bytes`);
480049
+ log80.info(`Audio generated after streaming: ${base64Audio.length} bytes`);
479901
480050
  ws.send(JSON.stringify({
479902
480051
  type: "message",
479903
480052
  sessionId: unifiedSessionId,
@@ -479907,7 +480056,7 @@ ${messageContent}`;
479907
480056
  isStep: false
479908
480057
  }));
479909
480058
  } catch (ttsError) {
479910
- log79.error(`TTS after streaming failed: ${ttsError.message}), skipping audio`);
480059
+ log80.error(`TTS after streaming failed: ${ttsError.message}), skipping audio`);
479911
480060
  }
479912
480061
  }
479913
480062
  } catch (error54) {
@@ -479917,7 +480066,7 @@ ${messageContent}`;
479917
480066
  sessionId: msg.sessionId,
479918
480067
  error: error54.message
479919
480068
  }));
479920
- log79.error(`Error for session ${msg.sessionId}: ${error54.message}`);
480069
+ log80.error(`Error for session ${msg.sessionId}: ${error54.message}`);
479921
480070
  }
479922
480071
  });
479923
480072
  } catch (error54) {
@@ -479935,7 +480084,7 @@ ${messageContent}`;
479935
480084
  return;
479936
480085
  }
479937
480086
  if (msg.type === "message" && msg.content) {
479938
- log79.info(`WebChat message from session ${msg.sessionId}: ${msg.content.substring(0, 100)}`);
480087
+ log80.info(`WebChat message from session ${msg.sessionId}: ${msg.content.substring(0, 100)}`);
479939
480088
  ws.send(JSON.stringify({
479940
480089
  type: "typing",
479941
480090
  isTyping: true,
@@ -479953,7 +480102,7 @@ ${messageContent}`;
479953
480102
  let contentParts = undefined;
479954
480103
  const visionConfig = multimodalService.getChannelVisionConfig("webchat");
479955
480104
  if (msg.image || msg.document) {
479956
- log79.info(`\uD83D\uDDBC\uFE0F Multimodal content detected from WebChat session ${unifiedSessionId}`);
480105
+ log80.info(`\uD83D\uDDBC\uFE0F Multimodal content detected from WebChat session ${unifiedSessionId}`);
479957
480106
  if (msg.image) {
479958
480107
  try {
479959
480108
  const imageInput = {
@@ -479967,25 +480116,25 @@ ${messageContent}`;
479967
480116
  const modelHasVision = activeModelId && activeProviderId ? multimodalService.modelSupportsVision(activeProviderId, activeModelId) : false;
479968
480117
  if (visionConfig.visionEnabled && modelHasVision) {
479969
480118
  contentParts = await multimodalService.processImage(imageInput, visionConfig.visionModelId || undefined);
479970
- log79.info(`\uD83D\uDDBC\uFE0F Image sent as vision ContentParts (model supports vision)`);
480119
+ log80.info(`\uD83D\uDDBC\uFE0F Image sent as vision ContentParts (model supports vision)`);
479971
480120
  } else {
479972
480121
  const ocrProvider = visionConfig.ocrProvider || (["openai", "gemini", "anthropic"].includes(dbProvider) ? dbProvider : "openai");
479973
- log79.info(`\uD83D\uDDBC\uFE0F Model lacks vision or vision disabled, using OCR via ${ocrProvider}...`);
480122
+ log80.info(`\uD83D\uDDBC\uFE0F Model lacks vision or vision disabled, using OCR via ${ocrProvider}...`);
479974
480123
  const ocrText = await multimodalService.ocrImage(imageInput, ocrProvider);
479975
480124
  finalMessageContent = ocrText ? `[Imagen adjunta \u2014 contenido extra\xEDdo por OCR]
479976
480125
  ${ocrText}
479977
480126
 
479978
480127
  ${finalMessageContent || ""}` : finalMessageContent || "";
479979
- log79.info(`\uD83D\uDDBC\uFE0F OCR result: ${ocrText.substring(0, 100)}...`);
480128
+ log80.info(`\uD83D\uDDBC\uFE0F OCR result: ${ocrText.substring(0, 100)}...`);
479980
480129
  }
479981
480130
  } catch (imgError) {
479982
- log79.error(`\u274C Image processing failed: ${imgError.message}`);
480131
+ log80.error(`\u274C Image processing failed: ${imgError.message}`);
479983
480132
  }
479984
480133
  }
479985
480134
  if (msg.document) {
479986
480135
  try {
479987
480136
  const ocrProvider = visionConfig.ocrProvider || (["openai", "gemini", "anthropic"].includes(dbProvider) ? dbProvider : "openai");
479988
- log79.info(`\uD83D\uDCC4 Document detected from WebChat, extracting text via OCR (${ocrProvider})...`);
480137
+ log80.info(`\uD83D\uDCC4 Document detected from WebChat, extracting text via OCR (${ocrProvider})...`);
479989
480138
  const docImage = {
479990
480139
  type: "base64",
479991
480140
  data: msg.document.base64,
@@ -479997,14 +480146,14 @@ ${finalMessageContent || ""}` : finalMessageContent || "";
479997
480146
  ${ocrText}
479998
480147
 
479999
480148
  ${finalMessageContent || ""}` : finalMessageContent || "";
480000
- log79.info(`\uD83D\uDCC4 Document OCR result: ${ocrText.substring(0, 100)}...`);
480149
+ log80.info(`\uD83D\uDCC4 Document OCR result: ${ocrText.substring(0, 100)}...`);
480001
480150
  } catch (docError) {
480002
- log79.error(`\u274C Document processing failed: ${docError.message}`);
480151
+ log80.error(`\u274C Document processing failed: ${docError.message}`);
480003
480152
  }
480004
480153
  }
480005
480154
  }
480006
480155
  const messages2 = contentParts ? [{ role: "user", content: contentParts }] : [{ role: "user", content: finalMessageContent }];
480007
- log79.info(`Generating response for session ${unifiedSessionId} (multimodal: ${!!(msg.image || msg.document)})...`);
480156
+ log80.info(`Generating response for session ${unifiedSessionId} (multimodal: ${!!(msg.image || msg.document)})...`);
480008
480157
  const { userId } = resolveContext({
480009
480158
  channel: "webchat",
480010
480159
  channelUserId: msg.sessionId
@@ -480075,7 +480224,7 @@ ${finalMessageContent || ""}` : finalMessageContent || "";
480075
480224
  }
480076
480225
  });
480077
480226
  const content = streamedContent || response.content?.trim() || "";
480078
- log79.info(`Response sent to session ${unifiedSessionId} (${content.length} chars)`);
480227
+ log80.info(`Response sent to session ${unifiedSessionId} (${content.length} chars)`);
480079
480228
  const voiceConfig = voiceService.getChannelVoiceConfig("webchat");
480080
480229
  const shouldSpeak = webchatPreferAudio;
480081
480230
  let responseType = "text";
@@ -480096,7 +480245,7 @@ ${finalMessageContent || ""}` : finalMessageContent || "";
480096
480245
  }));
480097
480246
  } else {
480098
480247
  try {
480099
- log79.info(`\uD83D\uDD0A TTS enabled, synthesizing audio for WebChat...`);
480248
+ log80.info(`\uD83D\uDD0A TTS enabled, synthesizing audio for WebChat...`);
480100
480249
  const audioOutput = await voiceService.speak(content, voiceConfig.ttsProvider, voiceConfig.ttsVoiceId || undefined);
480101
480250
  ttsProviderUsed = voiceConfig.ttsProvider;
480102
480251
  ttsMimeType = audioOutput.mimeType;
@@ -480111,7 +480260,7 @@ ${finalMessageContent || ""}` : finalMessageContent || "";
480111
480260
  isStep: false
480112
480261
  }));
480113
480262
  } catch (ttsError) {
480114
- log79.error(`TTS failed: ${ttsError.message}), sending text instead`);
480263
+ log80.error(`TTS failed: ${ttsError.message}), sending text instead`);
480115
480264
  ws.send(JSON.stringify({ type: "message", sessionId: unifiedSessionId, content, isStep: false }));
480116
480265
  }
480117
480266
  }
@@ -480120,10 +480269,10 @@ ${finalMessageContent || ""}` : finalMessageContent || "";
480120
480269
  }
480121
480270
  } else if (alreadyStreamed && shouldSpeak && voiceConfig.ttsProvider) {
480122
480271
  try {
480123
- log79.info(`\uD83D\uDD0A TTS enabled, synthesizing audio after streaming...`);
480272
+ log80.info(`\uD83D\uDD0A TTS enabled, synthesizing audio after streaming...`);
480124
480273
  const audioOutput = await voiceService.speak(content, voiceConfig.ttsProvider, voiceConfig.ttsVoiceId || undefined);
480125
480274
  const base64Audio = audioOutput.data.toString("base64");
480126
- log79.info(`Audio generated after streaming: ${base64Audio.length} bytes`);
480275
+ log80.info(`Audio generated after streaming: ${base64Audio.length} bytes`);
480127
480276
  ws.send(JSON.stringify({
480128
480277
  type: "message",
480129
480278
  sessionId: unifiedSessionId,
@@ -480133,7 +480282,7 @@ ${finalMessageContent || ""}` : finalMessageContent || "";
480133
480282
  isStep: false
480134
480283
  }));
480135
480284
  } catch (ttsError) {
480136
- log79.error(`TTS after streaming failed: ${ttsError.message}), skipping audio`);
480285
+ log80.error(`TTS after streaming failed: ${ttsError.message}), skipping audio`);
480137
480286
  }
480138
480287
  }
480139
480288
  } catch (error54) {
@@ -480144,7 +480293,7 @@ ${finalMessageContent || ""}` : finalMessageContent || "";
480144
480293
  sessionId: unifiedSessionId,
480145
480294
  error: error54.message
480146
480295
  }));
480147
- log79.error(`Error for session ${unifiedSessionId}: ${error54.message}`);
480296
+ log80.error(`Error for session ${unifiedSessionId}: ${error54.message}`);
480148
480297
  }
480149
480298
  });
480150
480299
  return;
@@ -480163,10 +480312,10 @@ ${finalMessageContent || ""}` : finalMessageContent || "";
480163
480312
  return;
480164
480313
  }
480165
480314
  if (data.sessionId.startsWith("meeting:")) {
480166
- log79.info(`Meeting stream client disconnected: ${data.sessionId}`);
480315
+ log80.info(`Meeting stream client disconnected: ${data.sessionId}`);
480167
480316
  return;
480168
480317
  }
480169
- log79.debug(`WebSocket disconnected: ${data.sessionId}`);
480318
+ log80.debug(`WebSocket disconnected: ${data.sessionId}`);
480170
480319
  logSubscribers.delete(data.sessionId);
480171
480320
  sessionManager.delete(data.sessionId);
480172
480321
  laneQueue.cancel(data.sessionId);
@@ -480199,28 +480348,28 @@ ${finalMessageContent || ""}` : finalMessageContent || "";
480199
480348
  }
480200
480349
  }
480201
480350
  });
480202
- log79.info(`Gateway started successfully`);
480351
+ log80.info(`Gateway started successfully`);
480203
480352
  const isGatewayChild = process.env.HIVE_GATEWAY_CHILD === "1";
480204
480353
  if (isDev) {
480205
480354
  const devUrl = gatewaySetupMode ? `http://localhost:${port}/setup` : `http://localhost:${port}`;
480206
- log79.info(`[gateway] UI: ${devUrl}`);
480207
- log79.info(`[gateway] API: http://${host}:${port}`);
480208
- log79.info(`[gateway] WebSocket: ws://${host}:${port}/ws`);
480209
- log79.info(`[gateway] Canvas: ws://${host}:${port}/canvas`);
480210
- log79.info(`[gateway] Modo: desarrollo`);
480355
+ log80.info(`[gateway] UI: ${devUrl}`);
480356
+ log80.info(`[gateway] API: http://${host}:${port}`);
480357
+ log80.info(`[gateway] WebSocket: ws://${host}:${port}/ws`);
480358
+ log80.info(`[gateway] Canvas: ws://${host}:${port}/canvas`);
480359
+ log80.info(`[gateway] Modo: desarrollo`);
480211
480360
  if (!isGatewayChild) {
480212
- log79.info(gatewaySetupMode ? `\uD83C\uDF89 Primer arranque \u2014 abriendo setup...` : `\uD83D\uDC1D Administra tu Hive aqu\xED: ${devUrl}`);
480361
+ log80.info(gatewaySetupMode ? `\uD83C\uDF89 Primer arranque \u2014 abriendo setup...` : `\uD83D\uDC1D Administra tu Hive aqu\xED: ${devUrl}`);
480213
480362
  }
480214
480363
  } else {
480215
480364
  const isSetupMode2 = gatewaySetupMode;
480216
480365
  const baseUrl = process.env.HIVE_PUBLIC_URL?.replace(/\/$/, "") ?? `http://${host}:${port}`;
480217
480366
  const uiUrl = isSetupMode2 ? `${baseUrl}/setup` : `${baseUrl}/ui`;
480218
- log79.info(`[gateway] UI: ${uiUrl}`);
480219
- log79.info(`[gateway] API: http://${host}:${port}`);
480220
- log79.info(`[gateway] WebSocket: ws://${host}:${port}/ws`);
480221
- log79.info(`[gateway] Canvas: ws://${host}:${port}/canvas`);
480367
+ log80.info(`[gateway] UI: ${uiUrl}`);
480368
+ log80.info(`[gateway] API: http://${host}:${port}`);
480369
+ log80.info(`[gateway] WebSocket: ws://${host}:${port}/ws`);
480370
+ log80.info(`[gateway] Canvas: ws://${host}:${port}/canvas`);
480222
480371
  if (!process.env.NO_BROWSER) {
480223
- log79.info(isSetupMode2 ? `\uD83C\uDF89 Primer arranque \u2014 abriendo wizard de configuraci\xF3n...` : `\uD83D\uDC1D Administra tu Hive aqu\xED: ${uiUrl}`);
480372
+ log80.info(isSetupMode2 ? `\uD83C\uDF89 Primer arranque \u2014 abriendo wizard de configuraci\xF3n...` : `\uD83D\uDC1D Administra tu Hive aqu\xED: ${uiUrl}`);
480224
480373
  try {
480225
480374
  const platform2 = process.platform;
480226
480375
  let shellCmd;
@@ -480240,59 +480389,59 @@ ${finalMessageContent || ""}` : finalMessageContent || "";
480240
480389
  });
480241
480390
  proc.unref();
480242
480391
  } catch (err) {
480243
- log79.warn(`Could not open browser: ${err.message}`);
480392
+ log80.warn(`Could not open browser: ${err.message}`);
480244
480393
  }
480245
480394
  }
480246
480395
  }
480247
480396
  if (!gatewaySetupMode)
480248
- log79.info(`Channels: ${channelManager.listChannels().map((c) => c.name).join(", ") || "none"}`);
480397
+ log80.info(`Channels: ${channelManager.listChannels().map((c) => c.name).join(", ") || "none"}`);
480249
480398
  process.on("SIGTERM", async () => {
480250
- log79.info("Received SIGTERM, shutting down gracefully...");
480399
+ log80.info("Received SIGTERM, shutting down gracefully...");
480251
480400
  watchers.forEach((close) => close());
480252
480401
  const mcp = agent?.getMCPManager();
480253
480402
  if (mcp) {
480254
- log79.info("Disconnecting MCP servers...");
480403
+ log80.info("Disconnecting MCP servers...");
480255
480404
  await mcp.disconnectAll().catch(() => {});
480256
480405
  }
480257
480406
  if (channelManager) {
480258
- log79.info("Stopping channels...");
480407
+ log80.info("Stopping channels...");
480259
480408
  await channelManager.stopAll();
480260
480409
  }
480261
480410
  try {
480262
480411
  const mod = await Promise.resolve().then(() => (init_browser_service(), exports_browser_service));
480263
480412
  mod.CDPClient.closeAll();
480264
- log79.info("Browser processes cleaned up");
480413
+ log80.info("Browser processes cleaned up");
480265
480414
  } catch {}
480266
480415
  try {
480267
480416
  canvasManager.clearAll();
480268
- log79.info("Canvas sessions cleaned up");
480417
+ log80.info("Canvas sessions cleaned up");
480269
480418
  } catch {}
480270
480419
  try {
480271
480420
  const { stopMCPHotReload: stopMCPHotReload2 } = await Promise.resolve().then(() => (init_hot_reload(), exports_hot_reload));
480272
480421
  stopMCPHotReload2();
480273
- log79.info("MCP hot-reload stopped");
480422
+ log80.info("MCP hot-reload stopped");
480274
480423
  } catch {}
480275
480424
  server.stop();
480276
480425
  try {
480277
480426
  unlinkSync4(pidFile);
480278
480427
  } catch {}
480279
- log79.info("Gateway shutdown complete");
480428
+ log80.info("Gateway shutdown complete");
480280
480429
  process.exit(0);
480281
480430
  });
480282
480431
  process.on("SIGHUP", async () => {
480283
- log79.info("Received SIGHUP, reloading configuration...");
480432
+ log80.info("Received SIGHUP, reloading configuration...");
480284
480433
  try {
480285
480434
  const newConfig = await loadConfig();
480286
480435
  await agent.updateConfig(newConfig);
480287
480436
  await agent.reload();
480288
- log79.info("Configuration reloaded successfully");
480437
+ log80.info("Configuration reloaded successfully");
480289
480438
  } catch (error54) {
480290
- log79.error(`Failed to reload configuration: ${error54.message}`);
480439
+ log80.error(`Failed to reload configuration: ${error54.message}`);
480291
480440
  }
480292
480441
  });
480293
480442
  }
480294
480443
  var _pkgVersion, logSubscribers;
480295
- var init_server = __esm(() => {
480444
+ var init_server2 = __esm(() => {
480296
480445
  init_loader();
480297
480446
  init_logger();
480298
480447
  init_session();
@@ -480343,7 +480492,7 @@ var init_server = __esm(() => {
480343
480492
  _pkgVersion = (() => {
480344
480493
  try {
480345
480494
  const pkgPath = path30.join(import.meta.dir, "../../../package.json");
480346
- return JSON.parse(readFileSync13(pkgPath, "utf-8")).version;
480495
+ return JSON.parse(readFileSync14(pkgPath, "utf-8")).version;
480347
480496
  } catch {
480348
480497
  return "0.0.27";
480349
480498
  }
@@ -480354,7 +480503,7 @@ var init_server = __esm(() => {
480354
480503
  // packages/core/src/gateway/index.ts
480355
480504
  var init_gateway = __esm(() => {
480356
480505
  init_loader();
480357
- init_server();
480506
+ init_server2();
480358
480507
  init_logger();
480359
480508
  });
480360
480509
 
@@ -481784,7 +481933,7 @@ var init_circuit_breaker = __esm(() => {
481784
481933
  circuitBreakerRegistry = new CircuitBreakerRegistry;
481785
481934
  });
481786
481935
  // packages/core/src/plugins/loader.ts
481787
- import { mkdirSync as mkdirSync18, readdirSync as readdirSync6, existsSync as existsSync29 } from "fs";
481936
+ import { mkdirSync as mkdirSync18, readdirSync as readdirSync7, existsSync as existsSync30 } from "fs";
481788
481937
  import * as path31 from "path";
481789
481938
 
481790
481939
  class PluginLoader {
@@ -481798,7 +481947,7 @@ class PluginLoader {
481798
481947
  log = logger.child("plugins");
481799
481948
  constructor(options2) {
481800
481949
  this.options = options2;
481801
- if (!existsSync29(options2.pluginDir)) {
481950
+ if (!existsSync30(options2.pluginDir)) {
481802
481951
  mkdirSync18(options2.pluginDir, { recursive: true });
481803
481952
  }
481804
481953
  }
@@ -481806,11 +481955,11 @@ class PluginLoader {
481806
481955
  const pluginDir = this.options.pluginDir;
481807
481956
  const discovered = [];
481808
481957
  try {
481809
- const entries = readdirSync6(pluginDir, { withFileTypes: true });
481958
+ const entries = readdirSync7(pluginDir, { withFileTypes: true });
481810
481959
  for (const entry of entries) {
481811
481960
  if (entry.isDirectory()) {
481812
481961
  const manifestPath = path31.join(pluginDir, entry.name, "manifest.json");
481813
- if (existsSync29(manifestPath)) {
481962
+ if (existsSync30(manifestPath)) {
481814
481963
  discovered.push(entry.name);
481815
481964
  }
481816
481965
  }
@@ -482105,7 +482254,7 @@ var init_src3 = __esm(() => {
482105
482254
  init_tools();
482106
482255
  init_retry();
482107
482256
  init_gateway();
482108
- init_server();
482257
+ init_server2();
482109
482258
  init_service();
482110
482259
  init_agent_loop();
482111
482260
  init_context_compiler();
@@ -482187,7 +482336,7 @@ var init_types6 = __esm(() => {
482187
482336
 
482188
482337
  // packages/cli/src/adapters/config.ts
482189
482338
  import * as path32 from "path";
482190
- import { existsSync as existsSync30, readFileSync as readFileSync14 } from "fs";
482339
+ import { existsSync as existsSync31, readFileSync as readFileSync15 } from "fs";
482191
482340
  function getHiveDir2(customDir) {
482192
482341
  if (customDir) {
482193
482342
  return path32.resolve(customDir);
@@ -482215,11 +482364,11 @@ function getDefaultPaths(hiveDir) {
482215
482364
  }
482216
482365
  function loadEnvFile(envPath) {
482217
482366
  const filePath = envPath || path32.join(process.cwd(), ".env");
482218
- if (!existsSync30(filePath)) {
482367
+ if (!existsSync31(filePath)) {
482219
482368
  return {};
482220
482369
  }
482221
482370
  try {
482222
- const content = readFileSync14(filePath, "utf-8");
482371
+ const content = readFileSync15(filePath, "utf-8");
482223
482372
  const env2 = {};
482224
482373
  for (const line of content.split(`
482225
482374
  `)) {
@@ -482287,7 +482436,7 @@ function getDistDir() {
482287
482436
  return dir;
482288
482437
  }
482289
482438
  const distPath = path32.join(dir, "dist");
482290
- if (existsSync30(distPath)) {
482439
+ if (existsSync31(distPath)) {
482291
482440
  return distPath;
482292
482441
  }
482293
482442
  return null;
@@ -482309,7 +482458,7 @@ __export(exports_docker, {
482309
482458
  });
482310
482459
  import { spawn as spawn3, execSync } from "child_process";
482311
482460
  import * as path33 from "path";
482312
- import { existsSync as existsSync31 } from "fs";
482461
+ import { existsSync as existsSync32 } from "fs";
482313
482462
 
482314
482463
  class DockerAdapter {
482315
482464
  type = "docker";
@@ -482329,7 +482478,7 @@ class DockerAdapter {
482329
482478
  path33.join(process.env.HOME || "", ".hive", "docker-compose.yml")
482330
482479
  ];
482331
482480
  for (const composePath of standardPaths) {
482332
- if (existsSync31(composePath)) {
482481
+ if (existsSync32(composePath)) {
482333
482482
  return composePath;
482334
482483
  }
482335
482484
  }
@@ -482339,7 +482488,7 @@ class DockerAdapter {
482339
482488
  try {
482340
482489
  execSync("docker --version", { stdio: "ignore" });
482341
482490
  execSync("docker compose version", { stdio: "ignore" });
482342
- if (!existsSync31(this.composeFile)) {
482491
+ if (!existsSync32(this.composeFile)) {
482343
482492
  return false;
482344
482493
  }
482345
482494
  try {
@@ -482470,7 +482619,7 @@ class DockerAdapter {
482470
482619
  } catch {
482471
482620
  errors6.push("Docker Compose is not installed");
482472
482621
  }
482473
- if (!existsSync31(this.composeFile)) {
482622
+ if (!existsSync32(this.composeFile)) {
482474
482623
  errors6.push(`docker-compose.yml not found at ${this.composeFile}`);
482475
482624
  } else {
482476
482625
  info3.push(`Compose file: ${this.composeFile}`);
@@ -482510,7 +482659,7 @@ var init_docker = __esm(() => {
482510
482659
  // packages/cli/src/adapters/bun-global.ts
482511
482660
  import { spawn as spawn4, execSync as execSync2 } from "child_process";
482512
482661
  import * as path34 from "path";
482513
- import { existsSync as existsSync32, readFileSync as readFileSync15, unlinkSync as unlinkSync5 } from "fs";
482662
+ import { existsSync as existsSync33, readFileSync as readFileSync16, unlinkSync as unlinkSync5 } from "fs";
482514
482663
 
482515
482664
  class BunGlobalAdapter {
482516
482665
  type = "bun-global";
@@ -482530,7 +482679,7 @@ class BunGlobalAdapter {
482530
482679
  stdio: ["ignore", "pipe", "ignore"]
482531
482680
  });
482532
482681
  const hivePath = output.trim();
482533
- if (hivePath && existsSync32(hivePath)) {
482682
+ if (hivePath && existsSync33(hivePath)) {
482534
482683
  return true;
482535
482684
  }
482536
482685
  } catch {
@@ -482558,13 +482707,13 @@ class BunGlobalAdapter {
482558
482707
  }).trim();
482559
482708
  const distDir = path34.dirname(hivePath);
482560
482709
  const potentialUiDir = path34.join(distDir, "ui");
482561
- if (existsSync32(potentialUiDir)) {
482710
+ if (existsSync33(potentialUiDir)) {
482562
482711
  uiDir = potentialUiDir;
482563
482712
  }
482564
482713
  } catch {}
482565
482714
  if (!uiDir) {
482566
482715
  const cwdUiDir = path34.join(process.cwd(), "packages/hive-ui/dist");
482567
- if (existsSync32(cwdUiDir)) {
482716
+ if (existsSync33(cwdUiDir)) {
482568
482717
  uiDir = cwdUiDir;
482569
482718
  }
482570
482719
  }
@@ -482615,8 +482764,8 @@ class BunGlobalAdapter {
482615
482764
  }
482616
482765
  async stop() {
482617
482766
  try {
482618
- if (existsSync32(this.pidFile)) {
482619
- const pid = parseInt(readFileSync15(this.pidFile, "utf-8").trim(), 10);
482767
+ if (existsSync33(this.pidFile)) {
482768
+ const pid = parseInt(readFileSync16(this.pidFile, "utf-8").trim(), 10);
482620
482769
  if (!isNaN(pid)) {
482621
482770
  try {
482622
482771
  process.kill(pid, "SIGTERM");
@@ -482648,8 +482797,8 @@ class BunGlobalAdapter {
482648
482797
  }
482649
482798
  async isRunning() {
482650
482799
  try {
482651
- if (existsSync32(this.pidFile)) {
482652
- const pid = parseInt(readFileSync15(this.pidFile, "utf-8").trim(), 10);
482800
+ if (existsSync33(this.pidFile)) {
482801
+ const pid = parseInt(readFileSync16(this.pidFile, "utf-8").trim(), 10);
482653
482802
  if (!isNaN(pid)) {
482654
482803
  try {
482655
482804
  process.kill(pid, 0);
@@ -482670,8 +482819,8 @@ class BunGlobalAdapter {
482670
482819
  }
482671
482820
  async getPid() {
482672
482821
  try {
482673
- if (existsSync32(this.pidFile)) {
482674
- const pid = parseInt(readFileSync15(this.pidFile, "utf-8").trim(), 10);
482822
+ if (existsSync33(this.pidFile)) {
482823
+ const pid = parseInt(readFileSync16(this.pidFile, "utf-8").trim(), 10);
482675
482824
  if (!isNaN(pid) && pid > 0) {
482676
482825
  try {
482677
482826
  process.kill(pid, 0);
@@ -482712,11 +482861,11 @@ class BunGlobalAdapter {
482712
482861
  encoding: "utf-8",
482713
482862
  stdio: ["ignore", "pipe", "ignore"]
482714
482863
  }).trim();
482715
- if (hivePath && existsSync32(hivePath)) {
482864
+ if (hivePath && existsSync33(hivePath)) {
482716
482865
  info3.push(`Hive binary: ${hivePath}`);
482717
482866
  const distDir = path34.dirname(hivePath);
482718
482867
  const uiDir = path34.join(distDir, "ui");
482719
- if (existsSync32(uiDir)) {
482868
+ if (existsSync33(uiDir)) {
482720
482869
  info3.push(`UI directory: ${uiDir}`);
482721
482870
  } else {
482722
482871
  warnings.push("UI directory not found - may use embedded UI");
@@ -482727,7 +482876,7 @@ class BunGlobalAdapter {
482727
482876
  } catch {
482728
482877
  errors6.push("Hive is not installed globally (try: bun install -g @johpaz/hive-agents)");
482729
482878
  }
482730
- if (existsSync32(this.hiveDir)) {
482879
+ if (existsSync33(this.hiveDir)) {
482731
482880
  info3.push(`Hive home: ${this.hiveDir}`);
482732
482881
  } else {
482733
482882
  warnings.push(`Hive home directory does not exist: ${this.hiveDir}`);
@@ -482769,7 +482918,7 @@ var init_bun_global = __esm(() => {
482769
482918
  // packages/cli/src/adapters/binary.ts
482770
482919
  import { spawn as spawn5, execSync as execSync3 } from "child_process";
482771
482920
  import * as path35 from "path";
482772
- import { existsSync as existsSync33, readFileSync as readFileSync16, unlinkSync as unlinkSync6 } from "fs";
482921
+ import { existsSync as existsSync34, readFileSync as readFileSync17, unlinkSync as unlinkSync6 } from "fs";
482773
482922
 
482774
482923
  class BinaryAdapter {
482775
482924
  type = "binary";
@@ -482781,7 +482930,7 @@ class BinaryAdapter {
482781
482930
  this.hiveDir = options2?.hiveDir || getHiveDir2();
482782
482931
  this.pidFile = path35.join(this.hiveDir, "gateway.pid");
482783
482932
  this.binaryPath = options2?.binaryPath || this.findBinary();
482784
- this.isDockerContainer = process.env.HIVE_UI_DIR === "/app/ui" || process.env.HIVE_HOST === "0.0.0.0" || existsSync33("/.dockerenv");
482933
+ this.isDockerContainer = process.env.HIVE_UI_DIR === "/app/ui" || process.env.HIVE_HOST === "0.0.0.0" || existsSync34("/.dockerenv");
482785
482934
  }
482786
482935
  get name() {
482787
482936
  return this.isDockerContainer ? "Docker Container" : "Standalone Binary";
@@ -482792,15 +482941,15 @@ class BinaryAdapter {
482792
482941
  const dir = path35.dirname(scriptPath);
482793
482942
  if (path35.basename(dir) === "dist") {
482794
482943
  const binaryInDist = path35.join(dir, "hive");
482795
- if (existsSync33(binaryInDist)) {
482944
+ if (existsSync34(binaryInDist)) {
482796
482945
  return binaryInDist;
482797
482946
  }
482798
482947
  const binaryWindows = path35.join(dir, "hive.exe");
482799
- if (existsSync33(binaryWindows)) {
482948
+ if (existsSync34(binaryWindows)) {
482800
482949
  return binaryWindows;
482801
482950
  }
482802
482951
  }
482803
- if (existsSync33(scriptPath) && !scriptPath.endsWith(".ts")) {
482952
+ if (existsSync34(scriptPath) && !scriptPath.endsWith(".ts")) {
482804
482953
  return scriptPath;
482805
482954
  }
482806
482955
  }
@@ -482813,7 +482962,7 @@ class BinaryAdapter {
482813
482962
  path35.join(process.env.HOME || "", ".bun", "bin", "hive")
482814
482963
  ];
482815
482964
  for (const binaryPath of commonPaths) {
482816
- if (existsSync33(binaryPath)) {
482965
+ if (existsSync34(binaryPath)) {
482817
482966
  return binaryPath;
482818
482967
  }
482819
482968
  }
@@ -482827,7 +482976,7 @@ class BinaryAdapter {
482827
482976
  if (scriptPath.endsWith(".ts")) {
482828
482977
  return false;
482829
482978
  }
482830
- if (existsSync33(this.binaryPath)) {
482979
+ if (existsSync34(this.binaryPath)) {
482831
482980
  return true;
482832
482981
  }
482833
482982
  try {
@@ -482839,7 +482988,7 @@ class BinaryAdapter {
482839
482988
  const distDir = getDistDir();
482840
482989
  if (distDir) {
482841
482990
  const uiDir = path35.join(distDir, "ui");
482842
- if (existsSync33(uiDir)) {
482991
+ if (existsSync34(uiDir)) {
482843
482992
  return true;
482844
482993
  }
482845
482994
  }
@@ -482855,7 +483004,7 @@ class BinaryAdapter {
482855
483004
  const distDir = getDistDir();
482856
483005
  if (distDir) {
482857
483006
  const uiDir = path35.join(distDir, "ui");
482858
- if (existsSync33(uiDir)) {
483007
+ if (existsSync34(uiDir)) {
482859
483008
  paths.uiDir = uiDir;
482860
483009
  }
482861
483010
  }
@@ -482922,8 +483071,8 @@ class BinaryAdapter {
482922
483071
  }
482923
483072
  async stop() {
482924
483073
  try {
482925
- if (existsSync33(this.pidFile)) {
482926
- const pid = parseInt(readFileSync16(this.pidFile, "utf-8").trim(), 10);
483074
+ if (existsSync34(this.pidFile)) {
483075
+ const pid = parseInt(readFileSync17(this.pidFile, "utf-8").trim(), 10);
482927
483076
  if (!isNaN(pid)) {
482928
483077
  try {
482929
483078
  process.kill(pid, "SIGTERM");
@@ -482956,8 +483105,8 @@ class BinaryAdapter {
482956
483105
  }
482957
483106
  async isRunning() {
482958
483107
  try {
482959
- if (existsSync33(this.pidFile)) {
482960
- const pid = parseInt(readFileSync16(this.pidFile, "utf-8").trim(), 10);
483108
+ if (existsSync34(this.pidFile)) {
483109
+ const pid = parseInt(readFileSync17(this.pidFile, "utf-8").trim(), 10);
482961
483110
  if (!isNaN(pid)) {
482962
483111
  try {
482963
483112
  process.kill(pid, 0);
@@ -482978,8 +483127,8 @@ class BinaryAdapter {
482978
483127
  }
482979
483128
  async getPid() {
482980
483129
  try {
482981
- if (existsSync33(this.pidFile)) {
482982
- const pid = parseInt(readFileSync16(this.pidFile, "utf-8").trim(), 10);
483130
+ if (existsSync34(this.pidFile)) {
483131
+ const pid = parseInt(readFileSync17(this.pidFile, "utf-8").trim(), 10);
482983
483132
  if (!isNaN(pid) && pid > 0) {
482984
483133
  try {
482985
483134
  process.kill(pid, 0);
@@ -483011,7 +483160,7 @@ class BinaryAdapter {
483011
483160
  const errors6 = [];
483012
483161
  const warnings = [];
483013
483162
  const info3 = [];
483014
- if (existsSync33(this.binaryPath)) {
483163
+ if (existsSync34(this.binaryPath)) {
483015
483164
  info3.push(`Binary: ${this.binaryPath}`);
483016
483165
  try {
483017
483166
  const stat3 = await import("fs/promises").then((m2) => m2.stat(this.binaryPath));
@@ -483034,13 +483183,13 @@ class BinaryAdapter {
483034
483183
  const distDir = getDistDir();
483035
483184
  if (distDir) {
483036
483185
  const uiDir = path35.join(distDir, "ui");
483037
- if (existsSync33(uiDir)) {
483186
+ if (existsSync34(uiDir)) {
483038
483187
  info3.push(`UI directory: ${uiDir}`);
483039
483188
  } else if (!hasEmbeddedUI) {
483040
483189
  warnings.push("UI directory not found and no embedded UI");
483041
483190
  }
483042
483191
  }
483043
- if (existsSync33(this.hiveDir)) {
483192
+ if (existsSync34(this.hiveDir)) {
483044
483193
  info3.push(`Hive home: ${this.hiveDir}`);
483045
483194
  } else {
483046
483195
  warnings.push(`Hive home directory does not exist: ${this.hiveDir}`);
@@ -483058,7 +483207,7 @@ class BinaryAdapter {
483058
483207
  } else {
483059
483208
  warnings.push("Hive Gateway is not running");
483060
483209
  }
483061
- if (process.platform !== "win32" && existsSync33(this.binaryPath)) {
483210
+ if (process.platform !== "win32" && existsSync34(this.binaryPath)) {
483062
483211
  try {
483063
483212
  execSync3(`test -x "${this.binaryPath}"`, { stdio: "ignore" });
483064
483213
  info3.push("Binary is executable");
@@ -483760,7 +483909,7 @@ __export(exports_gateway, {
483760
483909
  resetAdapter: () => resetAdapter,
483761
483910
  reload: () => reload
483762
483911
  });
483763
- import { existsSync as existsSync34, mkdirSync as mkdirSync19, writeFileSync as writeFileSync12, readFileSync as readFileSync17, unlinkSync as unlinkSync7, openSync } from "fs";
483912
+ import { existsSync as existsSync35, mkdirSync as mkdirSync19, writeFileSync as writeFileSync12, readFileSync as readFileSync18, unlinkSync as unlinkSync7, openSync } from "fs";
483764
483913
  import * as path36 from "path";
483765
483914
  import { spawn as spawn6 } from "child_process";
483766
483915
  async function getAdapter() {
@@ -483803,7 +483952,7 @@ async function getPidFile() {
483803
483952
  }
483804
483953
  function ensureLogDir() {
483805
483954
  const logDir = path36.dirname(getLogFile());
483806
- if (!existsSync34(logDir)) {
483955
+ if (!existsSync35(logDir)) {
483807
483956
  mkdirSync19(logDir, { recursive: true });
483808
483957
  }
483809
483958
  }
@@ -483836,7 +483985,7 @@ function openBrowser(url2) {
483836
483985
  async function isSetupMode2() {
483837
483986
  const hiveDir = getHiveDir();
483838
483987
  const dbPath = path36.join(hiveDir, "data", "hive.db");
483839
- return !existsSync34(dbPath);
483988
+ return !existsSync35(dbPath);
483840
483989
  }
483841
483990
  async function isRunning2() {
483842
483991
  try {
@@ -483847,9 +483996,9 @@ async function isRunning2() {
483847
483996
  }
483848
483997
  } catch {}
483849
483998
  const pidFile = await getPidFile();
483850
- if (!existsSync34(pidFile))
483999
+ if (!existsSync35(pidFile))
483851
484000
  return false;
483852
- const pid = parseInt(readFileSync17(pidFile, "utf-8").trim(), 10);
484001
+ const pid = parseInt(readFileSync18(pidFile, "utf-8").trim(), 10);
483853
484002
  if (isNaN(pid))
483854
484003
  return false;
483855
484004
  try {
@@ -483911,7 +484060,7 @@ async function start(flags3) {
483911
484060
  \u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2551
483912
484061
  \u2551 \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D \u2551
483913
484062
  \u2551 \u2551
483914
- \u2551 Personal Swarm AI Gateway \u2014 v0.0.31 \u2551
484063
+ \u2551 Personal Swarm AI Gateway \u2014 v0.0.32 \u2551
483915
484064
  \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D
483916
484065
 
483917
484066
  \uD83D\uDCE6 Installation: ${adapter.name}
@@ -483945,7 +484094,7 @@ async function handleDevMode(adapter, gatewayConfig, daemon) {
483945
484094
  return;
483946
484095
  }
483947
484096
  const hiveUiPath = path36.join(process.cwd(), "packages/hive-ui");
483948
- const hasVite = existsSync34(path36.join(hiveUiPath, "package.json"));
484097
+ const hasVite = existsSync35(path36.join(hiveUiPath, "package.json"));
483949
484098
  if (hasVite) {
483950
484099
  console.log(`\uD83C\uDFA8 Iniciando Vite (UI)...
483951
484100
  `);
@@ -484194,7 +484343,7 @@ async function handleProductionMode(adapter, gatewayConfig, daemon) {
484194
484343
  } catch {
484195
484344
  const hiveDir = getHiveDir();
484196
484345
  const dbPath = path36.join(hiveDir, "data", "hive.db");
484197
- needsSetup = !existsSync34(dbPath);
484346
+ needsSetup = !existsSync35(dbPath);
484198
484347
  }
484199
484348
  const url2 = needsSetup ? `http://localhost:${uiPort}/setup` : `http://localhost:${uiPort}`;
484200
484349
  if (needsSetup) {
@@ -484229,7 +484378,7 @@ async function stop() {
484229
484378
  return;
484230
484379
  }
484231
484380
  const pidFile = await getPidFile();
484232
- const pid = parseInt(readFileSync17(pidFile, "utf-8").trim(), 10);
484381
+ const pid = parseInt(readFileSync18(pidFile, "utf-8").trim(), 10);
484233
484382
  try {
484234
484383
  process.kill(pid, "SIGTERM");
484235
484384
  unlinkSync7(pidFile);
@@ -484275,7 +484424,7 @@ async function reload() {
484275
484424
  return;
484276
484425
  }
484277
484426
  const pidFile = await getPidFile();
484278
- const pid = parseInt(readFileSync17(pidFile, "utf-8").trim(), 10);
484427
+ const pid = parseInt(readFileSync18(pidFile, "utf-8").trim(), 10);
484279
484428
  try {
484280
484429
  process.kill(pid, "SIGHUP");
484281
484430
  console.log("\u2705 Configuraci\xF3n recargada");
@@ -485034,11 +485183,11 @@ async function updateSkills() {
485034
485183
  } else {
485035
485184
  console.log(` \u2705 Todas las skills est\xE1n actualizadas`);
485036
485185
  }
485037
- const { existsSync: existsSync38 } = await import("fs");
485186
+ const { existsSync: existsSync39 } = await import("fs");
485038
485187
  const { getHiveDir: getHiveDir3 } = await Promise.resolve().then(() => (init_loader(), exports_loader));
485039
485188
  const path40 = await import("path");
485040
485189
  const pidFile = path40.join(getHiveDir3(), "gateway.pid");
485041
- if (existsSync38(pidFile)) {
485190
+ if (existsSync39(pidFile)) {
485042
485191
  console.log(`
485043
485192
  \uD83D\uDCA1 El gateway est\xE1 corriendo. Ejecuta 'hive reload' para aplicar cambios.`);
485044
485193
  }
@@ -486312,8 +486461,8 @@ var MAIN_PACKAGE = "@johpaz/hive-agents";
486312
486461
  async function update() {
486313
486462
  console.log(`\uD83D\uDD04 Actualizando Hive...
486314
486463
  `);
486315
- const { existsSync: existsSync44 } = await import("fs");
486316
- const isGitRepo = existsSync44(".git") && existsSync44("package.json");
486464
+ const { existsSync: existsSync45 } = await import("fs");
486465
+ const isGitRepo = existsSync45(".git") && existsSync45("package.json");
486317
486466
  if (isGitRepo) {
486318
486467
  await updateFromGitRepo();
486319
486468
  } else {
@@ -486415,11 +486564,11 @@ Descargando ${MAIN_PACKAGE}@latest (via ${packageManager})...`);
486415
486564
  }
486416
486565
  }
486417
486566
  async function applyDatabaseUpdates() {
486418
- const { existsSync: existsSync44 } = await import("fs");
486567
+ const { existsSync: existsSync45 } = await import("fs");
486419
486568
  const { getHiveDir: getHiveDir3 } = await Promise.resolve().then(() => (init_loader(), exports_loader));
486420
486569
  const path45 = await import("path");
486421
486570
  const dbPath = path45.join(getHiveDir3(), "data", "hive.db");
486422
- if (!existsSync44(dbPath)) {
486571
+ if (!existsSync45(dbPath)) {
486423
486572
  console.log(` \u2139\uFE0F No se encontr\xF3 base de datos existente. Se crear\xE1 en el pr\xF3ximo 'hive start'.`);
486424
486573
  return;
486425
486574
  }
@@ -486457,7 +486606,7 @@ async function applyDatabaseUpdates() {
486457
486606
  }
486458
486607
  const hiveDir = getHiveDir3();
486459
486608
  const pidFile = path45.join(hiveDir, "gateway.pid");
486460
- if (existsSync44(pidFile)) {
486609
+ if (existsSync45(pidFile)) {
486461
486610
  console.log(`
486462
486611
  \uD83D\uDCA1 El gateway est\xE1 corriendo. Ejecuta 'hive reload' para aplicar cambios.`);
486463
486612
  }