import { Part, ResolvedRef } from "@inkeep/agents-core";
import { Context } from "hono";

//#region src/domains/run/services/TriggerService.d.ts

declare function buildTimezoneHeaders(timezone?: string | null): Record<string, string>;
type TriggerWebhookParams = {
  tenantId: string;
  projectId: string;
  agentId: string;
  triggerId: string;
  resolvedRef: ResolvedRef;
  rawBody: string;
  honoContext: Context;
};
type TriggerWebhookResult = {
  success: true;
  invocationId: string;
  conversationId: string;
} | {
  success: false;
  error: string;
  status: 400 | 401 | 403 | 404 | 422 | 500;
  validationErrors?: string[];
};
/**
 * Process a trigger webhook request.
 * Handles validation, transformation, and dispatches async execution.
 */
declare function processWebhook(params: TriggerWebhookParams): Promise<TriggerWebhookResult>;
declare function dispatchExecution(params: {
  tenantId: string;
  projectId: string;
  agentId: string;
  triggerId: string;
  resolvedRef: ResolvedRef;
  payload: Record<string, unknown>;
  transformedPayload: unknown;
  messageParts: Part[];
  userMessageText: string;
  runAsUserId?: string;
  forwardedHeaders?: Record<string, string>;
}): Promise<{
  invocationId: string;
  conversationId: string;
}>;
/**
 * Execute the agent asynchronously.
 * This runs after the webhook response is sent.
 */
declare function executeAgentAsync(params: {
  tenantId: string;
  projectId: string;
  agentId: string;
  triggerId: string;
  invocationId: string;
  conversationId: string;
  resolvedRef: ResolvedRef;
  dispatchedAt?: number;
  runAsUserId?: string;
  forwardedHeaders?: Record<string, string>;
  invocationType?: 'trigger' | 'scheduled_trigger';
  datasetRunId?: string;
} & ({
  userMessage: string;
  messageParts: Part[];
  messages?: undefined;
} | {
  messages: Array<{
    role: 'user' | 'assistant' | 'system';
    content: unknown;
  }>;
  userMessage?: undefined;
  messageParts?: undefined;
})): Promise<void>;
//#endregion
export { TriggerWebhookParams, TriggerWebhookResult, buildTimezoneHeaders, dispatchExecution, executeAgentAsync, processWebhook };