@volter/teams 0.1.61 → 0.1.62
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.d.ts +1 -1
- package/session-follow.mjs +13 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volter/teams",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.62",
|
|
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.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export function agentImage(seed: string): string;
|
|
|
45
45
|
* Who wrote each entry of a projected transcript (supercode-ui's `TranscriptEntryModel`s), from the messages' own
|
|
46
46
|
* annotations. Each actor carries `id` (a principal id, a session address or seed) for a host that draws its own faces.
|
|
47
47
|
*/
|
|
48
|
-
export function withPeople<Entry extends { role: string; text: string; ts: number | null; id: string }>(
|
|
48
|
+
export function withPeople<Entry extends { role: string; text: string; ts: number | null; id: string; messageIndex?: number }>(
|
|
49
49
|
transcript: Entry[],
|
|
50
50
|
messages: Array<{ role?: string; metadata?: Record<string, unknown> }>,
|
|
51
51
|
options?: { agentName?: string | null; sessionId?: string; personImage?(seed: string): string; agentImage?(seed: string): string; locale?: string | string[] },
|
package/session-follow.mjs
CHANGED
|
@@ -104,24 +104,32 @@ export function withPeople(transcript, messages, { agentName = null, sessionId =
|
|
|
104
104
|
for (const message of messages) {
|
|
105
105
|
if (message?.role !== 'user') continue;
|
|
106
106
|
const at = Date.parse(message.metadata?.timestamp ?? '');
|
|
107
|
-
|
|
107
|
+
// A timestamp alone is not an identity: a native batch may record several
|
|
108
|
+
// turns at the same instant. Keep this fallback only when it is unambiguous.
|
|
109
|
+
if (Number.isFinite(at)) byTime.set(at, byTime.has(at) ? null : message.metadata);
|
|
108
110
|
}
|
|
109
111
|
const people = transcript.map((entry) => {
|
|
110
112
|
if (entry.role === 'assistant') return { ...entry, actor: { id: sessionId, ...(agentName ? { name: agentName } : {}), image: agent(sessionId), kind: 'agent' } };
|
|
111
113
|
if (entry.role !== 'user') return entry;
|
|
114
|
+
// The projection carries its one-based position in this exact capture.
|
|
115
|
+
// Resolve it before looking at the words: a person's pasted envelope or
|
|
116
|
+
// wake notice remains that person's message when the native source says so.
|
|
117
|
+
const indexed = Number.isSafeInteger(entry.messageIndex) && entry.messageIndex > 0;
|
|
118
|
+
const native = indexed ? messages[entry.messageIndex - 1] : null;
|
|
119
|
+
const metadata = indexed ? native?.role === 'user' ? native.metadata ?? {} : {} : byTime.get(entry.ts) ?? {};
|
|
120
|
+
const attributed = Boolean(metadata.source_principal_id || metadata.source_name || metadata.source_via);
|
|
112
121
|
const automated = /^\s*<(hook_prompt|supercode-notice)\b[^>]*>([\s\S]*)<\/\1>\s*$/.exec(entry.text);
|
|
113
122
|
// This exact legacy wake string is emitted by mail_route::CODEX_WAKE. Do
|
|
114
123
|
// not infer automation from general wording in a person's own message.
|
|
115
124
|
const legacyWake = entry.text.trim() === 'You have unread supercode messages. Read them with: supercode message inbox';
|
|
116
|
-
if (automated || legacyWake) return { ...entry, role: 'notice', code: 'automation', text: `${automated?.[1] === 'hook_prompt' ? 'Hook' : 'Mailbox'} notification: ${automated ? automated[2].trim() : entry.text.trim()}` };
|
|
125
|
+
if (!attributed && (automated || legacyWake)) return { ...entry, role: 'notice', code: 'automation', text: `${automated?.[1] === 'hook_prompt' ? 'Hook' : 'Mailbox'} notification: ${automated ? automated[2].trim() : entry.text.trim()}` };
|
|
117
126
|
// A harness's delivery notice about a message is a compact system line, not a person's turn.
|
|
118
|
-
if (/^\s*\[Cross-session [a-z ]*notice\]/i.test(entry.text)) return { ...entry, role: 'notice', text: entry.text.trim().split('\n')[0] };
|
|
119
|
-
const peer = peerMessage(entry.text);
|
|
127
|
+
if (!attributed && /^\s*\[Cross-session [a-z ]*notice\]/i.test(entry.text)) return { ...entry, role: 'notice', text: entry.text.trim().split('\n')[0] };
|
|
128
|
+
const peer = attributed ? null : peerMessage(entry.text);
|
|
120
129
|
if (peer) {
|
|
121
130
|
const seed = peer.address.startsWith('sc:') ? peer.address : peer.name;
|
|
122
131
|
return { ...entry, text: peer.body, mail: { id: peer.id || entry.id, from: peer.name, to: agentName || 'This session', direction: 'in' }, actor: { id: seed, name: peer.name, image: agent(seed), kind: 'agent' }, context: [{ id: `${entry.id}:envelope`, kind: 'envelope', label: 'Delivered by supercode', detail: entry.text }] };
|
|
123
132
|
}
|
|
124
|
-
const metadata = byTime.get(entry.ts) ?? {};
|
|
125
133
|
const name = metadata.source_name || null;
|
|
126
134
|
const seed = name ? (metadata.source_principal_id || name) : '';
|
|
127
135
|
const via = typeof metadata.source_via === 'string' ? metadata.source_via.trim() : '';
|