export type Tool = 'claude-code' | 'opencode' | 'crush' | 'pi' | 'kimi' | string export type Host = 'laptop' | 'workpc' | string export interface SessionDTO { owner: string tool: string host: string session_id: string started_at: number // unix epoch seconds ended_at: number working_dir?: string source_file: string summary: string turn_count: number tokens_in_total: number tokens_out_total: number model?: string metadata?: unknown } export interface Session { id: string // `${tool}/${host}/${session_id}` tool: string host: string cwd: string // working_dir ?? '' model?: string started: string // ISO 8601 ended: string | null // null if ended_at <= started_at summary: string turns: number tokensIn: number tokensOut: number hasError: boolean // TODO: always false until error tracking is implemented } export function adaptSession(d: SessionDTO): Session { return { id: `${d.tool}/${d.host}/${d.session_id}`, tool: d.tool, host: d.host, cwd: d.working_dir ?? '', model: d.model, started: new Date(d.started_at * 1000).toISOString(), ended: d.ended_at > d.started_at ? new Date(d.ended_at * 1000).toISOString() : null, summary: d.summary, turns: d.turn_count, tokensIn: d.tokens_in_total, tokensOut: d.tokens_out_total, hasError: false, } } // ── Projects ───────────────────────────────────────────────────────────────── export interface ProjectDTO { cwd: string sessions: number turn_count: number tokens_in_total: number tokens_out_total: number last_active: number // unix epoch seconds; 0 = never hosts: string[] tools: string[] top_tool: string } export interface Project { cwd: string sessions: number turns: number tokensIn: number tokensOut: number lastActive: string // ISO 8601, or '' when last_active === 0 hosts: string[] tools: string[] topTool: string } export function adaptProject(d: ProjectDTO): Project { return { cwd: d.cwd, sessions: d.sessions, turns: d.turn_count, tokensIn: d.tokens_in_total, tokensOut: d.tokens_out_total, lastActive: d.last_active === 0 ? '' : new Date(d.last_active * 1000).toISOString(), hosts: d.hosts, tools: d.tools, topTool: d.top_tool, } }