@agentunion/fastaun-browser 0.5.8 → 0.5.9
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 +30 -0
- package/_packed_docs/CHANGELOG.md +30 -0
- package/_packed_docs/agent.md/examples//347/276/244/347/273/204-/345/274/200/345/217/221/345/233/242/351/230/237.md +21 -0
- package/dist/agent-md.d.ts.map +1 -1
- package/dist/agent-md.js +1 -0
- package/dist/agent-md.js.map +1 -1
- package/dist/aid-store.d.ts.map +1 -1
- package/dist/aid-store.js +1 -3
- package/dist/aid-store.js.map +1 -1
- package/dist/bundle.js +454 -83
- package/dist/client/delivery.d.ts +7 -0
- package/dist/client/delivery.d.ts.map +1 -1
- package/dist/client/delivery.js +140 -19
- package/dist/client/delivery.js.map +1 -1
- package/dist/client/group-state.js +2 -2
- package/dist/client/group-state.js.map +1 -1
- package/dist/client/lifecycle.d.ts.map +1 -1
- package/dist/client/lifecycle.js +15 -4
- package/dist/client/lifecycle.js.map +1 -1
- package/dist/client/rpc-pipeline.d.ts +8 -0
- package/dist/client/rpc-pipeline.d.ts.map +1 -1
- package/dist/client/rpc-pipeline.js +149 -34
- package/dist/client/rpc-pipeline.js.map +1 -1
- package/dist/client/v2-e2ee.d.ts.map +1 -1
- package/dist/client/v2-e2ee.js +50 -12
- package/dist/client/v2-e2ee.js.map +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +105 -13
- package/dist/client.js.map +1 -1
- package/dist/facades.d.ts.map +1 -1
- package/dist/facades.js +7 -3
- package/dist/facades.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/_packed_docs//345/217/221/345/270/203/346/212/245/345/221/212-0.5.6.md +0 -260
package/dist/client/v2-e2ee.js
CHANGED
|
@@ -4,6 +4,10 @@ import { decryptMessage, encryptGroupMessage, encryptP2PMessage, } from '../v2/e
|
|
|
4
4
|
import { V2Session, V2KeyStore } from '../v2/session/index.js';
|
|
5
5
|
import { ConnectionState, isJsonObject } from '../types.js';
|
|
6
6
|
import { normalizeGroupMentionMode } from './mention-mode.js';
|
|
7
|
+
function pullGateKeyForClient(client, method, params, fallback) {
|
|
8
|
+
const key = client._rpcPipeline?.pullGateKeyForCall?.(method, params);
|
|
9
|
+
return typeof key === 'string' && key ? key : fallback;
|
|
10
|
+
}
|
|
7
11
|
const V2_BOOTSTRAP_TTL_MS = 60 * 60 * 1000;
|
|
8
12
|
const V2_RETRYABLE_CODES = new Set([-33011, -33012, -33050, -33052, -33054]);
|
|
9
13
|
const V2_GROUP_STALE_BOOTSTRAP_CODE = -33054;
|
|
@@ -1152,7 +1156,9 @@ export class V2E2EECoordinator {
|
|
|
1152
1156
|
const ns = client._aid ? `p2p:${client._aid}` : '';
|
|
1153
1157
|
if (opts?.windowMode === 'tail') {
|
|
1154
1158
|
if (!opts.gateLocked) {
|
|
1155
|
-
const key =
|
|
1159
|
+
const key = pullGateKeyForClient(client, 'message.v2.pull', {
|
|
1160
|
+
window_mode: 'tail', after_seq: afterSeq, limit,
|
|
1161
|
+
}, `${ns}|tail|after=${afterSeq}|limit=${limit}`);
|
|
1156
1162
|
return await client._runPullSerialized(key, () => this.pullV2(afterSeq, limit, {
|
|
1157
1163
|
...(opts ?? {}),
|
|
1158
1164
|
gateLocked: true,
|
|
@@ -1162,7 +1168,9 @@ export class V2E2EECoordinator {
|
|
|
1162
1168
|
return Array.isArray(result.messages) ? result.messages : [];
|
|
1163
1169
|
}
|
|
1164
1170
|
if (ns && !opts?.gateLocked) {
|
|
1165
|
-
const key =
|
|
1171
|
+
const key = pullGateKeyForClient(client, 'message.v2.pull', {
|
|
1172
|
+
after_seq: afterSeq, force: opts?.force === true, limit,
|
|
1173
|
+
}, `${ns}|forward|after=${afterSeq}|force=${String(Boolean(opts?.force))}|limit=${limit}`);
|
|
1166
1174
|
return await client._runPullSerialized(key, () => this.pullV2(afterSeq, limit, {
|
|
1167
1175
|
...(opts ?? {}),
|
|
1168
1176
|
gateLocked: true,
|
|
@@ -1171,7 +1179,9 @@ export class V2E2EECoordinator {
|
|
|
1171
1179
|
const decrypted = [];
|
|
1172
1180
|
let nextAfterSeq = opts?.force ? afterSeq : (afterSeq || (ns ? client._seqTracker.getContiguousSeq(ns) : 0));
|
|
1173
1181
|
let pullGateKey = ns
|
|
1174
|
-
?
|
|
1182
|
+
? pullGateKeyForClient(client, 'message.v2.pull', {
|
|
1183
|
+
after_seq: afterSeq, force: opts?.force === true, limit,
|
|
1184
|
+
}, `${ns}|forward|after=${afterSeq}|force=${String(Boolean(opts?.force))}|limit=${limit}`)
|
|
1175
1185
|
: '';
|
|
1176
1186
|
const deferredServerCursor = ns ? this.pendingForwardCursor(ns, client._seqTracker.getContiguousSeq(ns)) : 0;
|
|
1177
1187
|
const deferredForwardAck = ns ? this.pendingForwardAck(ns, client._seqTracker.getContiguousSeq(ns)) : 0;
|
|
@@ -1224,6 +1234,7 @@ export class V2E2EECoordinator {
|
|
|
1224
1234
|
: null;
|
|
1225
1235
|
const pageMaxSeq = seqs.length > 0 ? Math.max(...seqs) : nextAfterSeq;
|
|
1226
1236
|
const deferredKeyFetches = new Map();
|
|
1237
|
+
let blockedSeq = 0;
|
|
1227
1238
|
for (const msg of messages) {
|
|
1228
1239
|
const seq = Number(msg.seq ?? 0);
|
|
1229
1240
|
if (!Number.isFinite(seq) || seq <= 0)
|
|
@@ -1270,6 +1281,9 @@ export class V2E2EECoordinator {
|
|
|
1270
1281
|
}
|
|
1271
1282
|
const deferStatus = {};
|
|
1272
1283
|
const plaintext = await client._decryptV2Message(msg, true, true, true, true, deferStatus, true);
|
|
1284
|
+
if (deferStatus.deferred) {
|
|
1285
|
+
blockedSeq = blockedSeq > 0 ? Math.min(blockedSeq, seq) : seq;
|
|
1286
|
+
}
|
|
1273
1287
|
if (deferStatus.deferred && deferStatus.fromAid) {
|
|
1274
1288
|
const key = `${deferStatus.fromAid}\u0000${deferStatus.senderDeviceId ?? ''}\u0000${deferStatus.groupId ?? ''}`;
|
|
1275
1289
|
deferredKeyFetches.set(key, {
|
|
@@ -1294,7 +1308,7 @@ export class V2E2EECoordinator {
|
|
|
1294
1308
|
const serverAckSeq = parsedServerAckSeq ?? 0;
|
|
1295
1309
|
const retentionFloor = Math.max(0, Number(result.retention_floor_seq ?? 0));
|
|
1296
1310
|
if (ns) {
|
|
1297
|
-
const commitTarget = Math.max(pageContigBefore, Number.isFinite(retentionFloor) ? retentionFloor : 0, pageCount === 1 ? deferredServerCursor : 0, seqs.length > 0 ? pageMaxSeq : pageContigBefore);
|
|
1311
|
+
const commitTarget = blockedSeq > 0 ? pageContigBefore : Math.max(pageContigBefore, Number.isFinite(retentionFloor) ? retentionFloor : 0, pageCount === 1 ? deferredServerCursor : 0, seqs.length > 0 ? pageMaxSeq : pageContigBefore);
|
|
1298
1312
|
let ackSeq = pageContigBefore;
|
|
1299
1313
|
let contigAdvanced = false;
|
|
1300
1314
|
try {
|
|
@@ -1338,7 +1352,8 @@ export class V2E2EECoordinator {
|
|
|
1338
1352
|
const knownServerAckSeq = hasServerAckSeq
|
|
1339
1353
|
? serverAckSeq
|
|
1340
1354
|
: (pageCount === 1 ? deferredServerCursor : 0);
|
|
1341
|
-
const ackNeeded =
|
|
1355
|
+
const ackNeeded = blockedSeq <= 0
|
|
1356
|
+
&& ackSeq > 0
|
|
1342
1357
|
&& ackSeq > lastAutoAckSeq
|
|
1343
1358
|
&& ((hasServerAckSeq && ackSeq > serverAckSeq)
|
|
1344
1359
|
|| (contigAdvanced && ackSeq > knownServerAckSeq));
|
|
@@ -1358,6 +1373,8 @@ export class V2E2EECoordinator {
|
|
|
1358
1373
|
}
|
|
1359
1374
|
const nextAfter = Math.max(pageMaxSeq, nextAfterSeq);
|
|
1360
1375
|
const rawCount = messages.length;
|
|
1376
|
+
if (blockedSeq > 0)
|
|
1377
|
+
break;
|
|
1361
1378
|
const shouldContinue = shouldContinueForwardPage({
|
|
1362
1379
|
rawCount,
|
|
1363
1380
|
nextAfterSeq,
|
|
@@ -1371,7 +1388,9 @@ export class V2E2EECoordinator {
|
|
|
1371
1388
|
if (!shouldContinue)
|
|
1372
1389
|
break;
|
|
1373
1390
|
if (pullGateKey && opts?.gateLocked && client._rpcPipeline?.yieldPullGate) {
|
|
1374
|
-
const nextKey =
|
|
1391
|
+
const nextKey = pullGateKeyForClient(client, 'message.v2.pull', {
|
|
1392
|
+
after_seq: nextAfter, force: opts?.force === true, limit,
|
|
1393
|
+
}, `${ns}|forward|after=${nextAfter}|force=${String(Boolean(opts?.force))}|limit=${limit}`);
|
|
1375
1394
|
await client._rpcPipeline.yieldPullGate(pullGateKey, nextKey, true);
|
|
1376
1395
|
pullGateKey = nextKey;
|
|
1377
1396
|
}
|
|
@@ -1605,7 +1624,10 @@ export class V2E2EECoordinator {
|
|
|
1605
1624
|
const ns = `group:${gid}`;
|
|
1606
1625
|
if (opts?.windowMode === 'tail') {
|
|
1607
1626
|
if (!opts.gateLocked) {
|
|
1608
|
-
const key =
|
|
1627
|
+
const key = pullGateKeyForClient(client, 'group.v2.pull', {
|
|
1628
|
+
group_id: gid, window_mode: 'tail', after_seq: afterSeq, limit,
|
|
1629
|
+
_group_cursor_params: opts?.cursorParams,
|
|
1630
|
+
}, `${ns}|tail|after=${afterSeq}|limit=${limit}`);
|
|
1609
1631
|
return await client._runPullSerialized(key, () => this.pullGroupV2(gid, afterSeq, limit, {
|
|
1610
1632
|
...(opts ?? {}),
|
|
1611
1633
|
gateLocked: true,
|
|
@@ -1618,7 +1640,10 @@ export class V2E2EECoordinator {
|
|
|
1618
1640
|
return Array.isArray(result.messages) ? result.messages : [];
|
|
1619
1641
|
}
|
|
1620
1642
|
if (!opts?.gateLocked) {
|
|
1621
|
-
const key =
|
|
1643
|
+
const key = pullGateKeyForClient(client, 'group.v2.pull', {
|
|
1644
|
+
group_id: gid, after_seq: afterSeq, force: opts?.force === true, limit,
|
|
1645
|
+
_group_cursor_params: opts?.cursorParams,
|
|
1646
|
+
}, `${ns}|forward|after=${afterSeq}|force=${String(Boolean(opts?.force))}|limit=${limit}`);
|
|
1622
1647
|
return await client._runPullSerialized(key, () => this.pullGroupV2(gid, afterSeq, limit, {
|
|
1623
1648
|
...(opts ?? {}),
|
|
1624
1649
|
gateLocked: true,
|
|
@@ -1629,7 +1654,10 @@ export class V2E2EECoordinator {
|
|
|
1629
1654
|
const cursorParams = opts?.cursorParams ?? {};
|
|
1630
1655
|
const ownsCursor = opts?.ownsCursor !== false;
|
|
1631
1656
|
let pullGateKey = ownsCursor
|
|
1632
|
-
?
|
|
1657
|
+
? pullGateKeyForClient(client, 'group.v2.pull', {
|
|
1658
|
+
group_id: gid, after_seq: afterSeq, force: opts?.force === true, limit,
|
|
1659
|
+
_group_cursor_params: cursorParams,
|
|
1660
|
+
}, `${ns}|forward|after=${afterSeq}|force=${String(Boolean(opts?.force))}|limit=${limit}`)
|
|
1633
1661
|
: '';
|
|
1634
1662
|
let nextAfterSeq = (opts?.explicitAfterSeq || opts?.force)
|
|
1635
1663
|
? afterSeq
|
|
@@ -1692,6 +1720,7 @@ export class V2E2EECoordinator {
|
|
|
1692
1720
|
: null;
|
|
1693
1721
|
const pageMaxSeq = seqs.length > 0 ? Math.max(...seqs) : nextAfterSeq;
|
|
1694
1722
|
const deferredKeyFetches = new Map();
|
|
1723
|
+
let blockedSeq = 0;
|
|
1695
1724
|
for (const msg of messages) {
|
|
1696
1725
|
const seq = Number(msg.seq ?? 0);
|
|
1697
1726
|
if (!Number.isFinite(seq) || seq <= 0)
|
|
@@ -1759,6 +1788,9 @@ export class V2E2EECoordinator {
|
|
|
1759
1788
|
}
|
|
1760
1789
|
const deferStatus = {};
|
|
1761
1790
|
let plaintext = await client._decryptV2Message(msg, true, true, true, true, deferStatus, true);
|
|
1791
|
+
if (deferStatus.deferred) {
|
|
1792
|
+
blockedSeq = blockedSeq > 0 ? Math.min(blockedSeq, seq) : seq;
|
|
1793
|
+
}
|
|
1762
1794
|
if (deferStatus.deferred && deferStatus.fromAid) {
|
|
1763
1795
|
const key = `${deferStatus.fromAid}\u0000${deferStatus.senderDeviceId ?? ''}\u0000${deferStatus.groupId ?? ''}`;
|
|
1764
1796
|
deferredKeyFetches.set(key, {
|
|
@@ -1781,7 +1813,7 @@ export class V2E2EECoordinator {
|
|
|
1781
1813
|
const retentionFloor = Math.max(Number(result.retention_floor_message_seq ?? result.retention_floor_seq ?? 0), Number(cursor?.retention_floor_seq ?? 0));
|
|
1782
1814
|
const visibilityFloor = Math.max(0, Math.max(0, Number(result.earliest_available_message_seq ?? 1) - 1), Number(cursor?.join_seq ?? 0));
|
|
1783
1815
|
const effectiveFloor = Math.max(retentionFloor, visibilityFloor);
|
|
1784
|
-
const commitTarget = Math.max(pageContigBefore, Number.isFinite(effectiveFloor) ? effectiveFloor : 0, ownsCursor && pageCount === 1 ? deferredServerCursor : 0, seqs.length > 0 ? pageMaxSeq : pageContigBefore);
|
|
1816
|
+
const commitTarget = blockedSeq > 0 ? pageContigBefore : Math.max(pageContigBefore, Number.isFinite(effectiveFloor) ? effectiveFloor : 0, ownsCursor && pageCount === 1 ? deferredServerCursor : 0, seqs.length > 0 ? pageMaxSeq : pageContigBefore);
|
|
1785
1817
|
let ackSeq = pageContigBefore;
|
|
1786
1818
|
let contigAdvanced = false;
|
|
1787
1819
|
if (ownsCursor) {
|
|
@@ -1827,7 +1859,8 @@ export class V2E2EECoordinator {
|
|
|
1827
1859
|
const knownServerCursorSeq = hasServerCursor
|
|
1828
1860
|
? cursorCurrentSeq
|
|
1829
1861
|
: (ownsCursor && pageCount === 1 ? deferredServerCursor : 0);
|
|
1830
|
-
const ackNeeded =
|
|
1862
|
+
const ackNeeded = blockedSeq <= 0
|
|
1863
|
+
&& ackSeq > 0
|
|
1831
1864
|
&& ackSeq > lastAutoAckSeq
|
|
1832
1865
|
&& ownsCursor
|
|
1833
1866
|
&& ((hasServerCursor && ackSeq > cursorCurrentSeq)
|
|
@@ -1849,6 +1882,8 @@ export class V2E2EECoordinator {
|
|
|
1849
1882
|
if (!ownsCursor)
|
|
1850
1883
|
break;
|
|
1851
1884
|
const rawCount = messages.length;
|
|
1885
|
+
if (blockedSeq > 0)
|
|
1886
|
+
break;
|
|
1852
1887
|
const shouldContinue = shouldContinueForwardPage({
|
|
1853
1888
|
rawCount,
|
|
1854
1889
|
nextAfterSeq,
|
|
@@ -1862,7 +1897,10 @@ export class V2E2EECoordinator {
|
|
|
1862
1897
|
if (!shouldContinue)
|
|
1863
1898
|
break;
|
|
1864
1899
|
if (pullGateKey && opts?.gateLocked && client._rpcPipeline?.yieldPullGate) {
|
|
1865
|
-
const nextKey =
|
|
1900
|
+
const nextKey = pullGateKeyForClient(client, 'group.v2.pull', {
|
|
1901
|
+
group_id: gid, after_seq: nextAfter, force: opts?.force === true, limit,
|
|
1902
|
+
_group_cursor_params: cursorParams,
|
|
1903
|
+
}, `${ns}|forward|after=${nextAfter}|force=${String(Boolean(opts?.force))}|limit=${limit}`);
|
|
1866
1904
|
await client._rpcPipeline.yieldPullGate(pullGateKey, nextKey, true);
|
|
1867
1905
|
pullGateKey = nextKey;
|
|
1868
1906
|
}
|