mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-10 18:58:48 +00:00
26 lines
751 B
TypeScript
26 lines
751 B
TypeScript
import type { RootLoadArgs } from "./types"
|
|
|
|
export async function loadRootSessionsWithFallback(input: RootLoadArgs) {
|
|
try {
|
|
const result = await input.list({ directory: input.directory, roots: true, limit: input.limit })
|
|
return {
|
|
data: result.data,
|
|
limit: input.limit,
|
|
limited: true,
|
|
} as const
|
|
} catch {
|
|
const result = await input.list({ directory: input.directory, roots: true })
|
|
return {
|
|
data: result.data,
|
|
limit: input.limit,
|
|
limited: false,
|
|
} as const
|
|
}
|
|
}
|
|
|
|
export function estimateRootSessionTotal(input: { count: number; limit: number; limited: boolean }) {
|
|
if (!input.limited) return input.count
|
|
if (input.count < input.limit) return input.count
|
|
return input.count + 1
|
|
}
|