/** * Per-bot, per-chat role file resolver. * * Role definitions live in botmux's session data directory, keyed by the bot's * Lark app id and the chat id: * {config.session.dataDir}/roles/{larkAppId}/{chatId}.md * * Storing under the session data dir (rather than the bot's project workingDir) * keeps role config out of the user's code repo, makes it relocate together * with the rest of session state via SESSION_DATA_DIR, and keying on larkAppId * means two bots that share a workingDir still get independent personas. Role * content is injected into the CLI prompt as a block, allowing the same * bot to adopt different personas in different Lark groups. */ export declare const MAX_ROLE_BYTES: number; export declare function isValidRoleChatId(chatId: string): boolean; /** * Resolve the per-chat role content for a given bot (larkAppId) and chat. * Returns the role markdown string, or null if no role file exists. */ export declare function resolveRoleFile(larkAppId: string, chatId: string): string | null; /** Clear the in-memory cache (useful for testing or manual reload). */ export declare function clearRoleCache(): void; /** Invalidate cache for a specific larkAppId + chatId pair. */ export declare function invalidateRoleCache(larkAppId: string, chatId: string): void; /** Write or overwrite role content for a chat. Creates the parent directory if needed. */ export declare function writeRoleFile(larkAppId: string, chatId: string, content: string): void; /** Delete a role file for a chat. */ export declare function deleteRoleFile(larkAppId: string, chatId: string): boolean; export type RoleSource = 'chat' | 'team' | 'none'; /** Resolve the team-level (per-bot) role, or null. */ export declare function resolveTeamRoleFile(larkAppId: string): string | null; /** Write or overwrite the team-level role for a bot. */ export declare function writeTeamRoleFile(larkAppId: string, content: string): void; /** Delete the team-level role for a bot. */ export declare function deleteTeamRoleFile(larkAppId: string): boolean; /** * Layered role resolution: per-chat override > team-level default > none. * Returns the effective content plus its source, so callers/UI/logs can * explain *why* a given role is in effect. */ export declare function resolveRole(larkAppId: string, chatId: string): { content: string | null; source: RoleSource; }; export type RoleInjectMode = 'every' | 'once'; /** * Read the bot-level DEFAULT injection mode (applies to any chat that hasn't set * its own). Defaults to 'every' (legacy) when unset/unparseable. This is the * fallback consulted by readRoleInjectMode — it lets an operator make the bot's * default role inject-once across all its chats from the Bot config page, * without touching each chat individually. */ export declare function readTeamRoleInjectMode(larkAppId: string): RoleInjectMode; /** Persist the bot-level default injection mode. 'every' removes the sidecar. */ export declare function writeTeamRoleInjectMode(larkAppId: string, mode: RoleInjectMode): void; /** * Read the injection mode for a (bot, chat). A chat that set its own mode via * 角色管理 wins (sidecar present ⇒ 'once'); otherwise we fall back to the * bot-level default (readTeamRoleInjectMode), which itself defaults to 'every' * — so legacy behavior is unchanged until an operator opts a bot into 'once'. */ export declare function readRoleInjectMode(larkAppId: string, chatId: string): RoleInjectMode; /** * Persist the injection mode. 'every' (the default) removes the sidecar so the * on-disk state stays clean; 'once' writes it. */ export declare function writeRoleInjectMode(larkAppId: string, chatId: string, mode: RoleInjectMode): void; /** Whether dispatch completion additionally leaves a same-topic send copy after report. */ export declare function readRoleDispatchCompletionEnabled(larkAppId: string, chatId: string): boolean; export declare function writeRoleDispatchCompletionEnabled(larkAppId: string, chatId: string, enabled: boolean): void; /** Remove all per-chat role metadata when the chat role is deleted. */ export declare function deleteRoleMeta(larkAppId: string, chatId: string): void; /** * Resolve the effective role content + source (like resolveRole) plus the * per-chat injection mode. The prompt builder uses this to decide whether to * emit the block on follow-up turns. */ export declare function resolveRoleInjection(larkAppId: string, chatId: string): { content: string | null; source: RoleSource; injectMode: RoleInjectMode; }; //# sourceMappingURL=role-resolver.d.ts.map