import { type Database } from "./database.js"; import { type TeamsInstallation } from "./teams-conversations.js"; /** A workspace (and, optionally, an agent in it) a Teams chat can use. */ export type TeamsChatTarget = { workspaceId: string; agentId: string | null; }; export type TeamsChatChoice = TeamsChatTarget & { subjectId: string; version: number; }; /** The person's current choice for their 1:1 chat, or null. Memory only. */ export declare function getTeamsChatChoice(db: Database, i: TeamsInstallation, input: { actorId: string; subjectId: string; }): Promise; /** * Remember what the person's 1:1 chat uses. The link must still name them; * the target must be a workspace of the installation's organization. */ export declare function setTeamsChatChoice(db: Database, i: TeamsInstallation, input: { actorId: string; subjectId: string; } & TeamsChatTarget): Promise; /** Forget the person's choice, for example when they lost access to it. Only their own. */ export declare function clearTeamsChatChoice(db: Database, i: TeamsInstallation, input: { actorId: string; subjectId: string; }): Promise; /** How long a switch card's numbers stay valid. */ export declare const TEAMS_ROUTE_PROMPT_TTL_MS: number; /** The most numbered options one switch card holds (the table's CHECK). */ export declare const TEAMS_ROUTE_PROMPT_MAX_OPTIONS = 100; export type TeamsRoutePrompt = { id: string; /** The message waiting for the answer, or null for a plain "switch". */ payload: Record | null; options: Array; }; /** * Record the switch card a person is shown, replacing any earlier one: only * the latest card's numbers count. Options are numbered from 1 in order. */ export declare function putTeamsRoutePrompt(db: Database, i: TeamsInstallation, input: { actorId: string; subjectId: string; payload: Record | null; options: readonly TeamsChatTarget[]; }): Promise; /** The person's latest switch card in this installation generation, while it is fresh, or null. */ export declare function readTeamsRoutePrompt(db: Database, i: TeamsInstallation, input: { actorId: string; subjectId: string; now?: Date; }): Promise; /** * Answer a switch card: the option at `position` of the person's latest * fresh card, and the message that was waiting for it. The card is removed * in the same transaction, so a repeated answer finds nothing. */ export declare function takeTeamsRoutePromptOption(db: Database, i: TeamsInstallation, input: { actorId: string; subjectId: string; position: number; now?: Date; }): Promise<{ target: TeamsChatTarget; payload: Record | null; } | null>; /** Remove switch cards older than their lifetime. Returns how many. */ export declare function pruneTeamsRoutePrompts(db: Database, i: TeamsInstallation, now?: Date): Promise; /** * Where an organization lets its Teams connection start work. `workspaceIds` * null is every workspace of the organization; an array narrows it to those, * and the installation's own workspace is always included. Personal * workspaces are their own switch (and the organization's Personal workspace * setting still applies). */ export type TeamsReach = { workspaceIds: string[] | null; personalWorkspaces: boolean; version: number; }; export declare function getTeamsReach(db: Database, i: TeamsInstallation): Promise; /** Whether a workspace is inside the reach. The installation's own always is. */ export declare function teamsReachIncludes(reach: Pick, i: Pick, workspace: { workspaceId: string; personal: boolean; }): boolean; /** * Change the reach. The caller must already have checked that the person is * an organization administrator who manages the installation's workspace. * Selected workspaces must belong to the organization and be shared * workspaces; the installation's own workspace is implied and not stored. * `expectedVersion` makes a stale editor fail instead of overwriting. */ export declare function setTeamsReach(db: Database, i: TeamsInstallation, input: { workspaceIds: readonly string[] | null; personalWorkspaces: boolean; expectedVersion?: number; }): Promise; /** A workspace's name in the organization, for telling a person what they lost access to. */ export declare function teamsWorkspaceName(db: Database, input: { accountId: string; workspaceId: string; }): Promise; /** An agent's name and its workspace's name, for the header on its Teams replies. */ export declare function teamsAgentLabel(db: Database, input: { accountId: string; agentId: string; }): Promise<{ name: string; workspaceName: string; } | null>; /** A shared agent Teams can offer: ids, names and where it works. */ export type TeamsAgentDirectoryEntry = { id: string; accountId: string; workspaceId: string; /** The agent's workspace's name, for replies and refusals. */ workspaceName: string; name: string; nameKey: string; avatar: unknown; /** Anyone in the organization may use it ("Who can use it: Anyone in "). */ organizationAccess: boolean; }; /** The most agents one directory read returns. */ export declare const TEAMS_AGENT_DIRECTORY_LIMIT = 1000; /** * The shared (workspace-visible) agents of an organization whose home is one * of `workspaceIds` (null: any shared workspace), by name. Only me agents and * agents of Personal workspaces are never listed. Agents in * `preferWorkspaceIds`, and agents anyone in the organization may use, come * first, so a large organization's limit only ever drops agents the person * can't use. Whether the person may use one is decided by the caller from * their live access to its workspace; this only lists. */ export declare function listTeamsAgentDirectory(db: Database, input: { accountId: string; workspaceIds: readonly string[] | null; preferWorkspaceIds?: readonly string[]; }): Promise; /** * One shared agent of the organization that lives in `workspaceId` (never * an Only me agent or one of a Personal workspace), read live; or null. `db` * may be a transaction: the read runs in an account-only scope and the * parent scope is restored afterwards. */ export declare function getTeamsAgentInWorkspace(db: Database, input: { accountId: string; workspaceId: string; agentId: string; }): Promise; /** * The service principal a Teams chat with an agent anyone in the * organization may use runs as, when the person asking isn't a member of the * agent's workspace (the Teams counterpart of Slack's `slack-agent:`). * Never a person. */ export declare function teamsOrganizationAgentSubjectId(agentId: string): string; /** The agent such a principal names, or null for anyone else. */ export declare function teamsOrganizationAgentIdFromSubject(subjectId: string | null | undefined): string | null; /** A Teams route whose chat runs as such an agent: its id starts with this. */ export declare const TEAMS_ORGANIZATION_AGENT_ROUTE_PREFIX = "teams-agent:";