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, } }