UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

34 lines (33 loc) • 1.83 kB
import { type MailboxStore } from "../core/mailbox-store.js"; import type { PermissionModeClass } from "./cross-session-envelope.js"; import { type PeerDeliveryReceiptState, type PeerDropReason, type PeerIdleNoticeKind } from "./peer-notices.js"; export interface PeerNoticeRoute { mailbox: MailboxStore; scope: string; /** The notice's author: this session (the recipient of a held message / the target of a subscription / * the requester answering itself). `name` = its directory row's display name when known. */ self: { sessionId: string; name?: string; modeClass?: () => PermissionModeClass | "unknown"; }; onError?: (error: unknown, ctx: { phase: "degraded"; sessionId: string; classification: string; }) => void; now?: () => number; } /** A delivery RECEIPT to the sender of one message this session judged (held / expired / delivered / * refused / denied). `refSeq` = the seq of the sender's message in THIS session's box. */ export declare function routePeerDeliveryReceipt(route: PeerNoticeRoute, toSession: string, state: Exclude<PeerDeliveryReceiptState, "dropped">, refSeq: number): Promise<boolean>; /** A `dropped` receipt (the ingress guard's arm). */ export declare function routePeerDroppedReceipt(route: PeerNoticeRoute, toSession: string, refSeq: number, dropReason?: PeerDropReason): Promise<boolean>; /** An idle NOTICE to a requester (`idle` / `exited` / `unavailable` from the target; `expired` from the * requester's own timer — then `toSession` is the requester itself and the record is self-sent). */ export declare function routePeerIdleNotice(route: PeerNoticeRoute, toSession: string, notice: { kind: PeerIdleNoticeKind; finishedAt?: number; detail?: string; label?: string; }): Promise<boolean>;