@agentunion/fastaun 0.5.13 → 0.5.15
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 +39 -0
- package/_packed_docs/CHANGELOG.md +39 -0
- package/_packed_docs/aun/345/210/206/345/270/203/345/274/217/346/265/213/350/257/225/350/277/220/350/241/214/346/214/207/345/215/227.md +85 -4
- package/_packed_docs/aun/346/265/213/350/257/225/350/277/220/350/241/214/346/214/207/345/215/227.md +1 -1
- package/dist/client/delivery.d.ts +1 -0
- package/dist/client/delivery.js +81 -55
- package/dist/client/delivery.js.map +1 -1
- package/dist/client/rpc-pipeline.d.ts +3 -3
- package/dist/client/rpc-pipeline.js +34 -39
- package/dist/client/rpc-pipeline.js.map +1 -1
- package/dist/client/v2-e2ee.js +51 -16
- package/dist/client/v2-e2ee.js.map +1 -1
- package/dist/client.js +28 -23
- package/dist/client.js.map +1 -1
- package/dist/events.d.ts +18 -8
- package/dist/events.js +154 -50
- package/dist/events.js.map +1 -1
- package/dist/group-index.js +1 -1
- package/dist/group-index.js.map +1 -1
- package/dist/logger.d.ts +9 -1
- package/dist/logger.js +29 -7
- package/dist/logger.js.map +1 -1
- package/dist/result.d.ts +1 -2
- package/dist/result.js +2 -2
- package/dist/result.js.map +1 -1
- package/dist/transport.d.ts +7 -1
- package/dist/transport.js +139 -55
- package/dist/transport.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/client/v2-e2ee.js
CHANGED
|
@@ -10,6 +10,10 @@ const V2_GROUP_STALE_BOOTSTRAP_CODE = -33054;
|
|
|
10
10
|
const V2_PULL_DEFAULT_PAGE_LIMIT = 50;
|
|
11
11
|
const V2_PULL_MAX_PAGE_LIMIT = 50;
|
|
12
12
|
const V2_SENDER_IK_SYNC_FETCH_TIMEOUT_MS = 3_000;
|
|
13
|
+
function pullGateKeyForClient(client, method, params, fallback) {
|
|
14
|
+
const key = client._rpcPipeline?.pullGateKeyForCall?.(method, params);
|
|
15
|
+
return typeof key === 'string' && key ? key : fallback;
|
|
16
|
+
}
|
|
13
17
|
function strictWindowSeq(value, field, positive = false) {
|
|
14
18
|
if (!Number.isSafeInteger(value))
|
|
15
19
|
throw new ValidationError(`${field} must be an integer`);
|
|
@@ -1145,7 +1149,10 @@ export class V2E2EECoordinator {
|
|
|
1145
1149
|
const ns = client._aid ? `p2p:${client._aid}` : '';
|
|
1146
1150
|
if (ns)
|
|
1147
1151
|
client._delivery.syncStarted(ns);
|
|
1148
|
-
const
|
|
1152
|
+
const pullGateKey = pullGateKeyForClient(client, 'message.v2.pull', {
|
|
1153
|
+
window_mode: 'tail', after_seq: afterSeq, limit,
|
|
1154
|
+
}, `${ns}|tail|after=${afterSeq}|limit=${limit}`);
|
|
1155
|
+
const result = await client._callRawV2Rpc('message.v2.pull', { window_mode: 'tail', after_seq: afterSeq, limit, _rpc_foreground: true }, pullGateKey);
|
|
1149
1156
|
const page = validateTailPage(result, afterSeq, limit);
|
|
1150
1157
|
if (ns) {
|
|
1151
1158
|
client._seqTracker.commitTailWindow(ns, {
|
|
@@ -1197,14 +1204,18 @@ export class V2E2EECoordinator {
|
|
|
1197
1204
|
client._delivery.syncStarted(ns);
|
|
1198
1205
|
if (opts?.windowMode === 'tail') {
|
|
1199
1206
|
if (!opts.gateLocked) {
|
|
1200
|
-
const key =
|
|
1207
|
+
const key = pullGateKeyForClient(client, 'message.v2.pull', {
|
|
1208
|
+
window_mode: 'tail', after_seq: afterSeq, limit,
|
|
1209
|
+
}, `${ns}|tail|after=${afterSeq}|limit=${limit}`);
|
|
1201
1210
|
return (await client._runPullSerialized(key, () => this.pullV2Impl(afterSeq, limit, { ...opts, gateLocked: true }), false));
|
|
1202
1211
|
}
|
|
1203
1212
|
const result = await this.pullV2TailInternal({ window_mode: 'tail', after_seq: afterSeq, limit });
|
|
1204
1213
|
return (Array.isArray(result.messages) ? result.messages : []);
|
|
1205
1214
|
}
|
|
1206
1215
|
if (ns && !opts?.gateLocked) {
|
|
1207
|
-
const key =
|
|
1216
|
+
const key = pullGateKeyForClient(client, 'message.v2.pull', {
|
|
1217
|
+
after_seq: afterSeq, force: opts?.force === true, limit,
|
|
1218
|
+
}, `${ns}|forward|after=${afterSeq}|force=${String(Boolean(opts?.force))}|limit=${limit}`);
|
|
1208
1219
|
return await client._runPullSerialized(key, async () => this.pullV2Impl(afterSeq, limit, {
|
|
1209
1220
|
...(opts ?? {}),
|
|
1210
1221
|
gateLocked: true,
|
|
@@ -1214,7 +1225,9 @@ export class V2E2EECoordinator {
|
|
|
1214
1225
|
const decrypted = [];
|
|
1215
1226
|
let nextAfterSeq = opts?.force ? afterSeq : (afterSeq || (ns ? client._seqTracker.getContiguousSeq(ns) : 0));
|
|
1216
1227
|
let pullGateKey = ns
|
|
1217
|
-
?
|
|
1228
|
+
? pullGateKeyForClient(client, 'message.v2.pull', {
|
|
1229
|
+
after_seq: afterSeq, force: opts?.force === true, limit,
|
|
1230
|
+
}, `${ns}|forward|after=${afterSeq}|force=${String(Boolean(opts?.force))}|limit=${limit}`)
|
|
1218
1231
|
: '';
|
|
1219
1232
|
const deferredServerCursor = ns ? this.pendingForwardCursor(ns, ns ? client._seqTracker.getContiguousSeq(ns) : 0) : 0;
|
|
1220
1233
|
const deferredForwardAck = ns ? this.pendingForwardAck(ns, client._seqTracker.getContiguousSeq(ns)) : 0;
|
|
@@ -1234,7 +1247,7 @@ export class V2E2EECoordinator {
|
|
|
1234
1247
|
limit,
|
|
1235
1248
|
...(opts?.force ? { force: true } : {}),
|
|
1236
1249
|
...(ackUpToSeq > 0 ? { ack_up_to_seq: ackUpToSeq } : {}),
|
|
1237
|
-
});
|
|
1250
|
+
}, pullGateKey);
|
|
1238
1251
|
if (ackUpToSeq > 0) {
|
|
1239
1252
|
const actualAckSeq = client._delivery.resolveP2PPullAckSeq(result, ackUpToSeq);
|
|
1240
1253
|
if (actualAckSeq >= ackUpToSeq) {
|
|
@@ -1470,7 +1483,9 @@ export class V2E2EECoordinator {
|
|
|
1470
1483
|
if (!shouldContinue)
|
|
1471
1484
|
break;
|
|
1472
1485
|
if (pullGateKey && opts?.gateLocked && client._rpcPipeline?.yieldPullGate) {
|
|
1473
|
-
const nextKey =
|
|
1486
|
+
const nextKey = pullGateKeyForClient(client, 'message.v2.pull', {
|
|
1487
|
+
after_seq: nextAfter, force: opts?.force === true, limit,
|
|
1488
|
+
}, `${ns}|forward|after=${nextAfter}|force=${String(Boolean(opts?.force))}|limit=${limit}`);
|
|
1474
1489
|
await client._rpcPipeline.yieldPullGate(pullGateKey, nextKey, true);
|
|
1475
1490
|
pullGateKey = nextKey;
|
|
1476
1491
|
}
|
|
@@ -1793,21 +1808,30 @@ export class V2E2EECoordinator {
|
|
|
1793
1808
|
const afterSeq = strictWindowSeq(params.after_seq ?? 0, 'after_seq');
|
|
1794
1809
|
const limit = strictWindowLimit(params.limit ?? V2_PULL_DEFAULT_PAGE_LIMIT);
|
|
1795
1810
|
const ns = `group:${groupId}`;
|
|
1796
|
-
const
|
|
1797
|
-
? params._group_cursor_params :
|
|
1811
|
+
const explicitCursorParams = isJsonObject(params._group_cursor_params)
|
|
1812
|
+
? params._group_cursor_params : {};
|
|
1813
|
+
const cursorParams = Object.keys(explicitCursorParams).length > 0 ? explicitCursorParams : params;
|
|
1798
1814
|
const requestDeviceId = String(cursorParams.device_id ?? '').trim();
|
|
1799
1815
|
const requestSlotId = String(cursorParams.slot_id ?? '').trim();
|
|
1800
1816
|
const ownsCursor = (!requestDeviceId || requestDeviceId === String(client._deviceId ?? ''))
|
|
1801
1817
|
&& (!requestSlotId || requestSlotId === String(client._slotId ?? ''));
|
|
1802
1818
|
if (ownsCursor)
|
|
1803
1819
|
client._delivery.syncStarted(ns);
|
|
1820
|
+
const pullGateKey = pullGateKeyForClient(client, 'group.v2.pull', {
|
|
1821
|
+
group_id: groupId,
|
|
1822
|
+
window_mode: 'tail',
|
|
1823
|
+
after_seq: afterSeq,
|
|
1824
|
+
limit,
|
|
1825
|
+
_group_cursor_params: explicitCursorParams,
|
|
1826
|
+
}, `${ns}|tail|after=${afterSeq}|limit=${limit}`);
|
|
1804
1827
|
const result = await client._callRawV2Rpc('group.v2.pull', withExplicitGroupAid({
|
|
1805
1828
|
group_id: groupId,
|
|
1806
1829
|
window_mode: 'tail',
|
|
1807
1830
|
after_seq: afterSeq,
|
|
1808
1831
|
limit,
|
|
1832
|
+
_group_cursor_params: explicitCursorParams,
|
|
1809
1833
|
_rpc_foreground: true,
|
|
1810
|
-
}, groupAid));
|
|
1834
|
+
}, groupAid), pullGateKey);
|
|
1811
1835
|
const resultAid = String(result.group_aid ?? result.groupAid ?? '').trim();
|
|
1812
1836
|
if (resultAid)
|
|
1813
1837
|
groupAid = resultAid;
|
|
@@ -1884,7 +1908,10 @@ export class V2E2EECoordinator {
|
|
|
1884
1908
|
client._delivery.syncStarted(ns);
|
|
1885
1909
|
if (opts?.windowMode === 'tail') {
|
|
1886
1910
|
if (!opts.gateLocked) {
|
|
1887
|
-
const key =
|
|
1911
|
+
const key = pullGateKeyForClient(client, 'group.v2.pull', {
|
|
1912
|
+
group_id: gid, window_mode: 'tail', after_seq: afterSeq, limit,
|
|
1913
|
+
_group_cursor_params: opts?.cursorParams,
|
|
1914
|
+
}, `${ns}|tail|after=${afterSeq}|limit=${limit}`);
|
|
1888
1915
|
return (await client._runPullSerialized(key, () => this.pullGroupV2Impl(gid, afterSeq, limit, {
|
|
1889
1916
|
...opts,
|
|
1890
1917
|
gateLocked: true,
|
|
@@ -1892,6 +1919,7 @@ export class V2E2EECoordinator {
|
|
|
1892
1919
|
}
|
|
1893
1920
|
const result = await this.pullGroupV2TailInternal({
|
|
1894
1921
|
...(opts?.cursorParams ?? {}),
|
|
1922
|
+
_group_cursor_params: opts?.cursorParams,
|
|
1895
1923
|
group_id: String(opts.wireGroupId ?? gid),
|
|
1896
1924
|
group_aid: groupAid || undefined,
|
|
1897
1925
|
window_mode: 'tail',
|
|
@@ -1901,7 +1929,10 @@ export class V2E2EECoordinator {
|
|
|
1901
1929
|
return (Array.isArray(result.messages) ? result.messages : []);
|
|
1902
1930
|
}
|
|
1903
1931
|
if (!opts?.gateLocked) {
|
|
1904
|
-
const key =
|
|
1932
|
+
const key = pullGateKeyForClient(client, 'group.v2.pull', {
|
|
1933
|
+
group_id: gid, after_seq: afterSeq, force: opts?.force === true, limit,
|
|
1934
|
+
_group_cursor_params: opts?.cursorParams,
|
|
1935
|
+
}, `${ns}|forward|after=${afterSeq}|force=${opts?.force === true}|limit=${limit}`);
|
|
1905
1936
|
return await client._runPullSerialized(key, async () => this.pullGroupV2Impl(gid, afterSeq, limit, {
|
|
1906
1937
|
...(opts ?? {}),
|
|
1907
1938
|
gateLocked: true,
|
|
@@ -1912,9 +1943,10 @@ export class V2E2EECoordinator {
|
|
|
1912
1943
|
const wireGroupId = String(opts?.wireGroupId ?? groupId ?? '').trim() || gid;
|
|
1913
1944
|
const cursorParams = opts?.cursorParams ?? {};
|
|
1914
1945
|
const ownsCursor = opts?.ownsCursor !== false;
|
|
1915
|
-
let pullGateKey =
|
|
1916
|
-
|
|
1917
|
-
:
|
|
1946
|
+
let pullGateKey = pullGateKeyForClient(client, 'group.v2.pull', {
|
|
1947
|
+
group_id: gid, after_seq: afterSeq, force: opts?.force === true, limit,
|
|
1948
|
+
_group_cursor_params: cursorParams,
|
|
1949
|
+
}, `${ns}|forward|after=${afterSeq}|force=${String(Boolean(opts?.force))}|limit=${limit}`);
|
|
1918
1950
|
let nextAfterSeq = (opts?.explicitAfterSeq || opts?.force)
|
|
1919
1951
|
? afterSeq
|
|
1920
1952
|
: (afterSeq || client._seqTracker.getContiguousSeq(ns));
|
|
@@ -1940,7 +1972,7 @@ export class V2E2EECoordinator {
|
|
|
1940
1972
|
...cursorParams,
|
|
1941
1973
|
...(opts?.force ? { force: true } : {}),
|
|
1942
1974
|
...(ackUpToSeq > 0 ? { ack_up_to_seq: ackUpToSeq } : {}),
|
|
1943
|
-
}, groupAid));
|
|
1975
|
+
}, groupAid), pullGateKey);
|
|
1944
1976
|
if (ackUpToSeq > 0) {
|
|
1945
1977
|
const actualAckSeq = client._delivery.resolveGroupPullAckSeq(result, ackUpToSeq);
|
|
1946
1978
|
if (actualAckSeq >= ackUpToSeq) {
|
|
@@ -2214,7 +2246,10 @@ export class V2E2EECoordinator {
|
|
|
2214
2246
|
if (!shouldContinue)
|
|
2215
2247
|
break;
|
|
2216
2248
|
if (pullGateKey && opts?.gateLocked && client._rpcPipeline?.yieldPullGate) {
|
|
2217
|
-
const nextKey =
|
|
2249
|
+
const nextKey = pullGateKeyForClient(client, 'group.v2.pull', {
|
|
2250
|
+
group_id: gid, after_seq: nextAfter, force: opts?.force === true, limit,
|
|
2251
|
+
_group_cursor_params: cursorParams,
|
|
2252
|
+
}, `${ns}|forward|after=${nextAfter}|force=${String(Boolean(opts?.force))}|limit=${limit}`);
|
|
2218
2253
|
await client._rpcPipeline.yieldPullGate(pullGateKey, nextKey, true);
|
|
2219
2254
|
pullGateKey = nextKey;
|
|
2220
2255
|
}
|