@agentunion/fastaun 0.5.35 → 0.5.36
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 +26 -0
- package/_packed_docs/CHANGELOG.md +26 -0
- package/_packed_docs/INDEX.md +10 -3
- package/_packed_docs/sdk/0.5.36-SDK/345/272/224/347/224/250/351/233/206/346/210/220/346/214/207/345/215/227.md +130 -0
- package/_packed_docs/sdk/0.5.36-SDK/345/274/200/345/217/221/344/270/216/347/247/273/346/244/215/346/214/207/345/215/227.md +176 -0
- package/_packed_docs/sdk/INDEX.md +15 -10
- package/dist/agent-md.d.ts +2 -1
- package/dist/agent-md.js +33 -6
- package/dist/agent-md.js.map +1 -1
- package/dist/aid-store.js +5 -1
- package/dist/aid-store.js.map +1 -1
- package/dist/auth.js +5 -2
- package/dist/auth.js.map +1 -1
- package/dist/client/delivery.d.ts +1 -0
- package/dist/client/delivery.js +66 -34
- package/dist/client/delivery.js.map +1 -1
- package/dist/client/rpc-pipeline.d.ts +2 -0
- package/dist/client/rpc-pipeline.js +28 -3
- package/dist/client/rpc-pipeline.js.map +1 -1
- package/dist/client/v2-e2ee.js +5 -1
- package/dist/client/v2-e2ee.js.map +1 -1
- package/dist/client.js +19 -7
- package/dist/client.js.map +1 -1
- package/dist/ownership-v21.d.ts +2 -1
- package/dist/ownership-v21.js +19 -9
- package/dist/ownership-v21.js.map +1 -1
- package/dist/pubsub/channel.js +3 -3
- package/dist/pubsub/channel.js.map +1 -1
- package/dist/pubsub/client.js +3 -4
- package/dist/pubsub/client.js.map +1 -1
- package/dist/pubsub/service.js +1 -1
- package/dist/pubsub/service.js.map +1 -1
- package/dist/tools/cross-sdk-agent.d.ts +1 -1
- package/dist/udp-standby.d.ts +0 -1
- package/dist/udp-standby.js +7 -11
- package/dist/udp-standby.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
|
@@ -1415,25 +1415,30 @@ export class AUNClient {
|
|
|
1415
1415
|
const observation = { root: manager.root, etag: observedEtag, version: Number(record?.observation_version ?? 0), content_hash: typeof record?.content === 'string' ? ownershipSha256(record.content) : '' };
|
|
1416
1416
|
const cache = this._ownershipConsensusCache ??= new Map();
|
|
1417
1417
|
const cached = cache.get(target);
|
|
1418
|
-
if (
|
|
1418
|
+
if (cached?.result.status === 'consensus' && cached.observedVersion === observation.version && record?.remote_status !== 'missing'
|
|
1419
|
+
&& (!record?.remote_owner_md_sha256 || record.remote_owner_md_sha256 === cached.result.owner_md_sha256)
|
|
1419
1420
|
&& (observedEtag === cached.observedEtag || observedEtag === cached.result.agent_md_etag)
|
|
1420
1421
|
&& (typeof record?.content !== 'string' || ownershipSha256(record.content) === cached.result.agent_md_sha256)) {
|
|
1421
1422
|
cached.observedEtag = observedEtag;
|
|
1422
1423
|
return { ...cached.result };
|
|
1423
1424
|
}
|
|
1424
|
-
if (!
|
|
1425
|
+
if (!cached) {
|
|
1425
1426
|
const local = manager.localOwnershipConsensus(target, record);
|
|
1426
1427
|
if (local) {
|
|
1427
|
-
cache.set(target, { observedEtag, result: local });
|
|
1428
|
+
cache.set(target, { observedEtag, observedVersion: observation.version, result: local });
|
|
1428
1429
|
return { ...local };
|
|
1429
1430
|
}
|
|
1430
1431
|
}
|
|
1431
1432
|
cache.delete(target);
|
|
1432
1433
|
const result = { status: 'unavailable', sub_aid: target, owner_aid: null, relation_version: 0, lock: 'unlocked', agent_md_etag: '', agent_md_sha256: '' };
|
|
1433
|
-
const entry = { observedEtag, result: { ...result } };
|
|
1434
|
+
const entry = { observedEtag, observedVersion: observation.version, result: { ...result } };
|
|
1434
1435
|
cache.set(target, entry);
|
|
1436
|
+
let consensusContent;
|
|
1435
1437
|
try {
|
|
1436
1438
|
const snapshot = await manager.readOwnershipFresh(target);
|
|
1439
|
+
consensusContent = snapshot.content;
|
|
1440
|
+
if (snapshot.owner_md_sha256)
|
|
1441
|
+
result.owner_md_sha256 = snapshot.owner_md_sha256;
|
|
1437
1442
|
Object.assign(result, { relation_version: snapshot.relation_version, lock: snapshot.lock, agent_md_etag: snapshot.etag,
|
|
1438
1443
|
agent_md_sha256: snapshot.exists ? ownershipSha256(snapshot.content) : '' });
|
|
1439
1444
|
if (snapshot.ownership_status)
|
|
@@ -1454,11 +1459,15 @@ export class AUNClient {
|
|
|
1454
1459
|
result.retryable = result.status === 'unavailable';
|
|
1455
1460
|
}
|
|
1456
1461
|
if (this._agentMdManager === manager && this._ownershipConsensusCache === cache && cache.get(target) === entry) {
|
|
1457
|
-
entry.result = { ...result };
|
|
1458
1462
|
try {
|
|
1459
|
-
manager.cacheOwnershipSnapshot(target, result, observation)
|
|
1463
|
+
if (manager.cacheOwnershipSnapshot(target, result, observation, consensusContent))
|
|
1464
|
+
entry.result = { ...result };
|
|
1465
|
+
else
|
|
1466
|
+
cache.delete(target);
|
|
1467
|
+
}
|
|
1468
|
+
catch {
|
|
1469
|
+
cache.delete(target);
|
|
1460
1470
|
}
|
|
1461
|
-
catch { }
|
|
1462
1471
|
}
|
|
1463
1472
|
return result;
|
|
1464
1473
|
}
|
|
@@ -2118,6 +2127,7 @@ export class AUNClient {
|
|
|
2118
2127
|
throw ownershipFailure('conflict', 'entity lifecycle ownership action changed');
|
|
2119
2128
|
const ownership = { statement: declaration.statement, action, ...(transfer ? { transfer: { new_owner_aid: ownershipAid(newOwner, 'new_owner_aid'), target_relation_version: declaration.statement.relation_version + 1, expires_at: Number(params.expires_at ?? Math.floor(Date.now() / 1000) + 3600) } } : {}) };
|
|
2120
2129
|
const raw = signOwnershipFile(owner, `---\nowner_aid: ${owner.aid}\nsub_aid: ${target}\nownership: ${JSON.stringify(ownership)}\n---\n`, 'owner');
|
|
2130
|
+
await this._getOwnershipFiles().verifyFile(raw, 'owner', target, owner.aid, true);
|
|
2121
2131
|
await storage.writeOwnerMd(owner.aid, target, raw, original, assertCurrent);
|
|
2122
2132
|
return async (error) => {
|
|
2123
2133
|
if (!(error instanceof AUNError) || error instanceof TimeoutError || error instanceof ConnectionError || error.retryable || isJsonObject(error.data) && error.data.committed === true || ![-32602, 4000, 4030, 403].includes(error.code) && !['INVALID_ARGUMENT', 'ROLE_ACCESS_DENIED', 'MEMBER_NOT_FOUND', 'permission_denied', 'member_banned', 'member_blocked'].includes(error.stringCode))
|
|
@@ -2263,12 +2273,14 @@ export class AUNClient {
|
|
|
2263
2273
|
else {
|
|
2264
2274
|
const payload = `---\nowner_aid: ${owner.aid}\nsub_aid: ${aid}\nownership: ${JSON.stringify({ statement, action: 'declare' })}\n---\n`;
|
|
2265
2275
|
const raw = signOwnershipFile(owner, payload, 'owner');
|
|
2276
|
+
await this._getOwnershipFiles().verifyFile(raw, 'owner', aid, owner.aid, true);
|
|
2266
2277
|
assertCurrent();
|
|
2267
2278
|
await storage.writeOwnerMd(owner.aid, aid, raw, original, assertCurrent);
|
|
2268
2279
|
}
|
|
2269
2280
|
const source = content ?? (observed.exists ? observed.content : buildDefaultAgentMd(aid, { type, name: String(entity.name ?? aid) }));
|
|
2270
2281
|
const updated = updateOwnershipAgentMd(source, { owner: owner.aid, ownership: { statement } }).replace(/^entity_cert_fingerprint:.*(?:\r?\n|$)/m, '');
|
|
2271
2282
|
const signed = signOwnershipFile(local.data.aid, updated, 'agent');
|
|
2283
|
+
await this._getOwnershipFiles().verifyFile(signed, 'agent', aid, undefined, true);
|
|
2272
2284
|
if (content === undefined) {
|
|
2273
2285
|
if (!previous || previous.owner_aid !== owner.aid || previous.relation_version !== version) {
|
|
2274
2286
|
assertCurrent();
|