export interface IdempotentCommand { readonly idempotencyKey: string readonly request: T } export function createIdempotencyKey(): string { return crypto.randomUUID() } /** * Create once per user intent. Retries must reuse the returned envelope rather than call this again. */ export function createIdempotentCommand(request: T): IdempotentCommand { return Object.freeze({ idempotencyKey: createIdempotencyKey(), request }) }