order recent chats first

This commit is contained in:
Arjun 2026-05-07 11:10:28 +05:30
parent a48887da61
commit 30c10b8db9
4 changed files with 117 additions and 75 deletions

View file

@ -49,6 +49,14 @@ export const MessageEvent = BaseRunEvent.extend({
message: Message,
});
const MONOTONIC_ID_TIMESTAMP_RE = /^(\d{4}-\d{2}-\d{2}T\d{2})-(\d{2})-(\d{2})Z(?:-|$)/;
export function monotonicIdToIsoTimestamp(id: string): string | undefined {
const match = MONOTONIC_ID_TIMESTAMP_RE.exec(id);
if (!match) return undefined;
return `${match[1]}:${match[2]}:${match[3]}Z`;
}
export const ToolInvocationEvent = BaseRunEvent.extend({
type: z.literal("tool-invocation"),
toolCallId: z.string().optional(),
@ -138,6 +146,7 @@ export const Run = z.object({
id: z.string(),
title: z.string().optional(),
createdAt: z.iso.datetime(),
lastMessageAt: z.iso.datetime().optional(),
agentId: z.string(),
model: z.string(),
provider: z.string(),
@ -151,6 +160,7 @@ export const ListRunsResponse = z.object({
id: true,
title: true,
createdAt: true,
lastMessageAt: true,
agentId: true,
})),
nextCursor: z.string().optional(),