@agentunion/fastaun-browser 0.5.10 → 0.5.11
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 +32 -0
- package/_packed_docs/CHANGELOG.md +32 -0
- package/_packed_docs/INDEX.md +3 -3
- package/_packed_docs/KITE_DOCS_GUIDE.md +1 -1
- package/_packed_docs/sdk/06-API/346/211/213/345/206/214.md +59 -0
- package/_packed_docs/sdk/AUN_DOCS_GUIDE.md +3 -2
- package/_packed_docs/sdk/INDEX.md +2 -1
- package/dist/bundle.js +588 -88
- package/dist/client/delivery.d.ts +11 -4
- package/dist/client/delivery.d.ts.map +1 -1
- package/dist/client/delivery.js +180 -31
- package/dist/client/delivery.js.map +1 -1
- package/dist/client/rpc-pipeline.d.ts.map +1 -1
- package/dist/client/rpc-pipeline.js +14 -2
- package/dist/client/rpc-pipeline.js.map +1 -1
- package/dist/client/v2-e2ee.d.ts +3 -0
- package/dist/client/v2-e2ee.d.ts.map +1 -1
- package/dist/client/v2-e2ee.js +147 -32
- package/dist/client/v2-e2ee.js.map +1 -1
- package/dist/client.d.ts +1 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +61 -2
- package/dist/client.js.map +1 -1
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +159 -15
- 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
|
@@ -13,6 +13,9 @@ type GroupEventGapOptions = {
|
|
|
13
13
|
};
|
|
14
14
|
export declare class MessageDeliveryEngine {
|
|
15
15
|
private readonly runtime;
|
|
16
|
+
private syncRun;
|
|
17
|
+
private syncingNamespaces;
|
|
18
|
+
private syncSessions;
|
|
16
19
|
private pendingPullDeliveryChanges;
|
|
17
20
|
private deliveryGeneration;
|
|
18
21
|
private realtimeTailResults;
|
|
@@ -36,6 +39,10 @@ export declare class MessageDeliveryEngine {
|
|
|
36
39
|
captureInlineGeneration(): number;
|
|
37
40
|
private beginRealtimeSync;
|
|
38
41
|
private endRealtimeSync;
|
|
42
|
+
onPullStarted(ns: string): void;
|
|
43
|
+
onPullPage(ns: string, pulledCount: number, hasMore: boolean, maxSeen?: number, remaining?: number | null, rawCount?: number, currentSeq?: number, targetSeq?: number): void;
|
|
44
|
+
onPullAborted(): void;
|
|
45
|
+
private syncStopped;
|
|
39
46
|
hasPendingPull(ns: string): boolean;
|
|
40
47
|
onPullGateIdle(ns: string): void;
|
|
41
48
|
onPullWorkSettled(): void;
|
|
@@ -89,10 +96,10 @@ export declare class MessageDeliveryEngine {
|
|
|
89
96
|
enqueueOrderedMessage(ns: string, event: string, seq: number, payload: EventPayload, source?: string): void;
|
|
90
97
|
isGroupEventNamespace(ns: string): boolean;
|
|
91
98
|
publishOrderedQueueItem(ns: string, event: string, seq: number, payload: EventPayload, pullResponse?: boolean, source?: string, batch?: DeliveryChangeBatch): Promise<void>;
|
|
92
|
-
publishOrderedGroupChanged(payload: EventPayload): Promise<void>;
|
|
99
|
+
publishOrderedGroupChanged(payload: EventPayload, source?: string): Promise<void>;
|
|
93
100
|
isInstanceScopedMessageEvent(event: string): boolean;
|
|
94
101
|
attachCurrentInstanceContext(payload: EventPayload): EventPayload;
|
|
95
|
-
normalizePublishedMessagePayload(event: string, payload: EventPayload): EventPayload;
|
|
102
|
+
normalizePublishedMessagePayload(event: string, payload: EventPayload, source?: string): EventPayload;
|
|
96
103
|
private stripInlineInternalFields;
|
|
97
104
|
private envelopeMetadata;
|
|
98
105
|
appMessageEnvelope(payload: EventPayload): JsonObject;
|
|
@@ -109,10 +116,10 @@ export declare class MessageDeliveryEngine {
|
|
|
109
116
|
payload: EventPayload;
|
|
110
117
|
};
|
|
111
118
|
messageRecallDedupKey(payload: JsonObject): string;
|
|
112
|
-
publishMessageRecallTombstone(seq: unknown, message: EventPayload): Promise<boolean>;
|
|
119
|
+
publishMessageRecallTombstone(seq: unknown, message: EventPayload, source?: string): Promise<boolean>;
|
|
113
120
|
recallEventFromGroupMessage(message: EventPayload): JsonObject | null;
|
|
114
121
|
groupRecallDedupKey(groupId: string, payload: JsonObject): string;
|
|
115
|
-
publishGroupRecallTombstone(groupId: string, seq: unknown, message: EventPayload): Promise<boolean>;
|
|
122
|
+
publishGroupRecallTombstone(groupId: string, seq: unknown, message: EventPayload, source?: string): Promise<boolean>;
|
|
116
123
|
onRawGroupMessageRecalled(data: EventPayload): Promise<void>;
|
|
117
124
|
publishAppEvent(event: string, payload: EventPayload, source?: string, ns?: string, batch?: DeliveryChangeBatch): Promise<void>;
|
|
118
125
|
messageTargetsCurrentInstance(message: EventPayload): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delivery.d.ts","sourceRoot":"","sources":["../../src/client/delivery.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAiC,KAAK,UAAU,EAAkB,KAAK,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAE3H,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAmClD,MAAM,MAAM,mBAAmB,GAAG;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,GAAG,aAAa,CAAC;IAChC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAcF,KAAK,oBAAoB,GAAG;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;
|
|
1
|
+
{"version":3,"file":"delivery.d.ts","sourceRoot":"","sources":["../../src/client/delivery.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAiC,KAAK,UAAU,EAAkB,KAAK,OAAO,EAAE,KAAK,SAAS,EAAE,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GACpH,OAAO,CAAC,OAAO,CAAC;IAsCb,oBAAoB,CACxB,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,UAAO,EAAE,MAAM,SAAS,EAAE,cAAc,CAAC,EAAE,mBAAmB,GACpI,OAAO,CAAC,OAAO,CAAC;CA6CpB"}
|
package/dist/client/delivery.js
CHANGED
|
@@ -63,6 +63,26 @@ function nonNegativeSafeSequenceHint(value) {
|
|
|
63
63
|
return null;
|
|
64
64
|
return value;
|
|
65
65
|
}
|
|
66
|
+
function canonicalDeliverySource(source) {
|
|
67
|
+
switch (String(source ?? '').trim()) {
|
|
68
|
+
case 'group-push':
|
|
69
|
+
case 'ordered':
|
|
70
|
+
case 'legacy':
|
|
71
|
+
return 'push';
|
|
72
|
+
case 'tail':
|
|
73
|
+
case 'pull-drained':
|
|
74
|
+
case 'pull_drained':
|
|
75
|
+
return 'pull';
|
|
76
|
+
case 'inline-push':
|
|
77
|
+
return 'inline_push';
|
|
78
|
+
case 'pending-retry':
|
|
79
|
+
return 'pending_retry';
|
|
80
|
+
case '':
|
|
81
|
+
return 'direct';
|
|
82
|
+
default:
|
|
83
|
+
return String(source).trim();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
66
86
|
function deduplicatePlainForwardPageMessages(value, afterSeq) {
|
|
67
87
|
if (!Array.isArray(value))
|
|
68
88
|
return [];
|
|
@@ -95,6 +115,9 @@ function p2pAppEventFromPlainPullMessage(message) {
|
|
|
95
115
|
}
|
|
96
116
|
export class MessageDeliveryEngine {
|
|
97
117
|
runtime;
|
|
118
|
+
syncRun = 0;
|
|
119
|
+
syncingNamespaces = new Set();
|
|
120
|
+
syncSessions = new Map();
|
|
98
121
|
pendingPullDeliveryChanges = null;
|
|
99
122
|
deliveryGeneration = 0;
|
|
100
123
|
realtimeTailResults = null;
|
|
@@ -116,6 +139,7 @@ export class MessageDeliveryEngine {
|
|
|
116
139
|
this.runtime = runtime;
|
|
117
140
|
}
|
|
118
141
|
resetInlineAckState() {
|
|
142
|
+
this.syncStopped('aborted');
|
|
119
143
|
this.inlineGeneration += 1;
|
|
120
144
|
this.deliveryGeneration += 1;
|
|
121
145
|
this.pendingPullDeliveryChanges = null;
|
|
@@ -131,6 +155,8 @@ export class MessageDeliveryEngine {
|
|
|
131
155
|
this.pendingP2PInlineAcks = null;
|
|
132
156
|
this.pendingGroupInlineAcks = null;
|
|
133
157
|
this.pendingGroupInlineAckNamespaces = null;
|
|
158
|
+
this.syncingNamespaces.clear();
|
|
159
|
+
this.syncSessions.clear();
|
|
134
160
|
}
|
|
135
161
|
isInlineGenerationCurrent(generation) {
|
|
136
162
|
return generation === this.inlineGeneration;
|
|
@@ -163,6 +189,95 @@ export class MessageDeliveryEngine {
|
|
|
163
189
|
endRealtimeSync(ns) {
|
|
164
190
|
this.realtimeSyncing?.delete(ns);
|
|
165
191
|
}
|
|
192
|
+
onPullStarted(ns) {
|
|
193
|
+
if (!ns || this.syncingNamespaces.has(ns))
|
|
194
|
+
return;
|
|
195
|
+
if (this.syncingNamespaces.size === 0) {
|
|
196
|
+
this.syncRun += 1;
|
|
197
|
+
this.syncSessions.clear();
|
|
198
|
+
this.runtime.client._dispatcher?.enqueue?.('sync.started', {
|
|
199
|
+
run_id: this.syncRun,
|
|
200
|
+
source: 'pull',
|
|
201
|
+
syncing: true,
|
|
202
|
+
namespaces_pending: 1,
|
|
203
|
+
received_total: 0,
|
|
204
|
+
namespace: ns,
|
|
205
|
+
started_at: Date.now(),
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
this.syncingNamespaces.add(ns);
|
|
209
|
+
this.syncSessions.set(ns, { pages: 0, raw: 0, pulled: 0 });
|
|
210
|
+
}
|
|
211
|
+
onPullPage(ns, pulledCount, hasMore, maxSeen, remaining, rawCount = pulledCount, currentSeq, targetSeq) {
|
|
212
|
+
this.onPullStarted(ns);
|
|
213
|
+
if (!ns)
|
|
214
|
+
return;
|
|
215
|
+
const session = this.syncSessions.get(ns) ?? { pages: 0, raw: 0, pulled: 0 };
|
|
216
|
+
session.pages += 1;
|
|
217
|
+
session.raw += Math.max(0, rawCount);
|
|
218
|
+
session.pulled += Math.max(0, pulledCount);
|
|
219
|
+
this.syncSessions.set(ns, session);
|
|
220
|
+
const received = session.pulled;
|
|
221
|
+
const progress = {
|
|
222
|
+
run_id: this.syncRun,
|
|
223
|
+
source: 'pull',
|
|
224
|
+
namespace: ns,
|
|
225
|
+
page: session.pages,
|
|
226
|
+
page_raw_count: Math.max(0, rawCount),
|
|
227
|
+
page_pulled_count: Math.max(0, pulledCount),
|
|
228
|
+
pulled_count: received,
|
|
229
|
+
received_total: received,
|
|
230
|
+
batch_size: Math.max(0, pulledCount),
|
|
231
|
+
estimated_remaining: hasMore ? undefined : 0,
|
|
232
|
+
max_seen: maxSeen,
|
|
233
|
+
has_more: hasMore,
|
|
234
|
+
};
|
|
235
|
+
if (typeof currentSeq === 'number' && Number.isSafeInteger(currentSeq) && currentSeq >= 0) {
|
|
236
|
+
progress.current_seq = currentSeq;
|
|
237
|
+
}
|
|
238
|
+
if (typeof targetSeq === 'number' && Number.isSafeInteger(targetSeq) && targetSeq >= 0) {
|
|
239
|
+
progress.target_seq = targetSeq;
|
|
240
|
+
}
|
|
241
|
+
if (typeof remaining === 'number' && Number.isSafeInteger(remaining) && remaining >= 0) {
|
|
242
|
+
progress.remaining = remaining;
|
|
243
|
+
progress.estimated_remaining = progress.remaining;
|
|
244
|
+
}
|
|
245
|
+
this.runtime.client._dispatcher?.enqueue?.('sync.progress', progress);
|
|
246
|
+
}
|
|
247
|
+
onPullAborted() {
|
|
248
|
+
this.syncStopped('aborted');
|
|
249
|
+
}
|
|
250
|
+
syncStopped(reason = 'pull_drained') {
|
|
251
|
+
if (this.syncingNamespaces.size === 0)
|
|
252
|
+
return;
|
|
253
|
+
const sessions = [...this.syncSessions.entries()];
|
|
254
|
+
const receivedTotal = sessions.reduce((total, [, session]) => total + session.pulled, 0);
|
|
255
|
+
this.syncingNamespaces.clear();
|
|
256
|
+
this.syncSessions.clear();
|
|
257
|
+
const payload = {
|
|
258
|
+
run_id: this.syncRun,
|
|
259
|
+
source: 'pull',
|
|
260
|
+
syncing: false,
|
|
261
|
+
namespaces_pending: 0,
|
|
262
|
+
received_total: receivedTotal,
|
|
263
|
+
reason,
|
|
264
|
+
stopped_at: Date.now(),
|
|
265
|
+
};
|
|
266
|
+
if (sessions.length === 1) {
|
|
267
|
+
const [namespace, session] = sessions[0];
|
|
268
|
+
payload.namespace = namespace;
|
|
269
|
+
payload.pages = session.pages;
|
|
270
|
+
payload.pulled_count = session.pulled;
|
|
271
|
+
}
|
|
272
|
+
else if (sessions.length > 1) {
|
|
273
|
+
payload.namespaces = sessions.map(([namespace]) => namespace);
|
|
274
|
+
payload.pages = sessions.reduce((total, [, session]) => total + session.pages, 0);
|
|
275
|
+
payload.pulled_count = receivedTotal;
|
|
276
|
+
}
|
|
277
|
+
this.runtime.client._dispatcher?.enqueue?.('sync.stopped', {
|
|
278
|
+
...payload,
|
|
279
|
+
});
|
|
280
|
+
}
|
|
166
281
|
hasPendingPull(ns) {
|
|
167
282
|
const pending = ns.startsWith('p2p:') ? this.pendingP2pPullUpper : this.pendingGroupPullUpper;
|
|
168
283
|
return (pending?.get(ns) ?? 0) > 0;
|
|
@@ -176,7 +291,7 @@ export class MessageDeliveryEngine {
|
|
|
176
291
|
const pipeline = this.runtime.client._rpcPipeline;
|
|
177
292
|
if (pipeline?.hasAnyPullActivity?.() === true)
|
|
178
293
|
return;
|
|
179
|
-
void this.flushPullDeliveryChanges();
|
|
294
|
+
void this.flushPullDeliveryChanges().finally(() => this.syncStopped('pull_drained'));
|
|
180
295
|
}
|
|
181
296
|
deliveryChangeNamespace(event, payload, ns = '') {
|
|
182
297
|
if (event === 'message.received')
|
|
@@ -236,7 +351,11 @@ export class MessageDeliveryEngine {
|
|
|
236
351
|
const changes = this.deliveryChangesPayload(batch.changes);
|
|
237
352
|
if (changes.length === 0)
|
|
238
353
|
return;
|
|
239
|
-
this.runtime.client._dispatcher.enqueue('delivery.changed', {
|
|
354
|
+
this.runtime.client._dispatcher.enqueue('delivery.changed', {
|
|
355
|
+
trigger: batch.trigger,
|
|
356
|
+
source: batch.trigger,
|
|
357
|
+
changes,
|
|
358
|
+
});
|
|
240
359
|
}
|
|
241
360
|
async flushPullDeliveryChanges() {
|
|
242
361
|
const generation = this.deliveryGeneration;
|
|
@@ -249,7 +368,11 @@ export class MessageDeliveryEngine {
|
|
|
249
368
|
const changes = this.deliveryChangesPayload(pending);
|
|
250
369
|
if (changes.length === 0)
|
|
251
370
|
return;
|
|
252
|
-
this.runtime.client._dispatcher.enqueue('delivery.changed', {
|
|
371
|
+
this.runtime.client._dispatcher.enqueue('delivery.changed', {
|
|
372
|
+
trigger: 'pull_drained',
|
|
373
|
+
source: 'pull',
|
|
374
|
+
changes,
|
|
375
|
+
});
|
|
253
376
|
}
|
|
254
377
|
recordPendingPull(ns, seq) {
|
|
255
378
|
if (!ns || !Number.isSafeInteger(seq) || seq <= 0)
|
|
@@ -852,7 +975,7 @@ export class MessageDeliveryEngine {
|
|
|
852
975
|
}
|
|
853
976
|
const message = normalizeGroupMentionMode(rawMessage);
|
|
854
977
|
if (this.recallEventFromGroupMessage(message)) {
|
|
855
|
-
if (await this.publishGroupRecallTombstone(groupId, seq, message)) {
|
|
978
|
+
if (await this.publishGroupRecallTombstone(groupId, seq, message, 'pull')) {
|
|
856
979
|
this.ensurePullOperationCurrent();
|
|
857
980
|
this.markPublishedSeq(ns, seq);
|
|
858
981
|
publishedCount += 1;
|
|
@@ -919,6 +1042,9 @@ export class MessageDeliveryEngine {
|
|
|
919
1042
|
this.ensurePullOperationCurrent();
|
|
920
1043
|
await this.confirmPlainForwardAck(ns, ackMethod, pendingAckSeq, groupId);
|
|
921
1044
|
}
|
|
1045
|
+
const remaining = typeof response.remaining === 'number' && Number.isSafeInteger(response.remaining) && response.remaining >= 0
|
|
1046
|
+
? response.remaining : null;
|
|
1047
|
+
this.onPullPage(ns, publishedCount, response.has_more === true, messages.length > 0 ? Number(messages[messages.length - 1].seq ?? 0) : undefined, remaining, messages.length, client._seqTracker.getContiguousSeq(ns), messages.length > 0 ? Number(messages[messages.length - 1].seq ?? 0) : undefined);
|
|
922
1048
|
return { rawCount: messages.length, publishedCount };
|
|
923
1049
|
}
|
|
924
1050
|
enqueueOrderedMessage(ns, event, seq, payload, source = 'push') {
|
|
@@ -941,11 +1067,11 @@ export class MessageDeliveryEngine {
|
|
|
941
1067
|
async publishOrderedQueueItem(ns, event, seq, payload, pullResponse = false, source = 'push', batch) {
|
|
942
1068
|
const client = this.runtime.client;
|
|
943
1069
|
if (event === 'group.changed' && this.isGroupEventNamespace(ns)) {
|
|
944
|
-
await this.publishOrderedGroupChanged(payload);
|
|
1070
|
+
await this.publishOrderedGroupChanged(payload, source);
|
|
945
1071
|
return;
|
|
946
1072
|
}
|
|
947
1073
|
if (event === 'message.recalled') {
|
|
948
|
-
await this.publishMessageRecallTombstone(seq, payload);
|
|
1074
|
+
await this.publishMessageRecallTombstone(seq, payload, source);
|
|
949
1075
|
return;
|
|
950
1076
|
}
|
|
951
1077
|
if (pullResponse) {
|
|
@@ -954,7 +1080,7 @@ export class MessageDeliveryEngine {
|
|
|
954
1080
|
}
|
|
955
1081
|
await client._publishAppEvent(event, payload, source, ns, batch);
|
|
956
1082
|
}
|
|
957
|
-
async publishOrderedGroupChanged(payload) {
|
|
1083
|
+
async publishOrderedGroupChanged(payload, source = 'ordered') {
|
|
958
1084
|
const client = this.runtime.client;
|
|
959
1085
|
if (isJsonObject(payload)) {
|
|
960
1086
|
const eventPayload = payload;
|
|
@@ -966,7 +1092,7 @@ export class MessageDeliveryEngine {
|
|
|
966
1092
|
client._cleanupDissolvedGroup?.(groupId);
|
|
967
1093
|
}
|
|
968
1094
|
}
|
|
969
|
-
await client._publishAppEvent('group.changed', payload);
|
|
1095
|
+
await client._publishAppEvent('group.changed', payload, source);
|
|
970
1096
|
}
|
|
971
1097
|
isInstanceScopedMessageEvent(event) {
|
|
972
1098
|
return event === 'message.received'
|
|
@@ -989,18 +1115,27 @@ export class MessageDeliveryEngine {
|
|
|
989
1115
|
}
|
|
990
1116
|
return result;
|
|
991
1117
|
}
|
|
992
|
-
normalizePublishedMessagePayload(event, payload) {
|
|
1118
|
+
normalizePublishedMessagePayload(event, payload, source = 'direct') {
|
|
1119
|
+
let normalized;
|
|
993
1120
|
if (this.isInstanceScopedMessageEvent(event)) {
|
|
994
1121
|
payload = this.stripInlineInternalFields(payload);
|
|
995
1122
|
if (event === 'group.message_created')
|
|
996
1123
|
payload = normalizeGroupMentionMode(payload);
|
|
997
|
-
|
|
1124
|
+
normalized = this.attachAppMessageEnvelope(this.stripInternalSenderDeviceFields(this.attachCurrentInstanceContext(payload)));
|
|
998
1125
|
}
|
|
999
|
-
if (this.isGroupScopedEvent(event)) {
|
|
1126
|
+
else if (this.isGroupScopedEvent(event)) {
|
|
1000
1127
|
payload = this.stripInlineInternalFields(payload);
|
|
1001
|
-
|
|
1128
|
+
normalized = this.attachAppGroupEventEnvelope(this.attachCurrentInstanceContext(payload));
|
|
1129
|
+
}
|
|
1130
|
+
else {
|
|
1131
|
+
normalized = payload;
|
|
1002
1132
|
}
|
|
1003
|
-
|
|
1133
|
+
const canonicalSource = canonicalDeliverySource(source);
|
|
1134
|
+
if (canonicalSource === 'direct' || !isJsonObject(normalized))
|
|
1135
|
+
return normalized;
|
|
1136
|
+
if (!this.isInstanceScopedMessageEvent(event) && !this.isGroupScopedEvent(event))
|
|
1137
|
+
return normalized;
|
|
1138
|
+
return { ...normalized, source: canonicalSource };
|
|
1004
1139
|
}
|
|
1005
1140
|
stripInlineInternalFields(payload) {
|
|
1006
1141
|
if (!isJsonObject(payload))
|
|
@@ -1269,7 +1404,7 @@ export class MessageDeliveryEngine {
|
|
|
1269
1404
|
return `p2p|tombstone:${tombstoneId}`;
|
|
1270
1405
|
return `p2p|unknown:${Date.now()}:${Math.random()}`;
|
|
1271
1406
|
}
|
|
1272
|
-
async publishMessageRecallTombstone(seq, message) {
|
|
1407
|
+
async publishMessageRecallTombstone(seq, message, source = 'push') {
|
|
1273
1408
|
const client = this.runtime.client;
|
|
1274
1409
|
const eventPayload = this.recallEventFromMessage(message);
|
|
1275
1410
|
if (!eventPayload)
|
|
@@ -1290,7 +1425,7 @@ export class MessageDeliveryEngine {
|
|
|
1290
1425
|
for (const [oldKey] of drop)
|
|
1291
1426
|
seen.delete(oldKey);
|
|
1292
1427
|
}
|
|
1293
|
-
await client._publishAppEvent('message.recalled', eventPayload);
|
|
1428
|
+
await client._publishAppEvent('message.recalled', eventPayload, source);
|
|
1294
1429
|
client._clientLog.debug(`message.recalled published: seq=${String(seq)} ids=${JSON.stringify(eventPayload.message_ids)}`);
|
|
1295
1430
|
return true;
|
|
1296
1431
|
}
|
|
@@ -1373,7 +1508,7 @@ export class MessageDeliveryEngine {
|
|
|
1373
1508
|
return `${normalizedGroupId}|tombstone:${tombstoneId}`;
|
|
1374
1509
|
return `${normalizedGroupId}|unknown:${Date.now()}:${Math.random()}`;
|
|
1375
1510
|
}
|
|
1376
|
-
async publishGroupRecallTombstone(groupId, seq, message) {
|
|
1511
|
+
async publishGroupRecallTombstone(groupId, seq, message, source = 'push') {
|
|
1377
1512
|
const client = this.runtime.client;
|
|
1378
1513
|
const eventPayload = this.recallEventFromGroupMessage(message);
|
|
1379
1514
|
if (!eventPayload)
|
|
@@ -1396,7 +1531,7 @@ export class MessageDeliveryEngine {
|
|
|
1396
1531
|
for (const [oldKey] of drop)
|
|
1397
1532
|
seen.delete(oldKey);
|
|
1398
1533
|
}
|
|
1399
|
-
await client._publishAppEvent('group.message_recalled', eventPayload);
|
|
1534
|
+
await client._publishAppEvent('group.message_recalled', eventPayload, source);
|
|
1400
1535
|
client._clientLog.debug(`group.message_recalled published: group=${groupId} seq=${String(seq)} ids=${JSON.stringify(eventPayload.message_ids)}`);
|
|
1401
1536
|
return true;
|
|
1402
1537
|
}
|
|
@@ -1470,7 +1605,7 @@ export class MessageDeliveryEngine {
|
|
|
1470
1605
|
if (contig !== contigBefore)
|
|
1471
1606
|
this.persistSeq(ns);
|
|
1472
1607
|
}
|
|
1473
|
-
async publishAppEvent(event, payload, source = '', ns = '', batch) {
|
|
1608
|
+
async publishAppEvent(event, payload, source = 'direct', ns = '', batch) {
|
|
1474
1609
|
const client = this.runtime.client;
|
|
1475
1610
|
const generation = this.deliveryGeneration;
|
|
1476
1611
|
if ((event === 'message.received' || event === 'group.message_created') && isJsonObject(payload)) {
|
|
@@ -1492,14 +1627,21 @@ export class MessageDeliveryEngine {
|
|
|
1492
1627
|
client._clientLog.debug(`agent_md etag inject skipped: ${String(exc)}`);
|
|
1493
1628
|
}
|
|
1494
1629
|
}
|
|
1495
|
-
|
|
1630
|
+
const canonicalSource = canonicalDeliverySource(source);
|
|
1631
|
+
let normalized = this.normalizePublishedMessagePayload(event, payload, source);
|
|
1632
|
+
if (isJsonObject(normalized)
|
|
1633
|
+
&& (this.isInstanceScopedMessageEvent(event) || this.isGroupScopedEvent(event))
|
|
1634
|
+
&& canonicalSource !== 'direct') {
|
|
1635
|
+
normalized = { ...normalized, source: canonicalSource };
|
|
1636
|
+
}
|
|
1637
|
+
client._dispatcher.enqueue(event, normalized);
|
|
1496
1638
|
if (generation !== this.deliveryGeneration)
|
|
1497
1639
|
return;
|
|
1498
|
-
if (
|
|
1499
|
-
&&
|
|
1640
|
+
if (canonicalSource !== 'pull' && canonicalSource !== 'pending_retry'
|
|
1641
|
+
&& canonicalSource !== 'push' && canonicalSource !== 'inline_push')
|
|
1500
1642
|
return;
|
|
1501
|
-
if (
|
|
1502
|
-
const localBatch = batch ?? this.createDeliveryChangeBatch(
|
|
1643
|
+
if (canonicalSource === 'push' || canonicalSource === 'inline_push') {
|
|
1644
|
+
const localBatch = batch ?? this.createDeliveryChangeBatch(canonicalSource);
|
|
1503
1645
|
this.recordDeliveryChange(localBatch.changes, event, payload, ns, generation);
|
|
1504
1646
|
if (!batch)
|
|
1505
1647
|
await this.flushRealtimeDeliveryChanges(localBatch);
|
|
@@ -1734,7 +1876,7 @@ export class MessageDeliveryEngine {
|
|
|
1734
1876
|
_decrypt_error: String(exc),
|
|
1735
1877
|
};
|
|
1736
1878
|
client._attachV2EnvelopeMetadataFromSource(safeEvent, data);
|
|
1737
|
-
await client._publishAppEvent('message.undecryptable', safeEvent);
|
|
1879
|
+
await client._publishAppEvent('message.undecryptable', safeEvent, 'push');
|
|
1738
1880
|
}
|
|
1739
1881
|
}
|
|
1740
1882
|
}
|
|
@@ -1857,7 +1999,7 @@ export class MessageDeliveryEngine {
|
|
|
1857
1999
|
_decrypt_error: String(exc),
|
|
1858
2000
|
};
|
|
1859
2001
|
client._attachV2EnvelopeMetadataFromSource(safeEvent, data);
|
|
1860
|
-
await client._publishAppEvent('group.message_undecryptable', safeEvent);
|
|
2002
|
+
await client._publishAppEvent('group.message_undecryptable', safeEvent, 'push');
|
|
1861
2003
|
}
|
|
1862
2004
|
}
|
|
1863
2005
|
}
|
|
@@ -1865,7 +2007,7 @@ export class MessageDeliveryEngine {
|
|
|
1865
2007
|
const client = this.runtime.client;
|
|
1866
2008
|
const groupId = (notification.group_id ?? '');
|
|
1867
2009
|
if (!groupId) {
|
|
1868
|
-
await client._publishAppEvent('group.message_created', notification);
|
|
2010
|
+
await client._publishAppEvent('group.message_created', notification, 'push');
|
|
1869
2011
|
return;
|
|
1870
2012
|
}
|
|
1871
2013
|
if (client._sessionOptions?.background_sync === false) {
|
|
@@ -1882,7 +2024,7 @@ export class MessageDeliveryEngine {
|
|
|
1882
2024
|
}
|
|
1883
2025
|
catch (exc) {
|
|
1884
2026
|
client._clientLog.warn(`auto pull group message failed:${String(exc)}`);
|
|
1885
|
-
await client._publishAppEvent('group.message_created', notification);
|
|
2027
|
+
await client._publishAppEvent('group.message_created', notification, 'push');
|
|
1886
2028
|
return;
|
|
1887
2029
|
}
|
|
1888
2030
|
}
|
|
@@ -1912,7 +2054,7 @@ export class MessageDeliveryEngine {
|
|
|
1912
2054
|
// 两种情况都不能再把原始通知当作第二条业务消息发布。
|
|
1913
2055
|
client._clientLog.warn(`auto pull group message commit/ack failed:${String(exc)}`);
|
|
1914
2056
|
if (!rawCompleted) {
|
|
1915
|
-
await client._publishAppEvent('group.message_created', notification);
|
|
2057
|
+
await client._publishAppEvent('group.message_created', notification, 'push');
|
|
1916
2058
|
}
|
|
1917
2059
|
}
|
|
1918
2060
|
}
|
|
@@ -2050,6 +2192,7 @@ export class MessageDeliveryEngine {
|
|
|
2050
2192
|
client._gapFillDone.add(dedupKey);
|
|
2051
2193
|
this.runtime.delivery.setGapFillActive(true);
|
|
2052
2194
|
let continuationAfterSeq = 0;
|
|
2195
|
+
let failed = false;
|
|
2053
2196
|
try {
|
|
2054
2197
|
let nextAfterSeq = afterSeq;
|
|
2055
2198
|
const maxPages = singlePage ? 1 : 100;
|
|
@@ -2089,6 +2232,7 @@ export class MessageDeliveryEngine {
|
|
|
2089
2232
|
}
|
|
2090
2233
|
const eventSeqs = [];
|
|
2091
2234
|
let hasDissolvedEvent = false;
|
|
2235
|
+
let publishedEventCount = 0;
|
|
2092
2236
|
for (const evt of eventObjects) {
|
|
2093
2237
|
const eventSeq = Number(evt.event_seq ?? 0);
|
|
2094
2238
|
if (Number.isFinite(eventSeq) && eventSeq > 0)
|
|
@@ -2110,7 +2254,8 @@ export class MessageDeliveryEngine {
|
|
|
2110
2254
|
}
|
|
2111
2255
|
}
|
|
2112
2256
|
if (Number.isFinite(eventSeq) && eventSeq > 0 && !client._pushedSeqs.get(ns)?.has(eventSeq)) {
|
|
2113
|
-
this.enqueueOrderedMessage(ns, 'group.changed', eventSeq, evt);
|
|
2257
|
+
this.enqueueOrderedMessage(ns, 'group.changed', eventSeq, evt, 'pull');
|
|
2258
|
+
publishedEventCount += 1;
|
|
2114
2259
|
}
|
|
2115
2260
|
}
|
|
2116
2261
|
const ackContig = client._seqTracker.getContiguousSeq(ns);
|
|
@@ -2136,6 +2281,7 @@ export class MessageDeliveryEngine {
|
|
|
2136
2281
|
client._clientLog.warn('group event auto-ack failed: group=' + groupId, e);
|
|
2137
2282
|
}
|
|
2138
2283
|
}
|
|
2284
|
+
this.onPullPage(ns, publishedEventCount, result.has_more === true, eventObjects.length > 0 ? Number(eventObjects[eventObjects.length - 1].event_seq ?? 0) : undefined, typeof result.remaining === 'number' && Number.isSafeInteger(result.remaining) && result.remaining >= 0 ? result.remaining : null, eventObjects.length, ackContig, eventObjects.length > 0 ? Number(eventObjects[eventObjects.length - 1].event_seq ?? 0) : undefined);
|
|
2139
2285
|
const nextAfter = Math.max(eventSeqs.length > 0 ? Math.max(...eventSeqs) : nextAfterSeq, nextAfterSeq);
|
|
2140
2286
|
if (singlePage && result.has_more === true && nextAfter > nextAfterSeq) {
|
|
2141
2287
|
continuationAfterSeq = nextAfter;
|
|
@@ -2149,11 +2295,14 @@ export class MessageDeliveryEngine {
|
|
|
2149
2295
|
}
|
|
2150
2296
|
}
|
|
2151
2297
|
catch (exc) {
|
|
2298
|
+
failed = true;
|
|
2152
2299
|
client._clientLog.warn(`group event gap-fill failed:${String(exc)}`);
|
|
2153
2300
|
}
|
|
2154
2301
|
finally {
|
|
2155
2302
|
client._gapFillDone.delete(dedupKey);
|
|
2156
2303
|
this.runtime.delivery.setGapFillActive(false);
|
|
2304
|
+
if (!client._rpcPipeline)
|
|
2305
|
+
this.syncStopped(failed ? 'aborted' : 'pull_drained');
|
|
2157
2306
|
if (singlePage && continuationAfterSeq > afterSeq) {
|
|
2158
2307
|
this.enqueueOnlineUnreadEventHint({
|
|
2159
2308
|
group_id: groupId,
|
|
@@ -3651,7 +3800,7 @@ export class MessageDeliveryEngine {
|
|
|
3651
3800
|
const seqNum = Number(seq);
|
|
3652
3801
|
if (!Number.isFinite(seqNum) || !Number.isInteger(seqNum) || seqNum <= 0 || !ns) {
|
|
3653
3802
|
if (event === 'message.recalled') {
|
|
3654
|
-
const published = await client._withPullResponseProcessing(ns, () => this.publishMessageRecallTombstone(seq, payload));
|
|
3803
|
+
const published = await client._withPullResponseProcessing(ns, () => this.publishMessageRecallTombstone(seq, payload, source));
|
|
3655
3804
|
this.ensurePullOperationCurrent();
|
|
3656
3805
|
return published;
|
|
3657
3806
|
}
|
|
@@ -3672,7 +3821,7 @@ export class MessageDeliveryEngine {
|
|
|
3672
3821
|
if (queue && queue.size === 0)
|
|
3673
3822
|
client._pendingOrderedMsgs.delete(ns);
|
|
3674
3823
|
if (event === 'message.recalled') {
|
|
3675
|
-
const published = await client._withPullResponseProcessing(ns, () => this.publishMessageRecallTombstone(seqNum, payload));
|
|
3824
|
+
const published = await client._withPullResponseProcessing(ns, () => this.publishMessageRecallTombstone(seqNum, payload, source));
|
|
3676
3825
|
this.ensurePullOperationCurrent();
|
|
3677
3826
|
this.markPublishedSeq(ns, seqNum);
|
|
3678
3827
|
return published;
|