-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpreload.js
More file actions
69 lines (60 loc) · 2.18 KB
/
Copy pathpreload.js
File metadata and controls
69 lines (60 loc) · 2.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
/**
* Preload script for AgentPeeper
* Exposes a safe API to the renderer process via contextBridge
*/
const { contextBridge, ipcRenderer } = require('electron');
// Whitelist of allowed IPC channels
const validChannels = [
'check-setup',
'run-setup',
'run-uninstall',
'read-sessions',
'read-cc-sessions-fs',
'read-transcript',
'read-pi-sessions',
'read-pi-transcript'
];
contextBridge.exposeInMainWorld('api', {
/**
* Check if monitoring hooks are set up
* @returns {Promise<{claudeDirExists: boolean, scriptExists: boolean, hooksConfigured: boolean, details: object}>}
*/
checkSetup: () => ipcRenderer.invoke('check-setup'),
/**
* Install monitoring hooks and script
* @returns {Promise<{success: boolean, steps: string[], error?: string}>}
*/
runSetup: () => ipcRenderer.invoke('run-setup'),
/**
* Uninstall monitoring hooks and clean up
* @returns {Promise<{success: boolean, steps: string[], error?: string}>}
*/
runUninstall: () => ipcRenderer.invoke('run-uninstall'),
/**
* Read the active sessions registry
* @returns {Promise<string>} JSON string of active sessions array
*/
readSessions: () => ipcRenderer.invoke('read-sessions'),
/**
* Discover CC sessions via filesystem (works for headless -p mode)
* @returns {Promise<string>} JSON string of discovered CC sessions array
*/
readCcSessionsFs: () => ipcRenderer.invoke('read-cc-sessions-fs'),
/**
* Read a transcript file by relative path
* @param {string} relativePath - Path relative to ~/.claude/
* @returns {Promise<string>} Transcript file contents
*/
readTranscript: (relativePath) => ipcRenderer.invoke('read-transcript', relativePath),
/**
* Read active pi coding agent sessions (discovered via filesystem)
* @returns {Promise<string>} JSON string of active pi sessions array
*/
readPiSessions: () => ipcRenderer.invoke('read-pi-sessions'),
/**
* Read a pi session transcript file by relative path
* @param {string} relativePath - Path relative to ~/.pi/agent/sessions/
* @returns {Promise<string>} Transcript file contents
*/
readPiTranscript: (relativePath) => ipcRenderer.invoke('read-pi-transcript', relativePath)
});