import { ArtifactParser } from "./ArtifactParser.js";
import { Artifact, MessageContent, ProjectScopeConfig } from "@inkeep/agents-core";

//#region src/domains/run/artifacts/replay-hydration.d.ts
type ArtifactRef = {
  artifactId: string;
  toolCallId: string;
};
type ReplayHydrationContext = {
  parser: ArtifactParser;
  artifactMap: Map<string, Artifact>;
};
/**
 * Normalize a data part's raw `data` field. DB rows sometimes store the JSON
 * as a string; upstream code elsewhere may have already parsed it.
 */
declare function parseDataPart(raw: unknown): unknown;
/**
 * A data part is an artifact ref iff it carries both `artifactId` and
 * `toolCallId` strings.
 */
declare function asArtifactRef(data: unknown): ArtifactRef | null;
/**
 * True for refs that exist purely as server-side bookkeeping for a user's
 * file upload. These are paired with a sibling `file` part that already
 * carries everything the UI needs — returning the ref on replay just
 * duplicates the attachment in the UI.
 */
declare function isAttachmentBookkeepingRef(ref: ArtifactRef): boolean;
/**
 * Build everything a conversation-replay pass needs to hydrate artifact refs
 * in a single shot: one batched ledger query + one scoped parser. Safe to
 * call on empty message lists (returns a context whose map is empty and
 * whose parser is never consulted).
 */
declare function createReplayHydrationContext(scopes: ProjectScopeConfig, messages: Array<{
  content: MessageContent;
}>): Promise<ReplayHydrationContext>;
/**
 * Hydrate a single `{artifactId, toolCallId}` ref into the Vercel-facing
 * `data-artifact` part shape. Delegates to `ArtifactParser.parseObject` so
 * we inherit the streaming path's summary-formatting and `typeSchema`
 * attachment logic without copying it.
 *
 * Returns `null` on a ledger miss — matching streaming behavior (which emits
 * `[]` rather than an unresolved placeholder).
 */
declare function hydrateArtifactRef(ctx: ReplayHydrationContext, ref: ArtifactRef): Promise<{
  type: 'data-artifact';
  data: Record<string, unknown>;
} | null>;
//#endregion
export { ArtifactRef, ReplayHydrationContext, asArtifactRef, createReplayHydrationContext, hydrateArtifactRef, isAttachmentBookkeepingRef, parseDataPart };