Files
html/api/paperclip-sync.php
2026-04-12 22:57:03 +02:00

34 lines
991 B
PHP

<?php
// Auto-sync: Paperclip agents -> Enterprise Viz
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
$pc = @file_get_contents('http://127.0.0.1:3100/api/companies/dd12987b-c774-45e7-95fd-d34003f91650/agents');
$agents = $pc ? json_decode($pc, true) : [];
// Map Paperclip roles to enterprise viz departments
$role_map = [
'ceo'=>'ceo','cto'=>'con','engineer'=>'dev','devops'=>'srv',
'qa'=>'qa','researcher'=>'con','cmo'=>'sal','cfo'=>'ops',
'designer'=>'dev','pm'=>'ops','general'=>'ops'
];
$viz_agents = [];
foreach ($agents as $a) {
$viz_agents[] = [
'name' => $a['name'],
'role' => $a['role'],
'dept' => $role_map[$a['role']] ?? 'ops',
'status' => $a['status'] ?? 'idle',
'id' => $a['id'],
'reportsTo' => $a['reportsTo'] ?? null
];
}
echo json_encode([
'ok' => true,
'agents' => $viz_agents,
'total' => count($viz_agents),
'synced_at' => date('Y-m-d H:i:s')
]);