paperclip-plugin-autopilot-ops 0.1.39 → 0.1.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/manifest.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/manifest.ts
2
2
  var PLUGIN_ID = "alephoo.autopilot-ops";
3
- var PLUGIN_VERSION = "0.1.39";
3
+ var PLUGIN_VERSION = "0.1.40";
4
4
  var DB_NAMESPACE_SLUG = "autopilot_ops";
5
5
  var PAGE_ROUTE = "autopilot";
6
6
  var TOOL_NAMES = {
@@ -402,6 +402,14 @@ var manifest = {
402
402
  capability: "api.routes.register",
403
403
  companyResolution: { from: "query", key: "companyId" }
404
404
  },
405
+ {
406
+ routeKey: "retirar-tablero",
407
+ method: "POST",
408
+ path: "/tableros/:clave/retirar",
409
+ auth: "board",
410
+ capability: "api.routes.register",
411
+ companyResolution: { from: "query", key: "companyId" }
412
+ },
405
413
  {
406
414
  routeKey: "reglas",
407
415
  method: "GET",
package/dist/ui/index.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
 
9
9
  // src/manifest.ts
10
10
  var PLUGIN_ID = "alephoo.autopilot-ops";
11
- var PLUGIN_VERSION = "0.1.39";
11
+ var PLUGIN_VERSION = "0.1.40";
12
12
  var DB_NAMESPACE_SLUG = "autopilot_ops";
13
13
  var PAGE_ROUTE = "autopilot";
14
14
  var TOOL_NAMES = {
@@ -410,6 +410,14 @@ var manifest = {
410
410
  capability: "api.routes.register",
411
411
  companyResolution: { from: "query", key: "companyId" }
412
412
  },
413
+ {
414
+ routeKey: "retirar-tablero",
415
+ method: "POST",
416
+ path: "/tableros/:clave/retirar",
417
+ auth: "board",
418
+ capability: "api.routes.register",
419
+ companyResolution: { from: "query", key: "companyId" }
420
+ },
413
421
  {
414
422
  routeKey: "reglas",
415
423
  method: "GET",
package/dist/worker.js CHANGED
@@ -39932,7 +39932,7 @@ function startWorkerRpcHost(options) {
39932
39932
 
39933
39933
  // src/manifest.ts
39934
39934
  var PLUGIN_ID = "alephoo.autopilot-ops";
39935
- var PLUGIN_VERSION = "0.1.39";
39935
+ var PLUGIN_VERSION = "0.1.40";
39936
39936
  var DB_NAMESPACE_SLUG = "autopilot_ops";
39937
39937
  var PAGE_ROUTE = "autopilot";
39938
39938
  var TOOL_NAMES = {
@@ -40334,6 +40334,14 @@ var manifest = {
40334
40334
  capability: "api.routes.register",
40335
40335
  companyResolution: { from: "query", key: "companyId" }
40336
40336
  },
40337
+ {
40338
+ routeKey: "retirar-tablero",
40339
+ method: "POST",
40340
+ path: "/tableros/:clave/retirar",
40341
+ auth: "board",
40342
+ capability: "api.routes.register",
40343
+ companyResolution: { from: "query", key: "companyId" }
40344
+ },
40337
40345
  {
40338
40346
  routeKey: "reglas",
40339
40347
  method: "GET",
@@ -47049,13 +47057,14 @@ function mapTablero(r) {
47049
47057
  publicadoPorId: r.publicado_por_id ?? null,
47050
47058
  versiones: Number(r.versiones ?? 1),
47051
47059
  createdAt: iso4(r.created_at),
47052
- updatedAt: iso4(r.updated_at)
47060
+ updatedAt: iso4(r.updated_at),
47061
+ retirado: r.retirado_at ? { en: iso4(r.retirado_at), por: r.retirado_por ?? null, motivo: r.retirado_motivo ?? null } : null
47053
47062
  };
47054
47063
  }
47055
- var COLS2 = "id, company_id, clave, titulo, descripcion, pedido, periodo, fuentes, widgets, agente_id, issue_id, publicado_por_tipo, publicado_por_id, versiones, created_at, updated_at";
47064
+ var COLS2 = "id, company_id, clave, titulo, descripcion, pedido, periodo, fuentes, widgets, agente_id, issue_id, publicado_por_tipo, publicado_por_id, versiones, created_at, updated_at, retirado_at, retirado_por, retirado_motivo";
47056
47065
  var CLAVE_RE2 = /^[a-z0-9][a-z0-9-]{1,60}$/;
47057
47066
  async function listarTableros(ctx, companyId) {
47058
- const rows = await ctx.db.query(`SELECT ${COLS2} FROM ${t5(ctx, "tablero")} WHERE company_id = $1 ORDER BY updated_at DESC`, [companyId]);
47067
+ const rows = await ctx.db.query(`SELECT ${COLS2} FROM ${t5(ctx, "tablero")} WHERE company_id = $1 AND retirado_at IS NULL ORDER BY updated_at DESC`, [companyId]);
47059
47068
  return rows.map(mapTablero);
47060
47069
  }
47061
47070
  async function leerTablero(ctx, companyId, clave) {
@@ -47074,13 +47083,13 @@ async function publicarTablero(ctx, input2) {
47074
47083
  const now = (/* @__PURE__ */ new Date()).toISOString();
47075
47084
  if (previo) {
47076
47085
  await ctx.db.execute(
47077
- `UPDATE ${t5(ctx, "tablero")} SET titulo = $3, descripcion = $4, pedido = COALESCE($5, pedido), periodo = $6, fuentes = $7::jsonb, widgets = $8::jsonb, agente_id = COALESCE($9, agente_id), issue_id = COALESCE($10, issue_id), publicado_por_tipo = $11, publicado_por_id = $12, versiones = versiones + 1, updated_at = now() WHERE company_id = $1 AND clave = $2`,
47086
+ `UPDATE ${t5(ctx, "tablero")} SET titulo = $3, descripcion = $4, pedido = COALESCE($5, pedido), periodo = $6, fuentes = $7::jsonb, widgets = $8::jsonb, agente_id = COALESCE($9, agente_id), issue_id = COALESCE($10, issue_id), publicado_por_tipo = $11, publicado_por_id = $12, versiones = versiones + 1, updated_at = now(), retirado_at = NULL, retirado_por = NULL, retirado_motivo = NULL WHERE company_id = $1 AND clave = $2`,
47078
47087
  [input2.companyId, clave, titulo, limpio(input2.descripcion, 600), limpio(input2.pedido, 1e3), limpio(input2.periodo, 80), JSON.stringify(fuentes), JSON.stringify(widgets), input2.agenteId ?? null, input2.issueId ?? null, input2.actor.tipo, input2.actor.id]
47079
47088
  );
47080
47089
  await ctx.activity.log({ companyId: input2.companyId, message: `Autopilot Care: tablero \xAB${titulo}\xBB actualizado (${clave}, versi\xF3n ${previo.versiones + 1})`, metadata: { clave, widgets: widgets.length, agentId: input2.agenteId ?? null, issueId: input2.issueId ?? null } });
47081
47090
  return {
47082
47091
  creado: false,
47083
- tablero: { ...previo, titulo, descripcion: limpio(input2.descripcion, 600), pedido: limpio(input2.pedido, 1e3) ?? previo.pedido, periodo: limpio(input2.periodo, 80), fuentes, widgets, agenteId: input2.agenteId ?? previo.agenteId, issueId: input2.issueId ?? previo.issueId, publicadoPorTipo: input2.actor.tipo, publicadoPorId: input2.actor.id, versiones: previo.versiones + 1, updatedAt: now }
47092
+ tablero: { ...previo, retirado: null, titulo, descripcion: limpio(input2.descripcion, 600), pedido: limpio(input2.pedido, 1e3) ?? previo.pedido, periodo: limpio(input2.periodo, 80), fuentes, widgets, agenteId: input2.agenteId ?? previo.agenteId, issueId: input2.issueId ?? previo.issueId, publicadoPorTipo: input2.actor.tipo, publicadoPorId: input2.actor.id, versiones: previo.versiones + 1, updatedAt: now }
47084
47093
  };
47085
47094
  }
47086
47095
  const id3 = randomUUID5();
@@ -47091,9 +47100,20 @@ async function publicarTablero(ctx, input2) {
47091
47100
  await ctx.activity.log({ companyId: input2.companyId, message: `Autopilot Care: tablero \xAB${titulo}\xBB publicado (${clave})`, metadata: { clave, widgets: widgets.length, agentId: input2.agenteId ?? null, issueId: input2.issueId ?? null } });
47092
47101
  return {
47093
47102
  creado: true,
47094
- tablero: { id: id3, companyId: input2.companyId, clave, titulo, descripcion: limpio(input2.descripcion, 600), pedido: limpio(input2.pedido, 1e3), periodo: limpio(input2.periodo, 80), fuentes, widgets, agenteId: input2.agenteId ?? null, issueId: input2.issueId ?? null, publicadoPorTipo: input2.actor.tipo, publicadoPorId: input2.actor.id, versiones: 1, createdAt: now, updatedAt: now }
47103
+ tablero: { id: id3, companyId: input2.companyId, clave, titulo, descripcion: limpio(input2.descripcion, 600), pedido: limpio(input2.pedido, 1e3), periodo: limpio(input2.periodo, 80), fuentes, widgets, agenteId: input2.agenteId ?? null, issueId: input2.issueId ?? null, publicadoPorTipo: input2.actor.tipo, publicadoPorId: input2.actor.id, versiones: 1, createdAt: now, updatedAt: now, retirado: null }
47095
47104
  };
47096
47105
  }
47106
+ async function retirarTablero(ctx, input2) {
47107
+ if (input2.actor.tipo !== "humano") throw new OpsError("actor_no_permitido", "un tablero lo da de baja una persona de la instituci\xF3n");
47108
+ const clave = typeof input2.clave === "string" ? input2.clave.trim().toLowerCase() : "";
47109
+ const previo = CLAVE_RE2.test(clave) ? await leerTablero(ctx, input2.companyId, clave) : null;
47110
+ if (!previo) throw new OpsError("tablero_inexistente", "no hay un tablero con esa clave");
47111
+ if (previo.retirado) return previo;
47112
+ const motivo = typeof input2.motivo === "string" && input2.motivo.trim() ? input2.motivo.trim().slice(0, 300) : null;
47113
+ await ctx.db.execute(`UPDATE ${t5(ctx, "tablero")} SET retirado_at = now(), retirado_por = $3, retirado_motivo = $4 WHERE company_id = $1 AND clave = $2`, [input2.companyId, clave, input2.actor.id, motivo]);
47114
+ await ctx.activity.log({ companyId: input2.companyId, message: `Autopilot Care: tablero \xAB${previo.titulo}\xBB retirado (${clave})`, metadata: { clave, por: input2.actor.id, motivo } });
47115
+ return { ...previo, retirado: { en: (/* @__PURE__ */ new Date()).toISOString(), por: input2.actor.id, motivo } };
47116
+ }
47097
47117
 
47098
47118
  // src/worker.ts
47099
47119
  function str3(v) {
@@ -47426,7 +47446,11 @@ async function manejarApi(ctx, input2) {
47426
47446
  return respuesta(200, { tableros: await listarTableros(ctx, companyId) });
47427
47447
  case "tablero-publicado": {
47428
47448
  const tb = await leerTablero(ctx, companyId, (input2.params.clave ?? "").toLowerCase());
47429
- return tb ? respuesta(200, tb) : respuesta(404, { error: "tablero_inexistente" });
47449
+ return tb && !tb.retirado ? respuesta(200, tb) : respuesta(404, { error: "tablero_inexistente" });
47450
+ }
47451
+ case "retirar-tablero": {
47452
+ if (actor.tipo !== "humano") return respuesta(403, { error: "actor_no_permitido", motivo: "un tablero lo da de baja una persona de la instituci\xF3n" });
47453
+ return respuesta(200, { tablero: await retirarTablero(ctx, { companyId, clave: input2.params.clave ?? "", motivo: str3(body.motivo), actor: { tipo: "humano", id: decididoPor ?? actor.id } }) });
47430
47454
  }
47431
47455
  case "reglas":
47432
47456
  return respuesta(200, { reglas: await listarReglas(ctx, companyId, { workflow: qs("workflow") ?? "demanda_pendiente", estado: qs("estado") }) });
@@ -0,0 +1,5 @@
1
+ -- Un tablero que la dirección da de baja deja de mostrarse, pero no se borra: queda quién lo retiró, cuándo y por qué.
2
+ -- Si el agente vuelve a publicar la misma clave (otro pedido), vuelve a estar a la vista.
3
+ ALTER TABLE plugin_autopilot_ops_1a68482ede.tablero ADD COLUMN retirado_at timestamptz;
4
+ ALTER TABLE plugin_autopilot_ops_1a68482ede.tablero ADD COLUMN retirado_por text;
5
+ ALTER TABLE plugin_autopilot_ops_1a68482ede.tablero ADD COLUMN retirado_motivo text;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paperclip-plugin-autopilot-ops",
3
- "version": "0.1.39",
3
+ "version": "0.1.40",
4
4
  "type": "module",
5
5
  "description": "Autopilot Care · operación autónoma gobernada para instituciones de salud: workflows determinísticos, validaciones, registro de negocio, políticas (observa/propone/ejecuta/corte) y tablero del director, como plugin de Paperclip.",
6
6
  "files": [