import { Artifact, Part } from "../../types/a2a.js";
import { ProjectScopeConfig } from "../../db/manage/scope-definitions.js";
import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
import "../../types/index.js";
import { LedgerArtifactSelect } from "../../types/entities.js";

//#region src/data-access/runtime/ledgerArtifacts.d.ts
/**
 * Atomic upsert operation for a single artifact - prevents race conditions
 */
declare const upsertLedgerArtifact: (db: AgentsRunDatabaseClient) => (params: {
  scopes: ProjectScopeConfig;
  contextId: string;
  taskId: string;
  toolCallId?: string | null;
  artifact: Artifact;
}) => Promise<{
  created: boolean;
  existing?: any;
}>;
/**
 * Save one or more artifacts to the ledger
 */
declare const addLedgerArtifacts: (db: AgentsRunDatabaseClient) => (params: {
  scopes: ProjectScopeConfig;
  contextId: string;
  taskId?: string | null;
  toolCallId?: string | null;
  artifacts: Artifact[];
}) => Promise<void>;
/**
 * Retrieve artifacts by taskId, toolCallId, toolCallIds, and/or artifactId.
 * At least one of taskId, toolCallId, toolCallIds, or artifactId must be provided.
 * Use toolCallIds for batch queries to avoid N+1 query problems.
 */
declare const getLedgerArtifacts: (db: AgentsRunDatabaseClient) => (params: {
  scopes: ProjectScopeConfig;
  taskId?: string;
  toolCallId?: string;
  toolCallIds?: string[];
  artifactId?: string;
}) => Promise<Artifact[]>;
/**
 * Get ledger artifacts by context ID
 */
declare const getLedgerArtifactsByContext: (db: AgentsRunDatabaseClient) => (params: {
  scopes: ProjectScopeConfig;
  contextId: string;
}) => Promise<LedgerArtifactSelect[]>;
/**
 * Update the parts column of an existing ledger artifact by ID.
 * Used to persist modifications (e.g. key_findings) to artifacts that already exist.
 */
declare const updateLedgerArtifactParts: (db: AgentsRunDatabaseClient) => (params: {
  scopes: ProjectScopeConfig;
  artifactId: string;
  parts: Part[];
}) => Promise<boolean>;
/**
 * Delete ledger artifacts by task ID
 */
declare const deleteLedgerArtifactsByTask: (db: AgentsRunDatabaseClient) => (params: {
  scopes: ProjectScopeConfig;
  taskId: string;
}) => Promise<boolean>;
/**
 * Delete ledger artifacts by context ID
 */
declare const deleteLedgerArtifactsByContext: (db: AgentsRunDatabaseClient) => (params: {
  scopes: ProjectScopeConfig;
  contextId: string;
}) => Promise<boolean>;
/**
 * Count ledger artifacts by task ID
 */
declare const countLedgerArtifactsByTask: (db: AgentsRunDatabaseClient) => (params: {
  scopes: ProjectScopeConfig;
  taskId: string;
}) => Promise<number>;
//#endregion
export { addLedgerArtifacts, countLedgerArtifactsByTask, deleteLedgerArtifactsByContext, deleteLedgerArtifactsByTask, getLedgerArtifacts, getLedgerArtifactsByContext, updateLedgerArtifactParts, upsertLedgerArtifact };