import { type AgentActionScope, type AgentChatAttachment, type MentionItemMedia } from "../agent/types.js"; import type { ReasoningEffort } from "../shared/reasoning-effort.js"; import { type McpAppModelContextContentPart } from "./mcp-app-host.js"; export { appendAgentChatContextToMessage } from "../shared/agent-chat-context.js"; export type AgentChatRequestMode = "act" | "plan"; export interface AgentChatMessage { message: string; context?: string; /** * Chip label for `context` when `submit: false`. Without it the chip uses the * generic app-context title. */ contextLabel?: string; actionScope?: AgentActionScope; submit?: boolean; projectSlug?: string; preset?: string; referenceImagePaths?: string[]; uploadedReferenceImages?: string[]; images?: string[]; attachments?: AgentChatAttachment[]; /** Stable tab identifier — auto-generated if omitted */ tabId?: string; targetTabId?: string; type?: "content" | "code"; /** @deprecated Use `type: "code"` instead. If true, treated as `type: "code"`. */ requiresCode?: boolean; model?: string; engine?: string; effort?: ReasoningEffort; mode?: AgentChatRequestMode; /** @deprecated Use `mode` instead. */ requestMode?: AgentChatRequestMode; instructions?: string; chatTarget?: "auto" | "local"; openSidebar?: boolean; newTab?: boolean; reuseEmptyTab?: boolean; background?: boolean; /** * Stable id used to deduplicate a submit and correlate it with * {@link AGENT_CHAT_SUBMIT_RESULT_EVENT}. Auto-generated if omitted. */ submitMessageId?: string; /** Drop a queued submit instead of handing it to chat after this time. */ submissionExpiresAt?: number; usageLabel?: string; approvedToolCalls?: string[]; } export interface AgentChatContextItem { key: string; title: string; context: string; contextNamespace?: string; /** Context is limited to one chat thread when present. */ targetThreadId?: string; /** * When a composer staged the item. A replacement with the same key gets a * later time, so cleanup can tell them apart. */ stagingId?: string; } export interface AgentChatContextSetOptions extends AgentChatContextItem { openSidebar?: boolean; focus?: boolean; } /** @deprecated Use `AgentChatContextSetOptions` instead. */ export type AgentChatContextMessage = AgentChatContextSetOptions; export interface AgentChatContextState { items: AgentChatContextItem[]; updatedAt: number; } export interface AgentChatOpenThreadRequest { threadId: string; newThread?: boolean; prefill?: string; onlyIfActiveThreadId?: string; openRequestId?: string; } export interface AgentChatOpenTaskRequest { threadId: string; parentThreadId?: string; description?: string; name?: string; openRequestId?: string; } export type BufferedAgentChatOpenRequest = { id: string; eventType: "agent-chat:open-thread" | "agent-task-open"; detail: AgentChatOpenThreadRequest | AgentChatOpenTaskRequest; }; export interface AgentComposerReference { label: string; icon?: string; media?: MentionItemMedia; source?: string; refType: string; refId?: string | null; refPath?: string | null; slotKey?: string; slotLabel?: string; metadata?: Record; clearsSlots?: string[]; relatedReferences?: AgentComposerReference[]; } export interface AgentComposerReferenceInsertOptions { openSidebar?: boolean; } export interface AgentComposerReferenceInsertPayload extends AgentComposerReference { insertMessageId: string; } export interface AgentChatContextMutationOptions { openSidebar?: boolean; } export interface AgentChatContextRemoveOptions extends AgentChatContextMutationOptions { key: string; } export declare const AGENT_CHAT_CONTEXT_STATE_KEY = "agent-chat-context"; export declare const AGENT_CHAT_CONTEXT_CHANGED_EVENT = "agentNative.chatContextChanged"; export declare const AGENT_CHAT_SET_CONTEXT_MESSAGE_TYPE = "agentNative.setChatContext"; export declare const AGENT_CHAT_REMOVE_CONTEXT_MESSAGE_TYPE = "agentNative.removeChatContext"; export declare const AGENT_CHAT_CLEAR_CONTEXT_MESSAGE_TYPE = "agentNative.clearChatContext"; export declare const AGENT_CHAT_INSERT_REFERENCE_MESSAGE_TYPE = "agentNative.insertComposerReference"; export declare const AGENT_CHAT_INSERT_REFERENCE_EVENT = "agentNative:insert-composer-reference"; export declare const AGENT_CHAT_SUBMIT_RESULT_EVENT = "agentNative.chatSubmitResult"; export declare const AGENT_CHAT_SUBMIT_TARGET_EVENT = "agentNative.chatSubmitTarget"; export interface AgentChatSubmitResult { submitMessageId: string; delivered: boolean; reason?: string; } export interface AgentChatSubmitTarget { submitMessageId: string; tabId: string; } export interface AgentChatSubmitRoute { tabId: string; /** The conversation thread, when the chat that routed the submit knows it. */ threadId: string | null; } export declare function reportAgentChatSubmitTarget(submitMessageId: string | undefined, tabId: string, options?: { threadId?: string; }): void; /** * Where a submission was routed. The target event fires once, often before a * lazily loaded route that tracks the submission has mounted, so late * listeners read it here instead of waiting for an event that already passed. */ export declare function getAgentChatSubmitTarget(submitMessageId: string): AgentChatSubmitRoute | null; export declare function reportAgentChatSubmitResult(submitMessageId: string | undefined, delivered: boolean, reason?: string): void; export declare function generateTabId(): string; export declare function generateAgentChatSubmitMessageId(): string; export declare function cancelAgentChatSubmit(id: string | undefined): void; export declare function isAgentChatSubmitCancelled(id: string | undefined): boolean; export declare function drainBufferedAgentChatSubmits(): Array>; export declare function claimAgentChatSubmit(id: string | undefined): boolean; export declare function drainBufferedAgentChatOpenRequests(): BufferedAgentChatOpenRequest[]; export declare function claimAgentChatOpenRequest(id: unknown): boolean; export declare function _resetAgentChatSubmitBufferForTests(): void; export declare function normalizeAgentChatContextItem(item: unknown): AgentChatContextItem | null; export declare function filterAgentChatContextItems(items: readonly AgentChatContextItem[], contextNamespace?: string | null, threadId?: string | null): AgentChatContextItem[]; export declare function normalizeAgentChatContextItems(items: unknown): AgentChatContextItem[]; export declare function publishAgentChatContextItems(items: readonly AgentChatContextItem[], options?: { persist?: boolean; updatedAt?: number; }): AgentChatContextState; export declare function getAgentChatContextState(): AgentChatContextState; export declare function listAgentChatContext(): AgentChatContextItem[]; export declare function subscribeAgentChatContext(listener: () => void): () => void; export declare function refreshAgentChatContext(): Promise; export declare function formatAgentChatContextItemsForPrompt(items: readonly AgentChatContextItem[]): string; export declare function normalizeAgentComposerReference(value: unknown): AgentComposerReference | null; export declare function requestAgentChatThreadOpen(detail: AgentChatOpenThreadRequest): void; export declare function requestAgentTaskOpen(detail: AgentChatOpenTaskRequest): void; export declare function imageContentFromDataUrl(dataUrl: string): McpAppModelContextContentPart | null; export interface ParsedSubmitChat { message: string; context?: string; contextLabel?: string; actionScope?: AgentActionScope; submit: boolean; openSidebar?: boolean; model?: string; engine?: string; effort?: unknown; newTab?: boolean; reuseEmptyTab?: boolean; background?: boolean; tabId?: string; targetTabId?: string; images?: string[]; attachments?: AgentChatAttachment[]; requestMode?: AgentChatRequestMode; submitMessageId?: string; submissionExpiresAt?: number; usageLabel?: string; approvedToolCalls?: string[]; /** The sender's `preset`, reported as the turn's analytics surface. */ surface?: string; } export declare function parseSubmitChatMessage(event: MessageEvent): ParsedSubmitChat | null; export declare function routesToCodeFrame(opts: Pick): boolean; export declare function sendToAgentChat(opts: AgentChatMessage): string; export interface SendToAgentChatAndConfirmResult { tabId: string; delivered: boolean; reason?: string; } export declare function sendToAgentChatAndConfirm(opts: Omit, options?: { submitMessageId?: string; timeoutMs?: number; }): Promise; export declare function nextAgentChatStagingId(): string; export declare function setAgentChatContextItem(opts: AgentChatContextSetOptions): void; /** Persist a staged context item before exposing it to a composer. */ export declare function setAgentChatContextItemAndPersist(opts: AgentChatContextSetOptions): Promise; /** Remove a staged context item from persisted state before clearing its composer. */ export declare function removeAgentChatContextItemAndPersist(key: string, options?: { stagingId?: string; }): Promise; /** @deprecated Use `setAgentChatContextItem` instead. */ export declare const setContextToAgentChat: typeof setAgentChatContextItem; /** @deprecated Use `setAgentChatContextItem` instead. */ export declare const addContextToAgentChat: typeof setAgentChatContextItem; export declare function insertAgentComposerReference(ref: AgentComposerReference, options?: AgentComposerReferenceInsertOptions): void; export declare function removeAgentChatContextItem(keyOrOpts: string | AgentChatContextRemoveOptions): void; export declare function clearAgentChatContext(opts?: AgentChatContextMutationOptions): void; export declare function _resetAgentChatContextForTests(): void;