import type { PinetReadOptions, PinetReadResult } from "@pinet/pinet-core/pinet-read-formatting"; import type { AgentSessionSearchInfo, AgentSessionSearchOptions, ClientAgentInfo, NormalizedMessageContent, OutboundAttachmentFile, PortLeaseAcquireInput, PortLeaseInfo, PortLeaseListOptions, PortLeaseReleaseInput, PortLeaseRenewInput, PinetLaneInfo, PinetLaneListOptions, PinetLaneParticipantInfo, PinetLaneParticipantUpsertInput, PinetLaneUpsertInput } from "./types.js"; export interface InboxItem { inboxId: number; message: { id: number; threadId: string; source: string; direction: string; sender: string; body: string; metadata: Record | null; createdAt: string; }; } export type { PinetReadMessage, PinetReadOptions, PinetReadResult, PinetUnreadThreadSummary, } from "@pinet/pinet-core/pinet-read-formatting"; export interface ThreadInfo { threadId: string; source: string; channel: string; ownerAgent: string | null; ownerBinding?: "explicit" | null; metadata?: Record | null; createdAt: string; updatedAt: string; } export type AgentInfo = ClientAgentInfo; export type { AgentSessionSearchInfo, AgentSessionSearchOptions }; export interface ScheduledWakeupInfo { id: number; threadId: string; fireAt: string; } export type { PortLeaseAcquireInput, PortLeaseInfo, PortLeaseListOptions, PortLeaseReleaseInput, PortLeaseRenewInput, PinetLaneInfo, PinetLaneListOptions, PinetLaneParticipantInfo, PinetLaneParticipantUpsertInput, PinetLaneUpsertInput, }; export declare const DEFAULT_SOCKET_PATH: string; export declare const REQUEST_TIMEOUT_MS = 5000; export declare const RECONNECT_DELAY_MS = 3000; export declare const INITIAL_RECONNECT_DELAY_MS = 1000; export declare const MAX_RECONNECT_DELAY_MS = 30000; export declare const HEARTBEAT_INTERVAL_MS = 5000; export declare const HEARTBEAT_METADATA_PROVIDER_TIMEOUT_MS = 2500; /** Compute reconnect delay with exponential backoff and jitter. */ export declare function computeReconnectDelay(attempt: number, random?: number): number; export interface AgentBroadcastResult { channel: string; messageIds: number[]; recipients: Array<{ id: string; name: string; }>; } export type BrokerConnectOpts = { path: string; } | { host: string; port: number; }; export interface BrokerClientAuthOptions { meshSecret?: string; meshSecretPath?: string; } export declare class BrokerClient { private readonly connectOpts; private readonly meshSecret; private readonly meshSecretPath; private socket; private connected; private shuttingDown; private reconnectTimer; private heartbeatTimer; private disconnectHandler; private reconnectHandler; private reconnectFailedHandler; private reconnectAttempt; private registrationSnapshot; private registeredIdentity; private heartbeatMetadataProvider; private heartbeatMetadataInFlight; private nextId; private readonly pending; private buffer; constructor(opts?: string | (BrokerConnectOpts & BrokerClientAuthOptions)); connect(): Promise; disconnect(): void; disconnectGracefully(): Promise; isConnected(): boolean; private resolveMeshSecret; private authenticateIfNeeded; register(name: string, emoji: string, metadata?: Record, stableId?: string): Promise<{ agentId: string; name: string; emoji: string; metadata?: Record | null; }>; unregister(): Promise; heartbeat(metadata?: Record | null): Promise; setHeartbeatMetadataProvider(provider: (() => Promise | null | undefined>) | null): void; pollInbox(): Promise; readInbox(options?: PinetReadOptions): Promise; ackMessages(ids: number[]): Promise; send(threadId: string, text: string, metadata?: Record): Promise; sendMessage(input: { threadId: string; body: string; source?: string; channel?: string; content?: NormalizedMessageContent; blocks?: ReadonlyArray>; files?: ReadonlyArray; agentName?: string; agentEmoji?: string; agentOwnerToken?: string; metadata?: Record; }): Promise<{ adapter: string; messageId: number; threadId: string; channel: string; source: string; }>; claimThread(threadId: string, channel?: string, source?: string): Promise<{ claimed: boolean; }>; resolveThread(threadTs: string): Promise; updateStatus(status: "working" | "idle"): Promise; sendAgentMessage(target: string, body: string, metadata?: Record): Promise; sendAgentBroadcast(channel: string, body: string): Promise; scheduleWakeup(fireAt: string, body: string): Promise; listLanes(options?: PinetLaneListOptions): Promise; upsertLane(input: PinetLaneUpsertInput): Promise; setLaneParticipant(input: PinetLaneParticipantUpsertInput): Promise; acquirePortLease(input: PortLeaseAcquireInput): Promise; renewPortLease(input: PortLeaseRenewInput): Promise; releasePortLease(input: PortLeaseReleaseInput): Promise; getPortLease(leaseId: string): Promise; listPortLeases(options?: PortLeaseListOptions): Promise; expirePortLeases(): Promise; listThreads(): Promise; listAgents(includeDisconnected?: boolean): Promise; searchAgentSessions(options?: AgentSessionSearchOptions): Promise; invokeAdapterCapability(adapter: string, capability: string, params?: Record): Promise>; /** * Compatibility wrapper for callers that still need direct Slack API access. * The broker RPC boundary remains adapter-neutral; Slack-specific payloads are * interpreted inside the Slack adapter's api.call capability. */ slackProxy(method: string, params: Record): Promise>; onDisconnect(handler: () => void): void; onReconnect(handler: () => void): void; onReconnectFailed(handler: (error: Error) => void): void; getReconnectAttempt(): number; getRegisteredIdentity(): { agentId: string; name: string; emoji: string; metadata?: Record | null; } | null; private request; private onData; private handleResponse; private scheduleReconnect; private connectSocket; private performRegister; private reconnectOnce; private startHeartbeat; private readHeartbeatMetadata; private runHeartbeatTick; private stopHeartbeat; private rejectAllPending; }