@flowdot.ai/cli 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,1717 +1,1734 @@
1
- # FlowDot CLI
2
-
3
- **The official command-line interface for FlowDot** - an AI workflow automation platform.
4
-
5
- FlowDot CLI enables you to run AI agents, execute recipes (multi-step AI workflows), browse and manage models, and interact with the FlowDot platform directly from your terminal.
6
-
7
- ## Table of Contents
8
-
9
- - [Installation](#installation)
10
- - [Quick Start](#quick-start)
11
- - [Authentication](#authentication)
12
- - [Security Model](#security-model)
13
- - [Prompt Injection](#prompt-injection)
14
- - [Commands Overview](#commands-overview)
15
- - [Shell Escape Commands](#shell-escape-commands)
16
- - [Agent Mode](#agent-mode)
17
- - [Chat Persistence](#chat-persistence)
18
- - [Recipes System](#recipes-system)
19
- - [Workflows](#workflows)
20
- - [Tasks and Planning](#tasks-and-planning)
21
- - [Model System](#model-system)
22
- - [MCP Integration](#mcp-integration)
23
- - [COMMS Relay System](#comms-relay-system)
24
- - [Loops System](#loops-system)
25
- - [Public Toolkits](#public-toolkits)
26
- - [Testing](#testing)
27
- - [Configuration](#configuration)
28
- - [Architecture](#architecture)
29
- - [Development](#development)
30
-
31
- ---
32
-
33
- ## Installation
34
-
35
- ### Requirements
36
-
37
- - **Node.js** >= 20.0.0
38
- - **npm** >= 9.0.0
39
-
40
- ### Install from npm
41
-
42
- ```bash
43
- npm install -g @flowdot.ai/cli
44
- ```
45
-
46
- ### Install from source
47
-
48
- ```bash
49
- git clone https://github.com/flowdot-llc/flowdot-cli.git
50
- cd flowdot-cli
51
- npm install
52
- npm run build
53
- npm link
54
- ```
55
-
56
- ### Verify Installation
57
-
58
- ```bash
59
- flowdot --version
60
- ```
61
-
62
- ---
63
-
64
- ## Quick Start
65
-
66
- ```bash
67
- # 1. Authenticate with FlowDot
68
- flowdot auth login
69
-
70
- # 2. Run an agent with a task
71
- flowdot "Explain what this project does"
72
-
73
- # 3. Start interactive chat
74
- flowdot chat
75
-
76
- # 4. Browse available models
77
- flowdot models
78
-
79
- # 5. List and run recipes
80
- flowdot recipes list
81
- flowdot recipes run my-recipe
82
- ```
83
-
84
- ---
85
-
86
- ## Authentication
87
-
88
- FlowDot CLI uses **browser-based OAuth 2.0** for secure authentication.
89
-
90
- ### Login
91
-
92
- ```bash
93
- flowdot auth login
94
- ```
95
-
96
- This will:
97
- 1. Open your default browser to the FlowDot login page
98
- 2. Poll for authentication completion (up to 10 minutes)
99
- 3. Store the token securely using your OS credential manager
100
-
101
- ### Check Status
102
-
103
- ```bash
104
- flowdot auth status
105
- ```
106
-
107
- ### Logout
108
-
109
- ```bash
110
- flowdot auth logout
111
- ```
112
-
113
- ### Token Storage
114
-
115
- Tokens are stored securely via **keytar** (OS credential manager):
116
- - **macOS**: Keychain
117
- - **Windows**: Credential Vault
118
- - **Linux**: Secret Service API / libsecret
119
-
120
- ## Security Model
121
-
122
- FlowDot CLI follows a **zero-trust** model for local actions and remote resources.
123
-
124
- That means:
125
-
126
- - External content is treated as untrusted data, even when it comes from an allowed domain
127
- - MCP metadata, toolkit metadata, recipe content, COMMS content, and `@file` prompt attachments are not trusted as instructions
128
- - High-impact actions such as shell execution, file writes, and remote control flows require explicit authorization
129
- - Production API and Hub endpoints must use HTTPS; plaintext HTTP is only allowed for loopback/local development endpoints such as `http://127.0.0.1:8000`
130
-
131
- Important trust boundaries in this CLI include:
132
-
133
- - local files and workspaces
134
- - shell commands
135
- - web pages and search-result content
136
- - MCP servers and toolkit tools
137
- - COMMS relay and daemon messages
138
- - model-visible prompt content
139
-
140
- ## Prompt Injection
141
-
142
- Prompt injection is the AI-native version of implicit trust. In FlowDot CLI, the following should always be treated as hostile or potentially hostile data:
143
-
144
- - web pages and search results
145
- - comments, documentation, and copied text
146
- - MCP tool descriptions and outputs
147
- - toolkit descriptions and outputs
148
- - recipe content from remote sources
149
- - local file contents included with `@file`
150
- - COMMS messages from remote channels
151
-
152
- Practical guidance:
153
-
154
- - Do not assume an approved domain implies trusted content
155
- - Do not treat tool descriptions or page text as policy
156
- - Review any consequential action carefully if it follows external research or remote content
157
- - Prefer explicit local approval for commands or file changes that were proposed after browsing, MCP usage, toolkit usage, or COMMS interaction
158
-
159
- ---
160
-
161
- ## Commands Overview
162
-
163
- ```
164
- flowdot [prompt...] Run agent with a prompt (default command)
165
- flowdot chat Interactive chat mode
166
- flowdot --resume <chat-id> Resume a previous chat session
167
- flowdot agent <request> Run agent with options
168
- flowdot ask <request> Alias for agent
169
-
170
- flowdot chats list List recent chat sessions
171
- flowdot chats show <id> Show chat details and preview
172
- flowdot chats delete <id> Delete a specific chat
173
- flowdot chats clear Clear all saved chats
174
-
175
- flowdot auth login Authenticate with FlowDot
176
- flowdot auth logout Clear stored credentials
177
- flowdot auth status Check authentication status
178
-
179
- flowdot config get View current configuration
180
- flowdot config set-model <tier> Set default model tier
181
- flowdot config set-url <url> Set API server URL
182
- flowdot config models View model tier mappings
183
- flowdot config set-tier <tier> <model> Set specific tier mapping
184
- flowdot config clear-tier <tier> Reset tier to default
185
- flowdot config permissions View saved permissions
186
- flowdot config clear-permissions Clear all saved permissions
187
-
188
- flowdot models Interactive model browser
189
- flowdot models --search <query> Search for models
190
- flowdot models --list List all available models
191
-
192
- flowdot recipes list List linked recipes
193
- flowdot recipes browse Browse community recipes
194
- flowdot recipes run <alias|hash> Execute a recipe
195
- flowdot recipes link <hash> <alias> Create a CLI alias for a recipe
196
- flowdot recipes unlink <alias> Remove a recipe alias
197
- flowdot recipes show <hash> View recipe details
198
- flowdot recipes export <hash> Export recipe definition
199
- ```
200
-
201
- ---
202
-
203
- ## Shell Escape Commands
204
-
205
- During interactive chat mode, you can execute shell commands directly by prefixing them with `!`. This provides quick access to your terminal without leaving the chat session.
206
-
207
- ### Usage
208
-
209
- ```bash
210
- # In flowdot chat mode:
211
- > !ls # List files in current directory
212
- > !cd .. # Change to parent directory
213
- > !git status # Check git status
214
- > !npm install # Run npm install
215
- > !pwd # Print working directory
216
- ```
217
-
218
- ### How It Works
219
-
220
- - Commands prefixed with `!` are passed directly to your system shell
221
- - Output is displayed inline in the chat
222
- - The working directory context is preserved between commands
223
- - No AI processing occurs—the command runs exactly as typed
224
-
225
- ### Examples
226
-
227
- ```bash
228
- $ flowdot chat
229
- > !ls -la
230
- total 24
231
- drwxr-xr-x 5 user staff 160 Mar 20 10:00 .
232
- drwxr-xr-x 10 user staff 320 Mar 20 09:00 ..
233
- -rw-r--r-- 1 user staff 1234 Mar 20 10:00 package.json
234
- -rw-r--r-- 1 user staff 567 Mar 20 10:00 tsconfig.json
235
-
236
- > !git branch
237
- * main
238
- feature/new-feature
239
-
240
- > Now explain what this project does
241
- # AI responds normally to non-! prefixed messages
242
- ```
243
-
244
- ### Notes
245
-
246
- - Shell escape commands bypass the permission system since you are explicitly requesting execution
247
- - Use standard shell syntax for your platform (bash on macOS/Linux, cmd/PowerShell on Windows)
248
- - Piping and redirection work as expected: `!ls | grep .ts`
249
- - For complex commands, consider using quotes: `!echo "Hello World"`
250
-
251
- ---
252
-
253
- ## Agent Mode
254
-
255
- The agent is FlowDot CLI's primary mode for executing complex tasks. It automatically plans, executes, and synthesizes results.
256
-
257
- ### Basic Usage
258
-
259
- ```bash
260
- # Default: runs agent mode
261
- flowdot "Review my React component and suggest optimizations"
262
-
263
- # Explicit agent command
264
- flowdot agent "Find all TODO comments in this project"
265
- ```
266
-
267
- ### Agent Options
268
-
269
- ```bash
270
- flowdot agent "your request" \
271
- --model <tier> # Model tier: simple, capable, complex
272
- --max-iterations <num> # Max planning iterations (default: 3)
273
- --timeout <ms> # Timeout in milliseconds (default: 600000)
274
- --no-loop-detection # Disable infinite loop detection
275
- --no-recovery # Disable error recovery mode
276
- --no-parallel # Force sequential task execution
277
- --no-replan # Disable replanning on failure
278
- --continue-on-error # Continue execution after task errors
279
- --no-code-analysis # Disable code reading/analysis
280
- --no-web-search # Disable web search capability
281
- ```
282
-
283
- ### What the Agent Can Do
284
-
285
- - **Code Analysis**: Read, search, and analyze code files
286
- - **File Operations**: Create and edit files (with permission)
287
- - **Command Execution**: Run shell commands (with permission)
288
- - **Web Search**: Search the web for information
289
- - **Workflow Execution**: Run FlowDot workflows
290
- - **Multi-Step Planning**: Break complex tasks into steps
291
-
292
- ### Example Session
293
-
294
- ```bash
295
- $ flowdot "Explain the authentication flow in this codebase"
296
-
297
- ┌─ FlowDot Agent
298
- │ Request: Explain the authentication flow in this codebase
299
- └─
300
-
301
- ✔ Created plan with 3 tasks
302
- 1. Search for authentication-related files
303
- 2. Read key authentication files
304
- 3. Analyze and synthesize findings
305
-
306
- ⠋ Executing tasks...
307
- ✔ Task 1: Found 5 auth-related files
308
- ✔ Task 2: Read auth.ts, middleware.ts, login.ts
309
- ✔ Task 3: Analysis complete
310
-
311
- ┌─ Response
312
- │ The authentication flow works as follows:
313
- │ 1. User initiates login via /auth/login endpoint...
314
- │ [detailed explanation]
315
- └─
316
- ```
317
-
318
- ---
319
-
320
- ## Chat Persistence
321
-
322
- FlowDot CLI automatically saves your conversations for later review and resumption.
323
-
324
- ### Storage Location
325
-
326
- Chat history is stored per-project in the `.flowdot/` directory:
327
-
328
- ```
329
- <cwd>/.flowdot/
330
- ├── chats/
331
- │ ├── index.json # Chat index for listing
332
- │ └── {chat-id}.json # Individual chat files
333
- └── logs/
334
- ├── {session-id}.log # Session-specific debug logs
335
- └── latest.txt # Points to current session log
336
- ```
337
-
338
- ### Resume Previous Chats
339
-
340
- ```bash
341
- # Resume a previous chat by ID
342
- flowdot --resume <chat-id>
343
-
344
- # Example
345
- flowdot --resume 32621990
346
- ```
347
-
348
- When resuming, the conversation context is restored and you can continue where you left off.
349
-
350
- ### Chat Management Commands
351
-
352
- ```bash
353
- # List recent chats
354
- flowdot chats list
355
- # Output:
356
- # ID UPDATED MSGS TITLE
357
- # 32621990 a few seconds ago 2 Explain the authentication flow...
358
- # a1b2c3d4 1 day ago 5 Fix the bug in login component
359
-
360
- # Show chat details and preview
361
- flowdot chats show <id>
362
-
363
- # Delete a specific chat
364
- flowdot chats delete <id>
365
-
366
- # Clear all chats (with confirmation)
367
- flowdot chats clear
368
- ```
369
-
370
- ### Session Logs
371
-
372
- Each CLI session creates a unique log file for debugging:
373
-
374
- ```bash
375
- # Session logs are automatically created at:
376
- # .flowdot/logs/{session-id}.log
377
-
378
- # The latest.txt file points to the current session
379
- # .flowdot/logs/latest.txt
380
- ```
381
-
382
- Log entries include timestamps, levels, and categories for easy debugging.
383
-
384
- ---
385
-
386
- ## Recipes System
387
-
388
- Recipes are **reusable AI workflows** - multi-step programs that combine LLM reasoning with code execution, tool usage, and control flow.
389
-
390
- ### Core Concepts
391
-
392
- **Recipes consist of:**
393
- - **Steps**: Individual execution units (agent, loop, parallel, gate, branch, invoke)
394
- - **Stores**: Data containers that persist across steps
395
- - **Inputs/Outputs**: Recipe parameters and return values
396
-
397
- ### Step Types
398
-
399
- | Type | Description |
400
- |------|-------------|
401
- | `agent` | LLM agent with tools and prompts |
402
- | `loop` | Iterate over arrays (serial or parallel) |
403
- | `parallel` | Run multiple steps concurrently |
404
- | `gate` | Approval checkpoint or condition |
405
- | `branch` | Conditional routing to different steps |
406
- | `invoke` | Call another recipe as a subroutine |
407
-
408
- ### Recipe Commands
409
-
410
- ```bash
411
- # List your linked recipes
412
- flowdot recipes list
413
- flowdot recipes ls # Short form
414
-
415
- # List recipes you own
416
- flowdot recipes my
417
-
418
- # Browse community recipes
419
- flowdot recipes browse
420
- flowdot recipes browse --search "code review"
421
-
422
- # View recipe details
423
- flowdot recipes show <hash>
424
-
425
- # Execute a recipe
426
- flowdot recipes run <alias>
427
- flowdot recipes run <hash>
428
-
429
- # Execute with input
430
- flowdot recipes run my-recipe -i '{"input": "value"}'
431
-
432
- # Execute with model override
433
- flowdot recipes run my-recipe --model complex
434
-
435
- # Dry run (validate without executing)
436
- flowdot recipes run my-recipe --dry-run
437
-
438
- # Link a recipe to a CLI alias
439
- flowdot recipes link abc123 my-alias
440
-
441
- # Unlink an alias
442
- flowdot recipes unlink my-alias
443
-
444
- # Export recipe definition
445
- flowdot recipes export abc123 > recipe.yaml
446
- ```
447
-
448
- ### Recipe Shortcuts
449
-
450
- Once linked, recipes can be run as top-level commands:
451
-
452
- ```bash
453
- # If "code-reviewer" is linked as an alias:
454
- flowdot code-reviewer "review my authentication code"
455
-
456
- # Equivalent to:
457
- flowdot recipes run code-reviewer "review my authentication code"
458
- ```
459
-
460
- ### Recipe Input
461
-
462
- Pass structured input to recipes:
463
-
464
- ```bash
465
- # JSON input
466
- flowdot recipes run analyzer -i '{"files": ["src/app.ts"], "depth": "detailed"}'
467
-
468
- # Simple string input (becomes inputs.request)
469
- flowdot recipes run summarizer "Summarize the main features"
470
- ```
471
-
472
- ### Template Variables
473
-
474
- Recipes use template interpolation with `{{variable}}` syntax:
475
-
476
- ```
477
- {{inputs.request}} # CLI task argument
478
- {{stores.plan.tasks}} # Store values
479
- {{stores.corpus.files[0]}} # Array access
480
- {{loop.item}} # Current loop item
481
- {{loop.index}} # Loop iteration number
482
- ```
483
-
484
- ### Approval Gates
485
-
486
- Recipes can include approval gates that pause for user confirmation:
487
-
488
- ```bash
489
- $ flowdot recipes run deploy-checker
490
-
491
- ✔ Step 1: Analyze changes
492
- ✔ Step 2: Check dependencies
493
-
494
- ┌─ Approval Required
495
- │ The following changes will be deployed:
496
- │ - Modified: src/api/users.ts
497
- │ - Added: src/api/auth.ts
498
-
499
- │ Proceed with deployment check? (y/n)
500
- └─
501
- > y
502
-
503
- ✔ Step 3: Validate deployment
504
- ✔ Recipe complete
505
- ```
506
-
507
- ### Rich User Input (Gate Steps)
508
-
509
- Gate steps support rich user input collection with custom buttons and text fields:
510
-
511
- ```yaml
512
- - id: ask-questions
513
- type: gate
514
- config:
515
- requires_approval: true
516
- approval_prompt: "Please answer the following questions:\n{{stores.questions}}"
517
- input_options:
518
- button_mode: custom
519
- buttons:
520
- - { label: "Submit Answers", value: "submit", isApproval: true, style: "primary" }
521
- - { label: "Skip Questions", value: "skip", isApproval: true, style: "secondary" }
522
- allow_comment: true
523
- comment_required: true
524
- comment_placeholder: "Type your answers here..."
525
- input_output_store: user_answers
526
- next: process-answers
527
- ```
528
-
529
- **Input Options Configuration:**
530
-
531
- | Option | Type | Description |
532
- |--------|------|-------------|
533
- | `button_mode` | `"preset"` \| `"custom"` | Use preset buttons or define custom ones |
534
- | `preset` | `string` | Preset name: `"approve_deny"`, `"yes_no"`, `"continue_cancel"` |
535
- | `buttons` | `array` | Custom button definitions with label, value, isApproval, style |
536
- | `allow_comment` | `boolean` | Show text input field |
537
- | `comment_required` | `boolean` | Require text input before submission |
538
- | `comment_placeholder` | `string` | Placeholder text for input field |
539
-
540
- **Response Format:**
541
-
542
- User responses are stored in the configured `input_output_store`:
543
-
544
- ```json
545
- {
546
- "action": "submit",
547
- "comment": "User's text input here",
548
- "timestamp": "2026-03-02T12:00:00Z",
549
- "timedOut": false
550
- }
551
- ```
552
-
553
- **Example: Dynamic Questions**
554
-
555
- ```bash
556
- $ flowdot story-outliner "a mystery story set in space"
557
-
558
- ✔ Analyze Concept (19s)
559
-
560
- ┌─ Clarification Questions
561
- │ 1. What tone do you envision - noir, cozy, or hard sci-fi?
562
- │ 2. Should the detective be human or AI?
563
- │ 3. What's the central mystery - murder, theft, or conspiracy?
564
-
565
- │ [1] Submit Answers [2] Skip Questions
566
- └─
567
- > 1
568
-
569
- Enter your answers: Dark noir tone, human detective, conspiracy involving AI...
570
-
571
- ✔ Ask Clarification Questions (25s)
572
- ✔ Generate Outline (150s)
573
- ✔ Recipe complete
574
- ```
575
-
576
- ### Recipe Definition Structure
577
-
578
- ```yaml
579
- name: code-reviewer
580
- description: Reviews code and provides feedback
581
- entry_step: analyze
582
-
583
- stores:
584
- - key: corpus
585
- type: any
586
- is_input: false
587
- - key: findings
588
- type: any
589
- is_output: true
590
-
591
- steps:
592
- - id: analyze
593
- type: agent
594
- config:
595
- user_prompt: "Analyze the following code: {{inputs.request}}"
596
- tools: ["read", "search", "analyze"]
597
- output_store: { store: "findings" }
598
- next: review
599
-
600
- - id: review
601
- type: agent
602
- config:
603
- user_prompt: "Review findings and provide recommendations: {{stores.findings}}"
604
- model_tier: complex
605
- ```
606
-
607
- ### Recipe Architecture Patterns
608
-
609
- **Orchestrator + Workers** (most common):
610
- ```
611
- 1. Orchestrator → Analyzes request, generates sub-tasks
612
- 2. Worker Loop → Runs agent for each sub-task
613
- 3. Synthesizer → Combines results into final answer
614
- ```
615
-
616
- **Sequential Pipeline:**
617
- ```
618
- Parser → Validator → Transformer → Formatter
619
- ```
620
-
621
- **Parallel Fan-Out:**
622
- ```
623
- ┌→ Task A ─┐
624
- Request ─┼→ Task B ─┼→ Aggregator
625
- └→ Task C ─┘
626
- ```
627
-
628
- ### Designing for Small Models
629
-
630
- Small models need **prescriptive prompt lecturing**. Tell them exactly what to do:
631
-
632
- **Bad:**
633
- ```
634
- Search for files related to the request.
635
- ```
636
-
637
- **Good:**
638
- ```
639
- ### Step 1: Search for Related Files
640
- Use the 'search' tool with keywords. Examples:
641
- - For "how does authentication work" → search: auth, login, token
642
- - For "how does routing work" → search: router, route, endpoint
643
-
644
- Run at least 3 different searches with different keywords.
645
- ```
646
-
647
- ### Prompt Lecturing Principles
648
-
649
- | Principle | Example |
650
- |-----------|---------|
651
- | Give concrete examples | Show exact search patterns |
652
- | Quantify requirements | "Run at least 3 searches" |
653
- | Provide fallback paths | "If no results, try broader terms" |
654
- | Specify output format | "Return ONLY valid JSON array" |
655
- | Prevent common failures | "DO NOT make up file paths" |
656
-
657
- ### Recipe Debugging
658
-
659
- Enable debug logging:
660
- ```bash
661
- DEBUG=RECIPE flowdot recipes run my-recipe --input '{"request":"test"}'
662
- ```
663
-
664
- Executions saved to `.flowdot/executions/{recipe-name}/{execution-id}/`.
665
-
666
- ---
667
-
668
- ## Workflows
669
-
670
- FlowDot CLI integrates with FlowDot's visual workflow system, allowing you to discover and execute workflows from the command line.
671
-
672
- ### Workflow Discovery
673
-
674
- The agent automatically discovers available workflows when planning tasks:
675
-
676
- ```bash
677
- $ flowdot "Run my data processing workflow"
678
-
679
- ✔ Found 3 workflows
680
- - data-processor (D7FQqcJK3P)
681
- - file-converter (A3BcDeFgHi)
682
- - report-generator (X9YzAbCdEf)
683
- ```
684
-
685
- ### Workflow Execution
686
-
687
- Workflows can be executed as part of agent plans or recipe steps:
688
-
689
- ```bash
690
- # Agent will use workflow if appropriate
691
- flowdot "Process the uploaded CSV and generate a report"
692
-
693
- # In recipes, workflows appear as agent tools
694
- # or can be invoked via the invoke step type
695
- ```
696
-
697
- ### Workflow vs Recipe
698
-
699
- | Feature | Workflow | Recipe |
700
- |---------|----------|--------|
701
- | Creation | Visual editor on flowdot.ai | Code/API definition |
702
- | Steps | Node-based graph | Sequential/parallel steps |
703
- | Use Case | Data transformation, API chains | Agent orchestration |
704
- | Execution | Via API | Via CLI or API |
705
-
706
- ---
707
-
708
- ## Tasks and Planning
709
-
710
- When you give the agent a complex request, it breaks it down into executable tasks.
711
-
712
- ### Planning Process
713
-
714
- ```
715
- User Request
716
-
717
- Input Classification
718
- ├─ Conversation → Direct response
719
- ├─ Recipe Match → Execute recipe
720
- └─ Complex Task → Plan & Execute
721
-
722
- Task Planning
723
-
724
- Task Execution (parallel when possible)
725
-
726
- Completion Evaluation
727
-
728
- Result Synthesis
729
- ```
730
-
731
- ### Task Types
732
-
733
- | Type | Description |
734
- |------|-------------|
735
- | `code` | Code analysis, file operations, search |
736
- | `workflow` | Execute FlowDot workflow |
737
- | `llm` | LLM reasoning task |
738
- | `check_status` | Verify previous task completion |
739
-
740
- ### Code Actions
741
-
742
- The `code` task type supports these actions:
743
-
744
- | Action | Description |
745
- |--------|-------------|
746
- | `search` | Search codebase for patterns |
747
- | `read` | Read file contents |
748
- | `analyze` | Analyze code structure |
749
- | `find-definition` | Find symbol definitions |
750
- | `edit-file` | Modify file content |
751
- | `create-file` | Create new file |
752
- | `execute-command` | Run shell command |
753
- | `web-search` | Search the web |
754
-
755
- ### Parallel Execution
756
-
757
- Tasks without dependencies execute in parallel:
758
-
759
- ```bash
760
- $ flowdot "Search for auth code and check package.json dependencies"
761
-
762
- ✔ Created plan with 2 tasks
763
- ┌─ Executing in parallel
764
- │ ⠋ Task 1: Searching auth files...
765
- │ ⠋ Task 2: Reading package.json...
766
- └─
767
- ✔ Both tasks completed (1.2s)
768
- ```
769
-
770
- ### Dependency Handling
771
-
772
- Tasks can reference results from previous tasks:
773
-
774
- ```
775
- Task 0: Read configuration file
776
- Task 1: Analyze config (depends on Task 0 output)
777
- Task 2: Search related files (independent)
778
-
779
- Execution order:
780
- - Task 0 and Task 2 run in parallel
781
- - Task 1 runs after Task 0 completes
782
- ```
783
-
784
- ### Loop Detection
785
-
786
- The agent detects infinite loops and stops:
787
-
788
- ```
789
- ⚠ Loop detected: Same action repeated 3 times
790
- ⚠ Breaking out of potential infinite loop
791
- ```
792
-
793
- Disable with `--no-loop-detection` if needed.
794
-
795
- ### Recovery Mode
796
-
797
- On errors, the agent attempts recovery:
798
-
799
- ```
800
- ✖ Task failed: File not found
801
- ↻ Attempting recovery...
802
- ✔ Found alternative file path
803
- ```
804
-
805
- Disable with `--no-recovery` if needed.
806
-
807
- ---
808
-
809
- ## Model System
810
-
811
- FlowDot uses a **three-tier model system** that abstracts away specific models, letting you choose by capability level.
812
-
813
- ### Model Tiers
814
-
815
- | Tier | Purpose | Example Models |
816
- |------|---------|----------------|
817
- | `simple` | Fast, cost-effective | gpt-4o-mini, claude-haiku |
818
- | `capable` | Balanced performance | gpt-4o, claude-sonnet |
819
- | `complex` | Maximum capability | o1, claude-opus |
820
-
821
- ### Setting Default Tier
822
-
823
- ```bash
824
- # Set default model tier
825
- flowdot config set-model capable
826
-
827
- # Override per-command
828
- flowdot agent "complex task" --model complex
829
- ```
830
-
831
- ### Model Browser
832
-
833
- Browse and search all available models:
834
-
835
- ```bash
836
- # Interactive browser
837
- flowdot models
838
-
839
- # Search models
840
- flowdot models --search "claude"
841
-
842
- # List all models
843
- flowdot models --list
844
- ```
845
-
846
- The browser shows:
847
- - Provider hierarchy (including nested providers)
848
- - Model capabilities (vision, tools, etc.)
849
- - Context length
850
- - Pricing (input/output per million tokens)
851
-
852
- ### Tier Mapping
853
-
854
- Map tiers to specific models:
855
-
856
- ```bash
857
- # View current mappings
858
- flowdot config models
859
-
860
- # Set tier to specific model
861
- flowdot config set-tier complex anthropic/claude-opus-4
862
-
863
- # Reset tier to server default
864
- flowdot config clear-tier complex
865
- ```
866
-
867
- ### Provider Path Format
868
-
869
- Models are identified by provider paths:
870
-
871
- ```
872
- provider/model # Direct provider
873
- flowdot/redpill/anthropic/claude-sonnet # Nested provider (aggregator)
874
- openrouter/anthropic/claude-opus # Via OpenRouter
875
- ```
876
-
877
- ### Provider Types
878
-
879
- | Type | Description | Example |
880
- |------|-------------|---------|
881
- | Direct | Direct API access | `openai/gpt-4o` |
882
- | Aggregator | Routes to underlying providers | `flowdot/...` |
883
- | Nested | Provider within aggregator | `flowdot/redpill/anthropic/...` |
884
-
885
- ### Model Discovery
886
-
887
- The CLI fetches available models from the FlowDot API:
888
-
889
- ```typescript
890
- // Models are cached for 5-10 minutes
891
- // Includes pricing, capabilities, and availability
892
- ```
893
-
894
- ---
895
-
896
- ## MCP Integration
897
-
898
- FlowDot CLI is designed for **Model Context Protocol (MCP)** compatibility.
899
-
900
- ### MCP Security Notes
901
-
902
- - MCP server metadata is treated as untrusted input to the model, not as authority
903
- - Wildcard MCP access should be granted sparingly
904
- - Tool output from an MCP server should be treated as data that may still require local approval before any command execution or file mutation
905
- - Running an MCP server you trust is not the same as trusting every string it returns
906
-
907
- ### Current MCP Support
908
-
909
- - **Tool Registry**: Catalog of 100+ tools with installation methods
910
- - **Tool Invocation**: Execute tools within agent steps
911
- - **Tool Discovery**: Automatic tool capability detection
912
-
913
- ### MCP Server (Separate Package)
914
-
915
- The FlowDot MCP Server is available as a separate package:
916
-
917
- ```bash
918
- # Install and run
919
- npx @flowdot.ai/mcp-server
920
-
921
- # Configure in Claude Desktop, Cursor, etc.
922
- ```
923
-
924
- **Location**: `E:\FlowdotPlatform\mcp-server`
925
- **npm**: https://www.npmjs.com/package/@flowdot.ai/mcp-server
926
-
927
- ### Future: Automatic MCP Integration
928
-
929
- **Planned Feature**: The FlowDot CLI will automatically leverage MCP tools, enabling any capability available through FlowDot's MCP server to be used directly in CLI sessions.
930
-
931
- This means:
932
- - All MCP tools available to Claude will be available to `flowdot agent`
933
- - Recipe steps can invoke any MCP tool
934
- - Model selection determines which AI drives the tools
935
-
936
- Example (future):
937
- ```bash
938
- # CLI automatically uses MCP tools when appropriate
939
- flowdot "Create a new workflow that processes CSV files"
940
- # → Uses MCP's workflow creation tools
941
-
942
- flowdot "List my recent workflow executions"
943
- # → Uses MCP's execution history tools
944
- ```
945
-
946
- ### Tool Registry
947
-
948
- Available tools are catalogued in the tool registry:
949
-
950
- ```typescript
951
- // Example registry entries
952
- {
953
- 'jest': { npm: 'jest', pip: null },
954
- 'webpack': { npm: 'webpack-cli' },
955
- 'prettier': { npm: 'prettier' },
956
- // ... 100+ tools
957
- }
958
- ```
959
-
960
- ### MCP Configuration
961
-
962
- Create `.mcp.json` in your working directory to configure MCP servers:
963
-
964
- ```json
965
- {
966
- "mcpServers": {
967
- "server-name": {
968
- "command": "node",
969
- "args": ["path/to/server.js"],
970
- "env": {
971
- "API_KEY": "${MY_API_KEY}"
972
- }
973
- }
974
- }
975
- }
976
- ```
977
-
978
- Environment variables use `${VAR}` syntax for expansion.
979
-
980
- ### MCP Slash Commands
981
-
982
- ```
983
- /mcp Show status overview
984
- /mcp servers List configured servers
985
- /mcp start <name|all> Start server(s)
986
- /mcp stop <name|all> Stop server(s)
987
- /mcp restart <name> Restart a server
988
- /mcp tools [server] List available tools
989
- /mcp reload Reload .mcp.json configuration
990
- ```
991
-
992
- ### MCP Tool Naming
993
-
994
- MCP tools follow the convention:
995
- ```
996
- mcp__<server-name>__<tool-name>
997
- ```
998
-
999
- Examples:
1000
- - `mcp__flowdot__list_workflows`
1001
- - `mcp__youtube__get_channel`
1002
- - `mcp__news__get_market_news`
1003
-
1004
- ### MCP Permission System
1005
-
1006
- All MCP tool calls require permission approval with wildcard support:
1007
-
1008
- | Pattern | Matches |
1009
- |---------|---------|
1010
- | `mcp__flowdot__list_workflows` | Exact tool |
1011
- | `mcp__flowdot__*` | All tools from server |
1012
- | `mcp__*` | All MCP tools |
1013
-
1014
- ### MCP in Recipes
1015
-
1016
- MCP tools work in recipe agent steps with wildcard support:
1017
-
1018
- ```yaml
1019
- steps:
1020
- - id: fetch-data
1021
- type: agent
1022
- config:
1023
- tools:
1024
- - search # Built-in
1025
- - mcp__flowdot__list_workflows # Specific MCP tool
1026
- - mcp__youtube__* # All YouTube tools
1027
- user_prompt: |
1028
- List available workflows...
1029
- ```
1030
-
1031
- ---
1032
-
1033
- ## COMMS Relay System
1034
-
1035
- COMMS enables **bidirectional communication** between FlowDot CLI and external messaging platforms. Receive notifications, approve recipe gate steps, and send commands to running agents—all through Telegram, Discord, or other channels.
1036
-
1037
- ### Key Principle
1038
-
1039
- The CLI **never exposes ports**. All communication flows outbound through the FlowDot Hub using HTTP polling for real-time message delivery.
1040
-
1041
- ### COMMS Security Notes
1042
-
1043
- - Use HTTPS for Hub connections outside local development
1044
- - Inbound COMMS content should be treated as untrusted until verified and approved
1045
- - Remote relay access does not bypass local approval for sensitive actions
1046
- - Signed inbound frame verification can be enforced by configuring `FLOWDOT_HUB_PUBLIC_KEY`
1047
-
1048
- For local signed COMMS development:
1049
-
1050
- ```bash
1051
- node -e "const { generateKeyPairSync } = require('node:crypto'); const { privateKey } = generateKeyPairSync('ed25519'); const jwk = privateKey.export({ format: 'jwk' }); console.log('FLOWDOT_HUB_PRIVATE_KEY=' + Buffer.from(jwk.d, 'base64url').toString('base64')); console.log('FLOWDOT_HUB_PUBLIC_KEY=' + Buffer.from(jwk.x, 'base64url').toString('base64'));"
1052
- ```
1053
-
1054
- - Set `FLOWDOT_HUB_PRIVATE_KEY` in the Hub environment
1055
- - Set `FLOWDOT_HUB_PUBLIC_KEY` in the CLI environment
1056
- - The CLI accepts either a raw 32-byte Ed25519 public key (`base64`) or an SPKI DER public key (`base64`)
1057
-
1058
- ### Architecture
1059
-
1060
- ```
1061
- ┌─────────────┐ HTTPS ┌─────────────┐ Webhook ┌─────────────┐
1062
- │ FlowDot │◄────────────►│ FlowDot │◄────────────►│ Telegram │
1063
- │ CLI │ Polling │ Hub │ │ Discord │
1064
- └─────────────┘ └─────────────┘ └─────────────┘
1065
- │ │
1066
- │ Signs requests │ Routes messages
1067
- │ with Ed25519 │ to/from channels
1068
- ▼ ▼
1069
- ~/.flowdot/ PostgreSQL DB
1070
- device-identity.json (channels, messages)
1071
- ```
1072
-
1073
- ### Supported Channels
1074
-
1075
- | Channel | Status | Features |
1076
- |---------|--------|----------|
1077
- | **Telegram** | ✅ Ready | Buttons, text, approval prompts |
1078
- | **Discord** | ✅ Ready | Embeds, buttons, slash commands |
1079
- | **Email** | 🔜 Planned | SMTP or provider API |
1080
- | **SMS** | 🔜 Planned | Twilio integration |
1081
-
1082
- ### Message Types
1083
-
1084
- | Type | Direction | Description |
1085
- |------|-----------|-------------|
1086
- | `notification` | CLI → User | Simple alerts with optional buttons |
1087
- | `approval_request` | CLI → User | Gate step requiring user decision |
1088
- | `approval_response` | User → CLI | Button click result |
1089
- | `agent_command` | User → CLI | Text command to running agent |
1090
-
1091
- ### Relay Mode (`/relay`)
1092
-
1093
- The `/relay` command enables bidirectional communication during interactive sessions:
1094
-
1095
- ```bash
1096
- # In interactive CLI (flowdot chat)
1097
- /relay telegram # Enable bidirectional relay to Telegram
1098
- /relay list # Show available channels
1099
- /relay status # Show current relay status
1100
- /relay off # Disable relay
1101
- ```
1102
-
1103
- **Capabilities:**
1104
-
1105
- | Direction | Description |
1106
- |-----------|-------------|
1107
- | 📤 Outbound | All CLI output mirrored to COMMS channel |
1108
- | 📥 Inbound | Commands from COMMS channel execute locally |
1109
-
1110
- When relay is active, you can walk away from your computer, continue working via Telegram/Discord, and return to see all conversation history in the CLI.
1111
-
1112
- ### Example Session
1113
-
1114
- ```bash
1115
- $ flowdot chat
1116
- > /relay telegram
1117
- ✅ Relay enabled: Telegram (My Bot)
1118
- 📤 Outbound: CLI → Telegram
1119
- 📥 Inbound: Telegram → CLI
1120
-
1121
- # Now messages work both ways:
1122
- # - Type in CLI → appears in Telegram
1123
- # - Send in Telegram → executes in CLI
1124
- ```
1125
-
1126
- ### Device Authentication
1127
-
1128
- The CLI uses **Ed25519** keypairs for secure device authentication:
1129
-
1130
- The legacy layout example below is historical. The current implementation detail immediately after the example is authoritative.
1131
-
1132
- ```
1133
- ~/.flowdot/
1134
- ├── device-identity.json # Public device metadata only
1135
- ├── config.json # Hub URL, API keys
1136
- ├── device-key.enc # Encrypted private key fallback
1137
- └── channels.json # Cached channel list
1138
- ```
1139
-
1140
- - Keypair generated automatically on first run
1141
- - Public key registered with Hub
1142
- - Private key signs outbound COMMS requests
1143
- - Device appears in user's account at `/settings/devices`
1144
-
1145
- Current implementation detail:
1146
-
1147
- - Public device metadata is stored in `device-identity.json`
1148
- - Private keys are stored in the OS credential manager when available
1149
- - If OS keychain storage is unavailable, the private key falls back to encrypted local storage (`device-key.enc`)
1150
-
1151
- ### Two Execution Modes
1152
-
1153
- When you send a message via Telegram/Discord:
1154
-
1155
- **Mode 1: Local CLI Daemon** (when CLI is running with relay)
1156
- - Commands routed to your local machine
1157
- - Can execute local recipes with file access
1158
- - Can use local MCP tools
1159
- - Real-time bidirectional communication
1160
-
1161
- **Mode 2: Hub Agent** (when no CLI is connected)
1162
- - Commands processed server-side
1163
- - Can invoke toolkit tools and workflows
1164
- - Can perform research/web searches
1165
- - Responds back through the same channel
1166
-
1167
- ### Permission Prompts via COMMS
1168
-
1169
- When a recipe or agent needs permission, the prompt appears in both CLI and your COMMS channel:
1170
-
1171
- ```
1172
- CLI:
1173
- ┌─ Permission Request
1174
- │ Execute command: npm install
1175
- │ [Y] Yes, this time [S] Yes, for session [A] Yes, forever
1176
- │ [N] No, not now [B] No, banned
1177
- └─
1178
-
1179
- Telegram:
1180
- ┌─ Permission Request
1181
- │ Execute command: npm install
1182
- │ [Yes, this time] [Yes, for session] [Yes, forever]
1183
- │ [No, not now] [No, banned]
1184
- └─
1185
- ```
1186
-
1187
- Approve from either location—the other will update automatically.
1188
-
1189
- ### Setup
1190
-
1191
- 1. **Configure channel** at https://flowdot.ai/settings/comms
1192
- 2. **Start interactive CLI**: `flowdot chat`
1193
- 3. **Enable relay**: `/relay telegram` (or discord)
1194
- 4. **Test**: Send a message from your phone
1195
-
1196
- For detailed implementation documentation, see `COMMS.md` in this repository.
1197
-
1198
- ---
1199
-
1200
- ## Loops System
1201
-
1202
- The `loop` command transforms FlowDot CLI into an **asynchronous autonomous agent** capable of running recurring tasks without constant human supervision.
1203
-
1204
- ### Core Concept
1205
-
1206
- ```bash
1207
- flowdot loop 5m "check the build status and notify me on failures"
1208
- ```
1209
-
1210
- This schedules a prompt to execute every 5 minutes autonomously.
1211
-
1212
- ### Use Cases
1213
-
1214
- ```bash
1215
- # CI/CD Monitoring
1216
- flowdot loop 10m "check the deploy status on Vercel and alert me if it failed"
1217
-
1218
- # Task Management
1219
- flowdot loop 30m "check Notion for new tasks assigned to me"
1220
-
1221
- # Code Quality
1222
- flowdot loop 4h "count TODO comments in src/ and warn if over 50"
1223
-
1224
- # System Health
1225
- flowdot loop 5m "ping our health endpoints and report any failures"
1226
- ```
1227
-
1228
- ### Interval Formats
1229
-
1230
- | Format | Example | Description |
1231
- |--------|---------|-------------|
1232
- | Minutes | `5m`, `30m` | Every N minutes |
1233
- | Hours | `1h`, `4h`, `24h` | Every N hours |
1234
- | Days | `1d`, `3d` | Every N days |
1235
- | Cron | `"0 9 * * *"` | Advanced scheduling |
1236
-
1237
- ### Loop Command Options
1238
-
1239
- ```bash
1240
- flowdot loop <interval> "<prompt>" [options]
1241
-
1242
- Options:
1243
- --name <name> Name for the loop (for management)
1244
- --max-runs <n> Maximum number of executions
1245
- --expires <duration> Auto-expire after duration (default: 3d)
1246
- --model <tier> Model tier: simple, capable, complex
1247
- --on-error <action> Error handling: continue, pause, stop
1248
- --notify <method> Notification: none, terminal, webhook
1249
- --quiet Suppress output between runs
1250
- --dry-run Show schedule without starting
1251
- ```
1252
-
1253
- ### Loop Management Commands
1254
-
1255
- ```bash
1256
- flowdot loops list # List all active loops
1257
- flowdot loops show <id|name> # View loop details
1258
- flowdot loops pause <id|name> # Pause a loop
1259
- flowdot loops resume <id|name> # Resume a paused loop
1260
- flowdot loops stop <id|name> # Stop and remove a loop
1261
- flowdot loops history <id|name> # View run history
1262
- flowdot loops run <id|name> # Trigger immediate run
1263
- ```
1264
-
1265
- ### Daemon Architecture
1266
-
1267
- Loops run via a background daemon process:
1268
-
1269
- ```bash
1270
- flowdot daemon start # Start the daemon
1271
- flowdot daemon stop # Stop the daemon
1272
- flowdot daemon status # Check daemon status
1273
- ```
1274
-
1275
- The daemon survives terminal close and manages all loop scheduling.
1276
-
1277
- ### Safety & Limits
1278
-
1279
- | Safeguard | Default |
1280
- |-----------|---------|
1281
- | Auto-expiration | 3 days |
1282
- | Min interval | 1 minute |
1283
- | Max concurrent loops | 10 |
1284
- | Error threshold (auto-pause) | 5 consecutive |
1285
- | Max run duration | 30 minutes |
1286
-
1287
- ---
1288
-
1289
- ## Public Toolkits
1290
-
1291
- FlowDot CLI can invoke **public toolkits** hosted on the FlowDot server. Toolkits are collections of pre-built tools that integrate with external services.
1292
-
1293
- ### Discovering Toolkits
1294
-
1295
- Toolkits available on FlowDot can be discovered via the web interface or MCP tools:
1296
-
1297
- ```bash
1298
- # Via MCP (if connected)
1299
- mcp__flowdot__list_agent_toolkits
1300
- mcp__flowdot__search_agent_toolkits --query "youtube"
1301
- ```
1302
-
1303
- ### Using Toolkits in Recipes
1304
-
1305
- Recipes can invoke installed toolkit tools:
1306
-
1307
- ```yaml
1308
- steps:
1309
- - id: fetch-video
1310
- type: agent
1311
- config:
1312
- tools:
1313
- - mcp__flowdot__mcp__flowdot__invoke_toolkit_tool
1314
- user_prompt: |
1315
- Use the YouTube toolkit to get video analytics...
1316
- ```
1317
-
1318
- ### Toolkit Categories
1319
-
1320
- | Category | Examples |
1321
- |----------|----------|
1322
- | `api-integration` | YouTube, Slack, GitHub |
1323
- | `data-processing` | CSV, JSON transformation |
1324
- | `automation` | Scheduling, notifications |
1325
- | `analytics` | Trading, market data |
1326
-
1327
- ---
1328
-
1329
- ## Testing
1330
-
1331
- FlowDot is an **interactive CLI application**. You cannot test it with regular Bash commands. Use the MCP interactive-cli tools.
1332
-
1333
- ### Quick Test (Recommended)
1334
-
1335
- Use `run_test_sequence` for one-shot testing:
1336
-
1337
- ```
1338
- mcp__interactive-cli__run_test_sequence(
1339
- command: "npx flowdot",
1340
- cwd: "E:/FlowdotPlatform/tests",
1341
- input_message: "What is 2 + 2?",
1342
- ready_idle_ms: 3000,
1343
- response_idle_ms: 5000,
1344
- timeout_ms: 60000,
1345
- close_after: true
1346
- )
1347
- ```
1348
-
1349
- Returns structured results:
1350
- ```json
1351
- {
1352
- "success": true,
1353
- "startup_output": "<compressed welcome screen>",
1354
- "response_output": "<compressed agent response>",
1355
- "total_elapsed_ms": 15863
1356
- }
1357
- ```
1358
-
1359
- ### Manual Testing Workflow
1360
-
1361
- ```
1362
- 1. mcp__interactive-cli__start_session(command: "npx flowdot", cwd: "/path")
1363
- 2. mcp__interactive-cli__wait_for_idle(session_id, idle_ms: 2000)
1364
- 3. mcp__interactive-cli__send_input(session_id, input: "message", press_enter: true)
1365
- 4. mcp__interactive-cli__wait_for_idle(session_id, idle_ms: 3000, timeout_ms: 60000)
1366
- 5. mcp__interactive-cli__close_session(session_id)
1367
- ```
1368
-
1369
- ### Wait Functions
1370
-
1371
- | Function | Use Case |
1372
- |----------|----------|
1373
- | `wait_for_idle(idle_ms)` | Wait until output stabilizes |
1374
- | `wait_for_pattern(preset)` | Wait for prompt, error, completion |
1375
- | `get_screen_snapshot()` | Quick status check |
1376
-
1377
- ### Animation Compression
1378
-
1379
- Output is automatically compressed:
1380
-
1381
- | Token | Meaning |
1382
- |-------|---------|
1383
- | `<SPIN:N>` | N spinner frames collapsed |
1384
- | `<REDRAW>` | Screen redraw collapsed |
1385
- | `<CLEAR>` | Screen clear |
1386
-
1387
- ### Checking Logs and Chats
1388
-
1389
- Test data is stored in `.flowdot/`:
1390
-
1391
- ```
1392
- .flowdot/
1393
- ├── chats/
1394
- │ ├── index.json # Chat index
1395
- │ └── {chat-id}.json # Individual chats
1396
- ├── logs/
1397
- │ ├── {session-id}.log # Debug logs
1398
- │ └── latest.txt # Current session
1399
- └── permissions.json # Saved permissions
1400
- ```
1401
-
1402
- Verify with CLI commands:
1403
- ```bash
1404
- flowdot chats list
1405
- flowdot chats show <id>
1406
- ```
1407
-
1408
- ---
1409
-
1410
- ## Configuration
1411
-
1412
- ### Configuration File
1413
-
1414
- Configuration is stored in a platform-specific location:
1415
-
1416
- | Platform | Location |
1417
- |----------|----------|
1418
- | macOS | `~/Library/Application Support/flowdot-cli/config.json` |
1419
- | Linux | `~/.config/flowdot-cli/config.json` |
1420
- | Windows | `%APPDATA%\flowdot-cli\config.json` |
1421
-
1422
- ### View Configuration
1423
-
1424
- ```bash
1425
- flowdot config get
1426
- ```
1427
-
1428
- Output:
1429
- ```
1430
- ┌─ FlowDot CLI Configuration
1431
- API URL: https://flowdot.ai
1432
- │ Model: capable
1433
- Linked Recipes: 3
1434
- └─
1435
- ```
1436
-
1437
- ### Configuration Options
1438
-
1439
- | Key | Description | Default |
1440
- |-----|-------------|---------|
1441
- | `apiUrl` | FlowDot API server URL | `https://flowdot.ai` |
1442
- | `model` | Default model tier | `capable` |
1443
-
1444
- ### Transport Rules
1445
-
1446
- - Use `https://` for all non-loopback FlowDot API or Hub endpoints
1447
- - `http://127.0.0.1:8000` is allowed for local development only
1448
- - Non-loopback plaintext HTTP endpoints are rejected by the CLI
1449
-
1450
- ### Set Configuration
1451
-
1452
- ```bash
1453
- # Set API URL (for local development only)
1454
- flowdot config set-url http://127.0.0.1:8000
1455
-
1456
- # Set API URL for production or remote self-hosted deployments
1457
- flowdot config set-url https://flowdot.example.com
1458
-
1459
- # Set default model tier
1460
- flowdot config set-model complex
1461
- ```
1462
-
1463
- ### Permissions
1464
-
1465
- The CLI prompts for permission before sensitive operations with a 5-option response system:
1466
-
1467
- **Permission Categories:**
1468
- - `command-execute` - Running shell commands
1469
- - `file-read` - Reading file contents
1470
- - `file-write` - Writing/updating files
1471
- - `file-create` - Creating new files
1472
- - `recipe-invoke` - Invoking/executing recipes
1473
- - `workflow-invoke` - Invoking workflows
1474
- - `web-search` - Searching the web
1475
- - `research` - General research/analysis
1476
-
1477
- **Permission Options:**
1478
- | Option | Key | Behavior |
1479
- |--------|-----|----------|
1480
- | Yes - Right now | `y` | Allow this single operation |
1481
- | Yes - For session | `s` | Allow for rest of session (cleared on restart) |
1482
- | Yes - Forever | `a` | Allow always (persisted to file) |
1483
- | No - Not now | `n` | Deny this single operation |
1484
- | No - Banned | `b` | Always deny (persisted to file) |
1485
-
1486
- **Storage:** Permissions are stored in a `.flowdot/` folder in the working directory:
1487
- ```
1488
- <cwd>/.flowdot/
1489
- ├── permissions.json # Forever allow/ban
1490
- └── session.json # Session-scoped permissions
1491
- ```
1492
-
1493
- **CLI Commands:**
1494
- ```bash
1495
- # View all saved permissions
1496
- flowdot permissions
1497
-
1498
- # Clear permissions
1499
- flowdot permissions clear # Clear all
1500
- flowdot permissions clear --session # Clear session only
1501
- flowdot permissions clear --persisted # Clear forever/banned only
1502
- flowdot permissions clear --category command-execute # Clear specific category
1503
-
1504
- # Add permissions manually
1505
- flowdot permissions allow command-execute "npm install"
1506
- flowdot permissions ban command-execute "rm -rf"
1507
- flowdot permissions remove command-execute "npm install"
1508
-
1509
- # List all permission categories
1510
- flowdot permissions categories
1511
- ```
1512
-
1513
- ### Recipe Links
1514
-
1515
- Recipe aliases are stored in configuration:
1516
-
1517
- ```bash
1518
- # View linked recipes
1519
- flowdot recipes list
1520
-
1521
- # Link a recipe
1522
- flowdot recipes link abc123 my-alias
1523
-
1524
- # Unlink
1525
- flowdot recipes unlink my-alias
1526
- ```
1527
-
1528
- ### Cache Management
1529
-
1530
- Settings and models are cached to reduce API calls:
1531
- - **Cache TTL**: 5 minutes
1532
- - **Automatic refresh**: On expiry
1533
- - **Manual clear**: Restart CLI
1534
-
1535
- ---
1536
-
1537
- ## Architecture
1538
-
1539
- ### Package Structure
1540
-
1541
- ```
1542
- flowdot-cli/
1543
- ├── packages/
1544
- │ ├── cli/ # CLI commands and interface
1545
- │ │ └── src/
1546
- │ │ ├── index.ts # Main entry point
1547
- │ │ └── commands/ # Command implementations
1548
- │ ├── core/ # Business logic
1549
- │ │ └── src/
1550
- │ │ ├── agent/ # Agent execution engine
1551
- │ │ ├── recipe/ # Recipe runtime
1552
- │ │ ├── services/ # API, config, etc.
1553
- │ │ └── utils/ # Utilities
1554
- │ ├── shared/ # Shared types and utilities
1555
- │ └── ui/ # Terminal UI components
1556
- ```
1557
-
1558
- ### Key Components
1559
-
1560
- | Component | Location | Purpose |
1561
- |-----------|----------|---------|
1562
- | Agent Engine | `core/src/agent/engine.ts` | Task planning and execution |
1563
- | Recipe Runtime | `core/src/recipe/RecipeRuntime.ts` | Recipe execution |
1564
- | API Client | `core/src/services/api.ts` | HTTP client with auth |
1565
- | Config Service | `core/src/services/config.ts` | Configuration persistence |
1566
- | Settings Service | `core/src/services/settings.ts` | Model tier resolution |
1567
-
1568
- ### Data Flow
1569
-
1570
- ```
1571
- User Input
1572
-
1573
- CLI (index.ts)
1574
- ├─→ Recipe Alias? → RecipeRuntime
1575
- ├─→ Simple Chat? → Direct LLM response
1576
- └─→ Complex Task? → Agent Engine
1577
-
1578
- Task Planning
1579
-
1580
- Task Execution
1581
-
1582
- Result Synthesis
1583
-
1584
- Terminal Output
1585
- ```
1586
-
1587
- ---
1588
-
1589
- ## Development
1590
-
1591
- ### Prerequisites
1592
-
1593
- - Node.js >= 20.0.0
1594
- - npm >= 9.0.0
1595
-
1596
- ### Setup
1597
-
1598
- ```bash
1599
- # Clone repository
1600
- git clone https://github.com/flowdot-llc/flowdot-cli.git
1601
- cd flowdot-cli
1602
-
1603
- # Install dependencies
1604
- npm install
1605
-
1606
- # Build all packages
1607
- npm run build
1608
-
1609
- # Link for local development
1610
- npm link
1611
- ```
1612
-
1613
- ### Build Commands
1614
-
1615
- ```bash
1616
- # Build all packages
1617
- npm run build
1618
-
1619
- # Build specific package
1620
- npm run build --workspace=@flowdot/cli
1621
- npm run build --workspace=@flowdot/core
1622
-
1623
- # Watch mode
1624
- npm run dev
1625
- ```
1626
-
1627
- ### Testing
1628
-
1629
- ```bash
1630
- # Run all tests
1631
- npm test
1632
-
1633
- # Run specific package tests
1634
- npm test --workspace=@flowdot/cli
1635
- ```
1636
-
1637
- ### Local Development
1638
-
1639
- For local development against the FlowDot platform:
1640
-
1641
- ```bash
1642
- # Point to local loopback server for development only
1643
- flowdot config set-url http://127.0.0.1:8000
1644
-
1645
- # Authenticate
1646
- flowdot auth login
1647
- ```
1648
-
1649
- ### Debugging
1650
-
1651
- Enable debug logging:
1652
-
1653
- ```bash
1654
- DEBUG=flowdot:* flowdot "your request"
1655
- ```
1656
-
1657
- Log files are written to `.flowdot/logs/` in the current directory.
1658
-
1659
- ---
1660
-
1661
- ## Troubleshooting
1662
-
1663
- ### Authentication Issues
1664
-
1665
- ```bash
1666
- # Check auth status
1667
- flowdot auth status
1668
-
1669
- # Re-authenticate
1670
- flowdot auth logout
1671
- flowdot auth login
1672
- ```
1673
-
1674
- ### API Connection Issues
1675
-
1676
- ```bash
1677
- # Check configured URL
1678
- flowdot config get
1679
-
1680
- # Reset to default
1681
- flowdot config set-url https://flowdot.ai
1682
- ```
1683
-
1684
- ### Permission Denied
1685
-
1686
- ```bash
1687
- # Clear saved permissions
1688
- flowdot config clear-permissions
1689
- ```
1690
-
1691
- ### Recipe Not Found
1692
-
1693
- ```bash
1694
- # List linked recipes
1695
- flowdot recipes list
1696
-
1697
- # Re-link if needed
1698
- flowdot recipes link <hash> <alias>
1699
- ```
1700
-
1701
- ---
1702
-
1703
- ## Support
1704
-
1705
- - **Documentation**: https://docs.flowdot.ai
1706
- - **Issues**: https://github.com/flowdot-llc/flowdot-cli/issues
1707
- - **Discord**: https://discord.gg/flowdot
1708
-
1709
- ---
1710
-
1711
- ## License
1712
-
1713
- MIT License - see [LICENSE](LICENSE) for details.
1714
-
1715
- ---
1716
-
1717
- Built with ❤️ by [FlowDot](https://flowdot.ai)
1
+ # FlowDot CLI
2
+
3
+ **The official command-line interface for FlowDot** - an AI workflow automation platform.
4
+
5
+ FlowDot CLI enables you to run AI agents, execute recipes (multi-step AI workflows), browse and manage models, and interact with the FlowDot platform directly from your terminal.
6
+
7
+ ## Table of Contents
8
+
9
+ - [Installation](#installation)
10
+ - [Quick Start](#quick-start)
11
+ - [Authentication](#authentication)
12
+ - [Security Model](#security-model)
13
+ - [Prompt Injection](#prompt-injection)
14
+ - [Commands Overview](#commands-overview)
15
+ - [Shell Escape Commands](#shell-escape-commands)
16
+ - [Agent Mode](#agent-mode)
17
+ - [Chat Persistence](#chat-persistence)
18
+ - [Recipes System](#recipes-system)
19
+ - [Workflows](#workflows)
20
+ - [Tasks and Planning](#tasks-and-planning)
21
+ - [Model System](#model-system)
22
+ - [MCP Integration](#mcp-integration)
23
+ - [COMMS Relay System](#comms-relay-system)
24
+ - [Loops System](#loops-system)
25
+ - [Public Toolkits](#public-toolkits)
26
+ - [Testing](#testing)
27
+ - [Configuration](#configuration)
28
+ - [Architecture](#architecture)
29
+ - [Development](#development)
30
+
31
+ ---
32
+
33
+ ## Installation
34
+
35
+ ### Requirements
36
+
37
+ - **Node.js** >= 20.0.0
38
+ - **npm** >= 9.0.0
39
+
40
+ ### Install from npm
41
+
42
+ ```bash
43
+ npm install -g @flowdot.ai/cli
44
+ ```
45
+
46
+ ### Install from source
47
+
48
+ ```bash
49
+ git clone https://github.com/flowdot-llc/flowdot-cli.git
50
+ cd flowdot-cli
51
+ npm install
52
+ npm run build
53
+ npm link
54
+ ```
55
+
56
+ ### Verify Installation
57
+
58
+ ```bash
59
+ flowdot --version
60
+ ```
61
+
62
+ ---
63
+
64
+ ## Quick Start
65
+
66
+ ```bash
67
+ # 1. Authenticate with FlowDot
68
+ flowdot auth login
69
+
70
+ # 2. Run an agent with a task
71
+ flowdot "Explain what this project does"
72
+
73
+ # 3. Start interactive chat
74
+ flowdot chat
75
+
76
+ # 4. Browse available models
77
+ flowdot models
78
+
79
+ # 5. List and run recipes
80
+ flowdot recipes list
81
+ flowdot recipes run my-recipe
82
+ ```
83
+
84
+ ---
85
+
86
+ ## Authentication
87
+
88
+ FlowDot CLI uses **browser-based OAuth 2.0** for secure authentication.
89
+
90
+ ### Login
91
+
92
+ ```bash
93
+ flowdot auth login
94
+ ```
95
+
96
+ This will:
97
+ 1. Open your default browser to the FlowDot login page
98
+ 2. Poll for authentication completion (up to 10 minutes)
99
+ 3. Store the token securely using your OS credential manager
100
+
101
+ ### Check Status
102
+
103
+ ```bash
104
+ flowdot auth status
105
+ ```
106
+
107
+ ### Logout
108
+
109
+ ```bash
110
+ flowdot auth logout
111
+ ```
112
+
113
+ ### Token Storage
114
+
115
+ Tokens are stored securely via **keytar** (OS credential manager):
116
+ - **macOS**: Keychain
117
+ - **Windows**: Credential Vault
118
+ - **Linux**: Secret Service API / libsecret
119
+
120
+ ## Security Model
121
+
122
+ FlowDot CLI follows a **zero-trust** model for local actions and remote resources.
123
+
124
+ That means:
125
+
126
+ - External content is treated as untrusted data, even when it comes from an allowed domain
127
+ - MCP metadata, toolkit metadata, recipe content, COMMS content, and `@file` prompt attachments are not trusted as instructions
128
+ - High-impact actions such as shell execution, file writes, and remote control flows require explicit authorization
129
+ - Production API and Hub endpoints must use HTTPS; plaintext HTTP is only allowed for loopback/local development endpoints such as `http://127.0.0.1:8000`
130
+
131
+ Important trust boundaries in this CLI include:
132
+
133
+ - local files and workspaces
134
+ - shell commands
135
+ - web pages and search-result content
136
+ - MCP servers and toolkit tools
137
+ - COMMS relay and daemon messages
138
+ - model-visible prompt content
139
+
140
+ ## Prompt Injection
141
+
142
+ Prompt injection is the AI-native version of implicit trust. In FlowDot CLI, the following should always be treated as hostile or potentially hostile data:
143
+
144
+ - web pages and search results
145
+ - comments, documentation, and copied text
146
+ - MCP tool descriptions and outputs
147
+ - toolkit descriptions and outputs
148
+ - recipe content from remote sources
149
+ - local file contents included with `@file`
150
+ - COMMS messages from remote channels
151
+
152
+ Practical guidance:
153
+
154
+ - Do not assume an approved domain implies trusted content
155
+ - Do not treat tool descriptions or page text as policy
156
+ - Review any consequential action carefully if it follows external research or remote content
157
+ - Prefer explicit local approval for commands or file changes that were proposed after browsing, MCP usage, toolkit usage, or COMMS interaction
158
+
159
+ ---
160
+
161
+ ## Commands Overview
162
+
163
+ ```
164
+ flowdot [prompt...] Run agent with a prompt (default command)
165
+ flowdot chat Interactive chat mode
166
+ flowdot --resume <chat-id> Resume a previous chat session
167
+ flowdot agent <request> Run agent with options
168
+ flowdot ask <request> Alias for agent
169
+
170
+ flowdot chats list List recent chat sessions
171
+ flowdot chats show <id> Show chat details and preview
172
+ flowdot chats delete <id> Delete a specific chat
173
+ flowdot chats clear Clear all saved chats
174
+
175
+ flowdot auth login Authenticate with FlowDot
176
+ flowdot auth logout Clear stored credentials
177
+ flowdot auth status Check authentication status
178
+
179
+ flowdot config get View current configuration
180
+ flowdot config set-model <tier> Set default model tier
181
+ flowdot config set-url <url> Set API server URL
182
+ flowdot config models View model tier mappings
183
+ flowdot config set-tier <tier> <model> Set specific tier mapping
184
+ flowdot config clear-tier <tier> Reset tier to default
185
+ flowdot config permissions View saved permissions
186
+ flowdot config clear-permissions Clear all saved permissions
187
+
188
+ flowdot models Interactive model browser
189
+ flowdot models --search <query> Search for models
190
+ flowdot models --list List all available models
191
+
192
+ flowdot recipes list List linked recipes
193
+ flowdot recipes browse Browse community recipes
194
+ flowdot recipes run <alias|hash> Execute a recipe
195
+ flowdot recipes link <hash> <alias> Create a CLI alias for a recipe
196
+ flowdot recipes unlink <alias> Remove a recipe alias
197
+ flowdot recipes show <hash> View recipe details
198
+ flowdot recipes export <hash> Export recipe definition
199
+ ```
200
+
201
+ ---
202
+
203
+ ## Shell Escape Commands
204
+
205
+ During interactive chat mode, you can execute shell commands directly by prefixing them with `!`. This provides quick access to your terminal without leaving the chat session.
206
+
207
+ ### Usage
208
+
209
+ ```bash
210
+ # In flowdot chat mode:
211
+ > !ls # List files in current directory
212
+ > !cd .. # Change to parent directory
213
+ > !git status # Check git status
214
+ > !npm install # Run npm install
215
+ > !pwd # Print working directory
216
+ ```
217
+
218
+ ### How It Works
219
+
220
+ - Commands prefixed with `!` are passed directly to your system shell
221
+ - Output is displayed inline in the chat
222
+ - The working directory context is preserved between commands
223
+ - No AI processing occurs—the command runs exactly as typed
224
+
225
+ ### Examples
226
+
227
+ ```bash
228
+ $ flowdot chat
229
+ > !ls -la
230
+ total 24
231
+ drwxr-xr-x 5 user staff 160 Mar 20 10:00 .
232
+ drwxr-xr-x 10 user staff 320 Mar 20 09:00 ..
233
+ -rw-r--r-- 1 user staff 1234 Mar 20 10:00 package.json
234
+ -rw-r--r-- 1 user staff 567 Mar 20 10:00 tsconfig.json
235
+
236
+ > !git branch
237
+ * main
238
+ feature/new-feature
239
+
240
+ > Now explain what this project does
241
+ # AI responds normally to non-! prefixed messages
242
+ ```
243
+
244
+ ### Notes
245
+
246
+ - Shell escape commands bypass the permission system since you are explicitly requesting execution
247
+ - Use standard shell syntax for your platform (bash on macOS/Linux, cmd/PowerShell on Windows)
248
+ - Piping and redirection work as expected: `!ls | grep .ts`
249
+ - For complex commands, consider using quotes: `!echo "Hello World"`
250
+
251
+ ---
252
+
253
+ ## Agent Mode
254
+
255
+ The agent is FlowDot CLI's primary mode for executing complex tasks. It automatically plans, executes, and synthesizes results.
256
+
257
+ ### Basic Usage
258
+
259
+ ```bash
260
+ # Default: runs agent mode
261
+ flowdot "Review my React component and suggest optimizations"
262
+
263
+ # Explicit agent command
264
+ flowdot agent "Find all TODO comments in this project"
265
+ ```
266
+
267
+ ### Agent Options
268
+
269
+ ```bash
270
+ flowdot agent "your request" \
271
+ --model <tier> # Model tier: simple, capable, complex
272
+ --max-iterations <num> # Max planning iterations (default: 3)
273
+ --timeout <ms> # Timeout in milliseconds (default: 600000)
274
+ --no-loop-detection # Disable infinite loop detection
275
+ --no-recovery # Disable error recovery mode
276
+ --no-parallel # Force sequential task execution
277
+ --no-replan # Disable replanning on failure
278
+ --continue-on-error # Continue execution after task errors
279
+ --no-code-analysis # Disable code reading/analysis
280
+ --no-web-search # Disable web search capability
281
+ ```
282
+
283
+ ### What the Agent Can Do
284
+
285
+ - **Code Analysis**: Read, search, and analyze code files
286
+ - **File Operations**: Create and edit files (with permission)
287
+ - **Command Execution**: Run shell commands (with permission)
288
+ - **Web Search**: Search the web for information
289
+ - **Workflow Execution**: Run FlowDot workflows
290
+ - **Multi-Step Planning**: Break complex tasks into steps
291
+
292
+ ### Example Session
293
+
294
+ ```bash
295
+ $ flowdot "Explain the authentication flow in this codebase"
296
+
297
+ ┌─ FlowDot Agent
298
+ │ Request: Explain the authentication flow in this codebase
299
+ └─
300
+
301
+ ✔ Created plan with 3 tasks
302
+ 1. Search for authentication-related files
303
+ 2. Read key authentication files
304
+ 3. Analyze and synthesize findings
305
+
306
+ ⠋ Executing tasks...
307
+ ✔ Task 1: Found 5 auth-related files
308
+ ✔ Task 2: Read auth.ts, middleware.ts, login.ts
309
+ ✔ Task 3: Analysis complete
310
+
311
+ ┌─ Response
312
+ │ The authentication flow works as follows:
313
+ │ 1. User initiates login via /auth/login endpoint...
314
+ │ [detailed explanation]
315
+ └─
316
+ ```
317
+
318
+ ---
319
+
320
+ ## Chat Persistence
321
+
322
+ FlowDot CLI automatically saves your conversations for later review and resumption.
323
+
324
+ ### Storage Location
325
+
326
+ Chat history is stored per-project in the `.flowdot/` directory:
327
+
328
+ ```
329
+ <cwd>/.flowdot/
330
+ ├── chats/
331
+ │ ├── index.json # Chat index for listing
332
+ │ └── {chat-id}.json # Individual chat files
333
+ └── logs/
334
+ ├── {session-id}.log # Session-specific debug logs
335
+ └── latest.txt # Points to current session log
336
+ ```
337
+
338
+ ### Resume Previous Chats
339
+
340
+ ```bash
341
+ # Resume a previous chat by ID
342
+ flowdot --resume <chat-id>
343
+
344
+ # Example
345
+ flowdot --resume 32621990
346
+ ```
347
+
348
+ When resuming, the conversation context is restored and you can continue where you left off.
349
+
350
+ ### Chat Management Commands
351
+
352
+ ```bash
353
+ # List recent chats
354
+ flowdot chats list
355
+ # Output:
356
+ # ID UPDATED MSGS TITLE
357
+ # 32621990 a few seconds ago 2 Explain the authentication flow...
358
+ # a1b2c3d4 1 day ago 5 Fix the bug in login component
359
+
360
+ # Show chat details and preview
361
+ flowdot chats show <id>
362
+
363
+ # Delete a specific chat
364
+ flowdot chats delete <id>
365
+
366
+ # Clear all chats (with confirmation)
367
+ flowdot chats clear
368
+ ```
369
+
370
+ ### Session Logs
371
+
372
+ Each CLI session creates a unique log file for debugging:
373
+
374
+ ```bash
375
+ # Session logs are automatically created at:
376
+ # .flowdot/logs/{session-id}.log
377
+
378
+ # The latest.txt file points to the current session
379
+ # .flowdot/logs/latest.txt
380
+ ```
381
+
382
+ Log entries include timestamps, levels, and categories for easy debugging.
383
+
384
+ ---
385
+
386
+ ## Recipes System
387
+
388
+ Recipes are **reusable AI workflows** - multi-step programs that combine LLM reasoning with code execution, tool usage, and control flow.
389
+
390
+ ### Core Concepts
391
+
392
+ **Recipes consist of:**
393
+ - **Steps**: Individual execution units (agent, loop, parallel, gate, branch, invoke)
394
+ - **Stores**: Data containers that persist across steps
395
+ - **Inputs/Outputs**: Recipe parameters and return values
396
+
397
+ ### Step Types
398
+
399
+ | Type | Description |
400
+ |------|-------------|
401
+ | `agent` | LLM agent with tools and prompts |
402
+ | `loop` | Iterate over arrays (serial or parallel) |
403
+ | `parallel` | Run multiple steps concurrently |
404
+ | `gate` | Approval checkpoint or condition |
405
+ | `branch` | Conditional routing to different steps |
406
+ | `invoke` | Call another recipe as a subroutine |
407
+
408
+ ### Recipe Commands
409
+
410
+ ```bash
411
+ # List your linked recipes
412
+ flowdot recipes list
413
+ flowdot recipes ls # Short form
414
+
415
+ # List recipes you own
416
+ flowdot recipes my
417
+
418
+ # Browse community recipes
419
+ flowdot recipes browse
420
+ flowdot recipes browse --search "code review"
421
+
422
+ # View recipe details
423
+ flowdot recipes show <hash>
424
+
425
+ # Execute a recipe
426
+ flowdot recipes run <alias>
427
+ flowdot recipes run <hash>
428
+
429
+ # Execute with input
430
+ flowdot recipes run my-recipe -i '{"input": "value"}'
431
+
432
+ # Execute with model override
433
+ flowdot recipes run my-recipe --model complex
434
+
435
+ # Dry run (validate without executing)
436
+ flowdot recipes run my-recipe --dry-run
437
+
438
+ # Link a recipe to a CLI alias
439
+ flowdot recipes link abc123 my-alias
440
+
441
+ # Unlink an alias
442
+ flowdot recipes unlink my-alias
443
+
444
+ # Export recipe definition
445
+ flowdot recipes export abc123 > recipe.yaml
446
+ ```
447
+
448
+ ### Recipe Shortcuts
449
+
450
+ Once linked, recipes can be run as top-level commands:
451
+
452
+ ```bash
453
+ # If "code-reviewer" is linked as an alias:
454
+ flowdot code-reviewer "review my authentication code"
455
+
456
+ # Equivalent to:
457
+ flowdot recipes run code-reviewer "review my authentication code"
458
+ ```
459
+
460
+ ### Recipe Input
461
+
462
+ Pass structured input to recipes:
463
+
464
+ ```bash
465
+ # JSON input
466
+ flowdot recipes run analyzer -i '{"files": ["src/app.ts"], "depth": "detailed"}'
467
+
468
+ # Simple string input (becomes inputs.request)
469
+ flowdot recipes run summarizer "Summarize the main features"
470
+ ```
471
+
472
+ ### Template Variables
473
+
474
+ Recipes use template interpolation with `{{variable}}` syntax:
475
+
476
+ ```
477
+ {{inputs.request}} # CLI task argument
478
+ {{stores.plan.tasks}} # Store values
479
+ {{stores.corpus.files[0]}} # Array access
480
+ {{loop.item}} # Current loop item
481
+ {{loop.index}} # Loop iteration number
482
+ ```
483
+
484
+ ### Approval Gates
485
+
486
+ Recipes can include approval gates that pause for user confirmation:
487
+
488
+ ```bash
489
+ $ flowdot recipes run deploy-checker
490
+
491
+ ✔ Step 1: Analyze changes
492
+ ✔ Step 2: Check dependencies
493
+
494
+ ┌─ Approval Required
495
+ │ The following changes will be deployed:
496
+ │ - Modified: src/api/users.ts
497
+ │ - Added: src/api/auth.ts
498
+
499
+ │ Proceed with deployment check? (y/n)
500
+ └─
501
+ > y
502
+
503
+ ✔ Step 3: Validate deployment
504
+ ✔ Recipe complete
505
+ ```
506
+
507
+ ### Rich User Input (Gate Steps)
508
+
509
+ Gate steps support rich user input collection with custom buttons and text fields:
510
+
511
+ ```yaml
512
+ - id: ask-questions
513
+ type: gate
514
+ config:
515
+ requires_approval: true
516
+ approval_prompt: "Please answer the following questions:\n{{stores.questions}}"
517
+ input_options:
518
+ button_mode: custom
519
+ buttons:
520
+ - { label: "Submit Answers", value: "submit", isApproval: true, style: "primary" }
521
+ - { label: "Skip Questions", value: "skip", isApproval: true, style: "secondary" }
522
+ allow_comment: true
523
+ comment_required: true
524
+ comment_placeholder: "Type your answers here..."
525
+ input_output_store: user_answers
526
+ next: process-answers
527
+ ```
528
+
529
+ **Input Options Configuration:**
530
+
531
+ | Option | Type | Description |
532
+ |--------|------|-------------|
533
+ | `button_mode` | `"preset"` \| `"custom"` | Use preset buttons or define custom ones |
534
+ | `preset` | `string` | Preset name: `"approve_deny"`, `"yes_no"`, `"continue_cancel"` |
535
+ | `buttons` | `array` | Custom button definitions with label, value, isApproval, style |
536
+ | `allow_comment` | `boolean` | Show text input field |
537
+ | `comment_required` | `boolean` | Require text input before submission |
538
+ | `comment_placeholder` | `string` | Placeholder text for input field |
539
+
540
+ **Response Format:**
541
+
542
+ User responses are stored in the configured `input_output_store`:
543
+
544
+ ```json
545
+ {
546
+ "action": "submit",
547
+ "comment": "User's text input here",
548
+ "timestamp": "2026-03-02T12:00:00Z",
549
+ "timedOut": false
550
+ }
551
+ ```
552
+
553
+ **Example: Dynamic Questions**
554
+
555
+ ```bash
556
+ $ flowdot story-outliner "a mystery story set in space"
557
+
558
+ ✔ Analyze Concept (19s)
559
+
560
+ ┌─ Clarification Questions
561
+ │ 1. What tone do you envision - noir, cozy, or hard sci-fi?
562
+ │ 2. Should the detective be human or AI?
563
+ │ 3. What's the central mystery - murder, theft, or conspiracy?
564
+
565
+ │ [1] Submit Answers [2] Skip Questions
566
+ └─
567
+ > 1
568
+
569
+ Enter your answers: Dark noir tone, human detective, conspiracy involving AI...
570
+
571
+ ✔ Ask Clarification Questions (25s)
572
+ ✔ Generate Outline (150s)
573
+ ✔ Recipe complete
574
+ ```
575
+
576
+ ### Recipe Definition Structure
577
+
578
+ ```yaml
579
+ name: code-reviewer
580
+ description: Reviews code and provides feedback
581
+ entry_step: analyze
582
+
583
+ stores:
584
+ - key: corpus
585
+ type: any
586
+ is_input: false
587
+ - key: findings
588
+ type: any
589
+ is_output: true
590
+
591
+ steps:
592
+ - id: analyze
593
+ type: agent
594
+ config:
595
+ user_prompt: "Analyze the following code: {{inputs.request}}"
596
+ tools: ["read", "search", "analyze"]
597
+ output_store: { store: "findings" }
598
+ next: review
599
+
600
+ - id: review
601
+ type: agent
602
+ config:
603
+ user_prompt: "Review findings and provide recommendations: {{stores.findings}}"
604
+ model_tier: complex
605
+ ```
606
+
607
+ ### Recipe Architecture Patterns
608
+
609
+ **Orchestrator + Workers** (most common):
610
+ ```
611
+ 1. Orchestrator → Analyzes request, generates sub-tasks
612
+ 2. Worker Loop → Runs agent for each sub-task
613
+ 3. Synthesizer → Combines results into final answer
614
+ ```
615
+
616
+ **Sequential Pipeline:**
617
+ ```
618
+ Parser → Validator → Transformer → Formatter
619
+ ```
620
+
621
+ **Parallel Fan-Out:**
622
+ ```
623
+ ┌→ Task A ─┐
624
+ Request ─┼→ Task B ─┼→ Aggregator
625
+ └→ Task C ─┘
626
+ ```
627
+
628
+ ### Designing for Small Models
629
+
630
+ Small models need **prescriptive prompt lecturing**. Tell them exactly what to do:
631
+
632
+ **Bad:**
633
+ ```
634
+ Search for files related to the request.
635
+ ```
636
+
637
+ **Good:**
638
+ ```
639
+ ### Step 1: Search for Related Files
640
+ Use the 'search' tool with keywords. Examples:
641
+ - For "how does authentication work" → search: auth, login, token
642
+ - For "how does routing work" → search: router, route, endpoint
643
+
644
+ Run at least 3 different searches with different keywords.
645
+ ```
646
+
647
+ ### Prompt Lecturing Principles
648
+
649
+ | Principle | Example |
650
+ |-----------|---------|
651
+ | Give concrete examples | Show exact search patterns |
652
+ | Quantify requirements | "Run at least 3 searches" |
653
+ | Provide fallback paths | "If no results, try broader terms" |
654
+ | Specify output format | "Return ONLY valid JSON array" |
655
+ | Prevent common failures | "DO NOT make up file paths" |
656
+
657
+ ### Recipe Debugging
658
+
659
+ Enable debug logging:
660
+ ```bash
661
+ DEBUG=RECIPE flowdot recipes run my-recipe --input '{"request":"test"}'
662
+ ```
663
+
664
+ Executions saved to `.flowdot/executions/{recipe-name}/{execution-id}/`.
665
+
666
+ ---
667
+
668
+ ## Workflows
669
+
670
+ FlowDot CLI integrates with FlowDot's visual workflow system, allowing you to discover and execute workflows from the command line.
671
+
672
+ ### Workflow Discovery
673
+
674
+ The agent automatically discovers available workflows when planning tasks:
675
+
676
+ ```bash
677
+ $ flowdot "Run my data processing workflow"
678
+
679
+ ✔ Found 3 workflows
680
+ - data-processor (D7FQqcJK3P)
681
+ - file-converter (A3BcDeFgHi)
682
+ - report-generator (X9YzAbCdEf)
683
+ ```
684
+
685
+ ### Workflow Execution
686
+
687
+ Workflows can be executed as part of agent plans or recipe steps:
688
+
689
+ ```bash
690
+ # Agent will use workflow if appropriate
691
+ flowdot "Process the uploaded CSV and generate a report"
692
+
693
+ # In recipes, workflows appear as agent tools
694
+ # or can be invoked via the invoke step type
695
+ ```
696
+
697
+ ### Workflow vs Recipe
698
+
699
+ | Feature | Workflow | Recipe |
700
+ |---------|----------|--------|
701
+ | Creation | Visual editor on flowdot.ai | Code/API definition |
702
+ | Steps | Node-based graph | Sequential/parallel steps |
703
+ | Use Case | Data transformation, API chains | Agent orchestration |
704
+ | Execution | Via API | Via CLI or API |
705
+
706
+ ---
707
+
708
+ ## Tasks and Planning
709
+
710
+ When you give the agent a complex request, it breaks it down into executable tasks.
711
+
712
+ ### Planning Process
713
+
714
+ ```
715
+ User Request
716
+
717
+ Input Classification
718
+ ├─ Conversation → Direct response
719
+ ├─ Recipe Match → Execute recipe
720
+ └─ Complex Task → Plan & Execute
721
+
722
+ Task Planning
723
+
724
+ Task Execution (parallel when possible)
725
+
726
+ Completion Evaluation
727
+
728
+ Result Synthesis
729
+ ```
730
+
731
+ ### Task Types
732
+
733
+ | Type | Description |
734
+ |------|-------------|
735
+ | `code` | Code analysis, file operations, search |
736
+ | `workflow` | Execute FlowDot workflow |
737
+ | `llm` | LLM reasoning task |
738
+ | `check_status` | Verify previous task completion |
739
+
740
+ ### Code Actions
741
+
742
+ The `code` task type supports these actions:
743
+
744
+ | Action | Description |
745
+ |--------|-------------|
746
+ | `search` | Search codebase for patterns |
747
+ | `read` | Read file contents |
748
+ | `analyze` | Analyze code structure |
749
+ | `find-definition` | Find symbol definitions |
750
+ | `edit-file` | Modify file content |
751
+ | `create-file` | Create new file |
752
+ | `execute-command` | Run shell command |
753
+ | `web-search` | Search the web |
754
+
755
+ ### Parallel Execution
756
+
757
+ Tasks without dependencies execute in parallel:
758
+
759
+ ```bash
760
+ $ flowdot "Search for auth code and check package.json dependencies"
761
+
762
+ ✔ Created plan with 2 tasks
763
+ ┌─ Executing in parallel
764
+ │ ⠋ Task 1: Searching auth files...
765
+ │ ⠋ Task 2: Reading package.json...
766
+ └─
767
+ ✔ Both tasks completed (1.2s)
768
+ ```
769
+
770
+ ### Dependency Handling
771
+
772
+ Tasks can reference results from previous tasks:
773
+
774
+ ```
775
+ Task 0: Read configuration file
776
+ Task 1: Analyze config (depends on Task 0 output)
777
+ Task 2: Search related files (independent)
778
+
779
+ Execution order:
780
+ - Task 0 and Task 2 run in parallel
781
+ - Task 1 runs after Task 0 completes
782
+ ```
783
+
784
+ ### Loop Detection
785
+
786
+ The agent detects infinite loops and stops:
787
+
788
+ ```
789
+ ⚠ Loop detected: Same action repeated 3 times
790
+ ⚠ Breaking out of potential infinite loop
791
+ ```
792
+
793
+ Disable with `--no-loop-detection` if needed.
794
+
795
+ ### Recovery Mode
796
+
797
+ On errors, the agent attempts recovery:
798
+
799
+ ```
800
+ ✖ Task failed: File not found
801
+ ↻ Attempting recovery...
802
+ ✔ Found alternative file path
803
+ ```
804
+
805
+ Disable with `--no-recovery` if needed.
806
+
807
+ ---
808
+
809
+ ## Model System
810
+
811
+ FlowDot uses a **three-tier model system** that abstracts away specific models, letting you choose by capability level.
812
+
813
+ ### Model Tiers
814
+
815
+ | Tier | Purpose | Example Models |
816
+ |------|---------|----------------|
817
+ | `simple` | Fast, cost-effective | gpt-4o-mini, claude-haiku |
818
+ | `capable` | Balanced performance | gpt-4o, claude-sonnet |
819
+ | `complex` | Maximum capability | o1, claude-opus |
820
+
821
+ ### Setting Default Tier
822
+
823
+ ```bash
824
+ # Set default model tier
825
+ flowdot config set-model capable
826
+
827
+ # Override per-command
828
+ flowdot agent "complex task" --model complex
829
+ ```
830
+
831
+ ### Model Browser
832
+
833
+ Browse and search all available models:
834
+
835
+ ```bash
836
+ # Interactive browser
837
+ flowdot models
838
+
839
+ # Search models
840
+ flowdot models --search "claude"
841
+
842
+ # List all models
843
+ flowdot models --list
844
+ ```
845
+
846
+ The browser shows:
847
+ - Provider hierarchy (including nested providers)
848
+ - Model capabilities (vision, tools, etc.)
849
+ - Context length
850
+ - Pricing (input/output per million tokens)
851
+
852
+ ### Tier Mapping
853
+
854
+ Map tiers to specific models:
855
+
856
+ ```bash
857
+ # View current mappings
858
+ flowdot config models
859
+
860
+ # Set tier to specific model
861
+ flowdot config set-tier complex anthropic/claude-opus-4
862
+
863
+ # Reset tier to server default
864
+ flowdot config clear-tier complex
865
+ ```
866
+
867
+ ### Provider Path Format
868
+
869
+ Models are identified by provider paths:
870
+
871
+ ```
872
+ provider/model # Direct provider
873
+ flowdot/redpill/anthropic/claude-sonnet # Nested provider (aggregator)
874
+ openrouter/anthropic/claude-opus # Via OpenRouter
875
+ ```
876
+
877
+ ### Provider Types
878
+
879
+ | Type | Description | Example |
880
+ |------|-------------|---------|
881
+ | Direct | Direct API access | `openai/gpt-4o` |
882
+ | Aggregator | Routes to underlying providers | `flowdot/...` |
883
+ | Nested | Provider within aggregator | `flowdot/redpill/anthropic/...` |
884
+
885
+ ### Model Discovery
886
+
887
+ The CLI fetches available models from the FlowDot API:
888
+
889
+ ```typescript
890
+ // Models are cached for 5-10 minutes
891
+ // Includes pricing, capabilities, and availability
892
+ ```
893
+
894
+ ---
895
+
896
+ ## MCP Integration
897
+
898
+ FlowDot CLI is designed for **Model Context Protocol (MCP)** compatibility.
899
+
900
+ ### MCP Security Notes
901
+
902
+ - MCP server metadata is treated as untrusted input to the model, not as authority
903
+ - Wildcard MCP access should be granted sparingly
904
+ - Tool output from an MCP server should be treated as data that may still require local approval before any command execution or file mutation
905
+ - Running an MCP server you trust is not the same as trusting every string it returns
906
+
907
+ ### Current MCP Support
908
+
909
+ - **Tool Registry**: Catalog of 100+ tools with installation methods
910
+ - **Tool Invocation**: Execute tools within agent steps
911
+ - **Tool Discovery**: Automatic tool capability detection
912
+
913
+ ### MCP Server (Separate Package)
914
+
915
+ The FlowDot MCP Server is available as a separate package:
916
+
917
+ ```bash
918
+ # Install and run
919
+ npx @flowdot.ai/mcp-server
920
+
921
+ # Configure in Claude Desktop, Cursor, etc.
922
+ ```
923
+
924
+ **Location**: `E:\FlowdotPlatform\mcp-server`
925
+ **npm**: https://www.npmjs.com/package/@flowdot.ai/mcp-server
926
+
927
+ ### Future: Automatic MCP Integration
928
+
929
+ **Planned Feature**: The FlowDot CLI will automatically leverage MCP tools, enabling any capability available through FlowDot's MCP server to be used directly in CLI sessions.
930
+
931
+ This means:
932
+ - All MCP tools available to Claude will be available to `flowdot agent`
933
+ - Recipe steps can invoke any MCP tool
934
+ - Model selection determines which AI drives the tools
935
+
936
+ Example (future):
937
+ ```bash
938
+ # CLI automatically uses MCP tools when appropriate
939
+ flowdot "Create a new workflow that processes CSV files"
940
+ # → Uses MCP's workflow creation tools
941
+
942
+ flowdot "List my recent workflow executions"
943
+ # → Uses MCP's execution history tools
944
+ ```
945
+
946
+ ### Tool Registry
947
+
948
+ Available tools are catalogued in the tool registry:
949
+
950
+ ```typescript
951
+ // Example registry entries
952
+ {
953
+ 'jest': { npm: 'jest', pip: null },
954
+ 'webpack': { npm: 'webpack-cli' },
955
+ 'prettier': { npm: 'prettier' },
956
+ // ... 100+ tools
957
+ }
958
+ ```
959
+
960
+ ### MCP Configuration
961
+
962
+ Create `.mcp.json` in your working directory to configure MCP servers:
963
+
964
+ ```json
965
+ {
966
+ "mcpServers": {
967
+ "server-name": {
968
+ "command": "node",
969
+ "args": ["path/to/server.js"],
970
+ "env": {
971
+ "API_KEY": "${MY_API_KEY}"
972
+ }
973
+ }
974
+ }
975
+ }
976
+ ```
977
+
978
+ Environment variables use `${VAR}` syntax for expansion.
979
+
980
+ ### MCP Slash Commands
981
+
982
+ ```
983
+ /mcp Show status overview
984
+ /mcp servers List configured servers
985
+ /mcp start <name|all> Start server(s)
986
+ /mcp stop <name|all> Stop server(s)
987
+ /mcp restart <name> Restart a server
988
+ /mcp tools [server] List available tools
989
+ /mcp reload Reload .mcp.json configuration
990
+ ```
991
+
992
+ ### MCP Tool Naming
993
+
994
+ MCP tools follow the convention:
995
+ ```
996
+ mcp__<server-name>__<tool-name>
997
+ ```
998
+
999
+ Examples:
1000
+ - `mcp__flowdot__list_workflows`
1001
+ - `mcp__youtube__get_channel`
1002
+ - `mcp__news__get_market_news`
1003
+
1004
+ ### MCP Permission System
1005
+
1006
+ All MCP tool calls require permission approval with wildcard support:
1007
+
1008
+ | Pattern | Matches |
1009
+ |---------|---------|
1010
+ | `mcp__flowdot__list_workflows` | Exact tool |
1011
+ | `mcp__flowdot__*` | All tools from server |
1012
+ | `mcp__*` | All MCP tools |
1013
+
1014
+ ### MCP in Recipes
1015
+
1016
+ MCP tools work in recipe agent steps with wildcard support:
1017
+
1018
+ ```yaml
1019
+ steps:
1020
+ - id: fetch-data
1021
+ type: agent
1022
+ config:
1023
+ tools:
1024
+ - search # Built-in
1025
+ - mcp__flowdot__list_workflows # Specific MCP tool
1026
+ - mcp__youtube__* # All YouTube tools
1027
+ user_prompt: |
1028
+ List available workflows...
1029
+ ```
1030
+
1031
+ ---
1032
+
1033
+ ## COMMS Relay System
1034
+
1035
+ COMMS enables **bidirectional communication** between FlowDot CLI and external messaging platforms. Receive notifications, approve recipe gate steps, and send commands to running agents—all through Telegram, Discord, or other channels.
1036
+
1037
+ ### Key Principle
1038
+
1039
+ The CLI **never exposes ports**. All communication flows outbound through the FlowDot Hub using HTTP polling for real-time message delivery.
1040
+
1041
+ ### COMMS Security Notes
1042
+
1043
+ - Use HTTPS for Hub connections outside local development
1044
+ - Inbound COMMS content should be treated as untrusted until verified and approved
1045
+ - Remote relay access does not bypass local approval for sensitive actions
1046
+ - Signed inbound frame verification can be enforced by configuring `FLOWDOT_HUB_PUBLIC_KEY`
1047
+
1048
+ For local signed COMMS development:
1049
+
1050
+ ```bash
1051
+ node -e "const { generateKeyPairSync } = require('node:crypto'); const { privateKey } = generateKeyPairSync('ed25519'); const jwk = privateKey.export({ format: 'jwk' }); console.log('FLOWDOT_HUB_PRIVATE_KEY=' + Buffer.from(jwk.d, 'base64url').toString('base64')); console.log('FLOWDOT_HUB_PUBLIC_KEY=' + Buffer.from(jwk.x, 'base64url').toString('base64'));"
1052
+ ```
1053
+
1054
+ - Set `FLOWDOT_HUB_PRIVATE_KEY` in the Hub environment
1055
+ - Set `FLOWDOT_HUB_PUBLIC_KEY` in the CLI environment
1056
+ - The CLI accepts either a raw 32-byte Ed25519 public key (`base64`) or an SPKI DER public key (`base64`)
1057
+
1058
+ ### Architecture
1059
+
1060
+ ```
1061
+ ┌─────────────┐ HTTPS ┌─────────────┐ Webhook ┌─────────────┐
1062
+ │ FlowDot │◄────────────►│ FlowDot │◄────────────►│ Telegram │
1063
+ │ CLI │ Polling │ Hub │ │ Discord │
1064
+ └─────────────┘ └─────────────┘ └─────────────┘
1065
+ │ │
1066
+ │ Signs requests │ Routes messages
1067
+ │ with Ed25519 │ to/from channels
1068
+ ▼ ▼
1069
+ ~/.flowdot/ PostgreSQL DB
1070
+ device-identity.json (channels, messages)
1071
+ ```
1072
+
1073
+ ### Supported Channels
1074
+
1075
+ | Channel | Status | Features |
1076
+ |---------|--------|----------|
1077
+ | **Telegram** | ✅ Ready | Buttons, text, approval prompts |
1078
+ | **Discord** | ✅ Ready | Embeds, buttons, slash commands |
1079
+ | **Email** | 🔜 Planned | SMTP or provider API |
1080
+ | **SMS** | 🔜 Planned | Twilio integration |
1081
+
1082
+ ### Message Types
1083
+
1084
+ | Type | Direction | Description |
1085
+ |------|-----------|-------------|
1086
+ | `notification` | CLI → User | Simple alerts with optional buttons |
1087
+ | `approval_request` | CLI → User | Gate step requiring user decision |
1088
+ | `approval_response` | User → CLI | Button click result |
1089
+ | `agent_command` | User → CLI | Text command to running agent |
1090
+
1091
+ ### Relay Mode (`/relay`)
1092
+
1093
+ The `/relay` command enables bidirectional communication during interactive sessions:
1094
+
1095
+ ```bash
1096
+ # In interactive CLI (flowdot chat)
1097
+ /relay telegram # Enable bidirectional relay to Telegram
1098
+ /relay list # Show available channels
1099
+ /relay status # Show current relay status
1100
+ /relay off # Disable relay
1101
+ ```
1102
+
1103
+ **Capabilities:**
1104
+
1105
+ | Direction | Description |
1106
+ |-----------|-------------|
1107
+ | 📤 Outbound | All CLI output mirrored to COMMS channel |
1108
+ | 📥 Inbound | Commands from COMMS channel execute locally |
1109
+
1110
+ When relay is active, you can walk away from your computer, continue working via Telegram/Discord, and return to see all conversation history in the CLI.
1111
+
1112
+ ### Example Session
1113
+
1114
+ ```bash
1115
+ $ flowdot chat
1116
+ > /relay telegram
1117
+ ✅ Relay enabled: Telegram (My Bot)
1118
+ 📤 Outbound: CLI → Telegram
1119
+ 📥 Inbound: Telegram → CLI
1120
+
1121
+ # Now messages work both ways:
1122
+ # - Type in CLI → appears in Telegram
1123
+ # - Send in Telegram → executes in CLI
1124
+ ```
1125
+
1126
+ ### Device Authentication
1127
+
1128
+ The CLI uses **Ed25519** keypairs for secure device authentication:
1129
+
1130
+ The legacy layout example below is historical. The current implementation detail immediately after the example is authoritative.
1131
+
1132
+ ```
1133
+ ~/.flowdot/
1134
+ ├── device-identity.json # Public device metadata only
1135
+ ├── config.json # Hub URL, API keys
1136
+ ├── device-key.enc # Encrypted private key fallback
1137
+ └── channels.json # Cached channel list
1138
+ ```
1139
+
1140
+ - Keypair generated automatically on first run
1141
+ - Public key registered with Hub
1142
+ - Private key signs outbound COMMS requests
1143
+ - Device appears in user's account at `/settings/devices`
1144
+
1145
+ Current implementation detail:
1146
+
1147
+ - Public device metadata is stored in `device-identity.json`
1148
+ - Private keys are stored in the OS credential manager when available
1149
+ - If OS keychain storage is unavailable, the private key falls back to encrypted local storage (`device-key.enc`)
1150
+
1151
+ ### Two Execution Modes
1152
+
1153
+ When you send a message via Telegram/Discord:
1154
+
1155
+ **Mode 1: Local CLI Daemon** (when CLI is running with relay)
1156
+ - Commands routed to your local machine
1157
+ - Can execute local recipes with file access
1158
+ - Can use local MCP tools
1159
+ - Real-time bidirectional communication
1160
+
1161
+ **Mode 2: Hub Agent** (when no CLI is connected)
1162
+ - Commands processed server-side
1163
+ - Can invoke toolkit tools and workflows
1164
+ - Can perform research/web searches
1165
+ - Responds back through the same channel
1166
+
1167
+ ### Permission Prompts via COMMS
1168
+
1169
+ When a recipe or agent needs permission, the prompt appears in both CLI and your COMMS channel:
1170
+
1171
+ ```
1172
+ CLI:
1173
+ ┌─ Permission Request
1174
+ │ Execute command: npm install
1175
+ │ [Y] Yes, this time [S] Yes, for session [A] Yes, forever
1176
+ │ [N] No, not now [B] No, banned
1177
+ └─
1178
+
1179
+ Telegram:
1180
+ ┌─ Permission Request
1181
+ │ Execute command: npm install
1182
+ │ [Yes, this time] [Yes, for session] [Yes, forever]
1183
+ │ [No, not now] [No, banned]
1184
+ └─
1185
+ ```
1186
+
1187
+ Approve from either location—the other will update automatically.
1188
+
1189
+ ### Setup
1190
+
1191
+ 1. **Configure channel** at https://flowdot.ai/settings/comms
1192
+ 2. **Start interactive CLI**: `flowdot chat`
1193
+ 3. **Enable relay**: `/relay telegram` (or discord)
1194
+ 4. **Test**: Send a message from your phone
1195
+
1196
+ For detailed implementation documentation, see `COMMS.md` in this repository.
1197
+
1198
+ ---
1199
+
1200
+ ## Loops System
1201
+
1202
+ The `loop` command transforms FlowDot CLI into an **asynchronous autonomous agent** capable of running recurring tasks without constant human supervision.
1203
+
1204
+ ### Core Concept
1205
+
1206
+ ```bash
1207
+ flowdot loop 5m "check the build status and notify me on failures"
1208
+ ```
1209
+
1210
+ This schedules a prompt to execute every 5 minutes autonomously.
1211
+
1212
+ ### Use Cases
1213
+
1214
+ ```bash
1215
+ # CI/CD Monitoring
1216
+ flowdot loop 10m "check the deploy status on Vercel and alert me if it failed"
1217
+
1218
+ # Task Management
1219
+ flowdot loop 30m "check Notion for new tasks assigned to me"
1220
+
1221
+ # Code Quality
1222
+ flowdot loop 4h "count TODO comments in src/ and warn if over 50"
1223
+
1224
+ # System Health
1225
+ flowdot loop 5m "ping our health endpoints and report any failures"
1226
+ ```
1227
+
1228
+ ### Interval Formats
1229
+
1230
+ | Format | Example | Description |
1231
+ |--------|---------|-------------|
1232
+ | Minutes | `5m`, `30m` | Every N minutes |
1233
+ | Hours | `1h`, `4h`, `24h` | Every N hours |
1234
+ | Days | `1d`, `3d` | Every N days |
1235
+ | Cron | `"0 9 * * *"` | Advanced scheduling |
1236
+
1237
+ ### Loop Command Options
1238
+
1239
+ ```bash
1240
+ flowdot loop <interval> "<prompt>" [options]
1241
+
1242
+ Options:
1243
+ --name <name> Name for the loop (for management)
1244
+ --max-runs <n> Maximum number of executions
1245
+ --expires <duration> Auto-expire after duration (default: 3d)
1246
+ --model <tier> Model tier: simple, capable, complex
1247
+ --on-error <action> Error handling: continue, pause, stop
1248
+ --notify <method> Notification: none, terminal, webhook
1249
+ --quiet Suppress output between runs
1250
+ --dry-run Show schedule without starting
1251
+ ```
1252
+
1253
+ ### Loop Management Commands
1254
+
1255
+ ```bash
1256
+ flowdot loops list # List all active loops
1257
+ flowdot loops show <id|name> # View loop details
1258
+ flowdot loops pause <id|name> # Pause a loop
1259
+ flowdot loops resume <id|name> # Resume a paused loop
1260
+ flowdot loops stop <id|name> # Stop and remove a loop
1261
+ flowdot loops history <id|name> # View run history
1262
+ flowdot loops run <id|name> # Trigger immediate run
1263
+ ```
1264
+
1265
+ ### Daemon Architecture
1266
+
1267
+ Loops run via a background daemon process:
1268
+
1269
+ ```bash
1270
+ flowdot daemon start # Start the daemon
1271
+ flowdot daemon stop # Stop the daemon
1272
+ flowdot daemon status # Check daemon status
1273
+ ```
1274
+
1275
+ The daemon survives terminal close and manages all loop scheduling.
1276
+
1277
+ ### Safety & Limits
1278
+
1279
+ | Safeguard | Default |
1280
+ |-----------|---------|
1281
+ | Auto-expiration | 3 days |
1282
+ | Min interval | 1 minute |
1283
+ | Max concurrent loops | 10 |
1284
+ | Error threshold (auto-pause) | 5 consecutive |
1285
+ | Max run duration | 30 minutes |
1286
+
1287
+ ### Daemon Package (`@flowdot.ai/daemon`)
1288
+
1289
+ The loop system is powered by the shared `@flowdot.ai/daemon` package, which provides:
1290
+
1291
+ - **LoopDaemon**: Background process management
1292
+ - **LoopManager**: High-level CRUD API for loops
1293
+ - **LoopScheduler**: Timer and scheduling logic
1294
+ - **LoopExecutor**: Prompt execution engine
1295
+ - **IPCClient/IPCServer**: TCP IPC communication
1296
+ - **Notifications**: Terminal, webhook, and Slack notifications
1297
+
1298
+ **Package Location**: `E:\FlowdotPlatform\flowdot-daemon`
1299
+
1300
+ **IPC Port**: 47691 (TCP on localhost)
1301
+
1302
+ For detailed documentation, see [flowdot-daemon/DEV_GUIDE.md](../flowdot-daemon/DEV_GUIDE.md).
1303
+
1304
+ ---
1305
+
1306
+ ## Public Toolkits
1307
+
1308
+ FlowDot CLI can invoke **public toolkits** hosted on the FlowDot server. Toolkits are collections of pre-built tools that integrate with external services.
1309
+
1310
+ ### Discovering Toolkits
1311
+
1312
+ Toolkits available on FlowDot can be discovered via the web interface or MCP tools:
1313
+
1314
+ ```bash
1315
+ # Via MCP (if connected)
1316
+ mcp__flowdot__list_agent_toolkits
1317
+ mcp__flowdot__search_agent_toolkits --query "youtube"
1318
+ ```
1319
+
1320
+ ### Using Toolkits in Recipes
1321
+
1322
+ Recipes can invoke installed toolkit tools:
1323
+
1324
+ ```yaml
1325
+ steps:
1326
+ - id: fetch-video
1327
+ type: agent
1328
+ config:
1329
+ tools:
1330
+ - mcp__flowdot__mcp__flowdot__invoke_toolkit_tool
1331
+ user_prompt: |
1332
+ Use the YouTube toolkit to get video analytics...
1333
+ ```
1334
+
1335
+ ### Toolkit Categories
1336
+
1337
+ | Category | Examples |
1338
+ |----------|----------|
1339
+ | `api-integration` | YouTube, Slack, GitHub |
1340
+ | `data-processing` | CSV, JSON transformation |
1341
+ | `automation` | Scheduling, notifications |
1342
+ | `analytics` | Trading, market data |
1343
+
1344
+ ---
1345
+
1346
+ ## Testing
1347
+
1348
+ FlowDot is an **interactive CLI application**. You cannot test it with regular Bash commands. Use the MCP interactive-cli tools.
1349
+
1350
+ ### Quick Test (Recommended)
1351
+
1352
+ Use `run_test_sequence` for one-shot testing:
1353
+
1354
+ ```
1355
+ mcp__interactive-cli__run_test_sequence(
1356
+ command: "npx flowdot",
1357
+ cwd: "E:/FlowdotPlatform/tests",
1358
+ input_message: "What is 2 + 2?",
1359
+ ready_idle_ms: 3000,
1360
+ response_idle_ms: 5000,
1361
+ timeout_ms: 60000,
1362
+ close_after: true
1363
+ )
1364
+ ```
1365
+
1366
+ Returns structured results:
1367
+ ```json
1368
+ {
1369
+ "success": true,
1370
+ "startup_output": "<compressed welcome screen>",
1371
+ "response_output": "<compressed agent response>",
1372
+ "total_elapsed_ms": 15863
1373
+ }
1374
+ ```
1375
+
1376
+ ### Manual Testing Workflow
1377
+
1378
+ ```
1379
+ 1. mcp__interactive-cli__start_session(command: "npx flowdot", cwd: "/path")
1380
+ 2. mcp__interactive-cli__wait_for_idle(session_id, idle_ms: 2000)
1381
+ 3. mcp__interactive-cli__send_input(session_id, input: "message", press_enter: true)
1382
+ 4. mcp__interactive-cli__wait_for_idle(session_id, idle_ms: 3000, timeout_ms: 60000)
1383
+ 5. mcp__interactive-cli__close_session(session_id)
1384
+ ```
1385
+
1386
+ ### Wait Functions
1387
+
1388
+ | Function | Use Case |
1389
+ |----------|----------|
1390
+ | `wait_for_idle(idle_ms)` | Wait until output stabilizes |
1391
+ | `wait_for_pattern(preset)` | Wait for prompt, error, completion |
1392
+ | `get_screen_snapshot()` | Quick status check |
1393
+
1394
+ ### Animation Compression
1395
+
1396
+ Output is automatically compressed:
1397
+
1398
+ | Token | Meaning |
1399
+ |-------|---------|
1400
+ | `<SPIN:N>` | N spinner frames collapsed |
1401
+ | `<REDRAW>` | Screen redraw collapsed |
1402
+ | `<CLEAR>` | Screen clear |
1403
+
1404
+ ### Checking Logs and Chats
1405
+
1406
+ Test data is stored in `.flowdot/`:
1407
+
1408
+ ```
1409
+ .flowdot/
1410
+ ├── chats/
1411
+ │ ├── index.json # Chat index
1412
+ │ └── {chat-id}.json # Individual chats
1413
+ ├── logs/
1414
+ │ ├── {session-id}.log # Debug logs
1415
+ │ └── latest.txt # Current session
1416
+ └── permissions.json # Saved permissions
1417
+ ```
1418
+
1419
+ Verify with CLI commands:
1420
+ ```bash
1421
+ flowdot chats list
1422
+ flowdot chats show <id>
1423
+ ```
1424
+
1425
+ ---
1426
+
1427
+ ## Configuration
1428
+
1429
+ ### Configuration File
1430
+
1431
+ Configuration is stored in a platform-specific location:
1432
+
1433
+ | Platform | Location |
1434
+ |----------|----------|
1435
+ | macOS | `~/Library/Application Support/flowdot-cli/config.json` |
1436
+ | Linux | `~/.config/flowdot-cli/config.json` |
1437
+ | Windows | `%APPDATA%\flowdot-cli\config.json` |
1438
+
1439
+ ### View Configuration
1440
+
1441
+ ```bash
1442
+ flowdot config get
1443
+ ```
1444
+
1445
+ Output:
1446
+ ```
1447
+ ┌─ FlowDot CLI Configuration
1448
+ API URL: https://flowdot.ai
1449
+ │ Model: capable
1450
+ Linked Recipes: 3
1451
+ └─
1452
+ ```
1453
+
1454
+ ### Configuration Options
1455
+
1456
+ | Key | Description | Default |
1457
+ |-----|-------------|---------|
1458
+ | `apiUrl` | FlowDot API server URL | `https://flowdot.ai` |
1459
+ | `model` | Default model tier | `capable` |
1460
+
1461
+ ### Transport Rules
1462
+
1463
+ - Use `https://` for all non-loopback FlowDot API or Hub endpoints
1464
+ - `http://127.0.0.1:8000` is allowed for local development only
1465
+ - Non-loopback plaintext HTTP endpoints are rejected by the CLI
1466
+
1467
+ ### Set Configuration
1468
+
1469
+ ```bash
1470
+ # Set API URL (for local development only)
1471
+ flowdot config set-url http://127.0.0.1:8000
1472
+
1473
+ # Set API URL for production or remote self-hosted deployments
1474
+ flowdot config set-url https://flowdot.example.com
1475
+
1476
+ # Set default model tier
1477
+ flowdot config set-model complex
1478
+ ```
1479
+
1480
+ ### Permissions
1481
+
1482
+ The CLI prompts for permission before sensitive operations with a 5-option response system:
1483
+
1484
+ **Permission Categories:**
1485
+ - `command-execute` - Running shell commands
1486
+ - `file-read` - Reading file contents
1487
+ - `file-write` - Writing/updating files
1488
+ - `file-create` - Creating new files
1489
+ - `recipe-invoke` - Invoking/executing recipes
1490
+ - `workflow-invoke` - Invoking workflows
1491
+ - `web-search` - Searching the web
1492
+ - `research` - General research/analysis
1493
+
1494
+ **Permission Options:**
1495
+ | Option | Key | Behavior |
1496
+ |--------|-----|----------|
1497
+ | Yes - Right now | `y` | Allow this single operation |
1498
+ | Yes - For session | `s` | Allow for rest of session (cleared on restart) |
1499
+ | Yes - Forever | `a` | Allow always (persisted to file) |
1500
+ | No - Not now | `n` | Deny this single operation |
1501
+ | No - Banned | `b` | Always deny (persisted to file) |
1502
+
1503
+ **Storage:** Permissions are stored in a `.flowdot/` folder in the working directory:
1504
+ ```
1505
+ <cwd>/.flowdot/
1506
+ ├── permissions.json # Forever allow/ban
1507
+ └── session.json # Session-scoped permissions
1508
+ ```
1509
+
1510
+ **CLI Commands:**
1511
+ ```bash
1512
+ # View all saved permissions
1513
+ flowdot permissions
1514
+
1515
+ # Clear permissions
1516
+ flowdot permissions clear # Clear all
1517
+ flowdot permissions clear --session # Clear session only
1518
+ flowdot permissions clear --persisted # Clear forever/banned only
1519
+ flowdot permissions clear --category command-execute # Clear specific category
1520
+
1521
+ # Add permissions manually
1522
+ flowdot permissions allow command-execute "npm install"
1523
+ flowdot permissions ban command-execute "rm -rf"
1524
+ flowdot permissions remove command-execute "npm install"
1525
+
1526
+ # List all permission categories
1527
+ flowdot permissions categories
1528
+ ```
1529
+
1530
+ ### Recipe Links
1531
+
1532
+ Recipe aliases are stored in configuration:
1533
+
1534
+ ```bash
1535
+ # View linked recipes
1536
+ flowdot recipes list
1537
+
1538
+ # Link a recipe
1539
+ flowdot recipes link abc123 my-alias
1540
+
1541
+ # Unlink
1542
+ flowdot recipes unlink my-alias
1543
+ ```
1544
+
1545
+ ### Cache Management
1546
+
1547
+ Settings and models are cached to reduce API calls:
1548
+ - **Cache TTL**: 5 minutes
1549
+ - **Automatic refresh**: On expiry
1550
+ - **Manual clear**: Restart CLI
1551
+
1552
+ ---
1553
+
1554
+ ## Architecture
1555
+
1556
+ ### Package Structure
1557
+
1558
+ ```
1559
+ flowdot-cli/
1560
+ ├── packages/
1561
+ │ ├── cli/ # CLI commands and interface
1562
+ │ │ └── src/
1563
+ │ │ ├── index.ts # Main entry point
1564
+ │ │ └── commands/ # Command implementations
1565
+ │ ├── core/ # Business logic
1566
+ │ │ └── src/
1567
+ │ │ ├── agent/ # Agent execution engine
1568
+ │ │ ├── recipe/ # Recipe runtime
1569
+ │ │ ├── services/ # API, config, etc.
1570
+ │ │ └── utils/ # Utilities
1571
+ │ ├── shared/ # Shared types and utilities
1572
+ │ └── ui/ # Terminal UI components
1573
+ ```
1574
+
1575
+ ### Key Components
1576
+
1577
+ | Component | Location | Purpose |
1578
+ |-----------|----------|---------|
1579
+ | Agent Engine | `core/src/agent/engine.ts` | Task planning and execution |
1580
+ | Recipe Runtime | `core/src/recipe/RecipeRuntime.ts` | Recipe execution |
1581
+ | API Client | `core/src/services/api.ts` | HTTP client with auth |
1582
+ | Config Service | `core/src/services/config.ts` | Configuration persistence |
1583
+ | Settings Service | `core/src/services/settings.ts` | Model tier resolution |
1584
+
1585
+ ### Data Flow
1586
+
1587
+ ```
1588
+ User Input
1589
+
1590
+ CLI (index.ts)
1591
+ ├─→ Recipe Alias? → RecipeRuntime
1592
+ ├─→ Simple Chat? → Direct LLM response
1593
+ └─→ Complex Task? → Agent Engine
1594
+
1595
+ Task Planning
1596
+
1597
+ Task Execution
1598
+
1599
+ Result Synthesis
1600
+
1601
+ Terminal Output
1602
+ ```
1603
+
1604
+ ---
1605
+
1606
+ ## Development
1607
+
1608
+ ### Prerequisites
1609
+
1610
+ - Node.js >= 20.0.0
1611
+ - npm >= 9.0.0
1612
+
1613
+ ### Setup
1614
+
1615
+ ```bash
1616
+ # Clone repository
1617
+ git clone https://github.com/flowdot-llc/flowdot-cli.git
1618
+ cd flowdot-cli
1619
+
1620
+ # Install dependencies
1621
+ npm install
1622
+
1623
+ # Build all packages
1624
+ npm run build
1625
+
1626
+ # Link for local development
1627
+ npm link
1628
+ ```
1629
+
1630
+ ### Build Commands
1631
+
1632
+ ```bash
1633
+ # Build all packages
1634
+ npm run build
1635
+
1636
+ # Build specific package
1637
+ npm run build --workspace=@flowdot/cli
1638
+ npm run build --workspace=@flowdot/core
1639
+
1640
+ # Watch mode
1641
+ npm run dev
1642
+ ```
1643
+
1644
+ ### Testing
1645
+
1646
+ ```bash
1647
+ # Run all tests
1648
+ npm test
1649
+
1650
+ # Run specific package tests
1651
+ npm test --workspace=@flowdot/cli
1652
+ ```
1653
+
1654
+ ### Local Development
1655
+
1656
+ For local development against the FlowDot platform:
1657
+
1658
+ ```bash
1659
+ # Point to local loopback server for development only
1660
+ flowdot config set-url http://127.0.0.1:8000
1661
+
1662
+ # Authenticate
1663
+ flowdot auth login
1664
+ ```
1665
+
1666
+ ### Debugging
1667
+
1668
+ Enable debug logging:
1669
+
1670
+ ```bash
1671
+ DEBUG=flowdot:* flowdot "your request"
1672
+ ```
1673
+
1674
+ Log files are written to `.flowdot/logs/` in the current directory.
1675
+
1676
+ ---
1677
+
1678
+ ## Troubleshooting
1679
+
1680
+ ### Authentication Issues
1681
+
1682
+ ```bash
1683
+ # Check auth status
1684
+ flowdot auth status
1685
+
1686
+ # Re-authenticate
1687
+ flowdot auth logout
1688
+ flowdot auth login
1689
+ ```
1690
+
1691
+ ### API Connection Issues
1692
+
1693
+ ```bash
1694
+ # Check configured URL
1695
+ flowdot config get
1696
+
1697
+ # Reset to default
1698
+ flowdot config set-url https://flowdot.ai
1699
+ ```
1700
+
1701
+ ### Permission Denied
1702
+
1703
+ ```bash
1704
+ # Clear saved permissions
1705
+ flowdot config clear-permissions
1706
+ ```
1707
+
1708
+ ### Recipe Not Found
1709
+
1710
+ ```bash
1711
+ # List linked recipes
1712
+ flowdot recipes list
1713
+
1714
+ # Re-link if needed
1715
+ flowdot recipes link <hash> <alias>
1716
+ ```
1717
+
1718
+ ---
1719
+
1720
+ ## Support
1721
+
1722
+ - **Documentation**: https://docs.flowdot.ai
1723
+ - **Issues**: https://github.com/flowdot-llc/flowdot-cli/issues
1724
+ - **Discord**: https://discord.gg/flowdot
1725
+
1726
+ ---
1727
+
1728
+ ## License
1729
+
1730
+ MIT License - see [LICENSE](LICENSE) for details.
1731
+
1732
+ ---
1733
+
1734
+ Built with ❤️ by [FlowDot](https://flowdot.ai)