UNPKG

@adonis-agora/agent

Version:

Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.

49 lines • 2.15 kB
/** * The governance read-model's keyset cursors: the `(timestamp ms, primary key)` of the last row a * page returned, base64url JSON. Opaque to callers; only the stores read them back. * * Cursors handed out before keyset paging were a plain offset (`"50"`, from `listRuns`), and the * HTTP layer's window cursors encode `[offset]`. {@link readRunsCursor} still honours the first, so * a link or a half-walked "Load more" from an older server keeps working. */ import type { CursorPage } from '../pagination.js'; /** A position in a list ordered `(at DESC, id DESC)`. */ export interface KeysetPosition { /** Epoch milliseconds of the order column. */ at: number; id: string; } export declare function encodeKeyset(at: number, id: string): string; /** The position a keyset cursor names, or `null` when `cursor` is not one this module wrote. */ export declare function decodeKeyset(cursor: string): KeysetPosition | null; /** * A `listRuns` `after`: a keyset position, or the offset an older server handed out (`"50"`). * Anything else reads as the first page, as before. */ export declare function readRunsCursor(after: string | undefined): { position: KeysetPosition; } | { offset: number; }; /** `(at, id) < (position)`: is `row` strictly older than `position` in `(at DESC, id DESC)`? */ export declare function isBefore(row: KeysetPosition, position: KeysetPosition): boolean; /** `(at DESC, id DESC)` comparator. */ export declare function newestFirst(left: KeysetPosition, right: KeysetPosition): number; /** * The seek predicate for `(column, "id") < (?, ?)`, spelled so every dialect (Postgres, MySQL, * SQLite) can still range-scan an index on `(column[, id])`. */ export declare function seekSql(column: string, position: KeysetPosition): { sql: string; bindings: unknown[]; }; /** * `limit + 1` rows → the page, with the next cursor at its last row. Forward-only, like every read * of this SPI: `prevCursor` stays `null`. */ export declare function keysetPage<T>(rows: Array<{ at: number; id: string; view: T; }>, limit: number): CursorPage<T>; //# sourceMappingURL=keyset.d.ts.map