murmur-it 0.0.0-stage → 0.2.0
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/CHANGELOG.md +48 -0
- package/LICENSE +21 -0
- package/README.md +125 -2
- package/adapters/hummin/murmur.ts +467 -0
- package/adapters/opencode/murmur.ts +304 -0
- package/bin/murmur.js +11 -0
- package/dist/broker.js +1050 -0
- package/dist/cli.js +588 -0
- package/dist/client.js +210 -0
- package/dist/config.js +83 -0
- package/dist/core.js +779 -0
- package/dist/hooks.js +120 -0
- package/dist/install.js +250 -0
- package/dist/mcp.js +217 -0
- package/dist/native.js +125 -0
- package/dist/proc.js +110 -0
- package/dist/proof.js +111 -0
- package/dist/protocol.js +92 -0
- package/dist/store.js +496 -0
- package/dist/wake.js +12 -0
- package/package.json +63 -4
package/dist/native.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { createConnection } from 'node:net';
|
|
2
|
+
import { StringDecoder } from 'node:string_decoder';
|
|
3
|
+
import { LineReader, encodeLine } from './protocol.js';
|
|
4
|
+
// Framing for the Claude native messaging socket, as Claude Code itself
|
|
5
|
+
// documents it in its log line "Inject messages": an auth line, then
|
|
6
|
+
// {"type":"user","message":{"role":"user","content":...}}, newline-delimited
|
|
7
|
+
// JSON. Any other type is dropped by the session ("Received unhandled
|
|
8
|
+
// message type"). Verified live 2026-10-20 against 2.1.304: an idle session
|
|
9
|
+
// took the message as a peer turn and answered it. The session never
|
|
10
|
+
// writes back, so success here only means the write was accepted; proof
|
|
11
|
+
// of delivery comes from the receiver's transcript (proof.ts).
|
|
12
|
+
export function buildAuthLine(token) {
|
|
13
|
+
return encodeLine({ type: 'auth', token });
|
|
14
|
+
}
|
|
15
|
+
export function buildMessageLine(text) {
|
|
16
|
+
return encodeLine({ type: 'user', message: { role: 'user', content: text } });
|
|
17
|
+
}
|
|
18
|
+
const DEFAULT_TIMEOUT_MS = 5000;
|
|
19
|
+
// Sends one message to a live Claude session over its native messaging
|
|
20
|
+
// socket (the /tmp/cc-socks/<pid>.sock socket the session exposes).
|
|
21
|
+
// Connects, writes the auth line and the message line, half-closes, then
|
|
22
|
+
// waits for the close or the timeout. Resolves ok true on a clean close or a
|
|
23
|
+
// reply line that is not an error object; ok false with the error text on
|
|
24
|
+
// connect failure, write failure, an error-object reply, or timeout.
|
|
25
|
+
// Never throws.
|
|
26
|
+
export async function nativeSend(socketPath, token, text, timeoutMs) {
|
|
27
|
+
const limit = timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
28
|
+
return new Promise((resolve) => {
|
|
29
|
+
const socket = createConnection(socketPath);
|
|
30
|
+
const decoder = new StringDecoder('utf8');
|
|
31
|
+
const reader = new LineReader();
|
|
32
|
+
let settled = false;
|
|
33
|
+
let lastSocketError = null;
|
|
34
|
+
let timer = null;
|
|
35
|
+
const finish = (result) => {
|
|
36
|
+
if (settled) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
settled = true;
|
|
40
|
+
if (timer !== null) {
|
|
41
|
+
clearTimeout(timer);
|
|
42
|
+
}
|
|
43
|
+
socket.destroy();
|
|
44
|
+
resolve(result);
|
|
45
|
+
};
|
|
46
|
+
timer = setTimeout(() => {
|
|
47
|
+
finish({ ok: false, error: 'no reply or close from ' + socketPath + ' within ' + String(limit) + 'ms' });
|
|
48
|
+
}, limit);
|
|
49
|
+
socket.once('error', (err) => {
|
|
50
|
+
lastSocketError = err.message;
|
|
51
|
+
finish({ ok: false, error: 'socket error on ' + socketPath + ': ' + err.message });
|
|
52
|
+
});
|
|
53
|
+
socket.once('connect', () => {
|
|
54
|
+
try {
|
|
55
|
+
// end() flushes both lines and half-closes, which is the session's
|
|
56
|
+
// cue to process the buffer and hang up.
|
|
57
|
+
socket.end(buildAuthLine(token) + buildMessageLine(text));
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
finish({ ok: false, error: 'write to ' + socketPath + ' failed: ' + err.message });
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
socket.on('data', (chunk) => {
|
|
64
|
+
const lines = reader.feed(decoder.write(chunk));
|
|
65
|
+
for (const line of lines) {
|
|
66
|
+
let parsed;
|
|
67
|
+
try {
|
|
68
|
+
parsed = JSON.parse(line);
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
// The peer spoke first with a line that is not JSON. It is still
|
|
72
|
+
// a reply line, and not an error object, so count the send as
|
|
73
|
+
// accepted.
|
|
74
|
+
finish({ ok: true, error: null });
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (isErrorReply(parsed)) {
|
|
78
|
+
finish({ ok: false, error: errorReplyText(parsed) });
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
finish({ ok: true, error: null });
|
|
82
|
+
}
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
socket.once('close', (hadError) => {
|
|
87
|
+
if (hadError || lastSocketError !== null) {
|
|
88
|
+
finish({
|
|
89
|
+
ok: false,
|
|
90
|
+
error: lastSocketError ?? 'socket to ' + socketPath + ' closed with an error',
|
|
91
|
+
});
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
// Clean close with no reply line: the peer read the writes and hung
|
|
95
|
+
// up without complaining, count that as accepted.
|
|
96
|
+
finish({ ok: true, error: null });
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
// Recognizes the plausible error shapes for a reply line: the murmur
|
|
101
|
+
// ErrReply shape ({ ok: false, error: { code, message } }) and a bare
|
|
102
|
+
// { type: 'error' }. Anything else counts as acceptance.
|
|
103
|
+
function isErrorReply(parsed) {
|
|
104
|
+
if (typeof parsed !== 'object' || parsed === null) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
const rec = parsed;
|
|
108
|
+
if (rec.ok === false && typeof rec.error === 'object' && rec.error !== null) {
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
return rec.type === 'error';
|
|
112
|
+
}
|
|
113
|
+
function errorReplyText(parsed) {
|
|
114
|
+
const rec = parsed;
|
|
115
|
+
if (typeof rec.error === 'object' && rec.error !== null) {
|
|
116
|
+
const message = rec.error.message;
|
|
117
|
+
if (typeof message === 'string') {
|
|
118
|
+
return message;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (typeof rec.message === 'string') {
|
|
122
|
+
return rec.message;
|
|
123
|
+
}
|
|
124
|
+
return JSON.stringify(parsed);
|
|
125
|
+
}
|
package/dist/proc.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import { basename } from 'node:path';
|
|
3
|
+
const SHELLS = new Set(['sh', 'bash', 'zsh', 'dash', 'fish', 'ksh', 'tcsh', 'csh']);
|
|
4
|
+
const MAX_DEPTH = 32;
|
|
5
|
+
// macOS ps answers one pid with a direct kernel lookup (about 3 ms) but lists
|
|
6
|
+
// the whole table for two or more (about 60 ms), and any full listing costs
|
|
7
|
+
// 20 ms without the comm column and 38 ms with it. Up to this many pids,
|
|
8
|
+
// one ps each beats one listing.
|
|
9
|
+
const ONE_BY_ONE_MAX = 4;
|
|
10
|
+
// Parses ps text. lstart is a fixed 24 character field, so a line splits as:
|
|
11
|
+
// pid, ppid, 24 chars of start time, then comm (which may hold spaces on
|
|
12
|
+
// macOS, where it is the executable path; absent when ps was not asked for it).
|
|
13
|
+
export function readProcTable(run = defaultPs) {
|
|
14
|
+
const table = new Map();
|
|
15
|
+
for (const raw of run().split('\n')) {
|
|
16
|
+
const match = /^\s*(\d+)\s+(\d+)\s+(.{24})(?:\s+(.*))?$/.exec(raw);
|
|
17
|
+
if (match === null) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
const [, pid, ppid, start, comm] = match;
|
|
21
|
+
table.set(Number(pid), { ppid: Number(ppid), start: start.trim(), comm: (comm ?? '').trim() });
|
|
22
|
+
}
|
|
23
|
+
return table;
|
|
24
|
+
}
|
|
25
|
+
function ps(args) {
|
|
26
|
+
return execFileSync('ps', args, { encoding: 'utf8', env: { ...process.env, LC_ALL: 'C' }, stdio: ['ignore', 'pipe', 'ignore'] });
|
|
27
|
+
}
|
|
28
|
+
function defaultPs() {
|
|
29
|
+
return ps(['-axo', 'pid=,ppid=,lstart=,comm=']);
|
|
30
|
+
}
|
|
31
|
+
function defaultPsNoComm() {
|
|
32
|
+
return ps(['-axo', 'pid=,ppid=,lstart=']);
|
|
33
|
+
}
|
|
34
|
+
function defaultPsOne(pid) {
|
|
35
|
+
return ps(['-o', 'pid=,ppid=,lstart=,comm=', '-p', String(pid)]);
|
|
36
|
+
}
|
|
37
|
+
// One process, or undefined when it is gone or ps is unavailable.
|
|
38
|
+
export function readProcess(pid, run = defaultPsOne) {
|
|
39
|
+
try {
|
|
40
|
+
return readProcTable(() => run(pid)).get(pid);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// A table that holds at least these pids, for liveness checks.
|
|
47
|
+
export function liveTable(pids, runOne, runAll = defaultPsNoComm) {
|
|
48
|
+
const distinct = [...new Set(pids)];
|
|
49
|
+
if (distinct.length > ONE_BY_ONE_MAX) {
|
|
50
|
+
try {
|
|
51
|
+
return readProcTable(runAll);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return new Map();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const table = new Map();
|
|
58
|
+
for (const pid of distinct) {
|
|
59
|
+
const info = readProcess(pid, runOne);
|
|
60
|
+
if (info !== undefined) {
|
|
61
|
+
table.set(pid, info);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return table;
|
|
65
|
+
}
|
|
66
|
+
export function isShell(comm) {
|
|
67
|
+
return SHELLS.has(basename(comm).replace(/^-/, ''));
|
|
68
|
+
}
|
|
69
|
+
// Walks up from startPid's parent. The host is the first ancestor that is
|
|
70
|
+
// not a shell; null when the table has no usable chain. Without full the walk
|
|
71
|
+
// stops at the host, so ancestors ends there instead of at the root.
|
|
72
|
+
export function hostOf(table, startPid, full = true) {
|
|
73
|
+
const ancestors = [];
|
|
74
|
+
let host = null;
|
|
75
|
+
let cursor = table.get(startPid)?.ppid;
|
|
76
|
+
while (cursor !== undefined && cursor > 1 && ancestors.length < MAX_DEPTH) {
|
|
77
|
+
const info = table.get(cursor);
|
|
78
|
+
if (info === undefined) {
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
ancestors.push(cursor);
|
|
82
|
+
if (host === null && !isShell(info.comm)) {
|
|
83
|
+
host = { pid: cursor, start: info.start };
|
|
84
|
+
if (!full) {
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
cursor = info.ppid;
|
|
89
|
+
}
|
|
90
|
+
if (host === null) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
return { hostPid: host.pid, hostStart: host.start, ancestors };
|
|
94
|
+
}
|
|
95
|
+
// The calling process's host, or null when ps is unavailable. ps runs once
|
|
96
|
+
// per ancestor, never over the whole table; the caller's own row is not
|
|
97
|
+
// fetched because node already knows its parent. Callers that only need the
|
|
98
|
+
// host (hooks, MCP, name) pass full = false and skip the rest of the chain.
|
|
99
|
+
export function currentHost(run, full = true) {
|
|
100
|
+
const table = {
|
|
101
|
+
get: (pid) => (pid === process.pid ? { ppid: process.ppid, start: '', comm: '' } : readProcess(pid, run)),
|
|
102
|
+
};
|
|
103
|
+
return hostOf(table, process.pid, full);
|
|
104
|
+
}
|
|
105
|
+
// True when pid is running and is still the same process that was recorded
|
|
106
|
+
// (same start time), so a recycled pid never reads as a live session.
|
|
107
|
+
export function isAlive(table, pid, start) {
|
|
108
|
+
const info = table.get(pid);
|
|
109
|
+
return info !== undefined && info.start === start;
|
|
110
|
+
}
|
package/dist/proof.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { closeSync, openSync, readSync, statSync } from 'node:fs';
|
|
2
|
+
import { PROOF_POLL_MS, deliveryTag } from './protocol.js';
|
|
3
|
+
// Watches nobody proved within a day are dropped; the delivery stays sent.
|
|
4
|
+
const FORGET_AFTER_MS = 24 * 60 * 60 * 1000;
|
|
5
|
+
export class ProofWatcher {
|
|
6
|
+
watches = new Map();
|
|
7
|
+
timer = null;
|
|
8
|
+
onProof;
|
|
9
|
+
pollMs;
|
|
10
|
+
now;
|
|
11
|
+
constructor(onProof, pollMs = 1000, now = Date.now) {
|
|
12
|
+
this.onProof = onProof;
|
|
13
|
+
this.pollMs = pollMs;
|
|
14
|
+
this.now = now;
|
|
15
|
+
}
|
|
16
|
+
// The transcript size right now. Taken before a push so the watch starts
|
|
17
|
+
// below anything the push can cause.
|
|
18
|
+
static offsetOf(path) {
|
|
19
|
+
try {
|
|
20
|
+
return statSync(path).size;
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return 0;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
watch(messageId, recipient, path, offset) {
|
|
27
|
+
const ts = this.now();
|
|
28
|
+
this.watches.set(String(messageId) + '\u0000' + recipient, {
|
|
29
|
+
messageId,
|
|
30
|
+
recipient,
|
|
31
|
+
path,
|
|
32
|
+
tag: deliveryTag(messageId),
|
|
33
|
+
offset,
|
|
34
|
+
pollUntil: ts + PROOF_POLL_MS,
|
|
35
|
+
createdAt: ts,
|
|
36
|
+
});
|
|
37
|
+
this.timer ??= setInterval(() => this.tick(), this.pollMs);
|
|
38
|
+
}
|
|
39
|
+
// Scans every pending watch of this recipient now, past its poll window
|
|
40
|
+
// too. Called on the recipient's hook events.
|
|
41
|
+
recheck(recipient) {
|
|
42
|
+
for (const watch of [...this.watches.values()]) {
|
|
43
|
+
if (watch.recipient === recipient) {
|
|
44
|
+
this.scan(watch);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
stop() {
|
|
49
|
+
if (this.timer !== null) {
|
|
50
|
+
clearInterval(this.timer);
|
|
51
|
+
this.timer = null;
|
|
52
|
+
}
|
|
53
|
+
this.watches.clear();
|
|
54
|
+
}
|
|
55
|
+
get size() {
|
|
56
|
+
return this.watches.size;
|
|
57
|
+
}
|
|
58
|
+
tick() {
|
|
59
|
+
const ts = this.now();
|
|
60
|
+
for (const watch of [...this.watches.values()]) {
|
|
61
|
+
if (ts - watch.createdAt > FORGET_AFTER_MS) {
|
|
62
|
+
this.drop(watch);
|
|
63
|
+
}
|
|
64
|
+
else if (ts <= watch.pollUntil) {
|
|
65
|
+
this.scan(watch);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (![...this.watches.values()].some((w) => ts <= w.pollUntil) && this.timer !== null) {
|
|
69
|
+
clearInterval(this.timer);
|
|
70
|
+
this.timer = null;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// Reads only what was appended since the last scan, keeping a tag-sized
|
|
74
|
+
// overlap so a tag split across two scans is still found.
|
|
75
|
+
scan(watch) {
|
|
76
|
+
// Most scans find nothing new, so the size check comes before the open.
|
|
77
|
+
let size;
|
|
78
|
+
try {
|
|
79
|
+
size = statSync(watch.path).size;
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (size <= watch.offset) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
let fd;
|
|
88
|
+
try {
|
|
89
|
+
fd = openSync(watch.path, 'r');
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
const buf = Buffer.alloc(size - watch.offset);
|
|
96
|
+
readSync(fd, buf, 0, buf.length, watch.offset);
|
|
97
|
+
if (buf.includes(watch.tag)) {
|
|
98
|
+
this.drop(watch);
|
|
99
|
+
this.onProof(watch.messageId, watch.recipient);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
watch.offset = Math.max(watch.offset, size - Buffer.byteLength(watch.tag));
|
|
103
|
+
}
|
|
104
|
+
finally {
|
|
105
|
+
closeSync(fd);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
drop(watch) {
|
|
109
|
+
this.watches.delete(String(watch.messageId) + '\u0000' + watch.recipient);
|
|
110
|
+
}
|
|
111
|
+
}
|
package/dist/protocol.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto';
|
|
2
|
+
// Wire protocol constants. Newline-delimited JSON over a Unix domain socket.
|
|
3
|
+
export const PROTOCOL_VERSION = 2;
|
|
4
|
+
export const MAX_BODY_CHARS = 4000;
|
|
5
|
+
export const RATE_WINDOW_MS = 60000;
|
|
6
|
+
export const RATE_MAX_SENDS = 20;
|
|
7
|
+
export const DUP_WINDOW_MS = 60000;
|
|
8
|
+
export const THREAD_CAP = 500;
|
|
9
|
+
export const UNREAD_CAP = 200;
|
|
10
|
+
export const NOTIFY_BATCH_MS = 60000;
|
|
11
|
+
export const WAIT_MAX_MS = 300000;
|
|
12
|
+
export const WAIT_DEFAULT_MS = 120000;
|
|
13
|
+
export const FIRST_LINE_MAX = 120;
|
|
14
|
+
export const HANDLE_RE = /^[a-z0-9][a-z0-9-]{1,31}$/;
|
|
15
|
+
// How long the broker keeps polling a receiver's transcript for proof after
|
|
16
|
+
// a push; later hook events of that session re-check without a deadline.
|
|
17
|
+
export const PROOF_POLL_MS = 120000;
|
|
18
|
+
export class MurmurError extends Error {
|
|
19
|
+
code;
|
|
20
|
+
constructor(code, message) {
|
|
21
|
+
super(message);
|
|
22
|
+
this.name = 'MurmurError';
|
|
23
|
+
this.code = code;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export function encodeLine(msg) {
|
|
27
|
+
return JSON.stringify(msg) + '\n';
|
|
28
|
+
}
|
|
29
|
+
export class LineReader {
|
|
30
|
+
buffer = '';
|
|
31
|
+
// Buffers text across calls and returns every complete line that has
|
|
32
|
+
// arrived so far. Lines are stripped of surrounding whitespace and empty
|
|
33
|
+
// lines are dropped.
|
|
34
|
+
feed(chunk) {
|
|
35
|
+
this.buffer += chunk;
|
|
36
|
+
const lines = [];
|
|
37
|
+
let idx = this.buffer.indexOf('\n');
|
|
38
|
+
while (idx !== -1) {
|
|
39
|
+
const line = this.buffer.slice(0, idx).trim();
|
|
40
|
+
this.buffer = this.buffer.slice(idx + 1);
|
|
41
|
+
if (line.length > 0) {
|
|
42
|
+
lines.push(line);
|
|
43
|
+
}
|
|
44
|
+
idx = this.buffer.indexOf('\n');
|
|
45
|
+
}
|
|
46
|
+
return lines;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export function firstLine(body) {
|
|
50
|
+
const nl = body.indexOf('\n');
|
|
51
|
+
const line = (nl === -1 ? body : body.slice(0, nl)).trim();
|
|
52
|
+
if (line.length > FIRST_LINE_MAX) {
|
|
53
|
+
return line.slice(0, FIRST_LINE_MAX);
|
|
54
|
+
}
|
|
55
|
+
return line;
|
|
56
|
+
}
|
|
57
|
+
export function truncateForDelivery(body) {
|
|
58
|
+
if (body.length <= MAX_BODY_CHARS) {
|
|
59
|
+
return { delivered: body, truncated: false };
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
delivered: body.slice(0, MAX_BODY_CHARS) + '\n[truncated: full body stored, read it with murmur_thread full: true]',
|
|
63
|
+
truncated: true,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export function newToken() {
|
|
67
|
+
return randomBytes(32).toString('hex');
|
|
68
|
+
}
|
|
69
|
+
// The search key for delivery proof. The trailing space keeps m42 from
|
|
70
|
+
// matching m420.
|
|
71
|
+
export function deliveryTag(messageId) {
|
|
72
|
+
return '[murmur m' + String(messageId) + ' ';
|
|
73
|
+
}
|
|
74
|
+
export function replyFooter(m) {
|
|
75
|
+
return ('(reply: murmur_reply messageId ' + String(m.id) + ', or from a shell: murmur reply ' + String(m.id) +
|
|
76
|
+
' <text>; whole thread: murmur_thread ' + String(m.threadId) + ')');
|
|
77
|
+
}
|
|
78
|
+
// What a session sees for one message, on every transport: a tag line with
|
|
79
|
+
// ids, sender and recipients, the (possibly truncated) body, references, and
|
|
80
|
+
// how to reply.
|
|
81
|
+
export function renderDelivery(m, deliveredBody, recipients) {
|
|
82
|
+
let head = deliveryTag(m.id) + 't' + String(m.threadId) + ' s' + String(m.seq) + ' from ' + m.sender;
|
|
83
|
+
if (m.inReplyTo !== null) {
|
|
84
|
+
head += ' re m' + String(m.inReplyTo);
|
|
85
|
+
}
|
|
86
|
+
if (m.verdict !== null) {
|
|
87
|
+
head += ' ' + m.verdict.toUpperCase();
|
|
88
|
+
}
|
|
89
|
+
head += ' to ' + recipients.join(', ') + ']';
|
|
90
|
+
const refs = m.references.length > 0 ? '\nrefs: ' + m.references.join(', ') : '';
|
|
91
|
+
return head + '\n' + deliveredBody + refs + '\n' + replyFooter(m);
|
|
92
|
+
}
|