@agentunion/fastaun-browser 0.5.13 → 0.5.14
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/dist/bundle.js +64 -59
- package/dist/client/delivery.d.ts +1 -0
- package/dist/client/delivery.d.ts.map +1 -1
- package/dist/client/delivery.js +53 -33
- package/dist/client/delivery.js.map +1 -1
- package/dist/client/rpc-pipeline.d.ts +2 -3
- package/dist/client/rpc-pipeline.d.ts.map +1 -1
- package/dist/client/rpc-pipeline.js +22 -32
- package/dist/client/rpc-pipeline.js.map +1 -1
- package/package.json +1 -1
package/dist/bundle.js
CHANGED
|
@@ -5111,15 +5111,15 @@ var MessageDeliveryEngine = class {
|
|
|
5111
5111
|
isInlineGenerationCurrent(generation) {
|
|
5112
5112
|
return generation === this.inlineGeneration;
|
|
5113
5113
|
}
|
|
5114
|
-
isPullOperationCurrent() {
|
|
5115
|
-
const
|
|
5116
|
-
|
|
5117
|
-
if (generation === void 0) return true;
|
|
5118
|
-
const pipeline = client._rpcPipeline;
|
|
5119
|
-
return typeof pipeline?.isPullGenerationCurrent === "function" ? pipeline.isPullGenerationCurrent(generation) : true;
|
|
5114
|
+
isPullOperationCurrent(namespace = "") {
|
|
5115
|
+
const pipeline = this.runtime.client._rpcPipeline;
|
|
5116
|
+
return typeof pipeline?.isPullNamespaceCurrent === "function" ? pipeline.isPullNamespaceCurrent(namespace) : true;
|
|
5120
5117
|
}
|
|
5121
|
-
ensurePullOperationCurrent() {
|
|
5122
|
-
if (!this.isPullOperationCurrent()) throw new Error("pull invalidated");
|
|
5118
|
+
ensurePullOperationCurrent(namespace = "") {
|
|
5119
|
+
if (!this.isPullOperationCurrent(namespace)) throw new Error("pull invalidated");
|
|
5120
|
+
}
|
|
5121
|
+
isPullScopedSource(source) {
|
|
5122
|
+
return source === "pull";
|
|
5123
5123
|
}
|
|
5124
5124
|
captureInlineGeneration() {
|
|
5125
5125
|
return this.inlineGeneration;
|
|
@@ -5723,7 +5723,7 @@ var MessageDeliveryEngine = class {
|
|
|
5723
5723
|
}
|
|
5724
5724
|
async confirmPlainForwardAck(ns, method, ackSeq, groupId = "") {
|
|
5725
5725
|
const client = this.runtime.client;
|
|
5726
|
-
this.ensurePullOperationCurrent();
|
|
5726
|
+
this.ensurePullOperationCurrent(ns);
|
|
5727
5727
|
const coordinator = this.forwardCoordinator();
|
|
5728
5728
|
const generation = this.captureInlineGeneration();
|
|
5729
5729
|
coordinator.recordForwardAck(ns, ackSeq);
|
|
@@ -5740,7 +5740,7 @@ var MessageDeliveryEngine = class {
|
|
|
5740
5740
|
_rpc_background: true
|
|
5741
5741
|
};
|
|
5742
5742
|
const result = await client._rpcPipeline.rawCall(method, params2, { background: true });
|
|
5743
|
-
this.ensurePullOperationCurrent();
|
|
5743
|
+
this.ensurePullOperationCurrent(ns);
|
|
5744
5744
|
const actualAckSeq = this.resolveForwardAckSeq(result, ackSeq);
|
|
5745
5745
|
if (actualAckSeq < ackSeq) {
|
|
5746
5746
|
throw new Error(`${method} server ACK watermark ${actualAckSeq} is below requested ${ackSeq}`);
|
|
@@ -5757,7 +5757,7 @@ var MessageDeliveryEngine = class {
|
|
|
5757
5757
|
throw new Error(`${method} response must be an object`);
|
|
5758
5758
|
}
|
|
5759
5759
|
const client = this.runtime.client;
|
|
5760
|
-
this.ensurePullOperationCurrent();
|
|
5760
|
+
this.ensurePullOperationCurrent(ns);
|
|
5761
5761
|
const response = result;
|
|
5762
5762
|
const messages = deduplicatePlainForwardPageMessages(response.messages, afterSeq);
|
|
5763
5763
|
const coordinator = this.forwardCoordinator();
|
|
@@ -5785,31 +5785,31 @@ var MessageDeliveryEngine = class {
|
|
|
5785
5785
|
let committed = false;
|
|
5786
5786
|
try {
|
|
5787
5787
|
for (const rawMessage of messages) {
|
|
5788
|
-
this.ensurePullOperationCurrent();
|
|
5788
|
+
this.ensurePullOperationCurrent(ns);
|
|
5789
5789
|
const seq2 = positiveSafeSequenceHint(rawMessage.seq);
|
|
5790
5790
|
if (method === "message.pull") {
|
|
5791
5791
|
const appEvent = p2pAppEventFromPlainPullMessage(rawMessage);
|
|
5792
5792
|
if (await this.publishPulledMessage(appEvent.event, ns, seq2, appEvent.payload, false)) {
|
|
5793
5793
|
publishedCount += 1;
|
|
5794
5794
|
}
|
|
5795
|
-
this.ensurePullOperationCurrent();
|
|
5795
|
+
this.ensurePullOperationCurrent(ns);
|
|
5796
5796
|
continue;
|
|
5797
5797
|
}
|
|
5798
5798
|
const message = normalizeGroupMentionMode(rawMessage);
|
|
5799
5799
|
if (this.recallEventFromGroupMessage(message)) {
|
|
5800
5800
|
if (await this.publishGroupRecallTombstone(groupId, seq2, message, "pull")) {
|
|
5801
|
-
this.ensurePullOperationCurrent();
|
|
5801
|
+
this.ensurePullOperationCurrent(ns);
|
|
5802
5802
|
this.markPublishedSeq(ns, seq2);
|
|
5803
5803
|
publishedCount += 1;
|
|
5804
5804
|
}
|
|
5805
5805
|
} else if (this.isSelfSentGroupMessage(message)) {
|
|
5806
5806
|
this.markPublishedSeq(ns, seq2);
|
|
5807
5807
|
} else if (await this.publishPulledMessage("group.message_created", ns, seq2, message, false)) {
|
|
5808
|
-
this.ensurePullOperationCurrent();
|
|
5808
|
+
this.ensurePullOperationCurrent(ns);
|
|
5809
5809
|
publishedCount += 1;
|
|
5810
5810
|
}
|
|
5811
5811
|
}
|
|
5812
|
-
this.ensurePullOperationCurrent();
|
|
5812
|
+
this.ensurePullOperationCurrent(ns);
|
|
5813
5813
|
const contiguousSeq = Number.isSafeInteger(result.contiguous_seq) ? result.contiguous_seq : void 0;
|
|
5814
5814
|
if (contiguousSeq === void 0) client._seqTracker.onPullResult(ns, messages, afterSeq);
|
|
5815
5815
|
else client._seqTracker.onPullResult(ns, messages, afterSeq, contiguousSeq);
|
|
@@ -5823,20 +5823,20 @@ var MessageDeliveryEngine = class {
|
|
|
5823
5823
|
client._seqTracker.forceContiguousSeq(ns, commitTarget);
|
|
5824
5824
|
}
|
|
5825
5825
|
if (client._seqTracker.getContiguousSeq(ns) !== pageContigBefore) {
|
|
5826
|
-
this.ensurePullOperationCurrent();
|
|
5826
|
+
this.ensurePullOperationCurrent(ns);
|
|
5827
5827
|
await this.drainOrderedMessages(ns, void 0, false, false);
|
|
5828
|
-
this.ensurePullOperationCurrent();
|
|
5828
|
+
this.ensurePullOperationCurrent(ns);
|
|
5829
5829
|
await client._commitSeqTrackerState(ns);
|
|
5830
5830
|
}
|
|
5831
5831
|
committed = true;
|
|
5832
5832
|
} catch (exc) {
|
|
5833
|
-
if (this.isPullOperationCurrent() && !committed && typeof client._seqTracker.restoreNamespaceSnapshot === "function") {
|
|
5833
|
+
if (this.isPullOperationCurrent(ns) && !committed && typeof client._seqTracker.restoreNamespaceSnapshot === "function") {
|
|
5834
5834
|
client._seqTracker.restoreNamespaceSnapshot(ns, pageTrackerSnapshot);
|
|
5835
5835
|
this.dropSeqTrackerPending(ns);
|
|
5836
5836
|
}
|
|
5837
5837
|
throw exc;
|
|
5838
5838
|
}
|
|
5839
|
-
this.ensurePullOperationCurrent();
|
|
5839
|
+
this.ensurePullOperationCurrent(ns);
|
|
5840
5840
|
const committedAck = client._seqTracker.getContiguousSeq(ns);
|
|
5841
5841
|
if (deferredServerCursor > 0 && committedAck >= deferredServerCursor) {
|
|
5842
5842
|
coordinator.clearForwardCursor(ns, committedAck);
|
|
@@ -5869,7 +5869,7 @@ var MessageDeliveryEngine = class {
|
|
|
5869
5869
|
if (clampedAckSeq < pendingAckSeq) {
|
|
5870
5870
|
throw new Error(`${ackMethod} cannot confirm pending Forward watermark ${pendingAckSeq}`);
|
|
5871
5871
|
}
|
|
5872
|
-
this.ensurePullOperationCurrent();
|
|
5872
|
+
this.ensurePullOperationCurrent(ns);
|
|
5873
5873
|
await this.confirmPlainForwardAck(ns, ackMethod, pendingAckSeq, groupId);
|
|
5874
5874
|
}
|
|
5875
5875
|
const remaining = typeof response.remaining === "number" && Number.isSafeInteger(response.remaining) && response.remaining >= 0 ? response.remaining : null;
|
|
@@ -5903,12 +5903,16 @@ var MessageDeliveryEngine = class {
|
|
|
5903
5903
|
}
|
|
5904
5904
|
async publishOrderedQueueItem(ns, event, seq2, payload, pullResponse = false, source = "push", batch) {
|
|
5905
5905
|
const client = this.runtime.client;
|
|
5906
|
+
const pullScoped = this.isPullScopedSource(source);
|
|
5907
|
+
if (pullScoped) this.ensurePullOperationCurrent(ns);
|
|
5906
5908
|
if (event === "group.changed" && this.isGroupEventNamespace(ns)) {
|
|
5907
5909
|
await this.publishOrderedGroupChanged(payload, source);
|
|
5910
|
+
if (pullScoped) this.ensurePullOperationCurrent(ns);
|
|
5908
5911
|
return;
|
|
5909
5912
|
}
|
|
5910
5913
|
if (event === "message.recalled") {
|
|
5911
5914
|
await this.publishMessageRecallTombstone(seq2, payload, source);
|
|
5915
|
+
if (pullScoped) this.ensurePullOperationCurrent(ns);
|
|
5912
5916
|
return;
|
|
5913
5917
|
}
|
|
5914
5918
|
if (pullResponse) {
|
|
@@ -5916,6 +5920,7 @@ var MessageDeliveryEngine = class {
|
|
|
5916
5920
|
return;
|
|
5917
5921
|
}
|
|
5918
5922
|
await client._publishAppEvent(event, payload, source, ns, batch);
|
|
5923
|
+
if (pullScoped) this.ensurePullOperationCurrent(ns);
|
|
5919
5924
|
}
|
|
5920
5925
|
async publishOrderedGroupChanged(payload, source = "ordered") {
|
|
5921
5926
|
const client = this.runtime.client;
|
|
@@ -8039,7 +8044,8 @@ var MessageDeliveryEngine = class {
|
|
|
8039
8044
|
}
|
|
8040
8045
|
async drainOrderedMessages(ns, beforeSeq, pullResponse = false, persist = true, batch, source = "pull") {
|
|
8041
8046
|
const client = this.runtime.client;
|
|
8042
|
-
this.
|
|
8047
|
+
const pullScoped = this.isPullScopedSource(source);
|
|
8048
|
+
if (pullScoped) this.ensurePullOperationCurrent(ns);
|
|
8043
8049
|
const queue = client._pendingOrderedMsgs.get(ns);
|
|
8044
8050
|
if (!queue || queue.size === 0) return;
|
|
8045
8051
|
const contig = client._seqTracker.getContiguousSeq(ns);
|
|
@@ -8048,7 +8054,7 @@ var MessageDeliveryEngine = class {
|
|
|
8048
8054
|
const drainBatches = /* @__PURE__ */ new Map();
|
|
8049
8055
|
try {
|
|
8050
8056
|
for (const seq2 of ready) {
|
|
8051
|
-
this.ensurePullOperationCurrent();
|
|
8057
|
+
if (pullScoped) this.ensurePullOperationCurrent(ns);
|
|
8052
8058
|
const item = queue.get(seq2);
|
|
8053
8059
|
queue.delete(seq2);
|
|
8054
8060
|
if (!item || client._pushedSeqs.get(ns)?.has(seq2)) continue;
|
|
@@ -8070,7 +8076,7 @@ var MessageDeliveryEngine = class {
|
|
|
8070
8076
|
itemSource,
|
|
8071
8077
|
itemBatch
|
|
8072
8078
|
);
|
|
8073
|
-
this.ensurePullOperationCurrent();
|
|
8079
|
+
if (pullScoped) this.ensurePullOperationCurrent(ns);
|
|
8074
8080
|
this.markPublishedSeq(ns, seq2);
|
|
8075
8081
|
delivered = true;
|
|
8076
8082
|
}
|
|
@@ -8082,7 +8088,7 @@ var MessageDeliveryEngine = class {
|
|
|
8082
8088
|
if (queue.size === 0) {
|
|
8083
8089
|
client._pendingOrderedMsgs.delete(ns);
|
|
8084
8090
|
if (delivered && persist) {
|
|
8085
|
-
this.ensurePullOperationCurrent();
|
|
8091
|
+
if (pullScoped) this.ensurePullOperationCurrent(ns);
|
|
8086
8092
|
await this.saveSeqTrackerState();
|
|
8087
8093
|
}
|
|
8088
8094
|
}
|
|
@@ -8126,8 +8132,9 @@ var MessageDeliveryEngine = class {
|
|
|
8126
8132
|
const client = this.runtime.client;
|
|
8127
8133
|
const ownsBatch = !operationBatch && (source === "push" || source === "inline_push");
|
|
8128
8134
|
const batch = operationBatch ?? (ownsBatch ? this.createDeliveryChangeBatch(source) : void 0);
|
|
8135
|
+
const pullScoped = this.isPullScopedSource(source);
|
|
8129
8136
|
try {
|
|
8130
|
-
this.ensurePullOperationCurrent();
|
|
8137
|
+
if (pullScoped) this.ensurePullOperationCurrent(ns);
|
|
8131
8138
|
const seqNum = Number(seq2);
|
|
8132
8139
|
if (!Number.isFinite(seqNum) || !Number.isInteger(seqNum) || seqNum <= 0 || !ns) {
|
|
8133
8140
|
if (event === "message.recalled") {
|
|
@@ -8135,11 +8142,11 @@ var MessageDeliveryEngine = class {
|
|
|
8135
8142
|
ns,
|
|
8136
8143
|
() => this.publishMessageRecallTombstone(seq2, payload, source)
|
|
8137
8144
|
);
|
|
8138
|
-
this.ensurePullOperationCurrent();
|
|
8145
|
+
if (pullScoped) this.ensurePullOperationCurrent(ns);
|
|
8139
8146
|
return published;
|
|
8140
8147
|
}
|
|
8141
8148
|
await client._withPullResponseProcessing(ns, () => client._publishAppEvent(event, payload, source, ns, batch));
|
|
8142
|
-
this.ensurePullOperationCurrent();
|
|
8149
|
+
if (pullScoped) this.ensurePullOperationCurrent(ns);
|
|
8143
8150
|
return true;
|
|
8144
8151
|
}
|
|
8145
8152
|
const queue = client._pendingOrderedMsgs.get(ns);
|
|
@@ -8149,7 +8156,7 @@ var MessageDeliveryEngine = class {
|
|
|
8149
8156
|
return false;
|
|
8150
8157
|
}
|
|
8151
8158
|
await this.drainOrderedMessages(ns, seqNum, false, persist, batch, source);
|
|
8152
|
-
this.ensurePullOperationCurrent();
|
|
8159
|
+
if (pullScoped) this.ensurePullOperationCurrent(ns);
|
|
8153
8160
|
queue?.delete(seqNum);
|
|
8154
8161
|
if (queue && queue.size === 0) client._pendingOrderedMsgs.delete(ns);
|
|
8155
8162
|
if (event === "message.recalled") {
|
|
@@ -8157,12 +8164,12 @@ var MessageDeliveryEngine = class {
|
|
|
8157
8164
|
ns,
|
|
8158
8165
|
() => this.publishMessageRecallTombstone(seqNum, payload, source)
|
|
8159
8166
|
);
|
|
8160
|
-
this.ensurePullOperationCurrent();
|
|
8167
|
+
if (pullScoped) this.ensurePullOperationCurrent(ns);
|
|
8161
8168
|
this.markPublishedSeq(ns, seqNum);
|
|
8162
8169
|
return published;
|
|
8163
8170
|
}
|
|
8164
8171
|
await client._withPullResponseProcessing(ns, () => client._publishAppEvent(event, payload, source, ns, batch));
|
|
8165
|
-
this.ensurePullOperationCurrent();
|
|
8172
|
+
if (pullScoped) this.ensurePullOperationCurrent(ns);
|
|
8166
8173
|
this.markPublishedSeq(ns, seqNum);
|
|
8167
8174
|
return true;
|
|
8168
8175
|
} finally {
|
|
@@ -15856,7 +15863,6 @@ var RpcPipeline = class {
|
|
|
15856
15863
|
__publicField(this, "pullGateStates", /* @__PURE__ */ new Map());
|
|
15857
15864
|
__publicField(this, "inlineRealtimeScopes", /* @__PURE__ */ new Set());
|
|
15858
15865
|
__publicField(this, "pullWorkTokens", /* @__PURE__ */ new Set());
|
|
15859
|
-
__publicField(this, "pullGeneration", 0);
|
|
15860
15866
|
__publicField(this, "pullInvalidationWait", null);
|
|
15861
15867
|
this.runtime = runtime;
|
|
15862
15868
|
}
|
|
@@ -15951,13 +15957,19 @@ var RpcPipeline = class {
|
|
|
15951
15957
|
if (pullGateKey) {
|
|
15952
15958
|
return await this.runPullSerialized(
|
|
15953
15959
|
pullGateKey,
|
|
15954
|
-
async () => await this.callImplInner(
|
|
15960
|
+
async () => await this.callImplInner(
|
|
15961
|
+
method,
|
|
15962
|
+
p,
|
|
15963
|
+
skipSendResultEnvelope,
|
|
15964
|
+
deferGroupReadyPostprocess,
|
|
15965
|
+
this.pullScopeKey(pullGateKey)
|
|
15966
|
+
),
|
|
15955
15967
|
rpcBackground && this.pullGateBackgroundForCall(method, p)
|
|
15956
15968
|
);
|
|
15957
15969
|
}
|
|
15958
15970
|
return await runWithRpcPriority(() => this.callImplInner(method, p, skipSendResultEnvelope, deferGroupReadyPostprocess));
|
|
15959
15971
|
}
|
|
15960
|
-
async callImplInner(method, p, skipSendResultEnvelope = false, deferGroupReadyPostprocess = false) {
|
|
15972
|
+
async callImplInner(method, p, skipSendResultEnvelope = false, deferGroupReadyPostprocess = false, pullNamespace = "") {
|
|
15961
15973
|
const client = this.runtime.client;
|
|
15962
15974
|
if (method === "message.v2.pull" || method === "message.pull" && hasMatchingV2Session(client)) {
|
|
15963
15975
|
try {
|
|
@@ -16037,7 +16049,10 @@ var RpcPipeline = class {
|
|
|
16037
16049
|
};
|
|
16038
16050
|
let result = await this.transportCallWithIdentityRecovery(invokeTransport, method, p);
|
|
16039
16051
|
const sendResultModeSource = result;
|
|
16040
|
-
result = await this.postprocessResult(method, p, result, {
|
|
16052
|
+
result = await this.postprocessResult(method, p, result, {
|
|
16053
|
+
skipGroupState: deferGroupReadyPostprocess,
|
|
16054
|
+
pullNamespace
|
|
16055
|
+
});
|
|
16041
16056
|
if (!skipSendResultEnvelope) {
|
|
16042
16057
|
result = client._delivery.attachSendResultEnvelope(
|
|
16043
16058
|
method,
|
|
@@ -16299,7 +16314,6 @@ var RpcPipeline = class {
|
|
|
16299
16314
|
if (active.timedOut) return;
|
|
16300
16315
|
active.timedOut = true;
|
|
16301
16316
|
active.invalidated = true;
|
|
16302
|
-
this.pullGeneration += 1;
|
|
16303
16317
|
active.cancel?.();
|
|
16304
16318
|
const err = new TimeoutError(`pull gate timeout: ${active.namespace}`, { retryable: true });
|
|
16305
16319
|
this.runtime.client._clientLog?.warn(`pull gate watchdog timeout: gate=${name} key=${active.key}`);
|
|
@@ -16474,12 +16488,14 @@ var RpcPipeline = class {
|
|
|
16474
16488
|
gate.inflight = false;
|
|
16475
16489
|
gate.startedAt = 0;
|
|
16476
16490
|
}
|
|
16477
|
-
|
|
16478
|
-
|
|
16491
|
+
isPullNamespaceCurrent(namespace) {
|
|
16492
|
+
const ns = this.pullScopeKey(namespace);
|
|
16493
|
+
if (!ns) return true;
|
|
16494
|
+
const active = this.pullGateStates.get(this.pullGateName(ns))?.active;
|
|
16495
|
+
return !active || active.namespace !== ns || !active.timedOut && !active.invalidated;
|
|
16479
16496
|
}
|
|
16480
16497
|
invalidatePulls() {
|
|
16481
16498
|
if (this.pullInvalidationWait) return this.pullInvalidationWait;
|
|
16482
|
-
this.pullGeneration += 1;
|
|
16483
16499
|
const error = new Error("pull invalidated");
|
|
16484
16500
|
const waits = [];
|
|
16485
16501
|
for (const state of this.pullGateStates.values()) {
|
|
@@ -16592,23 +16608,11 @@ var RpcPipeline = class {
|
|
|
16592
16608
|
}
|
|
16593
16609
|
async executePullOperation(operation, background) {
|
|
16594
16610
|
const client = this.runtime.client;
|
|
16595
|
-
|
|
16596
|
-
|
|
16597
|
-
client._pullOperationGeneration = this.pullGeneration;
|
|
16598
|
-
try {
|
|
16599
|
-
if (background) return await client._withBackgroundRpc(operation);
|
|
16600
|
-
return await operation();
|
|
16601
|
-
} finally {
|
|
16602
|
-
if (hadPrevious) client._pullOperationGeneration = previous;
|
|
16603
|
-
else delete client._pullOperationGeneration;
|
|
16604
|
-
}
|
|
16605
|
-
}
|
|
16606
|
-
pullOperationIsCurrent() {
|
|
16607
|
-
const generation = this.runtime.client._pullOperationGeneration;
|
|
16608
|
-
return generation === void 0 || this.isPullGenerationCurrent(generation);
|
|
16611
|
+
if (background) return await client._withBackgroundRpc(operation);
|
|
16612
|
+
return await operation();
|
|
16609
16613
|
}
|
|
16610
|
-
throwIfPullInvalidated() {
|
|
16611
|
-
if (!this.
|
|
16614
|
+
throwIfPullInvalidated(namespace) {
|
|
16615
|
+
if (!this.isPullNamespaceCurrent(namespace)) throw new Error("pull invalidated");
|
|
16612
16616
|
}
|
|
16613
16617
|
async yieldPullGate(key, nextKey, background) {
|
|
16614
16618
|
if (!key) return;
|
|
@@ -16713,7 +16717,7 @@ var RpcPipeline = class {
|
|
|
16713
16717
|
return this.bindActivePullCancellation(method, payload, request);
|
|
16714
16718
|
};
|
|
16715
16719
|
const result = await this.transportCallWithIdentityRecovery(invokeTransport, method, payload);
|
|
16716
|
-
this.throwIfPullInvalidated();
|
|
16720
|
+
this.throwIfPullInvalidated(this.pullScopeKey(this.pullGateKeyForCall(method, payload)));
|
|
16717
16721
|
return result;
|
|
16718
16722
|
}
|
|
16719
16723
|
async transportCallWithIdentityRecovery(operation, method, params2) {
|
|
@@ -16737,7 +16741,8 @@ var RpcPipeline = class {
|
|
|
16737
16741
|
}
|
|
16738
16742
|
async postprocessResult(method, params2, result, options = {}) {
|
|
16739
16743
|
const client = this.runtime.client;
|
|
16740
|
-
this.
|
|
16744
|
+
const pullNamespace = this.pullScopeKey(options.pullNamespace || this.pullGateKeyForCall(method, params2));
|
|
16745
|
+
this.throwIfPullInvalidated(pullNamespace);
|
|
16741
16746
|
let next = result;
|
|
16742
16747
|
if ((method === "group.send" || method === "group.v2.send") && isJsonObject(next)) {
|
|
16743
16748
|
next = normalizeGroupMentionMode(next);
|
|
@@ -16756,7 +16761,7 @@ var RpcPipeline = class {
|
|
|
16756
16761
|
if (method === "message.pull" && isJsonObject(next)) {
|
|
16757
16762
|
const isTail = String(next.window_mode ?? params2.window_mode ?? "").trim().toLowerCase() === "tail";
|
|
16758
16763
|
if (!isTail && client._aid && client._seqTracker) {
|
|
16759
|
-
const ns = `p2p:${client._aid}`;
|
|
16764
|
+
const ns = pullNamespace || `p2p:${client._aid}`;
|
|
16760
16765
|
const afterSeq = Math.max(0, Number(params2.after_seq ?? 0) || 0);
|
|
16761
16766
|
await client._delivery.commitPlainForwardPage(ns, afterSeq, "message.pull", next);
|
|
16762
16767
|
} else {
|
|
@@ -16774,7 +16779,7 @@ var RpcPipeline = class {
|
|
|
16774
16779
|
if (!ownsCursor) {
|
|
16775
16780
|
client._clientLog.debug(`group.pull external cursor skips local Forward commit: group=${gid}`);
|
|
16776
16781
|
} else if (!isTail && gid && client._seqTracker) {
|
|
16777
|
-
const ns = `group:${gid}`;
|
|
16782
|
+
const ns = pullNamespace || `group:${gid}`;
|
|
16778
16783
|
const afterSeq = Math.max(0, Number(params2.after_message_seq ?? params2.after_seq ?? 0) || 0);
|
|
16779
16784
|
await client._delivery.commitPlainForwardPage(ns, afterSeq, "group.pull", next, gid);
|
|
16780
16785
|
} else {
|
|
@@ -36,6 +36,7 @@ export declare class MessageDeliveryEngine {
|
|
|
36
36
|
isInlineGenerationCurrent(generation: number): boolean;
|
|
37
37
|
private isPullOperationCurrent;
|
|
38
38
|
private ensurePullOperationCurrent;
|
|
39
|
+
private isPullScopedSource;
|
|
39
40
|
captureInlineGeneration(): number;
|
|
40
41
|
private beginRealtimeSync;
|
|
41
42
|
private endRealtimeSync;
|
|
@@ -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;AAyFF,qBAAa,qBAAqB;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;IACxC,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,iBAAiB,CAAqB;IAC9C,OAAO,CAAC,YAAY,CAAqE;IACzF,OAAO,CAAC,0BAA0B,CAAoC;IACtE,OAAO,CAAC,kBAAkB,CAAK;IAC/B,OAAO,CAAC,mBAAmB,CAAgC;IAC3D,OAAO,CAAC,eAAe,CAA4B;IACnD,OAAO,CAAC,mBAAmB,CAAoC;IAC/D,OAAO,CAAC,qBAAqB,CAAoC;IACjE,OAAO,CAAC,yBAAyB,CAAoC;IACrE,OAAO,CAAC,uBAAuB,CAAoC;IAC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B,oBAAoB;IAYlC,OAAO,CAAC,sBAAsB;YAMhB,uBAAuB;IA4CrC,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAqDpC,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM;IAwB3E,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,SAAS;IA4BtD,oBAAoB,CACxB,EAAE,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,YAAY,UAAQ,EAAE,OAAO,UAAO,EACpE,KAAK,CAAC,EAAE,mBAAmB,EAAE,MAAM,SAAS,GAC3C,OAAO,CAAC,IAAI,CAAC;IAiDV,qBAAqB,CACzB,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,EAAE,cAAc,CAAC,EAAE,mBAAmB,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;CA8CpB"}
|
package/dist/client/delivery.js
CHANGED
|
@@ -165,20 +165,19 @@ export class MessageDeliveryEngine {
|
|
|
165
165
|
isInlineGenerationCurrent(generation) {
|
|
166
166
|
return generation === this.inlineGeneration;
|
|
167
167
|
}
|
|
168
|
-
isPullOperationCurrent() {
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
return true;
|
|
173
|
-
const pipeline = client._rpcPipeline;
|
|
174
|
-
return typeof pipeline?.isPullGenerationCurrent === 'function'
|
|
175
|
-
? pipeline.isPullGenerationCurrent(generation)
|
|
168
|
+
isPullOperationCurrent(namespace = '') {
|
|
169
|
+
const pipeline = this.runtime.client._rpcPipeline;
|
|
170
|
+
return typeof pipeline?.isPullNamespaceCurrent === 'function'
|
|
171
|
+
? pipeline.isPullNamespaceCurrent(namespace)
|
|
176
172
|
: true;
|
|
177
173
|
}
|
|
178
|
-
ensurePullOperationCurrent() {
|
|
179
|
-
if (!this.isPullOperationCurrent())
|
|
174
|
+
ensurePullOperationCurrent(namespace = '') {
|
|
175
|
+
if (!this.isPullOperationCurrent(namespace))
|
|
180
176
|
throw new Error('pull invalidated');
|
|
181
177
|
}
|
|
178
|
+
isPullScopedSource(source) {
|
|
179
|
+
return source === 'pull';
|
|
180
|
+
}
|
|
182
181
|
captureInlineGeneration() {
|
|
183
182
|
return this.inlineGeneration;
|
|
184
183
|
}
|
|
@@ -899,7 +898,7 @@ export class MessageDeliveryEngine {
|
|
|
899
898
|
}
|
|
900
899
|
async confirmPlainForwardAck(ns, method, ackSeq, groupId = '') {
|
|
901
900
|
const client = this.runtime.client;
|
|
902
|
-
this.ensurePullOperationCurrent();
|
|
901
|
+
this.ensurePullOperationCurrent(ns);
|
|
903
902
|
const coordinator = this.forwardCoordinator();
|
|
904
903
|
const generation = this.captureInlineGeneration();
|
|
905
904
|
coordinator.recordForwardAck(ns, ackSeq);
|
|
@@ -918,7 +917,7 @@ export class MessageDeliveryEngine {
|
|
|
918
917
|
_rpc_background: true,
|
|
919
918
|
};
|
|
920
919
|
const result = await client._rpcPipeline.rawCall(method, params, { background: true });
|
|
921
|
-
this.ensurePullOperationCurrent();
|
|
920
|
+
this.ensurePullOperationCurrent(ns);
|
|
922
921
|
const actualAckSeq = this.resolveForwardAckSeq(result, ackSeq);
|
|
923
922
|
if (actualAckSeq < ackSeq) {
|
|
924
923
|
throw new Error(`${method} server ACK watermark ${actualAckSeq} is below requested ${ackSeq}`);
|
|
@@ -936,7 +935,7 @@ export class MessageDeliveryEngine {
|
|
|
936
935
|
throw new Error(`${method} response must be an object`);
|
|
937
936
|
}
|
|
938
937
|
const client = this.runtime.client;
|
|
939
|
-
this.ensurePullOperationCurrent();
|
|
938
|
+
this.ensurePullOperationCurrent(ns);
|
|
940
939
|
const response = result;
|
|
941
940
|
const messages = deduplicatePlainForwardPageMessages(response.messages, afterSeq);
|
|
942
941
|
const coordinator = this.forwardCoordinator();
|
|
@@ -967,20 +966,20 @@ export class MessageDeliveryEngine {
|
|
|
967
966
|
let committed = false;
|
|
968
967
|
try {
|
|
969
968
|
for (const rawMessage of messages) {
|
|
970
|
-
this.ensurePullOperationCurrent();
|
|
969
|
+
this.ensurePullOperationCurrent(ns);
|
|
971
970
|
const seq = positiveSafeSequenceHint(rawMessage.seq);
|
|
972
971
|
if (method === 'message.pull') {
|
|
973
972
|
const appEvent = p2pAppEventFromPlainPullMessage(rawMessage);
|
|
974
973
|
if (await this.publishPulledMessage(appEvent.event, ns, seq, appEvent.payload, false)) {
|
|
975
974
|
publishedCount += 1;
|
|
976
975
|
}
|
|
977
|
-
this.ensurePullOperationCurrent();
|
|
976
|
+
this.ensurePullOperationCurrent(ns);
|
|
978
977
|
continue;
|
|
979
978
|
}
|
|
980
979
|
const message = normalizeGroupMentionMode(rawMessage);
|
|
981
980
|
if (this.recallEventFromGroupMessage(message)) {
|
|
982
981
|
if (await this.publishGroupRecallTombstone(groupId, seq, message, 'pull')) {
|
|
983
|
-
this.ensurePullOperationCurrent();
|
|
982
|
+
this.ensurePullOperationCurrent(ns);
|
|
984
983
|
this.markPublishedSeq(ns, seq);
|
|
985
984
|
publishedCount += 1;
|
|
986
985
|
}
|
|
@@ -989,11 +988,11 @@ export class MessageDeliveryEngine {
|
|
|
989
988
|
this.markPublishedSeq(ns, seq);
|
|
990
989
|
}
|
|
991
990
|
else if (await this.publishPulledMessage('group.message_created', ns, seq, message, false)) {
|
|
992
|
-
this.ensurePullOperationCurrent();
|
|
991
|
+
this.ensurePullOperationCurrent(ns);
|
|
993
992
|
publishedCount += 1;
|
|
994
993
|
}
|
|
995
994
|
}
|
|
996
|
-
this.ensurePullOperationCurrent();
|
|
995
|
+
this.ensurePullOperationCurrent(ns);
|
|
997
996
|
const contiguousSeq = Number.isSafeInteger(result.contiguous_seq)
|
|
998
997
|
? result.contiguous_seq
|
|
999
998
|
: undefined;
|
|
@@ -1006,21 +1005,21 @@ export class MessageDeliveryEngine {
|
|
|
1006
1005
|
client._seqTracker.forceContiguousSeq(ns, commitTarget);
|
|
1007
1006
|
}
|
|
1008
1007
|
if (client._seqTracker.getContiguousSeq(ns) !== pageContigBefore) {
|
|
1009
|
-
this.ensurePullOperationCurrent();
|
|
1008
|
+
this.ensurePullOperationCurrent(ns);
|
|
1010
1009
|
await this.drainOrderedMessages(ns, undefined, false, false);
|
|
1011
|
-
this.ensurePullOperationCurrent();
|
|
1010
|
+
this.ensurePullOperationCurrent(ns);
|
|
1012
1011
|
await client._commitSeqTrackerState(ns);
|
|
1013
1012
|
}
|
|
1014
1013
|
committed = true;
|
|
1015
1014
|
}
|
|
1016
1015
|
catch (exc) {
|
|
1017
|
-
if (this.isPullOperationCurrent() && !committed && typeof client._seqTracker.restoreNamespaceSnapshot === 'function') {
|
|
1016
|
+
if (this.isPullOperationCurrent(ns) && !committed && typeof client._seqTracker.restoreNamespaceSnapshot === 'function') {
|
|
1018
1017
|
client._seqTracker.restoreNamespaceSnapshot(ns, pageTrackerSnapshot);
|
|
1019
1018
|
this.dropSeqTrackerPending(ns);
|
|
1020
1019
|
}
|
|
1021
1020
|
throw exc;
|
|
1022
1021
|
}
|
|
1023
|
-
this.ensurePullOperationCurrent();
|
|
1022
|
+
this.ensurePullOperationCurrent(ns);
|
|
1024
1023
|
const committedAck = client._seqTracker.getContiguousSeq(ns);
|
|
1025
1024
|
if (deferredServerCursor > 0 && committedAck >= deferredServerCursor) {
|
|
1026
1025
|
coordinator.clearForwardCursor(ns, committedAck);
|
|
@@ -1051,7 +1050,7 @@ export class MessageDeliveryEngine {
|
|
|
1051
1050
|
if (clampedAckSeq < pendingAckSeq) {
|
|
1052
1051
|
throw new Error(`${ackMethod} cannot confirm pending Forward watermark ${pendingAckSeq}`);
|
|
1053
1052
|
}
|
|
1054
|
-
this.ensurePullOperationCurrent();
|
|
1053
|
+
this.ensurePullOperationCurrent(ns);
|
|
1055
1054
|
await this.confirmPlainForwardAck(ns, ackMethod, pendingAckSeq, groupId);
|
|
1056
1055
|
}
|
|
1057
1056
|
const remaining = typeof response.remaining === 'number' && Number.isSafeInteger(response.remaining) && response.remaining >= 0
|
|
@@ -1078,12 +1077,19 @@ export class MessageDeliveryEngine {
|
|
|
1078
1077
|
}
|
|
1079
1078
|
async publishOrderedQueueItem(ns, event, seq, payload, pullResponse = false, source = 'push', batch) {
|
|
1080
1079
|
const client = this.runtime.client;
|
|
1080
|
+
const pullScoped = this.isPullScopedSource(source);
|
|
1081
|
+
if (pullScoped)
|
|
1082
|
+
this.ensurePullOperationCurrent(ns);
|
|
1081
1083
|
if (event === 'group.changed' && this.isGroupEventNamespace(ns)) {
|
|
1082
1084
|
await this.publishOrderedGroupChanged(payload, source);
|
|
1085
|
+
if (pullScoped)
|
|
1086
|
+
this.ensurePullOperationCurrent(ns);
|
|
1083
1087
|
return;
|
|
1084
1088
|
}
|
|
1085
1089
|
if (event === 'message.recalled') {
|
|
1086
1090
|
await this.publishMessageRecallTombstone(seq, payload, source);
|
|
1091
|
+
if (pullScoped)
|
|
1092
|
+
this.ensurePullOperationCurrent(ns);
|
|
1087
1093
|
return;
|
|
1088
1094
|
}
|
|
1089
1095
|
if (pullResponse) {
|
|
@@ -1091,6 +1097,8 @@ export class MessageDeliveryEngine {
|
|
|
1091
1097
|
return;
|
|
1092
1098
|
}
|
|
1093
1099
|
await client._publishAppEvent(event, payload, source, ns, batch);
|
|
1100
|
+
if (pullScoped)
|
|
1101
|
+
this.ensurePullOperationCurrent(ns);
|
|
1094
1102
|
}
|
|
1095
1103
|
async publishOrderedGroupChanged(payload, source = 'ordered') {
|
|
1096
1104
|
const client = this.runtime.client;
|
|
@@ -3623,7 +3631,9 @@ export class MessageDeliveryEngine {
|
|
|
3623
3631
|
}
|
|
3624
3632
|
async drainOrderedMessages(ns, beforeSeq, pullResponse = false, persist = true, batch, source = 'pull') {
|
|
3625
3633
|
const client = this.runtime.client;
|
|
3626
|
-
this.
|
|
3634
|
+
const pullScoped = this.isPullScopedSource(source);
|
|
3635
|
+
if (pullScoped)
|
|
3636
|
+
this.ensurePullOperationCurrent(ns);
|
|
3627
3637
|
const queue = client._pendingOrderedMsgs.get(ns);
|
|
3628
3638
|
if (!queue || queue.size === 0)
|
|
3629
3639
|
return;
|
|
@@ -3635,7 +3645,8 @@ export class MessageDeliveryEngine {
|
|
|
3635
3645
|
const drainBatches = new Map();
|
|
3636
3646
|
try {
|
|
3637
3647
|
for (const seq of ready) {
|
|
3638
|
-
|
|
3648
|
+
if (pullScoped)
|
|
3649
|
+
this.ensurePullOperationCurrent(ns);
|
|
3639
3650
|
const item = queue.get(seq);
|
|
3640
3651
|
queue.delete(seq);
|
|
3641
3652
|
if (!item || client._pushedSeqs.get(ns)?.has(seq))
|
|
@@ -3651,7 +3662,8 @@ export class MessageDeliveryEngine {
|
|
|
3651
3662
|
}
|
|
3652
3663
|
}
|
|
3653
3664
|
await this.publishOrderedQueueItem(ns, item.event, seq, item.payload, pullResponse, itemSource, itemBatch);
|
|
3654
|
-
|
|
3665
|
+
if (pullScoped)
|
|
3666
|
+
this.ensurePullOperationCurrent(ns);
|
|
3655
3667
|
this.markPublishedSeq(ns, seq);
|
|
3656
3668
|
delivered = true;
|
|
3657
3669
|
}
|
|
@@ -3664,7 +3676,8 @@ export class MessageDeliveryEngine {
|
|
|
3664
3676
|
if (queue.size === 0) {
|
|
3665
3677
|
client._pendingOrderedMsgs.delete(ns);
|
|
3666
3678
|
if (delivered && persist) {
|
|
3667
|
-
|
|
3679
|
+
if (pullScoped)
|
|
3680
|
+
this.ensurePullOperationCurrent(ns);
|
|
3668
3681
|
await this.saveSeqTrackerState();
|
|
3669
3682
|
}
|
|
3670
3683
|
}
|
|
@@ -3714,17 +3727,21 @@ export class MessageDeliveryEngine {
|
|
|
3714
3727
|
const client = this.runtime.client;
|
|
3715
3728
|
const ownsBatch = !operationBatch && (source === 'push' || source === 'inline_push');
|
|
3716
3729
|
const batch = operationBatch ?? (ownsBatch ? this.createDeliveryChangeBatch(source) : undefined);
|
|
3730
|
+
const pullScoped = this.isPullScopedSource(source);
|
|
3717
3731
|
try {
|
|
3718
|
-
|
|
3732
|
+
if (pullScoped)
|
|
3733
|
+
this.ensurePullOperationCurrent(ns);
|
|
3719
3734
|
const seqNum = Number(seq);
|
|
3720
3735
|
if (!Number.isFinite(seqNum) || !Number.isInteger(seqNum) || seqNum <= 0 || !ns) {
|
|
3721
3736
|
if (event === 'message.recalled') {
|
|
3722
3737
|
const published = await client._withPullResponseProcessing(ns, () => this.publishMessageRecallTombstone(seq, payload, source));
|
|
3723
|
-
|
|
3738
|
+
if (pullScoped)
|
|
3739
|
+
this.ensurePullOperationCurrent(ns);
|
|
3724
3740
|
return published;
|
|
3725
3741
|
}
|
|
3726
3742
|
await client._withPullResponseProcessing(ns, () => client._publishAppEvent(event, payload, source, ns, batch));
|
|
3727
|
-
|
|
3743
|
+
if (pullScoped)
|
|
3744
|
+
this.ensurePullOperationCurrent(ns);
|
|
3728
3745
|
return true;
|
|
3729
3746
|
}
|
|
3730
3747
|
const queue = client._pendingOrderedMsgs.get(ns);
|
|
@@ -3735,18 +3752,21 @@ export class MessageDeliveryEngine {
|
|
|
3735
3752
|
return false;
|
|
3736
3753
|
}
|
|
3737
3754
|
await this.drainOrderedMessages(ns, seqNum, false, persist, batch, source);
|
|
3738
|
-
|
|
3755
|
+
if (pullScoped)
|
|
3756
|
+
this.ensurePullOperationCurrent(ns);
|
|
3739
3757
|
queue?.delete(seqNum);
|
|
3740
3758
|
if (queue && queue.size === 0)
|
|
3741
3759
|
client._pendingOrderedMsgs.delete(ns);
|
|
3742
3760
|
if (event === 'message.recalled') {
|
|
3743
3761
|
const published = await client._withPullResponseProcessing(ns, () => this.publishMessageRecallTombstone(seqNum, payload, source));
|
|
3744
|
-
|
|
3762
|
+
if (pullScoped)
|
|
3763
|
+
this.ensurePullOperationCurrent(ns);
|
|
3745
3764
|
this.markPublishedSeq(ns, seqNum);
|
|
3746
3765
|
return published;
|
|
3747
3766
|
}
|
|
3748
3767
|
await client._withPullResponseProcessing(ns, () => client._publishAppEvent(event, payload, source, ns, batch));
|
|
3749
|
-
|
|
3768
|
+
if (pullScoped)
|
|
3769
|
+
this.ensurePullOperationCurrent(ns);
|
|
3750
3770
|
this.markPublishedSeq(ns, seqNum);
|
|
3751
3771
|
return true;
|
|
3752
3772
|
}
|