























@@ -256,20 +256,52 @@ function resolveNonNegativeNumber(value: number | null | undefined): number | un
256256return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : undefined;
257257}
258258259-function resolveLatestCompactionCheckpoint(
259+type SessionCompactionCheckpointEntry = NonNullable<SessionEntry["compactionCheckpoints"]>[number];
260+261+function isProjectableCompactionCheckpoint(
262+value: unknown,
263+): value is SessionCompactionCheckpointEntry {
264+if (!value || typeof value !== "object" || Array.isArray(value)) {
265+return false;
266+}
267+const checkpoint = value as {
268+checkpointId?: unknown;
269+createdAt?: unknown;
270+reason?: unknown;
271+};
272+return (
273+Boolean(normalizeOptionalString(checkpoint.checkpointId)) &&
274+typeof checkpoint.createdAt === "number" &&
275+Number.isFinite(checkpoint.createdAt) &&
276+(checkpoint.reason === "manual" ||
277+checkpoint.reason === "auto-threshold" ||
278+checkpoint.reason === "overflow-retry" ||
279+checkpoint.reason === "timeout-retry")
280+);
281+}
282+283+function resolveProjectableCompactionCheckpoints(
260284entry?: Pick<SessionEntry, "compactionCheckpoints"> | null,
261-): NonNullable<SessionEntry["compactionCheckpoints"]>[number] | undefined {
285+): SessionCompactionCheckpointEntry[] {
262286const checkpoints = entry?.compactionCheckpoints;
263287if (!Array.isArray(checkpoints) || checkpoints.length === 0) {
264-return undefined;
288+return [];
265289}
266-return checkpoints.reduce((latest, checkpoint) =>
267-!latest || checkpoint.createdAt > latest.createdAt ? checkpoint : latest,
290+return checkpoints.filter(isProjectableCompactionCheckpoint);
291+}
292+293+function resolveLatestCompactionCheckpoint(
294+checkpoints: readonly SessionCompactionCheckpointEntry[],
295+): SessionCompactionCheckpointEntry | undefined {
296+return checkpoints.reduce<SessionCompactionCheckpointEntry | undefined>(
297+(latest, checkpoint) =>
298+!latest || checkpoint.createdAt > latest.createdAt ? checkpoint : latest,
299+undefined,
268300);
269301}
270302271303function buildCompactionCheckpointPreview(
272-checkpoint: NonNullable<SessionEntry["compactionCheckpoints"]>[number] | undefined,
304+checkpoint: SessionCompactionCheckpointEntry | undefined,
273305): GatewaySessionRow["latestCompactionCheckpoint"] {
274306if (!checkpoint) {
275307return undefined;
@@ -1772,8 +1804,12 @@ export function buildGatewaySessionRow(params: {
17721804params.storeChildSessionsByKey.get(key),
17731805)
17741806 : resolveChildSessionKeys(key, store, now, rowContext?.subagentRuns);
1807+const compactionCheckpoints = resolveProjectableCompactionCheckpoints(entry);
1808+const compactionCheckpointCount = Array.isArray(entry?.compactionCheckpoints)
1809+ ? compactionCheckpoints.length
1810+ : undefined;
17751811const latestCompactionCheckpoint = buildCompactionCheckpointPreview(
1776-resolveLatestCompactionCheckpoint(entry),
1812+resolveLatestCompactionCheckpoint(compactionCheckpoints),
17771813);
17781814const selectedOrRuntimeModelProvider = selectedModel?.provider ?? modelProvider;
17791815const selectedOrRuntimeModel = selectedModel?.model ?? model;
@@ -1907,7 +1943,7 @@ export function buildGatewaySessionRow(params: {
19071943lastTo: deliveryFields.lastTo ?? entry?.lastTo,
19081944lastAccountId: deliveryFields.lastAccountId ?? entry?.lastAccountId,
19091945lastThreadId: deliveryFields.lastThreadId ?? entry?.lastThreadId,
1910-compactionCheckpointCount: entry?.compactionCheckpoints?.length,
1946+ compactionCheckpointCount,
19111947 latestCompactionCheckpoint,
19121948pluginExtensions: pluginExtensions.length > 0 ? pluginExtensions : undefined,
19131949};
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。