paperclip-plugin-autopilot-ops 0.1.41 → 0.1.42
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 +24 -1
- package/dist/ui/index.js +24 -1
- package/dist/worker.js +69 -7
- package/migrations/010_tablero_publicaciones.sql +15 -0
- package/package.json +1 -1
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.
|
|
3
|
+
var PLUGIN_VERSION = "0.1.42";
|
|
4
4
|
var DB_NAMESPACE_SLUG = "autopilot_ops";
|
|
5
5
|
var PAGE_ROUTE = "autopilot";
|
|
6
6
|
var TOOL_NAMES = {
|
|
@@ -16,6 +16,7 @@ var TOOL_NAMES = {
|
|
|
16
16
|
consultarIndicador: "ops_consultar_indicador",
|
|
17
17
|
publicarTablero: "ops_publicar_tablero",
|
|
18
18
|
listarTableros: "ops_listar_tableros",
|
|
19
|
+
proponerRetiroTablero: "ops_proponer_retiro_tablero",
|
|
19
20
|
listarReglas: "ops_listar_reglas",
|
|
20
21
|
informarPruebaRegla: "ops_informar_prueba_regla",
|
|
21
22
|
evaluarRentabilidad: "ops_evaluar_rentabilidad"
|
|
@@ -271,6 +272,12 @@ var manifest = {
|
|
|
271
272
|
displayName: "Listar tableros",
|
|
272
273
|
description: "Lista los tableros publicados para esta instituci\xF3n (clave, t\xEDtulo, per\xEDodo, fuentes, cu\xE1ndo se actualiz\xF3 y cu\xE1ntos widgets tiene). Usar antes de publicar para reutilizar la clave de un tablero existente en vez de crear uno nuevo. Solo lectura.",
|
|
273
274
|
parametersSchema: { type: "object", properties: {} }
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
name: TOOL_NAMES.proponerRetiroTablero,
|
|
278
|
+
displayName: "Proponer retirar un tablero",
|
|
279
|
+
description: "Cuando la direcci\xF3n pide dar de baja (eliminar, borrar, sacar) un tablero: propon\xE9 retirarlo con su clave y el id de la tarea. No lo retira: el portal le muestra la propuesta a la direcci\xF3n en ese pedido y lo retira una persona. No publiques nada en esa tarea.",
|
|
280
|
+
parametersSchema: { type: "object", properties: { clave: { type: "string" }, issueId: { type: "string" } }, required: ["clave", "issueId"] }
|
|
274
281
|
}
|
|
275
282
|
],
|
|
276
283
|
apiRoutes: [
|
|
@@ -402,6 +409,22 @@ var manifest = {
|
|
|
402
409
|
capability: "api.routes.register",
|
|
403
410
|
companyResolution: { from: "query", key: "companyId" }
|
|
404
411
|
},
|
|
412
|
+
{
|
|
413
|
+
routeKey: "tableros-publicaciones",
|
|
414
|
+
method: "GET",
|
|
415
|
+
path: "/tableros-publicaciones",
|
|
416
|
+
auth: "board",
|
|
417
|
+
capability: "api.routes.register",
|
|
418
|
+
companyResolution: { from: "query", key: "companyId" }
|
|
419
|
+
},
|
|
420
|
+
{
|
|
421
|
+
routeKey: "descartar-retiro-tablero",
|
|
422
|
+
method: "POST",
|
|
423
|
+
path: "/tableros/:clave/no-retirar",
|
|
424
|
+
auth: "board",
|
|
425
|
+
capability: "api.routes.register",
|
|
426
|
+
companyResolution: { from: "query", key: "companyId" }
|
|
427
|
+
},
|
|
405
428
|
{
|
|
406
429
|
routeKey: "tableros-retirados",
|
|
407
430
|
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.
|
|
11
|
+
var PLUGIN_VERSION = "0.1.42";
|
|
12
12
|
var DB_NAMESPACE_SLUG = "autopilot_ops";
|
|
13
13
|
var PAGE_ROUTE = "autopilot";
|
|
14
14
|
var TOOL_NAMES = {
|
|
@@ -24,6 +24,7 @@ var TOOL_NAMES = {
|
|
|
24
24
|
consultarIndicador: "ops_consultar_indicador",
|
|
25
25
|
publicarTablero: "ops_publicar_tablero",
|
|
26
26
|
listarTableros: "ops_listar_tableros",
|
|
27
|
+
proponerRetiroTablero: "ops_proponer_retiro_tablero",
|
|
27
28
|
listarReglas: "ops_listar_reglas",
|
|
28
29
|
informarPruebaRegla: "ops_informar_prueba_regla",
|
|
29
30
|
evaluarRentabilidad: "ops_evaluar_rentabilidad"
|
|
@@ -279,6 +280,12 @@ var manifest = {
|
|
|
279
280
|
displayName: "Listar tableros",
|
|
280
281
|
description: "Lista los tableros publicados para esta instituci\xF3n (clave, t\xEDtulo, per\xEDodo, fuentes, cu\xE1ndo se actualiz\xF3 y cu\xE1ntos widgets tiene). Usar antes de publicar para reutilizar la clave de un tablero existente en vez de crear uno nuevo. Solo lectura.",
|
|
281
282
|
parametersSchema: { type: "object", properties: {} }
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
name: TOOL_NAMES.proponerRetiroTablero,
|
|
286
|
+
displayName: "Proponer retirar un tablero",
|
|
287
|
+
description: "Cuando la direcci\xF3n pide dar de baja (eliminar, borrar, sacar) un tablero: propon\xE9 retirarlo con su clave y el id de la tarea. No lo retira: el portal le muestra la propuesta a la direcci\xF3n en ese pedido y lo retira una persona. No publiques nada en esa tarea.",
|
|
288
|
+
parametersSchema: { type: "object", properties: { clave: { type: "string" }, issueId: { type: "string" } }, required: ["clave", "issueId"] }
|
|
282
289
|
}
|
|
283
290
|
],
|
|
284
291
|
apiRoutes: [
|
|
@@ -410,6 +417,22 @@ var manifest = {
|
|
|
410
417
|
capability: "api.routes.register",
|
|
411
418
|
companyResolution: { from: "query", key: "companyId" }
|
|
412
419
|
},
|
|
420
|
+
{
|
|
421
|
+
routeKey: "tableros-publicaciones",
|
|
422
|
+
method: "GET",
|
|
423
|
+
path: "/tableros-publicaciones",
|
|
424
|
+
auth: "board",
|
|
425
|
+
capability: "api.routes.register",
|
|
426
|
+
companyResolution: { from: "query", key: "companyId" }
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
routeKey: "descartar-retiro-tablero",
|
|
430
|
+
method: "POST",
|
|
431
|
+
path: "/tableros/:clave/no-retirar",
|
|
432
|
+
auth: "board",
|
|
433
|
+
capability: "api.routes.register",
|
|
434
|
+
companyResolution: { from: "query", key: "companyId" }
|
|
435
|
+
},
|
|
413
436
|
{
|
|
414
437
|
routeKey: "tableros-retirados",
|
|
415
438
|
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.
|
|
39935
|
+
var PLUGIN_VERSION = "0.1.42";
|
|
39936
39936
|
var DB_NAMESPACE_SLUG = "autopilot_ops";
|
|
39937
39937
|
var PAGE_ROUTE = "autopilot";
|
|
39938
39938
|
var TOOL_NAMES = {
|
|
@@ -39948,6 +39948,7 @@ var TOOL_NAMES = {
|
|
|
39948
39948
|
consultarIndicador: "ops_consultar_indicador",
|
|
39949
39949
|
publicarTablero: "ops_publicar_tablero",
|
|
39950
39950
|
listarTableros: "ops_listar_tableros",
|
|
39951
|
+
proponerRetiroTablero: "ops_proponer_retiro_tablero",
|
|
39951
39952
|
listarReglas: "ops_listar_reglas",
|
|
39952
39953
|
informarPruebaRegla: "ops_informar_prueba_regla",
|
|
39953
39954
|
evaluarRentabilidad: "ops_evaluar_rentabilidad"
|
|
@@ -40203,6 +40204,12 @@ var manifest = {
|
|
|
40203
40204
|
displayName: "Listar tableros",
|
|
40204
40205
|
description: "Lista los tableros publicados para esta instituci\xF3n (clave, t\xEDtulo, per\xEDodo, fuentes, cu\xE1ndo se actualiz\xF3 y cu\xE1ntos widgets tiene). Usar antes de publicar para reutilizar la clave de un tablero existente en vez de crear uno nuevo. Solo lectura.",
|
|
40205
40206
|
parametersSchema: { type: "object", properties: {} }
|
|
40207
|
+
},
|
|
40208
|
+
{
|
|
40209
|
+
name: TOOL_NAMES.proponerRetiroTablero,
|
|
40210
|
+
displayName: "Proponer retirar un tablero",
|
|
40211
|
+
description: "Cuando la direcci\xF3n pide dar de baja (eliminar, borrar, sacar) un tablero: propon\xE9 retirarlo con su clave y el id de la tarea. No lo retira: el portal le muestra la propuesta a la direcci\xF3n en ese pedido y lo retira una persona. No publiques nada en esa tarea.",
|
|
40212
|
+
parametersSchema: { type: "object", properties: { clave: { type: "string" }, issueId: { type: "string" } }, required: ["clave", "issueId"] }
|
|
40206
40213
|
}
|
|
40207
40214
|
],
|
|
40208
40215
|
apiRoutes: [
|
|
@@ -40334,6 +40341,22 @@ var manifest = {
|
|
|
40334
40341
|
capability: "api.routes.register",
|
|
40335
40342
|
companyResolution: { from: "query", key: "companyId" }
|
|
40336
40343
|
},
|
|
40344
|
+
{
|
|
40345
|
+
routeKey: "tableros-publicaciones",
|
|
40346
|
+
method: "GET",
|
|
40347
|
+
path: "/tableros-publicaciones",
|
|
40348
|
+
auth: "board",
|
|
40349
|
+
capability: "api.routes.register",
|
|
40350
|
+
companyResolution: { from: "query", key: "companyId" }
|
|
40351
|
+
},
|
|
40352
|
+
{
|
|
40353
|
+
routeKey: "descartar-retiro-tablero",
|
|
40354
|
+
method: "POST",
|
|
40355
|
+
path: "/tableros/:clave/no-retirar",
|
|
40356
|
+
auth: "board",
|
|
40357
|
+
capability: "api.routes.register",
|
|
40358
|
+
companyResolution: { from: "query", key: "companyId" }
|
|
40359
|
+
},
|
|
40337
40360
|
{
|
|
40338
40361
|
routeKey: "tableros-retirados",
|
|
40339
40362
|
method: "GET",
|
|
@@ -47054,6 +47077,9 @@ function validarWidgets(entrada) {
|
|
|
47054
47077
|
}
|
|
47055
47078
|
}
|
|
47056
47079
|
});
|
|
47080
|
+
const tonos = (t6) => salida.filter((w) => w.tipo === "indicador" && w.tono === t6).length;
|
|
47081
|
+
if (tonos("ambar") > 1) problemas.push("como m\xE1ximo un indicador en \xE1mbar por tablero: el que pide una acci\xF3n de la direcci\xF3n (los dem\xE1s, neutro)");
|
|
47082
|
+
if (tonos("corte") > 1) problemas.push("como m\xE1ximo un indicador en rojo (corte) por tablero: solo lo urgente");
|
|
47057
47083
|
if (problemas.length) throw new OpsError("tablero_invalido", `el tablero no se puede publicar: ${problemas.slice(0, 12).join("; ")}${problemas.length > 12 ? ` (y ${problemas.length - 12} m\xE1s)` : ""}`, { problemas });
|
|
47058
47084
|
return salida;
|
|
47059
47085
|
}
|
|
@@ -47075,10 +47101,11 @@ function mapTablero(r) {
|
|
|
47075
47101
|
versiones: Number(r.versiones ?? 1),
|
|
47076
47102
|
createdAt: iso4(r.created_at),
|
|
47077
47103
|
updatedAt: iso4(r.updated_at),
|
|
47078
|
-
retirado: r.retirado_at ? { en: iso4(r.retirado_at), por: r.retirado_por ?? null, motivo: r.retirado_motivo ?? null } : null
|
|
47104
|
+
retirado: r.retirado_at ? { en: iso4(r.retirado_at), por: r.retirado_por ?? null, motivo: r.retirado_motivo ?? null } : null,
|
|
47105
|
+
retiroPropuesto: r.retiro_propuesto_issue ? { issueId: String(r.retiro_propuesto_issue), en: iso4(r.retiro_propuesto_at) } : null
|
|
47079
47106
|
};
|
|
47080
47107
|
}
|
|
47081
|
-
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";
|
|
47108
|
+
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, retiro_propuesto_issue, retiro_propuesto_at";
|
|
47082
47109
|
var CLAVE_RE2 = /^[a-z0-9][a-z0-9-]{1,60}$/;
|
|
47083
47110
|
async function listarTableros(ctx, companyId) {
|
|
47084
47111
|
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]);
|
|
@@ -47097,12 +47124,16 @@ async function publicarTablero(ctx, input2) {
|
|
|
47097
47124
|
const fuentes = arr(input2.fuentes).filter((f) => typeof f === "string" && f.trim()).map((f) => String(f).trim().slice(0, 120)).slice(0, 12);
|
|
47098
47125
|
const limpio = (v, max) => typeof v === "string" && v.trim() ? v.trim().slice(0, max) : null;
|
|
47099
47126
|
const previo = await leerTablero(ctx, input2.companyId, clave);
|
|
47127
|
+
if (previo?.retirado && input2.actor.tipo !== "humano") throw new OpsError("tablero_retirado", "la direcci\xF3n retir\xF3 este tablero: no se vuelve a publicar con la misma clave; si lo quieren de nuevo, lo vuelve a mostrar una persona desde el portal");
|
|
47128
|
+
input2 = { ...input2, pedido: typeof input2.pedido === "string" ? input2.pedido.replace(/\s*\((pedido (de|por)|pedido el)[^)]*\)\s*[.,;]?\s*$/i, "").trim() : input2.pedido };
|
|
47100
47129
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
47130
|
+
const registrar = async (version2) => ctx.db.execute(`INSERT INTO ${t5(ctx, "tablero_publicacion")} (id, company_id, clave, version, issue_id) VALUES ($1, $2, $3, $4, $5)`, [randomUUID5(), input2.companyId, clave, version2, input2.issueId ?? null]);
|
|
47101
47131
|
if (previo) {
|
|
47102
47132
|
await ctx.db.execute(
|
|
47103
47133
|
`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`,
|
|
47104
47134
|
[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]
|
|
47105
47135
|
);
|
|
47136
|
+
await registrar(previo.versiones + 1);
|
|
47106
47137
|
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 } });
|
|
47107
47138
|
return {
|
|
47108
47139
|
creado: false,
|
|
@@ -47114,10 +47145,11 @@ async function publicarTablero(ctx, input2) {
|
|
|
47114
47145
|
`INSERT INTO ${t5(ctx, "tablero")} (id, company_id, clave, titulo, descripcion, pedido, periodo, fuentes, widgets, agente_id, issue_id, publicado_por_tipo, publicado_por_id) VALUES ($1, $2, $3, $4, $5, $6, $7, $8::jsonb, $9::jsonb, $10, $11, $12, $13)`,
|
|
47115
47146
|
[id3, 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]
|
|
47116
47147
|
);
|
|
47148
|
+
await registrar(1);
|
|
47117
47149
|
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 } });
|
|
47118
47150
|
return {
|
|
47119
47151
|
creado: true,
|
|
47120
|
-
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 }
|
|
47152
|
+
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, retiroPropuesto: null }
|
|
47121
47153
|
};
|
|
47122
47154
|
}
|
|
47123
47155
|
async function listarTablerosRetirados(ctx, companyId) {
|
|
@@ -47130,7 +47162,7 @@ async function restaurarTablero(ctx, input2) {
|
|
|
47130
47162
|
const previo = CLAVE_RE2.test(clave) ? await leerTablero(ctx, input2.companyId, clave) : null;
|
|
47131
47163
|
if (!previo) throw new OpsError("tablero_inexistente", "no hay un tablero con esa clave");
|
|
47132
47164
|
if (!previo.retirado) return previo;
|
|
47133
|
-
await ctx.db.execute(`UPDATE ${t5(ctx, "tablero")} SET retirado_at = NULL, retirado_por = NULL, retirado_motivo = NULL WHERE company_id = $1 AND clave = $2`, [input2.companyId, clave]);
|
|
47165
|
+
await ctx.db.execute(`UPDATE ${t5(ctx, "tablero")} SET retirado_at = NULL, retirado_por = NULL, retirado_motivo = NULL, retiro_propuesto_issue = NULL, retiro_propuesto_at = NULL WHERE company_id = $1 AND clave = $2`, [input2.companyId, clave]);
|
|
47134
47166
|
await ctx.activity.log({ companyId: input2.companyId, message: `Autopilot Care: tablero \xAB${previo.titulo}\xBB vuelve a mostrarse (${clave})`, metadata: { clave, por: input2.actor.id } });
|
|
47135
47167
|
return { ...previo, retirado: null };
|
|
47136
47168
|
}
|
|
@@ -47141,9 +47173,27 @@ async function retirarTablero(ctx, input2) {
|
|
|
47141
47173
|
if (!previo) throw new OpsError("tablero_inexistente", "no hay un tablero con esa clave");
|
|
47142
47174
|
if (previo.retirado) return previo;
|
|
47143
47175
|
const motivo = typeof input2.motivo === "string" && input2.motivo.trim() ? input2.motivo.trim().slice(0, 300) : null;
|
|
47144
|
-
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]);
|
|
47176
|
+
await ctx.db.execute(`UPDATE ${t5(ctx, "tablero")} SET retirado_at = now(), retirado_por = $3, retirado_motivo = $4, retiro_propuesto_issue = NULL, retiro_propuesto_at = NULL WHERE company_id = $1 AND clave = $2`, [input2.companyId, clave, input2.actor.id, motivo]);
|
|
47145
47177
|
await ctx.activity.log({ companyId: input2.companyId, message: `Autopilot Care: tablero \xAB${previo.titulo}\xBB retirado (${clave})`, metadata: { clave, por: input2.actor.id, motivo } });
|
|
47146
|
-
return { ...previo, retirado: { en: (/* @__PURE__ */ new Date()).toISOString(), por: input2.actor.id, motivo } };
|
|
47178
|
+
return { ...previo, retirado: { en: (/* @__PURE__ */ new Date()).toISOString(), por: input2.actor.id, motivo }, retiroPropuesto: null };
|
|
47179
|
+
}
|
|
47180
|
+
async function proponerRetiroTablero(ctx, input2) {
|
|
47181
|
+
const clave = typeof input2.clave === "string" ? input2.clave.trim().toLowerCase() : "";
|
|
47182
|
+
const previo = CLAVE_RE2.test(clave) ? await leerTablero(ctx, input2.companyId, clave) : null;
|
|
47183
|
+
if (!previo) throw new OpsError("tablero_inexistente", "no hay un tablero con esa clave (revis\xE1 ops_listar_tableros)");
|
|
47184
|
+
if (previo.retirado) throw new OpsError("tablero_retirado", "ese tablero ya est\xE1 retirado");
|
|
47185
|
+
if (!input2.issueId) throw new OpsError("issue_requerido", "issueId: la tarea en la que la direcci\xF3n pidi\xF3 la baja");
|
|
47186
|
+
await ctx.db.execute(`UPDATE ${t5(ctx, "tablero")} SET retiro_propuesto_issue = $3, retiro_propuesto_at = now() WHERE company_id = $1 AND clave = $2`, [input2.companyId, clave, input2.issueId]);
|
|
47187
|
+
await ctx.activity.log({ companyId: input2.companyId, message: `Autopilot Care: se propone retirar el tablero \xAB${previo.titulo}\xBB (${clave})`, metadata: { clave, issueId: input2.issueId } });
|
|
47188
|
+
return { ...previo, retiroPropuesto: { issueId: input2.issueId, en: (/* @__PURE__ */ new Date()).toISOString() } };
|
|
47189
|
+
}
|
|
47190
|
+
async function descartarRetiroTablero(ctx, input2) {
|
|
47191
|
+
if (input2.actor.tipo !== "humano") throw new OpsError("actor_no_permitido", "lo decide una persona de la instituci\xF3n");
|
|
47192
|
+
await ctx.db.execute(`UPDATE ${t5(ctx, "tablero")} SET retiro_propuesto_issue = NULL, retiro_propuesto_at = NULL WHERE company_id = $1 AND clave = $2`, [input2.companyId, String(input2.clave).toLowerCase()]);
|
|
47193
|
+
}
|
|
47194
|
+
async function listarPublicaciones(ctx, companyId) {
|
|
47195
|
+
const rows = await ctx.db.query(`SELECT clave, version, issue_id, publicado_at FROM ${t5(ctx, "tablero_publicacion")} WHERE company_id = $1 ORDER BY publicado_at DESC LIMIT 500`, [companyId]);
|
|
47196
|
+
return rows.map((r) => ({ clave: String(r.clave), version: Number(r.version), issueId: r.issue_id ?? null, en: iso4(r.publicado_at) }));
|
|
47147
47197
|
}
|
|
47148
47198
|
|
|
47149
47199
|
// src/worker.ts
|
|
@@ -47352,6 +47402,11 @@ Transiciones registradas: ${detalle.transiciones.length}; acciones registradas:
|
|
|
47352
47402
|
data: { tablero: { ...r.tablero, widgets: void 0 }, creado: r.creado }
|
|
47353
47403
|
};
|
|
47354
47404
|
}));
|
|
47405
|
+
ctx.tools.register(TOOL_NAMES.proponerRetiroTablero, toolSchema(TOOL_NAMES.proponerRetiroTablero), async (params, runCtx) => conErrores(async () => {
|
|
47406
|
+
const p = obj(params);
|
|
47407
|
+
const r = await proponerRetiroTablero(ctx, { companyId: runCtx.companyId, clave: str3(p.clave) ?? "", issueId: uuidOrNull(p.issueId), actor: actorAgente(runCtx) });
|
|
47408
|
+
return { content: `Propuesta registrada: la direcci\xF3n ve en el portal \xABretirar ${r.titulo}\xBB en ese pedido y decide. No publiques nada en esa tarea; dejala en revisi\xF3n con el p\xE1rrafo \xABPara la direcci\xF3n\xBB.`, data: { clave: r.clave } };
|
|
47409
|
+
}));
|
|
47355
47410
|
ctx.tools.register(TOOL_NAMES.listarTableros, toolSchema(TOOL_NAMES.listarTableros), async (_params, runCtx) => conErrores(async () => {
|
|
47356
47411
|
const tableros = await listarTableros(ctx, runCtx.companyId);
|
|
47357
47412
|
const resumen = tableros.map((x) => ({ clave: x.clave, titulo: x.titulo, periodo: x.periodo, fuentes: x.fuentes, widgets: x.widgets.length, versiones: x.versiones, actualizadoEn: x.updatedAt, issueId: x.issueId }));
|
|
@@ -47479,6 +47534,13 @@ async function manejarApi(ctx, input2) {
|
|
|
47479
47534
|
const tb = await leerTablero(ctx, companyId, (input2.params.clave ?? "").toLowerCase());
|
|
47480
47535
|
return tb && !tb.retirado ? respuesta(200, tb) : respuesta(404, { error: "tablero_inexistente" });
|
|
47481
47536
|
}
|
|
47537
|
+
case "tableros-publicaciones":
|
|
47538
|
+
return respuesta(200, { publicaciones: await listarPublicaciones(ctx, companyId) });
|
|
47539
|
+
case "descartar-retiro-tablero": {
|
|
47540
|
+
if (actor.tipo !== "humano") return respuesta(403, { error: "actor_no_permitido", motivo: "lo decide una persona de la instituci\xF3n" });
|
|
47541
|
+
await descartarRetiroTablero(ctx, { companyId, clave: input2.params.clave ?? "", actor: { tipo: "humano", id: decididoPor ?? actor.id } });
|
|
47542
|
+
return respuesta(200, { ok: true });
|
|
47543
|
+
}
|
|
47482
47544
|
case "tableros-retirados":
|
|
47483
47545
|
return respuesta(200, { tableros: await listarTablerosRetirados(ctx, companyId) });
|
|
47484
47546
|
case "restaurar-tablero": {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
-- Cada publicación de un tablero, con la tarea (pedido) que la originó: así el portal sabe con certeza qué tablero salió
|
|
2
|
+
-- de qué pedido, sin deducirlo del texto.
|
|
3
|
+
CREATE TABLE plugin_autopilot_ops_1a68482ede.tablero_publicacion (
|
|
4
|
+
id uuid PRIMARY KEY,
|
|
5
|
+
company_id uuid NOT NULL REFERENCES public.companies(id) ON DELETE CASCADE,
|
|
6
|
+
clave text NOT NULL,
|
|
7
|
+
version integer NOT NULL,
|
|
8
|
+
issue_id uuid,
|
|
9
|
+
publicado_at timestamptz NOT NULL DEFAULT now()
|
|
10
|
+
);
|
|
11
|
+
CREATE INDEX tablero_publicacion_empresa ON plugin_autopilot_ops_1a68482ede.tablero_publicacion (company_id, publicado_at DESC);
|
|
12
|
+
|
|
13
|
+
-- El agente propone retirar un tablero (cuando la dirección se lo pide); retirarlo lo decide una persona.
|
|
14
|
+
ALTER TABLE plugin_autopilot_ops_1a68482ede.tablero ADD COLUMN retiro_propuesto_issue uuid;
|
|
15
|
+
ALTER TABLE plugin_autopilot_ops_1a68482ede.tablero ADD COLUMN retiro_propuesto_at timestamptz;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "paperclip-plugin-autopilot-ops",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.42",
|
|
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": [
|