(state: SessionState)
| 546 | * across the server.ts / sidebar-agent.ts process boundary. |
| 547 | */ |
| 548 | export function writeSessionState(state: SessionState): void { |
| 549 | try { |
| 550 | mkdirSecure(SECURITY_DIR); |
| 551 | const tmp = `${STATE_FILE}.tmp.${process.pid}`; |
| 552 | writeSecureFile(tmp, JSON.stringify(state, null, 2)); |
| 553 | fs.renameSync(tmp, STATE_FILE); |
| 554 | } catch (err) { |
| 555 | console.error('[security] writeSessionState failed:', (err as Error).message); |
| 556 | } |
| 557 | } |
| 558 | |
| 559 | export function readSessionState(): SessionState | null { |
| 560 | try { |
no test coverage detected