import { type ChannelAdapter, type ChannelMessage, type MentionTarget } from './channel.js'; import { type GatewayMetrics } from './dashboard.js'; import { type InboxEntry, InboxStore } from './inbox.js'; import { type Assistant } from './index.js'; import { Scheduler } from './scheduler.js'; import { TaskStore } from './task-store.js'; import { type GolemConfig, type GroupChatConfig, type StreamingConfig } from './workspace.js'; export declare function splitMessage(text: string, maxLen: number): string[]; /** Sentinel an agent appends as its own trailing line to signal unfinished work. */ export declare const CONTINUE_SENTINEL = "[CONTINUE]"; /** Default max auto-continue relay rounds per inbound message. */ export declare const DEFAULT_AUTO_CONTINUE_ROUNDS = 5; /** Turn-end contract injected into prompts when auto-continue is enabled. */ export declare const TURN_END_CONTRACT: string; /** Prompt sent for each mechanical auto-continue round. */ export declare const AUTO_CONTINUE_PROMPT: string; /** Prompt hint reminding agents how to send images/files via markers. */ export declare const MEDIA_PROTOCOL_HINT: string; /** Split a trailing [CONTINUE] sentinel line off a reply. */ export declare function splitTrailingContinue(text: string): { body: string; hasContinue: boolean; }; /** * Matches a standalone [SEND_IMAGE: ] / [SEND_FILE: ] line. * NOTE: carries the `g` flag — when using .test()/.exec() directly, reset lastIndex * (e.g. new RegExp(source, flags)) or prefer extractMediaMarkers(). */ export declare const MEDIA_MARKER_RE: RegExp; /** * Extract media markers from agent reply text. * Returns the stripped body and the list of parsed markers. * Pure function — no side effects, safe to call idempotently. */ export declare function extractMediaMarkers(text: string): { body: string; markers: Array<{ kind: 'image' | 'file'; path: string; }>; }; /** * Resolve a file path from a media marker against the allowed root. * Returns the resolved absolute path or `null` if it escapes the allowed root. * * - Only the assistant workspace directory (`baseDir`) is allowed. * - Relative paths are resolved against `baseDir`. * - Absolute paths are checked to ensure they stay inside `baseDir`. * - Symlinks are resolved via `realpath` to prevent symlink escapes. * If the file does not exist, the prefix check alone is sufficient. */ export declare function resolveOutboundPath(baseDir: string, rawPath: string): Promise; interface GatewayOpts { dir?: string; port?: number; host?: string; token?: string; apiKey?: string; verbose?: boolean; } export interface GroupMessage { senderName: string; text: string; isBot: boolean; } /** Recent message history per group conversation (channel or Slack thread). */ export declare const groupHistories: Map; /** Total bot replies sent per group — used as a safety valve against runaway chains. */ export declare const groupTurnCounters: Map; /** Timestamp of the last human (non-bot) message per group — used to reset turn counters. */ export declare const groupLastActivity: Map; /** Clear all in-memory group state for a session key (called by the resetSession wrapper). */ export declare function clearGroupChatState(sessionKey: string): void; /** * After this many milliseconds of silence in a group, reset the turn counter. * This ensures maxTurns is a per-conversation limit, not a permanent lifetime ban. */ export declare const GROUP_TURN_RESET_MS: number; /** * Purge all in-memory group state for groups that have been idle longer than * `GROUP_TURN_RESET_MS`. Called periodically to prevent unbounded memory growth * when a gateway process serves many dynamic groups over its lifetime. */ export declare function purgeIdleGroups(): void; export declare function resolveGroupChatConfig(config: GolemConfig): Required; export declare function resolveStreamingConfig(config: GolemConfig): Required; /** Peer bot info for multi-bot awareness in group prompts. */ export interface PeerBot { name: string; role?: string; } export declare function buildGroupPrompt(history: GroupMessage[], senderName: string, userText: string, injectPass: boolean, groupKey: string, _dir: string, /** When set, the message explicitly @mentions someone else — this bot should almost always [PASS]. */ othersAddressed?: string[], /** Other GolemBot instances discovered via fleet, for multi-bot coordination. */ peers?: PeerBot[], /** When true, inject the turn-end contract so the agent signals unfinished work with [CONTINUE]. */ injectContinue?: boolean, /** When true, inject the media protocol hint so agents know how to send images/files. */ mediaHintSupported?: boolean): string; export declare function requireFields(type: string, config: Record, fields: string[]): void; /** * Extract @mentions from AI reply text by matching against known group members. * Returns the original text (unchanged) plus a list of resolved mention targets. */ export declare function parseMentions(text: string, memberCache: Map): { text: string; mentions: MentionTarget[]; }; /** * Process a single incoming IM message through the gateway pipeline. * Exported for unit-testing; `startGateway` calls this for every adapter message. */ export declare function handleMessage(msg: ChannelMessage, config: GolemConfig, assistant: Pick, adapter: Pick, channelType: string, verbose: boolean, dir: string, metrics?: GatewayMetrics, cronCtx?: { taskStore: TaskStore; scheduler: Scheduler; runTask?: (id: string) => Promise; }, /** Fleet peers for multi-bot awareness. */ peers?: PeerBot[]): Promise; /** * Convert a ChannelMessage to inbox entry fields for enqueueing. */ export declare function channelMsgToInbox(msg: ChannelMessage, sessionKey: string, fullText: string): Omit; /** * Start a sequential inbox consumer that processes pending messages one by one. * Returns a stop function. */ export declare function startInboxConsumer(inbox: InboxStore, processEntry: (entry: InboxEntry) => Promise, verbose: boolean): { stop: () => void; }; export declare function startGateway(opts: GatewayOpts): Promise; export {}; //# sourceMappingURL=gateway.d.ts.map