@agentunion/fastaun-browser 0.5.20 → 0.5.21
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 +47 -0
- package/_packed_docs/CHANGELOG.md +47 -0
- package/_packed_docs/INDEX.md +453 -440
- package/_packed_docs/KITE_DOCS_GUIDE.md +164 -161
- package/_packed_docs/agent.md/working/AID/347/261/273/345/236/213-owner/345/205/263/347/263/273/344/270/216/346/215/242owner/347/274/226/346/216/222/346/226/271/346/241/210.md +530 -0
- package/_packed_docs/agent.md/working/AID/347/261/273/345/236/213-owner/345/205/263/347/263/273/345/256/214/346/225/264/350/256/276/350/256/241/344/270/216/345/256/236/346/226/275/350/256/241/345/210/222.md +685 -0
- package/_packed_docs/agent.md/working/agent.md-schema/344/270/216/347/255/276/345/217/221/351/252/214/347/255/276/346/265/201/347/250/213/346/276/204/346/270/205.md +349 -0
- package/_packed_docs/agent.md/working//346/234/254/345/234/260Docker/346/265/213/350/257/225Bug/346/270/205/345/215/225.md +40 -0
- package/_packed_docs/protocol/06-/346/234/215/345/212/241/345/215/217/350/256/256.md +1433 -1392
- package/_packed_docs/protocol/08-AUN-E2EE.md +17 -12
- package/_packed_docs/protocol/Ownership/345/215/217/350/256/256/345/256/232/344/271/211.md +2 -0
- package/_packed_docs/protocol/Ownership/345/215/217/350/256/256/345/256/232/344/271/2112.1.md +666 -658
- package/_packed_docs/sdk/0.5.21-SDK/345/272/224/347/224/250/351/233/206/346/210/220/346/214/207/345/215/227.md +368 -0
- package/_packed_docs/sdk/0.5.21-SDK/345/274/200/345/217/221/344/270/216/347/247/273/346/244/215/346/214/207/345/215/227.md +350 -0
- package/_packed_docs/sdk/01-/345/277/253/351/200/237/345/274/200/345/247/213.md +1 -1
- package/_packed_docs/sdk/02-WebSocket/345/215/217/350/256/256.md +5 -1
- package/_packed_docs/sdk/03-/346/240/270/345/277/203/346/246/202/345/277/265.md +64 -64
- package/_packed_docs/sdk/04-/350/277/236/346/216/245/344/270/216/350/256/244/350/257/201.md +4 -1
- package/_packed_docs/sdk/05-E2EE/345/212/240/345/257/206/351/200/232/344/277/241.md +42 -39
- package/_packed_docs/sdk/06-API/346/211/213/345/206/214.md +147 -14
- package/_packed_docs/sdk/08-/346/234/200/344/275/263/345/256/236/350/267/265.md +48 -47
- package/_packed_docs/sdk/09-group-rpc-manual.md +5 -2
- package/_packed_docs/sdk/09-message-rpc-manual.md +250 -160
- package/_packed_docs/sdk/09-/345/207/255/350/257/201/346/234/215/345/212/241RPC/346/211/213/345/206/214.md +71 -0
- package/_packed_docs/sdk/09-/347/273/204/347/273/207/346/234/215/345/212/241RPC/346/211/213/345/206/214.md +88 -0
- package/_packed_docs/sdk/AUN_DOCS_GUIDE.md +134 -130
- package/_packed_docs/sdk/INDEX.md +239 -221
- package/_packed_docs/sdk/Ownership-SDK/347/274/226/346/216/222/346/214/207/345/215/2272.1.md +930 -922
- package/_packed_docs/sdk/Ownership2.1-SDK/345/272/224/347/224/250/351/233/206/346/210/220/346/214/207/345/215/227.md +106 -43
- package/_packed_docs/sdk/Ownership2.1-SDK/345/274/200/345/217/221/344/270/216/347/247/273/346/244/215/346/214/207/345/215/227.md +180 -9
- package/_packed_docs/sdk/Ownership2.1-TDD/345/210/206/351/230/266/346/256/265/345/256/236/346/226/275/350/256/241/345/210/222.md +708 -708
- package/_packed_docs/sdk/Ownership2.1/350/257/246/347/273/206/350/256/276/350/256/241.md +480 -476
- package/_packed_docs/sdk//345/207/255/350/257/201/344/270/216/347/273/204/347/273/207/346/234/215/345/212/241SDK/345/272/224/347/224/250/351/233/206/346/210/220/346/214/207/345/215/227.md +1 -1
- package/_packed_docs/sdk//345/207/255/350/257/201/344/270/216/347/273/204/347/273/207/346/234/215/345/212/241SDK/345/274/200/345/217/221/344/270/216/347/247/273/346/244/215/346/214/207/345/215/227.md +2 -2
- package/dist/agent-md-schema.d.ts +1 -0
- package/dist/agent-md-schema.d.ts.map +1 -1
- package/dist/agent-md-schema.js +5 -4
- package/dist/agent-md-schema.js.map +1 -1
- package/dist/agent-md.d.ts +25 -1
- package/dist/agent-md.d.ts.map +1 -1
- package/dist/agent-md.js +148 -71
- package/dist/agent-md.js.map +1 -1
- package/dist/aid-store.d.ts +13 -0
- package/dist/aid-store.d.ts.map +1 -1
- package/dist/aid-store.js +55 -8
- package/dist/aid-store.js.map +1 -1
- package/dist/aid.d.ts.map +1 -1
- package/dist/aid.js +2 -1
- package/dist/aid.js.map +1 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +4 -0
- package/dist/auth.js.map +1 -1
- package/dist/bundle.js +4981 -1219
- package/dist/cert-utils.d.ts +1 -0
- package/dist/cert-utils.d.ts.map +1 -1
- package/dist/cert-utils.js +21 -0
- package/dist/cert-utils.js.map +1 -1
- package/dist/client/delivery.d.ts +101 -16
- package/dist/client/delivery.d.ts.map +1 -1
- package/dist/client/delivery.js +1172 -160
- package/dist/client/delivery.js.map +1 -1
- package/dist/client/rpc-pipeline.d.ts +4 -1
- package/dist/client/rpc-pipeline.d.ts.map +1 -1
- package/dist/client/rpc-pipeline.js +122 -48
- package/dist/client/rpc-pipeline.js.map +1 -1
- package/dist/client/v2-e2ee.d.ts +22 -3
- package/dist/client/v2-e2ee.d.ts.map +1 -1
- package/dist/client/v2-e2ee.js +1258 -649
- package/dist/client/v2-e2ee.js.map +1 -1
- package/dist/client.d.ts +23 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +391 -87
- package/dist/client.js.map +1 -1
- package/dist/config.d.ts +4 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/events.d.ts +19 -1
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +146 -23
- package/dist/events.js.map +1 -1
- package/dist/facades.d.ts +42 -1
- package/dist/facades.d.ts.map +1 -1
- package/dist/facades.js +363 -7
- package/dist/facades.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/keystore/index.d.ts +14 -1
- package/dist/keystore/index.d.ts.map +1 -1
- package/dist/keystore/indexeddb-identity-store.d.ts +4 -0
- package/dist/keystore/indexeddb-identity-store.d.ts.map +1 -1
- package/dist/keystore/indexeddb-identity-store.js +30 -13
- package/dist/keystore/indexeddb-identity-store.js.map +1 -1
- package/dist/keystore/indexeddb-shared.d.ts +19 -2
- package/dist/keystore/indexeddb-shared.d.ts.map +1 -1
- package/dist/keystore/indexeddb-shared.js +193 -6
- package/dist/keystore/indexeddb-shared.js.map +1 -1
- package/dist/keystore/indexeddb-token-store.d.ts +15 -2
- package/dist/keystore/indexeddb-token-store.d.ts.map +1 -1
- package/dist/keystore/indexeddb-token-store.js +308 -27
- package/dist/keystore/indexeddb-token-store.js.map +1 -1
- package/dist/org-protocol.d.ts +45 -0
- package/dist/org-protocol.d.ts.map +1 -1
- package/dist/org-protocol.js +757 -11
- package/dist/org-protocol.js.map +1 -1
- package/dist/ownership-v21.d.ts +21 -4
- package/dist/ownership-v21.d.ts.map +1 -1
- package/dist/ownership-v21.js +49 -16
- package/dist/ownership-v21.js.map +1 -1
- package/dist/ownership-workflow.d.ts +30 -0
- package/dist/ownership-workflow.d.ts.map +1 -1
- package/dist/ownership-workflow.js +412 -54
- package/dist/ownership-workflow.js.map +1 -1
- package/dist/seq-tracker.d.ts +2 -0
- package/dist/seq-tracker.d.ts.map +1 -1
- package/dist/seq-tracker.js +3 -2
- package/dist/seq-tracker.js.map +1 -1
- package/dist/tools/cross-sdk-agent.d.ts +60 -3
- package/dist/tools/cross-sdk-agent.d.ts.map +1 -1
- package/dist/tools/cross-sdk-agent.js +433 -37
- package/dist/tools/cross-sdk-agent.js.map +1 -1
- package/dist/transport.d.ts +3 -0
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +62 -30
- 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,8 @@ export declare class RpcPipeline {
|
|
|
13
13
|
private pullInvalidationWait;
|
|
14
14
|
constructor(runtime: ClientRuntime);
|
|
15
15
|
call(method: string, params?: RpcParams): Promise<RpcResult>;
|
|
16
|
+
private _callWithSent;
|
|
17
|
+
private _call;
|
|
16
18
|
private callImpl;
|
|
17
19
|
private callImplInner;
|
|
18
20
|
preflight(method: string, params?: RpcParams): RpcPreflightResult;
|
|
@@ -50,7 +52,8 @@ export declare class RpcPipeline {
|
|
|
50
52
|
isPullNamespaceCurrent(namespace: string): boolean;
|
|
51
53
|
invalidatePulls(): Promise<void>;
|
|
52
54
|
private pullInvalidationInProgress;
|
|
53
|
-
|
|
55
|
+
runPullNamespaceSerialized<T>(key: string, operation: () => Promise<T> | T, background?: boolean): Promise<T>;
|
|
56
|
+
runPullSerialized<T>(key: string, operation: () => Promise<T> | T, background?: boolean, namespaceOnly?: boolean): Promise<T>;
|
|
54
57
|
private executePullOperation;
|
|
55
58
|
private throwIfPullInvalidated;
|
|
56
59
|
yieldPullGate(key: string, nextKey?: string, background?: boolean): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-pipeline.d.ts","sourceRoot":"","sources":["../../src/client/rpc-pipeline.ts"],"names":[],"mappings":"AAOA,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AA8KlD,KAAK,kBAAkB,GAAG,MAAM,GAAG,SAAS,GAAG,YAAY,GAAG,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"rpc-pipeline.d.ts","sourceRoot":"","sources":["../../src/client/rpc-pipeline.ts"],"names":[],"mappings":"AAOA,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EA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AId,OAAO,CAAC,sBAAsB;IA4B9B,OAAO,CAAC,oBAAoB;IA4C5B,OAAO,CAAC,wBAAwB;IAYhC,OAAO,CAAC,yBAAyB;IAcjC,OAAO,CAAC,4BAA4B;IAmBpC,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,yBAAyB;IAMjC,OAAO,CAAC,iCAAiC;IAQzC,wBAAwB,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI;CAKtE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeSlotId, slotIsolationKey } from '../config.js';
|
|
1
|
+
import { _INTERNAL_MESSAGE_FLOW_LIMITS, normalizeSlotId, slotIsolationKey } from '../config.js';
|
|
2
2
|
import { ClientSignatureError, ConnectionError, PermissionError, TimeoutError, ValidationError } from '../errors.js';
|
|
3
3
|
import { parseCertMetadata, verifySignatureWithCert } from '../cert-utils.js';
|
|
4
4
|
import { orgRequestParams, validateOrgRequestJSON } from '../org-protocol.js';
|
|
@@ -36,6 +36,7 @@ const SIGNED_METHODS = new Set([
|
|
|
36
36
|
'message.v2.put_peer_pk', 'message.v2.bootstrap',
|
|
37
37
|
'message.v2.group_bootstrap', 'message.v2.pull', 'message.history',
|
|
38
38
|
'message.v2.ack',
|
|
39
|
+
'message.peers',
|
|
39
40
|
'group.send',
|
|
40
41
|
'group.v2.put_group_pk', 'group.v2.bootstrap',
|
|
41
42
|
'group.v2.send', 'group.v2.pull', 'group.history', 'group.v2.ack',
|
|
@@ -134,7 +135,6 @@ async function signingCertFingerprint(certPem) {
|
|
|
134
135
|
}
|
|
135
136
|
const PULL_GATE_STALE_MS = 35_000;
|
|
136
137
|
const PULL_GATE_OPERATION_TIMEOUT_MS = 35_000;
|
|
137
|
-
const PULL_GATE_MAX_ACTIVE = 4;
|
|
138
138
|
function sameIdentityAdmissionRejection(error, original) {
|
|
139
139
|
const errorCode = Number(error?.code);
|
|
140
140
|
const originalCode = Number(original?.code);
|
|
@@ -186,6 +186,9 @@ function hasMatchingV2Session(client) {
|
|
|
186
186
|
return true;
|
|
187
187
|
return session.aid === client._aid && session.deviceId === client._deviceId;
|
|
188
188
|
}
|
|
189
|
+
function isP2pNamespace(namespace) {
|
|
190
|
+
return namespace.startsWith('p2p:') || namespace.startsWith('p2p.peer.v1/');
|
|
191
|
+
}
|
|
189
192
|
function isTransientV2PullFallbackError(error) {
|
|
190
193
|
const text = (error instanceof Error ? error.message : String(error)).toLowerCase();
|
|
191
194
|
return text.includes('no_service') || text.includes('service plane unavailable');
|
|
@@ -200,6 +203,12 @@ export class RpcPipeline {
|
|
|
200
203
|
this.runtime = runtime;
|
|
201
204
|
}
|
|
202
205
|
async call(method, params) {
|
|
206
|
+
return this._call(method, params);
|
|
207
|
+
}
|
|
208
|
+
async _callWithSent(method, params, onSent) {
|
|
209
|
+
return this._call(method, params, onSent);
|
|
210
|
+
}
|
|
211
|
+
async _call(method, params, onSent) {
|
|
203
212
|
const client = this.runtime.client;
|
|
204
213
|
const tStart = Date.now();
|
|
205
214
|
const volatileCursor = method === 'message.pull'
|
|
@@ -207,7 +216,7 @@ export class RpcPipeline {
|
|
|
207
216
|
: '';
|
|
208
217
|
client._clientLog.debug(`call enter: method=${method}`);
|
|
209
218
|
try {
|
|
210
|
-
const result = await this.callImpl(method, params);
|
|
219
|
+
const result = await this.callImpl(method, params, onSent);
|
|
211
220
|
client._clientLog.debug(`call exit: elapsed=${Date.now() - tStart}ms method=${method}`);
|
|
212
221
|
return result;
|
|
213
222
|
}
|
|
@@ -217,7 +226,7 @@ export class RpcPipeline {
|
|
|
217
226
|
const retryParams = { ...(params ?? {}) };
|
|
218
227
|
delete retryParams.after_volatile_cursor;
|
|
219
228
|
delete retryParams.client_signature;
|
|
220
|
-
const result = await this.callImpl(method, retryParams);
|
|
229
|
+
const result = await this.callImpl(method, retryParams, onSent);
|
|
221
230
|
client._clientLog.debug(`call exit: elapsed=${Date.now() - tStart}ms method=${method}`);
|
|
222
231
|
return result;
|
|
223
232
|
}
|
|
@@ -225,11 +234,21 @@ export class RpcPipeline {
|
|
|
225
234
|
throw err;
|
|
226
235
|
}
|
|
227
236
|
}
|
|
228
|
-
async callImpl(method, params) {
|
|
237
|
+
async callImpl(method, params, onSent) {
|
|
229
238
|
const client = this.runtime.client;
|
|
230
239
|
const preflight = this.preflight(method, params);
|
|
231
240
|
const p = preflight.params;
|
|
232
241
|
const rpcBackground = preflight.rpcBackground;
|
|
242
|
+
if (client._p2pPeerPullEnabled) {
|
|
243
|
+
if (method === 'message.peers')
|
|
244
|
+
return await client._delivery.peers(p, rpcBackground);
|
|
245
|
+
if (method === 'message.pull' || method === 'message.v2.pull')
|
|
246
|
+
return await client._delivery.pullPeers(p, rpcBackground);
|
|
247
|
+
if (method === 'message.history')
|
|
248
|
+
return await client._v2E2EE.historyPeerV2(p);
|
|
249
|
+
if (method === 'message.ack' || method === 'message.v2.ack')
|
|
250
|
+
return await client._v2E2EE.ackPeerV2(p);
|
|
251
|
+
}
|
|
233
252
|
const runWithRpcPriority = async (operation) => {
|
|
234
253
|
if (!rpcBackground)
|
|
235
254
|
return await operation();
|
|
@@ -249,6 +268,7 @@ export class RpcPipeline {
|
|
|
249
268
|
messageId: String(p.message_id ?? '') || undefined,
|
|
250
269
|
timestamp: p.timestamp,
|
|
251
270
|
ttl: p.ttl,
|
|
271
|
+
needRender: p.need_render !== false,
|
|
252
272
|
deviceId: String(p.device_id ?? '').trim() || String(p.to_device_id ?? '').trim() || undefined,
|
|
253
273
|
protectedHeaders: client._protectedHeadersFromParams(p),
|
|
254
274
|
context: isJsonObject(p.context) ? p.context : undefined,
|
|
@@ -266,6 +286,7 @@ export class RpcPipeline {
|
|
|
266
286
|
groupAid: String(p.group_aid ?? '').trim() || undefined,
|
|
267
287
|
messageId: String(p.message_id ?? '') || undefined,
|
|
268
288
|
timestamp: p.timestamp,
|
|
289
|
+
needRender: p.need_render !== false,
|
|
269
290
|
protectedHeaders: client._protectedHeadersFromParams(p),
|
|
270
291
|
context: isJsonObject(p.context) ? p.context : undefined,
|
|
271
292
|
});
|
|
@@ -292,11 +313,15 @@ export class RpcPipeline {
|
|
|
292
313
|
}
|
|
293
314
|
const pullGateKey = this.pullGateKeyForCall(method, p);
|
|
294
315
|
if (pullGateKey) {
|
|
295
|
-
|
|
316
|
+
if (method === 'group.history' || method === 'group.pull' || method === 'group.v2.pull') {
|
|
317
|
+
p._rpc_background = rpcBackground;
|
|
318
|
+
return await this.runPullNamespaceSerialized(pullGateKey, async () => await this.callImplInner(method, p, skipSendResultEnvelope, deferGroupReadyPostprocess, this.pullScopeKey(pullGateKey), onSent), rpcBackground && this.pullGateBackgroundForCall(method, p));
|
|
319
|
+
}
|
|
320
|
+
return await this.runPullSerialized(pullGateKey, async () => await this.callImplInner(method, p, skipSendResultEnvelope, deferGroupReadyPostprocess, this.pullScopeKey(pullGateKey), onSent), rpcBackground && this.pullGateBackgroundForCall(method, p));
|
|
296
321
|
}
|
|
297
|
-
return await runWithRpcPriority(() => this.callImplInner(method, p, skipSendResultEnvelope, deferGroupReadyPostprocess));
|
|
322
|
+
return await runWithRpcPriority(() => this.callImplInner(method, p, skipSendResultEnvelope, deferGroupReadyPostprocess, undefined, onSent));
|
|
298
323
|
}
|
|
299
|
-
async callImplInner(method, p, skipSendResultEnvelope = false, deferGroupReadyPostprocess = false, pullNamespace = '') {
|
|
324
|
+
async callImplInner(method, p, skipSendResultEnvelope = false, deferGroupReadyPostprocess = false, pullNamespace = '', onSent) {
|
|
300
325
|
const client = this.runtime.client;
|
|
301
326
|
if (method === 'message.v2.pull' || (method === 'message.pull' && hasMatchingV2Session(client))) {
|
|
302
327
|
try {
|
|
@@ -340,12 +365,13 @@ export class RpcPipeline {
|
|
|
340
365
|
await client._ensureV2SessionReady('group.pull');
|
|
341
366
|
client._clientLog.debug(`call route: ${method} -> V2 pull`);
|
|
342
367
|
if (p.window_mode === 'tail')
|
|
343
|
-
return await client._v2E2EE.pullGroupV2TailInternal(p);
|
|
368
|
+
return await client._v2E2EE.pullGroupV2TailInternal(p, false, true);
|
|
344
369
|
const hasExplicitAfterSeq = 'after_seq' in p || 'after_message_seq' in p;
|
|
345
370
|
const cursorParams = this.explicitGroupCursorParams(p);
|
|
346
371
|
const ownsCursor = Object.keys(cursorParams).length === 0 || this.groupCursorTargetsCurrentInstance(cursorParams);
|
|
347
372
|
const pullOpts = {
|
|
348
373
|
gateLocked: true,
|
|
374
|
+
background: p._rpc_background === true,
|
|
349
375
|
};
|
|
350
376
|
if (hasExplicitAfterSeq)
|
|
351
377
|
pullOpts.explicitAfterSeq = true;
|
|
@@ -378,16 +404,24 @@ export class RpcPipeline {
|
|
|
378
404
|
}
|
|
379
405
|
return await client._ackGroupV2((p.group_id ?? p.group_aid), (p.seq ?? p.msg_seq ?? p.up_to_seq), p.group_aid);
|
|
380
406
|
}
|
|
407
|
+
const rpcBackground = p._rpc_foreground === true ? false
|
|
408
|
+
: (typeof p._rpc_background === 'boolean' ? p._rpc_background : client._backgroundRpcDepth > 0);
|
|
409
|
+
delete p._rpc_background;
|
|
410
|
+
delete p._rpc_foreground;
|
|
381
411
|
await this.applyClientSignature(method, p);
|
|
382
412
|
const callTimeout = NON_IDEMPOTENT_METHODS.has(method) ? NON_IDEMPOTENT_TIMEOUT : undefined;
|
|
383
|
-
const rpcBackground = client._backgroundRpcDepth > 0;
|
|
384
413
|
const invokeTransport = () => {
|
|
385
|
-
const request =
|
|
386
|
-
? client._transport
|
|
387
|
-
:
|
|
414
|
+
const request = onSent
|
|
415
|
+
? client._transport['_callWithSent'](method, p, onSent, callTimeout, undefined, rpcBackground)
|
|
416
|
+
: callTimeout
|
|
417
|
+
? client._transport.call(method, p, callTimeout, undefined, rpcBackground)
|
|
418
|
+
: client._transport.call(method, p, undefined, undefined, rpcBackground);
|
|
388
419
|
return this.bindActivePullCancellation(method, p, request);
|
|
389
420
|
};
|
|
390
|
-
|
|
421
|
+
const invoke = () => this.transportCallWithIdentityRecovery(invokeTransport, method, p);
|
|
422
|
+
let result = method === 'group.pull'
|
|
423
|
+
? await this.runPullSerialized(this.pullGateKeyForCall(method, p), invoke, rpcBackground)
|
|
424
|
+
: await invoke();
|
|
391
425
|
const sendResultModeSource = result;
|
|
392
426
|
result = await this.postprocessResult(method, p, result, {
|
|
393
427
|
skipGroupState: deferGroupReadyPostprocess,
|
|
@@ -408,7 +442,8 @@ export class RpcPipeline {
|
|
|
408
442
|
}
|
|
409
443
|
const p = { ...(params ?? {}) };
|
|
410
444
|
this.mergeInstanceProtectedHeaders(method, p);
|
|
411
|
-
const rpcBackground = Boolean(p._rpc_background)
|
|
445
|
+
const rpcBackground = Boolean(p._rpc_background)
|
|
446
|
+
|| (!['message.peers', 'message.pull', 'message.v2.pull', 'group.pull', 'group.v2.pull', 'group.pull_events'].includes(method) && client._backgroundRpcDepth > 0);
|
|
412
447
|
delete p._rpc_background;
|
|
413
448
|
if (method === 'message.send' || method === 'group.send') {
|
|
414
449
|
this.normalizeOutboundMessagePayload(p, method);
|
|
@@ -521,7 +556,7 @@ export class RpcPipeline {
|
|
|
521
556
|
}
|
|
522
557
|
params.device_id = client._deviceId;
|
|
523
558
|
params.slot_id = client._slotId;
|
|
524
|
-
if ((method === 'message.pull' || method === 'message.v2.pull') && params.after_volatile_cursor === undefined) {
|
|
559
|
+
if (!client._p2pPeerPullEnabled && (method === 'message.pull' || method === 'message.v2.pull') && params.after_volatile_cursor === undefined) {
|
|
525
560
|
const volatileCursor = client._delivery.volatilePullCursor();
|
|
526
561
|
if (volatileCursor)
|
|
527
562
|
params.after_volatile_cursor = volatileCursor;
|
|
@@ -618,12 +653,18 @@ export class RpcPipeline {
|
|
|
618
653
|
if (method === 'message.pull' || method === 'message.v2.pull' || method === 'message.history') {
|
|
619
654
|
if (!client._aid)
|
|
620
655
|
return '';
|
|
656
|
+
const sender = String(params.sender_aid ?? params.peer_aid ?? '').trim();
|
|
657
|
+
if (client._p2pPeerPullEnabled && !sender)
|
|
658
|
+
return '';
|
|
659
|
+
const peerNamespace = sender && (client._p2pPeerPullEnabled || params.cursor_scope === 'peer')
|
|
660
|
+
? `p2p.peer.v1/${btoa(String.fromCharCode(...new TextEncoder().encode(sender))).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '')}`
|
|
661
|
+
: '';
|
|
621
662
|
const mode = method === 'message.history' ? 'history' : params.window_mode === 'tail' ? 'tail' : 'forward';
|
|
622
663
|
const cursor = mode === 'history'
|
|
623
664
|
? `before=${String(params.before_seq)}`
|
|
624
665
|
: `after=${String(params.after_seq ?? 0)}`;
|
|
625
666
|
const limit = mode === 'forward' ? (Number(params.limit ?? 50) || 50) : params.limit;
|
|
626
|
-
return `p2p:${client._aid}|mode=${mode}|cursor=${cursor}|volatile=${String(params.after_volatile_cursor ?? '')}|force=${String(Boolean(params.force))}|limit=${String(limit)}`;
|
|
667
|
+
return `${peerNamespace || `p2p:${client._aid}`}|mode=${mode}|cursor=${cursor}|volatile=${String(params.after_volatile_cursor ?? '')}|force=${String(Boolean(params.force))}|limit=${String(limit)}`;
|
|
627
668
|
}
|
|
628
669
|
if (method === 'group.pull' || method === 'group.v2.pull' || method === 'group.history') {
|
|
629
670
|
const gid = String(params.group_id ?? params.group_aid ?? '').trim();
|
|
@@ -660,14 +701,15 @@ export class RpcPipeline {
|
|
|
660
701
|
void key;
|
|
661
702
|
return 'pull';
|
|
662
703
|
}
|
|
663
|
-
pullGateState(key) {
|
|
664
|
-
const name = this.pullGateName(key);
|
|
704
|
+
pullGateState(key, namespaceOnly = false) {
|
|
705
|
+
const name = namespaceOnly ? 'pull-namespace' : this.pullGateName(key);
|
|
665
706
|
let state = this.pullGateStates.get(name);
|
|
666
707
|
if (!state) {
|
|
667
|
-
state = { activeByNamespace: new Map(), foreground: [], background: [], byKey: new Map(), lifecycle: new Map(), watchdog: null };
|
|
708
|
+
state = { networkLimited: !namespaceOnly, activeByNamespace: new Map(), foreground: [], background: [], byKey: new Map(), lifecycle: new Map(), watchdog: null, backgroundPeerDispatches: 0 };
|
|
668
709
|
this.pullGateStates.set(name, state);
|
|
669
710
|
}
|
|
670
|
-
|
|
711
|
+
if (state.networkLimited)
|
|
712
|
+
this.startPullGateWatchdog(state, name);
|
|
671
713
|
return state;
|
|
672
714
|
}
|
|
673
715
|
pullGateOperationTimeoutMs() {
|
|
@@ -751,30 +793,29 @@ export class RpcPipeline {
|
|
|
751
793
|
}
|
|
752
794
|
hasPendingRealtimePull(ns) {
|
|
753
795
|
const normalized = String(ns ?? '').trim();
|
|
754
|
-
if (!normalized || (!normalized
|
|
796
|
+
if (!normalized || (!isP2pNamespace(normalized) && !normalized.startsWith('group:')))
|
|
755
797
|
return false;
|
|
756
798
|
if (this.isPullResponseProcessing(normalized))
|
|
757
799
|
return true;
|
|
758
|
-
const state = this.pullGateStates.get(this.pullGateName(normalized));
|
|
759
|
-
if (!state)
|
|
760
|
-
return false;
|
|
761
800
|
const matches = (job) => {
|
|
762
801
|
if (!job)
|
|
763
802
|
return false;
|
|
764
803
|
return this.realtimePullNamespace(job.key) === normalized;
|
|
765
804
|
};
|
|
766
|
-
return [...state.activeByNamespace.values()].some(matches)
|
|
805
|
+
return [...this.pullGateStates.values()].some((state) => [...state.activeByNamespace.values()].some(matches)
|
|
767
806
|
|| state.foreground.some(matches)
|
|
768
|
-
|| state.background.some(matches);
|
|
807
|
+
|| state.background.some(matches));
|
|
769
808
|
}
|
|
770
809
|
hasPullActivity(namespace, includePending = true) {
|
|
771
810
|
const ns = String(namespace ?? '').trim();
|
|
772
|
-
if ((!ns.startsWith('
|
|
811
|
+
if ((!isP2pNamespace(ns) && !ns.startsWith('group:') && !ns.startsWith('group_event:'))
|
|
773
812
|
|| this.inlineRealtimeScopes.has(ns))
|
|
774
813
|
return true;
|
|
775
814
|
const client = this.runtime.client;
|
|
776
815
|
if ((client._pullResponseKeys?.get?.(ns) ?? 0) > 0)
|
|
777
816
|
return true;
|
|
817
|
+
if (isP2pNamespace(ns) && client._v2E2EE?.hasPeerPageActivity?.(ns))
|
|
818
|
+
return true;
|
|
778
819
|
const pendingP2p = client._pendingP2pPullUpper;
|
|
779
820
|
const pendingGroup = client._pendingGroupPullUpper;
|
|
780
821
|
if (includePending && ((pendingP2p?.get(ns) ?? 0) > 0 || (pendingGroup?.get(ns) ?? 0) > 0
|
|
@@ -782,7 +823,7 @@ export class RpcPipeline {
|
|
|
782
823
|
return true;
|
|
783
824
|
for (const marker of client._gapFillDone ?? []) {
|
|
784
825
|
const value = String(marker ?? '').trim();
|
|
785
|
-
if (ns
|
|
826
|
+
if (isP2pNamespace(ns) && (value.startsWith(`p2p_pull:${ns}`) || value.startsWith(`p2p_pull_retry:${ns}`)))
|
|
786
827
|
return true;
|
|
787
828
|
if (ns.startsWith('group:') && value.startsWith(`group_pull:${ns}`))
|
|
788
829
|
return true;
|
|
@@ -791,11 +832,9 @@ export class RpcPipeline {
|
|
|
791
832
|
if (gate?.inflight && this.pullScopeKey(key) === ns)
|
|
792
833
|
return true;
|
|
793
834
|
}
|
|
794
|
-
const state = this.pullGateStates.get(this.pullGateName(ns));
|
|
795
|
-
if (!state)
|
|
796
|
-
return false;
|
|
797
835
|
const matches = (job) => job !== null && job.namespace === ns;
|
|
798
|
-
return [...
|
|
836
|
+
return [...this.pullGateStates.values()].some((state) => [...state.activeByNamespace.values()].some(matches)
|
|
837
|
+
|| state.foreground.some(matches) || state.background.some(matches));
|
|
799
838
|
}
|
|
800
839
|
hasAnyPullActivity() {
|
|
801
840
|
if (this.pullWorkTokens.size > 0)
|
|
@@ -825,7 +864,7 @@ export class RpcPipeline {
|
|
|
825
864
|
}
|
|
826
865
|
async tryRunInlineRealtime(ns, seq, operation) {
|
|
827
866
|
const normalized = String(ns ?? '').trim();
|
|
828
|
-
if ((!normalized
|
|
867
|
+
if ((!isP2pNamespace(normalized) && !normalized.startsWith('group:'))
|
|
829
868
|
|| !Number.isSafeInteger(seq) || seq <= 0 || typeof operation !== 'function') {
|
|
830
869
|
return { acquired: false };
|
|
831
870
|
}
|
|
@@ -877,9 +916,11 @@ export class RpcPipeline {
|
|
|
877
916
|
this.inlineRealtimeScopes.delete(normalized);
|
|
878
917
|
if (state.activeByNamespace.get(normalized) === guard)
|
|
879
918
|
state.activeByNamespace.delete(normalized);
|
|
880
|
-
this.
|
|
919
|
+
for (const queuedState of this.pullGateStates.values()) {
|
|
920
|
+
this.drainPullGate(queuedState);
|
|
921
|
+
this.armQueuedPullTimers(queuedState);
|
|
922
|
+
}
|
|
881
923
|
this.runtime.client._delivery?.onPullGateIdle?.(normalized);
|
|
882
|
-
this.armQueuedPullTimers(state);
|
|
883
924
|
}
|
|
884
925
|
}
|
|
885
926
|
tryAcquirePullGate(key) {
|
|
@@ -918,8 +959,10 @@ export class RpcPipeline {
|
|
|
918
959
|
const ns = this.pullScopeKey(namespace);
|
|
919
960
|
if (!ns)
|
|
920
961
|
return true;
|
|
921
|
-
|
|
922
|
-
|
|
962
|
+
return [...this.pullGateStates.values()].every((state) => {
|
|
963
|
+
const active = state.activeByNamespace.get(ns);
|
|
964
|
+
return !active || active.namespace !== ns || (!active.timedOut && !active.invalidated);
|
|
965
|
+
});
|
|
923
966
|
}
|
|
924
967
|
invalidatePulls() {
|
|
925
968
|
if (this.pullInvalidationWait)
|
|
@@ -971,7 +1014,10 @@ export class RpcPipeline {
|
|
|
971
1014
|
pullInvalidationInProgress() {
|
|
972
1015
|
return this.pullInvalidationWait !== null;
|
|
973
1016
|
}
|
|
974
|
-
async
|
|
1017
|
+
async runPullNamespaceSerialized(key, operation, background = false) {
|
|
1018
|
+
return await this.runPullSerialized(key, operation, background, true);
|
|
1019
|
+
}
|
|
1020
|
+
async runPullSerialized(key, operation, background = false, namespaceOnly = false) {
|
|
975
1021
|
if (this.pullInvalidationInProgress()) {
|
|
976
1022
|
throw new Error('pull invalidated');
|
|
977
1023
|
}
|
|
@@ -989,7 +1035,7 @@ export class RpcPipeline {
|
|
|
989
1035
|
releasePullWork();
|
|
990
1036
|
}
|
|
991
1037
|
}
|
|
992
|
-
const state = this.pullGateState(key);
|
|
1038
|
+
const state = this.pullGateState(key, namespaceOnly);
|
|
993
1039
|
const namespace = this.pullScopeKey(key);
|
|
994
1040
|
const candidate = state.byKey.get(key);
|
|
995
1041
|
const existing = candidate && !candidate.timedOut && !candidate.invalidated ? candidate : null;
|
|
@@ -1025,7 +1071,8 @@ export class RpcPipeline {
|
|
|
1025
1071
|
(background ? state.background : state.foreground).push(job);
|
|
1026
1072
|
state.byKey.set(key, job);
|
|
1027
1073
|
this.drainPullGate(state);
|
|
1028
|
-
|
|
1074
|
+
if (state.networkLimited)
|
|
1075
|
+
this.checkPullGate(state, this.pullGateName(key));
|
|
1029
1076
|
return await promise;
|
|
1030
1077
|
}
|
|
1031
1078
|
async executePullOperation(operation, background) {
|
|
@@ -1082,17 +1129,37 @@ export class RpcPipeline {
|
|
|
1082
1129
|
state.lifecycle.set(ns, lifecycle);
|
|
1083
1130
|
}
|
|
1084
1131
|
drainPullGate(state) {
|
|
1132
|
+
const peerForward = (job) => job.background && job.namespace.startsWith('p2p.peer.v1/')
|
|
1133
|
+
&& job.key.includes('|peer=background|') && job.key.includes('|tail=false|') && job.key.includes('|force=false|');
|
|
1134
|
+
const priority = (job) => peerForward(job)
|
|
1135
|
+
? this.runtime.client._delivery?.peerBackgroundPullPriority?.(job.namespace) : undefined;
|
|
1085
1136
|
const takeRunnable = (queue) => {
|
|
1086
|
-
|
|
1137
|
+
let index = queue.findIndex((candidate) => (!this.inlineRealtimeScopes.has(candidate.namespace)
|
|
1087
1138
|
&& !state.activeByNamespace.has(candidate.namespace)));
|
|
1139
|
+
if (index >= 0 && queue === state.background && peerForward(queue[index])
|
|
1140
|
+
&& (state.backgroundPeerDispatches + 1) % _INTERNAL_MESSAGE_FLOW_LIMITS.pullMaxInflight !== 0) {
|
|
1141
|
+
let best = priority(queue[index]);
|
|
1142
|
+
if (best !== undefined)
|
|
1143
|
+
for (let next = index + 1; next < queue.length; next += 1) {
|
|
1144
|
+
const hint = priority(queue[next]);
|
|
1145
|
+
if (hint === undefined)
|
|
1146
|
+
break;
|
|
1147
|
+
if (!this.inlineRealtimeScopes.has(queue[next].namespace) && !state.activeByNamespace.has(queue[next].namespace) && hint < best) {
|
|
1148
|
+
index = next;
|
|
1149
|
+
best = hint;
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1088
1153
|
return index >= 0 ? queue.splice(index, 1)[0] : undefined;
|
|
1089
1154
|
};
|
|
1090
|
-
while (state.activeByNamespace.size <
|
|
1155
|
+
while (state.activeByNamespace.size < _INTERNAL_MESSAGE_FLOW_LIMITS.pullMaxInflight) {
|
|
1091
1156
|
const foregroundJob = takeRunnable(state.foreground);
|
|
1092
1157
|
const foregroundDrained = foregroundJob !== undefined && state.foreground.length === 0;
|
|
1093
1158
|
const job = foregroundJob ?? takeRunnable(state.background);
|
|
1094
1159
|
if (!job)
|
|
1095
1160
|
break;
|
|
1161
|
+
if (peerForward(job))
|
|
1162
|
+
state.backgroundPeerDispatches = (state.backgroundPeerDispatches + 1) % _INTERNAL_MESSAGE_FLOW_LIMITS.pullMaxInflight;
|
|
1096
1163
|
state.activeByNamespace.set(job.namespace, job);
|
|
1097
1164
|
this.runtime.client._delivery?.onPullStarted?.(job.namespace);
|
|
1098
1165
|
if (foregroundDrained)
|
|
@@ -1112,7 +1179,7 @@ export class RpcPipeline {
|
|
|
1112
1179
|
}
|
|
1113
1180
|
job.running = true;
|
|
1114
1181
|
let failed = false;
|
|
1115
|
-
void this.executePullOperation(job.operation, job.background).then((value) => { if (!job.timedOut && !job.invalidated)
|
|
1182
|
+
void this.executePullOperation(job.operation, state.networkLimited && job.background).then((value) => { if (!job.timedOut && !job.invalidated)
|
|
1116
1183
|
job.resolve(value); }, (error) => {
|
|
1117
1184
|
failed = true;
|
|
1118
1185
|
if (!job.timedOut && !job.invalidated)
|
|
@@ -1139,8 +1206,10 @@ export class RpcPipeline {
|
|
|
1139
1206
|
async rawCall(method, params, options) {
|
|
1140
1207
|
const client = this.runtime.client;
|
|
1141
1208
|
const payload = { ...(params ?? {}) };
|
|
1142
|
-
const rpcBackground = Boolean(payload.
|
|
1209
|
+
const rpcBackground = options?.background ?? (!Boolean(payload._rpc_foreground)
|
|
1210
|
+
&& (Boolean(payload._rpc_background) || client._backgroundRpcDepth > 0));
|
|
1143
1211
|
delete payload._rpc_background;
|
|
1212
|
+
delete payload._rpc_foreground;
|
|
1144
1213
|
const signed = options?.signed ?? true;
|
|
1145
1214
|
if (signed || method.startsWith('org.')) {
|
|
1146
1215
|
await this.applyClientSignature(method, payload);
|
|
@@ -1158,9 +1227,14 @@ export class RpcPipeline {
|
|
|
1158
1227
|
request = client._transport.call(method, payload);
|
|
1159
1228
|
return this.bindActivePullCancellation(method, payload, request, options?.pullGateKey ?? '');
|
|
1160
1229
|
};
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1230
|
+
try {
|
|
1231
|
+
const result = await this.transportCallWithIdentityRecovery(invokeTransport, method, payload);
|
|
1232
|
+
this.throwIfPullInvalidated(this.pullScopeKey(options?.pullGateKey || this.pullGateKeyForCall(method, payload)));
|
|
1233
|
+
return result;
|
|
1234
|
+
}
|
|
1235
|
+
finally {
|
|
1236
|
+
client._delivery?.requestBackgroundPullRecovery?.();
|
|
1237
|
+
}
|
|
1164
1238
|
}
|
|
1165
1239
|
async transportCallWithIdentityRecovery(operation, method, params) {
|
|
1166
1240
|
try {
|