@comput/pi-intercom 0.4.2 → 0.5.1

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,4 +1,5 @@
1
1
  import type { ObservationSnapshot } from './snapshot.js';
2
+ import { currentConnection, sortWorkersByConnection } from './connections.js';
2
3
 
3
4
  const labels: Record<string, string> = {
4
5
  processing: 'Processing', thinking: 'Thinking', responding: 'Writing response',
@@ -46,15 +47,16 @@ export function workerStatusPage(snapshot: ObservationSnapshot, options: { name?
46
47
  roster = roster.filter(a => a.name.toLowerCase() === options.name!.toLowerCase());
47
48
  if (snapshot.config && !roster.length) throw new Error('Worker name not found in the retained snapshot');
48
49
  }
49
- const workers: Array<Record<string, unknown>> = [];
50
+ const workers: Array<{ sessionId: string; [key: string]: unknown }> = [];
50
51
  const result = { version: 1, source: 'local-observations', generatedAt: new Date(now).toISOString(),
51
- statusMeaning: 'Last observed, not live liveness or task completion. Reports are self-reported, not approval.',
52
+ statusMeaning: 'Activity is last observed, not task completion. Connectivity is a separate endpoint check, never proof of termination. Reports are self-reported, not approval.',
52
53
  truncated: snapshot.truncated, errors: snapshot.errors, totalInSnapshot: roster.length, offset,
53
54
  nextOffset: null as number | null, workers };
54
55
  for (const agent of roster.slice(offset, offset + limit)) {
55
56
  const report = snapshot.reports?.find(r => r.sessionId === agent.sessionId && r.status !== 'clear');
56
57
  const reportAge = report ? now - Date.parse(report.updatedAt) : NaN;
57
58
  const entry = { sessionId: agent.sessionId, name: agent.name, ...workerObservation(snapshot, agent.sessionId, now),
59
+ connection: currentConnection(agent.sessionId, snapshot.connections, now),
58
60
  report: report ? { status: report.status, summary: report.summary, updatedAt: report.updatedAt,
59
61
  ageSeconds: Number.isFinite(reportAge) && reportAge >= 0 ? Math.floor(reportAge / 1000) : null,
60
62
  selfReported: true } : null };
@@ -62,5 +64,7 @@ export function workerStatusPage(snapshot: ObservationSnapshot, options: { name?
62
64
  if (Buffer.byteLength(JSON.stringify(result, null, 2)) > 40000) { workers.pop(); break; }
63
65
  }
64
66
  if (offset + workers.length < roster.length) result.nextOffset = offset + workers.length;
67
+ // Page boundaries remain in saved roster order; disconnected entries sort last within the page.
68
+ workers.splice(0, workers.length, ...sortWorkersByConnection(workers, snapshot.connections, now));
65
69
  return result;
66
70
  }