@agentunion/fastaun 0.5.31 → 0.5.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -1
- package/_packed_docs/CHANGELOG.md +39 -1
- package/_packed_docs/sdk/0.5.32-SDK/345/272/224/347/224/250/351/233/206/346/210/220/346/214/207/345/215/227.md +350 -0
- package/_packed_docs/sdk/0.5.32-SDK/345/274/200/345/217/221/344/270/216/347/247/273/346/244/215/346/214/207/345/215/227.md +319 -0
- package/_packed_docs/sdk/AUN_DOCS_GUIDE.md +12 -5
- package/_packed_docs/sdk/AUN/344/272/213/344/273/266/345/217/221/345/270/203/350/256/242/351/230/205/345/272/224/347/224/250/351/233/206/346/210/220/346/214/207/345/215/227.md +459 -0
- package/_packed_docs/sdk/AUN/344/272/213/344/273/266/345/217/221/345/270/203/350/256/242/351/230/205/345/274/200/345/217/221/347/247/273/346/244/215/346/214/207/345/215/227.md +554 -0
- package/_packed_docs/sdk/INDEX.md +27 -5
- package/_packed_docs/sdk//345/255/220AID/344/277/256/346/224/271agent.md/351/200/232/347/237/245Owner/345/234/272/346/231/257/346/214/207/345/215/227.md +234 -0
- package/dist/client/control-messages.d.ts +22 -6
- package/dist/client/control-messages.js +208 -146
- package/dist/client/control-messages.js.map +1 -1
- package/dist/client/delivery.d.ts +3 -0
- package/dist/client/delivery.js +67 -3
- package/dist/client/delivery.js.map +1 -1
- package/dist/client/group-state.d.ts +3 -0
- package/dist/client/group-state.js +48 -14
- package/dist/client/group-state.js.map +1 -1
- package/dist/client/lifecycle.js +3 -2
- package/dist/client/lifecycle.js.map +1 -1
- package/dist/client/rpc-pipeline.d.ts +9 -3
- package/dist/client/rpc-pipeline.js +53 -22
- package/dist/client/rpc-pipeline.js.map +1 -1
- package/dist/client/v2-e2ee.d.ts +13 -1
- package/dist/client/v2-e2ee.js +32 -19
- package/dist/client/v2-e2ee.js.map +1 -1
- package/dist/client.d.ts +6 -1
- package/dist/client.js +57 -21
- package/dist/client.js.map +1 -1
- package/dist/group-fs.js +1 -1
- package/dist/group-fs.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/ownership-workflow.js +3 -3
- package/dist/ownership-workflow.js.map +1 -1
- package/dist/pubsub/binding.d.ts +54 -0
- package/dist/pubsub/binding.js +343 -0
- package/dist/pubsub/binding.js.map +1 -0
- package/dist/pubsub/channel.d.ts +45 -0
- package/dist/pubsub/channel.js +137 -0
- package/dist/pubsub/channel.js.map +1 -0
- package/dist/pubsub/client.d.ts +93 -0
- package/dist/pubsub/client.js +318 -0
- package/dist/pubsub/client.js.map +1 -0
- package/dist/pubsub/credentials.d.ts +51 -0
- package/dist/pubsub/credentials.js +360 -0
- package/dist/pubsub/credentials.js.map +1 -0
- package/dist/pubsub/errors.d.ts +5 -0
- package/dist/pubsub/errors.js +6 -0
- package/dist/pubsub/errors.js.map +1 -0
- package/dist/pubsub/index.d.ts +48 -0
- package/dist/pubsub/index.js +152 -0
- package/dist/pubsub/index.js.map +1 -0
- package/dist/pubsub/scheduler.d.ts +58 -0
- package/dist/pubsub/scheduler.js +249 -0
- package/dist/pubsub/scheduler.js.map +1 -0
- package/dist/pubsub/service.d.ts +100 -0
- package/dist/pubsub/service.js +650 -0
- package/dist/pubsub/service.js.map +1 -0
- package/dist/pubsub/types.d.ts +119 -0
- package/dist/pubsub/types.js +2 -0
- package/dist/pubsub/types.js.map +1 -0
- package/dist/storage/lowlevel.js +44 -7
- package/dist/storage/lowlevel.js.map +1 -1
- package/dist/storage/read-cache.d.ts +7 -3
- package/dist/storage/read-cache.js +137 -18
- package/dist/storage/read-cache.js.map +1 -1
- package/dist/storage/vfs.d.ts +1 -0
- package/dist/storage/vfs.js +11 -1
- package/dist/storage/vfs.js.map +1 -1
- package/dist/tools/cross-sdk-agent.d.ts +1 -1
- package/dist/tools/pubsub-actor.d.ts +27 -0
- package/dist/tools/pubsub-actor.js +260 -0
- package/dist/tools/pubsub-actor.js.map +1 -0
- package/dist/transport.d.ts +25 -1
- package/dist/transport.js +175 -10
- package/dist/transport.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/client/v2-e2ee.js
CHANGED
|
@@ -485,9 +485,6 @@ export class V2E2EECoordinator {
|
|
|
485
485
|
catch (exc) {
|
|
486
486
|
client._clientLog.warn(`V2 session init failed (non-fatal): ${formatE2EEError(exc)}`);
|
|
487
487
|
}
|
|
488
|
-
if (opts.backgroundSync && client._v2Session && typeof client._v2AutoConfirmPendingProposals === 'function') {
|
|
489
|
-
client._safeAsync(client._v2AutoConfirmPendingProposals());
|
|
490
|
-
}
|
|
491
488
|
}
|
|
492
489
|
async initV2Session() {
|
|
493
490
|
const client = this.client;
|
|
@@ -561,7 +558,7 @@ export class V2E2EECoordinator {
|
|
|
561
558
|
inflight.add(gid);
|
|
562
559
|
client._safeAsync((async () => {
|
|
563
560
|
try {
|
|
564
|
-
await client._v2Session.ensureGroupRegistered?.(gid, client.
|
|
561
|
+
await client._v2Session.ensureGroupRegistered?.(gid, (method, params) => client.call(method, { ...params, _rpc_background: true }));
|
|
565
562
|
client._clientLog.debug(`group SPK registered: group=${gid} reason=${opts.reason}`);
|
|
566
563
|
}
|
|
567
564
|
catch (exc) {
|
|
@@ -583,7 +580,7 @@ export class V2E2EECoordinator {
|
|
|
583
580
|
inflight.add(gid);
|
|
584
581
|
client._safeAsync((async () => {
|
|
585
582
|
try {
|
|
586
|
-
await client._v2Session.rotateGroupSPK?.(gid, client.
|
|
583
|
+
await client._v2Session.rotateGroupSPK?.(gid, (method, params) => client.call(method, { ...params, _rpc_background: true }));
|
|
587
584
|
client._clientLog.debug(`group SPK rotated: group=${gid} reason=${opts.reason}`);
|
|
588
585
|
}
|
|
589
586
|
catch (exc) {
|
|
@@ -642,15 +639,15 @@ export class V2E2EECoordinator {
|
|
|
642
639
|
pendingSenderIKFetchKey(fromAid, senderDeviceId, groupId) {
|
|
643
640
|
return `${fromAid}#${senderDeviceId}#${groupId || ''}`;
|
|
644
641
|
}
|
|
645
|
-
async fetchSenderIKOnce(fromAid, senderDeviceId, groupId, certFingerprint = '') {
|
|
642
|
+
async fetchSenderIKOnce(fromAid, senderDeviceId, groupId, certFingerprint = '', rpcOptions) {
|
|
646
643
|
const client = this.client;
|
|
647
644
|
const peerAid = String(fromAid ?? '').trim();
|
|
648
645
|
const deviceId = String(senderDeviceId ?? '').trim();
|
|
649
646
|
const gid = String(groupId ?? '').trim();
|
|
650
647
|
const fingerprint = String(certFingerprint ?? '').trim().toLowerCase();
|
|
651
|
-
if (!peerAid)
|
|
648
|
+
if (!peerAid || rpcOptions?.deadline !== undefined && rpcOptions.deadline <= Date.now())
|
|
652
649
|
return null;
|
|
653
|
-
const fetchKey = [peerAid, deviceId, gid, fingerprint].join('#');
|
|
650
|
+
const fetchKey = [peerAid, deviceId, gid, fingerprint, ...(rpcOptions ? [rpcOptions.background, rpcOptions.deadline] : [])].join('#');
|
|
654
651
|
const existing = this.senderIKSyncFetches.get(fetchKey);
|
|
655
652
|
if (existing)
|
|
656
653
|
return await existing;
|
|
@@ -658,12 +655,15 @@ export class V2E2EECoordinator {
|
|
|
658
655
|
const started = Date.now();
|
|
659
656
|
let timer;
|
|
660
657
|
const timedOut = Symbol('sender-ik-timeout');
|
|
658
|
+
const expired = () => rpcOptions?.deadline !== undefined && rpcOptions.deadline <= Date.now();
|
|
661
659
|
const fetch = async () => {
|
|
660
|
+
if (expired())
|
|
661
|
+
return null;
|
|
662
662
|
try {
|
|
663
663
|
const bootstrap = await client.call('message.v2.bootstrap', {
|
|
664
664
|
peer_aid: peerAid,
|
|
665
665
|
e2ee_wrap_capabilities: v2WrapCapabilities(),
|
|
666
|
-
});
|
|
666
|
+
}, ...(rpcOptions ? [rpcOptions] : []));
|
|
667
667
|
const peers = (Array.isArray(bootstrap?.peer_devices) ? bootstrap.peer_devices : []);
|
|
668
668
|
for (const dev of peers)
|
|
669
669
|
client._cacheV2PeerIKFromDevice(dev, peerAid);
|
|
@@ -671,14 +671,18 @@ export class V2E2EECoordinator {
|
|
|
671
671
|
catch (exc) {
|
|
672
672
|
client._clientLog.warn(`V2 sender IK 同步 bootstrap 失败: peer=${peerAid} device=${deviceId || '-'} err=${formatE2EEError(exc)}`);
|
|
673
673
|
}
|
|
674
|
+
if (expired())
|
|
675
|
+
return null;
|
|
674
676
|
let senderPubDer = await this.getV2SenderPubDer(peerAid, deviceId, fingerprint);
|
|
677
|
+
if (expired())
|
|
678
|
+
return null;
|
|
675
679
|
if (senderPubDer || !gid)
|
|
676
680
|
return senderPubDer;
|
|
677
681
|
try {
|
|
678
682
|
const bootstrap = await client.call('group.v2.bootstrap', {
|
|
679
683
|
group_id: gid,
|
|
680
684
|
e2ee_wrap_capabilities: v2WrapCapabilities(),
|
|
681
|
-
});
|
|
685
|
+
}, ...(rpcOptions ? [rpcOptions] : []));
|
|
682
686
|
const devices = (Array.isArray(bootstrap?.devices) ? bootstrap.devices : []);
|
|
683
687
|
const audit = (Array.isArray(bootstrap?.audit_recipients) ? bootstrap.audit_recipients : []);
|
|
684
688
|
for (const dev of devices)
|
|
@@ -689,6 +693,8 @@ export class V2E2EECoordinator {
|
|
|
689
693
|
catch (exc) {
|
|
690
694
|
client._clientLog.warn(`V2 sender IK 同步 group bootstrap 失败: group=${gid} peer=${peerAid} err=${formatE2EEError(exc)}`);
|
|
691
695
|
}
|
|
696
|
+
if (expired())
|
|
697
|
+
return null;
|
|
692
698
|
senderPubDer = await this.getV2SenderPubDer(peerAid, deviceId, fingerprint);
|
|
693
699
|
return senderPubDer;
|
|
694
700
|
};
|
|
@@ -696,7 +702,7 @@ export class V2E2EECoordinator {
|
|
|
696
702
|
const result = await Promise.race([
|
|
697
703
|
fetch(),
|
|
698
704
|
new Promise((resolve) => {
|
|
699
|
-
timer = setTimeout(() => resolve(timedOut), V2_SENDER_IK_SYNC_FETCH_TIMEOUT_MS);
|
|
705
|
+
timer = setTimeout(() => resolve(timedOut), Math.max(0, Math.min(V2_SENDER_IK_SYNC_FETCH_TIMEOUT_MS, (rpcOptions?.deadline ?? Infinity) - Date.now())));
|
|
700
706
|
}),
|
|
701
707
|
]);
|
|
702
708
|
if (result === timedOut) {
|
|
@@ -924,10 +930,11 @@ export class V2E2EECoordinator {
|
|
|
924
930
|
}
|
|
925
931
|
else {
|
|
926
932
|
this.targetSetCache.delete(to);
|
|
927
|
-
const
|
|
933
|
+
const bootstrapParams = {
|
|
928
934
|
peer_aid: to,
|
|
929
935
|
e2ee_wrap_capabilities: v2WrapCapabilities(),
|
|
930
|
-
}
|
|
936
|
+
};
|
|
937
|
+
const bs = await (opts.background === undefined && opts.deadline === undefined ? client.call('message.v2.bootstrap', bootstrapParams) : client.call('message.v2.bootstrap', bootstrapParams, { background: opts.background, deadline: opts.deadline }));
|
|
931
938
|
if (typeof client._primeBootstrapPeerCerts === 'function') {
|
|
932
939
|
await client._primeBootstrapPeerCerts(bs, to);
|
|
933
940
|
}
|
|
@@ -995,10 +1002,11 @@ export class V2E2EECoordinator {
|
|
|
995
1002
|
}
|
|
996
1003
|
else {
|
|
997
1004
|
this.targetSetCache.delete(client._aid);
|
|
998
|
-
const
|
|
1005
|
+
const selfParams = {
|
|
999
1006
|
peer_aid: client._aid,
|
|
1000
1007
|
e2ee_wrap_capabilities: v2WrapCapabilities(),
|
|
1001
|
-
}
|
|
1008
|
+
};
|
|
1009
|
+
const selfBs = await (opts.background === undefined && opts.deadline === undefined ? client.call('message.v2.bootstrap', selfParams) : client.call('message.v2.bootstrap', selfParams, { background: opts.background, deadline: opts.deadline }));
|
|
1002
1010
|
if (typeof client._primeBootstrapPeerCerts === 'function') {
|
|
1003
1011
|
await client._primeBootstrapPeerCerts(selfBs, client._aid);
|
|
1004
1012
|
}
|
|
@@ -1114,9 +1122,11 @@ export class V2E2EECoordinator {
|
|
|
1114
1122
|
protectedHeaders: opts?.protectedHeaders,
|
|
1115
1123
|
context: opts?.context,
|
|
1116
1124
|
needRender: opts?.needRender,
|
|
1125
|
+
background: opts?.background,
|
|
1126
|
+
deadline: opts?.deadline,
|
|
1117
1127
|
useCache,
|
|
1118
1128
|
});
|
|
1119
|
-
const
|
|
1129
|
+
const request = {
|
|
1120
1130
|
to: toAid,
|
|
1121
1131
|
payload: envelope,
|
|
1122
1132
|
message_id: messageId,
|
|
@@ -1127,7 +1137,8 @@ export class V2E2EECoordinator {
|
|
|
1127
1137
|
encrypt: false,
|
|
1128
1138
|
need_render: opts?.needRender ?? true,
|
|
1129
1139
|
_skip_send_result_envelope: true,
|
|
1130
|
-
}
|
|
1140
|
+
};
|
|
1141
|
+
const result = await (opts?.background === undefined && opts?.deadline === undefined ? client.call('message.send', request) : client.call('message.send', request, { background: opts?.background, deadline: opts?.deadline }));
|
|
1131
1142
|
client._clientLog.debug(`message.v2.send ok: to=${toAid}, use_cache=${useCache}, seq=${String((isJsonObject(result) ? result.seq : '') ?? '')}`);
|
|
1132
1143
|
return result;
|
|
1133
1144
|
};
|
|
@@ -2503,6 +2514,8 @@ export class V2E2EECoordinator {
|
|
|
2503
2514
|
protectedHeaders: opts?.protectedHeaders,
|
|
2504
2515
|
context: opts?.context,
|
|
2505
2516
|
needRender: opts?.needRender,
|
|
2517
|
+
background: opts?.background,
|
|
2518
|
+
deadline: opts?.deadline,
|
|
2506
2519
|
useCache,
|
|
2507
2520
|
});
|
|
2508
2521
|
const result = await client.call('group.v2.send', withExplicitGroupAid({
|
|
@@ -2511,7 +2524,7 @@ export class V2E2EECoordinator {
|
|
|
2511
2524
|
...(opts?.ttl !== undefined ? { ttl: opts.ttl } : {}),
|
|
2512
2525
|
...(opts?.messageClass !== undefined ? { message_class: opts.messageClass } : {}),
|
|
2513
2526
|
...(opts?.protectedHeaders ? { protected_headers: opts.protectedHeaders } : {}),
|
|
2514
|
-
}, groupAid));
|
|
2527
|
+
}, groupAid), ...(opts?.background !== undefined || opts?.deadline !== undefined ? [{ background: opts?.background, deadline: opts?.deadline }] : []));
|
|
2515
2528
|
client._clientLog.debug(`group.v2.send ok: group=${gid}, use_cache=${useCache}, seq=${String((isJsonObject(result) ? result.seq : '') ?? '')}`);
|
|
2516
2529
|
return result;
|
|
2517
2530
|
};
|
|
@@ -2575,7 +2588,7 @@ export class V2E2EECoordinator {
|
|
|
2575
2588
|
const bs = await client.call('group.v2.bootstrap', {
|
|
2576
2589
|
group_id: groupId,
|
|
2577
2590
|
e2ee_wrap_capabilities: v2WrapCapabilities(),
|
|
2578
|
-
});
|
|
2591
|
+
}, ...(opts.background !== undefined || opts.deadline !== undefined ? [{ background: opts.background, deadline: opts.deadline }] : []));
|
|
2579
2592
|
allDevices = (Array.isArray(bs.devices) ? bs.devices : []);
|
|
2580
2593
|
auditRecipientsRaw = (Array.isArray(bs.audit_recipients) ? bs.audit_recipients : []);
|
|
2581
2594
|
epoch = Number(bs.epoch ?? 0) || 0;
|