forked from doctly/switchboard
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreload.js
More file actions
134 lines (121 loc) · 6.92 KB
/
Copy pathpreload.js
File metadata and controls
134 lines (121 loc) · 6.92 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
const { contextBridge, ipcRenderer, webUtils } = require('electron');
contextBridge.exposeInMainWorld('api', {
// Invoke (request-response)
getPlans: () => ipcRenderer.invoke('get-plans'),
readPlan: (filename) => ipcRenderer.invoke('read-plan', filename),
savePlan: (filePath, content) => ipcRenderer.invoke('save-plan', filePath, content),
getStats: () => ipcRenderer.invoke('get-stats'),
refreshStats: () => ipcRenderer.invoke('refresh-stats'),
getUsage: () => ipcRenderer.invoke('get-usage'),
getMemories: () => ipcRenderer.invoke('get-memories'),
readMemory: (filePath) => ipcRenderer.invoke('read-memory', filePath),
saveMemory: (filePath, content) => ipcRenderer.invoke('save-memory', filePath, content),
getProjects: (showArchived) => ipcRenderer.invoke('get-projects', showArchived),
getActiveSessions: () => ipcRenderer.invoke('get-active-sessions'),
getActiveTerminals: () => ipcRenderer.invoke('get-active-terminals'),
stopSession: (id) => ipcRenderer.invoke('stop-session', id),
toggleStar: (id) => ipcRenderer.invoke('toggle-star', id),
renameSession: (id, name) => ipcRenderer.invoke('rename-session', id, name),
archiveSession: (id, archived) => ipcRenderer.invoke('archive-session', id, archived),
openTerminal: (id, projectPath, isNew, sessionOptions) => ipcRenderer.invoke('open-terminal', id, projectPath, isNew, sessionOptions),
search: (type, query, titleOnly) => ipcRenderer.invoke('search', type, query, titleOnly),
readSessionJsonl: (sessionId) => ipcRenderer.invoke('read-session-jsonl', sessionId),
getSessionTokens: (sessionId) => ipcRenderer.invoke('get-session-tokens', sessionId),
// Settings
getSetting: (key) => ipcRenderer.invoke('get-setting', key),
setSetting: (key, value) => ipcRenderer.invoke('set-setting', key, value),
deleteSetting: (key) => ipcRenderer.invoke('delete-setting', key),
getEffectiveSettings: (projectPath) => ipcRenderer.invoke('get-effective-settings', projectPath),
getScheduleCreatorCommand: () => ipcRenderer.invoke('get-schedule-creator-command'),
createScheduleSession: (projectPath) => ipcRenderer.invoke('create-schedule-session', projectPath),
runScheduleNow: (filePath) => ipcRenderer.invoke('run-schedule-now', filePath),
getShellProfiles: () => ipcRenderer.invoke('get-shell-profiles'),
// Remote SSH hosts + projects
getRemoteTargets: () => ipcRenderer.invoke('get-remote-targets'),
saveRemoteHosts: (hosts) => ipcRenderer.invoke('save-remote-hosts', hosts),
testRemoteHost: (hostId) => ipcRenderer.invoke('test-remote-host', hostId),
addRemoteProject: (opts) => ipcRenderer.invoke('add-remote-project', opts),
syncRemoteHost: (hostId) => ipcRenderer.invoke('sync-remote-host', hostId),
remoteBrowse: (opts) => ipcRenderer.invoke('remote-browse', opts),
writeSshConfig: (host) => ipcRenderer.invoke('write-ssh-config', host),
remoteConnectStart: (hostId) => ipcRenderer.invoke('remote-connect-start', hostId),
remoteConnectInput: (connectId, data) => ipcRenderer.send('remote-connect-input', connectId, data),
remoteConnectCancel: (connectId) => ipcRenderer.invoke('remote-connect-cancel', connectId),
onRemoteConnectData: (callback) => ipcRenderer.on('remote-connect-data', (_e, id, data) => callback(id, data)),
onRemoteConnectExit: (callback) => ipcRenderer.on('remote-connect-exit', (_e, id, code) => callback(id, code)),
browseFolder: () => ipcRenderer.invoke('browse-folder'),
addProject: (projectPath) => ipcRenderer.invoke('add-project', projectPath),
removeProject: (projectPath) => ipcRenderer.invoke('remove-project', projectPath),
openExternal: (url) => ipcRenderer.invoke('open-external', url),
// Send (fire-and-forget)
sendInput: (id, data) => ipcRenderer.send('terminal-input', id, data),
resizeTerminal: (id, cols, rows) => ipcRenderer.send('terminal-resize', id, cols, rows),
closeTerminal: (id) => ipcRenderer.send('close-terminal', id),
// Agent status hooks
agentHooksHealth: () => ipcRenderer.invoke('agent-hooks-health'),
agentHooksRefresh: () => ipcRenderer.invoke('agent-hooks-refresh'),
agentHooksTest: () => ipcRenderer.invoke('agent-hooks-test'),
agentHooksLog: () => ipcRenderer.invoke('agent-hooks-log'),
// Listeners (main → renderer)
onTerminalData: (callback) => {
ipcRenderer.on('terminal-data', (_event, sessionId, data) => callback(sessionId, data));
},
onSessionDetected: (callback) => {
ipcRenderer.on('session-detected', (_event, tempId, realId) => callback(tempId, realId));
},
onProcessExited: (callback) => {
ipcRenderer.on('process-exited', (_event, sessionId, exitCode) => callback(sessionId, exitCode));
},
onTerminalNotification: (callback) => {
ipcRenderer.on('terminal-notification', (_event, sessionId, message) => callback(sessionId, message));
},
onCliBusyState: (callback) => {
ipcRenderer.on('cli-busy-state', (_event, sessionId, busy) => callback(sessionId, busy));
},
onSessionForked: (callback) => {
ipcRenderer.on('session-forked', (_event, oldId, newId) => callback(oldId, newId));
},
onProjectsChanged: (callback) => {
ipcRenderer.on('projects-changed', () => callback());
},
onStatusUpdate: (callback) => {
ipcRenderer.on('status-update', (_event, text, type) => callback(text, type));
},
// File drag-and-drop
getPathForFile: (file) => webUtils.getPathForFile(file),
// Platform
platform: process.platform,
// App version
getAppVersion: () => ipcRenderer.invoke('get-app-version'),
// Auto-updater
updaterCheck: () => ipcRenderer.invoke('updater-check'),
updaterDownload: () => ipcRenderer.invoke('updater-download'),
updaterInstall: () => ipcRenderer.invoke('updater-install'),
onUpdaterEvent: (callback) => {
ipcRenderer.on('updater-event', (_event, type, data) => callback(type, data));
},
// MCP bridge (main → renderer)
onMcpOpenDiff: (callback) => {
ipcRenderer.on('mcp-open-diff', (_event, sessionId, diffId, data) => callback(sessionId, diffId, data));
},
onMcpOpenFile: (callback) => {
ipcRenderer.on('mcp-open-file', (_event, sessionId, data) => callback(sessionId, data));
},
onMcpCloseAllDiffs: (callback) => {
ipcRenderer.on('mcp-close-all-diffs', (_event, sessionId) => callback(sessionId));
},
onMcpCloseTab: (callback) => {
ipcRenderer.on('mcp-close-tab', (_event, sessionId, diffId) => callback(sessionId, diffId));
},
// MCP bridge (renderer → main)
mcpDiffResponse: (sessionId, diffId, action, editedContent) => {
ipcRenderer.send('mcp-diff-response', sessionId, diffId, action, editedContent);
},
readFileForPanel: (filePath) => ipcRenderer.invoke('read-file-for-panel', filePath),
saveFileForPanel: (filePath, content) => ipcRenderer.invoke('save-file-for-panel', filePath, content),
watchFile: (filePath) => ipcRenderer.invoke('watch-file', filePath),
unwatchFile: (filePath) => ipcRenderer.invoke('unwatch-file', filePath),
onFileChanged: (callback) => {
ipcRenderer.on('file-changed', (_event, filePath) => callback(filePath));
},
});