import type { ActionCaller, ActionRunContext } from "./action.js"; export declare const ACTION_RECEIPT_SCHEMA_VERSION: "1"; export declare const DOMAIN_EVENT_SPEC_VERSION: "1.0"; export declare const DOMAIN_EVENT_CONTENT_TYPE: "application/json"; export type ActionJsonPrimitive = string | number | boolean | null; export type ActionJsonValue = ActionJsonPrimitive | ActionJsonValue[] | { [key: string]: ActionJsonValue; }; /** A CloudEvents 1.0-compatible event owned by the action that changed data. */ export interface ActionDomainEvent { specversion: typeof DOMAIN_EVENT_SPEC_VERSION; id: string; source: string; type: string; time: string; subject?: string; datacontenttype: typeof DOMAIN_EVENT_CONTENT_TYPE; data: TData; } export interface ActionDomainEventDraft { type: string; data: TData; source?: string; subject?: string; id?: string; time?: string; } export interface ActionDomainEventReference { id: string; source: string; type: string; time: string; subject?: string; } export interface ActionReceiptProvenance { caller: ActionCaller; appId?: string; orgId?: string; runId?: string; threadId?: string; turnId?: string; toolCallId?: string; correlationId?: string; causationId?: string; idempotencyKey?: string; } /** * Proof that an action mutation and its staged domain events committed together. * A failed or rolled-back transaction throws and must never produce this shape. */ export interface ActionReceipt { schemaVersion: typeof ACTION_RECEIPT_SCHEMA_VERSION; receiptId: string; action: string; status: "committed"; committedAt: string; provenance: ActionReceiptProvenance; result: TResult; events: ActionDomainEventReference[]; } export interface ActionAtomicAdapter { transaction(operation: (transaction: TTransaction) => Promise): Promise; /** Stage the receipt and events durably using this transaction. Do not publish here. */ stageActionOutcome(transaction: TTransaction, outcome: ActionAtomicOutcome): Promise; } export interface ActionAtomicOutcome { receipt: ActionReceipt; events: readonly ActionDomainEvent[]; } export interface ActionAtomicContext { transaction: TTransaction; emit(event: ActionDomainEventDraft): void; } export interface CommitActionOptions { adapter: ActionAtomicAdapter; action: string; source: string; context?: ActionRunContext; correlationId?: string; causationId?: string; idempotencyKey?: string; now?: () => Date; idFactory?: () => string; mutate(context: ActionAtomicContext): Promise | TResult; } export declare class ActionReceiptValidationError extends TypeError { constructor(message: string); } /** * Execute one mutation and stage all emitted events in the same transaction. * The committed receipt is returned only after the adapter confirms commit. */ export declare function commitAction(options: CommitActionOptions): Promise>; export declare function createActionDomainEvent(draft: ActionDomainEventDraft, options: { source: string; now?: () => Date; idFactory?: () => string; }): ActionDomainEvent; export declare function assertActionDomainEvent(value: unknown): asserts value is ActionDomainEvent; export declare function assertActionReceipt(value: unknown): asserts value is ActionReceipt; export declare function serializeActionReceipt(receipt: ActionReceipt): string; export declare function parseActionReceipt(serialized: string): ActionReceipt; export declare function serializeActionDomainEvent(event: ActionDomainEvent): string; export declare function parseActionDomainEvent(serialized: string): ActionDomainEvent;