// Shared system.run approval guard errors keep gateway/node responses // machine-readable while preserving the user-facing message string. type SystemRunApprovalGuardError = { ok: false; message: string; details: Record; }; /** Builds a failed system.run approval guard result with a structured code. */ export function systemRunApprovalGuardError(params: { code: string; message: string; details?: Record; }): SystemRunApprovalGuardError { const details = params.details ? { ...params.details } : {}; return { ok: false, message: params.message, details: { code: params.code, ...details, }, }; } /** Builds the standard response for system.run calls that still need approval. */ export function systemRunApprovalRequired(runId: string): SystemRunApprovalGuardError { return systemRunApprovalGuardError({ code: "APPROVAL_REQUIRED", message: "approval required", details: { runId }, }); }