import { type ChannelSetupAwaitChoice, type ChannelSetupLog } from "#setup/cli/index.js"; import { type SlackConnectorCreateDeps } from "./slack-connect-create.js"; import { readProjectLink, type SlackConnectLifecycleDeps } from "./slack-connect-lifecycle.js"; export { parseCreatedSlackConnector, parseSlackConnectorDetails, pickSlackConnector, type SlackConnectorRef, } from "./slack-connect.js"; /** Injected for tests; defaults to the real Vercel CLI subprocess primitives. */ export interface SlackbotProvisionDeps extends SlackConnectLifecycleDeps, SlackConnectorCreateDeps { /** Test seam for the linked Vercel project and team lookup. */ readProjectLink?: typeof readProjectLink; /** Test seam for the workspace poll's pacing; defaults to a real sleep. */ delay?: (ms: number, signal?: AbortSignal) => Promise; /** Monotonic-enough clock for enforcing the workspace lookup deadline. */ now?: () => number; } /** * Outcome of the Connect create-and-attach sequence for a Slackbot. The * discriminant is the complete lifecycle state: `attached` means a connector * exists, this project is registered as the trigger destination, and the app * is installed into a Slack workspace. * `not-installed` means the workspace-install deadline elapsed and any connector * created by this attempt was removed. `cleanup-failed` means it may remain and * callers must stop rather than create another connector. Attachment setup * reports detach and attach failures separately because attach must not run * while an old trigger destination may still exist. */ export type ProvisionSlackbotResult = { state: "connector-lookup-failed"; } | { state: "create-failed"; } | { state: "cancelled"; } | { state: "existing-not-installed"; connectorUid: string; } | { state: "cleanup-failed"; connectorUids: readonly string[]; } | { state: "detach-failed"; connectorUid: string; } | { state: "attach-failed"; connectorUid: string; } | { state: "not-installed"; } | { state: "installation-check-failed"; connectorUid: string; } | { state: "attached"; connectorUid: string; /** Deep link that opens a DM compose with the bot ("chat with your agent"). */ chatUrl?: string; workspaceName?: string; }; /** * Creates or reuses a Slack connector and points its event destination at eve. * A successful `connect create` is the completion boundary for a new browser * flow. Existing connectors are verified through their team-scoped detail * payload before attachment. */ export interface ProvisionSlackbotOptions { /** * Cancels the caller's whole operation. The promise rejects after attempting * cleanup; only the explicit interactive Cancel action returns `cancelled`. */ signal?: AbortSignal; /** Concurrent retry/cancel controls supplied by an interactive prompter. */ awaitChoice?: ChannelSetupAwaitChoice; } export declare function provisionSlackbot(log: ChannelSetupLog, projectRoot: string, /** Connector short-name passed to `vercel connect create slack --name`. */ slug: string, deps?: SlackbotProvisionDeps, options?: ProvisionSlackbotOptions): Promise; /** * Patches a connector UID chosen by Connect before the caller deploys the channel definition. */ export declare function reconcileSlackUid(log: ChannelSetupLog, projectRoot: string, slackbot: ProvisionSlackbotResult, expectedUid: string): Promise;