UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

45 lines (44 loc) • 2.54 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; `occupant` = the occupant this * session's run holds (`SessionMetadata.incarnation`), stamped as the notice's `fromOccupant`; absent = no token. */ self: { sessionId: string; name?: string; occupant?: string; modeClass?: () => PermissionModeClass | "unknown"; }; onError?: (error: unknown, ctx: { phase: "degraded"; sessionId: string; classification: string; }) => void; now?: () => number; } /** * WHO a notice is for: the addressee session and the occupant the notice answers — the `fromOccupant` of the record it is about, * or of the subscription it fulfils; `undefined` = that record stated none. Stamped as the notice record's `occupant`, so the * addressee's drain hands it only to that occupant (a notice for an earlier occupant of the id is discarded there). */ export interface PeerNoticeAddressee { readonly sessionId: string; readonly occupant: string | undefined; } /** 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, to: PeerNoticeAddressee, state: Exclude<PeerDeliveryReceiptState, "dropped">, refSeq: number, detail?: string): Promise<boolean>; /** A `dropped` receipt (the ingress guard's arm). */ export declare function routePeerDroppedReceipt(route: PeerNoticeRoute, to: PeerNoticeAddressee, 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 `to` is the requester itself and the record is self-sent). */ export declare function routePeerIdleNotice(route: PeerNoticeRoute, to: PeerNoticeAddressee, notice: { kind: PeerIdleNoticeKind; finishedAt?: number; detail?: string; label?: string; }): Promise<boolean>;