### Manual FLUJO Startup Command Source: https://github.com/mario-andreschak/flujo/blob/main/FLUJO-Launcher-README.md Use this command to start FLUJO manually from the command line after navigating to the FLUJO directory. Ensure Node.js is installed and configured in your PATH. ```batch cd %USERPROFILE%\FLUJO npm start ``` -------------------------------- ### Build and Start FLUJO Source: https://github.com/mario-andreschak/flujo/blob/main/README.md Build the project for production and start the compiled application. This provides the optimal experience. ```bash npm run build npm start ``` -------------------------------- ### Storage File Example Source: https://github.com/mario-andreschak/flujo/blob/main/src/app/api/backup/README.md Shows an example of how storage files are organized within the backup archive under the 'storage/' directory. ```text storage/models.json storage/flows.json storage/mcp_servers.json storage/chat_history.json storage/theme.json storage/global_env_vars.json storage/encryption_key.json ``` -------------------------------- ### Start Development Server Source: https://github.com/mario-andreschak/flujo/blob/main/README.md Start the development server to run FLUJO locally. Access it via http://localhost:4200. ```bash npm run dev ``` ```bash yarn dev ``` -------------------------------- ### Install Dependencies Request JSON Source: https://github.com/mario-andreschak/flujo/blob/main/src/app/api/git/README.md Use this JSON payload to run an installation command within a specified repository path. The installation command can be customized. ```json { "action": "install", "savePath": "/path/to/repo", "installCommand": "npm install" } ``` -------------------------------- ### Install Dependencies in a Cloned Repository Source: https://context7.com/mario-andreschak/flujo/llms.txt Installs dependencies within a cloned repository using a specified install command. This is a POST request to /api/git with action=install. ```bash curl -X POST http://localhost:4200/api/git \ -H "Content-Type: application/json" \ -d '{ "action": "install", "savePath": "/absolute/path/to/mcp-servers/my-server", "installCommand": "npm install" }' ``` -------------------------------- ### Install Dependencies Source: https://github.com/mario-andreschak/flujo/blob/main/src/app/api/git/README.md Installs project dependencies within a specified repository using a given command. ```APIDOC ## POST /api/git ### Description Runs the installation command in the specified repository. ### Method POST ### Endpoint /api/git ### Parameters #### Request Body - **action** (string) - Required - Must be 'install' - **savePath** (string) - Required - The path to the repository where dependencies should be installed. - **installCommand** (string) - Required - The command to execute for installing dependencies (e.g., 'npm install', 'yarn install'). ### Request Example ```json { "action": "install", "savePath": "/path/to/repo", "installCommand": "npm install" } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **path** (string) - The path to the repository. - **relativePath** (string) - The relative path of the repository. - **installCommand** (string) - The command that was executed. - **commandOutput** (string) - The output from the installation command. #### Response Example ```json { "success": true, "path": "/path/to/repo", "relativePath": "/path/to/repo", "installCommand": "npm install", "commandOutput": "Output from the install command" } ``` ``` -------------------------------- ### Application Initialization Source: https://context7.com/mario-andreschak/flujo/llms.txt Bootstrap the application on startup by verifying the storage system and starting all enabled MCP servers. ```APIDOC ## GET /api/init ### Description Bootstrap the application on startup. Called once when the frontend loads to verify the storage system and start all enabled MCP servers. ### Method GET ### Endpoint /api/init ### Request Example ```bash curl http://localhost:4200/api/init ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the initialization was successful. - **message** (string) - A confirmation message. #### Response Example ```json { "success": true, "message": "Application initialized successfully" } ``` #### Failure Response - **success** (boolean) - Indicates if the initialization failed. - **error** (string) - A message describing the initialization failure. #### Response Example ```json { "success": false, "error": "Initialization failed: " } ``` ``` -------------------------------- ### Install Dependencies with npm or yarn Source: https://github.com/mario-andreschak/flujo/blob/main/README.md Install project dependencies using either npm or yarn. Ensure Node.js (v18 or higher) is installed. ```bash npm install ``` ```bash yarn install ``` -------------------------------- ### Action-Based Routing Examples Source: https://github.com/mario-andreschak/flujo/blob/main/src/app/api/README.md Illustrates action-based routing for handling multiple operations via a single endpoint. GET requests use a query parameter, while POST requests use an action in the request body. ```plaintext // GET request with action parameter // GET /api/model?action=listModels // POST request with action in body // POST /api/model // { "action": "addModel", "model": { ... } } ``` -------------------------------- ### Initialize FLUJO Application Source: https://context7.com/mario-andreschak/flujo/llms.txt Bootstrap the application on startup by verifying the storage system and starting enabled MCP servers. Expects a success or failure message. ```bash curl http://localhost:4200/api/init # Expected response: # { "success": true, "message": "Application initialized successfully" } # On failure: # { "success": false, "error": "Initialization failed: " } ``` -------------------------------- ### Start Flujo with Docker Compose Source: https://github.com/mario-andreschak/flujo/blob/main/DOCKER.md Use Docker Compose to build and start the Flujo container in detached mode. Access Flujo via http://localhost:4200. ```bash docker-compose up -d ``` -------------------------------- ### Start FLUJO with Docker Compose Source: https://context7.com/mario-andreschak/flujo/llms.txt Clones the FLUJO repository and starts the services using Docker Compose in detached mode. Access the application at http://localhost:4200. ```bash # Clone and start with Docker Compose (recommended) git clone https://github.com/mario-andreschak/FLUJO.git cd FLUJO docker-compose up -d # Access at http://localhost:4200 ``` ```bash # Using the provided scripts for more control ./scripts/build-docker.sh ``` ```bash # Run with options: # --tag= : image tag (default: latest) # --detached : background mode # --port= : host port (default: 4200) # --no-privileged : disable privileged mode (not recommended) ./scripts/run-docker.sh --tag=latest --detached --port=4200 ``` -------------------------------- ### Frontend Service Integration Example Source: https://github.com/mario-andreschak/flujo/blob/main/src/app/api/README.md Shows how frontend services abstract API calls, providing a clean interface for frontend components. This example includes loading models and adding a new model. ```typescript // Frontend service export const modelService = { async loadModels() { const response = await fetch('/api/model?action=listModels'); const data = await response.json(); return data.models; }, async addModel(model) { const response = await fetch('/api/model', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ action: 'addModel', model }) }); return await response.json(); } }; // Frontend component const models = await modelService.loadModels(); ``` -------------------------------- ### Create Backup Client-Side Example Source: https://github.com/mario-andreschak/flujo/blob/main/src/app/api/backup/README.md Demonstrates how to initiate a backup creation request from a frontend component using the Fetch API. Handles successful downloads and error logging. ```typescript // Create a backup with selected items const response = await fetch('/api/backup', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ selections: ['models', 'flows', 'mcpServers', 'settings'] }) }); if (response.ok) { // Convert the response to a blob const blob = await response.blob(); // Create a download link const url = window.URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = 'flujo-backup.zip'; // Trigger the download document.body.appendChild(a); a.click(); // Clean up window.URL.revokeObjectURL(url); document.body.removeChild(a); } else { const errorData = await response.json(); console.error(`Error creating backup: ${errorData.error}`); } ``` -------------------------------- ### List Installed MCP Server Directories Source: https://context7.com/mario-andreschak/flujo/llms.txt Retrieves a list of all installed MCP server directories on the system. This action does not require any specific parameters. ```bash curl -X POST http://localhost:4200/api/git \ -H "Content-Type: application/json" \ -d '{ "action": "list" }' ``` -------------------------------- ### Backend MCP Service Usage Examples Source: https://github.com/mario-andreschak/flujo/blob/main/src/backend/services/mcp/README.md Demonstrates how to use the MCP service in the backend for server management, tool execution, and configuration updates. Ensure the service is imported correctly. ```typescript import { mcpService } from '@/backend/services/mcp'; // Load server configurations const configs = await mcpService.loadServerConfigs(); // Connect to a server const result = await mcpService.connectServer('serverName'); // List tools from a server const tools = await mcpService.listServerTools('serverName'); // Call a tool on a server const toolResult = await mcpService.callTool('serverName', 'toolName', { arg1: 'value1' }); // Update a server configuration const updatedConfig = await mcpService.updateServerConfig('serverName', { command: 'new-command', args: ['--arg1', 'value1'], }); // Get server status const status = await mcpService.getServerStatus('serverName'); // Disconnect from a server await mcpService.disconnectServer('serverName'); // Delete a server configuration await mcpService.deleteServerConfig('serverName'); ``` -------------------------------- ### Install @xenova/transformers Dependency Source: https://github.com/mario-andreschak/flujo/blob/main/plan.md Add the @xenova/transformers package to your project dependencies. ```bash npm install @xenova/transformers ``` -------------------------------- ### Frontend Component API Call Example Source: https://github.com/mario-andreschak/flujo/blob/main/src/app/api/mcp/README.md Demonstrates how a frontend component should initiate an API call by using the frontend service. This method abstracts the direct API interaction. ```typescript import { mcpService } from '@/frontend/services/mcp'; // Call a method on the frontend service const result = await mcpService.callTool('serverName', 'toolName', { arg1: 'value1' }); ``` -------------------------------- ### List or Get AI Models Source: https://context7.com/mario-andreschak/flujo/llms.txt Retrieve a list of all configured AI models or a single model by its ID. Loads configurations from local storage. ```bash # List all models curl http://localhost:4200/api/model # Expected response: # [ # { "id": "model-uuid-1", "name": "GPT-4o", "provider": "openai", "baseUrl": "...", ... }, # { "id": "model-uuid-2", "name": "Claude 3.5", "provider": "anthropic", ... } # ] # Get a single model by ID curl "http://localhost:4200/api/model?id=model-uuid-1" # { "id": "model-uuid-1", "name": "GPT-4o", ... } # Not found: # HTTP 404: { "error": "Model not found" } ``` -------------------------------- ### Git / Repository Management API Source: https://context7.com/mario-andreschak/flujo/llms.txt APIs for managing Git repositories, including cloning, installing dependencies, building, running, and inspecting them. Primarily used for installing MCP server repositories. ```APIDOC ## POST /api/git ### Description Performs Git operations such as cloning, installing dependencies, building, running, or inspecting repositories. ### Method POST ### Endpoint /api/git ### Parameters #### Request Body - **action** (string) - Required - The Git action to perform. Possible values: "clone", "install", "build", "run", "inspect". - **repoUrl** (string) - Required (for "clone") - The URL of the Git repository. - **savePath** (string) - Required (for "clone" and "install") - The local path to save or manage the repository. - **branch** (string) - Optional (for "clone") - The branch to clone. - **forceClone** (boolean) - Optional (for "clone") - Whether to force cloning. - **installCommand** (string) - Optional (for "install") - The command to install dependencies. ### Request Example ```bash # Clone a GitHub repository as an MCP server curl -X POST http://localhost:4200/api/git \ -H "Content-Type: application/json" \ -d '{ "action": "clone", "repoUrl": "https://github.com/modelcontextprotocol/servers.git", "savePath": "/absolute/path/to/mcp-servers/my-server", "branch": "main", "forceClone": false }' # Install dependencies in a cloned repository curl -X POST http://localhost:4200/api/git \ -H "Content-Type: application/json" \ -d '{ "action": "install", "savePath": "/absolute/path/to/mcp-servers/my-server", "installCommand": "npm install" }' ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **path** (string) - The path of the repository. - **relativePath** (string) - The relative path of the repository. - **envExample** (string) - An example of environment variables required. - **InstallCommand** (string) - The install command executed. - **commandOutput** (string) - The output of the executed command. #### Response Example ```json # Example for clone { "success": true, "path": "/absolute/path/...", "relativePath": "...", "envExample": "GITHUB_TOKEN=\nAPI_KEY=\n" } # Example for install { "success": true, "path": "...", "InstallCommand": "npm install", "commandOutput": "added 142 packages..." } ``` ``` -------------------------------- ### Global Variable Binding Example Source: https://context7.com/mario-andreschak/flujo/llms.txt Demonstrates referencing globally stored, encrypted environment variables using the `${global:KEY}` syntax within model system prompts or MCP server configurations. ```text # In a model system prompt: You are a helpful assistant. Your internal project ID is ${global:PROJECT_ID}. # In an MCP server environment variable value: GITHUB_PERSONAL_ACCESS_TOKEN=${global:GITHUB_PAT} ``` -------------------------------- ### API Adapter and Handler Example Source: https://github.com/mario-andreschak/flujo/blob/main/src/app/api/README.md Demonstrates the Adapter Pattern for decoupling API logic from backend services. The adapter handles service calls, while the handler processes incoming requests and uses the adapter. ```typescript // API adapter export const modelAdapter = { async listModels() { return await modelService.listModels(); }, async getModel(id: string) { return await modelService.getModel(id); } }; // API handler export async function GET(request: Request) { const { searchParams } = new URL(request.url); const action = searchParams.get('action'); if (action === 'listModels') { const models = await modelAdapter.listModels(); return Response.json({ models }); } if (action === 'getModel') { const id = searchParams.get('id'); if (!id) { return Response.json({ error: 'Missing model ID' }, { status: 400 }); } const model = await modelAdapter.getModel(id); return Response.json({ model }); } return Response.json({ error: 'Invalid action' }, { status: 400 }); } ``` -------------------------------- ### Configure GitHub MCP Server Source: https://github.com/mario-andreschak/flujo/blob/main/docs/features/mcp/docker-servers.md Example configuration for a GitHub MCP server using STDIO transport. Ensure sensitive variables like GITHUB_PERSONAL_ACCESS_TOKEN are marked as secret. ```yaml Server Name: github Docker Image: ghcr.io/github/github-mcp-server Transport Method: STDIO Environment Variables: - GITHUB_PERSONAL_ACCESS_TOKEN: your-token-here (Secret) ``` -------------------------------- ### Import and Use Model Service Methods Source: https://github.com/mario-andreschak/flujo/blob/main/src/frontend/services/model/README.md Demonstrates how to import the modelService and use its methods for loading, getting, adding, updating, and deleting models. Ensure the service is correctly imported from '@/frontend/services/model'. ```typescript import { modelService } from '@/frontend/services/model'; // Use the service methods const models = await modelService.loadModels(); const model = await modelService.getModel(id); const result = await modelService.addModel(model); const result = await modelService.updateModel(model); const result = await modelService.deleteModel(id); ``` -------------------------------- ### Check Initialization Status Source: https://github.com/mario-andreschak/flujo/blob/main/src/app/api/encryption/secure/README.md Checks whether the encryption system has been initialized. This endpoint returns the initialization status, indicating if setup procedures have been completed. ```APIDOC ## Check Initialization Status ### Description Checks if the encryption system has been initialized. ### Method POST ### Endpoint /api/encryption ### Request Body - **action** (string) - Required - Must be "check_initialized" ``` -------------------------------- ### Compile FLUJO Launcher with Aut2Exe (Batch) Source: https://github.com/mario-andreschak/flujo/blob/main/FLUJO-Launcher-README.md Command-line compilation of the FLUJO Launcher script using AutoIt's Aut2Exe tool. Ensure AutoIt is installed and the paths are correct. ```batch "C:\Program Files (x86)\AutoIt3\Aut2Exe\Aut2exe.exe" /in "FLUJO-Launcher.au3" /out "FLUJO-Launcher.exe" /x64 ``` -------------------------------- ### List MCP Tools on a Server Source: https://context7.com/mario-andreschak/flujo/llms.txt Lists the tools available on a running MCP server. Requires the server name. This is a GET request to the /api/mcp endpoint with action=listTools. ```bash curl "http://localhost:4200/api/mcp?action=listTools&server=github" ``` -------------------------------- ### Load MCP Server Configurations Source: https://context7.com/mario-andreschak/flujo/llms.txt Retrieves all MCP server configurations. This is a GET request to the /api/mcp endpoint with the action parameter set to 'loadConfigs'. ```bash curl "http://localhost:4200/api/mcp?action=loadConfigs" ``` -------------------------------- ### Example Restore API Request Body Selections Source: https://github.com/mario-andreschak/flujo/blob/main/src/app/api/restore/README.md This JSON array specifies which components to restore from a backup archive. Ensure the selections match the available items in the backup. ```json [ "models", "mcpServers", "flows", "chatHistory", "settings", "globalEnvVars", "encryptionKey", "mcpServersFolder" ] ``` -------------------------------- ### Verify Password and Get Token Source: https://context7.com/mario-andreschak/flujo/llms.txt Use this endpoint to verify a user's password and obtain a session token. Ensure the request body contains the correct action and password. ```bash curl -X POST http://localhost:4200/api/encryption/secure \ -H "Content-Type: application/json" \ -d '{ "action": "verify_password", "password": "my-strong-password" }' ``` -------------------------------- ### Frontend Component API Call Example Source: https://github.com/mario-andreschak/flujo/blob/main/src/app/api/model/README.md Demonstrates how a frontend component should interact with the model service via the frontend service, not directly with the API layer. ```typescript import { modelService } from '@/frontend/services/model'; // Call a method on the frontend service const models = await modelService.loadModels(); ``` -------------------------------- ### Simple GET Request to Chat Completions Endpoint Source: https://github.com/mario-andreschak/flujo/blob/main/src/app/v1/chat/completions/README.md Example of a simplified GET request to the chat completions endpoint. Parameters like model and message are passed as query parameters. ```typescript // Example GET request (simplified interface) const response = await fetch('/v1/chat/completions?model=flow-MyCustomFlow&message=Hello&temperature=0.7'); const result = await response.json(); ``` -------------------------------- ### Frontend Service API Call Example (TypeScript) Source: https://github.com/mario-andreschak/flujo/blob/main/src/app/api/flow/README.md Demonstrates how frontend components should interact with the flow service via the frontend service. This ensures proper API call handling and delegation to the backend. ```typescript import { flowService } from '@/frontend/services/flow'; // Call a method on the frontend service const flows = await flowService.loadFlows(); ``` -------------------------------- ### Configure Custom MCP Server with WebSocket Source: https://github.com/mario-andreschak/flujo/blob/main/docs/features/mcp/docker-servers.md Example configuration for a custom MCP server using WebSocket transport. This includes specifying a WebSocket port and environment variables for API keys and configuration paths. ```yaml Server Name: custom-server Docker Image: your-registry/custom-mcp-server:latest Transport Method: WebSocket WebSocket Port: 8080 Environment Variables: - API_KEY: your-api-key (Secret) - CONFIG_PATH: /app/config.json ``` -------------------------------- ### Initialize the Application Source: https://github.com/mario-andreschak/flujo/blob/main/src/app/api/init/README.md This endpoint initializes the application by performing necessary startup tasks, such as verifying the storage system. ```APIDOC ## GET /api/init ### Description Initializes the application by performing necessary startup tasks. ### Method GET ### Endpoint /api/init ### Response #### Success Response (200) - **success** (boolean) - Indicates if the initialization was successful. - **message** (string) - A confirmation message upon successful initialization. #### Response Example ```json { "success": true, "message": "Application initialized successfully" } ``` #### Error Response - **success** (boolean) - Indicates if the initialization failed. - **error** (string) - A message describing the initialization error. #### Response Example ```json { "success": false, "error": "Initialization failed: Error message" } ``` ``` -------------------------------- ### Initialize Application API Source: https://github.com/mario-andreschak/flujo/blob/main/src/app/api/README.md Performs essential startup tasks for the application, including storage verification, directory creation, and file verification. ```http GET /api/init ``` -------------------------------- ### Initialization API Source: https://github.com/mario-andreschak/flujo/blob/main/src/app/api/README.md Performs essential startup tasks when the application is first loaded. ```APIDOC ## GET /api/init ### Description Initializes the application by performing tasks such as storage verification, directory creation, and file verification. ### Method GET ### Endpoint /api/init ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating successful initialization. ### Response Example ```json { "success": true, "message": "Application initialized successfully." } ``` ``` -------------------------------- ### MCP Frontend Service Usage Examples Source: https://github.com/mario-andreschak/flujo/blob/main/src/frontend/services/mcp/README.md Demonstrates common operations using the mcpService, including loading configurations, listing tools, calling tools, updating configurations, checking status, deleting configurations, retrying connections, restarting servers, and subscribing to events. ```typescript // Import the service import { mcpService } from '@/frontend/services/mcp'; // Load server configurations const configs = await mcpService.loadServerConfigs(); // List tools from a server const tools = await mcpService.listServerTools('serverName'); // Call a tool on a server const toolResult = await mcpService.callTool('serverName', 'toolName', { arg1: 'value1' }); // Update a server configuration const updatedConfig = await mcpService.updateServerConfig('serverName', { command: 'new-command', args: ['--arg1', 'value1'], }); // Get server status const status = await mcpService.getServerStatus('serverName'); // Delete a server configuration await mcpService.deleteServerConfig('serverName'); // Retry connecting to a server await mcpService.retryServer('serverName'); // Restart a server await mcpService.restartServer('serverName'); // Subscribe to server events const cleanup = mcpService.subscribeToServerEvents('serverName', (event) => { console.log('Server event:', event); }); // Cleanup subscription when done cleanup(); ``` -------------------------------- ### GET /v1/chat/completions Source: https://github.com/mario-andreschak/flujo/blob/main/src/app/v1/chat/completions/README.md Submits a simplified chat completion request using GET parameters. Suitable for basic interactions. ```APIDOC ## GET /v1/chat/completions ### Description Submits a simplified chat completion request using GET parameters. Suitable for basic interactions. ### Method GET ### Endpoint /v1/chat/completions ### Parameters #### Query Parameters - **model** (string) - Required - Format 'flow-[FlowName]' - **message** (string) - Required - The user's message content - **temperature** (number) - Optional - Controls randomness (0-1) ### Request Example ``` /v1/chat/completions?model=flow-MyCustomFlow&message=Hello&temperature=0.7 ``` ### Response #### Success Response (200) - **id** (string) - Unique identifier for the completion. - **object** (string) - Type of object, e.g., 'chat.completion'. - **created** (integer) - Unix timestamp of creation. - **model** (string) - The model used for the completion. - **choices** (Array) - Array of completion choices. - **index** (integer) - Index of the choice. - **message** (object) - The generated message. - **role** (string) - Role of the message sender ('assistant'). - **content** (string) - The content of the message. - **finish_reason** (string) - The reason the model stopped generating tokens. - **usage** (object) - Usage statistics for the request. - **prompt_tokens** (integer) - Number of tokens in the prompt. - **completion_tokens** (integer) - Number of tokens in the completion. - **total_tokens** (integer) - Total tokens used. ### Response Example ```json { "id": "chatcmpl-123", "object": "chat.completion", "created": 1677652288, "model": "flow-MyCustomFlow", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "Hello! How can I assist you today?" }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 10, "completion_tokens": 20, "total_tokens": 30 } } ``` ``` -------------------------------- ### GET /api/env Source: https://github.com/mario-andreschak/flujo/blob/main/src/app/api/env/README.md Retrieves environment variables. By default, sensitive values are masked. Use `includeSecrets=true` to get decrypted values. ```APIDOC ## GET /api/env ### Description Retrieves environment variables. Supports fetching a specific variable using the `key` query parameter and optionally including decrypted sensitive values with `includeSecrets=true`. ### Method GET ### Endpoint /api/env ### Query Parameters - **key** (string) - Optional - The specific environment variable key to retrieve. - **includeSecrets** (boolean) - Optional - Set to `true` to include decrypted sensitive values in the response. ### Response (All Variables) #### Success Response (200) - **variables** (object) - An object containing environment variables. Sensitive values are masked by default. ### Response Example (All Variables) ```json { "variables": { "PUBLIC_VAR": "public value", "API_KEY": "********" } } ``` ### Response (Single Variable) #### Success Response (200) - **value** (string) - The value of the requested environment variable. ### Response Example (Single Variable) ```json { "value": "variable value" } ``` ``` -------------------------------- ### Get Specific Flow API Source: https://github.com/mario-andreschak/flujo/blob/main/src/app/api/README.md Retrieves a specific flow by its ID. Provide the flow's unique identifier to get its details. ```http GET /api/flow?action=getFlow&id={flowId} ``` -------------------------------- ### Build an MCP Server Repository Source: https://context7.com/mario-andreschak/flujo/llms.txt Use this action to build a project within a specified save path. Ensure the build command is correctly defined. ```bash curl -X POST http://localhost:4200/api/git \ -H "Content-Type: application/json" \ -d '{ "action": "build", "savePath": "/absolute/path/to/mcp-servers/my-server", "buildCommand": "npm run build" }' ``` -------------------------------- ### Initialize Encryption Subsystem Source: https://context7.com/mario-andreschak/flujo/llms.txt Initializes the encryption subsystem with a user-chosen password. This action sets up the encryption for secrets. ```bash curl -X POST http://localhost:4200/api/encryption/secure \ -H "Content-Type: application/json" \ -d '{ "action": "initialize", "password": "my-strong-password" }' ``` -------------------------------- ### Get a Secret Environment Variable Source: https://context7.com/mario-andreschak/flujo/llms.txt Retrieves a secret environment variable by its key. Use `includeSecrets=true` to get the decrypted value. Use with caution. ```bash curl "http://localhost:4200/api/env?key=OPENAI_API_KEY&includeSecrets=true" ``` -------------------------------- ### Run FLUJO as Desktop Application Source: https://github.com/mario-andreschak/flujo/blob/main/README.md Run FLUJO as a desktop application. Use 'electron-dev' for development or 'electron-dist' for a packaged build. ```bash npm run electron-dev # Development mode ``` ```bash npm run electron-dist # Build and package for your platform ``` -------------------------------- ### API Error Response Example Source: https://github.com/mario-andreschak/flujo/blob/main/src/app/api/cwd/README.md Provides an example of an error response from the API, including a descriptive message and a success flag set to false. ```json { "success": false, "error": "Failed to get current working directory: Error message" } ``` -------------------------------- ### Chat Completions GET Request Source: https://github.com/mario-andreschak/flujo/blob/main/src/app/v1/chat/completions/README.md This endpoint allows you to get chat completions from a specified flow model. It accepts several query parameters to control the generation process. ```APIDOC ## GET /v1/chat/completions ### Description Retrieves chat completions from a specified flow model based on user messages and generation parameters. ### Method GET ### Endpoint /v1/chat/completions ### Parameters #### Query Parameters - **model** (string) - Required - The flow model to use (format: 'flow-[FlowName]') - **message** (string) - Required - The user message content - **stream** (boolean) - Optional - Whether to stream the response ('true' or 'false') - **temperature** (number) - Optional - Controls randomness (0-1) - **max_tokens** (integer) - Optional - Maximum tokens to generate ### Response #### Success Response (200) - **Standard Response**: Contains `id`, `object`, `created`, `model`, `choices`, and `usage` fields. - **Streaming Response**: Uses Server-Sent Events (SSE) format. #### Response Example (Standard) ```json { "id": "chatcmpl-123", "object": "chat.completion", "created": 1677858242, "model": "flow-MyCustomFlow", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "Hello world!" }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 10, "completion_tokens": 20, "total_tokens": 30 } } ``` #### Response Example (Streaming) ``` data: { "id": "chatcmpl-123", "object": "chat.completion.chunk", "created": 1677858242, "model": "flow-MyCustomFlow", "choices": [{ "index": 0, "delta": { "content": "Hello" }, "finish_reason": null }] } data: { "id": "chatcmpl-123", "object": "chat.completion.chunk", "created": 1677858242, "model": "flow-MyCustomFlow", "choices": [{ "index": 0, "delta": { "content": " world" }, "finish_reason": null }] } data: [DONE] ``` ### Error Handling - `400 Bad Request`: Invalid request format or parameters - `404 Not Found`: Requested flow not found - `429 Too Many Requests`: Rate limit exceeded - `500 Internal Server Error`: Server-side error #### Error Response Example ```json { "error": { "message": "Invalid model specified.", "type": "invalid_request_error", "code": "invalid_model", "param": "model" } } ``` ``` -------------------------------- ### Clone Repository TypeScript Usage Example Source: https://github.com/mario-andreschak/flujo/blob/main/src/app/api/git/README.md Example of how to use the Git Operations API to clone a repository using fetch in TypeScript. Handles success and error responses. ```typescript const response = await fetch('/api/git', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ action: 'clone', repoUrl: 'https://github.com/username/repo.git', savePath: '/path/to/save/repo', branch: 'main' }) }); const data = await response.json(); if (data.success) { console.log(`Repository cloned to: ${data.path}`); } else { console.error(`Error: ${data.error}`); } ``` -------------------------------- ### Get a specific flow Source: https://github.com/mario-andreschak/flujo/blob/main/src/app/api/flow/README.md Retrieves details for a single flow identified by its ID. ```APIDOC ## GET /api/flow ### Description Gets a specific flow by its ID. ### Method GET ### Endpoint /?action=getFlow&id={flowId} ### Parameters #### Query Parameters - **action** (string) - Required - Must be 'getFlow' - **id** (string) - Required - The ID of the flow to retrieve ### Response #### Success Response (200) - **flow** (object) - The flow object with details. ``` -------------------------------- ### Import and Use Flow Service Methods Source: https://github.com/mario-andreschak/flujo/blob/main/src/frontend/services/flow/README.md Demonstrates how to import the flowService and use its various methods for loading, getting, creating, saving, and deleting flows, as well as managing nodes and generating sample data. Ensure the service is correctly imported before use. ```typescript // Import the service import { flowService } from '@/frontend/services/flow'; // Load all flows const flows = await flowService.loadFlows(); // Get a specific flow const flow = await flowService.getFlow('flow-id'); // Create a new flow const newFlow = flowService.createNewFlow('My New Flow'); // Save a flow const saveResult = await flowService.saveFlow(newFlow); // Delete a flow const deleteResult = await flowService.deleteFlow('flow-id'); // Create a new node const node = flowService.createNode('process', { x: 250, y: 150 }); // Create a history entry for undo/redo const historyEntry = flowService.createHistoryEntry(flow.nodes, flow.edges); // Generate a sample flow const sampleFlow = flowService.generateSampleFlow('Sample Flow'); ``` -------------------------------- ### GET /api/cwd Source: https://github.com/mario-andreschak/flujo/blob/main/src/app/api/cwd/README.md Retrieves the current working directory and the MCP servers directory path. ```APIDOC ## GET /api/cwd ### Description Returns the current working directory and MCP servers directory path. ### Method GET ### Endpoint /api/cwd ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful. - **cwd** (string) - The current working directory path. - **mcpServersDir** (string) - The path to the MCP servers directory. #### Response Example ```json { "success": true, "cwd": "/path/to/current/working/directory", "mcpServersDir": "/path/to/current/working/directory/mcp-servers" } ``` #### Error Response (500) - **success** (boolean) - Indicates if the request was successful. - **error** (string) - A message describing the error. #### Error Response Example ```json { "success": false, "error": "Failed to get current working directory: Error message" } ``` ``` -------------------------------- ### Build Flujo Docker Image with Script Source: https://github.com/mario-andreschak/flujo/blob/main/DOCKER.md Build the Flujo Docker image using the provided script. Use the --verbose option to see build output and --tag to specify a custom image tag. ```bash ./scripts/build-docker.sh --verbose --tag= ``` -------------------------------- ### Get All Environment Variables (Masked) Source: https://github.com/mario-andreschak/flujo/blob/main/src/app/api/env/README.md Retrieves all environment variables. Sensitive values are masked by default. ```typescript const response = await fetch('/api/env'); const data = await response.json(); console.log('Environment variables:', data.variables); ``` -------------------------------- ### Get a Single Environment Variable Source: https://context7.com/mario-andreschak/flujo/llms.txt Retrieves a specific environment variable by its key. The value is returned directly. ```bash curl "http://localhost:4200/api/env?key=MY_CONFIG" ``` -------------------------------- ### Initialize the Application using Fetch API Source: https://github.com/mario-andreschak/flujo/blob/main/src/app/api/init/README.md This TypeScript code snippet demonstrates how to call the initialization API using the fetch API and handle both success and error responses. ```typescript // Initialize the application const response = await fetch('/api/init'); const data = await response.json(); if (data.success) { console.log('Initialization successful:', data.message); } else { console.error('Initialization failed:', data.error); // Show error message to user showErrorNotification(data.error); } ``` -------------------------------- ### Get Environment Variables (Secrets Masked) Source: https://context7.com/mario-andreschak/flujo/llms.txt Retrieves all stored environment variables. By default, secret values are masked as '********'. ```bash curl "http://localhost:4200/api/env" ``` -------------------------------- ### List Flows API Source: https://github.com/mario-andreschak/flujo/blob/main/src/app/api/README.md Lists all available flows. Use this endpoint to get an overview of existing flow definitions. ```http GET /api/flow?action=listFlows ``` -------------------------------- ### GET /api/storage Source: https://github.com/mario-andreschak/flujo/blob/main/src/app/api/storage/README.md Retrieves data from storage using a specified key. An optional default value can be provided if the key does not exist. ```APIDOC ## GET /api/storage ### Description Retrieves data from storage. ### Method GET ### Endpoint /api/storage ### Parameters #### Query Parameters - **key** (string) - Required - The storage key to retrieve (must be a valid `StorageKey` enum value) - **defaultValue** (string) - Optional - JSON string of the default value to return if the key doesn't exist ### Response #### Success Response (200) - **value** (any) - The stored data associated with the key #### Response Example ```json { "value": "stored data" } ``` ``` -------------------------------- ### Test-run an MCP Server Source: https://context7.com/mario-andreschak/flujo/llms.txt Execute a server with a specified command and arguments, including environment variables. A timeout is applied, and a timeout is considered a success for MCP servers. ```bash curl -X POST http://localhost:4200/api/git \ -H "Content-Type: application/json" \ -d '{ "action": "run", "savePath": "/absolute/path/to/mcp-servers/my-server", "runCommand": "node", "args": ["dist/index.js"], "env": { "MY_API_KEY": "secret" } }' ``` -------------------------------- ### Display Dependency Status Source: https://github.com/mario-andreschak/flujo/blob/main/FLUJO-Launcher-README.md Shows the current installation and version status for each FLUJO dependency. Use this to quickly assess what needs attention. ```plaintext ☑️ Git for Windows ✅ Installed (2.43.0) ☑️ Node.js LTS ✅ Installed (v20.11.0) ☑️ Python 3.11 ❌ Not Installed ☑️ FLUJO Repository ✅ Repository Found ☑️ Build Application ⚠️ Not Built ``` -------------------------------- ### TypeScript: Perform Restore from Backup Source: https://github.com/mario-andreschak/flujo/blob/main/src/app/api/restore/README.md This TypeScript example demonstrates how to construct a FormData object with a backup file and selections, then send a POST request to the /api/restore endpoint. It includes basic response handling for success and error scenarios. ```typescript // Create a FormData object const formData = new FormData(); // Add the backup file formData.append('file', backupFile); // Add the selections formData.append('selections', JSON.stringify([ 'models', 'flows', 'mcpServers', 'settings' ])); // Send the restore request const response = await fetch('/api/restore', { method: 'POST', body: formData }); if (response.ok) { const data = await response.json(); console.log('Restore completed successfully'); } else { const errorData = await response.json(); console.error(`Error restoring from backup: ${errorData.error}`); } ``` -------------------------------- ### Check MCP Server Status Source: https://context7.com/mario-andreschak/flujo/llms.txt Checks the connection status of a specified MCP server. This is a GET request to the /api/mcp endpoint with action=status. ```bash curl "http://localhost:4200/api/mcp?action=status&server=github" ``` -------------------------------- ### Perform Model Operations API Source: https://github.com/mario-andreschak/flujo/blob/main/src/app/api/README.md Performs various model operations. This endpoint can be used for both GET and POST requests depending on the operation. ```http POST /api/model ``` -------------------------------- ### Basic Logger Usage Source: https://github.com/mario-andreschak/flujo/blob/main/src/utils/logger/README.md Demonstrates how to create and use a logger instance for basic logging with different log levels and data. ```typescript import { createLogger } from '@/utils/logger'; // Create a logger instance for this file const log = createLogger('path/to/component'); // Basic logging log.verbose('Extremely detailed message'); log.debug('Debug message'); log.info('Info message'); log.warn('Warning message'); log.error('Error message'); // Logging with data log.debug('Debug message with data', { key: 'value' }); ``` -------------------------------- ### Import and Use Model Service in TypeScript Source: https://github.com/mario-andreschak/flujo/blob/main/src/backend/services/model/README.md Demonstrates how to import the modelService and use its core functionalities like loading models, getting a specific model, adding a new model, fetching provider models, and generating completions. ```typescript import { modelService } from '@/backend/services/model'; // Load all models const models = await modelService.loadModels(); // Get a specific model const model = await modelService.getModel('model-id'); // Add a new model const result = await modelService.addModel({ id: 'new-model-id', name: 'gpt-4', displayName: 'GPT-4', encryptedApiKey: 'encrypted-api-key', baseUrl: 'https://api.openai.com/v1' }); // Fetch models from a provider const providerModels = await modelService.fetchProviderModels( 'https://api.openai.com/v1', 'model-id' ); // Generate a completion const completion = await modelService.generateCompletion( 'model-id', 'Generate a response to this prompt', [{ role: 'user', content: 'Hello, world!' }] ); ``` -------------------------------- ### Get Specific Sensitive Environment Variable (Decrypted) Source: https://github.com/mario-andreschak/flujo/blob/main/src/app/api/env/README.md Retrieves a specific sensitive environment variable and its decrypted value. Requires `includeSecrets=true`. ```typescript const responseWithSecret = await fetch('/api/env?key=API_KEY&includeSecrets=true'); const dataWithSecret = await responseWithSecret.json(); console.log('API Key:', dataWithSecret.value); ``` -------------------------------- ### Initiate OAuth Flow for MCP Servers Source: https://context7.com/mario-andreschak/flujo/llms.txt Begin the OAuth 2.0 authentication process for a streamable MCP server. Redirect the user to the returned authorizationUrl. ```bash curl -X POST http://localhost:4200/api/oauth/initiate \ -H "Content-Type: application/json" \ -d '{ "serverName": "my-oauth-server" }' # { # "authorizationUrl": "https://provider.com/oauth/authorize?client_id=...&state=...", # "serverName": "my-oauth-server" # } # Redirect the user to authorizationUrl; the callback will be handled at /api/oauth/callback ``` -------------------------------- ### Get Encryption Type API Request Source: https://github.com/mario-andreschak/flujo/blob/main/src/app/api/encryption/secure/README.md Use this JSON payload to retrieve the current encryption type, which can be either 'default' or 'user'. ```json { "action": "get_encryption_type" } ``` -------------------------------- ### Get Specific Environment Variable Source: https://github.com/mario-andreschak/flujo/blob/main/src/app/api/env/README.md Retrieves a single environment variable by its key. Sensitive values are masked unless `includeSecrets=true` is specified. ```typescript const response = await fetch('/api/env?key=API_URL'); const data = await response.json(); console.log('API URL:', data.value); ``` -------------------------------- ### Example Restore API Success Response Source: https://github.com/mario-andreschak/flujo/blob/main/src/app/api/restore/README.md A successful restore operation returns a JSON object with a 'success' flag set to true. ```json { "success": true } ```