@litmers/cursorflow-orchestrator 0.1.13 → 0.1.15

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.
Files changed (76) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +83 -2
  3. package/commands/cursorflow-clean.md +20 -6
  4. package/commands/cursorflow-prepare.md +1 -1
  5. package/commands/cursorflow-resume.md +127 -6
  6. package/commands/cursorflow-run.md +2 -2
  7. package/commands/cursorflow-signal.md +11 -4
  8. package/dist/cli/clean.js +164 -12
  9. package/dist/cli/clean.js.map +1 -1
  10. package/dist/cli/index.d.ts +1 -0
  11. package/dist/cli/index.js +6 -1
  12. package/dist/cli/index.js.map +1 -1
  13. package/dist/cli/logs.d.ts +8 -0
  14. package/dist/cli/logs.js +759 -0
  15. package/dist/cli/logs.js.map +1 -0
  16. package/dist/cli/monitor.js +113 -30
  17. package/dist/cli/monitor.js.map +1 -1
  18. package/dist/cli/prepare.js +1 -1
  19. package/dist/cli/resume.js +367 -18
  20. package/dist/cli/resume.js.map +1 -1
  21. package/dist/cli/run.js +9 -0
  22. package/dist/cli/run.js.map +1 -1
  23. package/dist/cli/signal.js +34 -20
  24. package/dist/cli/signal.js.map +1 -1
  25. package/dist/core/orchestrator.d.ts +13 -1
  26. package/dist/core/orchestrator.js +396 -35
  27. package/dist/core/orchestrator.js.map +1 -1
  28. package/dist/core/reviewer.d.ts +2 -0
  29. package/dist/core/reviewer.js +24 -2
  30. package/dist/core/reviewer.js.map +1 -1
  31. package/dist/core/runner.d.ts +9 -3
  32. package/dist/core/runner.js +266 -61
  33. package/dist/core/runner.js.map +1 -1
  34. package/dist/utils/config.js +38 -1
  35. package/dist/utils/config.js.map +1 -1
  36. package/dist/utils/enhanced-logger.d.ts +210 -0
  37. package/dist/utils/enhanced-logger.js +1030 -0
  38. package/dist/utils/enhanced-logger.js.map +1 -0
  39. package/dist/utils/events.d.ts +59 -0
  40. package/dist/utils/events.js +37 -0
  41. package/dist/utils/events.js.map +1 -0
  42. package/dist/utils/git.d.ts +11 -0
  43. package/dist/utils/git.js +40 -0
  44. package/dist/utils/git.js.map +1 -1
  45. package/dist/utils/logger.d.ts +2 -0
  46. package/dist/utils/logger.js +4 -1
  47. package/dist/utils/logger.js.map +1 -1
  48. package/dist/utils/types.d.ts +132 -1
  49. package/dist/utils/webhook.d.ts +5 -0
  50. package/dist/utils/webhook.js +109 -0
  51. package/dist/utils/webhook.js.map +1 -0
  52. package/examples/README.md +1 -1
  53. package/package.json +2 -1
  54. package/scripts/patches/test-cursor-agent.js +1 -1
  55. package/scripts/simple-logging-test.sh +97 -0
  56. package/scripts/test-real-cursor-lifecycle.sh +289 -0
  57. package/scripts/test-real-logging.sh +289 -0
  58. package/scripts/test-streaming-multi-task.sh +247 -0
  59. package/src/cli/clean.ts +170 -13
  60. package/src/cli/index.ts +4 -1
  61. package/src/cli/logs.ts +863 -0
  62. package/src/cli/monitor.ts +123 -30
  63. package/src/cli/prepare.ts +1 -1
  64. package/src/cli/resume.ts +463 -22
  65. package/src/cli/run.ts +10 -0
  66. package/src/cli/signal.ts +43 -27
  67. package/src/core/orchestrator.ts +458 -36
  68. package/src/core/reviewer.ts +40 -4
  69. package/src/core/runner.ts +293 -60
  70. package/src/utils/config.ts +41 -1
  71. package/src/utils/enhanced-logger.ts +1166 -0
  72. package/src/utils/events.ts +117 -0
  73. package/src/utils/git.ts +40 -0
  74. package/src/utils/logger.ts +4 -1
  75. package/src/utils/types.ts +160 -1
  76. package/src/utils/webhook.ts +85 -0
package/src/cli/signal.ts CHANGED
@@ -13,6 +13,7 @@ import { appendLog, createConversationEntry } from '../utils/state';
13
13
  interface SignalOptions {
14
14
  lane: string | null;
15
15
  message: string | null;
16
+ timeout: number | null; // New timeout in milliseconds
16
17
  runDir: string | null;
17
18
  help: boolean;
18
19
  }
@@ -20,12 +21,14 @@ interface SignalOptions {
20
21
  function printHelp(): void {
21
22
  console.log(`
22
23
  Usage: cursorflow signal <lane> "<message>" [options]
24
+ cursorflow signal <lane> --timeout <ms>
23
25
 
24
- Directly intervene in a running lane by sending a message to the agent.
26
+ Directly intervene in a running lane.
25
27
 
26
28
  Options:
27
29
  <lane> Lane name to signal
28
- "<message>" Message text to send
30
+ "<message>" Message text to send to the agent
31
+ --timeout <ms> Update execution timeout (in milliseconds)
29
32
  --run-dir <path> Use a specific run directory (default: latest)
30
33
  --help, -h Show help
31
34
  `);
@@ -33,6 +36,7 @@ Options:
33
36
 
34
37
  function parseArgs(args: string[]): SignalOptions {
35
38
  const runDirIdx = args.indexOf('--run-dir');
39
+ const timeoutIdx = args.indexOf('--timeout');
36
40
 
37
41
  // First non-option is lane, second (or rest joined) is message
38
42
  const nonOptions = args.filter(a => !a.startsWith('--'));
@@ -40,6 +44,7 @@ function parseArgs(args: string[]): SignalOptions {
40
44
  return {
41
45
  lane: nonOptions[0] || null,
42
46
  message: nonOptions.slice(1).join(' ') || null,
47
+ timeout: timeoutIdx >= 0 ? parseInt(args[timeoutIdx + 1] || '0') || null : null,
43
48
  runDir: runDirIdx >= 0 ? args[runDirIdx + 1] || null : null,
44
49
  help: args.includes('--help') || args.includes('-h'),
45
50
  };
@@ -69,11 +74,7 @@ async function signal(args: string[]): Promise<void> {
69
74
  const logsDir = getLogsDir(config);
70
75
 
71
76
  if (!options.lane) {
72
- throw new Error('Lane name required: cursorflow signal <lane> "<message>"');
73
- }
74
-
75
- if (!options.message) {
76
- throw new Error('Message required: cursorflow signal <lane> "<message>"');
77
+ throw new Error('Lane name required: cursorflow signal <lane> ...');
77
78
  }
78
79
 
79
80
  let runDir = options.runDir;
@@ -84,27 +85,42 @@ async function signal(args: string[]): Promise<void> {
84
85
  if (!runDir || !fs.existsSync(runDir)) {
85
86
  throw new Error(`Run directory not found: ${runDir || 'latest'}`);
86
87
  }
87
-
88
- const convoPath = path.join(runDir, 'lanes', options.lane, 'conversation.jsonl');
89
-
90
- if (!fs.existsSync(convoPath)) {
91
- throw new Error(`Conversation log not found at ${convoPath}. Is the lane running?`);
88
+
89
+ const laneDir = path.join(runDir, 'lanes', options.lane);
90
+ if (!fs.existsSync(laneDir)) {
91
+ throw new Error(`Lane directory not found: ${laneDir}`);
92
92
  }
93
-
94
- logger.info(`Sending signal to lane: ${options.lane}`);
95
- logger.info(`Message: "${options.message}"`);
96
-
97
- // Append as a "commander" role message
98
- // Note: We cast to 'system' or similar if 'commander' isn't in the enum,
99
- // but let's use 'reviewer' or 'system' which agents usually respect,
100
- // or update the type definition.
101
- const entry = createConversationEntry('system', `[COMMANDER INTERVENTION]\n${options.message}`, {
102
- task: 'DIRECT_SIGNAL'
103
- });
104
-
105
- appendLog(convoPath, entry);
106
-
107
- logger.success('Signal sent successfully. The agent will see this message in its next turn or via file monitoring.');
93
+
94
+ // Case 1: Timeout update
95
+ if (options.timeout !== null) {
96
+ const timeoutPath = path.join(laneDir, 'timeout.txt');
97
+ fs.writeFileSync(timeoutPath, String(options.timeout));
98
+ logger.success(`Timeout update signal sent to ${options.lane}: ${options.timeout}ms`);
99
+ return;
100
+ }
101
+
102
+ // Case 2: Intervention message
103
+ if (options.message) {
104
+ const interventionPath = path.join(laneDir, 'intervention.txt');
105
+ const convoPath = path.join(laneDir, 'conversation.jsonl');
106
+
107
+ logger.info(`Sending signal to lane: ${options.lane}`);
108
+ logger.info(`Message: "${options.message}"`);
109
+
110
+ // 1. Write to intervention.txt for live agents to pick up immediately via stdin
111
+ fs.writeFileSync(interventionPath, options.message);
112
+
113
+ // 2. Also append to conversation log for visibility and history
114
+ const entry = createConversationEntry('system', `[COMMANDER INTERVENTION]\n${options.message}`, {
115
+ task: 'DIRECT_SIGNAL'
116
+ });
117
+ appendLog(convoPath, entry);
118
+
119
+ logger.success('Signal sent successfully. The agent will see this message in its current turn or next step.');
120
+ return;
121
+ }
122
+
123
+ throw new Error('Either a message or --timeout is required.');
108
124
  }
109
125
 
110
126
  export = signal;