### Initialize Project Source: https://flowlib.dev/docs/reference/cli Interactive setup wizard for project configuration and dependency installation. ```bash npx flowlib-cli init ``` ```bash npx flowlib-cli init --framework express --database sqlite --package-manager pnpm ``` -------------------------------- ### init Source: https://flowlib.dev/docs/reference/cli Runs an interactive setup wizard to initialize a Flowlib project, including framework detection, dependency installation, and configuration creation. ```APIDOC ## CLI Command: init ### Description Interactive setup wizard. Detects framework, installs dependencies, creates config, generates schemas, and runs initial migration. ### Usage `npx flowlib-cli init [options]` ### Options - **--framework** (string) - Optional - Skip framework detection (express, nestjs, nextjs). - **--database** (string) - Optional - Skip database selection (sqlite, postgresql, mysql). - **--package-manager** (string) - Optional - Skip package manager detection (npm, pnpm, yarn, bun). ### Example `npx flowlib-cli init --framework express --database sqlite --package-manager pnpm` ``` -------------------------------- ### Start Development Server Source: https://flowlib.dev/docs/installation Commands to start the development server for different framework environments. ```bash npx tsx index.ts ``` ```bash npx nest start --watch ``` ```bash npx next dev ``` -------------------------------- ### Install @flowlib/webhooks Source: https://flowlib.dev/docs/plugins/webhooks Installation commands for various package managers. ```bash pnpm add @flowlib/webhooks ``` ```bash npm install @flowlib/webhooks ``` ```bash yarn add @flowlib/webhooks ``` ```bash bun add @flowlib/webhooks ``` -------------------------------- ### Install @flowlib/user-auth Source: https://flowlib.dev/docs/plugins/authentication Commands to install the authentication plugin using various package managers. ```bash pnpm add @flowlib/user-auth ``` ```bash npm install @flowlib/user-auth ``` ```bash yarn add @flowlib/user-auth ``` ```bash bun add @flowlib/user-auth ``` -------------------------------- ### Install Version Control Plugin Source: https://flowlib.dev/docs/plugins/version-control Install the package using your preferred package manager. ```shell pnpm add @flowlib/version-control ``` ```shell npm install @flowlib/version-control ``` ```shell yarn add @flowlib/version-control ``` ```shell bun add @flowlib/version-control ``` -------------------------------- ### Implement plugin init and shutdown hooks Source: https://flowlib.dev/docs/plugins/build-your-own Uses init for setup tasks like starting intervals and shutdown for cleanup to prevent resource leaks. ```typescript export function myPlugin(): FlowlibPlugin { let interval: NodeJS.Timeout; return { id: 'my-plugin', async init(ctx) { ctx.logger.info('My plugin initializing'); interval = setInterval(() => { /* background work */ }, 60000); }, async shutdown() { clearInterval(interval); }, }; } ``` -------------------------------- ### Install @flowlib/mcp Source: https://flowlib.dev/docs/plugins/mcp Install the MCP plugin using your preferred package manager. ```bash pnpm add @flowlib/mcp ``` ```bash npm install @flowlib/mcp ``` ```bash yarn add @flowlib/mcp ``` ```bash bun add @flowlib/mcp ``` -------------------------------- ### Install Flowlib UI Source: https://flowlib.dev/docs/quickstart Install the UI package for React-based frontend applications. ```bash pnpm add @flowlib/ui ``` -------------------------------- ### GET /plugins/{pluginId}/stats Source: https://flowlib.dev/docs/plugins/build-your-own Example of a simple GET endpoint returning plugin statistics. ```APIDOC ## GET /plugins/{pluginId}/stats ### Description Retrieves statistics for the specified plugin. ### Method GET ### Endpoint /plugins/{pluginId}/stats ### Response #### Success Response (200) - **requests** (number) - The number of requests processed. ``` -------------------------------- ### Install Next.js Packages Source: https://flowlib.dev/docs/installation Install core, Next.js-specific, and UI Flowlib packages using your preferred package manager. ```bash pnpm add @flowlib/core @flowlib/nextjs @flowlib/ui ``` ```bash npm install @flowlib/core @flowlib/nextjs @flowlib/ui ``` ```bash yarn add @flowlib/core @flowlib/nextjs @flowlib/ui ``` ```bash bun add @flowlib/core @flowlib/nextjs @flowlib/ui ``` -------------------------------- ### Install RBAC Plugin Source: https://flowlib.dev/docs/plugins/access-control Commands to install the @flowlib/rbac package using various package managers. ```bash pnpm add @flowlib/rbac ``` ```bash npm install @flowlib/rbac ``` ```bash yarn add @flowlib/rbac ``` ```bash bun add @flowlib/rbac ``` -------------------------------- ### Install Express Packages Source: https://flowlib.dev/docs/installation Install core and Express-specific Flowlib packages using your preferred package manager. ```bash pnpm add @flowlib/core @flowlib/express ``` ```bash npm install @flowlib/core @flowlib/express ``` ```bash yarn add @flowlib/core @flowlib/express ``` ```bash bun add @flowlib/core @flowlib/express ``` -------------------------------- ### POST /credentials/oauth2/start Source: https://flowlib.dev/docs/reference/api Start OAuth2 authorization flow. ```APIDOC ## POST /credentials/oauth2/start ### Description Start OAuth2 authorization flow. ### Method POST ### Endpoint /credentials/oauth2/start ``` -------------------------------- ### Initialize Flowlib via CLI Source: https://flowlib.dev/docs Use the CLI to automatically detect your framework, install dependencies, and configure the database. ```bash npx flowlib-cli init ``` -------------------------------- ### Start MCP Server Source: https://flowlib.dev/docs/reference/cli Exposes Flowlib tools to AI assistants via the Model Context Protocol. ```bash npx flowlib-cli mcp --url http://localhost:3000/flowlib ``` ```bash npx flowlib-cli mcp --print-config ``` -------------------------------- ### Install NestJS Packages Source: https://flowlib.dev/docs/installation Install core and NestJS-specific Flowlib packages using your preferred package manager. ```bash pnpm add @flowlib/core @flowlib/nestjs ``` ```bash npm install @flowlib/core @flowlib/nestjs ``` ```bash yarn add @flowlib/core @flowlib/nestjs ``` ```bash bun add @flowlib/core @flowlib/nestjs ``` -------------------------------- ### Configure logging settings Source: https://flowlib.dev/docs/reference/configuration Example configuration for setting the global log level and applying per-scope overrides. ```yaml logging: { level: 'info', scopes: { execution: 'debug', batch: 'silent', ai: 'debug', }, } ``` -------------------------------- ### MCP Server Configuration Output Source: https://flowlib.dev/docs/plugins/mcp Example JSON structure for MCP server integration. ```json { "mcpServers": { "flowlib": { "command": "npx", "args": [ "flowlib-cli", "mcp", "--url", "http://localhost:3000/flowlib", "--api-key", "YOUR_KEY" ] } } } ``` -------------------------------- ### Setup Express Backend Source: https://flowlib.dev/docs/installation Initialize the Flowlib router within an Express application. ```typescript import 'dotenv/config'; import express from 'express'; import { createFlowlibRouter } from '@flowlib/express'; const app = express(); app.use(express.json()); app.use( '/flowlib', await createFlowlibRouter({ database: { type: 'sqlite', connectionString: process.env.DATABASE_URL!, }, encryptionKey: process.env.FLOWLIB_ENCRYPTION_KEY, }), ); app.listen(3000, () => { console.log('Flowlib API at http://localhost:3000/flowlib'); }); ``` -------------------------------- ### GET /agent/tools Source: https://flowlib.dev/docs/reference/api List all available agent tools. ```APIDOC ## GET /agent/tools ### Description List all available agent tools. ### Method GET ### Endpoint /agent/tools ``` -------------------------------- ### Setup Next.js API Route Source: https://flowlib.dev/docs/installation Create the catch-all API route handler for Flowlib in Next.js. ```typescript import { createFlowlibHandler } from '@flowlib/nextjs'; const handler = createFlowlibHandler({ database: { type: 'sqlite', connectionString: process.env.DATABASE_URL!, }, encryptionKey: process.env.FLOWLIB_ENCRYPTION_KEY, }); export const GET = handler.GET; export const POST = handler.POST; export const PATCH = handler.PATCH; export const PUT = handler.PUT; export const DELETE = handler.DELETE; ``` -------------------------------- ### info Source: https://flowlib.dev/docs/reference/cli Displays diagnostic information about the current project setup. ```APIDOC ## CLI Command: info ### Description Shows system info, detected framework, database type, config location, installed packages, and registered plugins. ### Usage `npx flowlib-cli info [options]` ### Options - **--config** (string) - Optional - Path to config file. - **--json** (boolean) - Optional - Output as JSON. ``` -------------------------------- ### Define Flowlib Configuration Source: https://flowlib.dev/docs/reference/configuration Full example of a flowlib.config.ts file demonstrating database, logging, execution, triggers, plugins, and credential configuration. ```typescript import { defineConfig } from '@flowlib/core'; import { auth } from '@flowlib/user-auth'; import { rbac } from '@flowlib/rbac'; export const flowlibConfig = defineConfig({ database: { type: 'postgresql', connectionString: process.env.DATABASE_URL, }, apiPath: '/api/flowlib', frontendPath: '/flowlib', theme: 'light', logging: { level: 'info', scopes: { execution: 'debug' }, }, execution: { defaultTimeout: 120000, maxConcurrentExecutions: 20, flowTimeoutMs: 600_000, }, triggers: { webhookBaseUrl: process.env.WEBHOOK_BASE_URL, cronEnabled: true, }, plugins: [ auth({ betterAuthOptions: { secret: process.env.BETTER_AUTH_SECRET }, globalAdmins: [ { email: process.env.ADMIN_EMAIL, pw: process.env.ADMIN_PASSWORD, name: 'Admin' }, ], }), rbac(), ], defaultCredentials: [ { name: 'OpenAI', type: 'llm', provider: 'openai', authType: 'apiKey', config: { apiKey: process.env.OPENAI_API_KEY }, isShared: true, }, ], }); ``` -------------------------------- ### mcp Source: https://flowlib.dev/docs/reference/cli Starts a Model Context Protocol (MCP) server over stdio to expose tools to AI assistants. ```APIDOC ## CLI Command: mcp ### Description Connects to a running Flowlib instance and exposes flow building/execution tools to AI assistants like Claude, Copilot, or Cursor. ### Usage `npx flowlib-cli mcp [options]` ### Options - **--url** (string) - Optional - URL of the running Flowlib API (default: http://localhost:3000/flowlib). - **--api-key** (string) - Optional - API key for authenticated access. - **--print-config** (boolean) - Optional - Output ready-to-paste MCP client config. ``` -------------------------------- ### GET /plugins/version-control/vc/flows/:flowId/history Source: https://flowlib.dev/docs/plugins/version-control Get the synchronization history for a specific flow. ```APIDOC ## GET /plugins/version-control/vc/flows/:flowId/history ### Description Get sync history for a flow. ### Method GET ### Endpoint /plugins/version-control/vc/flows/:flowId/history ``` -------------------------------- ### Setup NestJS Backend Source: https://flowlib.dev/docs/installation Register the Flowlib module in the NestJS application module. ```typescript import { Module } from '@nestjs/common'; import { FlowlibModule } from '@flowlib/nestjs'; @Module({ imports: [ FlowlibModule.forRoot({ database: { type: 'sqlite', connectionString: process.env.DATABASE_URL!, }, encryptionKey: process.env.FLOWLIB_ENCRYPTION_KEY, }), ], }) export class AppModule {} ``` -------------------------------- ### Setup Next.js Cron Handler Source: https://flowlib.dev/docs/installation Configure a dedicated maintenance route for background tasks in Next.js. ```typescript import { createFlowlibCronHandler } from '@flowlib/nextjs'; const handleCron = createFlowlibCronHandler({ database: { type: 'sqlite', connectionString: process.env.DATABASE_URL!, }, encryptionKey: process.env.FLOWLIB_ENCRYPTION_KEY, triggers: { cronEnabled: true, webhookBaseUrl: 'https://your-app.com/api/flowlib', }, }); export const GET = handleCron; ``` -------------------------------- ### GET /credentials Source: https://flowlib.dev/docs/reference/api Lists credentials with optional filtering. ```APIDOC ## GET /credentials ### Description List credentials. ### Method GET ### Endpoint /credentials ### Parameters #### Query Parameters - **type** (string) - Optional - Filter by type. - **authType** (string) - Optional - Filter by auth type. - **isActive** (boolean) - Optional - Filter by active status. ``` -------------------------------- ### GET /plugins/version-control/vc/flows Source: https://flowlib.dev/docs/plugins/version-control List all flows currently synced with the version control system. ```APIDOC ## GET /plugins/version-control/vc/flows ### Description List all synced flows. ### Method GET ### Endpoint /plugins/version-control/vc/flows ``` -------------------------------- ### Integrate Flowlib with Node.js Frameworks Source: https://flowlib.dev/docs Examples for mounting Flowlib into Express, NestJS, and Next.js applications. ```typescript import express from 'express'; import { createFlowlibRouter } from '@flowlib/express'; const app = express(); const router = await createFlowlibRouter({ database: { type: 'sqlite', connectionString: 'file:./dev.db' }, encryptionKey: process.env.FLOWLIB_ENCRYPTION_KEY, }); app.use('/flowlib', router); app.listen(3000); ``` ```typescript import { Module } from '@nestjs/common'; import { FlowlibModule } from '@flowlib/nestjs'; @Module({ imports: [ FlowlibModule.forRoot({ database: { type: 'sqlite', connectionString: 'file:./dev.db' }, encryptionKey: process.env.FLOWLIB_ENCRYPTION_KEY, }), ], }) export class AppModule {} ``` ```typescript import { createFlowlibHandler } from '@flowlib/nextjs'; const handler = createFlowlibHandler({ database: { type: 'sqlite', connectionString: 'file:./dev.db' }, encryptionKey: process.env.FLOWLIB_ENCRYPTION_KEY, }); export const GET = handler.GET; export const POST = handler.POST; export const PATCH = handler.PATCH; export const PUT = handler.PUT; export const DELETE = handler.DELETE; ``` -------------------------------- ### GET /nodes Source: https://flowlib.dev/docs/reference/api Retrieves all available node definitions. ```APIDOC ## GET /nodes ### Description Get all available node definitions. ### Method GET ### Endpoint /nodes ``` -------------------------------- ### GET /credentials/oauth2/callback Source: https://flowlib.dev/docs/reference/api Handle OAuth2 redirect callback. ```APIDOC ## GET /credentials/oauth2/callback ### Description Handle OAuth2 redirect callback. ### Method GET ### Endpoint /credentials/oauth2/callback ``` -------------------------------- ### POST /plugins/{pluginId}/items/:id Source: https://flowlib.dev/docs/plugins/build-your-own Example of a POST endpoint using path parameters and request body data. ```APIDOC ## POST /plugins/{pluginId}/items/:id ### Description Creates or updates an item with a specific ID. ### Method POST ### Endpoint /plugins/{pluginId}/items/:id ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the item. #### Request Body - **name** (string) - Required - The name of the item. ### Response #### Success Response (201) - **id** (string) - The ID of the item. - **name** (string) - The name of the item. ``` -------------------------------- ### GET /node-data/databases Source: https://flowlib.dev/docs/reference/api Retrieves a list of available databases. ```APIDOC ## GET /node-data/databases ### Description Get available databases. ### Method GET ### Endpoint /node-data/databases ``` -------------------------------- ### Configure Custom Better Auth Instance Source: https://flowlib.dev/docs/plugins/authentication Advanced setup for full control by passing a custom Better Auth instance to the plugin. ```typescript import { betterAuth } from 'better-auth'; import { auth } from '@flowlib/user-auth'; const myAuth = betterAuth({ /* full Better Auth config */ }); export const flowlibConfig = defineConfig({ // ... plugins: [auth({ auth: myAuth })], }); ``` -------------------------------- ### Configure Authentication in flowlib.config.ts Source: https://flowlib.dev/docs/plugins/authentication Basic setup where the plugin manages the Better Auth instance internally. ```typescript import { defineConfig } from '@flowlib/core'; import { auth } from '@flowlib/user-auth'; export const flowlibConfig = defineConfig({ database: { type: 'sqlite', connectionString: 'file:./dev.db' }, plugins: [ auth({ betterAuthOptions: { secret: process.env.BETTER_AUTH_SECRET, }, globalAdmins: [{ email: 'admin@example.com', pw: 'changeme', name: 'Admin' }], }), ], }); ``` -------------------------------- ### GET /node-data/models Source: https://flowlib.dev/docs/reference/api Retrieves a list of available AI models. ```APIDOC ## GET /node-data/models ### Description Get available AI models. ### Method GET ### Endpoint /node-data/models ### Parameters #### Query Parameters - **credentialId** (string) - Optional - Filter by credential ID. - **provider** (string) - Optional - Filter by provider. ``` -------------------------------- ### GET /chat/status Source: https://flowlib.dev/docs/reference/api Check if chat is enabled. ```APIDOC ## GET /chat/status ### Description Check if chat is enabled. ### Method GET ### Endpoint /chat/status ``` -------------------------------- ### GET /credentials/oauth2/providers Source: https://flowlib.dev/docs/reference/api List available OAuth2 providers. ```APIDOC ## GET /credentials/oauth2/providers ### Description List available OAuth2 providers. ### Method GET ### Endpoint /credentials/oauth2/providers ``` -------------------------------- ### GET /credentials/expiring Source: https://flowlib.dev/docs/reference/api Retrieves a list of credentials that are expiring soon. ```APIDOC ## GET /credentials/expiring ### Description Get expiring credentials. ### Method GET ### Endpoint /credentials/expiring ### Parameters #### Query Parameters - **daysUntilExpiry** (number) - Optional - Number of days until expiry. ``` -------------------------------- ### GET /actions/:actionId/fields/:fieldName/options Source: https://flowlib.dev/docs/reference/api Loads dynamic field options for a specific action field. ```APIDOC ## GET /actions/:actionId/fields/:fieldName/options ### Description Load dynamic field options. ### Method GET ### Endpoint /actions/:actionId/fields/:fieldName/options ### Parameters #### Path Parameters - **actionId** (string) - Required - The ID of the action. - **fieldName** (string) - Required - The name of the field. ``` -------------------------------- ### Flow Execution Endpoints Source: https://flowlib.dev/docs/reference/api Endpoints for starting, monitoring, and controlling flow executions. ```APIDOC ## POST /flows/:flowId/run ### Method POST ### Endpoint /flows/:flowId/run ## POST /flows/:flowId/run-to-node/:nodeId ### Method POST ### Endpoint /flows/:flowId/run-to-node/:nodeId ## POST /flow-runs/list ### Method POST ### Endpoint /flow-runs/list ## GET /flow-runs/:flowRunId ### Method GET ### Endpoint /flow-runs/:flowRunId ## GET /flows/:flowId/flow-runs ### Method GET ### Endpoint /flows/:flowId/flow-runs ## POST /flow-runs/:flowRunId/resume ### Method POST ### Endpoint /flow-runs/:flowRunId/resume ## POST /flow-runs/:flowRunId/cancel ### Method POST ### Endpoint /flow-runs/:flowRunId/cancel ## POST /flow-runs/:flowRunId/pause ### Method POST ### Endpoint /flow-runs/:flowRunId/pause ``` -------------------------------- ### Accessing Upstream Data in Nodes Source: https://flowlib.dev/docs/execution-model Example of the incoming data object structure received by a node with multiple upstream dependencies. ```json { "fetch_user": { "id": 123, "name": "Alice", "email": "alice@example.com" }, "generate_subject": "Welcome aboard, Alice!" } ``` -------------------------------- ### Define a plugin API endpoint Source: https://flowlib.dev/docs/plugins/build-your-own Defines a basic GET endpoint mounted at /plugins/{pluginId}/stats. ```typescript export function myPlugin(): FlowlibPlugin { return { id: 'my-plugin', endpoints: [ { method: 'GET', path: '/stats', handler: async (ctx) => { return { body: { requests: 42 } }; }, }, ], }; } // Accessible at: GET /plugins/my-plugin/stats ``` -------------------------------- ### GET /triggers/:triggerId Source: https://flowlib.dev/docs/reference/api Get a specific trigger. ```APIDOC ## GET /triggers/:triggerId ### Description Get a specific trigger. ### Method GET ### Endpoint /triggers/:triggerId ### Parameters #### Path Parameters - **triggerId** (string) - Required - The ID of the trigger. ``` -------------------------------- ### Execute a flow programmatically Source: https://flowlib.dev/docs/triggers Start a flow execution using the Flowlib core API within a JavaScript or TypeScript environment. ```javascript const core = flowlib.getCore(); const result = await core.runs.start(flowId, { topic: 'Machine learning', }); ``` -------------------------------- ### GET /chat/messages/:flowId Source: https://flowlib.dev/docs/reference/api Get persisted chat messages. ```APIDOC ## GET /chat/messages/:flowId ### Description Get persisted chat messages. ### Method GET ### Endpoint /chat/messages/:flowId ### Parameters #### Path Parameters - **flowId** (string) - Required - The ID of the flow. ``` -------------------------------- ### GET /credentials/oauth2/providers/:providerId Source: https://flowlib.dev/docs/reference/api Get specific OAuth2 provider. ```APIDOC ## GET /credentials/oauth2/providers/:providerId ### Description Get specific OAuth2 provider. ### Method GET ### Endpoint /credentials/oauth2/providers/:providerId ### Parameters #### Path Parameters - **providerId** (string) - Required - The ID of the OAuth2 provider. ``` -------------------------------- ### Configure Environment Variables Source: https://flowlib.dev/docs/installation Set the database connection and encryption key in your environment configuration files. ```text DATABASE_URL=file:./dev.db FLOWLIB_ENCRYPTION_KEY= # Generate with: npx flowlib-cli secret ``` -------------------------------- ### Generate and Migrate Database Source: https://flowlib.dev/docs/installation Run CLI commands to generate and apply database migrations. ```bash npx flowlib-cli generate npx flowlib-cli migrate ``` -------------------------------- ### Graduate a stable release from next to latest Source: https://flowlib.dev/docs/developers/release-process Commands to exit pre-release mode, commit the version bump, and re-enter pre-release mode to resume development. ```bash git checkout main git pull # 1. Leave pre-release mode. This removes pre-release state and # resolves the accumulated changesets into a real version bump. pnpm changeset pre exit # 2. Commit and push. The Release workflow will open a Version Packages PR # with real versions (e.g. 0.3.0 instead of 0.3.0-next.4). git add .changeset/pre.json git commit -m "chore: exit pre-release mode" git push # 3. Review and merge the Version Packages PR. # Publish goes out under `latest` — this is the new default install. # 4. Re-enter pre-release mode to resume daily work on `next`. pnpm changeset pre enter next git add .changeset/pre.json git commit -m "chore: enter next pre-release mode" git push ``` -------------------------------- ### GET /chat/models/:credentialId Source: https://flowlib.dev/docs/reference/api List models for a credential. ```APIDOC ## GET /chat/models/:credentialId ### Description List models for a credential. ### Method GET ### Endpoint /chat/models/:credentialId ### Parameters #### Path Parameters - **credentialId** (string) - Required - The ID of the credential. #### Query Parameters - **q** (string) - Optional - Search query. ``` -------------------------------- ### Regenerate and Migrate Database Source: https://flowlib.dev/docs/plugins/overview Run these CLI commands after adding plugins that include database tables to update the schema. ```bash npx flowlib-cli generate npx flowlib-cli migrate --push ``` -------------------------------- ### GET /credentials/:id Source: https://flowlib.dev/docs/reference/api Retrieves a credential by its ID. ```APIDOC ## GET /credentials/:id ### Description Get credential by ID. ### Method GET ### Endpoint /credentials/:id ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the credential. ``` -------------------------------- ### POST /plugins/version-control/vc/push-all Source: https://flowlib.dev/docs/plugins/version-control Push all currently synced flows to their respective remote repositories. ```APIDOC ## POST /plugins/version-control/vc/push-all ### Description Push all synced flows. ### Method POST ### Endpoint /plugins/version-control/vc/push-all ``` -------------------------------- ### Generate Claude Desktop Configuration Source: https://flowlib.dev/docs/plugins/mcp Use the CLI to generate the required configuration snippet for Claude Desktop. ```bash npx flowlib-cli mcp --print-config ``` -------------------------------- ### Basic CLI Usage Source: https://flowlib.dev/docs/reference/cli General syntax for executing Flowlib CLI commands. ```bash npx flowlib-cli [options] ``` -------------------------------- ### Initialize Flowlib Plugins Source: https://flowlib.dev/docs/reference/configuration Defines the array of plugin instances to be initialized in order. Ensure the webhookBaseUrl is correctly set for the webhooks plugin. ```javascript plugins: [ auth({ /* ... */ }), rbac(), webhooks({ webhookBaseUrl: 'https://api.myapp.com/flowlib' }), ]; ``` -------------------------------- ### GET /node-definition/:nodeType Source: https://flowlib.dev/docs/reference/api Retrieves a specific node definition by its type. ```APIDOC ## GET /node-definition/:nodeType ### Description Get a specific node definition. ### Method GET ### Endpoint /node-definition/:nodeType ### Parameters #### Path Parameters - **nodeType** (string) - Required - The type of the node. ``` -------------------------------- ### GET /plugins/version-control/vc/flows/:flowId/status Source: https://flowlib.dev/docs/plugins/version-control Retrieve the current synchronization status for a specific flow. ```APIDOC ## GET /plugins/version-control/vc/flows/:flowId/status ### Description Get sync status for a flow. ### Method GET ### Endpoint /plugins/version-control/vc/flows/:flowId/status ``` -------------------------------- ### POST /plugins/version-control/vc/flows/:flowId/configure Source: https://flowlib.dev/docs/plugins/version-control Configure synchronization settings for a specific flow. ```APIDOC ## POST /plugins/version-control/vc/flows/:flowId/configure ### Description Configure sync for a flow. ### Method POST ### Endpoint /plugins/version-control/vc/flows/:flowId/configure ``` -------------------------------- ### GET /plugins/rbac/flows/:flowId/access Source: https://flowlib.dev/docs/plugins/access-control Retrieves a list of all access rules defined for a specific flow. ```APIDOC ## GET /plugins/rbac/flows/:flowId/access ### Description List all access rules for a specific flow. ### Method GET ### Endpoint /plugins/rbac/flows/:flowId/access ### Parameters #### Path Parameters - **flowId** (string) - Required - The unique identifier of the flow. ``` -------------------------------- ### POST /credentials Source: https://flowlib.dev/docs/reference/api Creates a new credential. ```APIDOC ## POST /credentials ### Description Create a credential. ### Method POST ### Endpoint /credentials ``` -------------------------------- ### POST /plugins/version-control/vc/pull-all Source: https://flowlib.dev/docs/plugins/version-control Pull all currently synced flows from their respective remote repositories. ```APIDOC ## POST /plugins/version-control/vc/pull-all ### Description Pull all synced flows. ### Method POST ### Endpoint /plugins/version-control/vc/pull-all ``` -------------------------------- ### GET /flow-runs/:flowRunId/stream Source: https://flowlib.dev/docs/reference/api Provides an SSE stream of execution events for a specific flow run. ```APIDOC ## GET /flow-runs/:flowRunId/stream ### Description SSE stream of execution events. ### Method GET ### Endpoint /flow-runs/:flowRunId/stream ### Parameters #### Path Parameters - **flowRunId** (string) - Required - The ID of the flow run. ``` -------------------------------- ### GET /flow-runs/:flowRunId/node-executions Source: https://flowlib.dev/docs/reference/api Retrieves the list of node executions associated with a specific flow run. ```APIDOC ## GET /flow-runs/:flowRunId/node-executions ### Description Get node executions for a run. ### Method GET ### Endpoint /flow-runs/:flowRunId/node-executions ### Parameters #### Path Parameters - **flowRunId** (string) - Required - The ID of the flow run. ``` -------------------------------- ### Configure Flowlib in Next.js Source: https://flowlib.dev/docs/installation Sets up Flowlib API handlers and cron handlers in a Next.js application. ```typescript import { createFlowlibHandler } from '@flowlib/nextjs'; import { auth } from '@flowlib/user-auth'; import { rbac } from '@flowlib/rbac'; const handler = createFlowlibHandler({ database: { type: 'sqlite', connectionString: process.env.DATABASE_URL!, }, encryptionKey: process.env.FLOWLIB_ENCRYPTION_KEY, execution: { defaultTimeout: 60000, maxConcurrentExecutions: 10, }, triggers: { cronEnabled: true, webhookBaseUrl: 'https://your-app.com/api/flowlib', }, plugins: [ auth({ /* Better Auth options */ }), rbac(), ], defaultCredentials: [ { name: 'OpenAI', type: 'llm', provider: 'openai', authType: 'apiKey', config: { apiKey: process.env.OPENAI_API_KEY! }, }, ], }); export const GET = handler.GET; export const POST = handler.POST; export const PATCH = handler.PATCH; export const PUT = handler.PUT; export const DELETE = handler.DELETE; ``` ```typescript import { createFlowlibCronHandler } from '@flowlib/nextjs'; import { auth } from '@flowlib/user-auth'; import { rbac } from '@flowlib/rbac'; export const GET = createFlowlibCronHandler({ database: { type: 'sqlite', connectionString: process.env.DATABASE_URL!, }, encryptionKey: process.env.FLOWLIB_ENCRYPTION_KEY, execution: { defaultTimeout: 60000, maxConcurrentExecutions: 10, }, triggers: { cronEnabled: true, webhookBaseUrl: 'https://your-app.com/api/flowlib', }, plugins: [ auth({ /* Better Auth options */ }), rbac(), ], defaultCredentials: [ { name: 'OpenAI', type: 'llm', provider: 'openai', authType: 'apiKey', config: { apiKey: process.env.OPENAI_API_KEY! }, }, ], }); ``` -------------------------------- ### GET /flows/:flowId/triggers Source: https://flowlib.dev/docs/plugins/webhooks Lists all triggers associated with a specific flow, including webhook triggers. ```APIDOC ## GET /flows/:flowId/triggers ### Description Lists all triggers including webhooks for a given flow. ### Method GET ### Endpoint /flows/:flowId/triggers ### Parameters #### Path Parameters - **flowId** (string) - Required - The unique identifier of the flow. ``` -------------------------------- ### Handle POST requests with parameters Source: https://flowlib.dev/docs/plugins/build-your-own Demonstrates accessing route parameters, request body, and the Flowlib instance within an endpoint handler. ```typescript endpoints: [ { method: 'POST', path: '/items/:id', handler: async (ctx) => { const { id } = ctx.params; const { name } = ctx.body; const flowlib = ctx.getFlowlib(); // Access flows, runs, etc. via the Flowlib instance return { status: 201, body: { id, name } }; }, }, ]; ``` -------------------------------- ### Generate Encryption Key Source: https://flowlib.dev/docs/reference/cli Creates a secure 32-byte base64 key for environment variables. ```bash npx flowlib-cli secret ``` -------------------------------- ### POST /node-data/model-query Source: https://flowlib.dev/docs/reference/api Tests an AI model prompt. ```APIDOC ## POST /node-data/model-query ### Description Test an AI model prompt. ### Method POST ### Endpoint /node-data/model-query ``` -------------------------------- ### Mount Flowlib Frontend in Next.js Source: https://flowlib.dev/docs/installation Use dynamic imports to render the Flowlib component on the frontend. ```typescript 'use client'; import dynamic from 'next/dynamic'; import '@flowlib/ui/styles'; import config from '../../flowlib.config'; const Flowlib = dynamic(() => import('@flowlib/ui').then((m) => ({ default: m.Flowlib })), { ssr: false, }); export default function FlowlibPage() { return ; } ``` -------------------------------- ### Configure MCP Options Source: https://flowlib.dev/docs/plugins/mcp Customize session TTL and audit logging settings within the plugin configuration. ```typescript mcp({ sessionTtlMs: 60 * 60 * 1000, // 1 hour sessions audit: { enabled: true, persist: true, logLevel: 'debug' }, }); ``` -------------------------------- ### GET /dashboard/stats Source: https://flowlib.dev/docs/reference/api Retrieves dashboard statistics including flow counts, run counts, and activity metrics. ```APIDOC ## GET /dashboard/stats ### Description Retrieves dashboard statistics including flow counts, run counts, and activity metrics. ### Method GET ### Endpoint /dashboard/stats ``` -------------------------------- ### Configure Version Control Source: https://flowlib.dev/docs/plugins/version-control Add the plugin to your flowlib.config.ts file with the required Git provider and repository details. ```typescript import { versionControl } from '@flowlib/version-control'; import { githubProvider } from '@flowlib/version-control/providers/github'; export const flowlibConfig = defineConfig({ // ... plugins: [ versionControl({ provider: githubProvider({ token: process.env.GITHUB_TOKEN }), repo: 'my-org/my-flows', }), ], }); ``` -------------------------------- ### Configure Flowlib Plugins Source: https://flowlib.dev/docs/plugins/overview Register plugins within the createFlowlibRouter configuration object. ```javascript import { auth } from '@flowlib/user-auth'; import { rbac } from '@flowlib/rbac'; const router = await createFlowlibRouter({ // ... plugins: [ auth({ /* Better Auth options */ }), rbac(), ], }); ``` -------------------------------- ### Define a basic Flowlib plugin Source: https://flowlib.dev/docs/plugins/build-your-own Create a plugin by returning an object that conforms to the FlowlibPlugin interface. ```typescript import type { FlowlibPlugin } from '@flowlib/core'; export function myPlugin(): FlowlibPlugin { return { id: 'my-plugin', name: 'My Plugin', }; } ``` -------------------------------- ### VS Code MCP Configuration Source: https://flowlib.dev/docs/plugins/mcp Add this configuration to your .vscode/mcp.json file. ```json { "servers": { "flowlib": { "command": "npx", "args": [ "flowlib-cli", "mcp", "--url", "http://localhost:3000/flowlib", "--api-key", "YOUR_KEY" ] } } } ``` -------------------------------- ### MCP Connection Architecture Diagram Source: https://flowlib.dev/docs/plugins/mcp Visual representation of the Stdio and Direct connection modes for the Flowlib MCP server. ```text ┌──────────────┐ stdio ┌──────────────┐ HTTP ┌────────────┐ │ Claude / VS │ ───────► │ flowlib-cli │ ─────► │ Flowlib │ │ Code / Cursor│ │ mcp server │ │ API │ └──────────────┘ └──────────────┘ └────────────┘ ┌──────────────┐ HTTP ┌────────────────────────────────────┐ │ MCP Client │ ───────► │ Flowlib (w/ mcpPlugin, direct) │ └──────────────┘ └────────────────────────────────────┘ ``` -------------------------------- ### Display Diagnostic Info Source: https://flowlib.dev/docs/reference/cli Outputs system and configuration details for debugging. ```bash npx flowlib-cli info ``` -------------------------------- ### Database Migration Source: https://flowlib.dev/docs/reference/cli Applies database schema changes, either via migration files or direct push. ```bash # Production: generate + apply migration files npx flowlib-cli migrate # Development: push schema directly (fast, no migration files) npx flowlib-cli migrate --push ``` -------------------------------- ### POST /plugins/version-control/vc/webhook Source: https://flowlib.dev/docs/plugins/version-control Webhook receiver endpoint for Git events. ```APIDOC ## POST /plugins/version-control/vc/webhook ### Description Webhook receiver for Git events (public). ### Method POST ### Endpoint /plugins/version-control/vc/webhook ``` -------------------------------- ### Define PostgreSQL database configuration Source: https://flowlib.dev/docs/installation Specify the database type and connection string for PostgreSQL integration. ```javascript database: { type: 'postgresql', connectionString: 'postgresql://user:pass@localhost:5432/myapp', }, ``` -------------------------------- ### migrate Source: https://flowlib.dev/docs/reference/cli Applies database schema changes to the project. ```APIDOC ## CLI Command: migrate ### Description Apply database schema changes. In development, use --push to apply schema directly without migration files. ### Usage `npx flowlib-cli migrate [options]` ### Options - **--config** (string) - Optional - Path to config file. - **--push** (boolean) - Optional - Use drizzle-kit push (fast, no migration files). - **-y, --yes** (boolean) - Optional - Skip confirmation prompts. ``` -------------------------------- ### POST /chat Source: https://flowlib.dev/docs/reference/api Chat streaming endpoint (SSE). ```APIDOC ## POST /chat ### Description Chat streaming endpoint (SSE). ### Method POST ### Endpoint /chat ``` -------------------------------- ### Execute a flow via REST API Source: https://flowlib.dev/docs/triggers Use a POST request to trigger a flow manually with specific input parameters. ```bash curl -X POST http://localhost:3000/flowlib/flows/{flowId}/run \ -H "Content-Type: application/json" \ -d '{ "inputs": { "topic": "Machine learning" } }' ``` -------------------------------- ### POST /flowlib/flows/{flowId}/run Source: https://flowlib.dev/docs/triggers Executes a flow manually via the REST API. ```APIDOC ## POST /flowlib/flows/{flowId}/run ### Description Triggers a flow execution manually using the REST API. ### Method POST ### Endpoint /flowlib/flows/{flowId}/run ### Parameters #### Path Parameters - **flowId** (string) - Required - The unique identifier of the flow to run. #### Request Body - **inputs** (object) - Optional - Key/value pairs to pass as inputs to the flow. ### Request Example { "inputs": { "topic": "Machine learning" } } ``` -------------------------------- ### Mount Flowlib Editor in Next.js Source: https://flowlib.dev/docs/installation Mount the Flowlib component in a Next.js catch-all route using dynamic imports to disable SSR. ```tsx 'use client'; import dynamic from 'next/dynamic'; import '@flowlib/ui/styles'; import config from '../../flowlib.config'; const Flowlib = dynamic(() => import('@flowlib/ui').then((mod) => ({ default: mod.Flowlib })), { ssr: false, }); export default function FlowlibPage() { return ; } ``` -------------------------------- ### POST /node-data/sql-query Source: https://flowlib.dev/docs/reference/api Tests a SQL query against the configured data source. ```APIDOC ## POST /node-data/sql-query ### Description Test a SQL query. ### Method POST ### Endpoint /node-data/sql-query ``` -------------------------------- ### MCP Tool Interface Source: https://flowlib.dev/docs/plugins/mcp The AI assistant can invoke these tools to interact with the flow library system. ```APIDOC ## Available MCP Tools ### Flow Management - **flow_list**: List all flows with names, IDs, and status. - **flow_get**: Get detailed metadata for a specific flow. - **flow_get_definition**: Get the full flow definition (nodes, edges, params). - **flow_create**: Create a new flow. - **flow_update**: Update a flow's definition or metadata. - **flow_delete**: Delete a flow. - **flow_validate**: Validate a flow definition for errors. ### Version Management - **version_list**: List all versions of a flow. - **version_get**: Get a specific version's definition. - **version_publish**: Publish a new version of a flow. ### Flow Execution - **run_start**: Start a flow run with inputs. - **run_to_node**: Run a flow up to a specific node (partial execution). - **run_list**: List recent flow runs. - **run_get**: Get details of a specific run. - **run_cancel**: Cancel a running flow. - **run_pause**: Pause a running flow. - **run_resume**: Resume a paused flow. ### Debugging - **debug_node_executions**: Get per-node execution traces for a run. - **debug_test_node**: Test a single node with custom input data. - **debug_test_expression**: Evaluate a template expression against test data. - **debug_test_mapper**: Test an input data mapper configuration. ### Credentials & Triggers - **credential_list**: List available credentials. - **credential_test**: Test a credential's connectivity. - **trigger_list**: List triggers for a flow. - **trigger_get**: Get trigger details. - **trigger_create**: Create a new trigger. - **trigger_update**: Update an existing trigger. - **trigger_delete**: Delete a trigger. ### Node Reference - **node_list_providers**: List all available node providers (core, gmail, slack, etc.). - **node_list_available**: List all available node types with their schemas. ``` -------------------------------- ### Run MCP Server Manually Source: https://flowlib.dev/docs/plugins/mcp Execute the MCP server directly via CLI or using environment variables. ```bash npx flowlib-cli mcp --url http://localhost:3000/flowlib --api-key YOUR_KEY ``` ```bash export FLOWLIB_URL=http://localhost:3000/flowlib export FLOWLIB_API_KEY=YOUR_KEY npx flowlib-cli mcp ``` -------------------------------- ### Configure Webhook trigger Source: https://flowlib.dev/docs/triggers Register the Webhooks plugin and define the base URL in the Flowlib configuration object. ```javascript import { webhooks } from '@flowlib/webhooks'; const config = { // ... triggers: { webhookBaseUrl: 'https://your-app.com/flowlib', }, plugins: [webhooks()], }; ``` -------------------------------- ### POST /node-executions/list Source: https://flowlib.dev/docs/reference/api Lists node executions with support for filtering. ```APIDOC ## POST /node-executions/list ### Description List node executions with filtering. ### Method POST ### Endpoint /node-executions/list ``` -------------------------------- ### POST /credentials/test-request Source: https://flowlib.dev/docs/reference/api Proxies an HTTP request for credential testing, protected against SSRF. ```APIDOC ## POST /credentials/test-request ### Description Proxy HTTP request for credential testing (SSRF-protected). ### Method POST ### Endpoint /credentials/test-request ``` -------------------------------- ### Integrate Flowlib with Next.js Source: https://flowlib.dev/docs/plugins/authentication Use dynamic imports to load the Flowlib component in a Next.js page, ensuring the configuration includes the auth plugin. ```typescript 'use client'; import dynamic from 'next/dynamic'; import '@flowlib/ui/styles'; import config from '../../flowlib.config'; // contains plugins: [auth(...), rbac()] const Flowlib = dynamic(() => import('@flowlib/ui').then((m) => ({ default: m.Flowlib })), { ssr: false, }); export default function FlowlibPage() { return ; } ``` -------------------------------- ### Register a plugin in configuration Source: https://flowlib.dev/docs/plugins/build-your-own Add the plugin instance to the plugins array within the Flowlib router configuration. ```typescript const router = await createFlowlibRouter({ // ... plugins: [myPlugin()], }); ``` -------------------------------- ### Flowlib Plugin Context Source: https://flowlib.dev/docs/reference/plugin-api The context object passed to the plugin's init method, providing access to database, logging, and tool registration. ```typescript interface FlowlibPluginContext { db: DatabaseConnection; dbType: DatabaseType; logger: Logger; registerTool: (def: AgentToolDefinition, executor: AgentToolExecutor) => void; config: FlowlibConfig; } ``` -------------------------------- ### Configure Vercel Cron Source: https://flowlib.dev/docs/installation Define the cron schedule in vercel.json for background maintenance tasks. ```json { "crons": [{ "path": "/api/flowlib/cron", "schedule": "* * * * *" }] } ``` -------------------------------- ### POST /credentials/oauth2/callback Source: https://flowlib.dev/docs/reference/api Handle OAuth2 callback (exchange code for tokens). ```APIDOC ## POST /credentials/oauth2/callback ### Description Handle OAuth2 callback (exchange code for tokens). ### Method POST ### Endpoint /credentials/oauth2/callback ``` -------------------------------- ### Mount Flowlib Editor in React Source: https://flowlib.dev/docs/installation Mount the Flowlib component in a standard React application. ```tsx import { Flowlib } from '@flowlib/ui'; import '@flowlib/ui/styles'; import { flowlibConfig } from '../flowlib.config'; function App() { return ; } ``` -------------------------------- ### Configure Webhooks Plugin Source: https://flowlib.dev/docs/plugins/webhooks Register the webhooks plugin in your flowlib configuration file. ```typescript import { webhooks } from '@flowlib/webhooks'; export const flowlibConfig = defineConfig({ // ... plugins: [ webhooks({ webhookBaseUrl: 'https://api.myapp.com/flowlib', }), ], }); ``` -------------------------------- ### Configure RBAC Plugin Source: https://flowlib.dev/docs/plugins/access-control Register the RBAC plugin in the flowlib configuration file after the auth plugin. ```typescript import { auth } from '@flowlib/user-auth'; import { rbac } from '@flowlib/rbac'; export const flowlibConfig = defineConfig({ // ... plugins: [ auth({ /* ... */ }), rbac(), ], }); ``` -------------------------------- ### Generate Schemas Source: https://flowlib.dev/docs/reference/cli Generates Drizzle schema files based on core and plugin configurations. ```bash npx flowlib-cli generate ``` -------------------------------- ### generate Source: https://flowlib.dev/docs/reference/cli Generates Drizzle schema files from core and plugin schemas. ```APIDOC ## CLI Command: generate ### Description Reads flowlib.config.ts, discovers plugins, merges schemas, and generates dialect-specific Drizzle files. ### Usage `npx flowlib-cli generate [options]` ### Options - **--config** (string) - Optional - Path to config file. - **--dialects** (string) - Optional - Comma-separated dialects (sqlite, postgresql, mysql). - **--out-dir** (string) - Optional - Output directory for generated files. - **--adapter** (string) - Optional - Schema adapter (drizzle or prisma). - **--schema-only** (boolean) - Optional - Generate schema files without migration files. - **-y, --yes** (boolean) - Optional - Skip confirmation prompts. ``` -------------------------------- ### Declare database tables in plugin schema Source: https://flowlib.dev/docs/plugins/build-your-own Define tables in an abstract format that the CLI uses to generate Drizzle schema files. ```typescript export function myPlugin(): FlowlibPlugin { return { id: 'my-plugin', schema: { my_plugin_logs: { fields: { id: { type: 'string', primaryKey: true }, flowRunId: { type: 'string', references: { table: 'flow_runs', field: 'id' } }, message: { type: 'string', required: true }, createdAt: { type: 'string', required: true }, }, }, }, requiredTables: ['my_plugin_logs'], }; } ```