Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

654 B
Raw Blame
import { DSL } from '@/interfaces/database/agent';
import { downloadJsonFile } from '@/utils/file-util';
import { clearSensitiveFields } from './clear-sensitive-fields';

/**
 * Shared agent-DSL download path: strips sensitive credentials
 * and writes the canonical wire shape to `<title>.json`. Used by the
 * canvas export button and the version-history dialog so both emit
 * the same structure.
 */
export const downloadDsl = (dsl: DSL | Record<string, any>, title: string) => {
  const sanitizedDsl = clearSensitiveFields(dsl);
  downloadJsonFile(
    { ...sanitizedDsl, globals: { ...(sanitizedDsl.globals ?? {}) } },
    `${title}.json`,
  );
};