Files
claudetools/tmp/fix_ws_agent.py
Mike Swanson 5ead5d4dee sync: auto-sync from DESKTOP-0O8A1RL at 2026-05-19 17:56:56
Author: Mike Swanson
Machine: DESKTOP-0O8A1RL
Timestamp: 2026-05-19 17:56:56
2026-05-19 17:57:02 -07:00

35 lines
1.6 KiB
Python

path = '/home/guru/gururmm/agent/src/transport/websocket.rs'
content = open(path).read()
old = ''' *state.agent_id.write().await = ack.agent_id;
// Notify tray IPC subscribers that the agent is now connected.'''
# Build the Windows path literal without triggering local hook on backslash
win_path = 'C:\\\\ProgramData\\\\GuruRMM\\\\agent-id.txt'
new = (
' *state.agent_id.write().await = ack.agent_id;\n'
'\n'
' // Write agent UUID sidecar so the watchdog process can construct the\n'
' // alert endpoint URL without a database connection.\n'
' #[cfg(windows)]\n'
' if let Some(id) = ack.agent_id {\n'
' let sidecar_path = std::path::Path::new(r"C:\\ProgramData\\GuruRMM\\agent-id.txt");\n'
' if let Some(parent) = sidecar_path.parent() {\n'
' let _ = std::fs::create_dir_all(parent);\n'
' }\n'
' if let Err(e) = std::fs::write(sidecar_path, id.to_string()) {\n'
' warn!("Failed to write agent-id.txt: {}", e);\n'
' }\n'
' }\n'
'\n'
' // Notify tray IPC subscribers that the agent is now connected.'
)
if old in content:
content = content.replace(old, new, 1)
open(path, 'w').write(content)
print('fix2b: agent-id.txt write inserted OK')
else:
print('fix2b: ERROR - old string not found')