forked from RunMaestro/Maestro
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcue.ts
More file actions
115 lines (93 loc) · 4.18 KB
/
Copy pathcue.ts
File metadata and controls
115 lines (93 loc) · 4.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/**
* Preload API for Cue operations
*
* Provides the window.maestro.cue namespace for:
* - Engine status and activity log queries
* - Runtime engine controls (enable/disable)
* - Run management (stop individual or all)
* - YAML configuration management (read, write, validate)
* - Real-time activity updates via event listener
*/
import { ipcRenderer } from 'electron';
import type {
CueGraphSession,
CueRunResult,
CueSessionStatus,
CueSettings,
} from '../../shared/cue';
export type {
CueEvent,
CueEventType,
CueGraphSession,
CueRunResult,
CueRunStatus,
CueSessionStatus,
CueSettings,
} from '../../shared/cue';
/**
* Creates the Cue API object for preload exposure
*/
export function createCueApi() {
return {
// Get global Cue settings (timeout, concurrency, queue)
getSettings: (): Promise<CueSettings> => ipcRenderer.invoke('cue:getSettings'),
// Get status of all Cue-enabled sessions
getStatus: (): Promise<CueSessionStatus[]> => ipcRenderer.invoke('cue:getStatus'),
// Get all sessions with their subscriptions (for graph visualization)
getGraphData: (): Promise<CueGraphSession[]> => ipcRenderer.invoke('cue:getGraphData'),
// Get currently active Cue runs
getActiveRuns: (): Promise<CueRunResult[]> => ipcRenderer.invoke('cue:getActiveRuns'),
// Get activity log (recent completed/failed runs)
getActivityLog: (limit?: number): Promise<CueRunResult[]> =>
ipcRenderer.invoke('cue:getActivityLog', { limit }),
// Enable the Cue engine (runtime control)
enable: (): Promise<void> => ipcRenderer.invoke('cue:enable'),
// Disable the Cue engine (runtime control)
disable: (): Promise<void> => ipcRenderer.invoke('cue:disable'),
// Stop a specific running Cue execution
stopRun: (runId: string): Promise<boolean> => ipcRenderer.invoke('cue:stopRun', { runId }),
// Stop all running Cue executions
stopAll: (): Promise<void> => ipcRenderer.invoke('cue:stopAll'),
// Manually trigger a subscription by name (Run Now), with optional prompt override
triggerSubscription: (subscriptionName: string, prompt?: string): Promise<boolean> =>
ipcRenderer.invoke('cue:triggerSubscription', { subscriptionName, prompt }),
// Get queue status per session
getQueueStatus: (): Promise<Record<string, number>> => ipcRenderer.invoke('cue:getQueueStatus'),
// Refresh a session's Cue configuration
refreshSession: (sessionId: string, projectRoot: string): Promise<void> =>
ipcRenderer.invoke('cue:refreshSession', { sessionId, projectRoot }),
// Remove a session from Cue tracking
removeSession: (sessionId: string): Promise<void> =>
ipcRenderer.invoke('cue:removeSession', { sessionId }),
// Read raw YAML content from a session's maestro-cue.yaml
readYaml: (projectRoot: string): Promise<string | null> =>
ipcRenderer.invoke('cue:readYaml', { projectRoot }),
// Write YAML content to a session's maestro-cue.yaml (with optional external prompt files)
writeYaml: (
projectRoot: string,
content: string,
promptFiles?: Record<string, string>
): Promise<void> => ipcRenderer.invoke('cue:writeYaml', { projectRoot, content, promptFiles }),
// Delete a session's cue.yaml config file
deleteYaml: (projectRoot: string): Promise<boolean> =>
ipcRenderer.invoke('cue:deleteYaml', { projectRoot }),
// Validate YAML content as a Cue configuration
validateYaml: (content: string): Promise<{ valid: boolean; errors: string[] }> =>
ipcRenderer.invoke('cue:validateYaml', { content }),
// Save pipeline layout (node positions, viewport, pipeline selection)
savePipelineLayout: (layout: Record<string, unknown>): Promise<void> =>
ipcRenderer.invoke('cue:savePipelineLayout', { layout }),
// Load saved pipeline layout
loadPipelineLayout: (): Promise<Record<string, unknown> | null> =>
ipcRenderer.invoke('cue:loadPipelineLayout'),
// Listen for real-time activity updates from the main process
onActivityUpdate: (callback: (data: CueRunResult) => void): (() => void) => {
const handler = (_e: unknown, data: CueRunResult) => callback(data);
ipcRenderer.on('cue:activityUpdate', handler);
return () => {
ipcRenderer.removeListener('cue:activityUpdate', handler);
};
},
};
}
export type CueApi = ReturnType<typeof createCueApi>;