/** * Helpers shared across platform adapters. * * The agent runner is platform-agnostic: it hands strings and structured tool * results to each adapter, which decides how to split, format, and route them. * The split/normalize logic itself doesn't differ across platforms — only the * markup wrappers — so it lives here once. */ import type { MessagingEventHandler } from "../adapter.js"; export type { ChatResponseErrorContext, ChatResponseErrorOperation, ChatResponseErrorReporter, ResolveStopTargetInput, RetryOptions, } from "./types.js"; import type { ChatResponseErrorContext, ChatResponseErrorReporter, RetryOptions, ResolveStopTargetInput } from "./types.js"; export declare function createChatResponseErrorReporter(resolve: () => Omit): ChatResponseErrorReporter; export declare class MessagingEventQueue { private readonly name; private queue; private processing; constructor(name?: string); enqueue(work: () => Promise): void; size(): number; private processNext; } /** * Run `fn` and retry with exponential backoff when its error matches * `isRateLimited`. Other errors propagate immediately. Each platform supplies * its own predicate so we don't have to know every SDK's error shape here. */ export declare function withRetry(fn: () => Promise, opts: RetryOptions): Promise; /** * Split `text` into chunks no larger than `limit`, appending a continuation * marker (e.g. `_(continued 1)_`) at the end of every part except the last. * * Each adapter passes its own `formatContinuation` so the marker uses the * platform's italic / emphasis convention. */ export declare function splitText(text: string, limit: number, formatContinuation: (partNum: number) => string): string[]; /** * Append a JSON-serializable entry to `${workingDir}/${channel}/log.jsonl`, * creating the directory on first use. This is the single write path every * adapter uses for human-readable message history. */ export declare function appendChannelLog(workingDir: string, channel: string, entry: object): void; /** Convenience for appending the bot's own outbound message. */ export declare function appendBotResponseLog(workingDir: string, channel: string, text: string, ts: string, threadTs?: string, extraFields?: Record): void; /** * Pick which session key a `/stop` should target without applying any * platform-specific fallback policy. Order: * 1. The provided sessionKey, if running. * 2. The bare conversationId, if running. */ export declare function resolveStopTarget(input: ResolveStopTargetInput): string | null; /** * Return the single running scoped session for this conversation, or null when * there are zero or multiple matches. */ export declare function resolveOnlyScopedStopTarget(handler: MessagingEventHandler, conversationId: string): string | null; /** * Render tool-call args for human display. Drops `label` (already in the * heading) and folds `path` + `offset`/`limit` into a single `path:start-end` * line. Pure data normalization with no platform-specific markup. */ export declare function formatToolArgs(args: Record | undefined): string; /** * Fetch `url` and write the response body to `destPath`, creating parent * directories as needed. Throws on non-2xx responses or write failures. */ export declare function downloadUrlToFile(url: string, destPath: string): Promise; //# sourceMappingURL=shared.d.ts.map