/** * Host-side ports the channels engine consumes. The framework never enforces * authority — hosts do; the engine treats IdentityPort/BindingStore answers as * authoritative and adds no permission model of its own (spec §6). */ import type { AgentEvent } from "@skaile/workspaces/types"; import type { Binding, ChannelActor, ChannelMessage, ChannelPlatform, ConversationKey } from "./types.js"; /** Detaches a subscription created by {@link SessionPort.subscribe}. */ export type Unsubscribe = () => void; /** A platform actor resolved to a host account by {@link IdentityPort}. */ export type HostUser = { /** Host-side user id — becomes the attributed senderId on delivery. */ id: string; displayName: string; }; /** Handle to a host session returned by {@link SessionPort.createSession}. */ export type SessionRef = { sessionId: string; }; /** Spec for lazy thread-session creation on bot-mention (spec §7.1.6). */ export type NewSessionSpec = { /** Human-readable title, e.g. "Teams: ". */ title: string; platform: ChannelPlatform; conversationKey: ConversationKey; tenantId?: string; /** Resolved host user requesting creation, when identity mapped. */ createdByUserId?: string; }; /** Host's session boundary — deliver inbound messages, subscribe to agent output. */ export interface SessionPort { /** Wakes if hibernated; persists attributed; prompts the agent (spec §7.1.7). */ deliver(binding: Binding, msg: ChannelMessage): Promise; /** One live subscription per active binding; consumes raw AgentEvents. */ subscribe(binding: Binding, sink: (e: AgentEvent) => void): Unsubscribe; createSession?(spec: NewSessionSpec): Promise; } /** Host's identity boundary — maps platform actors to host users. */ export interface IdentityPort { /** null ⇒ host policy applies (reject / framed-external — spec §7.1.5). */ resolveActor(actor: ChannelActor): Promise; } /** Host-persisted conversationKey ↔ session join (spec §5.1); answers are authoritative. */ export interface BindingStore { get(key: ConversationKey): Promise; put(binding: Binding): Promise; listForSession(sessionId: string): Promise; remove(key: ConversationKey): Promise; } /** Per-platform credentials. Adapters never persist these (spec §8). */ export type ChannelCredential = { kind: "msteams"; appId: string; clientSecret: string; } | { kind: "token"; token: string; baseUrl?: string; }; /** Host's secret boundary — resolves per-tenant platform credentials on demand. */ export interface CredentialPort { forTenant(platform: ChannelPlatform, tenantId: string): Promise; } /** Web-standard handler so hosts adapt it to Fastify raw child or Bun.serve alike. */ export type RawHttpHandler = (req: Request) => Promise; /** Host's HTTP surface for webhook-style adapters. */ export interface IngressHost { /** Webhook-style adapters (Teams) register here; outbound-socket adapters need nothing. */ registerHttpRoute?(path: string, handler: RawHttpHandler): void; } //# sourceMappingURL=ports.d.ts.map