mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-16 19:00:38 +09:00
Add chain-of-command API for agents
- agentService.getChainOfCommand() walks the reporting tree upward - GET /agents/:id now returns chainOfCommand array with the full management hierarchy - GET /agents/me endpoint returns the calling agent with its chain of command Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
5306142542
commit
6232d2397d
2 changed files with 31 additions and 1 deletions
|
|
@ -51,6 +51,20 @@ export function agentRoutes(db: Db) {
|
|||
res.json(tree);
|
||||
});
|
||||
|
||||
router.get("/agents/me", async (req, res) => {
|
||||
if (req.actor.type !== "agent" || !req.actor.agentId) {
|
||||
res.status(401).json({ error: "Agent authentication required" });
|
||||
return;
|
||||
}
|
||||
const agent = await svc.getById(req.actor.agentId);
|
||||
if (!agent) {
|
||||
res.status(404).json({ error: "Agent not found" });
|
||||
return;
|
||||
}
|
||||
const chainOfCommand = await svc.getChainOfCommand(agent.id);
|
||||
res.json({ ...agent, chainOfCommand });
|
||||
});
|
||||
|
||||
router.get("/agents/:id", async (req, res) => {
|
||||
const id = req.params.id as string;
|
||||
const agent = await svc.getById(id);
|
||||
|
|
@ -59,7 +73,8 @@ export function agentRoutes(db: Db) {
|
|||
return;
|
||||
}
|
||||
assertCompanyAccess(req, agent.companyId);
|
||||
res.json(agent);
|
||||
const chainOfCommand = await svc.getChainOfCommand(agent.id);
|
||||
res.json({ ...agent, chainOfCommand });
|
||||
});
|
||||
|
||||
router.get("/agents/:id/runtime-state", async (req, res) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue