MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / buildSession

Function buildSession

packages/node-runtime/src/services/session-service.ts:49–72  ·  view source on GitHub ↗
(
  db: DatabaseAdapter,
  id: string,
  dbPath: string,
  options?: ListSessionsOptions
)

Source from the content-addressed store, hash-verified

47}
48
49function buildSession(
50 db: DatabaseAdapter,
51 id: string,
52 dbPath: string,
53 options?: ListSessionsOptions
54): AnalysisSessionDTO | null {
55 const meta = getSessionMeta(db)
56 if (!meta) return null
57
58 const overview = options?.resolveOverview ? options.resolveOverview(db, id) : undefined
59 const info = overview ? buildSessionInfo(meta, overview, getSummaryCount(db)) : getSessionInfo(db)
60 if (!info) return null
61
62 let memberAvatar: string | null = null
63 if (meta.type === 'private') {
64 memberAvatar = getPrivateChatMemberAvatar(db, meta.name, meta.ownerId)
65 }
66
67 let dto: AnalysisSessionDTO = { ...info, id, dbPath, memberAvatar, aiConversationCount: 0 }
68 if (options?.enrichSession) {
69 dto = options.enrichSession(dto)
70 }
71 return dto
72}
73
74/**
75 * List all valid sessions, sorted by importedAt descending.

Callers 2

listAnalysisSessionsFunction · 0.85
getAnalysisSessionFunction · 0.85

Calls 7

getSessionMetaFunction · 0.90
buildSessionInfoFunction · 0.90
getSummaryCountFunction · 0.90
getSessionInfoFunction · 0.90
resolveOverviewMethod · 0.80
enrichSessionMethod · 0.80

Tested by

no test coverage detected