/** * Slack directory — "who can I @ here?" for agents. * * Two sources, merged: * - Crewly Cloud's directory of this account: every registered instance, * its teams and members, each member's Slack bot user. Tells an agent * that "Mia" is on the Portal team on the mac-mini and how to @ her. * - The Slack channel itself (`conversations.members` + `users.info`): * every bot user actually in the channel, including agents of OTHER * Crewly accounts (another company's Crewly sharing the workspace) and * bots from other vendors. Those are @-able even though Cloud knows * nothing about them. * * Results are cached per channel for a few minutes; Slack rate-limits * `users.info`. * * @module services/slack/slack-directory */ /** One colleague, as an agent should see it. */ export interface DirectoryEntry { name: string; /** `<@Uxxx>` when the colleague has a Slack bot user; null when only Crewly knows it. */ mention: string | null; botUserId: string | null; /** Crewly agent session when the colleague is a Crewly agent of this account. */ agentSession: string | null; team: string | null; /** Device name of the Crewly instance running it; 'this machine' for local agents. */ machine: string | null; /** Cloud instance id of the machine running it (agents of this account); room-join requests target it. */ instanceId?: string | null; /** True when Cloud names this agent its team's leader (Cloud directory `leader`, when sent). */ isLeader?: boolean; /** Where the entry came from. */ source: 'this-machine' | 'this-account' | 'channel'; /** True when the colleague is a member of the requested channel. */ inChannel: boolean; /** Set for channel members that are not Crewly agents of this account (other accounts, other bots). */ kind: 'agent' | 'bot' | 'human'; } /** Cloud directory shape (`GET /api/cloud/slack/directory`). */ export interface CloudDirectoryInstance { instanceId: string; deviceName: string; live: boolean; teams: Array<{ teamId: string; name: string; channelId: string | null; /** Session of the team's leader, when Cloud sends it */ leader?: string | null; agents: Array<{ agentSession: string; displayName: string; botUserId: string | null; installed: boolean; }>; }>; } /** Dependencies. */ export interface SlackDirectoryDeps { /** This instance's Cloud device id (to mark local agents). */ getInstanceId: () => string | null; /** Cloud directory fetch; null when not signed in. */ fetchCloudDirectory: () => Promise; /** Slack: member user ids of a channel (bots included); null when Slack is down. */ listChannelMembers: (channelId: string) => Promise; /** Slack: user record for a member id. */ getUser: (userId: string) => Promise<{ name: string; isBot: boolean; } | null>; /** Display name of a local team member by session (Cloud only knows names once an app exists). */ localMemberName?: (agentSession: string) => string | null; now?: () => number; } /** The directory service. */ export declare class SlackDirectoryService { private readonly deps; private readonly logger; private readonly cache; constructor(deps: SlackDirectoryDeps); /** * Colleagues an agent can address. With a channel id the result is scoped * to that channel (Cloud agents marked `inChannel`, plus channel-only bots * and humans); without one it is the account-wide roster. * * @param channelId - Slack channel id, optional * @returns Entries, local agents first */ list(channelId?: string): Promise; /** * One line for a channel prompt: who is in the channel and how to @ them. * * @param channelId - Slack channel id * @returns e.g. `Atlas (Think Tank, this machine) @Atlas · Mia (Portal, mac-mini) @Mia · Steve (human)`; '' when unknown */ rosterLine(channelId: string): Promise; /** Drop cached rosters (team saved, identity installed). */ invalidate(): void; } /** Install the process-wide instance. */ export declare function setSlackDirectoryService(service: SlackDirectoryService | null): void; /** The process-wide instance, or null before wiring. */ export declare function getSlackDirectoryService(): SlackDirectoryService | null; //# sourceMappingURL=slack-directory.service.d.ts.map