File size: 601 Bytes
7c5ed63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { Hono } from 'hono';
import { KIMI_CODE_HOME } from '../config';
import { readSessionDetail } from '../lib/session-store';
import { buildAgentTree } from '../lib/agent-tree';

export function subagentsRoute(home: string = KIMI_CODE_HOME): Hono {
  const r = new Hono();
  r.get('/:id/agents', async (c) => {
    const id = c.req.param('id');
    const detail = await readSessionDetail(home, id);
    if (!detail) {
      return c.json({ error: 'session not found', code: 'NOT_FOUND' }, 404);
    }
    return c.json({ sessionId: id, tree: buildAgentTree(detail.agents) });
  });
  return r;
}