Skip to content

Commit f637ba5

Browse files
khaliqgantclaude
andcommitted
fix: avoid /tmp directly for daemon state files
When socket is in /tmp, use /tmp/agent-relay-state/ subdirectory for teamDir. Fixes atomic write failures on macOS where temp file cleanup can remove files between write and rename operations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent e70740a commit f637ba5

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

packages/daemon/src/server.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,16 @@ export class Daemon {
142142
if (config.socketPath && !config.pidFilePath) {
143143
this.config.pidFilePath = `${config.socketPath}.pid`;
144144
}
145-
// Default teamDir to same directory as socket
145+
// Default teamDir to same directory as socket, but avoid /tmp directly
146+
// because macOS can clean temp files causing atomic write failures
146147
if (!this.config.teamDir) {
147-
this.config.teamDir = path.dirname(this.config.socketPath);
148+
const socketDir = path.dirname(this.config.socketPath);
149+
// If socket is in /tmp or /private/tmp, use a subdirectory
150+
if (socketDir === '/tmp' || socketDir === '/private/tmp') {
151+
this.config.teamDir = path.join(socketDir, 'agent-relay-state');
152+
} else {
153+
this.config.teamDir = socketDir;
154+
}
148155
}
149156
if (this.config.teamDir) {
150157
this.registry = new AgentRegistry(this.config.teamDir);

0 commit comments

Comments
 (0)