/** * Creating Slack agents from Slack, and the Ask form's shortcut context. * * A proposal is the server's own record of a confirmation card a chat posted * in its Slack thread. A click on the card is checked against this row, never * against the button payload. Both tables are HOME-owned, like * `slack_channel_routes`. * * Authorization (who may confirm) is decided by callers from live grants. * Nothing here grants anything. */ import type { SessionAvatar } from "@opengeni/contracts"; import { type Database } from "./database.js"; export type SlackAgentProposalHome = { accountId: string; workspaceId: string; }; export type SlackAgentProposalStatus = "pending" | "creating" | "created" | "cancelled"; export type SlackAgentProposal = { id: string; accountId: string; workspaceId: string; connectionId: string; slackTeamId: string; targetAccountId: string; targetWorkspaceId: string; proposedBySessionId: string; proposedBySlackUserId: string | null; slackChannelId: string; slackThreadTs: string; slackMessageTs: string | null; messageOperationId: string; name: string; nameKey: string; description: string; avatar: SessionAvatar; instructions: string; status: SlackAgentProposalStatus; createdSlackAgentId: string | null; decidedBySubjectId: string | null; decidedBySlackUserId: string | null; createdAt: Date; updatedAt: Date; }; export declare function insertSlackAgentProposal(db: Database, home: SlackAgentProposalHome, input: { id: string; connectionId: string; slackTeamId: string; targetAccountId: string; targetWorkspaceId: string; proposedBySessionId: string; proposedBySlackUserId: string | null; slackChannelId: string; slackThreadTs: string; messageOperationId: string; name: string; nameKey: string; description: string; avatar: SessionAvatar; instructions: string; }): Promise; export declare function getSlackAgentProposal(db: Database, home: SlackAgentProposalHome, input: { proposalId: string; }): Promise; /** Remember which Slack message is the card, once it is posted. */ export declare function setSlackAgentProposalMessage(db: Database, home: SlackAgentProposalHome, input: { proposalId: string; slackMessageTs: string; }): Promise; /** * Move a proposal from one status to another. Returns the updated row, or null * when it was not in one of `from` (someone else settled it first). */ export declare function transitionSlackAgentProposal(db: Database, home: SlackAgentProposalHome, input: { proposalId: string; from: readonly SlackAgentProposalStatus[]; to: SlackAgentProposalStatus; createdSlackAgentId?: string; decidedBySubjectId?: string | null; decidedBySlackUserId?: string | null; }): Promise; export type SlackAskForm = { id: string; connectionId: string; slackTeamId: string; slackUserId: string; slackChannelId: string; slackMessageTs: string; slackThreadTs: string | null; providerEventId: string; messageText: string; expiresAt: Date; }; /** * Keep the message a shortcut opened the Ask form on. Expired forms of the same * installation are removed on the way, so unsubmitted forms do not pile up. */ export declare function insertSlackAskForm(db: Database, home: SlackAgentProposalHome, input: Omit & { now?: Date; }): Promise; /** An unexpired Ask form, or null. */ export declare function getSlackAskForm(db: Database, home: SlackAgentProposalHome, input: { formId: string; now?: Date; }): Promise; /** Drop a submitted form. Its request is in the inbox by then. */ export declare function deleteSlackAskForm(db: Database, home: SlackAgentProposalHome, input: { formId: string; }): Promise;