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

Function sessionsRoute

apps/vis/server/src/routes/sessions.ts:7–38  ·  view source on GitHub ↗
(home: string = KIMI_CODE_HOME)

Source from the content-addressed store, hash-verified

5import { listSessions, readSessionDetail } from '../lib/session-store';
6
7export function sessionsRoute(home: string = KIMI_CODE_HOME): Hono {
8 const r = new Hono();
9 r.get('/', async (c) => {
10 const sessions = await listSessions(home);
11 return c.json({ sessions });
12 });
13 r.delete('/:id', async (c) => {
14 const id = c.req.param('id');
15 const all = await listSessions(home);
16 const target = all.find((s) => s.sessionId === id);
17 if (!target) return c.json({ error: 'session not found', code: 'NOT_FOUND' }, 404);
18 await rm(target.sessionDir, { recursive: true, force: true });
19 return c.json({ sessionId: id, deleted: true });
20 });
21 // Open the session directory in the OS file manager. The folder is
22 // opened on the SERVER host — only meaningful when vis runs locally.
23 r.post('/:id/reveal', async (c) => {
24 const id = c.req.param('id');
25 const detail = await readSessionDetail(home, id);
26 if (!detail) return c.json({ error: 'session not found', code: 'NOT_FOUND' }, 404);
27 try {
28 await revealInOs(detail.sessionDir);
29 return c.json({ sessionId: id, opened: detail.sessionDir });
30 } catch (err) {
31 return c.json(
32 { error: `failed to open: ${(err as Error).message}`, code: 'READ_ERROR' },
33 500,
34 );
35 }
36 });
37 return r;
38}

Callers 2

imports.test.tsFile · 0.90
createAppFunction · 0.90

Calls 7

listSessionsFunction · 0.90
readSessionDetailFunction · 0.90
revealInOsFunction · 0.90
jsonMethod · 0.80
getMethod · 0.65
deleteMethod · 0.65
postMethod · 0.65

Tested by

no test coverage detected