@dalmasonto/taskflow-mcp 1.0.28 → 1.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-registry.js +6 -9
- package/package.json +1 -1
package/dist/agent-registry.js
CHANGED
|
@@ -67,9 +67,12 @@ export function registerAgent(options) {
|
|
|
67
67
|
if (samePid && options?.customName && options.customName !== samePid.name) {
|
|
68
68
|
const oldName = samePid.name;
|
|
69
69
|
const newName = options.customName;
|
|
70
|
-
//
|
|
71
|
-
|
|
72
|
-
db.prepare('
|
|
70
|
+
// If the target name already exists as another row (disconnected from a previous session),
|
|
71
|
+
// delete it to free the UNIQUE name. Messages stay — they're linked by name string, not FK.
|
|
72
|
+
const existing = db.prepare('SELECT * FROM agent_registry WHERE name = ?').get(newName);
|
|
73
|
+
if (existing && existing.id !== samePid.id) {
|
|
74
|
+
db.prepare('DELETE FROM agent_registry WHERE id = ?').run(existing.id);
|
|
75
|
+
}
|
|
73
76
|
db.prepare('UPDATE agent_registry SET name = ?, tmux_pane = ?, connected_at = ? WHERE id = ?').run(newName, tmuxPane, ts, samePid.id);
|
|
74
77
|
const row = db.prepare('SELECT * FROM agent_registry WHERE id = ?').get(samePid.id);
|
|
75
78
|
broadcast('agent_renamed', { entity: 'agent', action: 'agent_renamed', payload: { ...row, oldName } });
|
|
@@ -93,12 +96,6 @@ export function registerAgent(options) {
|
|
|
93
96
|
|| (allDisconnected.length === 1 ? allDisconnected[0] : undefined);
|
|
94
97
|
if (disconnected) {
|
|
95
98
|
const newName = options?.customName || disconnected.name;
|
|
96
|
-
const renamed = newName !== disconnected.name;
|
|
97
|
-
// Update agent_messages if renaming to preserve history
|
|
98
|
-
if (renamed) {
|
|
99
|
-
db.prepare('UPDATE agent_messages SET sender_name = ? WHERE sender_name = ?').run(newName, disconnected.name);
|
|
100
|
-
db.prepare('UPDATE agent_messages SET recipient_name = ? WHERE recipient_name = ?').run(newName, disconnected.name);
|
|
101
|
-
}
|
|
102
99
|
db.prepare('UPDATE agent_registry SET name = ?, pid = ?, tmux_pane = ?, status = ?, connected_at = ?, disconnected_at = NULL WHERE id = ?').run(newName, agentPid, tmuxPane, 'connected', ts, disconnected.id);
|
|
103
100
|
const row = db.prepare('SELECT * FROM agent_registry WHERE id = ?').get(disconnected.id);
|
|
104
101
|
broadcast('agent_connected', { entity: 'agent', action: 'agent_connected', payload: row });
|