Files
claude-mem/src/types/database.ts
T
huakson 2b60dd2932 feat: isolate Claude and Codex session sources
Persist platform_source across session creation, transcript ingestion, API query paths, and viewer state so Claude and Codex data can coexist without bleeding into each other.

- add platform-source normalization helpers and persist platform_source in sdk_sessions via migration 24 with backfill and indexing
- thread platformSource through CLI hooks, transcript processing, context generation, pagination, search routes, SSE payloads, and session management
- expose source-aware project catalogs, viewer tabs, context preview selectors, and source badges for observations, prompts, and summaries
- start the transcript watcher from the worker for transcript-based clients and preserve platform source during Codex ingestion
- auto-start the worker from the MCP server for MCP-only clients and tighten stdio-driven cleanup during shutdown
- keep createSDKSession backward compatible with existing custom-title callers while allowing explicit platform source forwarding
2026-03-24 08:46:18 -03:00

142 lines
2.8 KiB
TypeScript

/**
* TypeScript types for database query results
* Provides type safety for bun:sqlite query results
*/
/**
* Schema information from sqlite3 PRAGMA table_info
*/
export interface TableColumnInfo {
cid: number;
name: string;
type: string;
notnull: number;
dflt_value: string | null;
pk: number;
}
/**
* Index information from sqlite3 PRAGMA index_list
*/
export interface IndexInfo {
seq: number;
name: string;
unique: number;
origin: string;
partial: number;
}
/**
* Table name from sqlite_master
*/
export interface TableNameRow {
name: string;
}
/**
* Schema version record
*/
export interface SchemaVersion {
version: number;
}
/**
* SDK Session database record
*/
export interface SdkSessionRecord {
id: number;
content_session_id: string;
memory_session_id: string | null;
project: string;
user_prompt: string | null;
started_at: string;
started_at_epoch: number;
completed_at: string | null;
completed_at_epoch: number | null;
status: 'active' | 'completed' | 'failed';
worker_port?: number;
prompt_counter?: number;
}
/**
* Observation database record
*/
export interface ObservationRecord {
id: number;
memory_session_id: string;
project: string;
text: string | null;
type: 'decision' | 'bugfix' | 'feature' | 'refactor' | 'discovery' | 'change';
created_at: string;
created_at_epoch: number;
title?: string;
concept?: string;
source_files?: string;
prompt_number?: number;
discovery_tokens?: number;
}
/**
* Session Summary database record
*/
export interface SessionSummaryRecord {
id: number;
memory_session_id: string;
project: string;
request: string | null;
investigated: string | null;
learned: string | null;
completed: string | null;
next_steps: string | null;
created_at: string;
created_at_epoch: number;
prompt_number?: number;
discovery_tokens?: number;
}
/**
* User Prompt database record
*/
export interface UserPromptRecord {
id: number;
content_session_id: string;
prompt_number: number;
prompt_text: string;
project?: string; // From JOIN with sdk_sessions
platform_source?: string;
created_at: string;
created_at_epoch: number;
}
/**
* Latest user prompt with session join
*/
export interface LatestPromptResult {
id: number;
content_session_id: string;
memory_session_id: string;
project: string;
platform_source: string;
prompt_number: number;
prompt_text: string;
created_at_epoch: number;
}
/**
* Observation with context (for time-based queries)
*/
export interface ObservationWithContext {
id: number;
memory_session_id: string;
project: string;
text: string | null;
type: string;
created_at: string;
created_at_epoch: number;
title?: string;
concept?: string;
source_files?: string;
prompt_number?: number;
discovery_tokens?: number;
}