@antseed/cli 0.1.157 → 0.1.159
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/README.md +158 -6
- package/dist/cli/commands/ants/addresses.d.ts +3 -0
- package/dist/cli/commands/ants/addresses.d.ts.map +1 -0
- package/dist/cli/commands/ants/addresses.js +20 -0
- package/dist/cli/commands/ants/addresses.js.map +1 -0
- package/dist/cli/commands/ants/addresses.test.d.ts +2 -0
- package/dist/cli/commands/ants/addresses.test.d.ts.map +1 -0
- package/dist/cli/commands/ants/addresses.test.js +12 -0
- package/dist/cli/commands/ants/addresses.test.js.map +1 -0
- package/dist/cli/commands/ants/arguments.test.d.ts +2 -0
- package/dist/cli/commands/ants/arguments.test.d.ts.map +1 -0
- package/dist/cli/commands/ants/arguments.test.js +51 -0
- package/dist/cli/commands/ants/arguments.test.js.map +1 -0
- package/dist/cli/commands/ants/dashboard.d.ts +4 -0
- package/dist/cli/commands/ants/dashboard.d.ts.map +1 -0
- package/dist/cli/commands/ants/dashboard.js +45 -0
- package/dist/cli/commands/ants/dashboard.js.map +1 -0
- package/dist/cli/commands/ants/dashboard.test.d.ts +2 -0
- package/dist/cli/commands/ants/dashboard.test.d.ts.map +1 -0
- package/dist/cli/commands/ants/dashboard.test.js +14 -0
- package/dist/cli/commands/ants/dashboard.test.js.map +1 -0
- package/dist/cli/commands/ants/emissions.d.ts +5 -0
- package/dist/cli/commands/ants/emissions.d.ts.map +1 -0
- package/dist/cli/commands/ants/emissions.js +44 -0
- package/dist/cli/commands/ants/emissions.js.map +1 -0
- package/dist/cli/commands/ants/emissions.test.d.ts +2 -0
- package/dist/cli/commands/ants/emissions.test.d.ts.map +1 -0
- package/dist/cli/commands/ants/emissions.test.js +17 -0
- package/dist/cli/commands/ants/emissions.test.js.map +1 -0
- package/dist/cli/commands/ants/extend.d.ts +3 -0
- package/dist/cli/commands/ants/extend.d.ts.map +1 -0
- package/dist/cli/commands/ants/extend.js +14 -0
- package/dist/cli/commands/ants/extend.js.map +1 -0
- package/dist/cli/commands/ants/extend.test.d.ts +2 -0
- package/dist/cli/commands/ants/extend.test.d.ts.map +1 -0
- package/dist/cli/commands/ants/extend.test.js +13 -0
- package/dist/cli/commands/ants/extend.test.js.map +1 -0
- package/dist/cli/commands/ants/index.d.ts +7 -0
- package/dist/cli/commands/ants/index.d.ts.map +1 -0
- package/dist/cli/commands/ants/index.js +46 -0
- package/dist/cli/commands/ants/index.js.map +1 -0
- package/dist/cli/commands/ants/index.test.d.ts +2 -0
- package/dist/cli/commands/ants/index.test.d.ts.map +1 -0
- package/dist/cli/commands/ants/index.test.js +24 -0
- package/dist/cli/commands/ants/index.test.js.map +1 -0
- package/dist/cli/commands/ants/max-lock.d.ts +3 -0
- package/dist/cli/commands/ants/max-lock.d.ts.map +1 -0
- package/dist/cli/commands/ants/max-lock.js +13 -0
- package/dist/cli/commands/ants/max-lock.js.map +1 -0
- package/dist/cli/commands/ants/max-lock.test.d.ts +2 -0
- package/dist/cli/commands/ants/max-lock.test.d.ts.map +1 -0
- package/dist/cli/commands/ants/max-lock.test.js +15 -0
- package/dist/cli/commands/ants/max-lock.test.js.map +1 -0
- package/dist/cli/commands/ants/merge.d.ts +3 -0
- package/dist/cli/commands/ants/merge.d.ts.map +1 -0
- package/dist/cli/commands/ants/merge.js +12 -0
- package/dist/cli/commands/ants/merge.js.map +1 -0
- package/dist/cli/commands/ants/merge.test.d.ts +2 -0
- package/dist/cli/commands/ants/merge.test.d.ts.map +1 -0
- package/dist/cli/commands/ants/merge.test.js +16 -0
- package/dist/cli/commands/ants/merge.test.js.map +1 -0
- package/dist/cli/commands/ants/move.d.ts +3 -0
- package/dist/cli/commands/ants/move.d.ts.map +1 -0
- package/dist/cli/commands/ants/move.js +14 -0
- package/dist/cli/commands/ants/move.js.map +1 -0
- package/dist/cli/commands/ants/move.test.d.ts +2 -0
- package/dist/cli/commands/ants/move.test.d.ts.map +1 -0
- package/dist/cli/commands/ants/move.test.js +16 -0
- package/dist/cli/commands/ants/move.test.js.map +1 -0
- package/dist/cli/commands/ants/pool.d.ts +3 -0
- package/dist/cli/commands/ants/pool.d.ts.map +1 -0
- package/dist/cli/commands/ants/pool.js +21 -0
- package/dist/cli/commands/ants/pool.js.map +1 -0
- package/dist/cli/commands/ants/pool.test.d.ts +2 -0
- package/dist/cli/commands/ants/pool.test.d.ts.map +1 -0
- package/dist/cli/commands/ants/pool.test.js +13 -0
- package/dist/cli/commands/ants/pool.test.js.map +1 -0
- package/dist/cli/commands/ants/pools.d.ts +6 -0
- package/dist/cli/commands/ants/pools.d.ts.map +1 -0
- package/dist/cli/commands/ants/pools.js +50 -0
- package/dist/cli/commands/ants/pools.js.map +1 -0
- package/dist/cli/commands/ants/pools.test.d.ts +2 -0
- package/dist/cli/commands/ants/pools.test.d.ts.map +1 -0
- package/dist/cli/commands/ants/pools.test.js +18 -0
- package/dist/cli/commands/ants/pools.test.js.map +1 -0
- package/dist/cli/commands/ants/positions.d.ts +6 -0
- package/dist/cli/commands/ants/positions.d.ts.map +1 -0
- package/dist/cli/commands/ants/positions.js +46 -0
- package/dist/cli/commands/ants/positions.js.map +1 -0
- package/dist/cli/commands/ants/positions.test.d.ts +2 -0
- package/dist/cli/commands/ants/positions.test.d.ts.map +1 -0
- package/dist/cli/commands/ants/positions.test.js +19 -0
- package/dist/cli/commands/ants/positions.test.js.map +1 -0
- package/dist/cli/commands/ants/rewards.d.ts +9 -0
- package/dist/cli/commands/ants/rewards.d.ts.map +1 -0
- package/dist/cli/commands/ants/rewards.js +93 -0
- package/dist/cli/commands/ants/rewards.js.map +1 -0
- package/dist/cli/commands/ants/rewards.test.d.ts +2 -0
- package/dist/cli/commands/ants/rewards.test.d.ts.map +1 -0
- package/dist/cli/commands/ants/rewards.test.js +46 -0
- package/dist/cli/commands/ants/rewards.test.js.map +1 -0
- package/dist/cli/commands/ants/seller.d.ts +3 -0
- package/dist/cli/commands/ants/seller.d.ts.map +1 -0
- package/dist/cli/commands/ants/seller.js +32 -0
- package/dist/cli/commands/ants/seller.js.map +1 -0
- package/dist/cli/commands/ants/seller.test.d.ts +2 -0
- package/dist/cli/commands/ants/seller.test.d.ts.map +1 -0
- package/dist/cli/commands/ants/seller.test.js +16 -0
- package/dist/cli/commands/ants/seller.test.js.map +1 -0
- package/dist/cli/commands/ants/shared.d.ts +26 -0
- package/dist/cli/commands/ants/shared.d.ts.map +1 -0
- package/dist/cli/commands/ants/shared.js +94 -0
- package/dist/cli/commands/ants/shared.js.map +1 -0
- package/dist/cli/commands/ants/shared.test.d.ts +2 -0
- package/dist/cli/commands/ants/shared.test.d.ts.map +1 -0
- package/dist/cli/commands/ants/shared.test.js +25 -0
- package/dist/cli/commands/ants/shared.test.js.map +1 -0
- package/dist/cli/commands/ants/split.d.ts +3 -0
- package/dist/cli/commands/ants/split.d.ts.map +1 -0
- package/dist/cli/commands/ants/split.js +12 -0
- package/dist/cli/commands/ants/split.js.map +1 -0
- package/dist/cli/commands/ants/split.test.d.ts +2 -0
- package/dist/cli/commands/ants/split.test.d.ts.map +1 -0
- package/dist/cli/commands/ants/split.test.js +13 -0
- package/dist/cli/commands/ants/split.test.js.map +1 -0
- package/dist/cli/commands/ants/stake.d.ts +3 -0
- package/dist/cli/commands/ants/stake.d.ts.map +1 -0
- package/dist/cli/commands/ants/stake.js +15 -0
- package/dist/cli/commands/ants/stake.js.map +1 -0
- package/dist/cli/commands/ants/stake.test.d.ts +2 -0
- package/dist/cli/commands/ants/stake.test.d.ts.map +1 -0
- package/dist/cli/commands/ants/stake.test.js +17 -0
- package/dist/cli/commands/ants/stake.test.js.map +1 -0
- package/dist/cli/commands/ants/status.d.ts +9 -0
- package/dist/cli/commands/ants/status.d.ts.map +1 -0
- package/dist/cli/commands/ants/status.js +43 -0
- package/dist/cli/commands/ants/status.js.map +1 -0
- package/dist/cli/commands/ants/status.test.d.ts +2 -0
- package/dist/cli/commands/ants/status.test.d.ts.map +1 -0
- package/dist/cli/commands/ants/status.test.js +23 -0
- package/dist/cli/commands/ants/status.test.js.map +1 -0
- package/dist/cli/commands/ants/usage.d.ts +4 -0
- package/dist/cli/commands/ants/usage.d.ts.map +1 -0
- package/dist/cli/commands/ants/usage.js +31 -0
- package/dist/cli/commands/ants/usage.js.map +1 -0
- package/dist/cli/commands/ants/usage.test.d.ts +2 -0
- package/dist/cli/commands/ants/usage.test.d.ts.map +1 -0
- package/dist/cli/commands/ants/usage.test.js +15 -0
- package/dist/cli/commands/ants/usage.test.js.map +1 -0
- package/dist/cli/commands/ants/verify.d.ts +3 -0
- package/dist/cli/commands/ants/verify.d.ts.map +1 -0
- package/dist/cli/commands/ants/verify.js +51 -0
- package/dist/cli/commands/ants/verify.js.map +1 -0
- package/dist/cli/commands/ants/verify.test.d.ts +2 -0
- package/dist/cli/commands/ants/verify.test.d.ts.map +1 -0
- package/dist/cli/commands/ants/verify.test.js +51 -0
- package/dist/cli/commands/ants/verify.test.js.map +1 -0
- package/dist/cli/commands/ants/withdraw.d.ts +16 -0
- package/dist/cli/commands/ants/withdraw.d.ts.map +1 -0
- package/dist/cli/commands/ants/withdraw.js +48 -0
- package/dist/cli/commands/ants/withdraw.js.map +1 -0
- package/dist/cli/commands/ants/withdraw.test.d.ts +2 -0
- package/dist/cli/commands/ants/withdraw.test.d.ts.map +1 -0
- package/dist/cli/commands/ants/withdraw.test.js +30 -0
- package/dist/cli/commands/ants/withdraw.test.js.map +1 -0
- package/dist/cli/commands/buyer/start.d.ts.map +1 -1
- package/dist/cli/commands/buyer/start.js +7 -1
- package/dist/cli/commands/buyer/start.js.map +1 -1
- package/dist/cli/commands/emissions.d.ts +7 -0
- package/dist/cli/commands/emissions.d.ts.map +1 -1
- package/dist/cli/commands/emissions.js +105 -27
- package/dist/cli/commands/emissions.js.map +1 -1
- package/dist/cli/commands/emissions.test.js +7 -1
- package/dist/cli/commands/emissions.test.js.map +1 -1
- package/dist/cli/commands/network/browse.d.ts.map +1 -1
- package/dist/cli/commands/network/browse.js +12 -3
- package/dist/cli/commands/network/browse.js.map +1 -1
- package/dist/cli/commands/network/chain-config-helper.d.ts +21 -1
- package/dist/cli/commands/network/chain-config-helper.d.ts.map +1 -1
- package/dist/cli/commands/network/chain-config-helper.js +6 -1
- package/dist/cli/commands/network/chain-config-helper.js.map +1 -1
- package/dist/cli/commands/network/peer.d.ts.map +1 -1
- package/dist/cli/commands/network/peer.js +21 -1
- package/dist/cli/commands/network/peer.js.map +1 -1
- package/dist/cli/commands/parse-positive-integer.d.ts +2 -0
- package/dist/cli/commands/parse-positive-integer.d.ts.map +1 -0
- package/dist/cli/commands/parse-positive-integer.js +9 -0
- package/dist/cli/commands/parse-positive-integer.js.map +1 -0
- package/dist/cli/commands/reward-actions.d.ts +11 -0
- package/dist/cli/commands/reward-actions.d.ts.map +1 -0
- package/dist/cli/commands/reward-actions.js +22 -0
- package/dist/cli/commands/reward-actions.js.map +1 -0
- package/dist/cli/commands/seller/contract-clients.test.d.ts +2 -0
- package/dist/cli/commands/seller/contract-clients.test.d.ts.map +1 -0
- package/dist/cli/commands/seller/contract-clients.test.js +46 -0
- package/dist/cli/commands/seller/contract-clients.test.js.map +1 -0
- package/dist/cli/commands/seller/index.d.ts.map +1 -1
- package/dist/cli/commands/seller/index.js +4 -2
- package/dist/cli/commands/seller/index.js.map +1 -1
- package/dist/cli/commands/seller/pool.d.ts +15 -0
- package/dist/cli/commands/seller/pool.d.ts.map +1 -0
- package/dist/cli/commands/seller/pool.js +201 -0
- package/dist/cli/commands/seller/pool.js.map +1 -0
- package/dist/cli/commands/seller/pool.test.d.ts +2 -0
- package/dist/cli/commands/seller/pool.test.d.ts.map +1 -0
- package/dist/cli/commands/seller/pool.test.js +16 -0
- package/dist/cli/commands/seller/pool.test.js.map +1 -0
- package/dist/cli/commands/seller/register.d.ts.map +1 -1
- package/dist/cli/commands/seller/register.js +38 -8
- package/dist/cli/commands/seller/register.js.map +1 -1
- package/dist/cli/commands/seller/rewards.d.ts +13 -0
- package/dist/cli/commands/seller/rewards.d.ts.map +1 -0
- package/dist/cli/commands/seller/rewards.js +115 -0
- package/dist/cli/commands/seller/rewards.js.map +1 -0
- package/dist/cli/commands/seller/rewards.test.d.ts +2 -0
- package/dist/cli/commands/seller/rewards.test.d.ts.map +1 -0
- package/dist/cli/commands/seller/rewards.test.js +21 -0
- package/dist/cli/commands/seller/rewards.test.js.map +1 -0
- package/dist/cli/commands/seller/setup.d.ts.map +1 -1
- package/dist/cli/commands/seller/setup.js +2 -1
- package/dist/cli/commands/seller/setup.js.map +1 -1
- package/dist/cli/commands/seller/stake.d.ts.map +1 -1
- package/dist/cli/commands/seller/stake.js +104 -65
- package/dist/cli/commands/seller/stake.js.map +1 -1
- package/dist/cli/commands/seller/stake.test.d.ts +2 -0
- package/dist/cli/commands/seller/stake.test.d.ts.map +1 -0
- package/dist/cli/commands/seller/stake.test.js +99 -0
- package/dist/cli/commands/seller/stake.test.js.map +1 -0
- package/dist/cli/commands/seller/start.d.ts.map +1 -1
- package/dist/cli/commands/seller/start.js +6 -0
- package/dist/cli/commands/seller/start.js.map +1 -1
- package/dist/cli/commands/seller/status.d.ts.map +1 -1
- package/dist/cli/commands/seller/status.js +44 -2
- package/dist/cli/commands/seller/status.js.map +1 -1
- package/dist/cli/index.js +2 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/payment-utils.d.ts +33 -2
- package/dist/cli/payment-utils.d.ts.map +1 -1
- package/dist/cli/payment-utils.js +101 -2
- package/dist/cli/payment-utils.js.map +1 -1
- package/dist/config/types.d.ts +20 -0
- package/dist/config/types.d.ts.map +1 -1
- package/dist/plugins/verifier-evidence.test.d.ts +2 -0
- package/dist/plugins/verifier-evidence.test.d.ts.map +1 -0
- package/dist/plugins/verifier-evidence.test.js +41 -0
- package/dist/plugins/verifier-evidence.test.js.map +1 -0
- package/dist/plugins/verifier.d.ts +8 -10
- package/dist/plugins/verifier.d.ts.map +1 -1
- package/dist/plugins/verifier.js +23 -51
- package/dist/plugins/verifier.js.map +1 -1
- package/dist/plugins/verifier.test.js +1 -37
- package/dist/plugins/verifier.test.js.map +1 -1
- package/dist/proxy/buyer-proxy.d.ts +2 -1
- package/dist/proxy/buyer-proxy.d.ts.map +1 -1
- package/dist/proxy/buyer-proxy.js +104 -28
- package/dist/proxy/buyer-proxy.js.map +1 -1
- package/dist/proxy/buyer-proxy.test.js +177 -19
- package/dist/proxy/buyer-proxy.test.js.map +1 -1
- package/dist/proxy/network-models.d.ts +1 -2
- package/dist/proxy/network-models.d.ts.map +1 -1
- package/dist/proxy/network-models.js +10 -23
- package/dist/proxy/network-models.js.map +1 -1
- package/dist/proxy/network-models.test.js +56 -27
- package/dist/proxy/network-models.test.js.map +1 -1
- package/dist/proxy/tee-control.d.ts +14 -0
- package/dist/proxy/tee-control.d.ts.map +1 -0
- package/dist/proxy/tee-control.js +100 -0
- package/dist/proxy/tee-control.js.map +1 -0
- package/dist/proxy/tee-control.test.d.ts +2 -0
- package/dist/proxy/tee-control.test.d.ts.map +1 -0
- package/dist/proxy/tee-control.test.js +56 -0
- package/dist/proxy/tee-control.test.js.map +1 -0
- package/dist/proxy/tee-verification.d.ts +24 -0
- package/dist/proxy/tee-verification.d.ts.map +1 -0
- package/dist/proxy/tee-verification.js +128 -0
- package/dist/proxy/tee-verification.js.map +1 -0
- package/dist/proxy/tee-verification.test.d.ts +2 -0
- package/dist/proxy/tee-verification.test.d.ts.map +1 -0
- package/dist/proxy/tee-verification.test.js +241 -0
- package/dist/proxy/tee-verification.test.js.map +1 -0
- package/package.json +8 -6
- package/dist/cli/commands/seller/emissions.d.ts +0 -3
- package/dist/cli/commands/seller/emissions.d.ts.map +0 -1
- package/dist/cli/commands/seller/emissions.js +0 -5
- package/dist/cli/commands/seller/emissions.js.map +0 -1
|
@@ -3,11 +3,11 @@ import { randomUUID } from 'node:crypto';
|
|
|
3
3
|
import { watchFile, unwatchFile } from 'node:fs';
|
|
4
4
|
import { readFile, writeFile, rename, mkdir, readdir, stat, unlink } from 'node:fs/promises';
|
|
5
5
|
import { join } from 'node:path';
|
|
6
|
-
import { ANTSEED_BUYER_FAULT_ERROR_CODE, ANTSEED_FAULT_ATTRIBUTION_HEADER, ANTSEED_ATTEST_PATH, adaptPeerFaultErrorResponse,
|
|
6
|
+
import { ANTSEED_BUYER_FAULT_ERROR_CODE, ANTSEED_FAULT_ATTRIBUTION_HEADER, ANTSEED_ATTEST_PATH, adaptPeerFaultErrorResponse, computeTrustScore, decodeSweepRequest, faultAttributionOf, faultCodeOf, isModelRouteEligible, modelRouteTotalPrice, normalizedModelReputationScore, peerSupportsCooperativeClose, rankModelRoutes, sanitizePeerDisplayName, } from '@antseed/node';
|
|
7
7
|
import { canonicalModelKey } from '@antseed/node/model-identity';
|
|
8
8
|
import { createStreamingAdapter, detectRequestServiceApiProtocol, transformRequest, transformResponse, } from './service-api-adapter.js';
|
|
9
9
|
import { DEBUG, log, extractRequestedService, summarizeRequestShape, summarizeErrorResponse, requestWantsStreaming, parsePeerPinnedService, rewritePeerPinnedServiceInBody, substituteRoutedModelAlias, overrideRoutedModelInBody, ROUTED_MODEL_ALIAS, SYSTEM_PROXY_SOURCE_HEADER, SYSTEM_ROUTED_MODEL_HEADER, normalizePeerId, } from './request-utils.js';
|
|
10
|
-
import { buildNetworkModels, effectiveModelReputationScore,
|
|
10
|
+
import { buildNetworkModels, effectiveModelReputationScore, parseModelTypeFilter, } from './network-models.js';
|
|
11
11
|
import { findMissingRequiredParameters, findUnannouncedRequestParameters, findAdvertisedServiceOffer, getExplicitProviderOverride, getExplicitPeerIdOverride, parseRequiredParametersHeader, REQUIRED_PARAMETERS_HEADER, resolvePeerRoutePlan, selectCandidatePeersForRouting, } from './routing.js';
|
|
12
12
|
import { computeResponseTelemetry, attachAntseedTelemetryHeaders, attachStreamingAntseedHeaders, } from './telemetry.js';
|
|
13
13
|
import { DEFAULT_BUYER_PEER_REFRESH_INTERVAL_MS } from '../config/defaults.js';
|
|
@@ -16,7 +16,11 @@ import { ConversationStore } from './conversation-store.js';
|
|
|
16
16
|
import { recordPeerFailureEntry, clearPeerHealthEntry, isCoolingDown, parsePersistedPeerHealth, prunePeerHealth, serializePeerHealth, reasonEscalates, } from './peer-health.js';
|
|
17
17
|
import { PeerAttributionTracker, HEARTBEAT_MS } from './peer-attribution.js';
|
|
18
18
|
import { estimateAnthropicPromptTokens, isCountTokensPath } from './count-tokens.js';
|
|
19
|
-
import {
|
|
19
|
+
import { runVerifier, verifierSupportFingerprint } from '../plugins/verifier.js';
|
|
20
|
+
import { TEE_VERIFIER_ID } from '@antseed/node/tee-status';
|
|
21
|
+
import { parseVerifierCapabilities } from '@antseed/node/verifier-capabilities';
|
|
22
|
+
import { TeeVerification } from './tee-verification.js';
|
|
23
|
+
import { TeeControl } from './tee-control.js';
|
|
20
24
|
import { loadConfig } from '../config/loader.js';
|
|
21
25
|
// Re-export for backward compatibility (used by tests and other consumers)
|
|
22
26
|
export { selectCandidatePeersForRouting } from './routing.js';
|
|
@@ -126,8 +130,6 @@ const CARRY_FORWARD_TTL_MS = 2 * 60 * 60_000;
|
|
|
126
130
|
const MAX_TRACKED_REQUEST_CONVERSATIONS = 512;
|
|
127
131
|
/** Min gap between background peer refreshes triggered by model_not_found responses. */
|
|
128
132
|
const MODEL_NOT_FOUND_REFRESH_THROTTLE_MS = 30_000;
|
|
129
|
-
/** Verification is expensive; bound how many verdicts we retain (TTL = peer-cache TTL). */
|
|
130
|
-
const VERIFY_CACHE_MAX_ENTRIES = 1024;
|
|
131
133
|
/**
|
|
132
134
|
* Statuses that prove the peer is alive and serving. Any response short of a
|
|
133
135
|
* server error counts: a peer that answers 400 or 404 is reachable, and
|
|
@@ -379,8 +381,9 @@ export function parsePersistedPeers(parsed, nowMs = Date.now(), maxAgeMs = CARRY
|
|
|
379
381
|
}
|
|
380
382
|
if (lastReachedAt > 0)
|
|
381
383
|
peer.lastReachedAt = lastReachedAt;
|
|
382
|
-
|
|
383
|
-
|
|
384
|
+
const displayName = sanitizePeerDisplayName(entry.displayName);
|
|
385
|
+
if (displayName)
|
|
386
|
+
peer.displayName = displayName;
|
|
384
387
|
if (typeof entry.publicAddress === 'string')
|
|
385
388
|
peer.publicAddress = entry.publicAddress;
|
|
386
389
|
if (entry.providerPricing && typeof entry.providerPricing === 'object') {
|
|
@@ -413,15 +416,9 @@ export function parsePersistedPeers(parsed, nowMs = Date.now(), maxAgeMs = CARRY
|
|
|
413
416
|
if (typeof entry.onChainAgentId === 'number' && Number.isFinite(entry.onChainAgentId)) {
|
|
414
417
|
peer.onChainAgentId = entry.onChainAgentId;
|
|
415
418
|
}
|
|
416
|
-
if (typeof entry.onChainStakeUsdcMicros === 'number' && Number.isFinite(entry.onChainStakeUsdcMicros)) {
|
|
417
|
-
peer.onChainStakeUsdcMicros = entry.onChainStakeUsdcMicros;
|
|
418
|
-
}
|
|
419
419
|
if (typeof entry.onChainReputationScore === 'number' && Number.isFinite(entry.onChainReputationScore)) {
|
|
420
420
|
peer.onChainReputationScore = entry.onChainReputationScore;
|
|
421
421
|
}
|
|
422
|
-
if (typeof entry.onChainTrustScore === 'number' && Number.isFinite(entry.onChainTrustScore)) {
|
|
423
|
-
peer.onChainTrustScore = entry.onChainTrustScore;
|
|
424
|
-
}
|
|
425
422
|
if (typeof entry.onChainSybilRisk === 'number' && Number.isFinite(entry.onChainSybilRisk)) {
|
|
426
423
|
peer.onChainSybilRisk = entry.onChainSybilRisk;
|
|
427
424
|
}
|
|
@@ -445,6 +442,27 @@ export function parsePersistedPeers(parsed, nowMs = Date.now(), maxAgeMs = CARRY
|
|
|
445
442
|
if (typeof entry.onChainStakedAtSec === 'number' && Number.isFinite(entry.onChainStakedAtSec)) {
|
|
446
443
|
peer.onChainStakedAtSec = entry.onChainStakedAtSec;
|
|
447
444
|
}
|
|
445
|
+
if (typeof entry.onChainUsageEpoch === 'number' && Number.isFinite(entry.onChainUsageEpoch)) {
|
|
446
|
+
peer.onChainUsageEpoch = entry.onChainUsageEpoch;
|
|
447
|
+
}
|
|
448
|
+
if (typeof entry.onChainUsageShareBps === 'number' && Number.isFinite(entry.onChainUsageShareBps)) {
|
|
449
|
+
peer.onChainUsageShareBps = entry.onChainUsageShareBps;
|
|
450
|
+
}
|
|
451
|
+
if (typeof entry.onChainUsageLastEpochUsdcMicros === 'number' && Number.isFinite(entry.onChainUsageLastEpochUsdcMicros)) {
|
|
452
|
+
peer.onChainUsageLastEpochUsdcMicros = entry.onChainUsageLastEpochUsdcMicros;
|
|
453
|
+
}
|
|
454
|
+
if (typeof entry.onChainPoolStakeAnts === 'number' && Number.isFinite(entry.onChainPoolStakeAnts)) {
|
|
455
|
+
peer.onChainPoolStakeAnts = entry.onChainPoolStakeAnts;
|
|
456
|
+
}
|
|
457
|
+
if (typeof entry.onChainPoolPowerShareBps === 'number' && Number.isFinite(entry.onChainPoolPowerShareBps)) {
|
|
458
|
+
peer.onChainPoolPowerShareBps = entry.onChainPoolPowerShareBps;
|
|
459
|
+
}
|
|
460
|
+
if (typeof entry.onChainWashFlagged === 'boolean') {
|
|
461
|
+
peer.onChainWashFlagged = entry.onChainWashFlagged;
|
|
462
|
+
}
|
|
463
|
+
if (typeof entry.onChainWashShareBps === 'number' && Number.isFinite(entry.onChainWashShareBps)) {
|
|
464
|
+
peer.onChainWashShareBps = entry.onChainWashShareBps;
|
|
465
|
+
}
|
|
448
466
|
if (typeof entry.onChainStatsFetchedAt === 'number' && Number.isFinite(entry.onChainStatsFetchedAt)) {
|
|
449
467
|
peer.onChainStatsFetchedAt = entry.onChainStatsFetchedAt;
|
|
450
468
|
}
|
|
@@ -466,10 +484,13 @@ export function parsePersistedPeers(parsed, nowMs = Date.now(), maxAgeMs = CARRY
|
|
|
466
484
|
if (entry.verificationResults && typeof entry.verificationResults === 'object') {
|
|
467
485
|
peer.verificationResults = entry.verificationResults;
|
|
468
486
|
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
487
|
+
// Re-score from the persisted signals rather than trusting the stored
|
|
488
|
+
// number: identity evidence expires, so a cached score can go stale. When
|
|
489
|
+
// nothing scoreable was persisted, keep whatever score the row carried.
|
|
490
|
+
const trust = computeTrustScore(peer, nowMs);
|
|
491
|
+
if (trust) {
|
|
492
|
+
peer.trust = trust;
|
|
493
|
+
peer.onChainReputationScore = trust.score;
|
|
473
494
|
}
|
|
474
495
|
peers.push(peer);
|
|
475
496
|
}
|
|
@@ -602,7 +623,8 @@ export class BuyerProxy {
|
|
|
602
623
|
*/
|
|
603
624
|
_lastModelActivityAt = 0;
|
|
604
625
|
_verifier;
|
|
605
|
-
|
|
626
|
+
_teeVerification;
|
|
627
|
+
_teeControl;
|
|
606
628
|
_stateWatchDebounce = null;
|
|
607
629
|
_configWatchDebounce = null;
|
|
608
630
|
_routingPreferences;
|
|
@@ -650,6 +672,8 @@ export class BuyerProxy {
|
|
|
650
672
|
constructor(config) {
|
|
651
673
|
this._node = config.node;
|
|
652
674
|
this._verifier = config.verifier;
|
|
675
|
+
this._teeVerification = new TeeVerification(config.verifier);
|
|
676
|
+
this._teeControl = new TeeControl(this._teeVerification.sessionId);
|
|
653
677
|
this._port = config.port;
|
|
654
678
|
this._bgRefreshIntervalMs = Math.max(1, config.backgroundRefreshIntervalMs ?? DEFAULT_BUYER_PEER_REFRESH_INTERVAL_MS);
|
|
655
679
|
this._peerCacheTtlMs = Math.max(0, config.peerCacheTtlMs ?? Math.max(6 * 60_000, this._bgRefreshIntervalMs + 60_000));
|
|
@@ -766,6 +790,14 @@ export class BuyerProxy {
|
|
|
766
790
|
resolve();
|
|
767
791
|
});
|
|
768
792
|
});
|
|
793
|
+
try {
|
|
794
|
+
const address = this._server.address();
|
|
795
|
+
await this._teeControl.publish(this._stateDir, typeof address === 'object' && address ? address.port : this._port);
|
|
796
|
+
}
|
|
797
|
+
catch (error) {
|
|
798
|
+
await new Promise((resolve) => this._server.close(() => resolve()));
|
|
799
|
+
throw error;
|
|
800
|
+
}
|
|
769
801
|
this._startBackgroundRefresh();
|
|
770
802
|
this._startSuspendHeartbeat();
|
|
771
803
|
// Trigger initial discovery immediately so the desktop can show services
|
|
@@ -791,6 +823,7 @@ export class BuyerProxy {
|
|
|
791
823
|
return;
|
|
792
824
|
}
|
|
793
825
|
this._cachedPeers = peers;
|
|
826
|
+
this._teeVerification.observePeers(peers);
|
|
794
827
|
// Preserve the original discovery timestamp so cacheAgeMs reflects how
|
|
795
828
|
// long ago the persisted data was actually written, not startup time.
|
|
796
829
|
const peersUpdatedAt = parsed.peersUpdatedAt;
|
|
@@ -806,6 +839,8 @@ export class BuyerProxy {
|
|
|
806
839
|
}
|
|
807
840
|
}
|
|
808
841
|
async stop() {
|
|
842
|
+
this._teeVerification.close();
|
|
843
|
+
await this._teeControl.close();
|
|
809
844
|
if (this._stateWatchDebounce) {
|
|
810
845
|
clearTimeout(this._stateWatchDebounce);
|
|
811
846
|
this._stateWatchDebounce = null;
|
|
@@ -997,6 +1032,7 @@ export class BuyerProxy {
|
|
|
997
1032
|
}
|
|
998
1033
|
}
|
|
999
1034
|
this._cachedPeers = merged;
|
|
1035
|
+
this._teeVerification.observePeers(merged);
|
|
1000
1036
|
this._cacheLastUpdatedAtMs = Date.now();
|
|
1001
1037
|
this._cacheMutationEpoch += 1;
|
|
1002
1038
|
this._persistPeersToState();
|
|
@@ -1031,19 +1067,27 @@ export class BuyerProxy {
|
|
|
1031
1067
|
defaultCachedInputUsdPerMillion: p.defaultCachedInputUsdPerMillion ?? null,
|
|
1032
1068
|
maxConcurrency: p.maxConcurrency ?? 0,
|
|
1033
1069
|
currentLoad: p.currentLoad ?? null,
|
|
1034
|
-
// On-chain stats read authoritatively by the buyer from AntseedChannels
|
|
1070
|
+
// On-chain stats read authoritatively by the buyer from AntseedChannels,
|
|
1071
|
+
// the seller pools, usage accounting and the wash-trading registry.
|
|
1035
1072
|
// Persisted so CLI/desktop surfaces can render richer UI without their
|
|
1036
|
-
// own duplicate
|
|
1073
|
+
// own duplicate RPC and trust-score implementations. The node already
|
|
1074
|
+
// scored the peer; `onChainReputationScore` is the trust score and
|
|
1075
|
+
// `trust` its breakdown.
|
|
1037
1076
|
onChainAgentId: p.onChainAgentId ?? null,
|
|
1038
|
-
onChainStakeUsdcMicros: p.onChainStakeUsdcMicros ?? null,
|
|
1039
1077
|
onChainChannelCount: p.onChainChannelCount ?? null,
|
|
1040
1078
|
onChainGhostCount: p.onChainGhostCount ?? null,
|
|
1041
1079
|
onChainTotalVolumeUsdcMicros: p.onChainTotalVolumeUsdcMicros ?? null,
|
|
1042
1080
|
onChainLastSettledAtSec: p.onChainLastSettledAtSec ?? null,
|
|
1043
1081
|
onChainStakedAtSec: p.onChainStakedAtSec ?? null,
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1082
|
+
onChainUsageEpoch: p.onChainUsageEpoch ?? null,
|
|
1083
|
+
onChainUsageShareBps: p.onChainUsageShareBps ?? null,
|
|
1084
|
+
onChainUsageLastEpochUsdcMicros: p.onChainUsageLastEpochUsdcMicros ?? null,
|
|
1085
|
+
onChainPoolStakeAnts: p.onChainPoolStakeAnts ?? null,
|
|
1086
|
+
onChainPoolPowerShareBps: p.onChainPoolPowerShareBps ?? null,
|
|
1087
|
+
onChainWashFlagged: p.onChainWashFlagged ?? null,
|
|
1088
|
+
onChainWashShareBps: p.onChainWashShareBps ?? null,
|
|
1089
|
+
onChainReputationScore: p.onChainReputationScore ?? null,
|
|
1090
|
+
trust: p.trust ?? null,
|
|
1047
1091
|
onChainSybilRisk: p.onChainSybilRisk ?? null,
|
|
1048
1092
|
onChainSybilFlags: p.onChainSybilFlags ?? null,
|
|
1049
1093
|
onChainStatsFetchedAt: p.onChainStatsFetchedAt ?? null,
|
|
@@ -1321,6 +1365,21 @@ export class BuyerProxy {
|
|
|
1321
1365
|
return `Discovered ${peers.length} peer(s): ${samples}${suffix}`;
|
|
1322
1366
|
}
|
|
1323
1367
|
async _handleControlPlane(req, res, method, path) {
|
|
1368
|
+
if (path.startsWith('/_antseed/verification')) {
|
|
1369
|
+
await this._teeControl.handle(req, res, method, path, () => this._teeVerification.snapshot(this._cachedPeers), async (peerId) => {
|
|
1370
|
+
const peer = this._cachedPeers.find((candidate) => candidate.peerId === peerId);
|
|
1371
|
+
if (!peer || !parseVerifierCapabilities(peer.capabilities).supported.includes(TEE_VERIFIER_ID)) {
|
|
1372
|
+
throw new Error('Seller is unknown or does not advertise TEE support');
|
|
1373
|
+
}
|
|
1374
|
+
if (!this._verifier)
|
|
1375
|
+
throw new Error('Verification is disabled by the buyer CLI');
|
|
1376
|
+
const signal = AbortSignal.timeout(31_000);
|
|
1377
|
+
const outcome = await this._teeVerification.verifyForDisplay(peer, () => runVerifier({ require: false, prefer: [TEE_VERIFIER_ID] }, peer.peerId, peer.capabilities, (chosen) => makeVerifierReach(this._node, peer, chosen, signal), signal));
|
|
1378
|
+
if (outcome.code === 'busy')
|
|
1379
|
+
throw new Error(outcome.reason);
|
|
1380
|
+
});
|
|
1381
|
+
return;
|
|
1382
|
+
}
|
|
1324
1383
|
const origin = req.headers.origin ?? '';
|
|
1325
1384
|
const isLocal = origin.startsWith('http://127.0.0.1') || origin.startsWith('http://localhost') || origin === 'file://';
|
|
1326
1385
|
if (isLocal)
|
|
@@ -1374,6 +1433,16 @@ export class BuyerProxy {
|
|
|
1374
1433
|
providerServiceUnitBillingModels: p.providerServiceUnitBillingModels,
|
|
1375
1434
|
providerServiceCapabilities: p.providerServiceCapabilities,
|
|
1376
1435
|
reputationScore: p.reputationScore,
|
|
1436
|
+
onChainReputationScore: p.onChainReputationScore ?? null,
|
|
1437
|
+
trust: p.trust ?? null,
|
|
1438
|
+
onChainPoolStakeAnts: p.onChainPoolStakeAnts ?? null,
|
|
1439
|
+
onChainPoolPowerShareBps: p.onChainPoolPowerShareBps ?? null,
|
|
1440
|
+
onChainUsageEpoch: p.onChainUsageEpoch ?? null,
|
|
1441
|
+
onChainUsageShareBps: p.onChainUsageShareBps ?? null,
|
|
1442
|
+
onChainUsageLastEpochUsdcMicros: p.onChainUsageLastEpochUsdcMicros ?? null,
|
|
1443
|
+
onChainWashFlagged: p.onChainWashFlagged ?? null,
|
|
1444
|
+
onChainWashShareBps: p.onChainWashShareBps ?? null,
|
|
1445
|
+
verificationResults: p.verificationResults,
|
|
1377
1446
|
lastSeen: p.lastSeen,
|
|
1378
1447
|
}));
|
|
1379
1448
|
res.writeHead(200, { 'content-type': 'application/json' });
|
|
@@ -1982,7 +2051,7 @@ export class BuyerProxy {
|
|
|
1982
2051
|
error: {
|
|
1983
2052
|
type: 'no_default_route',
|
|
1984
2053
|
code: 'no_default_route',
|
|
1985
|
-
message: `Model "${ROUTED_MODEL_ALIAS}" routes to the model selected in
|
|
2054
|
+
message: `Model "${ROUTED_MODEL_ALIAS}" routes to the model selected in the AI VPN, but no route is set. `
|
|
1986
2055
|
+ 'Pick a model in the desktop app, or request "<peerId>@<model>" explicitly.',
|
|
1987
2056
|
param: 'model',
|
|
1988
2057
|
},
|
|
@@ -2150,7 +2219,7 @@ export class BuyerProxy {
|
|
|
2150
2219
|
peerId: peer.peerId,
|
|
2151
2220
|
serviceId: plan.serviceId,
|
|
2152
2221
|
request: requestForPolicy,
|
|
2153
|
-
reputation: normalizedModelReputationScore(peer
|
|
2222
|
+
reputation: normalizedModelReputationScore(peer) ?? -1,
|
|
2154
2223
|
hasCachedInputPricing: offer.cachedInputUsdPerMillion !== undefined,
|
|
2155
2224
|
inputUsdPerMillion: offer.inputUsdPerMillion ?? null,
|
|
2156
2225
|
outputUsdPerMillion: offer.outputUsdPerMillion ?? null,
|
|
@@ -2422,8 +2491,15 @@ export class BuyerProxy {
|
|
|
2422
2491
|
const policy = this._verifier;
|
|
2423
2492
|
if (!policy)
|
|
2424
2493
|
return { ok: true, verified: false };
|
|
2425
|
-
const
|
|
2426
|
-
|
|
2494
|
+
const fingerprint = verifierSupportFingerprint(peer.capabilities);
|
|
2495
|
+
const outcome = await this._teeVerification.verify(peer, policy, () => runVerifier(policy, peer.peerId, peer.capabilities, makeReach, signal));
|
|
2496
|
+
const current = this._cachedPeers.find((candidate) => candidate.peerId === peer.peerId);
|
|
2497
|
+
if (current && verifierSupportFingerprint(current.capabilities) !== fingerprint) {
|
|
2498
|
+
return { ok: !policy.require, verified: false, transient: true, reason: 'Seller capabilities changed; retry verification' };
|
|
2499
|
+
}
|
|
2500
|
+
if (signal.aborted)
|
|
2501
|
+
return { ok: false, verified: false, transient: true, reason: 'Request aborted' };
|
|
2502
|
+
return outcome;
|
|
2427
2503
|
}
|
|
2428
2504
|
_parseMaxUploadBodyBytes(headers) {
|
|
2429
2505
|
const raw = headers['x-antseed-max-upload-body-bytes'];
|