/** * Shared Context for Multi-Agent Communication * * Manages inter-agent message sharing so each agent is aware of * what other agents have said in the conversation. */ import type { AgentPersonaConfig } from './types.js'; /** * Message entry in shared context */ export interface SharedMessage { /** Agent ID that sent the message (null for human) */ agentId: string | null; /** Display name of the sender */ displayName: string; /** Message content */ content: string; /** Timestamp */ timestamp: number; /** Discord message ID */ messageId?: string; /** Whether this is a human message */ isHuman: boolean; } /** * Channel context containing recent messages */ export interface ChannelContext { /** Channel ID */ channelId: string; /** Recent messages (limited to last N) */ messages: SharedMessage[]; /** Last update timestamp */ lastUpdate: number; } /** * Shared Context Manager * * Maintains a sliding window of recent messages per channel * so agents can be aware of the conversation context. */ export declare class SharedContextManager { /** Context per channel: Map */ private contexts; /** Maximum messages to keep per channel */ private readonly maxMessages; /** Maximum age of messages in ms (default: 10 minutes) */ private readonly maxAge; constructor(options?: { maxMessages?: number; maxAgeMs?: number; }); /** * Record a human message */ recordHumanMessage(channelId: string, username: string, content: string, messageId?: string): void; /** * Record a system/automated message (e.g., PR Review Poller) * Shows up in context but isn't from a human or a specific agent. */ recordSystemMessage(channelId: string, displayName: string, content: string, messageId?: string): void; /** * Record an agent message */ recordAgentMessage(channelId: string, agent: AgentPersonaConfig, content: string, messageId?: string): void; /** * Record a message to the channel context */ private recordMessage; /** * Trim context to max messages and max age */ private trimContext; /** * Get context for a channel */ getContext(channelId: string): ChannelContext | undefined; /** * Get recent messages for a channel */ getRecentMessages(channelId: string, limit?: number): SharedMessage[]; /** * Build context string for agent prompt injection * Excludes messages from the requesting agent to avoid self-reference */ buildContextForAgent(channelId: string, excludeAgentId: string, maxMessages?: number): string; /** * Get the last message from another agent (for response chaining) */ getLastAgentMessage(channelId: string, excludeAgentId?: string): SharedMessage | null; /** * Get the last human message in a channel */ getLastHumanMessage(channelId: string): SharedMessage | null; /** * Check if a specific agent has responded since the last human message */ hasAgentRespondedSinceHuman(channelId: string, agentId: string): boolean; /** * Clear context for a channel */ clearChannel(channelId: string): void; /** * Clear all contexts */ clearAll(): void; /** * Get all channel IDs with active contexts */ getActiveChannels(): string[]; /** * Truncate text to max length */ private truncate; } /** * Get or create the shared context manager singleton */ export declare function getSharedContextManager(options?: { maxMessages?: number; maxAgeMs?: number; }): SharedContextManager; /** * Reset the shared context manager (for testing) */ export declare function resetSharedContextManager(): void; //# sourceMappingURL=shared-context.d.ts.map