import { FALLBACK_STRATEGIES } from "@superblocksteam/library-shared/types";
import z from "zod";
/**
 * Feature flag definitions for AI service.
 *
 * To add a new flag, simply add a property here with key and schema:
 * ```
 * myNewFlag: {
 *   key: 'ai.my-new-flag',
 *   schema: z.number()
 * }
 * ```
 *
 * Then access it type-safely: `flags.myNewFlag`
 */
const FLAG_DEFINITIONS = {
    metadataCacheMaxTotalSizeMB: {
        key: "ai.metadata-cache-size-mb",
        schema: z.number(),
    },
    metadataCacheMaxSingleFileSizeMB: {
        key: "ai.metadata-file-size-mb",
        schema: z.number(),
    },
    unifiedProviderEnabled: {
        key: "superblocks.ai.provider.unified",
        schema: z.boolean(),
    },
    safetyGuidancePrompt: {
        key: "ai.prompt.safety-guidance",
        schema: z.string().nonempty(),
    },
    safetyClassificationEnabled: {
        key: "superblocks.ai.safety-classification.enabled",
        schema: z.boolean(),
    },
    secretRedactionEnabled: {
        key: "superblocks.ai.secret-redaction.enabled",
        schema: z.boolean(),
    },
    fallbackStrategy: {
        key: "ai.fallback.strategy",
        schema: z.enum(FALLBACK_STRATEGIES),
    },
    parameterizedApisEnabled: {
        key: "clark.parameterized-apis.v2.enabled",
        schema: z.boolean(),
    },
    webToolsEnabled: {
        key: "superblocks.ai.web-tools.enabled",
        schema: z.boolean(),
    },
    enableClarkAiReadAccessPermission: {
        key: "ui.clark-ai.read-access-permission",
        schema: z.boolean(),
    },
    apiRunLogsEnabled: {
        key: "ai.get-logs.api-runs.enabled",
        schema: z.boolean(),
    },
    useSystemSkills: {
        key: "clark.use_system_skills",
        schema: z.boolean(),
    },
    sessionRecordingEnabled: {
        key: "clark.session-recording.enabled",
        schema: z.boolean(),
    },
    sessionManagementEnabled: {
        key: "clark.session-management.enabled",
        schema: z.boolean(),
    },
    /** Derived from application templateName in CLI (not LD). See isSdkApiTemplate(). */
    sdkApiEnabled: {
        key: "clark.sdk-api.enabled",
        schema: z.boolean(),
    },
};
export const AiServiceFeatureFlags = {
    /**
     * Create a new feature flags instance with the given flag values.
     */
    create(flags = {}) {
        return new Proxy({}, {
            get(_target, prop) {
                if (typeof prop !== "string" || !(prop in FLAG_DEFINITIONS)) {
                    return undefined;
                }
                const def = FLAG_DEFINITIONS[prop];
                const raw = flags[def.key];
                if (raw === undefined) {
                    return undefined;
                }
                const result = def.schema.safeParse(raw);
                return result.success ? result.data : undefined;
            },
        });
    },
};
//# sourceMappingURL=features.js.map