<!-- Generated by scripts/gen-website-api.ts — do not edit by hand. Run `pnpm run gen-website-api` to regenerate. -->

# ctx.sessionQuery

`SessionQueryService` — provided by `@deepseek-ai/dsh-session-query`.

Live-preferred logical-corpus exact-read and relationship-tracing service.

[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/session-query/session-query/src/index.ts#L38)

### ctx.sessionQuery.listSessions()

```ts website-api
/**
 * List the complete logical corpus using live-preferred records.
 * @returns deterministic newest-first cloned session records.
 */
listSessions(): Promise<SessionRecord[]>
```

List the complete logical corpus using live-preferred records.

**Returns** deterministic newest-first cloned session records.

[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/session-query/session-query/src/index.ts#L63)

### ctx.sessionQuery.listEvents(sessionId)

```ts website-api
/**
 * List lightweight raw-log event records for one logical session.
 * @param sessionId - live-preferred session id to read.
 * @returns event records in ascending seq order.
 */
async listEvents(sessionId: SessionId): Promise<SessionEventRecord[]>
```

List lightweight raw-log event records for one logical session.

- `sessionId` — live-preferred session id to read.

**Returns** event records in ascending seq order.

[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/session-query/session-query/src/index.ts#L72)

### ctx.sessionQuery.traceSession(sessionId)

```ts website-api
/**
 * Trace known ancestry and descendants from one corpus observation.
 * @param sessionId - logical session id to trace.
 * @returns a complete lineage or an explicit unresolved parent boundary.
 * @throws when corpus resolution fails, the target is absent, or its known ancestry cycles.
 */
async traceSession(sessionId: SessionId): Promise<SessionLineageTrace>
```

Trace known ancestry and descendants from one corpus observation.

- `sessionId` — logical session id to trace.

**Returns** a complete lineage or an explicit unresolved parent boundary.

[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/session-query/session-query/src/index.ts#L83)

### ctx.sessionQuery.traceEvent(request)

```ts website-api
/**
 * Trace one event's direct positional and provenance relationships.
 * @param request - target session id and event seq.
 * @returns direct links plus the target's positional replacement chain.
 * @throws when source resolution fails, the target is absent, or surface/provenance validation fails.
 */
async traceEvent(request: SessionEventTraceRequest): Promise<SessionEventTrace>
```

Trace one event's direct positional and provenance relationships.

- `request` — target session id and event seq.

**Returns** direct links plus the target's positional replacement chain.

[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/session-query/session-query/src/index.ts#L94)

### ctx.sessionQuery.readEvent(request)

```ts website-api
/**
 * Read one full event plus a bounded raw-log context window.
 * @param request - target session/seq and context sizes.
 * @returns cloned target and neighboring events.
 */
async readEvent(request: SessionEventReadRequest): Promise<SessionEventWindow>
```

Read one full event plus a bounded raw-log context window.

- `request` — target session/seq and context sizes.

**Returns** cloned target and neighboring events.

[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/session-query/session-query/src/index.ts#L104)
