@antseed/node 0.2.81 → 0.2.83
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/dist/discovery/announcer.d.ts +0 -1
- package/dist/discovery/announcer.d.ts.map +1 -1
- package/dist/discovery/announcer.js +0 -3
- package/dist/discovery/announcer.js.map +1 -1
- package/dist/discovery/index.d.ts +0 -1
- package/dist/discovery/index.d.ts.map +1 -1
- package/dist/discovery/index.js +0 -1
- package/dist/discovery/index.js.map +1 -1
- package/dist/discovery/peer-metadata.d.ts +0 -1
- package/dist/discovery/peer-metadata.d.ts.map +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +12 -1
- package/dist/node.js.map +1 -1
- package/dist/payments/buyer-payment-manager.d.ts +1 -0
- package/dist/payments/buyer-payment-manager.d.ts.map +1 -1
- package/dist/payments/buyer-payment-manager.js +6 -4
- package/dist/payments/buyer-payment-manager.js.map +1 -1
- package/dist/payments/buyer-payment-negotiator.d.ts.map +1 -1
- package/dist/payments/buyer-payment-negotiator.js +10 -2
- package/dist/payments/buyer-payment-negotiator.js.map +1 -1
- package/dist/payments/evm/staking-client.d.ts +1 -0
- package/dist/payments/evm/staking-client.d.ts.map +1 -1
- package/dist/payments/evm/staking-client.js +7 -0
- package/dist/payments/evm/staking-client.js.map +1 -1
- package/dist/reputation/index.d.ts +0 -3
- package/dist/reputation/index.d.ts.map +1 -1
- package/dist/reputation/index.js +0 -2
- package/dist/reputation/index.js.map +1 -1
- package/dist/reputation/on-chain-reputation.d.ts +41 -0
- package/dist/reputation/on-chain-reputation.d.ts.map +1 -0
- package/dist/reputation/on-chain-reputation.js +95 -0
- package/dist/reputation/on-chain-reputation.js.map +1 -0
- package/dist/routing/default-router.d.ts +0 -1
- package/dist/routing/default-router.d.ts.map +1 -1
- package/dist/routing/default-router.js +11 -18
- package/dist/routing/default-router.js.map +1 -1
- package/dist/types/peer.d.ts +20 -2
- package/dist/types/peer.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/discovery/default-metadata-resolver.d.ts +0 -16
- package/dist/discovery/default-metadata-resolver.d.ts.map +0 -1
- package/dist/discovery/default-metadata-resolver.js +0 -16
- package/dist/discovery/default-metadata-resolver.js.map +0 -1
- package/dist/discovery/peer-selector.d.ts +0 -33
- package/dist/discovery/peer-selector.d.ts.map +0 -1
- package/dist/discovery/peer-selector.js +0 -80
- package/dist/discovery/peer-selector.js.map +0 -1
- package/dist/discovery/profile-manager.d.ts +0 -50
- package/dist/discovery/profile-manager.d.ts.map +0 -1
- package/dist/discovery/profile-manager.js +0 -105
- package/dist/discovery/profile-manager.js.map +0 -1
- package/dist/discovery/profile-search.d.ts +0 -27
- package/dist/discovery/profile-search.d.ts.map +0 -1
- package/dist/discovery/profile-search.js +0 -75
- package/dist/discovery/profile-search.js.map +0 -1
- package/dist/discovery/reputation-verifier.d.ts +0 -5
- package/dist/discovery/reputation-verifier.d.ts.map +0 -1
- package/dist/discovery/reputation-verifier.js +0 -5
- package/dist/discovery/reputation-verifier.js.map +0 -1
- package/dist/discovery/stats-verifier.d.ts +0 -27
- package/dist/discovery/stats-verifier.d.ts.map +0 -1
- package/dist/discovery/stats-verifier.js +0 -38
- package/dist/discovery/stats-verifier.js.map +0 -1
- package/dist/p2p/handshake.d.ts +0 -47
- package/dist/p2p/handshake.d.ts.map +0 -1
- package/dist/p2p/handshake.js +0 -107
- package/dist/p2p/handshake.js.map +0 -1
- package/dist/p2p/reconnect.d.ts +0 -48
- package/dist/p2p/reconnect.d.ts.map +0 -1
- package/dist/p2p/reconnect.js +0 -89
- package/dist/p2p/reconnect.js.map +0 -1
- package/dist/payments/disputes.d.ts +0 -18
- package/dist/payments/disputes.d.ts.map +0 -1
- package/dist/payments/disputes.js +0 -47
- package/dist/payments/disputes.js.map +0 -1
- package/dist/payments/evm/escrow-client.d.ts +0 -82
- package/dist/payments/evm/escrow-client.d.ts.map +0 -1
- package/dist/payments/evm/escrow-client.js +0 -277
- package/dist/payments/evm/escrow-client.js.map +0 -1
- package/dist/payments/evm/keypair.d.ts +0 -10
- package/dist/payments/evm/keypair.d.ts.map +0 -1
- package/dist/payments/evm/keypair.js +0 -13
- package/dist/payments/evm/keypair.js.map +0 -1
- package/dist/payments/evm/sessions-client.d.ts +0 -30
- package/dist/payments/evm/sessions-client.d.ts.map +0 -1
- package/dist/payments/evm/sessions-client.js +0 -61
- package/dist/payments/evm/sessions-client.js.map +0 -1
- package/dist/payments/evm/wallet.d.ts +0 -5
- package/dist/payments/evm/wallet.d.ts.map +0 -1
- package/dist/payments/evm/wallet.js +0 -31
- package/dist/payments/evm/wallet.js.map +0 -1
- package/dist/payments/session-store.d.ts +0 -68
- package/dist/payments/session-store.d.ts.map +0 -1
- package/dist/payments/session-store.js +0 -272
- package/dist/payments/session-store.js.map +0 -1
- package/dist/payments/settlement.d.ts +0 -6
- package/dist/payments/settlement.d.ts.map +0 -1
- package/dist/payments/settlement.js +0 -25
- package/dist/payments/settlement.js.map +0 -1
- package/dist/proxy/model-api-adapter.d.ts +0 -30
- package/dist/proxy/model-api-adapter.d.ts.map +0 -1
- package/dist/proxy/model-api-adapter.js +0 -891
- package/dist/proxy/model-api-adapter.js.map +0 -1
- package/dist/reputation/trust-engine.d.ts +0 -36
- package/dist/reputation/trust-engine.d.ts.map +0 -1
- package/dist/reputation/trust-engine.js +0 -95
- package/dist/reputation/trust-engine.js.map +0 -1
- package/dist/reputation/trust-score.d.ts +0 -43
- package/dist/reputation/trust-score.d.ts.map +0 -1
- package/dist/reputation/trust-score.js +0 -34
- package/dist/reputation/trust-score.js.map +0 -1
- package/dist/types/model-api.d.ts +0 -4
- package/dist/types/model-api.d.ts.map +0 -1
- package/dist/types/model-api.js +0 -11
- package/dist/types/model-api.js.map +0 -1
- package/dist/types/peer-profile.d.ts +0 -24
- package/dist/types/peer-profile.d.ts.map +0 -1
- package/dist/types/peer-profile.js +0 -2
- package/dist/types/peer-profile.js.map +0 -1
- package/dist/types/staking.d.ts +0 -16
- package/dist/types/staking.d.ts.map +0 -1
- package/dist/types/staking.js +0 -6
- package/dist/types/staking.js.map +0 -1
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { computeOnChainReputationScore } from '../reputation/on-chain-reputation.js';
|
|
1
2
|
export class DefaultRouter {
|
|
2
3
|
_minReputation;
|
|
3
4
|
_latencyMap = new Map();
|
|
4
5
|
constructor(config) {
|
|
5
|
-
this._minReputation = config?.minReputation ??
|
|
6
|
+
this._minReputation = config?.minReputation ?? 0;
|
|
6
7
|
}
|
|
7
8
|
selectPeer(_req, peers) {
|
|
8
|
-
const eligible = peers.filter((p) =>
|
|
9
|
+
const eligible = peers.filter((p) => this._effectiveReputation(p) >= this._minReputation);
|
|
9
10
|
if (eligible.length === 0)
|
|
10
11
|
return null;
|
|
11
12
|
eligible.sort((a, b) => {
|
|
@@ -13,11 +14,11 @@ export class DefaultRouter {
|
|
|
13
14
|
const priceB = b.defaultInputUsdPerMillion ?? Infinity;
|
|
14
15
|
if (priceA !== priceB)
|
|
15
16
|
return priceA - priceB;
|
|
16
|
-
// Prefer higher
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
20
|
-
return
|
|
17
|
+
// Prefer higher reputation scores (descending)
|
|
18
|
+
const reputationA = this._effectiveReputation(a);
|
|
19
|
+
const reputationB = this._effectiveReputation(b);
|
|
20
|
+
if (reputationA !== reputationB)
|
|
21
|
+
return reputationB - reputationA;
|
|
21
22
|
const latA = this._latencyMap.get(a.peerId) ?? Infinity;
|
|
22
23
|
const latB = this._latencyMap.get(b.peerId) ?? Infinity;
|
|
23
24
|
return latA - latB;
|
|
@@ -31,23 +32,15 @@ export class DefaultRouter {
|
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
_effectiveReputation(peer) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (this._isFiniteNonNegative(peer.trustScore)) {
|
|
38
|
-
return peer.trustScore;
|
|
35
|
+
const onChainScore = computeOnChainReputationScore(peer);
|
|
36
|
+
if (onChainScore != null) {
|
|
37
|
+
return onChainScore;
|
|
39
38
|
}
|
|
40
39
|
if (this._isFiniteNonNegative(peer.reputationScore)) {
|
|
41
40
|
return peer.reputationScore;
|
|
42
41
|
}
|
|
43
42
|
return 0;
|
|
44
43
|
}
|
|
45
|
-
_hasReputation(peer) {
|
|
46
|
-
if (this._isFiniteNonNegative(peer.onChainChannelCount)) {
|
|
47
|
-
return (peer.onChainChannelCount ?? 0) > 0 || (peer.onChainGhostCount ?? 0) > 0;
|
|
48
|
-
}
|
|
49
|
-
return this._isFiniteNonNegative(peer.trustScore) || this._isFiniteNonNegative(peer.reputationScore);
|
|
50
|
-
}
|
|
51
44
|
_isFiniteNonNegative(value) {
|
|
52
45
|
return typeof value === 'number' && Number.isFinite(value) && value >= 0;
|
|
53
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-router.js","sourceRoot":"","sources":["../../src/routing/default-router.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"default-router.js","sourceRoot":"","sources":["../../src/routing/default-router.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,6BAA6B,EAAE,MAAM,sCAAsC,CAAC;AAMrF,MAAM,OAAO,aAAa;IAChB,cAAc,CAAS;IACvB,WAAW,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEhD,YAAY,MAA4B;QACtC,IAAI,CAAC,cAAc,GAAG,MAAM,EAAE,aAAa,IAAI,CAAC,CAAC;IACnD,CAAC;IAED,UAAU,CAAC,IAA2B,EAAE,KAAiB;QACvD,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,cAAc,CAAC,CAAC;QAC1F,IAAI,QAAQ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B,CAAC,IAAc;QACzC,MAAM,YAAY,GAAG,6BAA6B,CAAC,IAAI,CAAC,CAAC;QACzD,IAAI,YAAY,IAAI,IAAI,EAAE,CAAC;YACzB,OAAO,YAAY,CAAC;QACtB,CAAC;QACD,IAAI,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC;YACpD,OAAO,IAAI,CAAC,eAAe,CAAC;QAC9B,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC;IAEO,oBAAoB,CAAC,KAAyB;QACpD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IAC3E,CAAC;CACF"}
|
package/dist/types/peer.d.ts
CHANGED
|
@@ -67,8 +67,21 @@ export interface PeerInfo {
|
|
|
67
67
|
maxConcurrency?: number;
|
|
68
68
|
/** Current number of requests the peer is handling. */
|
|
69
69
|
currentLoad?: number;
|
|
70
|
-
/**
|
|
71
|
-
|
|
70
|
+
/**
|
|
71
|
+
* On-chain ERC-8004 agent ID from `AntseedStaking.getAgentId`.
|
|
72
|
+
* Read by the buyer directly from the chain.
|
|
73
|
+
*/
|
|
74
|
+
onChainAgentId?: number;
|
|
75
|
+
/**
|
|
76
|
+
* On-chain seller stake in micro-USDC from `AntseedStaking.getStake`.
|
|
77
|
+
* Read by the buyer directly from the chain.
|
|
78
|
+
*/
|
|
79
|
+
onChainStakeUsdcMicros?: number;
|
|
80
|
+
/**
|
|
81
|
+
* Buyer-computed on-chain reputation score (0-100), derived from the
|
|
82
|
+
* on-chain stats below and cached for non-routing UI consumers.
|
|
83
|
+
*/
|
|
84
|
+
onChainReputationScore?: number;
|
|
72
85
|
/**
|
|
73
86
|
* On-chain settled channel count from `AntseedChannels.getAgentStats`.
|
|
74
87
|
* Read by the buyer directly from the chain — never trusted from peer metadata.
|
|
@@ -90,6 +103,11 @@ export interface PeerInfo {
|
|
|
90
103
|
* from `AntseedChannels.getAgentStats.lastSettledAt`. Read by the buyer from chain.
|
|
91
104
|
*/
|
|
92
105
|
onChainLastSettledAtSec?: number;
|
|
106
|
+
/**
|
|
107
|
+
* Unix seconds when the seller first staked in `AntseedStaking.sellers`.
|
|
108
|
+
* Read by the buyer from chain and used as a small maturity signal.
|
|
109
|
+
*/
|
|
110
|
+
onChainStakedAtSec?: number;
|
|
93
111
|
/**
|
|
94
112
|
* Unix ms when the buyer last refreshed on-chain stats for this peer.
|
|
95
113
|
* Used to throttle repeat `getAgentStats` calls across discovery cycles.
|
package/dist/types/peer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"peer.d.ts","sourceRoot":"","sources":["../../src/types/peer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAElE;;;;GAIG;AACH,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAA;CAAE,CAAC;AAE7D;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK5C;AAED,iEAAiE;AACjE,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,MAAM,WAAW,yBAAyB;IACxC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,EAAE,yBAAyB,CAAC;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;CACtD;AAED,MAAM,WAAW,kCAAkC;IACjD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CACp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AAM,CAAC,MAAM,EAAE,kCAAkC,CAAC,CAAC;IAC/E,0DAA0D;IAC1D,2BAA2B,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,qCAAqC,CAAC,CAAC;IACpF,sEAAsE;IACtE,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,uEAAuE;IACvE,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,6EAA6E;IAC7E,+BAA+B,CAAC,EAAE,MAAM,CAAC;IACzC,uDAAuD;IACvD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,uDAAuD;IACvD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC;;;OAGG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;OAIG;IACH,4BAA4B,CAAC,EAAE,MAAM,CAAC;IACtC;;;OAGG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,wEAAwE;IACxE,QAAQ,CAAC,EAAE,YAAY,CAAC;CACzB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antseed/node",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.83",
|
|
4
4
|
"description": "Antseed Network protocol SDK — P2P inference marketplace",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"ethers": "~6.16.0",
|
|
46
46
|
"node-datachannel": "^0.7.0",
|
|
47
47
|
"tokenx": "^1.3.0",
|
|
48
|
-
"@antseed/api-adapter": "0.1.
|
|
48
|
+
"@antseed/api-adapter": "0.1.38"
|
|
49
49
|
},
|
|
50
50
|
"optionalDependencies": {
|
|
51
51
|
"keytar": "^7.9.0"
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { PeerEndpoint, MetadataResolver } from "./metadata-resolver.js";
|
|
2
|
-
import type { PeerMetadata } from "./peer-metadata.js";
|
|
3
|
-
/**
|
|
4
|
-
* Default fail-closed metadata resolver.
|
|
5
|
-
*
|
|
6
|
-
* Always returns `null`, meaning no peer metadata can be resolved.
|
|
7
|
-
* This is intentional: without a real transport-specific resolver wired in,
|
|
8
|
-
* no peers will pass the metadata resolution step and lookups will
|
|
9
|
-
* return an empty list. Callers must supply a concrete `MetadataResolver`
|
|
10
|
-
* implementation (e.g. one that fetches metadata over HTTP or a P2P channel)
|
|
11
|
-
* to discover real peers.
|
|
12
|
-
*/
|
|
13
|
-
export declare class DefaultMetadataResolver implements MetadataResolver {
|
|
14
|
-
resolve(_peer: PeerEndpoint): Promise<PeerMetadata | null>;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=default-metadata-resolver.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"default-metadata-resolver.d.ts","sourceRoot":"","sources":["../../src/discovery/default-metadata-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD;;;;;;;;;GASG;AACH,qBAAa,uBAAwB,YAAW,gBAAgB;IACxD,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;CAGjE"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Default fail-closed metadata resolver.
|
|
3
|
-
*
|
|
4
|
-
* Always returns `null`, meaning no peer metadata can be resolved.
|
|
5
|
-
* This is intentional: without a real transport-specific resolver wired in,
|
|
6
|
-
* no peers will pass the metadata resolution step and lookups will
|
|
7
|
-
* return an empty list. Callers must supply a concrete `MetadataResolver`
|
|
8
|
-
* implementation (e.g. one that fetches metadata over HTTP or a P2P channel)
|
|
9
|
-
* to discover real peers.
|
|
10
|
-
*/
|
|
11
|
-
export class DefaultMetadataResolver {
|
|
12
|
-
async resolve(_peer) {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=default-metadata-resolver.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"default-metadata-resolver.js","sourceRoot":"","sources":["../../src/discovery/default-metadata-resolver.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,MAAM,OAAO,uBAAuB;IAClC,KAAK,CAAC,OAAO,CAAC,KAAmB;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
export interface ScoringWeights {
|
|
2
|
-
price: number;
|
|
3
|
-
capacity: number;
|
|
4
|
-
latency: number;
|
|
5
|
-
reputation: number;
|
|
6
|
-
}
|
|
7
|
-
export declare const DEFAULT_SCORING_WEIGHTS: ScoringWeights;
|
|
8
|
-
export interface PeerCandidate {
|
|
9
|
-
peerId: string;
|
|
10
|
-
region: string;
|
|
11
|
-
inputUsdPerMillion: number;
|
|
12
|
-
maxConcurrency: number;
|
|
13
|
-
currentLoad: number;
|
|
14
|
-
latencyMs: number;
|
|
15
|
-
reputation: number;
|
|
16
|
-
}
|
|
17
|
-
export interface ScoredPeer {
|
|
18
|
-
candidate: PeerCandidate;
|
|
19
|
-
score: number;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Score a single peer candidate.
|
|
23
|
-
*
|
|
24
|
-
* - priceScore: cheapestInputPrice / candidate.inputUsdPerMillion (capped at 1.0)
|
|
25
|
-
* - capacityScore: (maxConcurrency - currentLoad) / maxConcurrency
|
|
26
|
-
* - latencyScore: 1 - (latencyMs / 15000), clamped to [0, 1]
|
|
27
|
-
* - reputationScore: candidate.reputation (expected 0..1)
|
|
28
|
-
*/
|
|
29
|
-
export declare function scorePeer(candidate: PeerCandidate, cheapestInputPrice: number, weights?: ScoringWeights): number;
|
|
30
|
-
export declare function rankPeers(candidates: PeerCandidate[], weights?: ScoringWeights): ScoredPeer[];
|
|
31
|
-
export declare function selectBestPeer(candidates: PeerCandidate[], weights?: ScoringWeights): ScoredPeer | null;
|
|
32
|
-
export declare function selectDiversePeers(candidates: PeerCandidate[], count: number, weights?: ScoringWeights): ScoredPeer[];
|
|
33
|
-
//# sourceMappingURL=peer-selector.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"peer-selector.d.ts","sourceRoot":"","sources":["../../src/discovery/peer-selector.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,uBAAuB,EAAE,cAKrC,CAAC;AAEF,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,EAAE,MAAM,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,aAAa,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CACvB,SAAS,EAAE,aAAa,EACxB,kBAAkB,EAAE,MAAM,EAC1B,OAAO,GAAE,cAAwC,GAChD,MAAM,CA2BR;AAED,wBAAgB,SAAS,CACvB,UAAU,EAAE,aAAa,EAAE,EAC3B,OAAO,GAAE,cAAwC,GAChD,UAAU,EAAE,CAmBd;AAED,wBAAgB,cAAc,CAC5B,UAAU,EAAE,aAAa,EAAE,EAC3B,OAAO,GAAE,cAAwC,GAChD,UAAU,GAAG,IAAI,CAGnB;AAED,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,aAAa,EAAE,EAC3B,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,cAAwC,GAChD,UAAU,EAAE,CA2Bd"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
export const DEFAULT_SCORING_WEIGHTS = {
|
|
2
|
-
price: 0.35,
|
|
3
|
-
capacity: 0.25,
|
|
4
|
-
latency: 0.25,
|
|
5
|
-
reputation: 0.15,
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* Score a single peer candidate.
|
|
9
|
-
*
|
|
10
|
-
* - priceScore: cheapestInputPrice / candidate.inputUsdPerMillion (capped at 1.0)
|
|
11
|
-
* - capacityScore: (maxConcurrency - currentLoad) / maxConcurrency
|
|
12
|
-
* - latencyScore: 1 - (latencyMs / 15000), clamped to [0, 1]
|
|
13
|
-
* - reputationScore: candidate.reputation (expected 0..1)
|
|
14
|
-
*/
|
|
15
|
-
export function scorePeer(candidate, cheapestInputPrice, weights = DEFAULT_SCORING_WEIGHTS) {
|
|
16
|
-
// Price score
|
|
17
|
-
const priceScore = candidate.inputUsdPerMillion > 0
|
|
18
|
-
? Math.min(cheapestInputPrice / candidate.inputUsdPerMillion, 1.0)
|
|
19
|
-
: 1.0;
|
|
20
|
-
// Capacity score
|
|
21
|
-
const capacityScore = candidate.maxConcurrency > 0
|
|
22
|
-
? (candidate.maxConcurrency - candidate.currentLoad) /
|
|
23
|
-
candidate.maxConcurrency
|
|
24
|
-
: 0;
|
|
25
|
-
// Latency score
|
|
26
|
-
const latencyScore = Math.max(0, Math.min(1, 1 - candidate.latencyMs / 15000));
|
|
27
|
-
// Reputation score
|
|
28
|
-
const reputationScore = Math.max(0, Math.min(1, candidate.reputation));
|
|
29
|
-
const score = weights.price * priceScore +
|
|
30
|
-
weights.capacity * capacityScore +
|
|
31
|
-
weights.latency * latencyScore +
|
|
32
|
-
weights.reputation * reputationScore;
|
|
33
|
-
return Math.max(0, Math.min(1, score));
|
|
34
|
-
}
|
|
35
|
-
export function rankPeers(candidates, weights = DEFAULT_SCORING_WEIGHTS) {
|
|
36
|
-
if (candidates.length === 0) {
|
|
37
|
-
return [];
|
|
38
|
-
}
|
|
39
|
-
const cheapestInputPrice = Math.min(...candidates.map((c) => c.inputUsdPerMillion).filter((p) => p > 0));
|
|
40
|
-
const effectiveCheapest = Number.isFinite(cheapestInputPrice)
|
|
41
|
-
? cheapestInputPrice
|
|
42
|
-
: 0;
|
|
43
|
-
const scored = candidates.map((candidate) => ({
|
|
44
|
-
candidate,
|
|
45
|
-
score: scorePeer(candidate, effectiveCheapest, weights),
|
|
46
|
-
}));
|
|
47
|
-
scored.sort((a, b) => b.score - a.score);
|
|
48
|
-
return scored;
|
|
49
|
-
}
|
|
50
|
-
export function selectBestPeer(candidates, weights = DEFAULT_SCORING_WEIGHTS) {
|
|
51
|
-
const ranked = rankPeers(candidates, weights);
|
|
52
|
-
return ranked[0] ?? null;
|
|
53
|
-
}
|
|
54
|
-
export function selectDiversePeers(candidates, count, weights = DEFAULT_SCORING_WEIGHTS) {
|
|
55
|
-
const ranked = rankPeers(candidates, weights);
|
|
56
|
-
if (ranked.length <= count) {
|
|
57
|
-
return ranked;
|
|
58
|
-
}
|
|
59
|
-
const selected = [];
|
|
60
|
-
const seenRegions = new Set();
|
|
61
|
-
// First pass: pick the best from each unique region
|
|
62
|
-
for (const peer of ranked) {
|
|
63
|
-
if (selected.length >= count)
|
|
64
|
-
break;
|
|
65
|
-
if (!seenRegions.has(peer.candidate.region)) {
|
|
66
|
-
seenRegions.add(peer.candidate.region);
|
|
67
|
-
selected.push(peer);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
// Second pass: fill remaining slots by score
|
|
71
|
-
for (const peer of ranked) {
|
|
72
|
-
if (selected.length >= count)
|
|
73
|
-
break;
|
|
74
|
-
if (!selected.includes(peer)) {
|
|
75
|
-
selected.push(peer);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return selected;
|
|
79
|
-
}
|
|
80
|
-
//# sourceMappingURL=peer-selector.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"peer-selector.js","sourceRoot":"","sources":["../../src/discovery/peer-selector.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,uBAAuB,GAAmB;IACrD,KAAK,EAAE,IAAI;IACX,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE,IAAI;IACb,UAAU,EAAE,IAAI;CACjB,CAAC;AAiBF;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS,CACvB,SAAwB,EACxB,kBAA0B,EAC1B,UAA0B,uBAAuB;IAEjD,cAAc;IACd,MAAM,UAAU,GACd,SAAS,CAAC,kBAAkB,GAAG,CAAC;QAC9B,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,kBAAkB,GAAG,SAAS,CAAC,kBAAkB,EAAE,GAAG,CAAC;QAClE,CAAC,CAAC,GAAG,CAAC;IAEV,iBAAiB;IACjB,MAAM,aAAa,GACjB,SAAS,CAAC,cAAc,GAAG,CAAC;QAC1B,CAAC,CAAC,CAAC,SAAS,CAAC,cAAc,GAAG,SAAS,CAAC,WAAW,CAAC;YAClD,SAAS,CAAC,cAAc;QAC1B,CAAC,CAAC,CAAC,CAAC;IAER,gBAAgB;IAChB,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC;IAE/E,mBAAmB;IACnB,MAAM,eAAe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
import type { PeerProfile, ProfileCapability } from '../types/peer-profile.js';
|
|
2
|
-
import type { Identity } from '../p2p/identity.js';
|
|
3
|
-
export interface ProfileManagerConfig {
|
|
4
|
-
configDir: string;
|
|
5
|
-
identity?: Identity;
|
|
6
|
-
}
|
|
7
|
-
export declare class ProfileManager {
|
|
8
|
-
private readonly configDir;
|
|
9
|
-
private readonly identity;
|
|
10
|
-
private profile;
|
|
11
|
-
constructor(config: ProfileManagerConfig);
|
|
12
|
-
/**
|
|
13
|
-
* Create a new peer profile.
|
|
14
|
-
*/
|
|
15
|
-
createProfile(data: {
|
|
16
|
-
displayName: string;
|
|
17
|
-
description: string;
|
|
18
|
-
tags?: string[];
|
|
19
|
-
capabilities?: ProfileCapability[];
|
|
20
|
-
region?: string;
|
|
21
|
-
languages?: string[];
|
|
22
|
-
website?: string;
|
|
23
|
-
avatar?: string;
|
|
24
|
-
}): PeerProfile;
|
|
25
|
-
/**
|
|
26
|
-
* Update an existing profile.
|
|
27
|
-
*/
|
|
28
|
-
updateProfile(updates: Partial<Omit<PeerProfile, 'peerId' | 'createdAt'>>): PeerProfile;
|
|
29
|
-
/**
|
|
30
|
-
* Get the current profile.
|
|
31
|
-
*/
|
|
32
|
-
getProfile(): PeerProfile | null;
|
|
33
|
-
/**
|
|
34
|
-
* Get SHA-256 hash of the profile for metadata announcements.
|
|
35
|
-
*/
|
|
36
|
-
getProfileHash(): string;
|
|
37
|
-
/**
|
|
38
|
-
* Sign the profile hash with the identity's private key.
|
|
39
|
-
*/
|
|
40
|
-
getProfileSignature(): Promise<string>;
|
|
41
|
-
/**
|
|
42
|
-
* Save profile to disk.
|
|
43
|
-
*/
|
|
44
|
-
save(): Promise<void>;
|
|
45
|
-
/**
|
|
46
|
-
* Load profile from disk.
|
|
47
|
-
*/
|
|
48
|
-
load(): Promise<void>;
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=profile-manager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file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@@
|
|
|
1
|
-
import { readFile, writeFile, mkdir } from 'node:fs/promises';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import { createHash } from 'node:crypto';
|
|
4
|
-
import { signData } from '../p2p/identity.js';
|
|
5
|
-
import { bytesToHex } from '../utils/hex.js';
|
|
6
|
-
export class ProfileManager {
|
|
7
|
-
configDir;
|
|
8
|
-
identity;
|
|
9
|
-
profile = null;
|
|
10
|
-
constructor(config) {
|
|
11
|
-
this.configDir = config.configDir;
|
|
12
|
-
this.identity = config.identity;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Create a new peer profile.
|
|
16
|
-
*/
|
|
17
|
-
createProfile(data) {
|
|
18
|
-
if (!this.identity) {
|
|
19
|
-
throw new Error('Identity required to create profile');
|
|
20
|
-
}
|
|
21
|
-
const now = Date.now();
|
|
22
|
-
this.profile = {
|
|
23
|
-
peerId: this.identity.peerId,
|
|
24
|
-
displayName: data.displayName,
|
|
25
|
-
description: data.description,
|
|
26
|
-
tags: data.tags ?? [],
|
|
27
|
-
capabilities: data.capabilities ?? ['inference'],
|
|
28
|
-
region: data.region ?? 'unknown',
|
|
29
|
-
languages: data.languages ?? ['en'],
|
|
30
|
-
website: data.website,
|
|
31
|
-
avatar: data.avatar,
|
|
32
|
-
createdAt: now,
|
|
33
|
-
updatedAt: now,
|
|
34
|
-
};
|
|
35
|
-
return this.profile;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Update an existing profile.
|
|
39
|
-
*/
|
|
40
|
-
updateProfile(updates) {
|
|
41
|
-
if (!this.profile) {
|
|
42
|
-
throw new Error('No profile exists — call createProfile first');
|
|
43
|
-
}
|
|
44
|
-
this.profile = {
|
|
45
|
-
...this.profile,
|
|
46
|
-
...updates,
|
|
47
|
-
peerId: this.profile.peerId, // immutable
|
|
48
|
-
createdAt: this.profile.createdAt, // immutable
|
|
49
|
-
updatedAt: Date.now(),
|
|
50
|
-
};
|
|
51
|
-
return this.profile;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Get the current profile.
|
|
55
|
-
*/
|
|
56
|
-
getProfile() {
|
|
57
|
-
return this.profile;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Get SHA-256 hash of the profile for metadata announcements.
|
|
61
|
-
*/
|
|
62
|
-
getProfileHash() {
|
|
63
|
-
if (!this.profile)
|
|
64
|
-
return '';
|
|
65
|
-
const json = JSON.stringify(this.profile);
|
|
66
|
-
return createHash('sha256').update(json).digest('hex');
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Sign the profile hash with the identity's private key.
|
|
70
|
-
*/
|
|
71
|
-
async getProfileSignature() {
|
|
72
|
-
if (!this.identity || !this.profile) {
|
|
73
|
-
throw new Error('Identity and profile required for signing');
|
|
74
|
-
}
|
|
75
|
-
const hash = this.getProfileHash();
|
|
76
|
-
const hashBytes = new TextEncoder().encode(hash);
|
|
77
|
-
const signature = await signData(this.identity.privateKey, hashBytes);
|
|
78
|
-
return bytesToHex(signature);
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Save profile to disk.
|
|
82
|
-
*/
|
|
83
|
-
async save() {
|
|
84
|
-
if (!this.profile)
|
|
85
|
-
return;
|
|
86
|
-
await mkdir(this.configDir, { recursive: true });
|
|
87
|
-
const filePath = join(this.configDir, 'profile.json');
|
|
88
|
-
await writeFile(filePath, JSON.stringify(this.profile, null, 2), 'utf-8');
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Load profile from disk.
|
|
92
|
-
*/
|
|
93
|
-
async load() {
|
|
94
|
-
const filePath = join(this.configDir, 'profile.json');
|
|
95
|
-
try {
|
|
96
|
-
const raw = await readFile(filePath, 'utf-8');
|
|
97
|
-
this.profile = JSON.parse(raw);
|
|
98
|
-
}
|
|
99
|
-
catch {
|
|
100
|
-
// File doesn't exist — no profile yet
|
|
101
|
-
this.profile = null;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
//# sourceMappingURL=profile-manager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"profile-manager.js","sourceRoot":"","sources":["../../src/discovery/profile-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIzC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAO7C,MAAM,OAAO,cAAc;IACR,SAAS,CAAS;IAClB,QAAQ,CAAuB;IACxC,OAAO,GAAuB,IAAI,CAAC;IAE3C,YAAY,MAA4B;QACtC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;QAClC,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,aAAa,CAAC,IASb;QACC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACzD,CAAC;QAED,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG;YACb,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAgB;YACtC,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,EAAE;YACrB,YAAY,EAAE,IAAI,CAAC,YAAY,IAAI,CAAC,WAAW,CAAC;YAChD,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,SAAS;YAChC,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC;YAC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WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACjD,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QACtE,OAAO,UAAU,CAAC,SAAS,CAAC,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI;QACR,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,OAAO;QAC1B,MAAM,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACjD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;QACtD,MAAM,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IAC5E,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI;QACR,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;QACtD,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YAC9C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAgB,CAAC;QAChD,CAAC;QAAC,MAAM,CAAC;YACP,sCAAsC;YACtC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACtB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { PeerProfile, ProfileCapability } from '../types/peer-profile.js';
|
|
2
|
-
export interface ProfileSearchQuery {
|
|
3
|
-
capability?: ProfileCapability;
|
|
4
|
-
tags?: string[];
|
|
5
|
-
region?: string;
|
|
6
|
-
text?: string;
|
|
7
|
-
}
|
|
8
|
-
export interface ProfileSearchResult {
|
|
9
|
-
profile: PeerProfile;
|
|
10
|
-
relevanceScore: number;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* In-memory search index for cached peer profiles.
|
|
14
|
-
*/
|
|
15
|
-
export declare class ProfileSearchIndex {
|
|
16
|
-
private profiles;
|
|
17
|
-
addProfile(profile: PeerProfile): void;
|
|
18
|
-
removeProfile(peerId: string): void;
|
|
19
|
-
getProfile(peerId: string): PeerProfile | null;
|
|
20
|
-
getAllProfiles(): PeerProfile[];
|
|
21
|
-
/**
|
|
22
|
-
* Search profiles with relevance scoring.
|
|
23
|
-
*/
|
|
24
|
-
search(query: ProfileSearchQuery): ProfileSearchResult[];
|
|
25
|
-
get size(): number;
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=profile-search.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"profile-search.d.ts","sourceRoot":"","sources":["../../src/discovery/profile-search.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE/E,MAAM,WAAW,kBAAkB;IACjC,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,WAAW,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAuC;IAEvD,UAAU,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IAItC,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAInC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI;IAI9C,cAAc,IAAI,WAAW,EAAE;IAI/B;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,kBAAkB,GAAG,mBAAmB,EAAE;IAyDxD,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF"}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* In-memory search index for cached peer profiles.
|
|
3
|
-
*/
|
|
4
|
-
export class ProfileSearchIndex {
|
|
5
|
-
profiles = new Map();
|
|
6
|
-
addProfile(profile) {
|
|
7
|
-
this.profiles.set(profile.peerId, profile);
|
|
8
|
-
}
|
|
9
|
-
removeProfile(peerId) {
|
|
10
|
-
this.profiles.delete(peerId);
|
|
11
|
-
}
|
|
12
|
-
getProfile(peerId) {
|
|
13
|
-
return this.profiles.get(peerId) ?? null;
|
|
14
|
-
}
|
|
15
|
-
getAllProfiles() {
|
|
16
|
-
return Array.from(this.profiles.values());
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Search profiles with relevance scoring.
|
|
20
|
-
*/
|
|
21
|
-
search(query) {
|
|
22
|
-
const results = [];
|
|
23
|
-
for (const profile of this.profiles.values()) {
|
|
24
|
-
let score = 0;
|
|
25
|
-
// Filter by capability (hard filter)
|
|
26
|
-
if (query.capability) {
|
|
27
|
-
if (!profile.capabilities.includes(query.capability))
|
|
28
|
-
continue;
|
|
29
|
-
score += 10;
|
|
30
|
-
}
|
|
31
|
-
// Filter by region (boost score)
|
|
32
|
-
if (query.region) {
|
|
33
|
-
if (profile.region.toLowerCase() === query.region.toLowerCase()) {
|
|
34
|
-
score += 5;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
// Tag matching (boost score)
|
|
38
|
-
if (query.tags && query.tags.length > 0) {
|
|
39
|
-
const profileTags = new Set(profile.tags.map(t => t.toLowerCase()));
|
|
40
|
-
let tagMatches = 0;
|
|
41
|
-
for (const tag of query.tags) {
|
|
42
|
-
if (profileTags.has(tag.toLowerCase())) {
|
|
43
|
-
tagMatches++;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
if (tagMatches > 0) {
|
|
47
|
-
score += tagMatches * 3;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
// Text search in name and description
|
|
51
|
-
if (query.text) {
|
|
52
|
-
const text = query.text.toLowerCase();
|
|
53
|
-
if (profile.displayName.toLowerCase().includes(text)) {
|
|
54
|
-
score += 8;
|
|
55
|
-
}
|
|
56
|
-
if (profile.description.toLowerCase().includes(text)) {
|
|
57
|
-
score += 4;
|
|
58
|
-
}
|
|
59
|
-
if (profile.tags.some(t => t.toLowerCase().includes(text))) {
|
|
60
|
-
score += 2;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if (score > 0) {
|
|
64
|
-
results.push({ profile, relevanceScore: score });
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
// Sort by relevance (descending)
|
|
68
|
-
results.sort((a, b) => b.relevanceScore - a.relevanceScore);
|
|
69
|
-
return results;
|
|
70
|
-
}
|
|
71
|
-
get size() {
|
|
72
|
-
return this.profiles.size;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
//# sourceMappingURL=profile-search.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"profile-search.js","sourceRoot":"","sources":["../../src/discovery/profile-search.ts"],"names":[],"mappings":"AAcA;;GAEG;AACH,MAAM,OAAO,kBAAkB;IACrB,QAAQ,GAA6B,IAAI,GAAG,EAAE,CAAC;IAEvD,UAAU,CAAC,OAAoB;QAC7B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC;IAED,aAAa,CAAC,MAAc;QAC1B,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;IAED,UAAU,CAAC,MAAc;QACvB,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC;IAC3C,CAAC;IAED,cAAc;QACZ,OAAO,KA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AG,CAAC,CAAC;gBAC1B,CAAC;YACH,CAAC;YAED,sCAAsC;YACtC,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;gBACf,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;gBACtC,IAAI,OAAO,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;oBACrD,KAAK,IAAI,CAAC,CAAC;gBACb,CAAC;gBACD,IAAI,OAAO,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;oBACrD,KAAK,IAAI,CAAC,CAAC;gBACb,CAAC;gBACD,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;oBAC3D,KAAK,IAAI,CAAC,CAAC;gBACb,CAAC;YACH,CAAC;YAED,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;gBACd,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;QAED,iCAAiC;QACjC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,GAAG,CAAC,CAAC,cAAc,CAAC,CAAC;QAC5D,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;IAC5B,CAAC;CACF"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated Use stats-verifier.ts instead. This module is kept for backward compatibility.
|
|
3
|
-
*/
|
|
4
|
-
export { verifyStats as verifyReputation, type StatsVerification as ReputationVerification } from './stats-verifier.js';
|
|
5
|
-
//# sourceMappingURL=reputation-verifier.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reputation-verifier.d.ts","sourceRoot":"","sources":["../../src/discovery/reputation-verifier.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,WAAW,IAAI,gBAAgB,EAAE,KAAK,iBAAiB,IAAI,sBAAsB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reputation-verifier.js","sourceRoot":"","sources":["../../src/discovery/reputation-verifier.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,WAAW,IAAI,gBAAgB,EAAoD,MAAM,qBAAqB,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { PeerMetadata } from "./peer-metadata.js";
|
|
2
|
-
import type { StatsClient } from "../payments/evm/stats-client.js";
|
|
3
|
-
import type { StakingClient } from "../payments/evm/staking-client.js";
|
|
4
|
-
export interface StatsVerification {
|
|
5
|
-
/** Whether the claimed stats match on-chain data. */
|
|
6
|
-
valid: boolean;
|
|
7
|
-
/** The actual on-chain reputation score (channel count). */
|
|
8
|
-
actualReputation: number;
|
|
9
|
-
/** The actual on-chain channel count. */
|
|
10
|
-
actualChannelCount: number;
|
|
11
|
-
/** The actual on-chain ghost/dispute count. */
|
|
12
|
-
actualDisputeCount: number;
|
|
13
|
-
/** The claimed on-chain reputation score from metadata. */
|
|
14
|
-
claimedReputation?: number;
|
|
15
|
-
/** The claimed on-chain channel count from metadata. */
|
|
16
|
-
claimedChannelCount?: number;
|
|
17
|
-
/** The claimed on-chain dispute count from metadata. */
|
|
18
|
-
claimedDisputeCount?: number;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Verify a peer's claimed on-chain stats against the AntseedStats contract.
|
|
22
|
-
* Uses the staking client to look up the agentId from the peer's EVM address
|
|
23
|
-
* (derived from peerId), then fetches stats from the StatsClient and compares
|
|
24
|
-
* claimed vs actual.
|
|
25
|
-
*/
|
|
26
|
-
export declare function verifyStats(statsClient: StatsClient, stakingClient: StakingClient, metadata: PeerMetadata): Promise<StatsVerification>;
|
|
27
|
-
//# sourceMappingURL=stats-verifier.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stats-verifier.d.ts","sourceRoot":"","sources":["../../src/discovery/stats-verifier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAGvE,MAAM,WAAW,iBAAiB;IAChC,qDAAqD;IACrD,KAAK,EAAE,OAAO,CAAC;IACf,4DAA4D;IAC5D,gBAAgB,EAAE,MAAM,CAAC;IACzB,yCAAyC;IACzC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,+CAA+C;IAC/C,kBAAkB,EAAE,MAAM,CAAC;IAC3B,2DAA2D;IAC3D,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,wDAAwD;IACxD,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,wDAAwD;IACxD,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAC/B,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAC5B,QAAQ,EAAE,YAAY,GACrB,OAAO,CAAC,iBAAiB,CAAC,CAiC5B"}
|