========================================================================
    Gemini AI Local Image & Video Automation Cluster - Quick Start Guide
========================================================================

Welcome to the Gemini AI Local Automation Cluster Controller!
This system transforms Google Gemini's advanced multimodal AI vision capabilities
into a robust, high-availability local production engine with multi-account matrix
management. Whether for creators generating visuals in batches or enterprise AI
agents needing automated content generation pipelines, this platform delivers
rock-solid, efficient, and watermark-free media generation.

========================================================================
1. Core Features Overview
========================================================================
1. [Multi-Account Matrix Management]
   Manage multiple independent accounts concurrently with physical sandbox isolation,
   preventing cross-account correlation and multiplying cluster throughput.

2. [High-Fidelity Image & Native Video Creation]
   - Text-to-Image & Image-to-Image: Rich prompt engineering, single/multiple reference
     images for character and style consistency, and multi-resolution (1K/2K/4K) outputs
     across popular aspect ratios.
   - Native Video Generation: High-definition MP4 video generation guided by text prompts
     or initial/reference frames with dynamic camera motions.

3. [Lossless Local Storage & Privacy]
   All rendered images and MP4 videos are saved directly to your local downloads folder,
   free from cloud re-compression, metadata loss, or watermarks.

4. [Production-Ready RESTful APIs]
   Built-in standard RESTful API endpoints ready out-of-the-box for AI agents (LangChain,
   Dify, Coze, AutoGPT) and custom backend pipelines.

========================================================================
2. Key System Highlights
========================================================================
★ Intelligent Two-Tier Load Balancing:
  Dual-architecture design featuring "Resident Fast Pool" and "Elastic Standby Pool".
  Resident nodes handle urgent requests with sub-second latency, while requests are
  distributed smoothly across nodes to prevent rate limits.

★ True Zero-Resource Elastic Hibernation:
  Standby nodes automatically enter deep sleep after an idle timeout (default 300s),
  completely freeing RAM and CPU. Nodes wake dynamically when incoming tasks arrive.

★ Physical Sandbox Isolation:
  Each account runs inside an isolated browser profile sandbox. Cookies, caches, and
  local storage are completely decoupled, eliminating account association risks.

★ AI Agent Native Integration:
  Standardized OpenAPI endpoints with turnkey examples in Python, cURL, and JavaScript.
  The API specification can be passed directly as a System Prompt to LLMs.

★ Silent Background Execution:
  Windows-native silent background runner launches without terminal windows, keeping
  your desktop clean and uninterrupted.

========================================================================
3. Quick Start Instructions
========================================================================
[CRITICAL PREREQUISITE: Google Chrome Browser Version]
------------------------------------------------------------------------
★ CRITICAL: Google Chrome MUST be updated to the LATEST STABLE VERSION!
  1. Why is this necessary?
     - Google Gemini web endpoints (notably Nano Banana 2.1 and Gemini Omni video models)
       rely on modern Web Components, cross-origin streams, and Service Worker specs.
     - Our automation engine utilizes the Chrome Extension Manifest V3 standard.
     - Outdated Chrome versions (e.g., Chrome 110, 115) can cause:
       ① Persistent loading spinners or blank screens on Gemini web;
       ② Extension background disconnects causing hanging tasks;
       ③ Inability to parse usage quotas and recent policy modal dialogs.
  2. How to check and update Chrome?
     - Open Chrome -> Click top-right [⋮] menu -> Select [Help] -> Click [About Google Chrome].
     - Chrome will automatically check, download, and install the latest version.
     - Click "Relaunch" once finished.
------------------------------------------------------------------------

[Step 1: Start the Service]
- Windows Users:
  1. Double-click [start_cluster.bat] to launch the controller with console logs,
     OR double-click [start_silent.vbs] to run silently in the background without a window.
  2. The web management dashboard opens automatically within 1-2 seconds:
     👉 Dashboard URL: http://127.0.0.1:8765/
- macOS Users:
  1. Double-click [GeminiCluster.app] (if Gatekeeper warns of unverified developer, double-click [一键修复打开权限(解除苹果隔离).command] in the same directory to clear the quarantine flag);
  2. Upon launch, the system automatically runs the background service and opens the management dashboard in your default browser.
  3. To stop all services and background processes, double-click [双击停止所有服务.command].

[Step 2: Add Account & Login]
1. Click [+ New Account Node] on the top-right of the dashboard.
2. Enter a node name (e.g., "Account-01"), optional proxy (e.g., http://127.0.0.1:7890),
   and choose whether to keep it resident (resident nodes never sleep). Click Save.
3. On the new account card, click [🔑 Open Login]:
   - An isolated Chrome browser window will open, navigating to Gemini's login page.
   - Complete Google login normally until you see the Gemini chat interface.

   ★ [CRITICAL STEP FOR FIRST LOGIN · Terms & Dialog Confirmations]:
   ----------------------------------------------------------------------
   Google Gemini displays terms of service, disclaimer, or onboarding modals
   (e.g., "Welcome to Nano Banana 2.1 / Video Generation") for new accounts.
   To ensure unattended background automation runs smoothly:
     ① Enter a test prompt (e.g., "a cute corgi") and generate an image.
     ② Enter a test prompt (e.g., "a flying butterfly") and generate a video.
     ③ Click "Agree / Accept / Next / Got it" on all pop-up dialogs.
   Once all terms are accepted and generation finishes, simply close that Chrome window!
   The cluster controller will automatically mark the node as Ready.
   ----------------------------------------------------------------------

[Step 3: Generate Images & Videos]
- Method A [Visual Web Studio]:
  Enter prompts directly into the web dashboard, select aspect ratio and resolution,
  and click Generate. Real-time progress and renders will appear on screen.
- Method B [Automated REST API]:
  Dispatch tasks programmatically via HTTP POST. See API documentation below.

[Step 4: Media Outputs & Storage Management]
- All generated assets are saved to .mysuperhub/downloads in your Windows user directory
  (safe from app updates or re-installations).
- Click [⚙️ Storage & Network Settings] on the dashboard:
  1. Customize downloads and profiles directories, or open them in File Explorer.
  2. Toggle [Allow Remote / LAN Network Access] on or off (see Section 4).
- View, play, or download media at any time in the [Gallery] tab.

[How to Stop All Services]
Double-click [stop_all.bat] to safely terminate all background processes and workers.

========================================================================
4. API Integration & Network Access
========================================================================
Complete parameters, schemas, and code samples are available in:
📄 [API_DOCUMENTATION_EN.md] / [API_DOCUMENTATION_CN.md]

1. Base URLs & Network Access Control:
   - Base URLs:
     • Localhost: http://127.0.0.1:8765
     • LAN / Remote: http://<Host-IP>:8765
   - Content-Type: application/json
   - [Network Access Policy] (Configured in Storage & Network Settings):
     • OPEN (Default): Listens on 0.0.0.0:8765, allowing devices on the same LAN or
       remote servers to call APIs and access the web dashboard.
     • LOCALHOST ONLY: Listens on 127.0.0.1:8765, strictly blocking external access.
     • Applying changes: Restart the cluster (run [stop_all.bat] then [start_cluster.bat]).

2. Core API Endpoints:
   - Image Generation: POST /api/generate-image
     Payload example:
     {
       "prompt": "Cyberpunk corgi astronaut on Mars, realistic cinematic lighting, 4K",
       "aspect_ratio": "16:9",
       "resolution": "4k"
     }
   - Video Generation: POST /api/generate-video
     Payload example:
     {
       "prompt": "Race car speeding through rain at night, slow motion tracking shot",
       "aspect_ratio": "16:9",
       "timeout": 600
     }
   - Download / Stream Media: GET /api/download/{filepath}
   - Cluster Workers Health: GET /api/workers

3. AI Agent Tool-Calling Guide:
   Copy Section 2 [AI Agent / LLM Tool Calling Guide] from API_DOCUMENTATION_EN.md
   directly into your LLM System Prompt. The model will autonomously generate media.

========================================================================
5. Frequently Asked Questions (FAQ)
========================================================================
Q1: What should I know about network proxy settings?
    - If you require a proxy to reach Google services, configure proxy URLs in
      individual account settings (e.g., http://127.0.0.1:7890) or enable TUN mode
      in your proxy client.

Q2: Port conflict error or cannot open dashboard?
    - Run [stop_all.bat] to release any dangling processes, then restart.

Q3: How long does video generation take?
    - Video generation involves heavy diffusion computation and typically takes
      2 to 5 minutes. Set your API request timeout to at least 600s.

========================================================================
