@volter/teams 0.1.73 → 0.1.74
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/package.json +1 -1
- package/session-follow.mjs +24 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volter/teams",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.74",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Volter Teams, the neutral team plane: machine identity and daemon core, the local door and server link, admission from machine grants, product doors, and the Teams server's neutral routes (company RFC 0008).",
|
|
6
6
|
"license": "MIT",
|
package/session-follow.mjs
CHANGED
|
@@ -210,19 +210,36 @@ export function withPeople(transcript, messages, { agentName = null, sessionId =
|
|
|
210
210
|
export function withMail(transcript, rows, { agentName = 'This session', agentId = '', agentImage: picture = agentImage } = {}) {
|
|
211
211
|
// An older mailbox must not jump ahead of the page of history being viewed.
|
|
212
212
|
// Its envelopes become visible when the person loads that earlier history.
|
|
213
|
-
|
|
214
|
-
|
|
213
|
+
let earliest = Infinity;
|
|
214
|
+
for (const entry of transcript) if (Number.isFinite(entry.ts)) earliest = Math.min(earliest, entry.ts);
|
|
215
|
+
if (earliest !== Infinity) rows = rows.filter(row => row.at >= earliest);
|
|
215
216
|
const nameOf = actor => actor?.self ? agentName : actor?.name || 'Unknown sender';
|
|
216
217
|
const mail = rows.map(row => ({ id: `mail:${row.id}`, role: 'notice', text: row.text, ts: row.at, truncated: false,
|
|
217
218
|
mail: { id: row.id, from: nameOf(row.fromActor), to: row.toActor ? nameOf(row.toActor) : row.direction === 'in' ? agentName : 'Another session',
|
|
218
219
|
image: row.fromActor?.kind === 'agent' ? picture(row.fromActor.self ? agentId : row.fromActor.id) : `https://brand.volter.ai/bot/svg?seed=${encodeURIComponent(row.fromActor?.id || row.from)}&size=24&radius=4`,
|
|
219
220
|
subject: row.subject || undefined, via: row.fromActor?.via, direction: row.direction, inReplyTo: row.inReplyTo } }));
|
|
220
|
-
|
|
221
|
-
//
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
221
|
+
// Some native envelopes use a shortened ID. It identifies a copy only if
|
|
222
|
+
// there is exactly one matching full ID; ambiguity must not erase native mail.
|
|
223
|
+
const fullIds = new Set(rows.map(row => row.id));
|
|
224
|
+
const sortedIds = [...fullIds].sort();
|
|
225
|
+
const inMailbox = id => {
|
|
226
|
+
if (!id) return false;
|
|
227
|
+
if (fullIds.has(id)) return true;
|
|
228
|
+
let low = 0, high = sortedIds.length;
|
|
229
|
+
while (low < high) { const middle = (low + high) >>> 1; if (sortedIds[middle] < id) low = middle + 1; else high = middle; }
|
|
230
|
+
return sortedIds[low]?.startsWith(id) === true && sortedIds[low + 1]?.startsWith(id) !== true;
|
|
231
|
+
};
|
|
232
|
+
mail.sort((a, b) => a.ts - b.ts);
|
|
233
|
+
const result = []; let next = 0;
|
|
234
|
+
// Keep native order, including untimed tools/results. Ascending envelopes
|
|
235
|
+
// can be merged before the first later timed entry without repeated splices
|
|
236
|
+
// or sorting the native transcript itself.
|
|
237
|
+
for (const entry of transcript) {
|
|
238
|
+
if (entry.mail && inMailbox(entry.mail.id)) continue;
|
|
239
|
+
while (next < mail.length && Number.isFinite(entry.ts) && entry.ts > mail[next].ts) result.push(mail[next++]);
|
|
240
|
+
result.push(entry);
|
|
225
241
|
}
|
|
242
|
+
while (next < mail.length) result.push(mail[next++]);
|
|
226
243
|
return result;
|
|
227
244
|
}
|
|
228
245
|
|