@litmers/cursorflow-orchestrator 0.1.36 → 0.1.39
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/CHANGELOG.md +8 -0
- package/commands/cursorflow-init.md +113 -32
- package/commands/cursorflow-prepare.md +146 -339
- package/commands/cursorflow-run.md +148 -131
- package/dist/cli/add.js +8 -4
- package/dist/cli/add.js.map +1 -1
- package/dist/cli/index.js +2 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/new.js +3 -5
- package/dist/cli/new.js.map +1 -1
- package/dist/cli/resume.js +26 -15
- package/dist/cli/resume.js.map +1 -1
- package/dist/cli/run.js +1 -6
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/setup-commands.d.ts +1 -0
- package/dist/cli/setup-commands.js +1 -0
- package/dist/cli/setup-commands.js.map +1 -1
- package/dist/core/runner/agent.d.ts +5 -1
- package/dist/core/runner/agent.js +34 -2
- package/dist/core/runner/agent.js.map +1 -1
- package/dist/core/runner/pipeline.d.ts +0 -1
- package/dist/core/runner/pipeline.js +116 -167
- package/dist/core/runner/pipeline.js.map +1 -1
- package/dist/core/runner/prompt.d.ts +0 -1
- package/dist/core/runner/prompt.js +11 -16
- package/dist/core/runner/prompt.js.map +1 -1
- package/dist/core/runner/task.d.ts +1 -2
- package/dist/core/runner/task.js +24 -36
- package/dist/core/runner/task.js.map +1 -1
- package/dist/core/runner.js +12 -2
- package/dist/core/runner.js.map +1 -1
- package/dist/core/stall-detection.d.ts +16 -4
- package/dist/core/stall-detection.js +97 -148
- package/dist/core/stall-detection.js.map +1 -1
- package/dist/services/logging/console.d.ts +7 -1
- package/dist/services/logging/console.js +15 -3
- package/dist/services/logging/console.js.map +1 -1
- package/dist/services/logging/formatter.js +2 -0
- package/dist/services/logging/formatter.js.map +1 -1
- package/dist/types/config.d.ts +1 -1
- package/dist/types/logging.d.ts +1 -1
- package/dist/types/task.d.ts +2 -7
- package/dist/utils/doctor.js +4 -4
- package/dist/utils/doctor.js.map +1 -1
- package/dist/utils/git.js +2 -0
- package/dist/utils/git.js.map +1 -1
- package/dist/utils/health.js +13 -13
- package/dist/utils/health.js.map +1 -1
- package/dist/utils/log-formatter.js +44 -7
- package/dist/utils/log-formatter.js.map +1 -1
- package/dist/utils/logger.js +2 -2
- package/dist/utils/logger.js.map +1 -1
- package/package.json +2 -1
- package/src/cli/add.ts +9 -4
- package/src/cli/index.ts +3 -0
- package/src/cli/new.ts +3 -5
- package/src/cli/resume.ts +30 -19
- package/src/cli/run.ts +1 -6
- package/src/cli/setup-commands.ts +1 -1
- package/src/core/runner/agent.ts +40 -5
- package/src/core/runner/pipeline.ts +127 -176
- package/src/core/runner/prompt.ts +11 -18
- package/src/core/runner/task.ts +24 -37
- package/src/core/runner.ts +13 -2
- package/src/core/stall-detection.ts +190 -146
- package/src/services/logging/console.ts +15 -3
- package/src/services/logging/formatter.ts +2 -0
- package/src/types/config.ts +1 -1
- package/src/types/logging.ts +4 -2
- package/src/types/task.ts +2 -7
- package/src/utils/doctor.ts +5 -5
- package/src/utils/git.ts +2 -0
- package/src/utils/health.ts +15 -15
- package/src/utils/log-formatter.ts +50 -7
- package/src/utils/logger.ts +2 -2
- package/commands/cursorflow-add.md +0 -159
- package/commands/cursorflow-clean.md +0 -84
- package/commands/cursorflow-doctor.md +0 -102
- package/commands/cursorflow-models.md +0 -51
- package/commands/cursorflow-monitor.md +0 -90
- package/commands/cursorflow-new.md +0 -87
- package/commands/cursorflow-resume.md +0 -205
- package/commands/cursorflow-signal.md +0 -52
- package/commands/cursorflow-stop.md +0 -55
- package/commands/cursorflow-triggers.md +0 -250
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
# CursorFlow Resume
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
Resume lanes that were interrupted or failed. CursorFlow allows you to continue from where the agent left off, restart from the first task, or resume all incomplete lanes at once.
|
|
5
|
-
|
|
6
|
-
## Usage
|
|
7
|
-
|
|
8
|
-
```bash
|
|
9
|
-
cursorflow resume [lane-name] [options]
|
|
10
|
-
cursorflow resume --status # Check status of all lanes
|
|
11
|
-
cursorflow resume --all # Resume all incomplete lanes
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
## Options
|
|
15
|
-
|
|
16
|
-
| Option | Description |
|
|
17
|
-
|------|------|
|
|
18
|
-
| `<lane-name>` | The name of the lane to resume (e.g., `lane-1`) |
|
|
19
|
-
| `--status` | Show status of all lanes in the run (no resume) |
|
|
20
|
-
| `--all` | Resume ALL incomplete/failed lanes automatically |
|
|
21
|
-
| `--run-dir <path>` | Use a specific run directory (default: latest) |
|
|
22
|
-
| `--max-concurrent <n>` | Max lanes to run in parallel when using `--all` (default: 3) |
|
|
23
|
-
| `--restart` | Restart from the first task (index 0) |
|
|
24
|
-
| `--clean` | Clean up the existing worktree before resuming |
|
|
25
|
-
| `--skip-doctor` | Skip pre-resume checks (not recommended) |
|
|
26
|
-
|
|
27
|
-
## Checking Lane Status
|
|
28
|
-
|
|
29
|
-
Before resuming, you can check the status of all lanes:
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
cursorflow resume --status
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
This displays a table showing:
|
|
36
|
-
- Lane name
|
|
37
|
-
- Current status (completed, failed, running, paused, etc.)
|
|
38
|
-
- Progress (current task / total tasks)
|
|
39
|
-
- Whether the lane needs to be resumed
|
|
40
|
-
|
|
41
|
-
Example output:
|
|
42
|
-
```
|
|
43
|
-
📊 Lane Status (run-1703145600000)
|
|
44
|
-
|
|
45
|
-
Lane Status Progress Needs Resume
|
|
46
|
-
------------------------------------------------------------
|
|
47
|
-
01-lane-auth completed 3/3
|
|
48
|
-
02-lane-api failed 1/3 ✓
|
|
49
|
-
└─ Error: cursor-agent timed out...
|
|
50
|
-
03-lane-ui running 2/3 ✓
|
|
51
|
-
|
|
52
|
-
Total: 3 | Completed: 1 | Needs Resume: 2
|
|
53
|
-
|
|
54
|
-
Tip: Run cursorflow resume --all to resume all incomplete lanes
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
## Resuming All Incomplete Lanes
|
|
58
|
-
|
|
59
|
-
The most common use case after interruption:
|
|
60
|
-
|
|
61
|
-
```bash
|
|
62
|
-
# Check what needs to be resumed
|
|
63
|
-
cursorflow resume --status
|
|
64
|
-
|
|
65
|
-
# Resume all incomplete lanes
|
|
66
|
-
cursorflow resume --all
|
|
67
|
-
|
|
68
|
-
# Resume with custom concurrency
|
|
69
|
-
cursorflow resume --all --max-concurrent 2
|
|
70
|
-
|
|
71
|
-
# Restart all incomplete lanes from the beginning
|
|
72
|
-
cursorflow resume --all --restart
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
## How it works
|
|
76
|
-
|
|
77
|
-
### Single Lane Resume
|
|
78
|
-
1. **Pre-flight Checks**: Runs doctor validation to check for branch conflicts and Git issues.
|
|
79
|
-
2. **State Loading**: Reads the `state.json` for the specified lane to find the last successful task.
|
|
80
|
-
3. **Environment Restore**: Verifies the Git worktree and branch for the lane.
|
|
81
|
-
4. **Execution**: Spawns a new runner that starts either from the current task index or from index 0 if `--restart` is used.
|
|
82
|
-
|
|
83
|
-
### Resume All (`--all`)
|
|
84
|
-
1. **Status Check**: Scans all lanes in the run directory.
|
|
85
|
-
2. **Filter**: Identifies lanes that need resuming (failed, paused, interrupted).
|
|
86
|
-
3. **Dependency Analysis**:
|
|
87
|
-
- Checks each lane's `dependsOn` field
|
|
88
|
-
- Skips lanes with unresolvable dependencies (deps not completed and not in resume list)
|
|
89
|
-
- Orders execution so lanes wait for their dependencies to complete first
|
|
90
|
-
4. **Pre-flight Checks**: Runs doctor validation once for the entire run.
|
|
91
|
-
5. **Parallel Execution**: Spawns runners for multiple lanes with concurrency control.
|
|
92
|
-
6. **Dependency-Aware Scheduling**: Only starts a lane when all its dependencies have completed.
|
|
93
|
-
7. **Progress Tracking**: Reports success/failure/skipped for each lane.
|
|
94
|
-
|
|
95
|
-
## Pre-resume Validation
|
|
96
|
-
|
|
97
|
-
Before resuming, CursorFlow automatically runs validation checks:
|
|
98
|
-
- **Branch conflicts**: Ensures no existing branches conflict with the lane's prefix
|
|
99
|
-
- **Git status**: Verifies repository state and remote connectivity
|
|
100
|
-
- **Task configuration**: Validates the task JSON files are still valid
|
|
101
|
-
|
|
102
|
-
To skip these checks (not recommended):
|
|
103
|
-
```bash
|
|
104
|
-
cursorflow resume lane-1 --skip-doctor
|
|
105
|
-
cursorflow resume --all --skip-doctor
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
## Examples
|
|
109
|
-
|
|
110
|
-
### Check status of all lanes
|
|
111
|
-
```bash
|
|
112
|
-
cursorflow resume --status
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### Resume all incomplete lanes
|
|
116
|
-
```bash
|
|
117
|
-
cursorflow resume --all
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
### Resume a single failed lane
|
|
121
|
-
```bash
|
|
122
|
-
cursorflow resume 01-lane-1
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### Restart a lane from scratch
|
|
126
|
-
```bash
|
|
127
|
-
cursorflow resume 02-lane-2 --restart
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
### Resume from an older run
|
|
131
|
-
```bash
|
|
132
|
-
cursorflow resume --status --run-dir _cursorflow/logs/runs/run-123456789/
|
|
133
|
-
cursorflow resume --all --run-dir _cursorflow/logs/runs/run-123456789/
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
### Resume with limited parallelism
|
|
137
|
-
```bash
|
|
138
|
-
cursorflow resume --all --max-concurrent 1 # One at a time
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
## Dependency Handling
|
|
142
|
-
|
|
143
|
-
When using `--all`, CursorFlow respects the `dependsOn` field in each lane's configuration:
|
|
144
|
-
|
|
145
|
-
- **Automatic ordering**: Lanes will wait for their dependencies to complete before starting
|
|
146
|
-
- **Skipped lanes**: If a lane depends on another that isn't completed and isn't in the resume queue, it will be skipped
|
|
147
|
-
- **Parallel with deps**: Independent lanes run in parallel; dependent lanes wait
|
|
148
|
-
|
|
149
|
-
Example status output with dependencies:
|
|
150
|
-
```
|
|
151
|
-
📊 Lane Status (run-1703145600000)
|
|
152
|
-
|
|
153
|
-
Lane Status Progress DependsOn Resumable
|
|
154
|
-
---------------------------------------------------------------------------
|
|
155
|
-
01-lane-core completed 3/3 -
|
|
156
|
-
02-lane-api failed 1/3 01-lane-core ✓
|
|
157
|
-
03-lane-ui failed 0/3 02-lane-api ⏳ waiting
|
|
158
|
-
└─ waiting for: 02-lane-api
|
|
159
|
-
|
|
160
|
-
Total: 3 | Completed: 1 | Needs Resume: 2
|
|
161
|
-
|
|
162
|
-
Tip: Run cursorflow resume --all to resume all incomplete lanes
|
|
163
|
-
Lanes with dependencies will wait until their dependencies complete.
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
In this example:
|
|
167
|
-
- `01-lane-core` is already completed
|
|
168
|
-
- `02-lane-api` can start immediately (its dependency `01-lane-core` is completed)
|
|
169
|
-
- `03-lane-ui` will wait until `02-lane-api` completes
|
|
170
|
-
|
|
171
|
-
## Troubleshooting
|
|
172
|
-
|
|
173
|
-
### State not found
|
|
174
|
-
If the command fails because the state is missing, ensure you are providing the correct lane name. Use `cursorflow resume --status` to see the names of the lanes in the latest run.
|
|
175
|
-
|
|
176
|
-
### Worktree issues
|
|
177
|
-
If the worktree directory was manually deleted, use the `--clean` or `--restart` flag to allow CursorFlow to recreate the environment.
|
|
178
|
-
|
|
179
|
-
### Branch conflicts
|
|
180
|
-
If resume fails due to branch conflicts:
|
|
181
|
-
|
|
182
|
-
```bash
|
|
183
|
-
# Check what branches exist
|
|
184
|
-
git branch --list "feature/*"
|
|
185
|
-
|
|
186
|
-
# Clean up old CursorFlow branches
|
|
187
|
-
cursorflow clean branches --dry-run
|
|
188
|
-
cursorflow clean branches
|
|
189
|
-
|
|
190
|
-
# Or manually delete specific branches
|
|
191
|
-
git branch -D feature/lane-1-old-branch
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
### Changed branch prefix
|
|
195
|
-
If the task JSON file's `branchPrefix` was changed after the initial run:
|
|
196
|
-
1. Either restore the original prefix in the JSON
|
|
197
|
-
2. Or use `--restart` to start fresh with the new prefix
|
|
198
|
-
3. Or manually clean up old branches with `cursorflow clean branches`
|
|
199
|
-
|
|
200
|
-
### Some lanes still failing after `--all`
|
|
201
|
-
If some lanes continue to fail after using `--all`:
|
|
202
|
-
1. Check the specific error with `cursorflow resume --status`
|
|
203
|
-
2. Try resuming the problematic lane individually with more visibility
|
|
204
|
-
3. Use `cursorflow monitor` to watch the lane in real-time
|
|
205
|
-
4. Check the lane's terminal log in `_cursorflow/logs/runs/<run>/lanes/<lane>/`
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
# CursorFlow Signal
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
Directly intervene in a running lane by sending a message to the agent. This is useful for providing immediate feedback or corrections during long-running tasks.
|
|
5
|
-
|
|
6
|
-
## Usage
|
|
7
|
-
|
|
8
|
-
```bash
|
|
9
|
-
cursorflow signal <lane-name> "<message>" [options]
|
|
10
|
-
cursorflow signal <lane-name> --timeout <ms>
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Options
|
|
14
|
-
|
|
15
|
-
| Option | Description |
|
|
16
|
-
|------|------|
|
|
17
|
-
| `<lane-name>` | The name of the lane to signal |
|
|
18
|
-
| `"<message>"` | The text message to send to the agent |
|
|
19
|
-
| `--timeout <ms>` | Update the execution timeout (in milliseconds) |
|
|
20
|
-
| `--run-dir <path>` | Use a specific run directory (default: latest) |
|
|
21
|
-
|
|
22
|
-
## How it works
|
|
23
|
-
1. **Logging**: Intervention messages are recorded in the lane's conversation history.
|
|
24
|
-
2. **Injection**: If `enableIntervention: true`, messages are injected into the agent's input stream.
|
|
25
|
-
3. **Dynamic Timeout**: If `--timeout` is used, the active runner receives a signal to reset its internal timer to the new value.
|
|
26
|
-
|
|
27
|
-
## Examples
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
# Provide a hint to a running agent
|
|
31
|
-
cursorflow signal 01-lane-1 "Make sure to export the new function from index.ts"
|
|
32
|
-
|
|
33
|
-
# Increase timeout to 10 minutes mid-execution
|
|
34
|
-
cursorflow signal 01-lane-1 --timeout 600000
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## Dashboard Alternative
|
|
38
|
-
You can also use the interactive monitor to send signals:
|
|
39
|
-
1. Run `cursorflow monitor latest`.
|
|
40
|
-
2. Select a lane and enter details (`→`).
|
|
41
|
-
3. Press `I` to send an intervention message.
|
|
42
|
-
4. Press `O` to update the execution timeout.
|
|
43
|
-
|
|
44
|
-
## Note on Intervention
|
|
45
|
-
For the agent to receive the signal immediately, the task must be configured with:
|
|
46
|
-
```json
|
|
47
|
-
{
|
|
48
|
-
"enableIntervention": true,
|
|
49
|
-
"tasks": [...]
|
|
50
|
-
}
|
|
51
|
-
```
|
|
52
|
-
If disabled, the signal will be logged but the agent will not be interrupted.
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
# CursorFlow Stop
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
Stop running CursorFlow workflows or specific lanes by killing their associated processes.
|
|
5
|
-
|
|
6
|
-
## Usage
|
|
7
|
-
|
|
8
|
-
```bash
|
|
9
|
-
cursorflow stop [run-id] [options]
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
## Options
|
|
13
|
-
|
|
14
|
-
| Option | Description |
|
|
15
|
-
|--------|-------------|
|
|
16
|
-
| `[run-id]` | Stop a specific run |
|
|
17
|
-
| `--lane <name>` | Stop only a specific lane |
|
|
18
|
-
| `--force` | Use `SIGKILL` instead of `SIGTERM` (immediate termination) |
|
|
19
|
-
| `--yes`, `-y` | Skip confirmation prompt |
|
|
20
|
-
| `--help`, `-h` | Show help |
|
|
21
|
-
|
|
22
|
-
## Examples
|
|
23
|
-
|
|
24
|
-
### Stop all running workflows
|
|
25
|
-
```bash
|
|
26
|
-
cursorflow stop
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
### Stop a specific run
|
|
30
|
-
```bash
|
|
31
|
-
cursorflow stop run-20251222-153012
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
### Stop only one lane
|
|
35
|
-
```bash
|
|
36
|
-
cursorflow stop --lane api-setup
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
### Force stop everything without confirmation
|
|
40
|
-
```bash
|
|
41
|
-
cursorflow stop --force --yes
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
## Execution Flow
|
|
45
|
-
|
|
46
|
-
1. **Detection**: identifies active runs and their associated PIDs.
|
|
47
|
-
2. **Confirmation**: Unless `--yes` is used, it lists running workflows and asks for confirmation.
|
|
48
|
-
3. **Termination**: Sends termination signals to all active lane processes.
|
|
49
|
-
4. **Verification**: Displays which lanes were successfully stopped.
|
|
50
|
-
|
|
51
|
-
## Notes
|
|
52
|
-
|
|
53
|
-
1. **Signals**: By default, it sends `SIGTERM` to allow processes to clean up. Use `--force` for `SIGKILL` if a process is stuck.
|
|
54
|
-
2. **Persistence**: Stopping a run doesn't delete any logs or worktrees. You can resume later using `cursorflow resume`.
|
|
55
|
-
3. **PIDs**: The command relies on PIDs stored in the lane state files.
|
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
# CursorFlow Event Triggers & Webhooks
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
CursorFlow emits various status changes during the orchestration process as **Events**. Through this event system, you can send notifications to external services (Webhooks) or execute custom logic to automate complex workflows.
|
|
6
|
-
|
|
7
|
-
## Key Concepts
|
|
8
|
-
|
|
9
|
-
### 1. Events
|
|
10
|
-
Occurrences during the lifecycle of the orchestrator, lanes, tasks, agents, and reviewers. Each event has a unique type and payload.
|
|
11
|
-
|
|
12
|
-
### 2. Webhooks
|
|
13
|
-
A mechanism to send emitted events to external HTTP endpoints. Configured via `cursorflow.config.js`, allowing you to filter for specific events.
|
|
14
|
-
|
|
15
|
-
### 3. Dependency Triggers
|
|
16
|
-
Internally, when a lane completes, any subsequent lanes that depend on it are automatically executed (triggered). This is managed by the DAG (Directed Acyclic Graph) scheduler.
|
|
17
|
-
|
|
18
|
-
## Supported Events
|
|
19
|
-
|
|
20
|
-
| Category | Event Type | Occurrence |
|
|
21
|
-
| :--- | :--- | :--- |
|
|
22
|
-
| **Orchestration** | `orchestration.started` | When the entire workflow begins |
|
|
23
|
-
| | `orchestration.completed` | When all lanes complete successfully |
|
|
24
|
-
| | `orchestration.failed` | When an error occurs during the workflow |
|
|
25
|
-
| **Lane** | `lane.started` | When an individual lane starts execution |
|
|
26
|
-
| | `lane.completed` | When all tasks in a lane are finished |
|
|
27
|
-
| | `lane.failed` | When an error occurs during lane execution |
|
|
28
|
-
| | `lane.dependency_requested` | When an agent requests to modify external dependencies |
|
|
29
|
-
| **Task** | `task.started` | When an individual task within a lane begins |
|
|
30
|
-
| | `task.completed` | When a task succeeds |
|
|
31
|
-
| | `task.failed` | When a task fails |
|
|
32
|
-
| **Agent** | `agent.prompt_sent` | When a prompt is sent to the AI agent |
|
|
33
|
-
| | `agent.response_received` | When a response is received from the AI agent |
|
|
34
|
-
| **Review** | `review.started` | When the AI review process begins |
|
|
35
|
-
| | `review.completed` | When the AI review completes (includes results) |
|
|
36
|
-
| | `review.approved` | When a review is approved |
|
|
37
|
-
| | `review.rejected` | When a review is rejected and a retry is determined |
|
|
38
|
-
|
|
39
|
-
## Common Event Structure
|
|
40
|
-
|
|
41
|
-
All events passed to listeners have the following common wrapper structure:
|
|
42
|
-
|
|
43
|
-
```typescript
|
|
44
|
-
{
|
|
45
|
-
"id": "evt_1734842400000_abc123", // Unique event ID
|
|
46
|
-
"type": "task.completed", // Event type
|
|
47
|
-
"timestamp": "2024-12-22T10:00:00.000Z", // Timestamp (ISO 8601)
|
|
48
|
-
"runId": "run-1734842400000", // Current orchestration run ID
|
|
49
|
-
"payload": { ... } // Event-specific data (see below)
|
|
50
|
-
}
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
## Event Payload Details
|
|
54
|
-
|
|
55
|
-
### 1. Orchestration
|
|
56
|
-
|
|
57
|
-
#### `orchestration.started`
|
|
58
|
-
- `runId`: Unique run ID
|
|
59
|
-
- `tasksDir`: Path to the directory containing task configuration files
|
|
60
|
-
- `laneCount`: Total number of lanes to be executed
|
|
61
|
-
- `runRoot`: Root directory where logs and status files are stored
|
|
62
|
-
|
|
63
|
-
#### `orchestration.completed`
|
|
64
|
-
- `runId`: Unique run ID
|
|
65
|
-
- `laneCount`: Total number of lanes
|
|
66
|
-
- `completedCount`: Number of successfully completed lanes
|
|
67
|
-
- `failedCount`: Number of failed lanes
|
|
68
|
-
|
|
69
|
-
#### `orchestration.failed`
|
|
70
|
-
- `error`: Error message
|
|
71
|
-
- `blockedLanes`: (Optional) List of lane names that could not start due to dependency issues
|
|
72
|
-
|
|
73
|
-
### 2. Lane
|
|
74
|
-
|
|
75
|
-
#### `lane.started`
|
|
76
|
-
- `laneName`: Name of the lane (filename)
|
|
77
|
-
- `pid`: (Optional) Process ID of the child process running the lane
|
|
78
|
-
- `logPath`: Path to the log file for this lane
|
|
79
|
-
|
|
80
|
-
#### `lane.completed`
|
|
81
|
-
- `laneName`: Name of the lane
|
|
82
|
-
- `exitCode`: Exit code (0 for success)
|
|
83
|
-
|
|
84
|
-
#### `lane.failed`
|
|
85
|
-
- `laneName`: Name of the lane
|
|
86
|
-
- `exitCode`: Exit code
|
|
87
|
-
- `error`: Description of the failure cause
|
|
88
|
-
|
|
89
|
-
#### `lane.dependency_requested`
|
|
90
|
-
- `laneName`: Name of the lane that sent the request
|
|
91
|
-
- `dependencyRequest`: Dependency modification plan (includes `reason`, `changes`, `commands`)
|
|
92
|
-
|
|
93
|
-
### 3. Task
|
|
94
|
-
|
|
95
|
-
#### `task.started`
|
|
96
|
-
- `taskName`: Name of the task
|
|
97
|
-
- `taskBranch`: Name of the Git branch being worked on
|
|
98
|
-
- `index`: Task sequence index within the lane (starting from 0)
|
|
99
|
-
- `timeout`: (Optional) Task-specific timeout in milliseconds
|
|
100
|
-
|
|
101
|
-
#### `task.completed`
|
|
102
|
-
- `taskName`: Name of the task
|
|
103
|
-
- `taskBranch`: Name of the Git branch
|
|
104
|
-
- `status`: Completion status (e.g., 'FINISHED')
|
|
105
|
-
|
|
106
|
-
#### `task.failed`
|
|
107
|
-
- `taskName`: Name of the task
|
|
108
|
-
- `taskBranch`: Branch name
|
|
109
|
-
- `error`: Error message from task execution
|
|
110
|
-
|
|
111
|
-
### 4. Agent
|
|
112
|
-
|
|
113
|
-
#### `agent.prompt_sent`
|
|
114
|
-
- `taskName`: Current task name
|
|
115
|
-
- `model`: AI model used
|
|
116
|
-
- `promptLength`: Length of the sent prompt string
|
|
117
|
-
|
|
118
|
-
#### `agent.response_received`
|
|
119
|
-
- `taskName`: Task name
|
|
120
|
-
- `ok`: Success flag (boolean)
|
|
121
|
-
- `duration`: Time taken for AI response (milliseconds)
|
|
122
|
-
- `responseLength`: Length of the received response string
|
|
123
|
-
- `error`: (On failure) Error message
|
|
124
|
-
|
|
125
|
-
### 5. Review
|
|
126
|
-
|
|
127
|
-
#### `review.started`
|
|
128
|
-
- `taskName`: Name of the task under review
|
|
129
|
-
- `taskBranch`: Name of the branch under review
|
|
130
|
-
|
|
131
|
-
#### `review.completed`
|
|
132
|
-
- `taskName`: Task name
|
|
133
|
-
- `status`: Review result (`'approved'` or `'needs_changes'`)
|
|
134
|
-
- `issueCount`: Number of issues found
|
|
135
|
-
- `summary`: Review summary content
|
|
136
|
-
|
|
137
|
-
#### `review.approved`
|
|
138
|
-
- `taskName`: Task name
|
|
139
|
-
- `iterations`: Number of review iterations until final approval
|
|
140
|
-
|
|
141
|
-
#### `review.rejected`
|
|
142
|
-
- `taskName`: Task name
|
|
143
|
-
- `reason`: Reason for rejection (summary of requested changes)
|
|
144
|
-
- `iterations`: Current number of review iterations
|
|
145
|
-
|
|
146
|
-
## Webhook Configuration
|
|
147
|
-
|
|
148
|
-
Set up the `webhooks` array in your `cursorflow.config.js` file.
|
|
149
|
-
|
|
150
|
-
```javascript
|
|
151
|
-
module.exports = {
|
|
152
|
-
// ... other settings
|
|
153
|
-
webhooks: [
|
|
154
|
-
{
|
|
155
|
-
enabled: true,
|
|
156
|
-
url: 'https://your-api.com/webhooks/cursorflow',
|
|
157
|
-
secret: 'your-hmac-secret', // Secret for HMAC signature
|
|
158
|
-
events: ['lane.completed', 'orchestration.*'], // Event patterns to receive
|
|
159
|
-
headers: {
|
|
160
|
-
'X-Custom-Header': 'CursorFlow-Bot'
|
|
161
|
-
},
|
|
162
|
-
retries: 3, // Number of retries on failure
|
|
163
|
-
timeoutMs: 5000 // Timeout setting
|
|
164
|
-
}
|
|
165
|
-
]
|
|
166
|
-
};
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
### Event Filtering Patterns
|
|
170
|
-
- `*`: Receive all events
|
|
171
|
-
- `lane.*`: Receive all lane-related events
|
|
172
|
-
- `task.failed`: Receive only task failure events
|
|
173
|
-
|
|
174
|
-
## Programmatic Event Listeners (Function Triggers)
|
|
175
|
-
|
|
176
|
-
In addition to webhooks, you can register event listeners directly via Node.js code to execute custom logic. This is useful for running local scripts or complex conditional logic.
|
|
177
|
-
|
|
178
|
-
### 1. Registering in `cursorflow.config.js`
|
|
179
|
-
|
|
180
|
-
Since the `cursorflow run` command loads the configuration file, you can subscribe to events at this point.
|
|
181
|
-
|
|
182
|
-
```javascript
|
|
183
|
-
// cursorflow.config.js
|
|
184
|
-
const { events } = require('@litmers/cursorflow-orchestrator');
|
|
185
|
-
|
|
186
|
-
// Execute custom logic on task completion
|
|
187
|
-
events.on('task.completed', (event) => {
|
|
188
|
-
const { taskName, taskBranch } = event.payload;
|
|
189
|
-
console.log(`[HOOK] Task completed: ${taskName} (Branch: ${taskBranch})`);
|
|
190
|
-
|
|
191
|
-
// Example: Check if a specific file was created or update a local database
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
// Notify on entire orchestration failure
|
|
195
|
-
events.on('orchestration.failed', (event) => {
|
|
196
|
-
console.error(`!!! Orchestration failed: ${event.payload.error}`);
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
module.exports = {
|
|
200
|
-
tasksDir: '_cursorflow/tasks',
|
|
201
|
-
// ... other configurations
|
|
202
|
-
};
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
### 2. Usage in Custom Scripts
|
|
206
|
-
|
|
207
|
-
If you are using CursorFlow as a library, you can call the `orchestrate` function directly and monitor events.
|
|
208
|
-
|
|
209
|
-
```javascript
|
|
210
|
-
const { orchestrate, events } = require('@litmers/cursorflow-orchestrator');
|
|
211
|
-
|
|
212
|
-
async function runMyPipeline() {
|
|
213
|
-
// Register event listener
|
|
214
|
-
events.on('lane.started', (event) => {
|
|
215
|
-
console.log(`Lane started: ${event.payload.laneName}`);
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
// Execute orchestration
|
|
219
|
-
try {
|
|
220
|
-
await orchestrate('./my-tasks');
|
|
221
|
-
console.log('All tasks completed');
|
|
222
|
-
} catch (err) {
|
|
223
|
-
console.error('Error during orchestration', err);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
runMyPipeline();
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
## Security & Verification
|
|
231
|
-
|
|
232
|
-
When sending webhooks, you can verify the integrity of the payload using the `X-CursorFlow-Signature` header.
|
|
233
|
-
|
|
234
|
-
- **Algorithm**: HMAC-SHA256
|
|
235
|
-
- **Format**: `sha256=<hex_signature>`
|
|
236
|
-
|
|
237
|
-
The receiver should hash the request body using the configured `secret` and verify it matches the signature in the header.
|
|
238
|
-
|
|
239
|
-
## Use Cases
|
|
240
|
-
|
|
241
|
-
1. **Slack/Discord Notifications**: Notify the team messenger on `orchestration.completed` or `lane.failed`.
|
|
242
|
-
2. **Deployment Automation**: Execute an external script to deploy code to a staging environment once a specific lane completes.
|
|
243
|
-
3. **Statistics Collection**: Record token usage or response times in a database via the `agent.response_received` event.
|
|
244
|
-
4. **Dashboard Updates**: Reflect real-time status on an external monitoring dashboard.
|
|
245
|
-
|
|
246
|
-
## Precautions
|
|
247
|
-
|
|
248
|
-
- Webhook endpoints must support the `POST` method.
|
|
249
|
-
- Payloads are sent in `application/json` format.
|
|
250
|
-
- Consider network latency and set timeout and retry policies appropriately.
|