MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / wireRoute

Function wireRoute

apps/vis/server/src/routes/wire.ts:9–48  ·  view source on GitHub ↗
(home: string = KIMI_CODE_HOME)

Source from the content-addressed store, hash-verified

7import { readAgentWire } from '../lib/wire-reader';
8
9export function wireRoute(home: string = KIMI_CODE_HOME): Hono {
10 const r = new Hono();
11 r.get('/:id/wire', async (c) => {
12 const id = c.req.param('id');
13 const agentId = c.req.query('agent') ?? 'main';
14 if (!isSafeAgentId(agentId)) {
15 return c.json({ error: 'invalid agent id', code: 'BAD_REQUEST' }, 400);
16 }
17 const detail = await readSessionDetail(home, id);
18 if (!detail) {
19 return c.json({ error: 'session not found', code: 'NOT_FOUND' }, 404);
20 }
21 const agent = detail.agents.find((a) => a.agentId === agentId);
22 if (!agent) {
23 return c.json({ error: `agent "${agentId}" not found`, code: 'NOT_FOUND' }, 404);
24 }
25 if (!agent.wireExists) {
26 return c.json({ error: 'wire missing', code: 'NOT_FOUND' }, 404);
27 }
28 try {
29 const result = await readAgentWire(
30 join(detail.sessionDir, 'agents', agentId, 'wire.jsonl'),
31 );
32 const baseUrl = new URL(c.req.url).origin;
33 rehydrateWireEntries(result.records, id, agentId, baseUrl);
34 return c.json({
35 sessionId: id,
36 agentId,
37 protocolVersion: result.metadata.protocolVersion,
38 metadata: result.metadata,
39 records: result.records,
40 warnings: result.warnings,
41 });
42 } catch (err) {
43 const msg = (err as Error).message;
44 return c.json({ error: msg, code: 'READ_ERROR' }, 500);
45 }
46 });
47 return r;
48}

Callers 2

imports.test.tsFile · 0.90
createAppFunction · 0.90

Calls 6

isSafeAgentIdFunction · 0.90
readSessionDetailFunction · 0.90
readAgentWireFunction · 0.90
rehydrateWireEntriesFunction · 0.90
jsonMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected