import { AuthorizeResult } from "../authorization/authorize-result"; import { SlackAPIClient, ChatPostMessageRequest, ChatPostMessageResponse, WebhookParams, AssistantThreadsSetStatusResponse, AssistantThreadsSetSuggestedPromptsResponse, AssistantThreadsSetTitleResponse } from "slack-web-api-client"; import { AssistantThreadContextStore } from "../assistant/thread-context-store"; import { AssistantThreadContext } from "../assistant/thread-context"; /** * SlackApp context object that provides data available before performing authorize() */ export interface PreAuthorizeSlackAppContext { isEnterpriseInstall?: boolean; enterpriseId?: string; teamId?: string; userId?: string; actorEnterpriseId?: string; actorTeamId?: string; actorUserId?: string; botId?: string; botUserId?: string; responseUrl?: string; channelId?: string; threadTs?: string; isAssistantThreadEvent: boolean; triggerId?: string; functionExecutionId?: string; functionBotAccessToken?: string; custom: { [key: string]: any; }; } /** * respond() utility for easily utilizing response_url to post a channel message. */ export type Respond = (params: WebhookParams) => Promise; /** * SlackApp context object that provides data available after performing authorize() */ export type SlackAppContext = { client: SlackAPIClient; botToken: string; botId: string; botUserId: string; userToken?: string; authorizeResult: AuthorizeResult; } & PreAuthorizeSlackAppContext; /** * SlackApp context object that provides channelId and say() utility */ export type SlackAppContextWithChannelId = { channelId: string; say: (params: Omit) => Promise; } & SlackAppContext; export type SlackAppContextWithAssistantUtilities = SlackAppContextWithChannelId & { setStatus: (args: { status: string; }) => Promise; setSuggestedPrompts: (args: { title?: string; prompts: ({ title: string; message: string; } | string)[]; }) => Promise; setTitle: (args: { title: string; }) => Promise; threadContextStore: AssistantThreadContextStore; saveThreadContextStore: (newContext: AssistantThreadContext) => Promise; threadContext?: AssistantThreadContext; channelId: string; threadTs: string; isAssitantThreadEvent: true; }; /** * SlackApp context object that provides channelId and respond() utility. */ export type SlackAppContextWithRespond = { channelId: string; respond: Respond; } & SlackAppContext; /** * SlackApp context object that may provide respond() utility. */ export type SlackAppContextWithOptionalRespond = { respond?: Respond; } & SlackAppContext; /** * Internal method that sets a context object's basic properties. */ export declare function builtBaseContext(body: Record): PreAuthorizeSlackAppContext; /** * Extracts is_enterprise_install: boolean property from payload. * @param body the whole request payload data * @returns is_enterprise_install if exists */ export declare function extractIsEnterpriseInstall(body: Record): boolean | undefined; /** * Extracts enterprise_id: string property from payload. * @param body the whole request payload data * @returns enterprise_id if exists */ export declare function extractEnterpriseId(body: Record): string | undefined; /** * Extracts team_id: string property from payload. * @param body the whole request payload data * @returns team_id if exists */ export declare function extractTeamId(body: Record): string | undefined; /** * Extracts user_id: string property from payload. * @param body the whole request payload data * @returns user_id if exists */ export declare function extractUserId(body: Record): string | undefined; /** * Extracts enterprise_id of the organization to which the actor of the event belongs. * @param body the whole request payload data * @returns enterprise_id if exists */ export declare function extractActorEnterpriseId(body: Record): string | undefined; /** * Extracts team_id of the workspace to which the actor of the event belongs. * @param body the whole request payload data * @returns team_id if exists */ export declare function extractActorTeamId(body: Record): string | undefined; /** * Extracts user_id of the actor of the event belongs. * @param body the whole request payload data * @returns user_id if exists */ export declare function extractActorUserId(body: Record): string | undefined; /** * Extracts response_url: string property from payload. * @param body the whole request payload data * @returns response_url if exists */ export declare function extractResponseUrl(body: Record): string | undefined; /** * Extracts channel_id: string property from payload. * @param body the whole request payload data * @returns channel_id if exists */ export declare function extractChannelId(body: Record): string | undefined; /** * Determines if the payload represents an assistant thread event. * Assistant thread events include thread lifecycle events and messages in assistant DM threads. * @param body - The whole request payload data * @returns true if this is an assistant thread event (thread_started, context_changed, or DM message) */ export declare function isAssitantThreadEvent(body: Record): boolean; /** * Extracts thread_ts property from assistant thread event payloads. * This utility is specifically designed for AI assistant thread use cases. * * Note: thread_ts is always required for assistant threads, but optional for regular channels. * Using this value indiscriminately with the say utility could affect existing app behaviors. * * @param body - The whole request payload data * @returns thread_ts if this is an assistant thread event, undefined otherwise */ export declare function extractThreadTs(body: Record): string | undefined; /** * Extracts trigger_id/interactivity_pointer property from payload. * @param body the whole request payload data * @returns trigger_id if exists */ export declare function extractTriggerId(body: Record): string | undefined; /** * Extracts function_execution_id property from payload. * @param body the whole request payload data * @returns function_execution_id if exists */ export declare function extractFunctionExecutionId(body: Record): string | undefined; /** * Extracts JIT bot_access_token property for a custom function invocation from payload. * @param body the whole request payload data * @returns function's JIT bot_access_token if exists */ export declare function extractFunctionBotAccessToken(body: Record): string | undefined; //# sourceMappingURL=context.d.ts.map