@uuaid/pillar 2.5.4 → 2.5.5
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/README.md +17 -0
- package/bin/pillar.mjs +21 -15
- package/package.json +1 -1
- package/src/net/refusals.mjs +1 -1
- package/src/net/transport.mjs +8 -5
package/README.md
CHANGED
|
@@ -169,6 +169,23 @@ themselves. Messages from members who are not your contacts still follow
|
|
|
169
169
|
Same convention as the mobile app and agentnet.chat; `send-group` with a
|
|
170
170
|
`groups.json` keeps working and now sends the same tag.
|
|
171
171
|
|
|
172
|
+
For signed groups-v2 invitations, an incomplete manifest chain waits in a
|
|
173
|
+
bounded buffer: at most 4 pending invitations per sender and 64 overall,
|
|
174
|
+
with 4 MiB per sender and 32 MiB total across invitation and recovery buffers.
|
|
175
|
+
Malformed manifests take no slot. At the count caps, invitations that do not
|
|
176
|
+
name your exact UUAID and key as invited are evicted before ones that do;
|
|
177
|
+
within each class the oldest goes first, from the same sender first when
|
|
178
|
+
that sender is at its cap. Malformed manifests cannot evict anything, and
|
|
179
|
+
existing non-self junk is removed before a pending invitation that names you.
|
|
180
|
+
A complete, verified invitation is adopted immediately and leaves no pending
|
|
181
|
+
slot.
|
|
182
|
+
|
|
183
|
+
The accepted remaining limit is that 64 genuine but incomplete invitations
|
|
184
|
+
that name you (16 senders with 4 each) can evict an older pending invitation
|
|
185
|
+
that also names you. Re-sending its manifest chain completes that invitation;
|
|
186
|
+
the eviction delays adoption and does not remove an adopted group. Admission
|
|
187
|
+
and eviction do not currently prefer contacts or trusted senders.
|
|
188
|
+
|
|
172
189
|
### Replacing an identity: `init --force`
|
|
173
190
|
|
|
174
191
|
`init --force` mints a NEW uuaid, which silently breaks every contact that
|
package/bin/pillar.mjs
CHANGED
|
@@ -52,6 +52,12 @@ import { groupCommandRoute, groupRouteLookups, RosterStore } from "../src/groups
|
|
|
52
52
|
import { runGroupV2 } from "../src/group-v2-cli.mjs";
|
|
53
53
|
import { Mailbox } from "../src/mailbox/mailbox.mjs";
|
|
54
54
|
|
|
55
|
+
// JSON rendered as one text line (or embedded in a Zestro command). Preserve
|
|
56
|
+
// parsed values while escaping the two separators JSON.stringify leaves raw.
|
|
57
|
+
function jsonLine(value) {
|
|
58
|
+
return JSON.stringify(value).replace(/[\u2028\u2029]/g, c => `\\u${c.charCodeAt(0).toString(16)}`);
|
|
59
|
+
}
|
|
60
|
+
|
|
55
61
|
function parseArgs(argv) {
|
|
56
62
|
const args = { _: [] };
|
|
57
63
|
for (let i = 0; i < argv.length; i++) {
|
|
@@ -836,7 +842,7 @@ async function cmdGroup(args) {
|
|
|
836
842
|
const { decrypt } = await import("../src/net/envelope.mjs");
|
|
837
843
|
// A local view: it never pulls from carriers (that would take "new" away
|
|
838
844
|
// from the next inbox run). Pull with pillar inbox first.
|
|
839
|
-
console.log(
|
|
845
|
+
console.log(jsonLine({ group: g.id, name: g.name, members: g.members, pending: g.pending, left: g.left, createdBy: g.createdBy, view: "local — pull new mail with pillar inbox" }));
|
|
840
846
|
const items = [];
|
|
841
847
|
for (const row of p.mailbox.groupInbound(g.id, limit)) {
|
|
842
848
|
const { env, payload } = viewOfRow(p, row, decrypt);
|
|
@@ -855,7 +861,7 @@ async function cmdGroup(args) {
|
|
|
855
861
|
}
|
|
856
862
|
for (const [msgId, m] of byMsg) items.push({ at: m.at, line: { dir: "out", msgId, at: m.at, members: m.to, acceptedByCarrier: m.carrier, acknowledged: m.acked, read: m.read } });
|
|
857
863
|
items.sort((a, b) => (a.at < b.at ? -1 : a.at > b.at ? 1 : 0));
|
|
858
|
-
for (const it of items.slice(-limit)) console.log(
|
|
864
|
+
for (const it of items.slice(-limit)) console.log(jsonLine(it.line));
|
|
859
865
|
return;
|
|
860
866
|
}
|
|
861
867
|
} finally {
|
|
@@ -955,7 +961,7 @@ async function cmdRecv(args) {
|
|
|
955
961
|
const tag = extractGroupTag(env.payload);
|
|
956
962
|
if (tag) { line.group = tag.name; line.groupId = tag.id; if (tag.msgId) line.msgId = tag.msgId; if (tag.op !== "message") line.op = tag.op; }
|
|
957
963
|
if (rk.named) line.id = env.id;
|
|
958
|
-
console.log(
|
|
964
|
+
console.log(jsonLine(line));
|
|
959
965
|
if (bridge && env.kind === "request") {
|
|
960
966
|
// Interaction-convention return leg: ack FIRST — pillar-ask allows 120s
|
|
961
967
|
// per phase but ZestroBridge times out at 30s, so the ack goes out before
|
|
@@ -970,7 +976,7 @@ async function cmdRecv(args) {
|
|
|
970
976
|
const senderKey = env.transportSignature.publicKey; // open() F1: sender derives from this key
|
|
971
977
|
try {
|
|
972
978
|
if (!autoAcks) await p.send({ recipient: env.sender, recipientPublicKey: senderKey, kind: "ack", payload: { inReplyTo: env.id } });
|
|
973
|
-
const result = await bridge.sendCommand({ command:
|
|
979
|
+
const result = await bridge.sendCommand({ command: jsonLine({ kind: env.kind, payload: env.payload, sender: env.sender }) });
|
|
974
980
|
const hasText = result && typeof result === "object" &&
|
|
975
981
|
["text", "result", "output", "response", "message"].some(k => k in result);
|
|
976
982
|
const text = hasText
|
|
@@ -996,8 +1002,8 @@ async function cmdRecv(args) {
|
|
|
996
1002
|
}
|
|
997
1003
|
} else if (bridge && env.kind !== "ack" && env.kind !== "reply") {
|
|
998
1004
|
try {
|
|
999
|
-
const result = await bridge.sendCommand({ command:
|
|
1000
|
-
console.log(` → zestro result: ${
|
|
1005
|
+
const result = await bridge.sendCommand({ command: jsonLine({ kind: env.kind, payload: env.payload, sender: env.sender }) });
|
|
1006
|
+
console.log(` → zestro result: ${jsonLine(result).slice(0, 200)}`);
|
|
1001
1007
|
} catch (e) {
|
|
1002
1008
|
if (e.code === "SESSION_BUSY") {
|
|
1003
1009
|
console.log(` → zestro: busy (${e.message})`);
|
|
@@ -1093,7 +1099,7 @@ async function cmdInbox(args) {
|
|
|
1093
1099
|
const rows = p.mailbox.inboxAfter(startCursor, 1000);
|
|
1094
1100
|
for (const row of rows) {
|
|
1095
1101
|
const { env, payload, groupId } = viewOfRow(p, row, decrypt);
|
|
1096
|
-
console.log(
|
|
1102
|
+
console.log(jsonLine(inboxLine(env, payload, { new: true })));
|
|
1097
1103
|
printed.push({ id: env.id, sender: env.sender, kind: env.kind, payload, groupId });
|
|
1098
1104
|
}
|
|
1099
1105
|
if (rows.length && !args.peek) p.mailbox.setReaderCursor(rk.key, rows.at(-1).released_seq ?? rows.at(-1).seq);
|
|
@@ -1105,7 +1111,7 @@ async function cmdInbox(args) {
|
|
|
1105
1111
|
// courier's auto-ack, a bot) seal back to a sender who is NOT in fleet.json
|
|
1106
1112
|
// via `pillar send … --to-pubkey <fromPublicKey>`. Additive field.
|
|
1107
1113
|
for (const env of fresh) {
|
|
1108
|
-
console.log(
|
|
1114
|
+
console.log(jsonLine(inboxLine(env, env.payload, { new: true })));
|
|
1109
1115
|
printed.push({ id: env.id, sender: env.sender, kind: env.kind, payload: env.payload, groupId: extractGroupTag(env.payload)?.id ?? null });
|
|
1110
1116
|
}
|
|
1111
1117
|
// Backlog: rows stored earlier (e.g. by a recv daemon) but never surfaced.
|
|
@@ -1116,7 +1122,7 @@ async function cmdInbox(args) {
|
|
|
1116
1122
|
if (args.unread) {
|
|
1117
1123
|
for (const row of backlog) {
|
|
1118
1124
|
const { env, payload, groupId } = viewOfRow(p, row, decrypt);
|
|
1119
|
-
console.log(
|
|
1125
|
+
console.log(jsonLine(inboxLine(env, payload, { new: false })));
|
|
1120
1126
|
printed.push({ id: env.id, sender: env.sender, kind: env.kind, payload, groupId });
|
|
1121
1127
|
}
|
|
1122
1128
|
}
|
|
@@ -1155,7 +1161,7 @@ async function cmdInbox(args) {
|
|
|
1155
1161
|
const { spawnSync } = await import("node:child_process");
|
|
1156
1162
|
const r = spawnSync(args.notify, {
|
|
1157
1163
|
shell: true,
|
|
1158
|
-
input:
|
|
1164
|
+
input: jsonLine({ uuaid: p.uuaid, new: newCount, unread: backlog.length }) + "\n",
|
|
1159
1165
|
env: { ...process.env, PILLAR_NEW: String(newCount), PILLAR_UNREAD: String(backlog.length), PILLAR_UUAID: p.uuaid },
|
|
1160
1166
|
stdio: ["pipe", "inherit", "inherit"],
|
|
1161
1167
|
});
|
|
@@ -1200,7 +1206,7 @@ async function cmdWait(args) {
|
|
|
1200
1206
|
const report = (carrierViews, local) => {
|
|
1201
1207
|
const kinds = {};
|
|
1202
1208
|
for (const k of [...carrierViews.map((v) => v.kind), ...local.map((r) => JSON.parse(r.envelope_json).kind)]) kinds[k] = (kinds[k] ?? 0) + 1;
|
|
1203
|
-
console.log(
|
|
1209
|
+
console.log(jsonLine({ uuaid: p.uuaid, ...(rk.named ? { reader: rk.key } : {}), pending: carrierViews.length + local.length, carrier: carrierViews.length, local: local.length, kinds }));
|
|
1204
1210
|
};
|
|
1205
1211
|
let local = localRows();
|
|
1206
1212
|
if (local.length) { report([], local); await p.stop(); exit(0); }
|
|
@@ -1209,7 +1215,7 @@ async function cmdWait(args) {
|
|
|
1209
1215
|
local = localRows();
|
|
1210
1216
|
await p.stop();
|
|
1211
1217
|
if (views.length || local.length) { report(views, local); exit(0); }
|
|
1212
|
-
console.log(
|
|
1218
|
+
console.log(jsonLine({ uuaid: p.uuaid, pending: 0, timedOut: true }));
|
|
1213
1219
|
exit(3);
|
|
1214
1220
|
}
|
|
1215
1221
|
|
|
@@ -1227,7 +1233,7 @@ async function cmdReaders(args) {
|
|
|
1227
1233
|
for (const r of readers) {
|
|
1228
1234
|
const behind = mb.inboxAfter(r.cursor, 100000).length;
|
|
1229
1235
|
const leases = live.filter((l) => l.reader === r.name);
|
|
1230
|
-
console.log(
|
|
1236
|
+
console.log(jsonLine({
|
|
1231
1237
|
reader: r.name, named: !r.name.startsWith("ctx:"), cursor: r.cursor, unseen: behind,
|
|
1232
1238
|
last: describeProcess(r), live: leases.map(describeProcess),
|
|
1233
1239
|
}));
|
|
@@ -1261,7 +1267,7 @@ async function cmdStatus(args) {
|
|
|
1261
1267
|
const rows = id ? [p.mailbox.getOutbound(id)].filter(Boolean) : p.mailbox.outboxRecent(Number(args.limit ?? 20));
|
|
1262
1268
|
if (id && !rows.length) { console.error(`no envelope ${id} in this home's outbox`); exit(2); }
|
|
1263
1269
|
for (const r of rows) {
|
|
1264
|
-
console.log(
|
|
1270
|
+
console.log(jsonLine({
|
|
1265
1271
|
id: r.envelope_id, to: r.recipient, kind: r.kind ?? null, at: r.created_at,
|
|
1266
1272
|
...(r.group_id ? { groupId: r.group_id, msgId: r.group_msg_id ?? null } : {}),
|
|
1267
1273
|
acceptedByCarrier: r.status === "delivered" ? (r.delivered_at ?? true) : null,
|
|
@@ -1372,7 +1378,7 @@ async function cmdTrust(args) {
|
|
|
1372
1378
|
return;
|
|
1373
1379
|
}
|
|
1374
1380
|
for (const row of mb.inboxQuarantined(500)) {
|
|
1375
|
-
console.log(
|
|
1381
|
+
console.log(jsonLine({ id: row.envelope_id, from: row.sender, reason: row.quarantined, at: row.received_at }));
|
|
1376
1382
|
}
|
|
1377
1383
|
mb.close();
|
|
1378
1384
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uuaid/pillar",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.5",
|
|
4
4
|
"description": "Pillar (Protocol for Inter-agent Linked Ledger And Relay) — the secure delivery layer of UACP, the Universal Agent Communication Protocol. UACP = UUAID (identity) + Envelope (signed, encrypted container) + Pillar (relay, mailbox, routing, store-and-forward). Reference implementation of the UACP delivery layer; includes VDA-1 (IAASO-3901, in ballot) delivery attestation and a blind escrow for the Zilligon ZGN / EVM rails.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
package/src/net/refusals.mjs
CHANGED
|
@@ -106,7 +106,7 @@ export function withCarrierFix(status, body) {
|
|
|
106
106
|
* terminal. Every other character is printed as received.
|
|
107
107
|
*/
|
|
108
108
|
function oneLine(value) {
|
|
109
|
-
return String(value).replace(/[\u0000-\u001f\u007f-\u009f]+/g, " ").trim();
|
|
109
|
+
return String(value).replace(/[\u0000-\u001f\u007f-\u009f\u2028\u2029]+/g, " ").trim();
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
/**
|
package/src/net/transport.mjs
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* Transport — libp2p node that speaks the UUAID pillar protocol.
|
|
3
3
|
*
|
|
4
4
|
* Design:
|
|
5
|
-
* - The
|
|
6
|
-
*
|
|
5
|
+
* - The transport PeerId uses a secp256k1 key read from the pillar's
|
|
6
|
+
* 32-byte seed. It differs from the Ed25519 identity used to sign
|
|
7
|
+
* envelopes; peerIdFromSeedHex derives the transport PeerId.
|
|
7
8
|
* - Kad-DHT is used for two things:
|
|
8
9
|
* 1. Peer routing (find PeerId -> multiaddrs)
|
|
9
10
|
* 2. Content routing (publish a UUAID -> hash mapping so anyone can
|
|
@@ -38,7 +39,7 @@ export const PILLAR_PROTOCOL = "/uuaid/pillar/1.0.0";
|
|
|
38
39
|
export const DHT_PROTOCOL_PREFIX = "/uuaid";
|
|
39
40
|
|
|
40
41
|
/**
|
|
41
|
-
* Build a libp2p node
|
|
42
|
+
* Build a libp2p node with the seed-derived secp256k1 transport identity.
|
|
42
43
|
*
|
|
43
44
|
* @param {{seedHex: string, listenAddrs?: string[], bootstrapPeers?: string[], enableRelay?: boolean, dhtClientMode?: boolean}} opts
|
|
44
45
|
*/
|
|
@@ -111,8 +112,10 @@ export function peerIdFromSeedHex(seedHex) {
|
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
/**
|
|
114
|
-
* Convert a raw Ed25519 public key hex to
|
|
115
|
-
*
|
|
115
|
+
* Convert a raw Ed25519 public key hex to its Ed25519 libp2p PeerId.
|
|
116
|
+
* This conversion does not identify the node started by createTransport,
|
|
117
|
+
* which uses a seed-derived secp256k1 key. Use peerIdFromSeedHex for that
|
|
118
|
+
* node; a UUAID's Ed25519 public key alone cannot derive its transport PeerId.
|
|
116
119
|
*/
|
|
117
120
|
export function peerIdFromEd25519Hex(publicKeyHex) {
|
|
118
121
|
const raw = Buffer.from(publicKeyHex, "hex");
|