/** * Agent chat-reply loop (`teamshare-agent chat`): replies to a single * mentioning message (the one that triggered the wake). One mention → one * reply → go to sleep. When no targetId is given, replies only to the * *latest* mention (not all historical ones) as a fallback. * * Generation uses the configured harness (opencode/claude/codex/gemini/ * copilot/goose/openhands/aider) or the `--self` LLM completion. */ import { TeamshareApi } from '../api'; import { type HarnessName } from '../harness/harness-adapter'; /** * Extract a human-readable error from a harness failure message. * With spawnHarness the error is " exited with code N: ". * We extract the detail part and try to parse JSON errors from it. */ export declare function cleanHarnessError(raw: string): string; /** * IMP-913: injected into the prompt on retry attempts (>= 2) after a * transient provider error. Permissive by design - the model verifies and * reuses what exists, but a crash BEFORE creation still creates normally. */ export declare const RETRY_NOTE: string; export interface ChatReplyOptions { harness: HarnessName; selfMode: boolean; llm?: { baseUrl: string; apiKey: string; model: string; temperature?: number; maxTokens?: number; }; /** Reasoning effort for harnesses that expose it (codex: low|medium|high|xhigh, agy: low|medium|high). */ effort?: string; /** Debug/testing switch (TS_CHAT_ECHO=1): post canned acknowledgments. */ echo?: boolean; /** Project this chat belongs to - recorded as the session title for spend attribution. */ projectId?: string; /** API client for the tool loop (required when selfMode is true). */ api?: import('../api').TeamshareApi; /** Working directory - used by antigravity to find .agents/mcp_config.json. */ cwd?: string; /** Harness session id - stamped on MCP claims so they can be released at exit. */ sessionId?: string; /** Agent row id - scopes machine-local harness session continuation. */ agentId?: string; /** Optional logger for retry/give-up lines (wired to the CLI's log). */ onLog?: (text: string) => void; /** Idle timeout in minutes - killed after this long with no output. Default 20. */ timeoutMin?: number; } /** * True when the body mentions `@token` in either raw (`@name`) or structured * (`@[userId:name]`) format. Used by the reply loop to match mentions. */ export declare function bodyMentionsToken(body: string, token: string): boolean; /** Display body with structured @[id:Name] → @Name for prompt readability. */ export declare function displayBody(body: string): string; /** * Runs the chat reply loop. Heartbeats working/online around the work and * replies to at most ONE mentioning message: * - If `targetId` is given (from the wake event's messageId), reply ONLY * to that specific message. * - Otherwise, reply to the single LATEST mention (not all of them). * One mention → one reply → go to sleep. */ export declare function runChatReply(api: TeamshareApi, agentId: string, projectId: string, mentionToken: string, opts: ChatReplyOptions, targetId?: string): Promise<{ replied: number; skipped: number; }>; /** True when the reply contains actual text (not only harness JSON events). */ export declare function looksLikeRealText(reply: string): boolean;