export interface SlackSlashCommand { type: 'slash_command'; command: string; text: string; userId: string; userName: string; channelId: string; channelName: string; teamId: string; responseUrl: string; } export interface SlackInteraction { type: 'interaction'; interactionType: string; payload: Record; userId: string; channelId: string; responseUrl?: string | undefined; } export interface SlackEventCallback { type: 'event_callback'; eventType: string; text: string; userId: string; channelId: string; teamId: string; threadTs?: string | undefined; eventTs?: string | undefined; raw: Record; } export type SlackEvent = SlackSlashCommand | SlackInteraction | SlackEventCallback; export interface SlackOAuthAuthorizeOptions { readonly clientId: string; readonly redirectUri?: string | undefined; readonly scopes?: readonly string[] | undefined; readonly userScopes?: readonly string[] | undefined; readonly state?: string | undefined; readonly teamId?: string | undefined; } export interface SlackOAuthExchangeOptions { readonly clientId: string; readonly clientSecret: string; readonly code: string; readonly redirectUri?: string | undefined; } export interface SlackOAuthExchangeResult { readonly ok: boolean; readonly access_token?: string | undefined; readonly bot_user_id?: string | undefined; readonly app_id?: string | undefined; readonly team?: { readonly id?: string; readonly name?: string; }; readonly authed_user?: Record | undefined; readonly error?: string | undefined; readonly [key: string]: unknown; } export interface SlackAuthTestResult { readonly ok: boolean; readonly url?: string | undefined; readonly team?: string | undefined; readonly user?: string | undefined; readonly team_id?: string | undefined; readonly user_id?: string | undefined; readonly bot_id?: string | undefined; readonly error?: string | undefined; readonly [key: string]: unknown; } export interface SlackSocketModeConnection { readonly ok: boolean; readonly url?: string | undefined; readonly error?: string | undefined; readonly [key: string]: unknown; } export interface SlackConversationRecord { readonly id: string; readonly name?: string | undefined; readonly is_channel?: boolean | undefined; readonly is_group?: boolean | undefined; readonly is_im?: boolean | undefined; readonly is_mpim?: boolean | undefined; readonly is_archived?: boolean | undefined; readonly num_members?: number | undefined; readonly [key: string]: unknown; } export interface SlackUserRecord { readonly id: string; readonly name?: string | undefined; readonly real_name?: string | undefined; readonly is_bot?: boolean | undefined; readonly deleted?: boolean | undefined; readonly profile?: Record | undefined; readonly [key: string]: unknown; } export interface SlackCursorPage { readonly ok: boolean; readonly entries: readonly T[]; readonly nextCursor: string; readonly error?: string | undefined; } export interface SlackSocketModeEnvelope { readonly envelope_id?: string | undefined; readonly type?: string | undefined; readonly accepts_response_payload?: boolean | undefined; readonly payload?: Record | undefined; readonly [key: string]: unknown; } export interface SlackSocketModeClientOptions { readonly appToken: string; readonly integration: SlackIntegration; readonly onEnvelope: (envelope: SlackSocketModeEnvelope, client: SlackSocketModeClient) => void | Promise; readonly WebSocketImpl?: typeof WebSocket | undefined; /** * The socket closed on its own, not because `stop()` was called. * * A node under LAN leadership has to know: it holds the Slack surface on the * strength of being able to read it, and a dropped socket means it cannot. * Staying nominally responsible while reading nothing is the starvation this * whole design exists to avoid, so the holder stands down and lets another * machine take the workspace. */ readonly onClosed?: ((reason: string) => void) | undefined; } /** * SlackIntegration, handles inbound webhook verification/parsing and outbound * message posting for Slack slash commands and interactions. * * Env vars: * SLACK_WEBHOOK_URL , incoming webhook URL for outbound posting * SLACK_BOT_TOKEN , Bot User OAuth token (xoxb-…) for API calls * SLACK_SIGNING_SECRET , used to verify X-Slack-Signature on inbound */ export declare class SlackIntegration { private webhookUrl?; private botToken?; constructor(webhookUrl?: string | undefined, botToken?: string | undefined); static buildOAuthAuthorizeUrl(options: SlackOAuthAuthorizeOptions): string; authTest(token?: string | undefined): Promise; appsConnectionsOpen(appToken: string): Promise; exchangeOAuthCode(options: SlackOAuthExchangeOptions): Promise; listConversations(options?: { readonly token?: string | undefined; readonly cursor?: string | undefined; readonly limit?: number | undefined; readonly types?: readonly string[] | undefined; readonly excludeArchived?: boolean | undefined; readonly teamId?: string | undefined; }): Promise>; listUsers(options?: { readonly token?: string | undefined; readonly cursor?: string | undefined; readonly limit?: number | undefined; readonly teamId?: string | undefined; }): Promise>; /** * Verify an inbound Slack request using HMAC-SHA256. * Slack signs requests with: v0={HMAC-SHA256("v0:{timestamp}:{body}")} */ verifySignature(body: string, timestamp: string, signature: string, signingSecret: string): boolean; /** * Parse an inbound Slack payload into a typed SlackEvent. * Supports slash commands (application/x-www-form-urlencoded) and * interaction payloads (JSON-encoded in a "payload" field). */ parseEvent(body: Record): SlackEvent; private callApi; /** * Post a message to a channel using the Slack Web API (chat.postMessage). * Requires SLACK_BOT_TOKEN. */ postMessage(channel: string, text: string, blocks?: unknown[]): Promise; /** * Post a message via an Incoming Webhook URL. * Requires SLACK_WEBHOOK_URL or a URL passed at call time. */ postWebhook(text: string, blocks?: unknown[], url?: string): Promise; /** * Format an agent result as Slack Block Kit blocks. */ formatAgentResult(agentId: string, task: string, result: string): unknown[]; /** * Format a session summary as Slack Block Kit blocks. */ formatSessionSummary(sessionId: string, messageCount: number, tokensUsed: number): unknown[]; } export declare class SlackSocketModeClient { private readonly options; private socket; private started; /** True while `stop()` is closing the socket, so its close is not a loss. */ private stopping; private readonly WebSocketImpl; constructor(options: SlackSocketModeClientOptions); start(): Promise; stop(): void; ack(envelopeId: string, payload?: Record): void; send(payload: Record): void; get isStarted(): boolean; private handleMessage; } //# sourceMappingURL=slack.d.ts.map