Agregar herramienta para gestionar transferencias de repos
- Nueva herramienta gitea_transfer_manage con 3 acciones: - status: Ver estado de transferencias pendientes - accept: Aceptar transferencia como destinatario - reject: Rechazar/cancelar transferencia como owner actual - Notificaciones claras para cada acción - Manejo de errores mejorado
This commit is contained in:
@@ -481,6 +481,90 @@ server.registerTool(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// ==================== HERRAMIENTA 7: gitea_transfer_manage ====================
|
||||||
|
server.registerTool(
|
||||||
|
'gitea_transfer_manage',
|
||||||
|
{
|
||||||
|
title: 'Gestionar Transferencias de Repositorios Gitea',
|
||||||
|
description: 'Gestiona transferencias: status (ver estado), accept (aceptar como recipient), reject (rechazar como owner). Requiere owner y repo.',
|
||||||
|
inputSchema: {
|
||||||
|
action: z.enum(['status', 'accept', 'reject']).describe('Acción a realizar'),
|
||||||
|
owner: z.string().describe('Propietario actual del repo'),
|
||||||
|
repo: z.string().describe('Nombre del repo'),
|
||||||
|
},
|
||||||
|
outputSchema: {
|
||||||
|
result: z.any().describe('Resultado de la operación')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async ({ action, owner, repo }) => {
|
||||||
|
try {
|
||||||
|
let result;
|
||||||
|
let notification = '';
|
||||||
|
|
||||||
|
switch (action) {
|
||||||
|
case 'status':
|
||||||
|
// Obtener información del repo incluyendo estado de transferencia
|
||||||
|
const repoData: any = await giteaRequest(`/repos/${owner}/${repo}`);
|
||||||
|
const transferStatus = repoData.repo_transfer;
|
||||||
|
|
||||||
|
if (transferStatus) {
|
||||||
|
notification = `⚠️ Hay una transferencia pendiente: ${transferStatus.doer.login} → ${transferStatus.recipient.login}`;
|
||||||
|
result = {
|
||||||
|
has_pending_transfer: true,
|
||||||
|
transfer: transferStatus,
|
||||||
|
_notification: notification
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
notification = '✓ No hay transferencias pendientes';
|
||||||
|
result = {
|
||||||
|
has_pending_transfer: false,
|
||||||
|
_notification: notification
|
||||||
|
};
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'accept':
|
||||||
|
// Aceptar transferencia (como recipient)
|
||||||
|
result = await giteaRequest(`/repos/${owner}/${repo}/transfer/accept`, {
|
||||||
|
method: 'POST',
|
||||||
|
});
|
||||||
|
notification = `✓ Transferencia aceptada exitosamente para '${owner}/${repo}'`;
|
||||||
|
result = typeof result === 'object' && result !== null
|
||||||
|
? { ...result, _notification: notification }
|
||||||
|
: { success: true, _notification: notification };
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'reject':
|
||||||
|
// Rechazar/cancelar transferencia (como owner)
|
||||||
|
result = await giteaRequest(`/repos/${owner}/${repo}/transfer`, {
|
||||||
|
method: 'DELETE',
|
||||||
|
});
|
||||||
|
notification = `✓ Transferencia rechazada/cancelada exitosamente para '${owner}/${repo}'`;
|
||||||
|
result = typeof result === 'object' && result !== null
|
||||||
|
? { ...result, _notification: notification }
|
||||||
|
: { success: true, _notification: notification };
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
content: [{
|
||||||
|
type: 'text',
|
||||||
|
text: JSON.stringify(result, null, 2)
|
||||||
|
}],
|
||||||
|
structuredContent: {
|
||||||
|
result
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
const errorMsg = error instanceof Error ? error.message : 'Error desconocido';
|
||||||
|
return {
|
||||||
|
content: [{ type: 'text', text: `Error: ${errorMsg}` }],
|
||||||
|
isError: true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// ==================== SERVIDOR EXPRESS ====================
|
// ==================== SERVIDOR EXPRESS ====================
|
||||||
const app = express();
|
const app = express();
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
|
|||||||
Reference in New Issue
Block a user