@agentunion/fastaun 0.5.13 → 0.5.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -0
- package/_packed_docs/CHANGELOG.md +39 -0
- package/_packed_docs/aun/345/210/206/345/270/203/345/274/217/346/265/213/350/257/225/350/277/220/350/241/214/346/214/207/345/215/227.md +85 -4
- package/_packed_docs/aun/346/265/213/350/257/225/350/277/220/350/241/214/346/214/207/345/215/227.md +1 -1
- package/dist/client/delivery.d.ts +1 -0
- package/dist/client/delivery.js +81 -55
- package/dist/client/delivery.js.map +1 -1
- package/dist/client/rpc-pipeline.d.ts +3 -3
- package/dist/client/rpc-pipeline.js +34 -39
- package/dist/client/rpc-pipeline.js.map +1 -1
- package/dist/client/v2-e2ee.js +51 -16
- package/dist/client/v2-e2ee.js.map +1 -1
- package/dist/client.js +28 -23
- package/dist/client.js.map +1 -1
- package/dist/events.d.ts +18 -8
- package/dist/events.js +154 -50
- package/dist/events.js.map +1 -1
- package/dist/group-index.js +1 -1
- package/dist/group-index.js.map +1 -1
- package/dist/logger.d.ts +9 -1
- package/dist/logger.js +29 -7
- package/dist/logger.js.map +1 -1
- package/dist/result.d.ts +1 -2
- package/dist/result.js +2 -2
- package/dist/result.js.map +1 -1
- package/dist/transport.d.ts +7 -1
- package/dist/transport.js +139 -55
- package/dist/transport.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -575,6 +575,7 @@ export class AUNClient {
|
|
|
575
575
|
aunPath: this._configModel.aunPath,
|
|
576
576
|
});
|
|
577
577
|
this._logger.bindDeviceId(this._deviceId);
|
|
578
|
+
this._logger.bindAid(initAid ?? '');
|
|
578
579
|
this._clientLog = this._logger.for('aun_core.client');
|
|
579
580
|
if (debugFlag) {
|
|
580
581
|
this._clientLog.info(`AUNClient initialized (debug=true, aunPath=${this._configModel.aunPath})`);
|
|
@@ -624,13 +625,13 @@ export class AUNClient {
|
|
|
624
625
|
});
|
|
625
626
|
this._transport = new RPCTransport({
|
|
626
627
|
eventDispatcher: this._dispatcher,
|
|
627
|
-
timeout:
|
|
628
|
-
onDisconnect: (err, closeCode) => this._handleTransportDisconnect(err, closeCode),
|
|
628
|
+
timeout: 35_000,
|
|
629
629
|
verifySsl: this._configModel.verifySsl,
|
|
630
630
|
logger: this._logger.for('aun_core.transport'),
|
|
631
631
|
dnsNet,
|
|
632
632
|
});
|
|
633
|
-
this._transport.
|
|
633
|
+
this._transport.setProtocolMetaObserver((meta) => this._observeRpcMeta(meta));
|
|
634
|
+
this._transport.setProtocolDisconnectCallback((err, closeCode) => this._handleTransportDisconnect(err, closeCode));
|
|
634
635
|
this._runtime = new ClientRuntime(this);
|
|
635
636
|
this._identityRuntime = new IdentityRuntimeManager(this._runtime);
|
|
636
637
|
this._peerDirectory = new PeerDirectory(this._runtime);
|
|
@@ -654,11 +655,11 @@ export class AUNClient {
|
|
|
654
655
|
}
|
|
655
656
|
}
|
|
656
657
|
// 内部订阅:推送消息自动解密后 re-publish 给用户
|
|
657
|
-
this._dispatcher.
|
|
658
|
+
this._dispatcher.subscribeProtocol('_raw.message.received', (data) => this._onRawMessageReceived(data));
|
|
658
659
|
// P2P 消息撤回推送:在线 push 与 pull tombstone 去重后再发布给应用层
|
|
659
|
-
this._dispatcher.
|
|
660
|
+
this._dispatcher.subscribeProtocol('_raw.message.recalled', (data) => this._safeAsync(this._onRawMessageRecalled(data)));
|
|
660
661
|
// V2 P2P 推送通知:收到通知后自动走 message.v2.pull 拉取并解密
|
|
661
|
-
this._dispatcher.
|
|
662
|
+
this._dispatcher.subscribeProtocol('_raw.peer.v2.message_received', (data) => {
|
|
662
663
|
const ns = this._aid ? `p2p:${this._aid}` : '';
|
|
663
664
|
const hasInline = isJsonObject(data)
|
|
664
665
|
&& isJsonObject(data.inline_message);
|
|
@@ -668,7 +669,7 @@ export class AUNClient {
|
|
|
668
669
|
: this._onV2PushNotification(data, 'v2'));
|
|
669
670
|
});
|
|
670
671
|
// V2 群组消息推送通知:收到通知后自动走 group.v2.pull 拉取并解密
|
|
671
|
-
this._dispatcher.
|
|
672
|
+
this._dispatcher.subscribeProtocol('_raw.group.v2.message_created', (data) => {
|
|
672
673
|
const groupId = isJsonObject(data)
|
|
673
674
|
? String(data.group_id ?? '').trim()
|
|
674
675
|
: '';
|
|
@@ -681,26 +682,26 @@ export class AUNClient {
|
|
|
681
682
|
: this._onRawGroupV2MessageCreated(data, 'v2'));
|
|
682
683
|
});
|
|
683
684
|
// 群组消息推送:自动解密后 re-publish
|
|
684
|
-
this._dispatcher.
|
|
685
|
+
this._dispatcher.subscribeProtocol('_raw.group.message_created', (data) => this._onRawGroupMessageCreated(data));
|
|
685
686
|
// 群组消息撤回推送:在线 push 通道,与 pull 双 tombstone 兜底互补(SDK 去重只回调一次)
|
|
686
|
-
this._dispatcher.
|
|
687
|
+
this._dispatcher.subscribeProtocol('_raw.group.message_recalled', (data) => this._safeAsync(this._onRawGroupMessageRecalled(data)));
|
|
687
688
|
// 群组变更事件:透传并触发 V2 state/SPK 维护
|
|
688
|
-
this._dispatcher.
|
|
689
|
+
this._dispatcher.subscribeProtocol('_raw.group.changed', (data) => this._onRawGroupChanged(data));
|
|
689
690
|
// 定向邀请底层事件:按群 + 目标 AID 聚合后向应用层只提示一次。
|
|
690
|
-
this._dispatcher.
|
|
691
|
-
this._dispatcher.
|
|
691
|
+
this._dispatcher.subscribeProtocol('_raw.group.invite_created', (data) => this._onRawGroupInviteCreated(data));
|
|
692
|
+
this._dispatcher.subscribeProtocol('_raw.group.invite_finalized', (data) => this._onRawGroupInviteFinalized(data));
|
|
692
693
|
// V2 state proposal 服务平面事件:owner/admin 负责确认或重新提案
|
|
693
|
-
this._dispatcher.
|
|
694
|
-
this._dispatcher.
|
|
695
|
-
this._dispatcher.
|
|
694
|
+
this._dispatcher.subscribeProtocol('_raw.group.v2.state_proposed', (data) => this._safeAsync(this._onV2StateProposed(data)));
|
|
695
|
+
this._dispatcher.subscribeProtocol('_raw.group.v2.state_retry_needed', (data) => this._safeAsync(this._onV2StateRetryNeeded(data)));
|
|
696
|
+
this._dispatcher.subscribeProtocol('_raw.group.v2.state_confirmed', (data) => this._safeAsync(this._onV2StateConfirmed(data)));
|
|
696
697
|
// 群组状态提交事件:验证 state_hash 链并更新本地存储
|
|
697
|
-
this._dispatcher.
|
|
698
|
+
this._dispatcher.subscribeProtocol('_raw.group.state_committed', (data) => this._onGroupStateCommitted(data));
|
|
698
699
|
// 其他事件直接透传
|
|
699
700
|
for (const evt of ['message.ack', 'storage.object_changed', 'stream/created', 'stream/closed']) {
|
|
700
|
-
this._dispatcher.
|
|
701
|
+
this._dispatcher.subscribeProtocol(`_raw.${evt}`, (data) => this._dispatcher.enqueue(evt, data));
|
|
701
702
|
}
|
|
702
703
|
// 服务端主动断开通知:记录日志并标记不重连
|
|
703
|
-
this._dispatcher.
|
|
704
|
+
this._dispatcher.subscribeProtocol('_raw.gateway.disconnect', (data) => this._onGatewayDisconnect(data));
|
|
704
705
|
}
|
|
705
706
|
// ── 属性 ──────────────────────────────────────────────────
|
|
706
707
|
/** 当前 AID */
|
|
@@ -867,6 +868,7 @@ export class AUNClient {
|
|
|
867
868
|
const debugFlag = nextConfig.debug;
|
|
868
869
|
this._logger = new AUNLogger({ debug: debugFlag, aunPath: nextConfig.aunPath });
|
|
869
870
|
this._logger.bindDeviceId(this._deviceId);
|
|
871
|
+
this._logger.bindAid(aid.aid);
|
|
870
872
|
this._clientLog = this._logger.for('aun_core.client');
|
|
871
873
|
const dnsNet = new DnsResilientNet({
|
|
872
874
|
verifySsl: nextConfig.verifySsl,
|
|
@@ -908,13 +910,13 @@ export class AUNClient {
|
|
|
908
910
|
});
|
|
909
911
|
this._transport = new RPCTransport({
|
|
910
912
|
eventDispatcher: this._dispatcher,
|
|
911
|
-
timeout:
|
|
912
|
-
onDisconnect: (err, closeCode) => this._handleTransportDisconnect(err, closeCode),
|
|
913
|
+
timeout: 35_000,
|
|
913
914
|
verifySsl: nextConfig.verifySsl,
|
|
914
915
|
logger: this._logger.for('aun_core.transport'),
|
|
915
916
|
dnsNet,
|
|
916
917
|
});
|
|
917
|
-
this._transport.
|
|
918
|
+
this._transport.setProtocolMetaObserver((meta) => this._observeRpcMeta(meta));
|
|
919
|
+
this._transport.setProtocolDisconnectCallback((err, closeCode) => this._handleTransportDisconnect(err, closeCode));
|
|
918
920
|
}
|
|
919
921
|
loadIdentity(aid) {
|
|
920
922
|
this._identityRuntime.loadIdentity(aid);
|
|
@@ -1740,7 +1742,7 @@ export class AUNClient {
|
|
|
1740
1742
|
this._clientLog.debug(`on exit: elapsed=${Date.now() - tStart}ms event=${event}`);
|
|
1741
1743
|
return result;
|
|
1742
1744
|
}
|
|
1743
|
-
async _callRawV2Rpc(method, params) {
|
|
1745
|
+
async _callRawV2Rpc(method, params, pullGateKey = '') {
|
|
1744
1746
|
const p = { ...(params ?? {}) };
|
|
1745
1747
|
const forceForeground = Boolean(p._rpc_foreground);
|
|
1746
1748
|
const rpcBackground = !forceForeground
|
|
@@ -1769,7 +1771,10 @@ export class AUNClient {
|
|
|
1769
1771
|
if (method.startsWith('group.') && p.slot_id === undefined) {
|
|
1770
1772
|
p.slot_id = this._slotId;
|
|
1771
1773
|
}
|
|
1772
|
-
return await this._rpcPipeline.rawCall(method, p, {
|
|
1774
|
+
return await this._rpcPipeline.rawCall(method, p, {
|
|
1775
|
+
background: rpcBackground,
|
|
1776
|
+
...(pullGateKey ? { pullGateKey } : {}),
|
|
1777
|
+
});
|
|
1773
1778
|
}
|
|
1774
1779
|
/** P2-13: 取消订阅事件(对齐 Python/JS off 方法) */
|
|
1775
1780
|
off(event, handler) {
|