@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
|
@@ -174,6 +174,9 @@ export declare class MessageDeliveryEngine {
|
|
|
174
174
|
pendingPullUpper(ns: string): number;
|
|
175
175
|
hasAnyPendingPull(): boolean;
|
|
176
176
|
onPullGateIdle(ns: string): void;
|
|
177
|
+
queueMessageClassPull(params: Record<string, any>): void;
|
|
178
|
+
restoreMessageClassPulls(): Promise<void>;
|
|
179
|
+
private pullMessageClassPage;
|
|
177
180
|
private recordBackgroundPullNeed;
|
|
178
181
|
observeBackgroundPullResponse(ns: string, afterSeq: number, result: unknown, limit?: number): void;
|
|
179
182
|
private finishBackgroundPull;
|
package/dist/client/delivery.js
CHANGED
|
@@ -165,8 +165,11 @@ export class MessageDeliveryEngine {
|
|
|
165
165
|
this.groupPullVersions.clear();
|
|
166
166
|
}
|
|
167
167
|
groupPullNamespace(namespace) {
|
|
168
|
-
|
|
168
|
+
let groupId = namespace.startsWith('group_event:') ? namespace.slice('group_event:'.length)
|
|
169
169
|
: namespace.startsWith('group:') ? namespace.slice('group:'.length) : '';
|
|
170
|
+
if (namespace.startsWith('message_class/')) {
|
|
171
|
+
groupId = /^message_class\/[^/]+\/(?:group|volatile_group)\/(.+)$/.exec(namespace)?.[1] ?? '';
|
|
172
|
+
}
|
|
170
173
|
return groupId ? `group:${normalizeGroupAid(groupId)}` : '';
|
|
171
174
|
}
|
|
172
175
|
automaticGroupPullStopped(namespace) {
|
|
@@ -1684,12 +1687,64 @@ export class MessageDeliveryEngine {
|
|
|
1684
1687
|
}
|
|
1685
1688
|
this.schedulePendingGroupPullIfNeeded(ns, 'pull-gate-idle');
|
|
1686
1689
|
}
|
|
1690
|
+
queueMessageClassPull(params) {
|
|
1691
|
+
const client = this.runtime.client;
|
|
1692
|
+
if (client._sessionOptions?.background_sync === false || !client._aid || client._closing)
|
|
1693
|
+
return;
|
|
1694
|
+
const group = Boolean(params.group_id ?? params.group_aid);
|
|
1695
|
+
if (!client._controlMessages().supports(params.message_class, group))
|
|
1696
|
+
return;
|
|
1697
|
+
this.ensurePeerContext();
|
|
1698
|
+
const ns = `message_class/${params.message_class}/${group ? params.volatile ? 'volatile_group' : 'group' : 'peer'}/${group ? params.group_id ?? params.group_aid : params.sender_aid}`;
|
|
1699
|
+
if (this.automaticGroupPullStopped(ns))
|
|
1700
|
+
return;
|
|
1701
|
+
this.recordBackgroundPullNeed(ns, 0, true, true);
|
|
1702
|
+
this.backgroundPullNeeds.get(ns).messageClassRequest = { ...params };
|
|
1703
|
+
this.requestBackgroundPullRecovery();
|
|
1704
|
+
}
|
|
1705
|
+
async restoreMessageClassPulls() {
|
|
1706
|
+
const client = this.runtime.client;
|
|
1707
|
+
if (!client._aid || client._sessionOptions?.background_sync === false)
|
|
1708
|
+
return;
|
|
1709
|
+
const saved = client._tokenStore.loadInstanceState?.(client._aid, client._deviceId, client._slotId)?.message_control_v1 ?? {};
|
|
1710
|
+
for (const key of Object.keys(saved)) {
|
|
1711
|
+
const [messageClass, kind, scope] = JSON.parse(key);
|
|
1712
|
+
this.queueMessageClassPull({ message_class: messageClass,
|
|
1713
|
+
...(kind === 'peer' ? { sender_aid: scope } : { group_id: scope }), ...(kind === 'volatile_group' ? { volatile: true } : {}) });
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
async pullMessageClassPage(ns, need, generation) {
|
|
1717
|
+
const client = this.runtime.client;
|
|
1718
|
+
const request = need.messageClassRequest;
|
|
1719
|
+
const trigger = need.trigger;
|
|
1720
|
+
try {
|
|
1721
|
+
const result = await this.runAutomaticPull(ns, () => client._controlMessages().call(request.group_id || request.group_aid ? 'group.v2.pull' : 'message.v2.pull', request, true));
|
|
1722
|
+
if (generation !== this.captureInlineAckGeneration() || trigger !== need.trigger)
|
|
1723
|
+
return;
|
|
1724
|
+
if (result._pubsub_backpressure === true) {
|
|
1725
|
+
need.retryAt = Infinity;
|
|
1726
|
+
return;
|
|
1727
|
+
}
|
|
1728
|
+
if (result.has_more === true || result.volatile_has_more === true) {
|
|
1729
|
+
if (result.head_seq > 0)
|
|
1730
|
+
need.messageClassRequest = { ...request, head_seq: result.head_seq };
|
|
1731
|
+
}
|
|
1732
|
+
else
|
|
1733
|
+
this.backgroundPullNeeds.delete(ns);
|
|
1734
|
+
}
|
|
1735
|
+
catch (error) {
|
|
1736
|
+
if (generation === this.captureInlineAckGeneration()) {
|
|
1737
|
+
need.retryAt = this.automaticPullFailures.get(ns)?.retryAt ?? Date.now() + BACKGROUND_PULL_RETRY_DELAY_MS;
|
|
1738
|
+
}
|
|
1739
|
+
throw error;
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1687
1742
|
recordBackgroundPullNeed(ns, throughSeq = 0, probe = false, restart = false) {
|
|
1688
1743
|
if (this.automaticGroupPullStopped(ns))
|
|
1689
1744
|
return;
|
|
1690
1745
|
const client = this.runtime.client;
|
|
1691
1746
|
if (client._sessionOptions?.background_sync === false || !client._aid
|
|
1692
|
-
|| !(ns === `p2p:${client._aid}` || ns.startsWith('group:') || ns.startsWith('group_event:')))
|
|
1747
|
+
|| !(ns === `p2p:${client._aid}` || ns.startsWith('group:') || ns.startsWith('group_event:') || ns.startsWith('message_class/')))
|
|
1693
1748
|
return;
|
|
1694
1749
|
const need = this.backgroundPullNeeds.get(ns) ?? {
|
|
1695
1750
|
throughSeq: 0, hasMore: false, probe, lastAfter: -1, retryAt: 0, empty: false, trigger: {},
|
|
@@ -1784,6 +1839,13 @@ export class MessageDeliveryEngine {
|
|
|
1784
1839
|
}
|
|
1785
1840
|
if (ns.startsWith('p2p:') && !this.hasP2pApplicationSubscription())
|
|
1786
1841
|
continue;
|
|
1842
|
+
if (need.messageClassRequest && need.messageClassRequest.message_class !== 'sdk_control') {
|
|
1843
|
+
const events = need.messageClassRequest.group_id || need.messageClassRequest.group_aid
|
|
1844
|
+
? ['group.message_created', 'group.message_batch'] : ['message.received', 'message.batch'];
|
|
1845
|
+
const handlers = client._dispatcher._snapshotApplicationHandlers?.(events);
|
|
1846
|
+
if (handlers && ![...handlers.values()].some((selected) => selected.length > 0))
|
|
1847
|
+
continue;
|
|
1848
|
+
}
|
|
1787
1849
|
if (this.backgroundPullTasks.has(ns) || this.realtimeSyncing?.has(ns) || this.onlineUnreadHintTasks?.has(ns))
|
|
1788
1850
|
continue;
|
|
1789
1851
|
const eventScope = ns.startsWith('group_event:');
|
|
@@ -1793,7 +1855,7 @@ export class MessageDeliveryEngine {
|
|
|
1793
1855
|
if (filling || (!eventScope && client._rpcPipeline?.hasPullActivity?.(ns, false))
|
|
1794
1856
|
|| (eventScope && ['pulling', 'processing', 'pulled'].includes(client._rpcPipeline?.getPullLifecycle?.(ns))))
|
|
1795
1857
|
continue;
|
|
1796
|
-
if (this.syncState(ns).ack >= need.throughSeq && !need.hasMore && !need.probe) {
|
|
1858
|
+
if (!need.messageClassRequest && this.syncState(ns).ack >= need.throughSeq && !need.hasMore && !need.probe) {
|
|
1797
1859
|
this.backgroundPullNeeds.delete(ns);
|
|
1798
1860
|
continue;
|
|
1799
1861
|
}
|
|
@@ -1805,6 +1867,8 @@ export class MessageDeliveryEngine {
|
|
|
1805
1867
|
const task = Promise.resolve().then(() => {
|
|
1806
1868
|
if (generation !== this.captureInlineAckGeneration())
|
|
1807
1869
|
return;
|
|
1870
|
+
if (need.messageClassRequest)
|
|
1871
|
+
return this.pullMessageClassPage(ns, need, generation);
|
|
1808
1872
|
return eventScope ? this.fillGroupEventGap(ns.slice('group_event:'.length))
|
|
1809
1873
|
: ns.startsWith('group:') ? this.fillGroupGap(ns.slice(6)) : this.fillP2pGap();
|
|
1810
1874
|
}).finally(() => {
|