/** * The native engine adapter: implements {@link AdmittedChatSession} over ONE real `CotalEndpoint` * that a reviewed admission adapter constructed under the session's own identity. The adapter owns * start; listeners may be installed before it starts. This module never constructs, admits, mints or starts an endpoint, and never reads a * credential. No connector-core. The three client behaviours core lacks live in `engine.ts`. * * Classification rules (native error -> session outcome): * - `isPublishPermissionDenied` (broker publish refusal) -> refused PERMISSION_DENIED * - `EpEnvelopeError` with `outcome: "not-executed"` or a * pre-effect code (bad-request, permission-denied, …) -> refused, native code kept * - `EpEnvelopeError` with `outcome: "unknown"`, timeouts, and * anything else thrown after a publish or request was issued -> unknown (never retried) * - local validation thrown before any I/O -> refused USAGE_INVALID * - a send, join or channel mode outside the session's grant -> refused PERMISSION_DENIED, * before any I/O ({@link grantRefusal}) * A denial is never turned into an empty `ok`. */ import { type CotalEndpoint, type Presence, type PresenceView } from "@cotal-ai/core"; import { ParticipantEngine } from "./engine.js"; import type { AdmittedChatSession, ChannelInfo, CloseReport, ConnectionReport, DmTarget, HistoryPage, PublishResult, Refused, Result, RosterView, SessionEvent, SessionIdentity, SessionMessage } from "./session.js"; /** * Refuse a channel outside the session's read or post grant before any effect, so the broker's * refusal and its subject never reach the caller. A session opened on no channel holds no grant, * and the refusal says how to open one that does. The broker remains the enforcement point. */ export declare function grantRefusal(grant: readonly string[], channel: string, use: "read" | "post"): Refused | undefined; /** * Resolve a DM target before any effect. A `{ principal }` target, or a typed string that parses as * a principal `.`, goes to that principal as is, whether or not it is present or was * heard from. It is never matched against display names, so a peer whose display name spells a * principal cannot capture it; that peer is reached by its own principal or `/reply`. Any other * string is a display name, which must name one principal across the roster and the heard senders: * a name both carry refuses and lists them instead of picking the present one. Absence is a verdict * only on a current roster (endpoint.ts:2816-2823). */ export declare function resolveDmTarget(to: DmTarget, roster: readonly Presence[], rosterState: PresenceView["state"], engine: ParticipantEngine, selfPrincipal: string): { readonly id: string; readonly name: string; } | Refused; /** Inputs the admission adapter supplies with the endpoint whose start it owns. */ export interface NativeSessionInputs { readonly endpoint: CotalEndpoint; readonly identity: SessionIdentity; /** The admission adapter's own retirement call. This module only invokes it. */ readonly retire: () => Promise; } export declare class NativeChatSession implements AdmittedChatSession { private readonly inputs; private readonly engine; private readonly listeners; private state; private attention; private closed; /** Why the session ended itself, when it could not continue. */ private lost; private readonly onMessage; /** The endpoint drops its connection during a reconnect this session asked for. That outage was * reported when the reconnect started, so the state stays reconnecting until it is back. */ private readonly onConnection; private readonly onPresence; private readonly onError; /** A reconnect that finds this session's own DM durable gone cannot succeed by retrying: the * session was retired while the broker was away, as a stack restart retires the sessions its old * manager admitted. The session ends with that reason instead of reporting reconnecting for good. */ private readonly onWarning; constructor(inputs: NativeSessionInputs); identity(): SessionIdentity; subscribe(listener: (event: SessionEvent) => void): () => void; private ingest; surfaced(keys: readonly string[]): void; send(text: string, channel: string, mentions: readonly string[]): Promise; dm(to: DmTarget, text: string, replyTo?: string): Promise; anycast(role: string, text: string): Promise; private call; setStatus(status: "idle" | "working" | "waiting", activity?: string): Promise>; setAttention(mode: "open" | "dnd" | "focus"): Promise>; setChannelMode(channel: string, mode: "quiet" | "muted" | "normal"): Promise>; join(channel: string): Promise>; leave(channel: string): Promise>; inbox(peek: boolean): Promise>; roster(): Promise>; channelInfo(channel: string): Promise>; connection(): Promise>; history(channel: string, limit: number): Promise>; invoke(endpoint: string, command: string, args: Readonly> | undefined, timeoutMs: number): Promise>; reconnect(): Promise>; close(): Promise; private setState; private emit; } //# sourceMappingURL=native-session.d.ts.map