/*
 * Runtime Web – Unified Serverless Framework for Full-Stack TypeScript Applications
 * Documentation: https://runtimeweb.com/docs/getting-started
 *
 * @template: ai-chat
 */

import { RuntimeConfig } from '@worktif/runtime';

/**
 * Runtime CLI Configuration for AI Chat Application
 *
 * This file defines the configuration for your AI Chat application,
 * including deployment stages, paths, feature flags, and AI service settings.
 */
const config: RuntimeConfig = {
    /**
     * Project name used for AWS resource naming
     */
    projectName: '{{PROJECT_NAME}}',

    /**
     * Deployment stages configuration
     * Each stage can have its own AWS region, profile, and domain settings
     */
    stages: [
        {
            name: 'dev',
            awsRegion: '{{REGION}}',
            awsProfile: 'default',
            /*env: {
                BEDROCK_MODEL_ID: 'anthropic.claude-3-sonnet-20240229-v1:0',
                MEMORY_TABLE_NAME: '{{PROJECT_NAME}}-sessions-dev',
                ALLOWED_ORIGIN: '*',
                AWS_REGION: '{{REGION}}',
            },*/
        },
        {
            name: 'staging',
            awsRegion: 'us-east-1',
            awsProfile: 'default',
            // env: {
            //     BEDROCK_MODEL_ID: 'anthropic.claude-3-sonnet-20240229-v1:0',
            //     MEMORY_TABLE_NAME: '{{PROJECT_NAME}}-sessions-staging',
            //     ALLOWED_ORIGIN: '*',
            //     AWS_REGION: 'us-east-1',
            // },
        },
        {
            name: 'prod',
            awsRegion: 'us-east-2',
            awsProfile: 'default',
            // env: {
            //     BEDROCK_MODEL_ID: 'anthropic.claude-3-sonnet-20240229-v1:0',
            //     MEMORY_TABLE_NAME: '{{PROJECT_NAME}}-sessions-prod',
            //     ALLOWED_ORIGIN: 'https://your-domain.com',
            //     AWS_REGION: 'us-east-2',
            // },
        },
    ],

    /**
     * Project paths configuration
     */
    paths: {
        srcDir: 'src',
        reactEntry: 'src/index.tsx',
        outDir: 'out/dist',
        cdkDir: 'cdk',
    },

    /**
     * Infrastructure mode
     * - 'cdk': Use AWS CDK for infrastructure (recommended)
     * - 'auto': Automatic infrastructure management
     */
    infraMode: 'cdk',

    /**
     * Feature flags for AI Chat application
     */
    features: {
        /**
         * Enable SEO metadata storage in DynamoDB
         */
        enableSeo: false,

        /**
         * Enable web app manifest generation
         */
        enableManifest: true,

        /**
         * Enable Lambda warmup to reduce cold starts
         * Recommended for AI services to minimize latency
         */
        enableWarmup: true,

        /**
         * Clear CloudFront cache on deployment
         */
        clearCacheOnDeploy: true,

        /**
         * Enable AI chat functionality with Bedrock integration
         */
        // enableAiChat: true,

        /**
         * Enable session memory persistence in DynamoDB
         */
        // enableSessionMemory: true,

        /**
         * Enable streaming responses (SSE)
         */
        // enableStreaming: true,
    },

    /**
     * Awake Lambda Development configuration (optional)
     *
     * Enables debugging real AWS Lambda invocations on your local machine.
     * All values can be overridden via CLI options (CLI takes priority).
     *
     * To use Runtime Lambda Debug:
     * 1. Deploy the Runtime Lambda Debug stack: npx cdk deploy {projectName}-RuntimeAwake-{stage}
     * 2. Start Runtime Lambda Debug: npx runtime dev --awake
     *
     * Run diagnostics: npx runtime dev doctor
     */
    awake: {
        /**
         * Enable Awake Lambda Development
         */
        enabled: true,

        /**
         * Fallback behavior when local CLI is offline
         * - 'execute': Execute the original handler in the cloud (default)
         * - 'error': Return 503 "Live dev session not connected"
         * CLI override: --fallback
         */
        fallbackMode: 'execute',
    },
};

export default config;
