import type { SessionId, TurnId } from '../../types/ids/index.js'; import type { SessionRecord } from '../../types/session/records.js'; import type { ExternalRef, Origin } from '../../types/session/turn.js'; /** * How the index derives `external_refs`: only from `session_started.origin`, * `turn_started.origin` and `session_updated.externalRefs` (spec D9). Nothing * writes a ref directly, so a rebuild from the logs reproduces every one. * * An external id is any string. It is never parsed, never required to be a * UUID, and never read as a namzu id. */ /** * The kinds of caller-side name the index resolves. The three session kinds * are {@link ExternalRef}'s; `turn` names one turn by the caller's own id for * it (`origin.externalTurnId`, such as the turn id an AG-UI client sent). */ export type ExternalRefKind = ExternalRef['kind'] | 'turn'; /** One claim a session log makes on a caller-side name. */ export interface ExternalRefClaim { readonly protocol: string; readonly kind: ExternalRefKind; readonly externalId: string; readonly sessionId: SessionId; /** The turn a `turn` ref names; absent on the session kinds. */ readonly turnId?: TurnId; /** The claiming record's `ts`: the earliest claim on a name wins. */ readonly claimedAt: string; /** The claiming record's `seq`, the tie-break within one timestamp. */ readonly claimedSeq: number; } /** What a caller-side name resolves to. */ export interface ExternalRefTarget { readonly protocol: string; readonly kind: ExternalRefKind; readonly externalId: string; readonly sessionId: SessionId; readonly turnId?: TurnId; } /** * The session kind an origin's `externalSessionId` is filed under: an AG-UI * thread, an A2A context, and a session for every other protocol (ACP, the * desktop map, HTTP hosts). */ export declare function sessionRefKind(protocol: Origin['protocol'] | string): ExternalRef['kind']; /** A change to the refs one record makes. */ export type ExternalRefChange = { readonly op: 'claim'; readonly claim: ExternalRefClaim; } | { readonly op: 'release'; readonly protocol: string; readonly kind: ExternalRefKind; readonly externalId: string; readonly sessionId: SessionId; }; /** The ref changes one record makes, in the order they apply. */ export declare function externalRefChanges(record: SessionRecord): ExternalRefChange[]; /** * Orders competing claims on one name: earliest `claimedAt`, then the lower * session id, then the lower seq. The order depends only on the claims, never * on the order logs were indexed in, so a rebuild resolves a contested name * exactly as the incremental index did. */ export declare function compareClaims(a: ExternalRefClaim, b: ExternalRefClaim): number; export declare function claimTarget(claim: ExternalRefClaim): ExternalRefTarget; //# sourceMappingURL=refs.d.ts.map