@siftd/connect-agent 0.2.43 → 0.2.44

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.
@@ -188,32 +188,39 @@ export class CalendarTools {
188
188
  }
189
189
  normalizeTodoItems(inputItems, existingItems) {
190
190
  const existingById = new Map(existingItems.map((item) => [item.id, item]));
191
- const seenKey = new Set(existingItems.map((item) => item.title.trim().toLowerCase()));
191
+ const titleToId = new Map(existingItems.map((item) => [item.title.trim().toLowerCase(), item.id]));
192
192
  for (const rawItem of inputItems) {
193
193
  if (!rawItem || typeof rawItem.title !== 'string' || !rawItem.title.trim())
194
194
  continue;
195
195
  const title = rawItem.title.trim();
196
- const id = typeof rawItem.id === 'string' && rawItem.id.trim()
196
+ const titleKey = title.toLowerCase();
197
+ const existingId = titleToId.get(titleKey);
198
+ const requestedId = typeof rawItem.id === 'string' && rawItem.id.trim()
197
199
  ? rawItem.id.trim()
198
- : stableId('todo', [title, rawItem.due]);
199
- const priority = rawItem.priority === 'low' || rawItem.priority === 'high' ? rawItem.priority : 'medium';
200
- const due = typeof rawItem.due === 'string' && rawItem.due.trim() ? rawItem.due.trim() : undefined;
201
- const notes = typeof rawItem.notes === 'string' && rawItem.notes.trim() ? rawItem.notes.trim() : undefined;
200
+ : undefined;
201
+ const fallbackId = stableId('todo', [title, rawItem.due]);
202
+ const id = requestedId || existingId || fallbackId;
203
+ const previous = existingById.get(id) || (existingId ? existingById.get(existingId) : undefined);
204
+ const resolvedId = previous?.id || id;
205
+ const priority = rawItem.priority === 'low' || rawItem.priority === 'high'
206
+ ? rawItem.priority
207
+ : previous?.priority || 'medium';
208
+ const due = typeof rawItem.due === 'string' && rawItem.due.trim() ? rawItem.due.trim() : previous?.due;
209
+ const notes = typeof rawItem.notes === 'string' && rawItem.notes.trim() ? rawItem.notes.trim() : previous?.notes;
202
210
  const incomingSubtasks = Array.isArray(rawItem.subtasks)
203
211
  ? rawItem.subtasks
204
212
  .filter((subtask) => subtask && typeof subtask.title === 'string' && subtask.title.trim())
205
213
  .map((subtask, index) => ({
206
214
  id: typeof subtask.id === 'string' && subtask.id.trim()
207
215
  ? subtask.id.trim()
208
- : stableId('subtask', [id, subtask.title.trim(), String(index)]),
216
+ : stableId('subtask', [resolvedId, subtask.title.trim(), String(index)]),
209
217
  title: subtask.title.trim(),
210
218
  done: Boolean(subtask.done),
211
219
  notes: typeof subtask.notes === 'string' && subtask.notes.trim() ? subtask.notes.trim() : undefined,
212
220
  }))
213
221
  : undefined;
214
- const previous = existingById.get(id);
215
222
  const subtasks = incomingSubtasks || previous?.subtasks;
216
- let done = Boolean(rawItem.done);
223
+ let done = typeof rawItem.done === 'boolean' ? rawItem.done : (previous?.done ?? false);
217
224
  if (incomingSubtasks && incomingSubtasks.length > 0) {
218
225
  done = incomingSubtasks.every((subtask) => subtask.done);
219
226
  }
@@ -222,11 +229,11 @@ export class CalendarTools {
222
229
  for (const subtask of previous.subtasks)
223
230
  subtask.done = true;
224
231
  }
225
- const key = title.toLowerCase();
226
- if (seenKey.has(key) && !existingById.has(id))
227
- continue;
228
- seenKey.add(key);
229
- existingById.set(id, { id, title, done, due, priority, notes, subtasks });
232
+ if (previous && previous.id !== resolvedId) {
233
+ existingById.delete(previous.id);
234
+ }
235
+ existingById.set(resolvedId, { id: resolvedId, title, done, due, priority, notes, subtasks });
236
+ titleToId.set(titleKey, resolvedId);
230
237
  }
231
238
  return Array.from(existingById.values());
232
239
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@siftd/connect-agent",
3
- "version": "0.2.43",
3
+ "version": "0.2.44",
4
4
  "description": "Master orchestrator agent - control Claude Code remotely via web",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",