import { MidGenerationCompressor } from "../../compression/MidGenerationCompressor.js";
import { AgentRunContext, ResolvedGenerationResponse } from "../agent-types.js";
import { StreamPart } from "../../artifacts/ArtifactParser.js";
import { Part } from "@inkeep/agents-core";
import { Span } from "@opentelemetry/api";
import { ToolSet } from "ai";

//#region src/domains/run/agents/generation/generate.d.ts
declare function setupGenerationContext(ctx: AgentRunContext, runtimeContext?: {
  contextId: string;
  metadata: {
    conversationId: string;
    threadId: string;
    taskId: string;
    streamRequestId: string;
    apiKey?: string;
  };
}): {
  contextId: string;
  taskId: string;
  streamRequestId: string;
  sessionId: string;
};
declare function buildBaseGenerationConfig(ctx: AgentRunContext, modelSettings: Record<string, unknown>, messages: unknown[], sanitizedTools: ToolSet, compressor: MidGenerationCompressor | null, originalMessageCount: number, timeoutMs: number, toolChoice?: 'auto' | 'required', phase?: string): Record<string, unknown>;
declare function buildTelemetryConfig(ctx: AgentRunContext, phase?: string): object;
declare function computeGenerationType(parts: Array<{
  kind?: string;
}> | undefined | null, hasObject: boolean): 'text_generation' | 'object_generation' | 'mixed_generation';
declare function buildStructuredSuccessText(response: ResolvedGenerationResponse): string;
declare function selectStructuredFallbackText(response: ResolvedGenerationResponse): string;
declare function mapPartsToEventParts(parts: Array<{
  kind?: string;
  text?: string;
  data?: unknown;
} | StreamPart> | undefined | null): Array<{
  type: 'text' | 'data_component' | 'data_artifact';
  content?: string;
  data?: unknown;
}>;
declare function resolveTextResponseAndWarn({
  response,
  hasStructuredOutput,
  hasTransferToolCall,
  logger: log,
  warnContext
}: {
  response: ResolvedGenerationResponse;
  hasStructuredOutput: boolean;
  hasTransferToolCall: boolean;
  logger: {
    warn: (obj: Record<string, unknown>, msg: string) => void;
  };
  warnContext: Record<string, unknown>;
}): string;
declare function handleGenerationError(ctx: AgentRunContext, error: unknown, span: Span): never;
declare function runGenerate(ctx: AgentRunContext, userParts: Part[], runtimeContext?: {
  contextId: string;
  metadata: {
    conversationId: string;
    threadId: string;
    taskId: string;
    streamRequestId: string;
    apiKey?: string;
  };
}, options?: {
  schemaOnlyTools?: boolean;
}): Promise<ResolvedGenerationResponse>;
//#endregion
export { buildBaseGenerationConfig, buildStructuredSuccessText, buildTelemetryConfig, computeGenerationType, handleGenerationError, mapPartsToEventParts, resolveTextResponseAndWarn, runGenerate, selectStructuredFallbackText, setupGenerationContext };