(_params: Record<string, unknown>, context: SessionListContext)
| 25 | } |
| 26 | |
| 27 | function handler(_params: Record<string, unknown>, context: SessionListContext): ToolResult { |
| 28 | const keyword = (_params.keyword as string | undefined)?.toLowerCase() |
| 29 | const sessionIds = context.listSessionIds() |
| 30 | |
| 31 | const sessions = sessionIds |
| 32 | .map((id) => { |
| 33 | const db = context.openDb(id) |
| 34 | if (!db) return null |
| 35 | const meta = getSessionMeta(db) |
| 36 | if (!meta) return null |
| 37 | if (keyword && !meta.name.toLowerCase().includes(keyword)) return null |
| 38 | const overview = getSessionOverview(db) |
| 39 | return { id, ...meta, ...overview } |
| 40 | }) |
| 41 | .filter(Boolean) |
| 42 | |
| 43 | return { |
| 44 | content: JSON.stringify({ total: sessions.length, sessions }), |
| 45 | data: sessions, |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | export const sessionsListTool: ToolDefinition = { |
| 50 | name: 'list_sessions', |
nothing calls this directly
no test coverage detected