-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreload.js
More file actions
396 lines (340 loc) · 12 KB
/
preload.js
File metadata and controls
396 lines (340 loc) · 12 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
const { contextBridge, ipcRenderer } = require('electron');
// Expose protected methods that allow the renderer process to use
// the ipcRenderer without exposing the entire object
contextBridge.exposeInMainWorld('electronAPI', {
// System info
platform: process.platform,
versions: {
node: process.versions.node,
chrome: process.versions.chrome,
electron: process.versions.electron
},
// ============================================
// Agents API
// ============================================
/**
* Get all agents from all providers
* @returns {Promise<{agents: Array, errors: Array, counts: Object}>}
*/
getAgents: () => ipcRenderer.invoke('agents:get-all'),
/**
* Get detailed information for a specific agent
* @param {string} provider - 'gemini', 'jules', or 'cursor'
* @param {string} rawId - The provider's native ID
* @param {string} [filePath] - For Gemini, the path to the session file
*/
getAgentDetails: (provider, rawId, filePath) =>
ipcRenderer.invoke('agents:get-details', { provider, rawId, filePath }),
// ============================================
// Settings API
// ============================================
/**
* Get all settings and API key status
*/
getSettings: () => ipcRenderer.invoke('settings:get'),
/**
* Set an API key for a provider
* @param {string} provider - 'jules' or 'cursor'
* @param {string} key - The API key
*/
setApiKey: (provider, key) =>
ipcRenderer.invoke('settings:set-api-key', { provider, key }),
/**
* Set Jira Base URL
* @param {string} url
*/
setJiraBaseUrl: (url) =>
ipcRenderer.invoke('settings:set-jira-base-url', { url }),
/**
* Test if an API key is valid
* @param {string} provider - 'jules' or 'cursor'
*/
testApiKey: (provider) =>
ipcRenderer.invoke('settings:test-api-key', { provider }),
/**
* Remove an API key for a provider (disconnect)
* @param {string} provider - 'jules', 'cursor', 'codex', or 'claude'
*/
removeApiKey: (provider) =>
ipcRenderer.invoke('settings:remove-api-key', { provider }),
// ============================================
// Cloudflare KV / Computers API
// ============================================
/**
* Save Cloudflare KV config (Account ID + API token)
*/
setCloudflareConfig: (accountId, apiToken, namespaceTitle) =>
ipcRenderer.invoke('cloudflare:set-config', { accountId, apiToken, namespaceTitle }),
/**
* Clear Cloudflare KV config
*/
clearCloudflareConfig: () =>
ipcRenderer.invoke('cloudflare:clear-config'),
/**
* Test Cloudflare KV connectivity and ensure namespace
*/
testCloudflare: () =>
ipcRenderer.invoke('cloudflare:test'),
/**
* List computers (devices) stored in Cloudflare KV
*/
listComputers: () =>
ipcRenderer.invoke('computers:list'),
/**
* Push all local keys to Cloudflare KV
*/
pushKeysToCloudflare: () =>
ipcRenderer.invoke('cloudflare:push-keys'),
/**
* Pull all keys from Cloudflare KV to local storage
*/
pullKeysFromCloudflare: () =>
ipcRenderer.invoke('cloudflare:pull-keys'),
/**
* Update polling settings
* @param {boolean} [enabled] - Whether auto-polling is enabled
* @param {number} [interval] - Polling interval in milliseconds
*/
setPolling: (enabled, interval) =>
ipcRenderer.invoke('settings:set-polling', { enabled, interval }),
/**
* Set application theme
* @param {string} theme - 'system', 'light', or 'dark'
*/
setTheme: (theme) =>
ipcRenderer.invoke('settings:set-theme', { theme }),
/**
* Set display mode
* @param {string} mode - 'fullscreen' or 'windowed'
*/
setDisplayMode: (mode) =>
ipcRenderer.invoke('settings:set-display-mode', { mode }),
/**
* Save filter settings
* @param {object} filters
*/
saveFilters: (filters) =>
ipcRenderer.invoke('settings:save-filters', { filters }),
/**
* Set selected model
* @param {string} model
*/
setModel: (model) =>
ipcRenderer.invoke('settings:set-model', { model }),
/**
* Add a Gemini project path to scan
* @param {string} path
*/
addGeminiPath: (path) =>
ipcRenderer.invoke('settings:add-gemini-path', { path }),
/**
* Remove a Gemini project path
* @param {string} path
*/
removeGeminiPath: (path) =>
ipcRenderer.invoke('settings:remove-gemini-path', { path }),
/**
* Get Gemini paths configuration
*/
getGeminiPaths: () =>
ipcRenderer.invoke('settings:get-gemini-paths'),
/**
* Add a Claude project path
* @param {string} path
*/
addClaudePath: (path) =>
ipcRenderer.invoke('settings:add-claude-path', { path }),
/**
* Remove a Claude project path
* @param {string} path
*/
removeClaudePath: (path) =>
ipcRenderer.invoke('settings:remove-claude-path', { path }),
/**
* Get Claude paths configuration
*/
getClaudePaths: () =>
ipcRenderer.invoke('settings:get-claude-paths'),
/**
* Add a Cursor project path
* @param {string} path
*/
addCursorPath: (path) =>
ipcRenderer.invoke('settings:add-cursor-path', { path }),
/**
* Remove a Cursor project path
* @param {string} path
*/
removeCursorPath: (path) =>
ipcRenderer.invoke('settings:remove-cursor-path', { path }),
/**
* Get Cursor paths configuration
*/
getCursorPaths: () =>
ipcRenderer.invoke('settings:get-cursor-paths'),
/**
* Add a Codex project path
* @param {string} path
*/
addCodexPath: (path) =>
ipcRenderer.invoke('settings:add-codex-path', { path }),
/**
* Remove a Codex project path
* @param {string} path
*/
removeCodexPath: (path) =>
ipcRenderer.invoke('settings:remove-codex-path', { path }),
/**
* Get Codex paths configuration
*/
getCodexPaths: () =>
ipcRenderer.invoke('settings:get-codex-paths'),
/**
* Add a GitHub repository path
* @param {string} path
*/
addGithubPath: (path) =>
ipcRenderer.invoke('settings:add-github-path', { path }),
/**
* Remove a GitHub repository path
* @param {string} path
*/
removeGithubPath: (path) =>
ipcRenderer.invoke('settings:remove-github-path', { path }),
/**
* Get GitHub repository paths
*/
getGithubPaths: () =>
ipcRenderer.invoke('settings:get-github-paths'),
/**
* Get all project paths (combined Gemini + GitHub)
*/
getAllProjectPaths: () =>
ipcRenderer.invoke('settings:get-all-project-paths'),
/**
* Update the application (git pull + restart)
*/
updateApp: () =>
ipcRenderer.invoke('app:update'),
// ============================================
// Utilities API
// ============================================
/**
* Open a URL in the default browser
* @param {string} url
*/
openExternal: (url) =>
ipcRenderer.invoke('utils:open-external', { url }),
/**
* Open a directory selection dialog
* @returns {Promise<string|null>} The selected path or null if canceled
*/
openDirectory: () => ipcRenderer.invoke('dialog:open-directory'),
/**
* Get connection status for all providers
*/
getConnectionStatus: () =>
ipcRenderer.invoke('utils:get-status'),
// ============================================
// Task Creation API
// ============================================
/**
* Get available repositories for a specific provider
* @param {string} provider - 'gemini', 'jules', or 'cursor'
*/
getRepositories: (provider) =>
ipcRenderer.invoke('repos:get', { provider }),
/**
* Get repositories from all configured providers
*/
getAllRepositories: () =>
ipcRenderer.invoke('repos:get-all'),
/**
* Create a new task/session
* @param {string} provider - 'gemini', 'jules', 'cursor', 'codex', 'claude-cli', 'claude-cloud'
* @param {object} options - Provider-specific options
* @param {string} options.prompt - Task description
* @param {string} [options.repository] - Repository URL, source name, or path
* @param {string} [options.projectPath] - For remote tasks, repository path
* @param {string} [options.targetDeviceId] - For remote execution, target device ID
* @param {string} [options.branch] - Branch name (defaults to 'main')
* @param {boolean} [options.autoCreatePr] - Auto-create PR (defaults to true)
*/
createTask: (provider, options) =>
ipcRenderer.invoke('tasks:create', { provider, options }),
/**
* Send a follow-up message to a task
* @param {string} provider - 'jules' or 'cursor'
* @param {string} rawId - The provider's native ID
* @param {string} message - The message content
*/
sendMessage: (provider, rawId, message) =>
ipcRenderer.invoke('tasks:send-message', { provider, rawId, message }),
/**
* Get available models for the Orchestrator
*/
orchestratorGetModels: () =>
ipcRenderer.invoke('orchestrator:get-models'),
/**
* Send a message to the Agent Orchestrator
* @param {Array} messages - Chat history
* @param {string} selectedModel - Selected model identifier
*/
orchestratorChat: (messages, selectedModel) =>
ipcRenderer.invoke('orchestrator:chat', { messages, selectedModel }),
// ============================================
// Events API
// ============================================
/**
* Listen for refresh tick events from polling
* @param {Function} callback
* @returns {Function} Unsubscribe function
*/
onRefreshTick: (callback) => {
const subscription = (event) => callback();
ipcRenderer.on('agents:refresh-tick', subscription);
return () => {
ipcRenderer.removeListener('agents:refresh-tick', subscription);
};
},
// ============================================
// GitHub API
// ============================================
github: {
getRepos: () => ipcRenderer.invoke('github:get-repos'),
getAllPrs: () => ipcRenderer.invoke('github:get-all-prs'),
getPrs: (owner, repo, state) => ipcRenderer.invoke('github:get-prs', { owner, repo, state }),
getBranches: (owner, repo) => ipcRenderer.invoke('github:get-branches', { owner, repo }),
getOwners: () => ipcRenderer.invoke('github:get-owners'),
getPrDetails: (owner, repo, prNumber) => ipcRenderer.invoke('github:get-pr-details', { owner, repo, prNumber }),
getRepoFile: (owner, repo, path) => ipcRenderer.invoke('github:get-repo-file', { owner, repo, path }),
mergePr: (owner, repo, prNumber, method) => ipcRenderer.invoke('github:merge-pr', { owner, repo, prNumber, method }),
closePr: (owner, repo, prNumber) => ipcRenderer.invoke('github:close-pr', { owner, repo, prNumber }),
markPrReadyForReview: (nodeId) => ipcRenderer.invoke('github:mark-pr-ready-for-review', { nodeId }),
createRepo: ({ ownerType, owner, name, private: isPrivate }) =>
ipcRenderer.invoke('github:create-repo', { ownerType, owner, name, private: isPrivate })
},
// ============================================
// Jira API
// ============================================
jira: {
getBoards: () => ipcRenderer.invoke('jira:get-boards'),
getSprints: (boardId) => ipcRenderer.invoke('jira:get-sprints', { boardId }),
getBacklogIssues: (boardId) => ipcRenderer.invoke('jira:get-backlog-issues', { boardId }),
getSprintIssues: (sprintId) => ipcRenderer.invoke('jira:get-sprint-issues', { sprintId }),
getIssue: (issueKey) => ipcRenderer.invoke('jira:get-issue', { issueKey }),
getIssueComments: (issueKey) => ipcRenderer.invoke('jira:get-issue-comments', { issueKey })
},
// ============================================
// Projects / Repositories API
// ============================================
projects: {
createLocalRepo: ({ name, directory }) =>
ipcRenderer.invoke('projects:create-local-repo', { name, directory }),
enqueueCreateRepo: ({ deviceId, name }) =>
ipcRenderer.invoke('projects:enqueue-create-repo', { deviceId, name }),
getLocalRepos: () => ipcRenderer.invoke('projects:get-local'),
getRepoFile: (path, fileName) => ipcRenderer.invoke('projects:get-repo-file', { path, fileName }),
pullRepo: (path) => ipcRenderer.invoke('projects:pull-repo', { path })
}
});