feat(session): add cross-session references

This commit is contained in:
Yichen Jiang
2026-07-21 16:46:48 +08:00
parent 9a5c81f9e5
commit 32d786c439
81 changed files with 2837 additions and 160 deletions

View File

@@ -15,6 +15,7 @@ import type {
SessionEventWindow,
SessionLineageTrace,
SessionRecord,
SessionSurfaceSnapshot,
} from './types.ts'
import {
SESSION_QUERY_READ_WINDOW_MAX,
@@ -74,6 +75,21 @@ export class SessionQueryService extends Service {
return tracing.eventRecords(sessionId, loaded.events)
}
/**
* Read one session's complete current model surface from one corpus observation.
* @param sessionId - live-preferred session id to read.
* @returns cloned header, current surface, and raw-log capture boundary.
* @throws when source resolution fails or the session surface is invalid.
*/
async readSurface(sessionId: SessionId): Promise<SessionSurfaceSnapshot> {
const loaded = await this._corpus.load(sessionId)
return {
session: structuredClone(loaded.header),
capturedThroughSeq: loaded.events.at(-1)?.seq ?? null,
events: tracing.currentSurfaceEvents(sessionId, loaded.events),
}
}
/**
* Trace known ancestry and descendants from one corpus observation.
* @param sessionId - logical session id to trace.