//#region src/domains/run/workflow/steps/scheduledTriggerSteps.d.ts
/**
 * Step: Log a message (allows logging from workflow context)
 */
declare function logStep(message: string, data: Record<string, unknown>): Promise<void>;
/**
 * Step: Check if trigger is still enabled.
 * Reads trigger config from the runtime DB.
 */
declare function checkTriggerEnabledStep(params: {
  tenantId: string;
  projectId: string;
  agentId: string;
  scheduledTriggerId: string;
  runnerId: string;
}): Promise<{
  shouldContinue: boolean;
  reason: "deleted" | "disabled";
  trigger: null;
} | {
  shouldContinue: boolean;
  trigger: {
    createdAt: string;
    updatedAt: string;
    name: string;
    description: string | null;
    enabled: boolean;
    cronExpression: string | null;
    cronTimezone: string | null;
    runAt: string | null;
    messageTemplate: string | null;
    maxRetries: number;
    retryDelaySeconds: number;
    timeoutSeconds: number;
    nextRunAt: string | null;
    ref: string;
    agentId: string;
    projectId: string;
    tenantId: string;
    id: string;
    runAsUserId: string | null;
    createdBy: string | null;
    payload?: Record<string, unknown> | null | undefined;
  };
  reason?: undefined;
}>;
/**
 * Step: Try to create invocation idempotently.
 * Returns existing invocation if already created.
 */
declare function createInvocationIdempotentStep(params: {
  tenantId: string;
  projectId: string;
  agentId: string;
  scheduledTriggerId: string;
  scheduledFor: string;
  payload: Record<string, unknown> | null;
  idempotencyKey: string;
  ref: string;
}): Promise<{
  invocation: {
    scheduledTriggerId: string;
    scheduledFor: string;
    startedAt: string | null;
    completedAt: string | null;
    conversationIds: string[] | null;
    attemptNumber: number;
    idempotencyKey: string;
    createdAt: string;
    agentId: string;
    projectId: string;
    tenantId: string;
    id: string;
    status: "pending" | "failed" | "running" | "completed" | "cancelled";
    ref?: {
      type: "commit" | "tag" | "branch";
      name: string;
      hash: string;
    } | null | undefined;
    resolvedPayload?: Record<string, unknown> | null | undefined;
  };
  alreadyExists: boolean;
}>;
/**
 * Step: Check if invocation was cancelled before execution
 * Returns true if cancelled (should skip execution), false otherwise
 */
declare function checkInvocationCancelledStep(params: {
  tenantId: string;
  projectId: string;
  agentId: string;
  scheduledTriggerId: string;
  invocationId: string;
}): Promise<{
  cancelled: boolean;
}>;
/**
 * Step: Mark invocation as running
 */
declare function markRunningStep(params: {
  tenantId: string;
  projectId: string;
  agentId: string;
  scheduledTriggerId: string;
  invocationId: string;
}): Promise<{
  scheduledTriggerId: string;
  scheduledFor: string;
  startedAt: string | null;
  completedAt: string | null;
  conversationIds: string[] | null;
  attemptNumber: number;
  idempotencyKey: string;
  createdAt: string;
  agentId: string;
  projectId: string;
  tenantId: string;
  id: string;
  status: "pending" | "failed" | "running" | "completed" | "cancelled";
  ref?: {
    type: "commit" | "tag" | "branch";
    name: string;
    hash: string;
  } | null | undefined;
  resolvedPayload?: Record<string, unknown> | null | undefined;
}>;
/**
 * Step: Add a conversation ID to the invocation's conversationIds array
 * Called after each attempt to track all conversations created during retries
 */
declare function addConversationIdStep(params: {
  tenantId: string;
  projectId: string;
  agentId: string;
  scheduledTriggerId: string;
  invocationId: string;
  conversationId: string;
}): Promise<{
  scheduledTriggerId: string;
  scheduledFor: string;
  startedAt: string | null;
  completedAt: string | null;
  conversationIds: string[] | null;
  attemptNumber: number;
  idempotencyKey: string;
  createdAt: string;
  agentId: string;
  projectId: string;
  tenantId: string;
  id: string;
  status: "pending" | "failed" | "running" | "completed" | "cancelled";
  ref?: {
    type: "commit" | "tag" | "branch";
    name: string;
    hash: string;
  } | null | undefined;
  resolvedPayload?: Record<string, unknown> | null | undefined;
} | undefined>;
/**
 * Step: Mark invocation as completed
 */
declare function markCompletedStep(params: {
  tenantId: string;
  projectId: string;
  agentId: string;
  scheduledTriggerId: string;
  invocationId: string;
}): Promise<{
  scheduledTriggerId: string;
  scheduledFor: string;
  startedAt: string | null;
  completedAt: string | null;
  conversationIds: string[] | null;
  attemptNumber: number;
  idempotencyKey: string;
  createdAt: string;
  agentId: string;
  projectId: string;
  tenantId: string;
  id: string;
  status: "pending" | "failed" | "running" | "completed" | "cancelled";
  ref?: {
    type: "commit" | "tag" | "branch";
    name: string;
    hash: string;
  } | null | undefined;
  resolvedPayload?: Record<string, unknown> | null | undefined;
} | undefined>;
/**
 * Step: Mark invocation as failed
 */
declare function markFailedStep(params: {
  tenantId: string;
  projectId: string;
  agentId: string;
  scheduledTriggerId: string;
  invocationId: string;
}): Promise<{
  scheduledTriggerId: string;
  scheduledFor: string;
  startedAt: string | null;
  completedAt: string | null;
  conversationIds: string[] | null;
  attemptNumber: number;
  idempotencyKey: string;
  createdAt: string;
  agentId: string;
  projectId: string;
  tenantId: string;
  id: string;
  status: "pending" | "failed" | "running" | "completed" | "cancelled";
  ref?: {
    type: "commit" | "tag" | "branch";
    name: string;
    hash: string;
  } | null | undefined;
  resolvedPayload?: Record<string, unknown> | null | undefined;
} | undefined>;
declare function disableOneTimeTriggerStep(params: {
  tenantId: string;
  projectId: string;
  agentId: string;
  scheduledTriggerId: string;
}): Promise<void>;
/**
 * Step: Increment attempt number for retry
 */
declare function incrementAttemptStep(params: {
  tenantId: string;
  projectId: string;
  agentId: string;
  scheduledTriggerId: string;
  invocationId: string;
  currentAttempt: number;
}): Promise<void>;
/**
 * Step: Reset a cancelled invocation back to pending.
 * Used when a restarted workflow finds a cancelled invocation via idempotency
 * that is still scheduled for a future time.
 */
declare function resetInvocationToPendingStep(params: {
  tenantId: string;
  projectId: string;
  agentId: string;
  scheduledTriggerId: string;
  invocationId: string;
}): Promise<{
  scheduledTriggerId: string;
  scheduledFor: string;
  startedAt: string | null;
  completedAt: string | null;
  conversationIds: string[] | null;
  attemptNumber: number;
  idempotencyKey: string;
  createdAt: string;
  agentId: string;
  projectId: string;
  tenantId: string;
  id: string;
  status: "pending" | "failed" | "running" | "completed" | "cancelled";
  ref?: {
    type: "commit" | "tag" | "branch";
    name: string;
    hash: string;
  } | null | undefined;
  resolvedPayload?: Record<string, unknown> | null | undefined;
} | undefined>;
/**
 * Step: Execute the scheduled trigger using executeAgentAsync.
 *
 * Uses the shared executeAgentAsync from TriggerService which includes
 * proper tracing, error handling, and conversation management.
 */
declare function executeScheduledTriggerStep(params: {
  tenantId: string;
  projectId: string;
  agentId: string;
  scheduledTriggerId: string;
  invocationId: string;
  messageTemplate?: string | null;
  payload?: Record<string, unknown> | null;
  timeoutSeconds: number;
  runAsUserId?: string | null;
  cronTimezone?: string | null;
  ref: string;
}): Promise<{
  success: boolean;
  conversationId?: string;
  error?: string;
}>;
//#endregion
export { addConversationIdStep, checkInvocationCancelledStep, checkTriggerEnabledStep, createInvocationIdempotentStep, disableOneTimeTriggerStep, executeScheduledTriggerStep, incrementAttemptStep, logStep, markCompletedStep, markFailedStep, markRunningStep, resetInvocationToPendingStep };