claqueta-mcp 0.49.0 → 0.50.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 (2) hide show
  1. package/dist/cli.js +32 -7
  2. 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.49.0" : "dev";
86
+ var VERSION = true ? "0.50.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:
@@ -11842,6 +11842,7 @@ var ErrorApi = class extends Error {
11842
11842
  return this.estado === 409;
11843
11843
  }
11844
11844
  };
11845
+ var duracionValida = (d) => typeof d === "number" && Number.isFinite(d) && d > 0;
11845
11846
  var cabReclamo = (reclamo) => reclamo ? { "x-claqueta-reclamo": reclamo } : {};
11846
11847
  var PLAZO_TRANSFERENCIA_MS = 10 * 6e4;
11847
11848
  function conPlazo(senal, ms2 = PLAZO_TRANSFERENCIA_MS) {
@@ -11889,11 +11890,12 @@ function crearClienteApi(base, token, f = fetch) {
11889
11890
  const sub = await llamar("POST", `${base_rd}/url`, {}, rec);
11890
11891
  const put = await f(sub.url, { method: "PUT", headers: sub.cabeceras, body: bytes, signal });
11891
11892
  if (!put.ok) throw new ErrorApi(put.status, `la subida a S3 del render ${clave} fall\xF3 (HTTP ${put.status})`);
11892
- await llamar("POST", `${base_rd}/confirmar`, { nombre: basename3(ruta), ...revision ? { revision } : {} }, rec);
11893
+ await llamar("POST", `${base_rd}/confirmar`, { nombre: basename3(ruta), ...revision ? { revision } : {}, ...duracionValida(o.duracionS) ? { duracion_s: o.duracionS } : {} }, rec);
11893
11894
  return;
11894
11895
  }
11895
11896
  const form = new FormData();
11896
11897
  if (revision) form.append("revision", JSON.stringify(revision));
11898
+ if (duracionValida(o.duracionS)) form.append("duracion_s", String(o.duracionS));
11897
11899
  form.append("archivo", new Blob([bytes], { type: "video/mp4" }), basename3(ruta));
11898
11900
  await leer2(await f(`${base}${base_rd}`, { method: "POST", headers: cab(rec), body: form, signal }));
11899
11901
  }
@@ -11993,13 +11995,14 @@ function crearClienteApi(base, token, f = fetch) {
11993
11995
  const sub = await llamar("POST", `${base_mp4}/url`, {}, rec);
11994
11996
  const put = await f(sub.url, { method: "PUT", headers: sub.cabeceras, body: bytes, signal });
11995
11997
  if (!put.ok) throw new ErrorApi(put.status, `la subida a S3 fall\xF3 (HTTP ${put.status})`);
11996
- return llamar("POST", `${base_mp4}/confirmar`, { nombre: basename3(ruta), ...camposCosto(o), ...o.revision ? { revision: o.revision } : {}, ...o.renders?.length ? { renders: o.renders } : {} }, rec);
11998
+ return llamar("POST", `${base_mp4}/confirmar`, { nombre: basename3(ruta), ...camposCosto(o), ...o.revision ? { revision: o.revision } : {}, ...o.renders?.length ? { renders: o.renders } : {}, ...duracionValida(o.duracionS) ? { duracion_s: o.duracionS } : {} }, rec);
11997
11999
  }
11998
12000
  const form = new FormData();
11999
12001
  const costo = camposCosto(o);
12000
12002
  if (costo["costo_usd"] !== void 0) form.append("costo_usd", String(costo["costo_usd"]));
12001
12003
  if (costo["desglose"]) form.append("desglose", JSON.stringify(costo["desglose"]));
12002
12004
  if (o.revision) form.append("revision", JSON.stringify(o.revision));
12005
+ if (duracionValida(o.duracionS)) form.append("duracion_s", String(o.duracionS));
12003
12006
  if (o.renders?.length) form.append("renders", JSON.stringify(o.renders));
12004
12007
  form.append("archivo", new Blob([bytes], { type: "video/mp4" }), basename3(ruta));
12005
12008
  return leer2(await f(`${base}${base_mp4}`, { method: "POST", headers: cab(rec), body: form, signal }));
@@ -12487,6 +12490,15 @@ function buscarFfmpeg(buscar) {
12487
12490
  const ffprobe = uno("ffprobe");
12488
12491
  return ffmpeg && ffprobe ? { ffmpeg, ffprobe } : null;
12489
12492
  }
12493
+ async function medirDuracion(video, bins, correr) {
12494
+ try {
12495
+ const p = await correr(bins.ffprobe, ["-v", "error", "-show_entries", "format=duration", "-of", "csv=p=0", video], 3e4);
12496
+ const d = Number(p.stdout.trim().split("\n")[0]);
12497
+ return p.codigo === 0 && Number.isFinite(d) && d > 0 ? Math.round(d * 100) / 100 : void 0;
12498
+ } catch {
12499
+ return void 0;
12500
+ }
12501
+ }
12490
12502
  async function extraerFotogramas(video, destino, bins, correr, n = MAX_FOTOGRAMAS) {
12491
12503
  const p = await correr(bins.ffprobe, ["-v", "error", "-show_entries", "format=duration", "-of", "csv=p=0", video], 3e4);
12492
12504
  const duracion2 = Number(p.stdout.trim().split("\n")[0]);
@@ -14610,7 +14622,7 @@ async function leerManifiesto(salidaDir, log = () => {
14610
14622
  crudo = JSON.parse(await readFile7(join22(salidaDir, "manifiesto.json"), "utf8"));
14611
14623
  if (!crudo || typeof crudo !== "object") throw new Error("no es un objeto");
14612
14624
  } catch {
14613
- return { renders: [], costo: void 0, tiempos: void 0, construccion: void 0, edicion: void 0 };
14625
+ return { renders: [], costo: void 0, tiempos: void 0, construccion: void 0, edicion: void 0, duracionS: void 0 };
14614
14626
  }
14615
14627
  const t = crudo["tiempos_s"];
14616
14628
  const c = crudo["construccion"];
@@ -14619,7 +14631,8 @@ async function leerManifiesto(salidaDir, log = () => {
14619
14631
  costo: leerCosto(crudo["costos_usd"]),
14620
14632
  tiempos: t && typeof t === "object" && !Array.isArray(t) ? t : void 0,
14621
14633
  construccion: c && typeof c === "object" && !Array.isArray(c) ? construccionConVersion(c, crudo) : void 0,
14622
- edicion: leerEdicion(crudo["edicion"])
14634
+ edicion: leerEdicion(crudo["edicion"]),
14635
+ duracionS: typeof crudo["duracion_s"] === "number" && Number.isFinite(crudo["duracion_s"]) && crudo["duracion_s"] > 0 ? dosDecimales(crudo["duracion_s"]) || void 0 : void 0
14623
14636
  };
14624
14637
  }
14625
14638
  function leerEdicion(e7) {
@@ -15338,6 +15351,16 @@ async function trabajarVideo(c, d, r2, turno, buzon) {
15338
15351
  if (sub instanceof Error) return await fallar("piezas", `no se pudieron subir las piezas: ${sub.message}`, null, true);
15339
15352
  const transf = { senal: parar.signal, ...r2.reclamo ? { reclamo: r2.reclamo } : {} };
15340
15353
  const renders = manifiesto.renders;
15354
+ const duracionDe = async (ruta) => {
15355
+ if (manifiesto.duracionS) return manifiesto.duracionS;
15356
+ try {
15357
+ if (d.medirDuracion) return await d.medirDuracion(ruta);
15358
+ const bins = buscarFfmpeg((cmd) => buscarEnPath(cmd, process.env));
15359
+ return bins ? await medirDuracion(ruta, bins, correrReal) : void 0;
15360
+ } catch {
15361
+ return void 0;
15362
+ }
15363
+ };
15341
15364
  const total = Math.max(renders.length, 1);
15342
15365
  const subidos = [];
15343
15366
  for (const [k, render] of renders.slice(1).entries()) {
@@ -15349,7 +15372,8 @@ async function trabajarVideo(c, d, r2, turno, buzon) {
15349
15372
  await avisar(aviso, "advertencia");
15350
15373
  }
15351
15374
  await avisar(`subiendo render ${k + 2}/${total} (${render.etiqueta})`, void 0, { render: render.etiqueta, indice: k + 2, total, destinos: render.destinos });
15352
- const adj2 = await reintentar(`render ${render.etiqueta}`, () => d.api.adjuntarRender(id3, r2.version, render.etiqueta, ruta, revisionDe(render), transf), dormir, log, parar.signal);
15375
+ const durRender = await duracionDe(ruta);
15376
+ const adj2 = await reintentar(`render ${render.etiqueta}`, () => d.api.adjuntarRender(id3, r2.version, render.etiqueta, ruta, revisionDe(render), { ...transf, ...durRender ? { duracionS: durRender } : {} }), dormir, log, parar.signal);
15353
15377
  if (adj2 === "cancelado") return { tipo: "cancelado", videoId: id3 };
15354
15378
  if (adj2 instanceof Error) return await fallar("revision", `no se pudo adjuntar el render ${render.etiqueta}: ${adj2.message}`, null, true);
15355
15379
  subidos.push(render.etiqueta);
@@ -15377,7 +15401,8 @@ async function trabajarVideo(c, d, r2, turno, buzon) {
15377
15401
  }
15378
15402
  const principal = renders[0];
15379
15403
  if (total > 1) await avisar(`subiendo render 1/${total} (${principal.etiqueta})`, void 0, { render: principal.etiqueta, indice: 1, total, destinos: principal.destinos });
15380
- const opciones = { ...transf, ...manifiesto.costo ?? {}, ...principal && revisionDe(principal) ? { revision: revisionDe(principal) } : {}, ...subidos.length ? { renders: subidos } : {} };
15404
+ const durPrincipal = await duracionDe(mp42);
15405
+ const opciones = { ...transf, ...durPrincipal ? { duracionS: durPrincipal } : {}, ...manifiesto.costo ?? {}, ...principal && revisionDe(principal) ? { revision: revisionDe(principal) } : {}, ...subidos.length ? { renders: subidos } : {} };
15381
15406
  const adj = await reintentar("MP4", () => d.api.adjuntarMp4(id3, r2.version, mp42, opciones), dormir, log, parar.signal);
15382
15407
  if (adj === "cancelado") return { tipo: "cancelado", videoId: id3 };
15383
15408
  if (adj instanceof Error) return await fallar("revision", `no se pudo adjuntar el MP4: ${adj.message}`, null, true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claqueta-mcp",
3
- "version": "0.49.0",
3
+ "version": "0.50.0",
4
4
  "description": "Cliente de Claqueta: puente stdio para el servidor MCP remoto, comando setup y worker de la cola. Úsalo con npx en Claude Desktop o Claude Code.",
5
5
  "type": "module",
6
6
  "bin": {