/** * Preview of a write operation that has NOT been executed. * * Returned when a write tool is called with `confirm: false`. The caller (an AI * assistant) can show the human exactly what would be written and ask for * confirmation before re-calling with `confirm: true` and the same * `idempotency_key`. */ export interface WritePreview
{
readonly preview: true;
/** UUID v4 echoed back on confirm to make retries idempotent. */
readonly idempotency_key: string;
/** Human-readable description of what would be written. */
readonly summary: string;
/** The exact payload that would be sent to the write endpoint. */
readonly payload: P;
}
/**
* Receipt for a write operation that HAS been executed.
*
* Returned when a write tool is called with `confirm: true`.
*/
export interface WriteReceipt = WritePreview | WriteReceipt {
/** When `false`, return a preview; when `true`, execute the write. */
confirm: boolean;
/** Human-readable description of the write, surfaced in the preview. */
summary: string;
/** The payload that will be written. */
payload: P;
/** Performs the actual write. Receives the payload and the idempotency key. */
write: (payload: P, idempotencyKey: string) => Promise (options: WithPreviewOptions ): Promise