claqueta-mcp 0.64.0 → 0.66.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/cli.js +443 -102
  2. package/motor/MOTOR_VERSION +1 -1
  3. package/motor/esteticas/_comun/LEEME.md +3 -0
  4. package/motor/esteticas/_comun/fuentes/marca.json +216 -0
  5. package/motor/esteticas/base/estetica.json +4 -2
  6. package/motor/esteticas/base/explicativo-personaje.css +12 -8
  7. package/motor/esteticas/cine-3d/explicativo-personaje.css +3 -2
  8. package/motor/esteticas/claro-puntos/estetica.json +2 -1
  9. package/motor/esteticas/comic/estetica.json +1 -0
  10. package/motor/esteticas/flat-editorial/estetica.json +2 -1
  11. package/motor/esteticas/interfaz-oscura/estetica.json +2 -1
  12. package/motor/esteticas/linea-minimal/estetica.json +4 -3
  13. package/motor/esteticas/linea-minimal/explicativo-personaje.css +15 -9
  14. package/motor/esteticas/linea-minimal/lista-top-n.css +11 -8
  15. package/motor/esteticas/marca-clara/estetica.json +4 -2
  16. package/motor/esteticas/marca-clara/explicativo-personaje.css +13 -10
  17. package/motor/esteticas/marca-clara/lista-top-n.css +14 -10
  18. package/motor/esteticas/poster-oscuro/estetica.json +2 -1
  19. package/motor/esteticas/vector-plano/estetica.json +2 -1
  20. package/motor/plantillas/_comun/zonas_seguras.json +120 -0
  21. package/motor/plantillas/algoritmo-visual/familia.json +3 -0
  22. package/motor/plantillas/anuncio-producto/familia.json +4 -1
  23. package/motor/plantillas/asi-se-hizo/familia.json +4 -1
  24. package/motor/plantillas/base/familia.json +5 -2
  25. package/motor/plantillas/demo-producto/familia.json +4 -1
  26. package/motor/plantillas/explicativo-personaje/animacion.js +6 -2
  27. package/motor/plantillas/explicativo-personaje/familia.json +5 -2
  28. package/motor/plantillas/leccion-diagrama/SKILL.md +39 -0
  29. package/motor/plantillas/leccion-diagrama/animacion.js +100 -4
  30. package/motor/plantillas/leccion-diagrama/estilos.css +5 -0
  31. package/motor/plantillas/leccion-diagrama/familia.json +9 -2
  32. package/motor/plantillas/lista-top-n/familia.json +4 -1
  33. package/motor/plantillas/poster-oscuro/familia.json +5 -2
  34. package/motor/plantillas/tres-objeciones/familia.json +4 -1
  35. package/motor/pyproject.toml +1 -1
  36. package/motor/src/claqueta_motor/beats.py +1 -0
  37. package/motor/src/claqueta_motor/cli.py +14 -5
  38. package/motor/src/claqueta_motor/composicion.py +34 -5
  39. package/motor/src/claqueta_motor/composicion_asi.py +2 -2
  40. package/motor/src/claqueta_motor/composicion_explicativo.py +14 -6
  41. package/motor/src/claqueta_motor/composicion_leccion.py +155 -21
  42. package/motor/src/claqueta_motor/composicion_lista.py +5 -2
  43. package/motor/src/claqueta_motor/contrato.py +24 -0
  44. package/motor/src/claqueta_motor/diagramas.py +5 -1
  45. package/motor/src/claqueta_motor/diagramas_gen.py +421 -38
  46. package/motor/src/claqueta_motor/escenas.py +17 -0
  47. package/motor/src/claqueta_motor/esteticas.py +15 -1
  48. package/motor/src/claqueta_motor/familias.py +5 -2
  49. package/motor/src/claqueta_motor/ffmpeg.py +38 -1
  50. package/motor/src/claqueta_motor/fuentes_marca.py +295 -0
  51. package/motor/src/claqueta_motor/medios.py +98 -12
  52. package/motor/src/claqueta_motor/onomatopeyas.py +264 -13
  53. package/motor/src/claqueta_motor/paleta.py +4 -0
  54. package/motor/src/claqueta_motor/plan.py +2 -0
  55. package/motor/src/claqueta_motor/revision.py +8 -0
  56. package/motor/src/claqueta_motor/revision_visual.py +19 -2
  57. package/motor/src/claqueta_motor/serie.py +8 -2
  58. package/motor/src/claqueta_motor/tablero.py +548 -0
  59. package/motor/src/claqueta_motor/zonas.py +104 -0
  60. package/motor/uv.lock +1 -1
  61. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -83,7 +83,7 @@ function ayudaConexionTodas(plataforma = process.platform) {
83
83
  }
84
84
 
85
85
  // src/config.ts
86
- var VERSION = true ? "0.64.0" : "dev";
86
+ var VERSION = true ? "0.66.0" : "dev";
87
87
  var construirAyuda = (plataforma = process.platform) => `claqueta-mcp ${VERSION}: puente stdio hacia el servidor MCP remoto de Claqueta.
88
88
 
89
89
  Uso:
@@ -245,13 +245,13 @@ function leerConfig(argv, env, archivo2 = {}) {
245
245
 
246
246
  // src/local/cli-local.ts
247
247
  import { homedir as homedir7 } from "node:os";
248
- import { join as join28 } from "node:path";
248
+ import { join as join29 } from "node:path";
249
249
 
250
250
  // src/motor-docker.ts
251
251
  import { spawn } from "node:child_process";
252
- var IMAGEN_POR_DEFECTO = "public.ecr.aws/v9d5u4i8/claqueta-motor@sha256:5c762e2c54042dae1e0020a6e7dcb478ddbc83a099a46a3734c233607b9f0de6";
253
- var IMAGEN_CLONACION_POR_DEFECTO = "public.ecr.aws/v9d5u4i8/claqueta-motor@sha256:6b41cf61f59881287ffe54cc4a18330c00a8e5deeee488f026dbf6f35e491ee4";
254
- var MOTOR_VERSION_POR_DEFECTO = "0.28.0";
252
+ var IMAGEN_POR_DEFECTO = "public.ecr.aws/v9d5u4i8/claqueta-motor@sha256:9a85c7aacbd6d701b68e0f31c5dcc21440ffc3bfb24ba174890744f3969eb2a8";
253
+ var IMAGEN_CLONACION_POR_DEFECTO = "public.ecr.aws/v9d5u4i8/claqueta-motor@sha256:a0fe2c0abe7e5ca8d291843ac8bd2b36db97a783277ca28e8f21054cff11212c";
254
+ var MOTOR_VERSION_POR_DEFECTO = "0.30.0";
255
255
  var PERFIL_AWS_POR_DEFECTO = "claqueta-motor";
256
256
  var REGION_POR_DEFECTO = "us-west-1";
257
257
  var ejecutarReal = (cmd, args2, opc) => new Promise((resolver) => {
@@ -11554,8 +11554,8 @@ function bitacora(ctx, a) {
11554
11554
  creado: estado2["creado"],
11555
11555
  formatos: renders.map((r2) => {
11556
11556
  const idx = join10(c, String(r2["composicion"]), "index.html");
11557
- const sha = sha2562(idx);
11558
- return { clave: r2["clave"], composicion: idx, editada: sha !== null && sha !== r2["index_sha256_original"] };
11557
+ const sha2 = sha2562(idx);
11558
+ return { clave: r2["clave"], composicion: idx, editada: sha2 !== null && sha2 !== r2["index_sha256_original"] };
11559
11559
  }),
11560
11560
  final: existsSync3(join10(c, "final", "video.mp4")) ? join10(c, "final", "video.mp4") : null,
11561
11561
  historial: estado2["historial"] ?? [],
@@ -12167,8 +12167,8 @@ function verificarIntegridad(id3, esperado, datos) {
12167
12167
  if (md5 !== etag) throw new ErrorMedia(`el asset ${id3} no coincide con su ETag (baj\xF3 md5 ${md5.slice(0, 12)}\u2026, esperado ${etag.slice(0, 12)}\u2026)`, true);
12168
12168
  return;
12169
12169
  }
12170
- const sha = createHash5("sha256").update(datos).digest("hex");
12171
- if (sha !== esperado) throw new ErrorMedia(`el asset ${id3} no coincide con su sha256 (baj\xF3 ${sha.slice(0, 12)}\u2026, esperado ${esperado.slice(0, 12)}\u2026)`, true);
12170
+ const sha2 = createHash5("sha256").update(datos).digest("hex");
12171
+ if (sha2 !== esperado) throw new ErrorMedia(`el asset ${id3} no coincide con su sha256 (baj\xF3 ${sha2.slice(0, 12)}\u2026, esperado ${esperado.slice(0, 12)}\u2026)`, true);
12172
12172
  }
12173
12173
  async function descargarMedia(media, pedidoDir, descargar2 = (u2, senal2) => fetch(u2, senal2 ? { signal: senal2 } : {}), senal, clips = []) {
12174
12174
  const salida = {};
@@ -13921,6 +13921,8 @@ Opciones:
13921
13921
  --almacen <dir> Con --mcp-local: almac\xE9n local a revisar (por defecto CLAQUETA_LOCAL_DIR o ~/Claqueta/local).
13922
13922
  --voz-clonada Calcula la compatibilidad como un worker con voz clonada (imagen -clonacion).
13923
13923
  --compositor claude Revisa tambi\xE9n el compositor con agente: Claude Code (\`claude\`) en el PATH y un Node 22+ para HyperFrames.
13924
+ --guionista Revisa tambi\xE9n el guionista local (grupos con defaults.guionista "agente"): si el worker lo tiene activado
13925
+ (GUIONISTA=1 o el servicio instalado con --guionista) y si Claude Code (\`claude\`) est\xE1 en el PATH.
13924
13926
  --json Salida de m\xE1quina (JSON) en stdout.
13925
13927
 
13926
13928
  Respeta NO_COLOR; sin terminal (pipe) no usa colores.
@@ -13938,6 +13940,10 @@ function leerArgsDoctor(argv) {
13938
13940
  op2.vozClonada = true;
13939
13941
  continue;
13940
13942
  }
13943
+ if (a === "--guionista") {
13944
+ op2.guionista = true;
13945
+ continue;
13946
+ }
13941
13947
  if (a === "--mcp-local") {
13942
13948
  op2.mcpLocal = true;
13943
13949
  continue;
@@ -14249,6 +14255,18 @@ async function chequeosLocal(d) {
14249
14255
  lista.push({ id: "local-aislamiento", titulo: "Aislamiento", estado: "aviso", mensaje: AVISO_SIN_AISLAMIENTO, arreglo: "Para correr el motor aislado usa el modo Docker (el predeterminado)." });
14250
14256
  return lista;
14251
14257
  }
14258
+ async function chequeosGuionista(d, porElWorker) {
14259
+ const { plist } = rutasServicio(d.os.casa);
14260
+ let enServicio = false;
14261
+ try {
14262
+ enServicio = d.fs.existe(plist) && d.fs.leer(plist).includes("<string>--guionista</string>");
14263
+ } catch {
14264
+ }
14265
+ const fuente = porElWorker ? "el worker arranc\xF3 con --guionista" : d.env["GUIONISTA"] === "1" ? "GUIONISTA=1" : enServicio ? "el servicio launchd lleva --guionista" : null;
14266
+ const activado = fuente ? { id: "guionista-activado", titulo: "Guionista: activado", estado: "ok", mensaje: `Activado (${fuente}).` } : { id: "guionista-activado", titulo: "Guionista: activado", estado: "aviso", mensaje: 'No est\xE1 activado (es opt-in): los videos de los grupos con defaults.guionista "agente" salen con el guion original (\xABguionista omitido: el worker no lo activ\xF3 (--guionista)\xBB).', arreglo: "npx claqueta-mcp@latest worker --guionista (o GUIONISTA=1)" };
14267
+ const cl2 = await d.ejecutar(d.env["GUIONISTA_COMANDO"] || "claude", ["--version"]);
14268
+ return [activado, cl2.codigo === 0 && !cl2.noEncontrado ? { id: "guionista-claude", titulo: "Guionista: Claude Code", estado: "ok", mensaje: `claude ${cl2.stdout.trim().split("\n")[0]?.slice(0, 60) ?? ""} (reescribe el guion de los grupos con defaults.guionista "agente", con la cuenta de este equipo).` } : { id: "guionista-claude", titulo: "Guionista: Claude Code", estado: "aviso", mensaje: "No encuentro `claude` en el PATH: los videos de los grupos con guionista saldr\xE1n con el guion original (\xABguionista no disponible: ausente\xBB).", arreglo: "npm install -g @anthropic-ai/claude-code && claude (inicia sesi\xF3n una vez)" }];
14269
+ }
14252
14270
  async function chequeosCompositor(d) {
14253
14271
  const cl2 = await d.ejecutar(d.env["COMPOSITOR_COMANDO"] || "claude", ["--version"]);
14254
14272
  const claude = cl2.codigo === 0 && !cl2.noEncontrado ? { id: "compositor-claude", titulo: "Compositor: Claude Code", estado: "ok", mensaje: `claude ${cl2.stdout.trim().split("\n")[0]?.slice(0, 60) ?? ""} (usa la cuenta con la que iniciaste sesi\xF3n en este equipo).` } : { id: "compositor-claude", titulo: "Compositor: Claude Code", estado: "aviso", mensaje: "No encuentro `claude` en el PATH: los videos saldr\xE1n con la composici\xF3n del motor (\xABcompositor no disponible: ausente\xBB).", arreglo: "npm install -g @anthropic-ai/claude-code && claude (inicia sesi\xF3n una vez)" };
@@ -14422,6 +14440,7 @@ async function ejecutarDoctor(o, d) {
14422
14440
  chequeos = [chequeoNode(d), dk2.binario, dk2.demonio, aws.cli, aws.perfil, ...conf.chequeos, api, ...comp.chequeos, img.chequeo, chequeoDisco(d), chequeoServicio(d)].map(enmascara);
14423
14441
  }
14424
14442
  if (o.compositor) chequeos = [...chequeos, ...(await chequeosCompositor(d)).map(enmascara)];
14443
+ if (o.guionista) chequeos = [...chequeos, ...(await chequeosGuionista(d, o.guionistaActivado === true)).map(enmascara)];
14425
14444
  const resumen3 = { ok: 0, aviso: 0, bloqueo: 0 };
14426
14445
  for (const c of chequeos) resumen3[c.estado]++;
14427
14446
  return { version: VERSION, listo: resumen3.bloqueo === 0, resumen: resumen3, chequeos, compatibilidad: JSON.parse(enmascarar(JSON.stringify(compat.informe), conf.cred.secretos)) };
@@ -14462,7 +14481,7 @@ var codigoSalida = (inf) => inf.resumen.bloqueo > 0 ? 1 : 0;
14462
14481
  // src/worker-cli.ts
14463
14482
  import { mkdirSync as mkdirSync12 } from "node:fs";
14464
14483
  import { homedir as homedir6, hostname as hostname6 } from "node:os";
14465
- import { dirname as dirname11, join as join27 } from "node:path";
14484
+ import { dirname as dirname12, join as join28 } from "node:path";
14466
14485
 
14467
14486
  // src/worker/avance.ts
14468
14487
  var NOMBRES = {
@@ -14585,8 +14604,8 @@ function crearAvance(salida, ops = {}) {
14585
14604
 
14586
14605
  // src/worker/worker.ts
14587
14606
  import { hostname as hostname4 } from "node:os";
14588
- import { access as access3, mkdir as mkdir8, readFile as readFile10, rm as rm5, writeFile as writeFile7 } from "node:fs/promises";
14589
- import { dirname as dirname10, join as join26, resolve as resolve9, sep as sep5 } from "node:path";
14607
+ import { access as access3, mkdir as mkdir9, readFile as readFile11, rm as rm6, writeFile as writeFile8 } from "node:fs/promises";
14608
+ import { dirname as dirname11, join as join27, resolve as resolve9, sep as sep5 } from "node:path";
14590
14609
 
14591
14610
  // src/worker/informe.ts
14592
14611
  import { access, readFile as readFile6 } from "node:fs/promises";
@@ -15031,8 +15050,281 @@ async function pasoCompositor(p) {
15031
15050
  return { tipo: "renderizado", res: otra, registro };
15032
15051
  }
15033
15052
 
15053
+ // src/worker/guionista.ts
15054
+ import { createHash as createHash7 } from "node:crypto";
15055
+ import { existsSync as existsSync10, readFileSync as readFileSync14 } from "node:fs";
15056
+ import { mkdir as mkdir8, readFile as readFile10, rm as rm5, writeFile as writeFile7 } from "node:fs/promises";
15057
+ import { dirname as dirname10, join as join25 } from "node:path";
15058
+ var TOPE_GUIONISTA_MS = 5 * 6e4;
15059
+ var PRESUPUESTO_GUIONISTA_USD = 1;
15060
+ var MAX_VUELTAS_GUIONISTA = 2;
15061
+ var HERRAMIENTAS_GUIONISTA = ["Read", "Write", "Edit", "Glob", "Grep"];
15062
+ var HERRAMIENTAS_PROHIBIDAS_GUIONISTA = ["Bash", "WebFetch", "WebSearch", "Task", "Agent", "NotebookEdit"];
15063
+ var CAMPOS_EDITABLES = ["guion", "guion_libre", "estilo"];
15064
+ var ESTILOS_DESTINO = /* @__PURE__ */ new Set(["leccion-diagrama"]);
15065
+ var TOPE_PEDIDO = 200 * 1024;
15066
+ var MINIMO_VUELTA_MS2 = 3e4;
15067
+ var PALABRAS_POR_S2 = 2.6;
15068
+ function leerEncargoGuionista(origen) {
15069
+ const g2 = origen?.["guionista"];
15070
+ if (!g2 || typeof g2 !== "object" || g2["modo"] !== "agente") return null;
15071
+ const reglas = Array.isArray(g2["reglas"]) ? g2["reglas"].filter((x2) => typeof x2 === "string") : [];
15072
+ return { origen: typeof g2["origen"] === "string" ? g2["origen"] : "grupo", reglas, revision: g2["revision"] ?? null, propuesta: g2["propuesta"] ?? null };
15073
+ }
15074
+ var sha = (x2) => createHash7("sha256").update(JSON.stringify(x2)).digest("hex");
15075
+ var escenasDe = (p) => {
15076
+ const e7 = p["guion"]?.escenas;
15077
+ return Array.isArray(e7) ? e7 : [];
15078
+ };
15079
+ var palabras2 = (p) => {
15080
+ const texto7 = escenasDe(p).map((e7) => typeof e7.narracion === "string" ? e7.narracion : "").join(" ") + (escenasDe(p).length ? "" : String(p["guion_libre"] ?? ""));
15081
+ return texto7.split(/\s+/).filter(Boolean).length;
15082
+ };
15083
+ function entornoGuionista(env, claude) {
15084
+ const sal = {};
15085
+ for (const k of ["HOME", "USER", "LOGNAME", "LANG", "TMPDIR"]) if (env[k]) sal[k] = env[k];
15086
+ return { ...sal, TERM: "dumb", PATH: [.../* @__PURE__ */ new Set([dirname10(claude), "/usr/bin", "/bin"])].join(":"), DO_NOT_TRACK: "1", DISABLE_AUTOUPDATER: "1" };
15087
+ }
15088
+ function argumentosGuionista(prompt, dir, presupuestoUsd) {
15089
+ return [
15090
+ "-p",
15091
+ prompt,
15092
+ "--output-format",
15093
+ "json",
15094
+ "--add-dir",
15095
+ dir,
15096
+ "--strict-mcp-config",
15097
+ "--mcp-config",
15098
+ '{"mcpServers":{}}',
15099
+ "--setting-sources",
15100
+ "project",
15101
+ "--permission-mode",
15102
+ "acceptEdits",
15103
+ "--allowedTools",
15104
+ ...HERRAMIENTAS_GUIONISTA,
15105
+ "--disallowedTools",
15106
+ ...HERRAMIENTAS_PROHIBIDAS_GUIONISTA,
15107
+ "--no-session-persistence",
15108
+ "--max-budget-usd",
15109
+ presupuestoUsd.toFixed(2)
15110
+ ];
15111
+ }
15112
+ function catalogoIconos(motorDir) {
15113
+ const comun = join25(motorDir, "plantillas", "_comun");
15114
+ const leer2 = (ruta) => {
15115
+ try {
15116
+ return JSON.parse(readFileSync14(ruta, "utf8"));
15117
+ } catch {
15118
+ return null;
15119
+ }
15120
+ };
15121
+ const lucide = leer2(join25(comun, "lucide", "iconos.json"));
15122
+ if (!lucide) return null;
15123
+ const nombres = new Set(Object.keys(lucide));
15124
+ for (const set of ["phosphor", "tabler"]) for (const k of Object.keys(leer2(join25(comun, "recursos", set, "iconos.json")) ?? {})) nombres.add(`${set}:${k}`);
15125
+ for (const set of ["aws", "azure", "gcp", "k8s", "ia", "marca", "emoji", "bandera", "dev", "salud", "clima", "lugar", "cripto"]) {
15126
+ const d = leer2(join25(comun, "recursos", set, "iconos.json"));
15127
+ for (const k of [...Object.keys(d?.iconos ?? {}), ...Object.keys(d?.alias ?? {})]) nombres.add(`${set}:${k}`);
15128
+ }
15129
+ return nombres;
15130
+ }
15131
+ function revisarReescrito(r2, nuevo, iconos) {
15132
+ if (!nuevo || typeof nuevo !== "object" || Array.isArray(nuevo)) return { errores: ["pedido.json debe ser un objeto JSON"], ignorados: [] };
15133
+ const n = nuevo;
15134
+ const original = r2.pedido;
15135
+ const ignorados = Object.keys({ ...original, ...n }).filter((k) => !CAMPOS_EDITABLES.includes(k) && JSON.stringify(original[k]) !== JSON.stringify(n[k]));
15136
+ const final = { ...original };
15137
+ for (const k of CAMPOS_EDITABLES) {
15138
+ if (k in n && n[k] !== void 0 && n[k] !== null) final[k] = n[k];
15139
+ }
15140
+ if (escenasDe(final).length && "guion_libre" in final && !("guion_libre" in n)) delete final["guion_libre"];
15141
+ const errores = [];
15142
+ if (final["estilo"] !== original["estilo"]) {
15143
+ if (typeof final["estilo"] !== "string" || !ESTILOS_DESTINO.has(final["estilo"])) errores.push(`estilo: solo puedes cambiarlo a ${[...ESTILOS_DESTINO].join(", ")} (o dejar ${JSON.stringify(original["estilo"] ?? "base")})`);
15144
+ else if (!escenasDe(final).some((e7) => e7.visual?.diagrama)) errores.push("estilo leccion-diagrama sin visual.diagrama en ninguna escena: agrega el diagrama o deja el estilo original");
15145
+ }
15146
+ const v2 = gk.safeParse({ ...final, workspace: r2.workspace, proyecto: r2.proyecto });
15147
+ if (!v2.success) for (const p of v2.error.issues.slice(0, 8)) errores.push(`${p.path.map(String).join(".") || "(ra\xEDz)"}: ${p.message}`);
15148
+ try {
15149
+ traducirPedido({ ...r2, pedido: final });
15150
+ } catch (e7) {
15151
+ if (e7 instanceof PedidoNoSoportado) errores.push(e7.message);
15152
+ else throw e7;
15153
+ }
15154
+ const ids = new Set(escenasDe(final).map((e7) => e7.id));
15155
+ for (const campo of ["media", "storyboard", "referencias"]) {
15156
+ const lista = original[campo];
15157
+ if (!Array.isArray(lista)) continue;
15158
+ for (const x2 of lista) {
15159
+ if (typeof x2?.escena === "string" && escenasDe(final).length && !ids.has(x2.escena)) errores.push(`${campo} apunta a la escena \xAB${x2.escena}\xBB, que ya no existe: conserva ese id`);
15160
+ }
15161
+ }
15162
+ if (iconos) {
15163
+ const malos = escenasDe(final).flatMap((e7) => Array.isArray(e7.iconos) ? e7.iconos : []).filter((i) => typeof i !== "string" || !iconos.has(i.trim().toLowerCase()));
15164
+ if (malos.length) errores.push(`iconos que no existen: ${[...new Set(malos.map(String))].slice(0, 12).join(", ")} (b\xFAscalos en _encargo/iconos.txt)`);
15165
+ }
15166
+ if (JSON.stringify(final).length > TOPE_PEDIDO) errores.push("el pedido pasa de 200 KB");
15167
+ if (familiaDe(final) && !FAMILIAS_SOPORTADAS.includes(familiaDe(final))) errores.push(`familia desconocida: ${familiaDe(final)}`);
15168
+ return errores.length ? { errores, ignorados } : { errores, pedido: final, ignorados };
15169
+ }
15170
+ var familiaDe = (p) => typeof p["estilo"] === "string" ? p["estilo"] : null;
15171
+ function resumirCambios(antes, despues) {
15172
+ const sal = [];
15173
+ const ea2 = escenasDe(antes);
15174
+ const ed2 = escenasDe(despues);
15175
+ if (ea2.length !== ed2.length) sal.push(`escenas: ${ea2.length} \u2192 ${ed2.length}`);
15176
+ const pa2 = palabras2(antes);
15177
+ const pd2 = palabras2(despues);
15178
+ if (pa2 !== pd2) sal.push(`narraci\xF3n: ${pa2} \u2192 ${pd2} palabras (~${Math.round(pa2 / PALABRAS_POR_S2)} \u2192 ~${Math.round(pd2 / PALABRAS_POR_S2)} s)`);
15179
+ const iconosDe = (l) => l.reduce((s, e7) => s + (Array.isArray(e7.iconos) ? e7.iconos.length : 0), 0);
15180
+ const conIconos = (l) => l.filter((e7) => Array.isArray(e7.iconos) && e7.iconos.length).length;
15181
+ if (iconosDe(ea2) !== iconosDe(ed2)) sal.push(`iconos: ${iconosDe(ea2)} \u2192 ${iconosDe(ed2)} (${conIconos(ed2)}/${ed2.length} escenas con iconos)`);
15182
+ const diag = (l) => l.filter((e7) => e7.visual?.diagrama).length;
15183
+ if (diag(ea2) !== diag(ed2)) sal.push(`diagramas: ${diag(ea2)} \u2192 ${diag(ed2)}`);
15184
+ if (antes["estilo"] !== despues["estilo"]) sal.push(`estilo: ${String(antes["estilo"] ?? "base")} \u2192 ${String(despues["estilo"])}`);
15185
+ if (!sal.length && sha(antes["guion"]) !== sha(despues["guion"])) sal.push("textos de escena reescritos");
15186
+ return sal;
15187
+ }
15188
+ function encargoMd(e7, objetivo) {
15189
+ return [
15190
+ "# Encargo: mejorar el guion de un video de Claqueta",
15191
+ "",
15192
+ "Reescribe `pedido.json` (en esta carpeta) para que el video sea mejor, siguiendo estas reglas. Escribe el resultado en el mismo `pedido.json`.",
15193
+ "Solo se toman `guion` (escenas), `guion_libre` y `estilo`; cualquier otro campo que cambies se ignora.",
15194
+ "No hay herramientas de red ni MCP: los iconos v\xE1lidos est\xE1n en `_encargo/iconos.txt` (uno por l\xEDnea; b\xFAscalos con Grep).",
15195
+ typeof objetivo === "number" ? `Duraci\xF3n objetivo: ${objetivo} s (unas ${Math.round(objetivo * PALABRAS_POR_S2)} palabras de narraci\xF3n).` : "",
15196
+ "",
15197
+ "## Reglas",
15198
+ ...e7.encargo.reglas.map((r2) => `- ${r2.replace(/\(búscalos con buscar_iconos\)/, "(b\xFAscalos en _encargo/iconos.txt)")}`),
15199
+ "- Conserva los `id` de las escenas a las que apunta `media`, `storyboard` o `referencias`.",
15200
+ "",
15201
+ "## Revisi\xF3n del pedido (hecha por reglas al solicitarlo)",
15202
+ "```json",
15203
+ JSON.stringify(e7.encargo.revision, null, 2),
15204
+ "```",
15205
+ "",
15206
+ "## Propuesta determinista (puedes partir de ella o mejorarla)",
15207
+ "```json",
15208
+ JSON.stringify(e7.encargo.propuesta, null, 2),
15209
+ "```"
15210
+ ].join("\n");
15211
+ }
15212
+ var PROMPT = "Lee _encargo/encargo.md y pedido.json. Reescribe pedido.json siguiendo el encargo (solo guion, guion_libre y estilo). Cuando termines, responde en una l\xEDnea qu\xE9 cambiaste.";
15213
+ var promptCorreccion2 = (errores) => `El pedido.json que escribiste no pasa la validaci\xF3n:
15214
+ ${errores.map((x2) => `- ${x2}`).join("\n")}
15215
+ Lee _encargo/encargo.md y corrige pedido.json (solo guion, guion_libre y estilo).`;
15216
+ function crearGuionista(o, d = depsReales4(o.motorDir)) {
15217
+ return {
15218
+ ejecutor: "claude",
15219
+ async reescribir(e7) {
15220
+ const t0 = d.ahora();
15221
+ const original = e7.r.pedido;
15222
+ const base = {
15223
+ ejecutor: "claude",
15224
+ origen: e7.encargo.origen,
15225
+ modelo: null,
15226
+ vueltas: 0,
15227
+ segundos: 0,
15228
+ costo_usd: null,
15229
+ tokens: null,
15230
+ turnos: null,
15231
+ respaldo: true,
15232
+ motivo: null,
15233
+ cambios: [],
15234
+ escenas_antes: escenasDe(original).length,
15235
+ escenas_despues: escenasDe(original).length,
15236
+ palabras_antes: palabras2(original),
15237
+ palabras_despues: palabras2(original),
15238
+ pedido_sha256_antes: sha(original),
15239
+ pedido_sha256_despues: null,
15240
+ ignorados: []
15241
+ };
15242
+ const reg = (x2) => ({ ...base, ...x2, segundos: Math.round((d.ahora() - t0) / 1e3) });
15243
+ const respaldo2 = (motivo, detalle, x2 = {}) => ({ tipo: "respaldo", registro: reg({ ...x2, respaldo: true, motivo: `${motivo}${detalle ? `: ${detalle}` : ""}`.slice(0, 300) }) });
15244
+ const claude = d.buscarEjecutable(o.comando, o.env);
15245
+ if (!claude) return respaldo2("ausente", `no encuentro \`${o.comando}\` en el PATH`);
15246
+ await rm5(e7.dir, { recursive: true, force: true });
15247
+ await mkdir8(join25(e7.dir, "_encargo"), { recursive: true });
15248
+ await writeFile7(join25(e7.dir, "pedido.json"), JSON.stringify(original, null, 2));
15249
+ await writeFile7(join25(e7.dir, "_encargo", "encargo.md"), encargoMd(e7, original["formato"]?.duracion_objetivo_s));
15250
+ const iconos = d.iconos();
15251
+ await writeFile7(join25(e7.dir, "_encargo", "iconos.txt"), iconos ? [...iconos].sort().join("\n") : "");
15252
+ let costo = null;
15253
+ let tokens = null;
15254
+ let turnos = null;
15255
+ let modelo = null;
15256
+ let prompt = PROMPT;
15257
+ let ultimos = [];
15258
+ let ignorados = [];
15259
+ for (let vuelta = 1; vuelta <= MAX_VUELTAS_GUIONISTA; vuelta++) {
15260
+ const restante = o.topeMs - (d.ahora() - t0);
15261
+ if (vuelta > 1 && restante < (o.minimoVueltaMs ?? MINIMO_VUELTA_MS2)) break;
15262
+ const s = await d.lanzar(claude, argumentosGuionista(prompt, e7.dir, o.presupuestoUsd), { cwd: e7.dir, env: entornoGuionista(o.env, claude), timeoutMs: restante, ...e7.senal ? { senal: e7.senal } : {} });
15263
+ const uso = leerSalidaClaude(s.stdout);
15264
+ costo = uso.costo === null ? costo : (costo ?? 0) + uso.costo;
15265
+ turnos = uso.turnos === null ? turnos : (turnos ?? 0) + uso.turnos;
15266
+ modelo = uso.modelo ?? modelo;
15267
+ if (uso.tokens) tokens = tokens ? { entrada: tokens.entrada + uso.tokens.entrada, salida: tokens.salida + uso.tokens.salida, cache_lectura: tokens.cache_lectura + uso.tokens.cache_lectura, cache_escritura: tokens.cache_escritura + uso.tokens.cache_escritura } : uso.tokens;
15268
+ const uso_ = { vueltas: vuelta, costo_usd: costo, tokens, turnos, modelo };
15269
+ if (s.abortado) return { tipo: "cancelado" };
15270
+ if (s.noEncontrado) return respaldo2("ausente", `no pude ejecutar ${o.comando}`, uso_);
15271
+ if (s.tiempoAgotado) return respaldo2("tiempo agotado", `m\xE1s de ${Math.round(o.topeMs / 6e4)} min`, uso_);
15272
+ if (s.codigo !== 0 || uso.error) return respaldo2("error", uso.error ?? `sali\xF3 con c\xF3digo ${s.codigo}: ${s.stderr.trim().slice(-160)}`, uso_);
15273
+ let nuevo;
15274
+ try {
15275
+ nuevo = JSON.parse(await readFile10(join25(e7.dir, "pedido.json"), "utf8"));
15276
+ } catch {
15277
+ nuevo = null;
15278
+ }
15279
+ const rev = revisarReescrito(e7.r, nuevo, iconos);
15280
+ ignorados = rev.ignorados;
15281
+ if (rev.pedido) {
15282
+ const cambios = resumirCambios(original, rev.pedido);
15283
+ if (sha(rev.pedido) === sha(original)) return respaldo2("sin cambios", "el agente dej\xF3 el pedido igual", { ...uso_, ignorados });
15284
+ return {
15285
+ tipo: "ok",
15286
+ pedido: rev.pedido,
15287
+ registro: reg({ ...uso_, respaldo: false, motivo: null, cambios, ignorados, escenas_despues: escenasDe(rev.pedido).length, palabras_despues: palabras2(rev.pedido), pedido_sha256_despues: sha(rev.pedido) })
15288
+ };
15289
+ }
15290
+ ultimos = rev.errores;
15291
+ prompt = promptCorreccion2(rev.errores);
15292
+ }
15293
+ return respaldo2("pedido inv\xE1lido", ultimos.slice(0, 3).join("; "), { vueltas: MAX_VUELTAS_GUIONISTA, costo_usd: costo, tokens, turnos, modelo, ignorados });
15294
+ }
15295
+ };
15296
+ }
15297
+ function depsReales4(motorDir) {
15298
+ let cache;
15299
+ return {
15300
+ lanzar: lanzarReal,
15301
+ buscarEjecutable: buscarEnPath,
15302
+ ahora: Date.now,
15303
+ iconos: () => cache !== void 0 ? cache : cache = motorDir && existsSync10(motorDir) ? catalogoIconos(motorDir) : null
15304
+ };
15305
+ }
15306
+ async function anotarGuionistaEnManifiesto(salidaDir, registro, guionFinal) {
15307
+ const ruta = join25(salidaDir, "manifiesto.json");
15308
+ let m;
15309
+ try {
15310
+ m = JSON.parse(await readFile10(ruta, "utf8"));
15311
+ } catch {
15312
+ return;
15313
+ }
15314
+ const valor = { ...registro, ..."respaldo" in registro && !registro.respaldo ? { guion_final: guionFinal } : {} };
15315
+ m["guionista"] = valor;
15316
+ const k = m["construccion"];
15317
+ if (k && typeof k === "object" && !Array.isArray(k)) k["guionista"] = valor;
15318
+ await writeFile7(ruta, JSON.stringify(m, null, 2));
15319
+ }
15320
+ function mensajeGuionista(r2) {
15321
+ if (r2.respaldo) return `guionista no disponible: ${r2.motivo ?? "sin motivo"}; sale el guion original`.slice(0, 480);
15322
+ const costo = r2.costo_usd !== null ? `, US$${r2.costo_usd.toFixed(2)}` : "";
15323
+ return `guionista: guion reescrito (${r2.cambios.join("; ") || "sin cambios visibles"}; ${r2.segundos} s${costo})`.slice(0, 480);
15324
+ }
15325
+
15034
15326
  // src/worker/paso-parecido.ts
15035
- import { join as join25 } from "node:path";
15327
+ import { join as join26 } from "node:path";
15036
15328
  function crearParecidoDelVideo(o) {
15037
15329
  let ruta = null;
15038
15330
  let metricasRef = null;
@@ -15041,7 +15333,7 @@ function crearParecidoDelVideo(o) {
15041
15333
  const b = await o.bajarReferencias();
15042
15334
  const local = b.archivos[o.referencia.asset_id];
15043
15335
  if (!local) throw new Error(`no se pudo bajar la referencia ${o.referencia.asset_id}${b.fallos[o.referencia.asset_id] ? `: ${b.fallos[o.referencia.asset_id]}` : ""}`);
15044
- return join25(o.pedidoDir, local.ruta);
15336
+ return join26(o.pedidoDir, local.ruta);
15045
15337
  })();
15046
15338
  const ref = { asset_id: o.referencia.asset_id, nombre: o.referencia.nombre, origen: o.referencia.origen };
15047
15339
  return {
@@ -15052,7 +15344,7 @@ function crearParecidoDelVideo(o) {
15052
15344
  return { referencia: ref, ref: refM, base, medir: (v2) => o.medidor.medir(v2) };
15053
15345
  },
15054
15346
  async final(mp42, registro) {
15055
- const c = await o.medidor.comparar(mp42, await rutaRef(), join25(o.raiz, "parecido"), `${o.titulo} vs ${o.referencia.nombre ?? "referencia"}`);
15347
+ const c = await o.medidor.comparar(mp42, await rutaRef(), join26(o.raiz, "parecido"), `${o.titulo} vs ${o.referencia.nombre ?? "referencia"}`);
15056
15348
  const vueltas = [...registro?.parecido?.vueltas ?? []];
15057
15349
  if (registro && !registro.respaldo && registro.vuelta_usada && !vueltas.some((v2) => v2.vuelta === registro.vuelta_usada)) {
15058
15350
  vueltas.push({ vuelta: registro.vuelta_usada, cambios_por_minuto: c.este.cambios_por_minuto, escena_media_s: c.este.escena_media_s, lectura_ritmo: c.lectura["ritmo_de_cortes"]?.lectura ?? null });
@@ -15136,9 +15428,9 @@ async function trabajarVideo(c, d, r2, turno, buzon) {
15136
15428
  const { api } = d;
15137
15429
  const id3 = r2.video_id;
15138
15430
  const agenteB = d.agenteB && r2.pedido?.["previa"] !== true && agentesPresentes(d.agenteB.presenciaDir).length ? d.agenteB : null;
15139
- const raiz = agenteB ? join26(agenteB.trabajoDir, `nube-${id3}-v${r2.version}-i${r2.intento}`) : join26(c.trabajoDir, `${id3}-v${r2.version}-i${r2.intento}`);
15140
- const pedidoDir = join26(raiz, agenteB ? "entrada" : "pedido");
15141
- let salidaDir = join26(raiz, "salida");
15431
+ const raiz = agenteB ? join27(agenteB.trabajoDir, `nube-${id3}-v${r2.version}-i${r2.intento}`) : join27(c.trabajoDir, `${id3}-v${r2.version}-i${r2.intento}`);
15432
+ const pedidoDir = join27(raiz, agenteB ? "entrada" : "pedido");
15433
+ let salidaDir = join27(raiz, "salida");
15142
15434
  log(`reclamado ${id3} v${r2.version} (intento ${r2.intento}): ${r2.titulo}${agenteB ? " (hay un Agente B presente: compongo por pasos y lo dejo en el buz\xF3n)" : ""}`);
15143
15435
  d.avance?.iniciar({ id: id3, titulo: r2.titulo, version: r2.version, intento: r2.intento });
15144
15436
  let costo;
@@ -15172,8 +15464,8 @@ async function trabajarVideo(c, d, r2, turno, buzon) {
15172
15464
  c = { ...c, timeoutMs: tope.ms };
15173
15465
  log(`${id3}: video largo (~${tope.duracionS} s, ${tope.formatos} formato${tope.formatos === 1 ? "" : "s"}): tope ${Math.round(tope.ms / 6e4)} min`);
15174
15466
  }
15175
- await mkdir8(pedidoDir, { recursive: true });
15176
- await mkdir8(salidaDir, { recursive: true });
15467
+ await mkdir9(pedidoDir, { recursive: true });
15468
+ await mkdir9(salidaDir, { recursive: true });
15177
15469
  const parar = new AbortController();
15178
15470
  const alCerrar = () => parar.abort();
15179
15471
  d.senal?.addEventListener("abort", alCerrar, { once: true });
@@ -15199,6 +15491,15 @@ async function trabajarVideo(c, d, r2, turno, buzon) {
15199
15491
  const latido = setInterval(() => publicar(ultimo, true), d.latidoMs ?? 3e4);
15200
15492
  publicar(ultimo, true);
15201
15493
  try {
15494
+ const guion = await pasoGuionista(d, r2, pedido, raiz, parar.signal, log, async (mensaje, nivel, datos) => {
15495
+ d.avance?.nota(mensaje);
15496
+ await cadena2;
15497
+ await api.progreso(id3, { ...r_2, etapa: "voz", porcentaje: 0, mensaje, ...nivel ? { nivel } : {}, datos }).catch(() => {
15498
+ });
15499
+ });
15500
+ if (cancelado || guion.tipo === "cancelado") return { tipo: "cancelado", videoId: id3 };
15501
+ if (guion.tipo === "ok") pedido = traducirPedido({ ...r2, pedido: guion.pedido });
15502
+ const registroGuionista = guion.tipo === "sin_paso" ? null : guion;
15202
15503
  try {
15203
15504
  const locales = await descargarMedia(r2.media, pedidoDir, d.descargar, parar.signal, idsDeClips(pedido));
15204
15505
  if (Object.keys(locales).length) pedido["archivos_locales"] = locales;
@@ -15207,7 +15508,7 @@ async function trabajarVideo(c, d, r2, turno, buzon) {
15207
15508
  if (e7 instanceof ErrorMedia) return await fallar("media", e7.message, null, e7.reintentable);
15208
15509
  throw e7;
15209
15510
  }
15210
- await writeFile7(join26(pedidoDir, "pedido.json"), JSON.stringify(pedido, null, 2));
15511
+ await writeFile8(join27(pedidoDir, "pedido.json"), JSON.stringify(pedido, null, 2));
15211
15512
  if (cancelado) return { tipo: "cancelado", videoId: id3 };
15212
15513
  let res;
15213
15514
  const onEvento = (e7) => {
@@ -15219,12 +15520,12 @@ async function trabajarVideo(c, d, r2, turno, buzon) {
15219
15520
  const bajarReferencias = () => bajadas ??= descargarReferenciasVideo(r2.media, pedido["referencias"], pedidoDir, d.descargar, parar.signal);
15220
15521
  let porAgente = false;
15221
15522
  if (agenteB) {
15222
- const b = await caminoAgenteB(c, d, r2, agenteB, { raiz, rutaPedido: join26(pedidoDir, "pedido.json"), pedido, bajarReferencias, turno, senal: parar.signal, onEvento, log, buzon });
15523
+ const b = await caminoAgenteB(c, d, r2, agenteB, { raiz, rutaPedido: join27(pedidoDir, "pedido.json"), pedido, bajarReferencias, turno, senal: parar.signal, onEvento, log, buzon });
15223
15524
  await cadena2;
15224
15525
  if (cancelado || b.tipo === "cancelado") return { tipo: "cancelado", videoId: id3 };
15225
15526
  if (b.tipo === "listo") {
15226
15527
  res = b.res;
15227
- salidaDir = join26(raiz, "final");
15528
+ salidaDir = join27(raiz, "final");
15228
15529
  porAgente = true;
15229
15530
  }
15230
15531
  }
@@ -15245,7 +15546,7 @@ async function trabajarVideo(c, d, r2, turno, buzon) {
15245
15546
  }
15246
15547
  if (cancelado) return { tipo: "cancelado", videoId: id3 };
15247
15548
  if (res.abortado) return await fallar(ultimo.etapa, "el worker se detuvo mientras generaba; se reintentar\xE1", null, true);
15248
- const mp42 = join26(salidaDir, "video.mp4");
15549
+ const mp42 = join27(salidaDir, "video.mp4");
15249
15550
  const refParecido = d.parecido && pedido["previa"] !== true ? elegirReferencia(pedido, r2.media, r2.origen, d.motorDir) : null;
15250
15551
  const parecido = refParecido && d.parecido ? crearParecidoDelVideo({ medidor: d.parecido, referencia: refParecido, pedidoDir, raiz, titulo: r2.titulo, bajarReferencias }) : null;
15251
15552
  let registroCompositor;
@@ -15282,6 +15583,7 @@ async function trabajarVideo(c, d, r2, turno, buzon) {
15282
15583
  const advertencias = [];
15283
15584
  if (res.codigo === 0 || res.codigo === 15) {
15284
15585
  if (!await existe3(mp42)) return await fallar(ultimo.etapa, `el motor termin\xF3 bien pero no dej\xF3 video.mp4`, res.codigo, true);
15586
+ if (registroGuionista) await anotarGuionistaEnManifiesto(salidaDir, registroGuionista.tipo === "omitido" ? { omitido: true, razon: registroGuionista.razon } : registroGuionista.registro, registroGuionista.tipo === "ok" ? pedido["guion"] : null);
15285
15587
  const manifiesto = await leerManifiesto(salidaDir, log);
15286
15588
  costo = manifiesto.costo;
15287
15589
  if (pedido["previa"] === true) {
@@ -15461,7 +15763,7 @@ async function trabajarVideo(c, d, r2, turno, buzon) {
15461
15763
  await cadena2;
15462
15764
  }
15463
15765
  } finally {
15464
- if (!c.conservar && !agenteB) await rm5(raiz, { recursive: true, force: true });
15766
+ if (!c.conservar && !agenteB) await rm6(raiz, { recursive: true, force: true });
15465
15767
  }
15466
15768
  }
15467
15769
  async function caminoAgenteB(c, d, r2, cfg, x2) {
@@ -15486,7 +15788,7 @@ async function caminoAgenteB(c, d, r2, cfg, x2) {
15486
15788
  pedido_ruta: x2.rutaPedido,
15487
15789
  referencias: {
15488
15790
  pedido: Array.isArray(x2.pedido["referencias"]) ? x2.pedido["referencias"] : [],
15489
- archivos: Object.fromEntries(Object.entries(refs.archivos).map(([k, v2]) => [k, join26(dirname10(x2.rutaPedido), v2.ruta)])),
15791
+ archivos: Object.fromEntries(Object.entries(refs.archivos).map(([k, v2]) => [k, join27(dirname11(x2.rutaPedido), v2.ruta)])),
15490
15792
  fallos: refs.fallos
15491
15793
  },
15492
15794
  carpeta: x2.raiz,
@@ -15512,7 +15814,7 @@ async function caminoAgenteB(c, d, r2, cfg, x2) {
15512
15814
  }
15513
15815
  actualizarTrabajo(cfg, trabajo, { estado: "aprobado" });
15514
15816
  await x2.turno.tomar();
15515
- const final = join26(x2.raiz, "final", "video.mp4");
15817
+ const final = join27(x2.raiz, "final", "video.mp4");
15516
15818
  if (fin.respuesta.usar_final === true && await existe3(final)) {
15517
15819
  x2.log(`buz\xF3n ${r2.video_id}: aprobado; uso el final/ que renderiz\xF3 el Agente B`);
15518
15820
  return { tipo: "listo", res: { codigo: 0, tiempoAgotado: false, abortado: false, error: null, stderrCola: [] } };
@@ -15531,6 +15833,23 @@ async function caminoAgenteB(c, d, r2, cfg, x2) {
15531
15833
  }
15532
15834
  };
15533
15835
  }
15836
+ async function pasoGuionista(d, r2, pedido, raiz, senal, log, bitacora2) {
15837
+ const encargo = leerEncargoGuionista(r2.origen);
15838
+ if (!encargo) return { tipo: "sin_paso" };
15839
+ const omitir = !d.guionista ? "el worker no lo activ\xF3 (--guionista)" : pedido["previa"] === true ? "vista previa" : r2.reutilizar ? "reutiliza escenas de la versi\xF3n anterior" : r2.intento > 1 ? `reintento ${r2.intento}: sale con el pedido original por si el reescrito caus\xF3 el fallo` : null;
15840
+ if (omitir) {
15841
+ log(`${r2.video_id}: guionista omitido (${omitir})`);
15842
+ await bitacora2(`guionista omitido: ${omitir}; sale el guion original`, "advertencia", { guionista: { omitido: true, razon: omitir } });
15843
+ return { tipo: "omitido", razon: omitir };
15844
+ }
15845
+ log(`${r2.video_id}: guionista: reescribiendo el guion con ${d.guionista.ejecutor}`);
15846
+ const res = await d.guionista.reescribir({ r: r2, encargo, dir: join27(raiz, "guionista"), senal });
15847
+ if (res.tipo === "cancelado") return res;
15848
+ const mensaje = mensajeGuionista(res.registro);
15849
+ log(`${r2.video_id}: ${mensaje}`);
15850
+ await bitacora2(mensaje, res.tipo === "respaldo" ? "advertencia" : void 0, { guionista: res.registro });
15851
+ return res;
15852
+ }
15534
15853
  async function anotarDevolucion(d, r2, resp) {
15535
15854
  if (!resp || resp.estado !== "aprobado" && resp.estado !== "rechazado") return;
15536
15855
  const quien = `${resp.agente ?? "Agente B"}${resp.host ? ` en ${resp.host}` : ""}${resp.sesion ? ` (sesi\xF3n ${resp.sesion})` : ""}`;
@@ -15556,14 +15875,14 @@ async function prepararInsumos(d, r2, raiz, senal, log, cadena2) {
15556
15875
  var renders0 = (m) => m.renders[0]?.etiqueta ?? null;
15557
15876
  async function esPrevia(salidaDir) {
15558
15877
  try {
15559
- return JSON.parse(await readFile10(join26(salidaDir, "manifiesto.json"), "utf8")).previa === true;
15878
+ return JSON.parse(await readFile11(join27(salidaDir, "manifiesto.json"), "utf8")).previa === true;
15560
15879
  } catch {
15561
15880
  return false;
15562
15881
  }
15563
15882
  }
15564
15883
  async function checksFallidos(salidaDir) {
15565
15884
  try {
15566
- const rev = JSON.parse(await readFile10(join26(salidaDir, "revision.json"), "utf8"));
15885
+ const rev = JSON.parse(await readFile11(join27(salidaDir, "revision.json"), "utf8"));
15567
15886
  const malos = (rev.checks ?? []).filter((x2) => !x2.ok && x2.nivel === "requerido").map((x2) => x2.detalle ? `${x2.id} (${x2.detalle})` : x2.id);
15568
15887
  return malos.length ? malos.join(", ") : "sin detalle";
15569
15888
  } catch {
@@ -15572,8 +15891,8 @@ async function checksFallidos(salidaDir) {
15572
15891
  }
15573
15892
  async function piezasDelManifiesto(salidaDir) {
15574
15893
  try {
15575
- const m = JSON.parse(await readFile10(join26(salidaDir, "manifiesto.json"), "utf8"));
15576
- return (m.renders?.[0]?.archivos?.piezas ?? []).flatMap((p) => typeof p.ruta === "string" ? [join26(salidaDir, p.ruta)] : []);
15894
+ const m = JSON.parse(await readFile11(join27(salidaDir, "manifiesto.json"), "utf8"));
15895
+ return (m.renders?.[0]?.archivos?.piezas ?? []).flatMap((p) => typeof p.ruta === "string" ? [join27(salidaDir, p.ruta)] : []);
15577
15896
  } catch {
15578
15897
  return [];
15579
15898
  }
@@ -15634,7 +15953,7 @@ async function correrBucle(c, d) {
15634
15953
  let desactualizadoAvisado = false;
15635
15954
  while (!senal.aborted) {
15636
15955
  try {
15637
- const r2 = await procesarSiguiente(c, { api: d.api, log, senal, ...d.motor ? { motor: d.motor } : {}, ...d.avance ? { avance: d.avance } : {}, ...d.compositor ? { compositor: d.compositor } : {}, ...d.parecido ? { parecido: d.parecido } : {}, ...d.motorDir ? { motorDir: d.motorDir } : {}, ...d.bloqueo ? { bloqueo: d.bloqueo } : {}, ...d.agenteB ? { agenteB: d.agenteB } : {} });
15956
+ const r2 = await procesarSiguiente(c, { api: d.api, log, senal, ...d.motor ? { motor: d.motor } : {}, ...d.avance ? { avance: d.avance } : {}, ...d.compositor ? { compositor: d.compositor } : {}, ...d.guionista ? { guionista: d.guionista } : {}, ...d.parecido ? { parecido: d.parecido } : {}, ...d.motorDir ? { motorDir: d.motorDir } : {}, ...d.bloqueo ? { bloqueo: d.bloqueo } : {}, ...d.agenteB ? { agenteB: d.agenteB } : {} });
15638
15957
  if (r2.tipo === "ocupado") {
15639
15958
  if (!ocupadoAvisado) log(`motor ocupado en esta m\xE1quina, espero: ${r2.motivo}`);
15640
15959
  ocupadoAvisado = true;
@@ -15731,12 +16050,19 @@ Opciones:
15731
16050
  Si falla o se pasa del tiempo, el video sale con la composici\xF3n del motor y la bit\xE1cora lo dice.
15732
16051
  Tambi\xE9n con COMPOSITOR=claude.
15733
16052
  --compositor-tiempo <min> Tope del compositor por video, todas las vueltas (por defecto el de la familia: 15).
16053
+ --guionista Activa el guionista local (apagado por defecto; tambi\xE9n GUIONISTA=1): en los videos cuyo grupo tiene
16054
+ defaults.guionista "agente", Claude Code (\`claude -p\`, la cuenta de este equipo, sin llave de API) reescribe
16055
+ el guion antes de la voz: aislado en su carpeta, sin MCP, sin tu token, sin Bash ni red, con tope de tiempo
16056
+ y de presupuesto (US$${PRESUPUESTO_GUIONISTA_USD}). Si \`claude\` no est\xE1, falla o el resultado no valida, sale el guion original.
16057
+ Sin esta opci\xF3n, esos videos salen con su guion original y la bit\xE1cora lo dice.
16058
+ --guionista-tiempo <min> Tope del guionista por video (1 a 30; por defecto ${TOPE_GUIONISTA_MS / 6e4}).
15734
16059
  --una-vez Procesa lo que haya en la cola y sale.
15735
16060
  --voz-clonada Acepta la voz clonada del usuario (Chatterbox): renders finales, pruebas del laboratorio y purgas
15736
16061
  de su cach\xE9. En Docker usa la imagen del motor con etiqueta \xAB-clonacion\xBB (--motor-imagen-clonacion);
15737
16062
  con --modo local instala el extra \xABclonacion\xBB y usa MPS en Apple Silicon. Los pesos (~3 GB) se bajan
15738
16063
  la primera vez. Sin esta opci\xF3n, esos renders salen con Kokoro y la bit\xE1cora lo dice.
15739
- --motor-imagen-clonacion <imagen> Imagen del motor con voz clonada (p. ej. claqueta-motor:0.15.0-clonacion).
16064
+ --motor-imagen-clonacion <imagen> Imagen del motor con voz clonada (por defecto la p\xFAblica del motor ${MOTOR_VERSION_POR_DEFECTO}
16065
+ con el extra \xABclonacion\xBB: ${IMAGEN_CLONACION_POR_DEFECTO}).
15740
16066
 
15741
16067
  Agente B (CLA-189): si una sesi\xF3n de Claude Code con el MCP local est\xE1 esperando trabajo (~/Claqueta/presencia), el worker compone
15742
16068
  por pasos en ~/Claqueta/trabajo, deja el trabajo en ~/Claqueta/buzon/<video>.json, suelta el motor y espera su devoluci\xF3n; si nadie lo
@@ -15759,10 +16085,11 @@ function leerArgsWorker(argv) {
15759
16085
  else if (a === "--sin-actualizar-motor") op2.sinActualizarMotor = true;
15760
16086
  else if (a === "--sin-verificar") op2.sinVerificar = true;
15761
16087
  else if (a === "--voz-clonada") op2.vozClonada = true;
16088
+ else if (a === "--guionista") op2.guionista = true;
15762
16089
  else if (a === "--instalar-servicio") op2.accion = "instalar-servicio";
15763
16090
  else if (a === "--quitar-servicio") op2.accion = "quitar-servicio";
15764
16091
  else {
15765
- const m = /^--(url|agente|intervalo|motor-imagen|perfil-aws|si-falla-revision|modo|compositor|compositor-tiempo|motor-imagen-clonacion)(?:=(.*))?$/.exec(a);
16092
+ const m = /^--(url|agente|intervalo|motor-imagen|perfil-aws|si-falla-revision|modo|compositor|compositor-tiempo|guionista-tiempo|motor-imagen-clonacion)(?:=(.*))?$/.exec(a);
15766
16093
  if (!m) return { tipo: "error", mensaje: `Opci\xF3n desconocida de worker: ${a}. Usa --help.` };
15767
16094
  const valor = (m[2] ?? argv[++i])?.trim();
15768
16095
  if (!valor) return { tipo: "error", mensaje: `Falta el valor de --${m[1]}.` };
@@ -15774,6 +16101,10 @@ function leerArgsWorker(argv) {
15774
16101
  const n = Number(valor);
15775
16102
  if (!Number.isFinite(n) || n < 1 || n > 60) return { tipo: "error", mensaje: "--compositor-tiempo debe ser de 1 a 60 minutos." };
15776
16103
  op2.compositorTiempoMin = n;
16104
+ } else if (m[1] === "guionista-tiempo") {
16105
+ const n = Number(valor);
16106
+ if (!Number.isFinite(n) || n < 1 || n > 30) return { tipo: "error", mensaje: "--guionista-tiempo debe ser de 1 a 30 minutos." };
16107
+ op2.guionistaTiempoMin = n;
15777
16108
  } else if (m[1] === "modo") {
15778
16109
  if (valor !== "docker" && valor !== "local") return { tipo: "error", mensaje: '--modo debe ser "docker" o "local".' };
15779
16110
  op2.modo = valor;
@@ -15805,6 +16136,7 @@ function leerArgsWorker(argv) {
15805
16136
  if (op2.accion !== "correr" && op2.unaVez) return { tipo: "error", mensaje: "--una-vez no tiene sentido con el servicio (se reiniciar\xEDa en bucle)." };
15806
16137
  return { tipo: "worker", opciones: op2 };
15807
16138
  }
16139
+ var guionistaActivado = (o, env) => o.guionista === true || env["GUIONISTA"] === "1";
15808
16140
  function argsParaServicio(o) {
15809
16141
  return [
15810
16142
  ...o.url ? ["--url", o.url] : [],
@@ -15817,6 +16149,8 @@ function argsParaServicio(o) {
15817
16149
  ...o.siFallaRevision !== "adjuntar" ? ["--si-falla-revision", o.siFallaRevision] : [],
15818
16150
  ...o.compositor ? ["--compositor", o.compositor] : [],
15819
16151
  ...o.compositorTiempoMin ? ["--compositor-tiempo", String(o.compositorTiempoMin)] : [],
16152
+ ...o.guionista ? ["--guionista"] : [],
16153
+ ...o.guionistaTiempoMin ? ["--guionista-tiempo", String(o.guionistaTiempoMin)] : [],
15820
16154
  ...o.vozClonada ? ["--voz-clonada"] : [],
15821
16155
  ...o.motorImagenClonacion ? ["--motor-imagen-clonacion", o.motorImagenClonacion] : []
15822
16156
  ];
@@ -15834,7 +16168,7 @@ function configWorker(o, conexion, env, nombreEquipo, casa) {
15834
16168
  CLAQUETA_API_URL: conexion.url,
15835
16169
  WORKER_NOMBRE: o.agente ?? nombreEquipo,
15836
16170
  MOTOR_IMAGEN: o.motorImagen ?? IMAGEN_POR_DEFECTO,
15837
- WORKER_TRABAJO_DIR: env["WORKER_TRABAJO_DIR"] || join27(casa, ".cache", "claqueta", "trabajo"),
16171
+ WORKER_TRABAJO_DIR: env["WORKER_TRABAJO_DIR"] || join28(casa, ".cache", "claqueta", "trabajo"),
15838
16172
  WORKER_SONDEO_S: String(o.intervaloS ?? (env["WORKER_SONDEO_S"] || 10))
15839
16173
  });
15840
16174
  const imagenClonacion = o.motorImagenClonacion ?? (IMAGEN_CLONACION_POR_DEFECTO || void 0);
@@ -15852,8 +16186,8 @@ function configAgenteB(env, casa) {
15852
16186
  return (env[k] && Number.isFinite(n) && n > 0 ? n : def) * 6e4;
15853
16187
  };
15854
16188
  return {
15855
- presenciaDir: join27(casa, "Claqueta", "presencia"),
15856
- buzonDir: join27(casa, "Claqueta", "buzon"),
16189
+ presenciaDir: join28(casa, "Claqueta", "presencia"),
16190
+ buzonDir: join28(casa, "Claqueta", "buzon"),
15857
16191
  trabajoDir: carpetaBasePorDefecto(env, casa),
15858
16192
  tomaMs: min("WORKER_AGENTE_B_TOMA_MIN", 5),
15859
16193
  maxMs: min("WORKER_AGENTE_B_MAX_MIN", 45),
@@ -15878,7 +16212,7 @@ async function ejecutarWorker(o, d) {
15878
16212
  return 0;
15879
16213
  }
15880
16214
  if (!o.sinVerificar) {
15881
- const verificar = d.verificar ?? ((x2) => ejecutarDoctor({ json: false, ...x2.compositor ? { compositor: x2.compositor } : {}, ...x2.url ? { url: x2.url } : {}, ...x2.perfilAws ? { perfilAws: x2.perfilAws } : {}, ...x2.motorImagen ? { motorImagen: x2.motorImagen } : {}, modo: x2.modo }, { ...depsReales2(d.env), ejecutar, os: { plataforma: d.plataforma ?? process.platform, casa } }));
16215
+ const verificar = d.verificar ?? ((x2) => ejecutarDoctor({ json: false, ...x2.compositor ? { compositor: x2.compositor } : {}, ...guionistaActivado(x2, d.env) ? { guionista: true, guionistaActivado: true } : {}, ...x2.url ? { url: x2.url } : {}, ...x2.perfilAws ? { perfilAws: x2.perfilAws } : {}, ...x2.motorImagen ? { motorImagen: x2.motorImagen } : {}, modo: x2.modo }, { ...depsReales2(d.env), ejecutar, os: { plataforma: d.plataforma ?? process.platform, casa } }));
15882
16216
  let informe = await verificar(o);
15883
16217
  if (!informe.listo && d.env["CLAQUETA_SERVICIO"] === "1" && o.accion === "correr") {
15884
16218
  const dormir = d.dormir ?? dormirReal2;
@@ -15930,7 +16264,7 @@ ${formatearInforme(informe, false)}Corrige lo marcado con \u2716 o salta la veri
15930
16264
  { ejecutar, env: d.env, log }
15931
16265
  );
15932
16266
  if (o.vozClonada) {
15933
- if (!c.imagenClonacion) throw new Error("--voz-clonada en Docker necesita la imagen del motor con etiqueta \xAB-clonacion\xBB: p\xE1sala con --motor-imagen-clonacion (p. ej. una construida con \xABdocker build --target clonacion -t claqueta-motor:0.15.0-clonacion .\xBB en claqueta-motores), o usa --modo local.");
16267
+ if (!c.imagenClonacion) throw new Error(`--voz-clonada en Docker necesita la imagen del motor con etiqueta \xAB-clonacion\xBB: p\xE1sala con --motor-imagen-clonacion (p. ej. una construida con \xABdocker build --target clonacion -t claqueta-motor:${MOTOR_VERSION_POR_DEFECTO}-clonacion .\xBB en claqueta-motores), o usa --modo local.`);
15934
16268
  await prepararMotor(
15935
16269
  { imagen: c.imagenClonacion, perfilAws: o.perfilAws ?? d.env["CLAQUETA_AWS_PROFILE"] ?? PERFIL_AWS_POR_DEFECTO, perfilExplicito: Boolean(o.perfilAws), sinActualizar: o.sinActualizarMotor },
15936
16270
  { ejecutar, env: d.env, log }
@@ -15953,10 +16287,17 @@ ${formatearInforme(informe, false)}Corrige lo marcado con \u2716 o salta la veri
15953
16287
  ...o.compositorTiempoMin ? { topeMs: o.compositorTiempoMin * 6e4 } : {}
15954
16288
  });
15955
16289
  }
15956
- const parecido = d.crearMedidor ? d.crearMedidor(c) : c.modo === "local" ? c.comando ? crearMedidor({ modo: "local", python: join27(dirname11(c.comando), "python3"), scripts: join27(motorEmpaquetado, "scripts"), ffmpeg: buscarFfmpeg((cmd) => buscarEnPath(cmd, d.env))?.ffmpeg ?? "ffmpeg", env: c.entornoMotor ?? {} }, correrReal) : void 0 : crearMedidor({ modo: "docker", imagen: c.imagen, ...typeof process.getuid === "function" ? { usuario: `${process.getuid()}:${process.getgid()}` } : {} }, correrReal);
16290
+ const guionista = !guionistaActivado(o, d.env) ? void 0 : (d.crearGuionista ?? crearGuionista)({
16291
+ comando: d.env["GUIONISTA_COMANDO"] || "claude",
16292
+ topeMs: (o.guionistaTiempoMin ?? TOPE_GUIONISTA_MS / 6e4) * 6e4,
16293
+ presupuestoUsd: PRESUPUESTO_GUIONISTA_USD,
16294
+ env: d.env,
16295
+ motorDir: motorEmpaquetado
16296
+ });
16297
+ const parecido = d.crearMedidor ? d.crearMedidor(c) : c.modo === "local" ? c.comando ? crearMedidor({ modo: "local", python: join28(dirname12(c.comando), "python3"), scripts: join28(motorEmpaquetado, "scripts"), ffmpeg: buscarFfmpeg((cmd) => buscarEnPath(cmd, d.env))?.ffmpeg ?? "ffmpeg", env: c.entornoMotor ?? {} }, correrReal) : void 0 : crearMedidor({ modo: "docker", imagen: c.imagen, ...typeof process.getuid === "function" ? { usuario: `${process.getuid()}:${process.getgid()}` } : {} }, correrReal);
15957
16298
  const agenteB = configAgenteB(d.env, casa);
15958
- log(`worker ${c.nombre} \u2192 ${c.apiUrl} (${c.modo === "local" ? "motor local sin Docker" : `imagen ${c.imagen}`}, trabajo en ${c.trabajoDir}, si falla la revisi\xF3n: ${c.siFallaRevision}${c.vozClonada ? `, voz clonada${c.modo === "docker" ? ` (${c.imagenClonacion})` : ""}` : ""}${compositor ? `, compositor ${compositor.ejecutor}${o.compositorTiempoMin ? ` (tope ${o.compositorTiempoMin} min)` : ""}` : ""})`);
15959
- const salida = await (d.bucle ?? correrBucle)(c, { api, log, senal: parar.signal, ...avance ? { avance } : {}, ...compositor ? { compositor } : {}, ...parecido ? { parecido, motorDir: motorEmpaquetado } : {}, bloqueo: rutaBloqueoMotor(casa), ...agenteB ? { agenteB } : {} });
16299
+ log(`worker ${c.nombre} \u2192 ${c.apiUrl} (${c.modo === "local" ? "motor local sin Docker" : `imagen ${c.imagen}`}, trabajo en ${c.trabajoDir}, si falla la revisi\xF3n: ${c.siFallaRevision}${c.vozClonada ? `, voz clonada${c.modo === "docker" ? ` (${c.imagenClonacion})` : ""}` : ""}${compositor ? `, compositor ${compositor.ejecutor}${o.compositorTiempoMin ? ` (tope ${o.compositorTiempoMin} min)` : ""}` : ""}${guionista ? "" : ", sin guionista"})`);
16300
+ const salida = await (d.bucle ?? correrBucle)(c, { api, log, senal: parar.signal, ...avance ? { avance } : {}, ...compositor ? { compositor } : {}, ...guionista ? { guionista } : {}, ...parecido ? { parecido, motorDir: motorEmpaquetado } : {}, bloqueo: rutaBloqueoMotor(casa), ...agenteB ? { agenteB } : {} });
15960
16301
  log("worker detenido");
15961
16302
  return salida;
15962
16303
  }
@@ -16029,7 +16370,7 @@ function crearContextoLocal(o, d) {
16029
16370
  const simulado = d.env["CLAQUETA_MOTOR_COMANDO"]?.trim();
16030
16371
  let listo = null;
16031
16372
  const preparar = async () => {
16032
- if (simulado) return { modo: o.modo, imagen: imagen2, cache: join28(casa, ".cache", "claqueta", "simulado"), shm: "1g", comando: simulado };
16373
+ if (simulado) return { modo: o.modo, imagen: imagen2, cache: join29(casa, ".cache", "claqueta", "simulado"), shm: "1g", comando: simulado };
16033
16374
  if (o.modo === "local") {
16034
16375
  d.log(AVISO_SIN_AISLAMIENTO);
16035
16376
  const l = await prepararMotorLocal({ ejecutar, env: d.env, plataforma: process.platform, versionNode: process.version, casa, log: d.log, motorEmpaquetado: d.motorEmpaquetado });
@@ -16094,7 +16435,7 @@ import { createInterface as createInterface4 } from "node:readline";
16094
16435
 
16095
16436
  // src/local/herramientas-agente-b.ts
16096
16437
  import { hostname as hostname7 } from "node:os";
16097
- import { join as join29 } from "node:path";
16438
+ import { join as join30 } from "node:path";
16098
16439
  var esObjeto3 = (v2) => typeof v2 === "object" && v2 !== null && !Array.isArray(v2);
16099
16440
  var MINUTOS_POR_DEFECTO = 10;
16100
16441
  var MINUTOS_MAX = 120;
@@ -16184,7 +16525,7 @@ function resumirPedido(p) {
16184
16525
  if (Array.isArray(p["media"])) r2["media"] = p["media"].length;
16185
16526
  return r2;
16186
16527
  }
16187
- var absolutas = (carpeta2, v2) => esObjeto3(v2) ? Object.fromEntries(Object.entries(v2).map(([k, x2]) => [k, typeof x2 === "string" && !x2.startsWith("/") ? join29(carpeta2, x2) : x2])) : v2;
16528
+ var absolutas = (carpeta2, v2) => esObjeto3(v2) ? Object.fromEntries(Object.entries(v2).map(([k, x2]) => [k, typeof x2 === "string" && !x2.startsWith("/") ? join30(carpeta2, x2) : x2])) : v2;
16188
16529
  function motor(ctx) {
16189
16530
  const d = duenoActivo(ctx.bloqueo, { esVivo: ctx.esVivo ?? vivoPorDefecto2 });
16190
16531
  return d ? { libre: false, ocupado_con: d.paso, carpeta: d.carpeta, desde: d.desde, pid: d.pid } : { libre: true };
@@ -16392,9 +16733,9 @@ async function llamarHerramientaAgenteB(nombre, argumentos, ctx, l = {}) {
16392
16733
  }
16393
16734
 
16394
16735
  // src/local/herramientas-almacen.ts
16395
- import { existsSync as existsSync10 } from "node:fs";
16736
+ import { existsSync as existsSync11 } from "node:fs";
16396
16737
  import { homedir as homedir8 } from "node:os";
16397
- import { join as join30 } from "node:path";
16738
+ import { join as join31 } from "node:path";
16398
16739
  var esObjeto4 = (v2) => typeof v2 === "object" && v2 !== null && !Array.isArray(v2);
16399
16740
  function simuladorDelEsquema() {
16400
16741
  const de2 = (nombre) => Object.entries(core_exports).find(([k]) => k === nombre)?.[1];
@@ -16472,7 +16813,7 @@ ${JSON.stringify(detalles, null, 2)}` }] });
16472
16813
  function mp4(alm, v2) {
16473
16814
  for (const ver of alm.listarVersiones(v2.id).reverse()) {
16474
16815
  const r2 = ver.archivos["video"];
16475
- if (typeof r2 === "string" && existsSync10(r2)) return r2;
16816
+ if (typeof r2 === "string" && existsSync11(r2)) return r2;
16476
16817
  }
16477
16818
  return null;
16478
16819
  }
@@ -16516,7 +16857,7 @@ function llamarHerramientaAlmacen(nombre, argumentos, ctx) {
16516
16857
  version: video.versionActual,
16517
16858
  existia,
16518
16859
  avisos,
16519
- almacen: join30(alm.raiz, "videos", video.id),
16860
+ almacen: join31(alm.raiz, "videos", video.id),
16520
16861
  siguiente: existia ? "Ya exist\xEDa un video con ese solicitud_id; no se duplic\xF3." : "En la cola local: el worker local lo genera en segundo plano. Consulta con local_ver_video."
16521
16862
  });
16522
16863
  }
@@ -16565,7 +16906,7 @@ function llamarHerramientaAlmacen(nombre, argumentos, ctx) {
16565
16906
  if (!ruta) return fallo2("Falta \xABruta\xBB (ruta absoluta del archivo).");
16566
16907
  const etiquetas = Array.isArray(a["etiquetas"]) ? a["etiquetas"].filter((x2) => typeof x2 === "string") : void 0;
16567
16908
  const { asset, existia } = alm.registrarAsset({
16568
- ruta: ruta === "~" || ruta.startsWith("~/") ? join30(homedir8(), ruta.slice(1)) : ruta,
16909
+ ruta: ruta === "~" || ruta.startsWith("~/") ? join31(homedir8(), ruta.slice(1)) : ruta,
16569
16910
  ...cadena2("rol") ? { rol: cadena2("rol") } : {},
16570
16911
  ...cadena2("nombre") ? { nombre: cadena2("nombre") } : {},
16571
16912
  ...etiquetas ? { etiquetas } : {},
@@ -16577,7 +16918,7 @@ function llamarHerramientaAlmacen(nombre, argumentos, ctx) {
16577
16918
  const f = {};
16578
16919
  if (cadena2("rol")) f.rol = cadena2("rol");
16579
16920
  if (cadena2("tipo")) f.tipo = cadena2("tipo");
16580
- return texto4({ biblioteca: join30(alm.raiz, "biblioteca"), assets: alm.listarAssets(f).map((x2) => resumenAsset(alm, x2)) });
16921
+ return texto4({ biblioteca: join31(alm.raiz, "biblioteca"), assets: alm.listarAssets(f).map((x2) => resumenAsset(alm, x2)) });
16581
16922
  }
16582
16923
  }
16583
16924
  } catch (e7) {
@@ -16589,10 +16930,10 @@ function llamarHerramientaAlmacen(nombre, argumentos, ctx) {
16589
16930
 
16590
16931
  // src/local/herramientas-maquina.ts
16591
16932
  import { spawn as spawn5 } from "node:child_process";
16592
- import { closeSync as closeSync3, existsSync as existsSync11, mkdirSync as mkdirSync13, openSync as openSync3, readFileSync as readFileSync14, readSync, renameSync as renameSync6, rmSync as rmSync8, statSync as statSync9, writeFileSync as writeFileSync10 } from "node:fs";
16593
- import { join as join31 } from "node:path";
16933
+ import { closeSync as closeSync3, existsSync as existsSync12, mkdirSync as mkdirSync13, openSync as openSync3, readFileSync as readFileSync15, readSync, renameSync as renameSync6, rmSync as rmSync8, statSync as statSync9, writeFileSync as writeFileSync10 } from "node:fs";
16934
+ import { join as join32 } from "node:path";
16594
16935
  var esObjeto5 = (v2) => typeof v2 === "object" && v2 !== null && !Array.isArray(v2);
16595
- var rutasWorkerFondo = (casa) => ({ pid: join31(casa, ".cache", "claqueta", "worker.pid"), log: join31(casa, ".cache", "claqueta", "worker.log") });
16936
+ var rutasWorkerFondo = (casa) => ({ pid: join32(casa, ".cache", "claqueta", "worker.pid"), log: join32(casa, ".cache", "claqueta", "worker.log") });
16596
16937
  var TOPE_LOG = 5 * 1024 * 1024;
16597
16938
  var esquema3 = (props, requeridos = []) => ({ type: "object", properties: props, required: requeridos, additionalProperties: false });
16598
16939
  var PROPS_WORKER = {
@@ -16747,7 +17088,7 @@ var pidVivoReal2 = (pid) => {
16747
17088
  };
16748
17089
  function leerPidfile(ruta) {
16749
17090
  try {
16750
- const v2 = JSON.parse(readFileSync14(ruta, "utf8"));
17091
+ const v2 = JSON.parse(readFileSync15(ruta, "utf8"));
16751
17092
  if (esObjeto5(v2) && typeof v2["pid"] === "number" && Number.isInteger(v2["pid"]) && v2["pid"] > 1) return v2;
16752
17093
  } catch {
16753
17094
  }
@@ -16771,7 +17112,7 @@ async function estadoServicio(ctx) {
16771
17112
  const r2 = rutasServicio(ctx.casa);
16772
17113
  const base = { plist: r2.plist, log: r2.log };
16773
17114
  if (ctx.plataforma !== "darwin") return { aplica: false, instalado: false, cargado: false, corriendo: false, ...base };
16774
- const instalado = existsSync11(r2.plist);
17115
+ const instalado = existsSync12(r2.plist);
16775
17116
  const p = await ctx.ejecutar("launchctl", ["print", `gui/${ctx.uid}/${ETIQUETA}`]);
16776
17117
  if (p.codigo !== 0) return { aplica: true, instalado, cargado: false, corriendo: false, ...base };
16777
17118
  const pid = Number(/\bpid = (\d+)/.exec(p.stdout)?.[1]);
@@ -16779,7 +17120,7 @@ async function estadoServicio(ctx) {
16779
17120
  return { aplica: true, instalado, cargado: true, corriendo, ...Number.isInteger(pid) ? { pid } : {}, ...base };
16780
17121
  }
16781
17122
  function colaArchivo(ruta, n, filtro) {
16782
- if (!existsSync11(ruta)) return [];
17123
+ if (!existsSync12(ruta)) return [];
16783
17124
  const tam = statSync9(ruta).size;
16784
17125
  const leer2 = Math.min(tam, 512 * 1024);
16785
17126
  const buf = Buffer.alloc(leer2);
@@ -16842,9 +17183,9 @@ async function iniciar(ctx, a) {
16842
17183
  );
16843
17184
  }
16844
17185
  const r2 = rutasWorkerFondo(ctx.casa);
16845
- mkdirSync13(join31(ctx.casa, ".cache", "claqueta"), { recursive: true });
17186
+ mkdirSync13(join32(ctx.casa, ".cache", "claqueta"), { recursive: true });
16846
17187
  try {
16847
- if (existsSync11(r2.log) && statSync9(r2.log).size > TOPE_LOG) renameSync6(r2.log, `${r2.log}.1`);
17188
+ if (existsSync12(r2.log) && statSync9(r2.log).size > TOPE_LOG) renameSync6(r2.log, `${r2.log}.1`);
16848
17189
  } catch {
16849
17190
  }
16850
17191
  const ahora = (ctx.ahora?.() ?? /* @__PURE__ */ new Date()).toISOString();
@@ -16927,11 +17268,11 @@ async function verLog(ctx, a) {
16927
17268
  if (await fondoVivo(ctx)) ruta = fondoLog;
16928
17269
  else if ((await estadoServicio(ctx)).cargado) ruta = servLog;
16929
17270
  else {
16930
- const mt2 = (r2) => existsSync11(r2) ? statSync9(r2).mtimeMs : -1;
17271
+ const mt2 = (r2) => existsSync12(r2) ? statSync9(r2).mtimeMs : -1;
16931
17272
  ruta = mt2(servLog) > mt2(fondoLog) ? servLog : fondoLog;
16932
17273
  }
16933
17274
  }
16934
- if (!existsSync11(ruta)) return texto5(`No hay log en ${ruta} (el worker no ha corrido ${ruta === servLog ? "como servicio" : "en segundo plano"}).`);
17275
+ if (!existsSync12(ruta)) return texto5(`No hay log en ${ruta} (el worker no ha corrido ${ruta === servLog ? "como servicio" : "en segundo plano"}).`);
16935
17276
  const filtro = cad(a, "filtro");
16936
17277
  const s = secretos(ctx);
16937
17278
  const lineas = colaArchivo(ruta, n, filtro).map((l) => enmascarar(l, s));
@@ -17055,24 +17396,24 @@ async function llamarHerramientaMaquina(nombre, argumentos, ctx) {
17055
17396
  }
17056
17397
 
17057
17398
  // src/local/skill.ts
17058
- import { cpSync as cpSync2, existsSync as existsSync12, mkdirSync as mkdirSync14, readFileSync as readFileSync15 } from "node:fs";
17399
+ import { cpSync as cpSync2, existsSync as existsSync13, mkdirSync as mkdirSync14, readFileSync as readFileSync16 } from "node:fs";
17059
17400
  import { homedir as homedir9 } from "node:os";
17060
- import { join as join32, resolve as resolve11 } from "node:path";
17401
+ import { join as join33, resolve as resolve11 } from "node:path";
17061
17402
  var NOMBRE_SKILL = "claqueta-motor";
17062
17403
  var PROMPT_SKILL = "dirigir-motor";
17063
17404
  var ARCHIVOS_SKILL = ["SKILL.md", "reglas.md", "referencia.md"];
17064
17405
  var URI = (archivo2) => `claqueta://skill/${PROMPT_SKILL}/${archivo2}`;
17065
- var destinoPorDefecto = (casa = homedir9()) => join32(casa, ".claude", "skills", NOMBRE_SKILL);
17406
+ var destinoPorDefecto = (casa = homedir9()) => join33(casa, ".claude", "skills", NOMBRE_SKILL);
17066
17407
  function leer(dir, archivo2) {
17067
17408
  try {
17068
- return readFileSync15(join32(dir, archivo2), "utf8");
17409
+ return readFileSync16(join33(dir, archivo2), "utf8");
17069
17410
  } catch {
17070
17411
  return null;
17071
17412
  }
17072
17413
  }
17073
17414
  function recursosSkill(dir) {
17074
17415
  if (!dir) return [];
17075
- return ARCHIVOS_SKILL.filter((a) => existsSync12(join32(dir, a))).map((a) => ({
17416
+ return ARCHIVOS_SKILL.filter((a) => existsSync13(join33(dir, a))).map((a) => ({
17076
17417
  uri: URI(a),
17077
17418
  name: `${PROMPT_SKILL}/${a}`,
17078
17419
  description: a === "SKILL.md" ? "Skill \xABdirigir el motor\xBB: flujo del compositor con las herramientas local_*" : a === "reglas.md" ? "Reglas del compositor (comunes con el worker)" : "Herramientas locales, carpeta de trabajo y c\xF3mo leer el parecido",
@@ -17085,7 +17426,7 @@ function leerRecursoSkill(dir, uri) {
17085
17426
  return texto7 === null ? null : { uri, mimeType: "text/markdown", text: texto7 };
17086
17427
  }
17087
17428
  function promptsSkill(dir) {
17088
- if (!dir || !existsSync12(join32(dir, "SKILL.md"))) return [];
17429
+ if (!dir || !existsSync13(join33(dir, "SKILL.md"))) return [];
17089
17430
  return [{
17090
17431
  name: PROMPT_SKILL,
17091
17432
  description: "Dirige el motor local como compositor: componer \u2192 previa \u2192 fotogramas \u2192 parecido \u2192 editar (2 vueltas) \u2192 render \u2192 revisar.",
@@ -17114,11 +17455,11 @@ ${partes2.join("\n\n---\n\n")}` } }]
17114
17455
  };
17115
17456
  }
17116
17457
  function instalarSkill(origen, destino = destinoPorDefecto()) {
17117
- const faltan = ARCHIVOS_SKILL.filter((a) => !existsSync12(join32(origen, a)));
17458
+ const faltan = ARCHIVOS_SKILL.filter((a) => !existsSync13(join33(origen, a)));
17118
17459
  if (faltan.length) throw new Error(`el paquete no trae la skill completa en ${origen} (faltan ${faltan.join(", ")})`);
17119
17460
  const d = resolve11(destino);
17120
17461
  mkdirSync14(d, { recursive: true });
17121
- for (const a of ARCHIVOS_SKILL) cpSync2(join32(origen, a), join32(d, a));
17462
+ for (const a of ARCHIVOS_SKILL) cpSync2(join33(origen, a), join33(d, a));
17122
17463
  return { destino: d, archivos: [...ARCHIVOS_SKILL] };
17123
17464
  }
17124
17465
  var AYUDA_SKILL = `claqueta-mcp skill: la skill \xABdirigir el motor\xBB (la sesi\xF3n de Claude como compositor del motor local).
@@ -17397,8 +17738,8 @@ function servirDiagnostico(o) {
17397
17738
  import { createInterface as createInterface6 } from "node:readline";
17398
17739
 
17399
17740
  // src/local.ts
17400
- import { createHash as createHash7 } from "node:crypto";
17401
- import { readFile as readFile11, stat } from "node:fs/promises";
17741
+ import { createHash as createHash8 } from "node:crypto";
17742
+ import { readFile as readFile12, stat } from "node:fs/promises";
17402
17743
  import { homedir as homedir10 } from "node:os";
17403
17744
  import { basename as basename5, extname as extname5, resolve as resolve12 } from "node:path";
17404
17745
  var LIMITE_BASE64_BYTES = 3 * 1024 * 1024;
@@ -17452,11 +17793,11 @@ async function interceptarSubirMedia(msg, deps) {
17452
17793
  if (tam > limite) return falloGrande(id3, tam, limite);
17453
17794
  let datos;
17454
17795
  try {
17455
- datos = await readFile11(ruta);
17796
+ datos = await readFile12(ruta);
17456
17797
  } catch {
17457
17798
  return falloHerramienta(id3, `No se pudo leer el archivo local "${pedida}".`);
17458
17799
  }
17459
- const sha2563 = createHash7("sha256").update(datos).digest("hex");
17800
+ const sha2563 = createHash8("sha256").update(datos).digest("hex");
17460
17801
  const nombre = typeof args2["nombre"] === "string" && args2["nombre"] ? args2["nombre"] : basename5(ruta);
17461
17802
  const { ruta: _r2, url: _u2, ...resto } = args2;
17462
17803
  void _r2;
@@ -17490,7 +17831,7 @@ async function interceptarSubirMedia(msg, deps) {
17490
17831
  }, null, 2);
17491
17832
  return { tipo: "respuesta", mensaje: { jsonrpc: "2.0", id: id3, result: { content: [{ type: "text", text: texto8 }] } } };
17492
17833
  }
17493
- const md5 = createHash7("md5").update(datos).digest("hex");
17834
+ const md5 = createHash8("md5").update(datos).digest("hex");
17494
17835
  let putResp;
17495
17836
  try {
17496
17837
  putResp = await (deps.put ?? fetch)(permiso.url, { method: "PUT", headers: permiso.cabeceras ?? {}, body: datos });
@@ -17520,28 +17861,28 @@ function falloGrande(id3, tam, limite) {
17520
17861
  }
17521
17862
 
17522
17863
  // src/video-local.ts
17523
- import { createHash as createHash8 } from "node:crypto";
17524
- import { existsSync as existsSync13, readFileSync as readFileSync16, statSync as statSync10 } from "node:fs";
17864
+ import { createHash as createHash9 } from "node:crypto";
17865
+ import { existsSync as existsSync14, readFileSync as readFileSync17, statSync as statSync10 } from "node:fs";
17525
17866
  import { homedir as homedir11, hostname as hostname8 } from "node:os";
17526
- import { basename as basename6, isAbsolute as isAbsolute4, join as join33, resolve as resolve13 } from "node:path";
17867
+ import { basename as basename6, isAbsolute as isAbsolute4, join as join34, resolve as resolve13 } from "node:path";
17527
17868
  var esObjeto9 = (v2) => typeof v2 === "object" && v2 !== null && !Array.isArray(v2);
17528
17869
  var LIMITE_VIDEO_LOCAL_BYTES = 1024 * 1024 * 1024;
17529
17870
  var LIMITE_JSON = 256 * 1024;
17530
17871
  var RE_ID4 = /^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/;
17531
17872
  var RE_CLAVE = /^\d{1,5}x\d{1,5}$/;
17532
- var carpetaTrabajoBase = (env = process.env, casa = homedir11()) => resolve13(env["CLAQUETA_TRABAJO_DIR"]?.trim() || join33(casa, "Claqueta", "trabajo"));
17873
+ var carpetaTrabajoBase = (env = process.env, casa = homedir11()) => resolve13(env["CLAQUETA_TRABAJO_DIR"]?.trim() || join34(casa, "Claqueta", "trabajo"));
17533
17874
  var ErrorCarpeta = class extends Error {
17534
17875
  };
17535
17876
  function resolverCarpeta2(valor, base) {
17536
- const v2 = valor.trim() === "~" ? homedir11() : valor.trim().startsWith("~/") ? join33(homedir11(), valor.trim().slice(2)) : valor.trim();
17877
+ const v2 = valor.trim() === "~" ? homedir11() : valor.trim().startsWith("~/") ? join34(homedir11(), valor.trim().slice(2)) : valor.trim();
17537
17878
  if (isAbsolute4(v2)) return resolve13(v2);
17538
- if (RE_ID4.test(v2) && !v2.includes("..")) return join33(base, v2);
17879
+ if (RE_ID4.test(v2) && !v2.includes("..")) return join34(base, v2);
17539
17880
  throw new ErrorCarpeta(`carpeta \xAB${valor}\xBB no v\xE1lida: usa el id de la carpeta de trabajo (p. ej. 20261119-1530-billar) o una ruta absoluta`);
17540
17881
  }
17541
17882
  function leerJson5(ruta) {
17542
17883
  try {
17543
- if (!existsSync13(ruta) || statSync10(ruta).size > LIMITE_JSON * 8) return null;
17544
- const v2 = JSON.parse(readFileSync16(ruta, "utf8"));
17884
+ if (!existsSync14(ruta) || statSync10(ruta).size > LIMITE_JSON * 8) return null;
17885
+ const v2 = JSON.parse(readFileSync17(ruta, "utf8"));
17545
17886
  return esObjeto9(v2) ? v2 : null;
17546
17887
  } catch {
17547
17888
  return null;
@@ -17550,16 +17891,16 @@ function leerJson5(ruta) {
17550
17891
  var texto6 = (v2) => typeof v2 === "string" && v2.trim() ? v2.trim() : void 0;
17551
17892
  var numero2 = (v2) => typeof v2 === "number" && Number.isFinite(v2) ? v2 : void 0;
17552
17893
  function archivo(ruta) {
17553
- if (!existsSync13(ruta)) return null;
17894
+ if (!existsSync14(ruta)) return null;
17554
17895
  const st2 = statSync10(ruta);
17555
17896
  if (!st2.isFile() || st2.size === 0) return null;
17556
17897
  if (st2.size > LIMITE_VIDEO_LOCAL_BYTES) throw new ErrorCarpeta(`${ruta} pesa ${(st2.size / 1024 / 1024).toFixed(0)} MB y el puente sube hasta ${LIMITE_VIDEO_LOCAL_BYTES / 1024 / 1024} MB por archivo`);
17557
- return { ruta, bytes: st2.size, md5: createHash8("md5").update(readFileSync16(ruta)).digest("hex") };
17898
+ return { ruta, bytes: st2.size, md5: createHash9("md5").update(readFileSync17(ruta)).digest("hex") };
17558
17899
  }
17559
17900
  function bitacoraDe(carpeta2, pasos) {
17560
17901
  const salida = [];
17561
17902
  try {
17562
- const lineas = readFileSync16(join33(carpeta2, "bitacora.jsonl"), "utf8").split("\n").filter((l) => l.trim());
17903
+ const lineas = readFileSync17(join34(carpeta2, "bitacora.jsonl"), "utf8").split("\n").filter((l) => l.trim());
17563
17904
  for (const l of lineas.slice(-60)) {
17564
17905
  try {
17565
17906
  const e7 = JSON.parse(l);
@@ -17581,12 +17922,12 @@ function bitacoraDe(carpeta2, pasos) {
17581
17922
  });
17582
17923
  }
17583
17924
  function leerCarpetaLocal(carpeta2, opciones = {}) {
17584
- if (!existsSync13(carpeta2) || !statSync10(carpeta2).isDirectory()) throw new ErrorCarpeta(`no existe la carpeta ${carpeta2}`);
17585
- const final = join33(carpeta2, "final");
17586
- const manifiesto = leerJson5(join33(final, "manifiesto.json"));
17925
+ if (!existsSync14(carpeta2) || !statSync10(carpeta2).isDirectory()) throw new ErrorCarpeta(`no existe la carpeta ${carpeta2}`);
17926
+ const final = join34(carpeta2, "final");
17927
+ const manifiesto = leerJson5(join34(final, "manifiesto.json"));
17587
17928
  if (!manifiesto) throw new ErrorCarpeta(`${carpeta2} no tiene un video terminado (falta final/manifiesto.json): termina con local_render`);
17588
- const pasos = leerJson5(join33(carpeta2, "pasos.json"));
17589
- const pedido = leerJson5(join33(carpeta2, "fuentes", "pedido.json")) ?? leerJson5(join33(final, "fuentes", "pedido.json"));
17929
+ const pasos = leerJson5(join34(carpeta2, "pasos.json"));
17930
+ const pedido = leerJson5(join34(carpeta2, "fuentes", "pedido.json")) ?? leerJson5(join34(final, "fuentes", "pedido.json"));
17590
17931
  const rutas = {};
17591
17932
  const revisiones = {};
17592
17933
  const lista = Array.isArray(manifiesto["renders"]) ? manifiesto["renders"].filter(esObjeto9) : [];
@@ -17594,13 +17935,13 @@ function leerCarpetaLocal(carpeta2, opciones = {}) {
17594
17935
  for (const [i, r2] of lista.entries()) {
17595
17936
  const clave = `${numero2(r2["ancho"]) ?? ""}x${numero2(r2["alto"]) ?? ""}`;
17596
17937
  if (!RE_CLAVE.test(clave) || renders.some((x2) => x2["clave"] === clave)) continue;
17597
- const dir = join33(final, "renders", clave);
17598
- const video = archivo(join33(dir, "video.mp4")) ?? (i === 0 ? archivo(join33(final, "video.mp4")) : null);
17938
+ const dir = join34(final, "renders", clave);
17939
+ const video = archivo(join34(dir, "video.mp4")) ?? (i === 0 ? archivo(join34(final, "video.mp4")) : null);
17599
17940
  if (!video) throw new ErrorCarpeta(`falta el MP4 del render ${clave} en ${dir}: vuelve a correr local_render`);
17600
- const poster = archivo(join33(dir, "poster.jpg")) ?? (i === 0 ? archivo(join33(final, "poster.jpg")) : null);
17941
+ const poster = archivo(join34(dir, "poster.jpg")) ?? (i === 0 ? archivo(join34(final, "poster.jpg")) : null);
17601
17942
  rutas[`video:${clave}`] = video.ruta;
17602
17943
  if (poster) rutas[`poster:${clave}`] = poster.ruta;
17603
- const revisionJson = leerJson5(join33(dir, "revision.json"));
17944
+ const revisionJson = leerJson5(join34(dir, "revision.json"));
17604
17945
  if (revisionJson && Buffer.byteLength(JSON.stringify(revisionJson)) <= LIMITE_JSON) revisiones[clave] = revisionJson;
17605
17946
  const rev = esObjeto9(r2["revision"]) ? r2["revision"] : null;
17606
17947
  renders.push({
@@ -17615,14 +17956,14 @@ function leerCarpetaLocal(carpeta2, opciones = {}) {
17615
17956
  if (!renders.length) {
17616
17957
  const f = esObjeto9(manifiesto["formato"]) ? manifiesto["formato"] : {};
17617
17958
  const clave = `${numero2(f["ancho"]) ?? 1080}x${numero2(f["alto"]) ?? 1920}`;
17618
- const video = archivo(join33(final, "video.mp4"));
17959
+ const video = archivo(join34(final, "video.mp4"));
17619
17960
  if (!video) throw new ErrorCarpeta(`falta final/video.mp4 en ${carpeta2}: termina con local_render`);
17620
- const poster = archivo(join33(final, "poster.jpg"));
17961
+ const poster = archivo(join34(final, "poster.jpg"));
17621
17962
  rutas[`video:${clave}`] = video.ruta;
17622
17963
  if (poster) rutas[`poster:${clave}`] = poster.ruta;
17623
17964
  renders.push({ clave, video: { bytes: video.bytes, md5: video.md5 }, ...poster ? { poster: { bytes: poster.bytes, md5: poster.md5 } } : {} });
17624
17965
  }
17625
- const man = archivo(join33(final, "manifiesto.json"));
17966
+ const man = archivo(join34(final, "manifiesto.json"));
17626
17967
  rutas["manifiesto:null"] = man.ruta;
17627
17968
  const construccion = esObjeto9(manifiesto["construccion"]) ? construccionConVersion(manifiesto["construccion"], manifiesto) : null;
17628
17969
  const composicion = construccion && esObjeto9(construccion["composicion"]) ? construccion["composicion"] : null;
@@ -17661,18 +18002,18 @@ function leerCarpetaLocal(carpeta2, opciones = {}) {
17661
18002
  var RE_VID = /^vid_[A-Za-z0-9_-]{1,40}$/;
17662
18003
  function leerVideoDelAlmacen(raiz, vid, n, opciones = {}) {
17663
18004
  if (!RE_VID.test(vid)) throw new ErrorCarpeta(`video local \xAB${vid}\xBB no v\xE1lido: usa el id vid_\u2026 de local_listar_videos`);
17664
- const dir = join33(raiz, "videos", vid);
17665
- const video = leerJson5(join33(dir, "video.json"));
18005
+ const dir = join34(raiz, "videos", vid);
18006
+ const video = leerJson5(join34(dir, "video.json"));
17666
18007
  if (!video) throw new ErrorCarpeta(`no existe el video ${vid} en el almac\xE9n local ${raiz}`);
17667
18008
  const version2 = n ?? numero2(video["versionActual"]) ?? 1;
17668
- const ver = leerJson5(join33(dir, "versiones", String(version2), "version.json"));
18009
+ const ver = leerJson5(join34(dir, "versiones", String(version2), "version.json"));
17669
18010
  const carpeta2 = esObjeto9(ver?.["archivos"]) ? texto6(ver["archivos"]["carpeta_trabajo"]) : void 0;
17670
18011
  if (!carpeta2) throw new ErrorCarpeta(`la versi\xF3n ${version2} de ${vid} no tiene carpeta de trabajo: todav\xEDa no se genera`);
17671
18012
  const titulo = opciones.titulo ?? texto6(video["titulo"]);
17672
18013
  const l = leerCarpetaLocal(carpeta2, { ...titulo ? { titulo } : {}, ...opciones.maquina ? { maquina: opciones.maquina } : {} });
17673
18014
  const bitacora2 = [];
17674
18015
  try {
17675
- for (const linea of readFileSync16(join33(dir, "bitacora.jsonl"), "utf8").split("\n").filter((x2) => x2.trim()).slice(-60)) {
18016
+ for (const linea of readFileSync17(join34(dir, "bitacora.jsonl"), "utf8").split("\n").filter((x2) => x2.trim()).slice(-60)) {
17676
18017
  try {
17677
18018
  const e7 = JSON.parse(linea);
17678
18019
  const datos = esObjeto9(e7["datos"]) ? e7["datos"] : {};
@@ -17735,7 +18076,7 @@ async function interceptarSubirVideoLocal(msg, deps) {
17735
18076
  if (!ruta) return fallo3(id3, `El servidor pidi\xF3 un archivo que no est\xE1 en la carpeta (${s.archivo} ${s.render ?? ""}).`);
17736
18077
  let datos;
17737
18078
  try {
17738
- datos = readFileSync16(ruta);
18079
+ datos = readFileSync17(ruta);
17739
18080
  } catch {
17740
18081
  return fallo3(id3, `No se pudo leer ${ruta}.`);
17741
18082
  }