eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
76 lines (75 loc) • 3.67 kB
TypeScript
import type { TaskDeliveryPolicy, DeliverHookPayload, DeliverPayload } from "#channel/types.js";
import type { getSessionTaskCohorts } from "#tasks/session-task-cohorts.js";
export type SessionControl = "clear" | "compact" | "expired" | "reset";
type TaskCohorts = ReturnType<typeof getSessionTaskCohorts>;
export interface DeliveryAdmission {
readonly delivery: DeliverHookPayload;
readonly sequence: number;
}
export interface TurnSelection {
readonly delivery: DeliverHookPayload;
/**
* True only for a lone, callerless conversational delivery that arrived
* while nothing else was pending. Such a delivery may move the session to
* the deployment that accepted it.
*/
readonly handoffEligible: boolean;
readonly kind: "turn";
/** Sequences of every admission folded into this turn. */
readonly sequences: readonly number[];
}
export type SessionInputSelection = TurnSelection | {
readonly control: SessionControl;
readonly kind: "control";
} | {
readonly kind: "authorization-resume";
readonly payloads: readonly DeliverPayload[];
};
/**
* Ordered, admitted session input, plus the idempotency and cancellation
* facts for task deliveries this owner has seen. Entries are private; callers
* receive typed admission and selection values. Everything here is rebuilt
* deterministically on replay, and a successor never inherits it because
* handoff requires every indexed task to be terminal.
*/
export declare class SessionInputQueue {
private readonly entries;
private readonly cancelledTaskIds;
private readonly seenTaskDeliveryIds;
private nextSequence;
get pendingCount(): number;
/** Admits a delivery unless it repeats or belongs to a cancelled task. */
enqueueDelivery(delivery: DeliverHookPayload): DeliveryAdmission | undefined;
/** A caller's own task id counts as seen so its echo is not admitted twice. */
rememberTask(taskId: string): void;
isTaskCancelled(taskId: string): boolean;
enqueueControl(control: SessionControl): void;
/** Keeps one payload per authorization attempt; a repeated callback for the same attempt is dropped. */
enqueueAuthorization(payloads: readonly DeliverPayload[]): void;
delivery(sequence: number): DeliverHookPayload | undefined;
/** Task lifecycle effects must be applied even while their cohort report is held. */
taskDeliveries(): readonly DeliveryAdmission[];
replaceDelivery(sequence: number, delivery: DeliverHookPayload | undefined): void;
/** Drops queued notifications from a cancelled task and refuses later ones. */
cancelTask(taskId: string): void;
takeSteering(admitted: ReadonlySet<number>, callerCallId: string | undefined): TurnSelection | undefined;
takeNext(cohorts: TaskCohorts, options?: {
readonly deferDeliveries?: boolean;
readonly taskDeliveryPolicy?: TaskDeliveryPolicy;
/**
* Attempt ids of the open authorization challenge. Callbacks for other
* attempts are stale and dropped; once every expected attempt has
* reported, the collected payloads resume the challenge ahead of
* ordinary input.
*/
readonly expectedAttemptIds?: ReadonlySet<string>;
/** Sequence of a delivery admitted while nothing else was pending. */
readonly freshSequence?: number;
}): SessionInputSelection | undefined;
private nextActionableIndex;
private takeSelectionAt;
private isCancelledTaskDelivery;
private retain;
}
export declare function isSteeringDelivery(delivery: DeliverHookPayload, callerCallId: string | undefined): boolean;
export {};