agents-relay 2.0.91 → 2.0.92

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.
@@ -1,3 +1,4 @@
1
+ import { preserveTaskComments } from './task-comments.js';
1
2
  import { DatabaseSync } from 'node:sqlite';
2
3
  import { dirname } from 'node:path';
3
4
  import { mkdirSync } from 'node:fs';
@@ -23,7 +24,7 @@ function mergeRecords(local, remote) {
23
24
  }
24
25
  export function mergeInboundJobSnapshot(local, remote) {
25
26
  const base = remote.updatedAt > local.updatedAt ? structuredClone(remote) : structuredClone(local);
26
- base.tasks = mergeRecords(local.tasks, remote.tasks);
27
+ base.tasks = preserveTaskComments(local.tasks, mergeRecords(local.tasks, remote.tasks));
27
28
  const localPlans = local.plans ?? [];
28
29
  const remotePlans = remote.plans ?? [];
29
30
  if (localPlans.length > 0 || remotePlans.length > 0) {
@@ -14,3 +14,18 @@ export function taskCommentContext(task) {
14
14
  return '';
15
15
  return '\n\n[Task comments — append-only supplementary context]\n' + task.comments.map(c => `${c.createdAt} (${c.author}, ${c.id}): ${c.text}`).join('\n');
16
16
  }
17
+ /** Preserve append-only comments across stale external or lifecycle snapshots. */
18
+ export function preserveTaskComments(previous, incoming) {
19
+ return incoming.map(task => {
20
+ const old = previous.find(item => item.id === task.id);
21
+ if (!old?.comments?.length)
22
+ return task;
23
+ const comments = [...old.comments], known = new Set(comments.map(comment => comment.id));
24
+ for (const comment of task.comments ?? [])
25
+ if (!known.has(comment.id)) {
26
+ comments.push(comment);
27
+ known.add(comment.id);
28
+ }
29
+ return { ...task, comments };
30
+ });
31
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agents-relay",
3
- "version": "2.0.91",
3
+ "version": "2.0.92",
4
4
  "description": "Durable async agent jobs coordinated through GitHub pull requests",
5
5
  "type": "module",
6
6
  "bin": {