@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.
Files changed (285) hide show
  1. package/README.md +158 -6
  2. package/dist/cli/commands/ants/addresses.d.ts +3 -0
  3. package/dist/cli/commands/ants/addresses.d.ts.map +1 -0
  4. package/dist/cli/commands/ants/addresses.js +20 -0
  5. package/dist/cli/commands/ants/addresses.js.map +1 -0
  6. package/dist/cli/commands/ants/addresses.test.d.ts +2 -0
  7. package/dist/cli/commands/ants/addresses.test.d.ts.map +1 -0
  8. package/dist/cli/commands/ants/addresses.test.js +12 -0
  9. package/dist/cli/commands/ants/addresses.test.js.map +1 -0
  10. package/dist/cli/commands/ants/arguments.test.d.ts +2 -0
  11. package/dist/cli/commands/ants/arguments.test.d.ts.map +1 -0
  12. package/dist/cli/commands/ants/arguments.test.js +51 -0
  13. package/dist/cli/commands/ants/arguments.test.js.map +1 -0
  14. package/dist/cli/commands/ants/dashboard.d.ts +4 -0
  15. package/dist/cli/commands/ants/dashboard.d.ts.map +1 -0
  16. package/dist/cli/commands/ants/dashboard.js +45 -0
  17. package/dist/cli/commands/ants/dashboard.js.map +1 -0
  18. package/dist/cli/commands/ants/dashboard.test.d.ts +2 -0
  19. package/dist/cli/commands/ants/dashboard.test.d.ts.map +1 -0
  20. package/dist/cli/commands/ants/dashboard.test.js +14 -0
  21. package/dist/cli/commands/ants/dashboard.test.js.map +1 -0
  22. package/dist/cli/commands/ants/emissions.d.ts +5 -0
  23. package/dist/cli/commands/ants/emissions.d.ts.map +1 -0
  24. package/dist/cli/commands/ants/emissions.js +44 -0
  25. package/dist/cli/commands/ants/emissions.js.map +1 -0
  26. package/dist/cli/commands/ants/emissions.test.d.ts +2 -0
  27. package/dist/cli/commands/ants/emissions.test.d.ts.map +1 -0
  28. package/dist/cli/commands/ants/emissions.test.js +17 -0
  29. package/dist/cli/commands/ants/emissions.test.js.map +1 -0
  30. package/dist/cli/commands/ants/extend.d.ts +3 -0
  31. package/dist/cli/commands/ants/extend.d.ts.map +1 -0
  32. package/dist/cli/commands/ants/extend.js +14 -0
  33. package/dist/cli/commands/ants/extend.js.map +1 -0
  34. package/dist/cli/commands/ants/extend.test.d.ts +2 -0
  35. package/dist/cli/commands/ants/extend.test.d.ts.map +1 -0
  36. package/dist/cli/commands/ants/extend.test.js +13 -0
  37. package/dist/cli/commands/ants/extend.test.js.map +1 -0
  38. package/dist/cli/commands/ants/index.d.ts +7 -0
  39. package/dist/cli/commands/ants/index.d.ts.map +1 -0
  40. package/dist/cli/commands/ants/index.js +46 -0
  41. package/dist/cli/commands/ants/index.js.map +1 -0
  42. package/dist/cli/commands/ants/index.test.d.ts +2 -0
  43. package/dist/cli/commands/ants/index.test.d.ts.map +1 -0
  44. package/dist/cli/commands/ants/index.test.js +24 -0
  45. package/dist/cli/commands/ants/index.test.js.map +1 -0
  46. package/dist/cli/commands/ants/max-lock.d.ts +3 -0
  47. package/dist/cli/commands/ants/max-lock.d.ts.map +1 -0
  48. package/dist/cli/commands/ants/max-lock.js +13 -0
  49. package/dist/cli/commands/ants/max-lock.js.map +1 -0
  50. package/dist/cli/commands/ants/max-lock.test.d.ts +2 -0
  51. package/dist/cli/commands/ants/max-lock.test.d.ts.map +1 -0
  52. package/dist/cli/commands/ants/max-lock.test.js +15 -0
  53. package/dist/cli/commands/ants/max-lock.test.js.map +1 -0
  54. package/dist/cli/commands/ants/merge.d.ts +3 -0
  55. package/dist/cli/commands/ants/merge.d.ts.map +1 -0
  56. package/dist/cli/commands/ants/merge.js +12 -0
  57. package/dist/cli/commands/ants/merge.js.map +1 -0
  58. package/dist/cli/commands/ants/merge.test.d.ts +2 -0
  59. package/dist/cli/commands/ants/merge.test.d.ts.map +1 -0
  60. package/dist/cli/commands/ants/merge.test.js +16 -0
  61. package/dist/cli/commands/ants/merge.test.js.map +1 -0
  62. package/dist/cli/commands/ants/move.d.ts +3 -0
  63. package/dist/cli/commands/ants/move.d.ts.map +1 -0
  64. package/dist/cli/commands/ants/move.js +14 -0
  65. package/dist/cli/commands/ants/move.js.map +1 -0
  66. package/dist/cli/commands/ants/move.test.d.ts +2 -0
  67. package/dist/cli/commands/ants/move.test.d.ts.map +1 -0
  68. package/dist/cli/commands/ants/move.test.js +16 -0
  69. package/dist/cli/commands/ants/move.test.js.map +1 -0
  70. package/dist/cli/commands/ants/pool.d.ts +3 -0
  71. package/dist/cli/commands/ants/pool.d.ts.map +1 -0
  72. package/dist/cli/commands/ants/pool.js +21 -0
  73. package/dist/cli/commands/ants/pool.js.map +1 -0
  74. package/dist/cli/commands/ants/pool.test.d.ts +2 -0
  75. package/dist/cli/commands/ants/pool.test.d.ts.map +1 -0
  76. package/dist/cli/commands/ants/pool.test.js +13 -0
  77. package/dist/cli/commands/ants/pool.test.js.map +1 -0
  78. package/dist/cli/commands/ants/pools.d.ts +6 -0
  79. package/dist/cli/commands/ants/pools.d.ts.map +1 -0
  80. package/dist/cli/commands/ants/pools.js +50 -0
  81. package/dist/cli/commands/ants/pools.js.map +1 -0
  82. package/dist/cli/commands/ants/pools.test.d.ts +2 -0
  83. package/dist/cli/commands/ants/pools.test.d.ts.map +1 -0
  84. package/dist/cli/commands/ants/pools.test.js +18 -0
  85. package/dist/cli/commands/ants/pools.test.js.map +1 -0
  86. package/dist/cli/commands/ants/positions.d.ts +6 -0
  87. package/dist/cli/commands/ants/positions.d.ts.map +1 -0
  88. package/dist/cli/commands/ants/positions.js +46 -0
  89. package/dist/cli/commands/ants/positions.js.map +1 -0
  90. package/dist/cli/commands/ants/positions.test.d.ts +2 -0
  91. package/dist/cli/commands/ants/positions.test.d.ts.map +1 -0
  92. package/dist/cli/commands/ants/positions.test.js +19 -0
  93. package/dist/cli/commands/ants/positions.test.js.map +1 -0
  94. package/dist/cli/commands/ants/rewards.d.ts +9 -0
  95. package/dist/cli/commands/ants/rewards.d.ts.map +1 -0
  96. package/dist/cli/commands/ants/rewards.js +93 -0
  97. package/dist/cli/commands/ants/rewards.js.map +1 -0
  98. package/dist/cli/commands/ants/rewards.test.d.ts +2 -0
  99. package/dist/cli/commands/ants/rewards.test.d.ts.map +1 -0
  100. package/dist/cli/commands/ants/rewards.test.js +46 -0
  101. package/dist/cli/commands/ants/rewards.test.js.map +1 -0
  102. package/dist/cli/commands/ants/seller.d.ts +3 -0
  103. package/dist/cli/commands/ants/seller.d.ts.map +1 -0
  104. package/dist/cli/commands/ants/seller.js +32 -0
  105. package/dist/cli/commands/ants/seller.js.map +1 -0
  106. package/dist/cli/commands/ants/seller.test.d.ts +2 -0
  107. package/dist/cli/commands/ants/seller.test.d.ts.map +1 -0
  108. package/dist/cli/commands/ants/seller.test.js +16 -0
  109. package/dist/cli/commands/ants/seller.test.js.map +1 -0
  110. package/dist/cli/commands/ants/shared.d.ts +26 -0
  111. package/dist/cli/commands/ants/shared.d.ts.map +1 -0
  112. package/dist/cli/commands/ants/shared.js +94 -0
  113. package/dist/cli/commands/ants/shared.js.map +1 -0
  114. package/dist/cli/commands/ants/shared.test.d.ts +2 -0
  115. package/dist/cli/commands/ants/shared.test.d.ts.map +1 -0
  116. package/dist/cli/commands/ants/shared.test.js +25 -0
  117. package/dist/cli/commands/ants/shared.test.js.map +1 -0
  118. package/dist/cli/commands/ants/split.d.ts +3 -0
  119. package/dist/cli/commands/ants/split.d.ts.map +1 -0
  120. package/dist/cli/commands/ants/split.js +12 -0
  121. package/dist/cli/commands/ants/split.js.map +1 -0
  122. package/dist/cli/commands/ants/split.test.d.ts +2 -0
  123. package/dist/cli/commands/ants/split.test.d.ts.map +1 -0
  124. package/dist/cli/commands/ants/split.test.js +13 -0
  125. package/dist/cli/commands/ants/split.test.js.map +1 -0
  126. package/dist/cli/commands/ants/stake.d.ts +3 -0
  127. package/dist/cli/commands/ants/stake.d.ts.map +1 -0
  128. package/dist/cli/commands/ants/stake.js +15 -0
  129. package/dist/cli/commands/ants/stake.js.map +1 -0
  130. package/dist/cli/commands/ants/stake.test.d.ts +2 -0
  131. package/dist/cli/commands/ants/stake.test.d.ts.map +1 -0
  132. package/dist/cli/commands/ants/stake.test.js +17 -0
  133. package/dist/cli/commands/ants/stake.test.js.map +1 -0
  134. package/dist/cli/commands/ants/status.d.ts +9 -0
  135. package/dist/cli/commands/ants/status.d.ts.map +1 -0
  136. package/dist/cli/commands/ants/status.js +43 -0
  137. package/dist/cli/commands/ants/status.js.map +1 -0
  138. package/dist/cli/commands/ants/status.test.d.ts +2 -0
  139. package/dist/cli/commands/ants/status.test.d.ts.map +1 -0
  140. package/dist/cli/commands/ants/status.test.js +23 -0
  141. package/dist/cli/commands/ants/status.test.js.map +1 -0
  142. package/dist/cli/commands/ants/usage.d.ts +4 -0
  143. package/dist/cli/commands/ants/usage.d.ts.map +1 -0
  144. package/dist/cli/commands/ants/usage.js +31 -0
  145. package/dist/cli/commands/ants/usage.js.map +1 -0
  146. package/dist/cli/commands/ants/usage.test.d.ts +2 -0
  147. package/dist/cli/commands/ants/usage.test.d.ts.map +1 -0
  148. package/dist/cli/commands/ants/usage.test.js +15 -0
  149. package/dist/cli/commands/ants/usage.test.js.map +1 -0
  150. package/dist/cli/commands/ants/verify.d.ts +3 -0
  151. package/dist/cli/commands/ants/verify.d.ts.map +1 -0
  152. package/dist/cli/commands/ants/verify.js +51 -0
  153. package/dist/cli/commands/ants/verify.js.map +1 -0
  154. package/dist/cli/commands/ants/verify.test.d.ts +2 -0
  155. package/dist/cli/commands/ants/verify.test.d.ts.map +1 -0
  156. package/dist/cli/commands/ants/verify.test.js +51 -0
  157. package/dist/cli/commands/ants/verify.test.js.map +1 -0
  158. package/dist/cli/commands/ants/withdraw.d.ts +16 -0
  159. package/dist/cli/commands/ants/withdraw.d.ts.map +1 -0
  160. package/dist/cli/commands/ants/withdraw.js +48 -0
  161. package/dist/cli/commands/ants/withdraw.js.map +1 -0
  162. package/dist/cli/commands/ants/withdraw.test.d.ts +2 -0
  163. package/dist/cli/commands/ants/withdraw.test.d.ts.map +1 -0
  164. package/dist/cli/commands/ants/withdraw.test.js +30 -0
  165. package/dist/cli/commands/ants/withdraw.test.js.map +1 -0
  166. package/dist/cli/commands/buyer/start.d.ts.map +1 -1
  167. package/dist/cli/commands/buyer/start.js +7 -1
  168. package/dist/cli/commands/buyer/start.js.map +1 -1
  169. package/dist/cli/commands/emissions.d.ts +7 -0
  170. package/dist/cli/commands/emissions.d.ts.map +1 -1
  171. package/dist/cli/commands/emissions.js +105 -27
  172. package/dist/cli/commands/emissions.js.map +1 -1
  173. package/dist/cli/commands/emissions.test.js +7 -1
  174. package/dist/cli/commands/emissions.test.js.map +1 -1
  175. package/dist/cli/commands/network/browse.d.ts.map +1 -1
  176. package/dist/cli/commands/network/browse.js +12 -3
  177. package/dist/cli/commands/network/browse.js.map +1 -1
  178. package/dist/cli/commands/network/chain-config-helper.d.ts +21 -1
  179. package/dist/cli/commands/network/chain-config-helper.d.ts.map +1 -1
  180. package/dist/cli/commands/network/chain-config-helper.js +6 -1
  181. package/dist/cli/commands/network/chain-config-helper.js.map +1 -1
  182. package/dist/cli/commands/network/peer.d.ts.map +1 -1
  183. package/dist/cli/commands/network/peer.js +21 -1
  184. package/dist/cli/commands/network/peer.js.map +1 -1
  185. package/dist/cli/commands/parse-positive-integer.d.ts +2 -0
  186. package/dist/cli/commands/parse-positive-integer.d.ts.map +1 -0
  187. package/dist/cli/commands/parse-positive-integer.js +9 -0
  188. package/dist/cli/commands/parse-positive-integer.js.map +1 -0
  189. package/dist/cli/commands/reward-actions.d.ts +11 -0
  190. package/dist/cli/commands/reward-actions.d.ts.map +1 -0
  191. package/dist/cli/commands/reward-actions.js +22 -0
  192. package/dist/cli/commands/reward-actions.js.map +1 -0
  193. package/dist/cli/commands/seller/contract-clients.test.d.ts +2 -0
  194. package/dist/cli/commands/seller/contract-clients.test.d.ts.map +1 -0
  195. package/dist/cli/commands/seller/contract-clients.test.js +46 -0
  196. package/dist/cli/commands/seller/contract-clients.test.js.map +1 -0
  197. package/dist/cli/commands/seller/index.d.ts.map +1 -1
  198. package/dist/cli/commands/seller/index.js +4 -2
  199. package/dist/cli/commands/seller/index.js.map +1 -1
  200. package/dist/cli/commands/seller/pool.d.ts +15 -0
  201. package/dist/cli/commands/seller/pool.d.ts.map +1 -0
  202. package/dist/cli/commands/seller/pool.js +201 -0
  203. package/dist/cli/commands/seller/pool.js.map +1 -0
  204. package/dist/cli/commands/seller/pool.test.d.ts +2 -0
  205. package/dist/cli/commands/seller/pool.test.d.ts.map +1 -0
  206. package/dist/cli/commands/seller/pool.test.js +16 -0
  207. package/dist/cli/commands/seller/pool.test.js.map +1 -0
  208. package/dist/cli/commands/seller/register.d.ts.map +1 -1
  209. package/dist/cli/commands/seller/register.js +38 -8
  210. package/dist/cli/commands/seller/register.js.map +1 -1
  211. package/dist/cli/commands/seller/rewards.d.ts +13 -0
  212. package/dist/cli/commands/seller/rewards.d.ts.map +1 -0
  213. package/dist/cli/commands/seller/rewards.js +115 -0
  214. package/dist/cli/commands/seller/rewards.js.map +1 -0
  215. package/dist/cli/commands/seller/rewards.test.d.ts +2 -0
  216. package/dist/cli/commands/seller/rewards.test.d.ts.map +1 -0
  217. package/dist/cli/commands/seller/rewards.test.js +21 -0
  218. package/dist/cli/commands/seller/rewards.test.js.map +1 -0
  219. package/dist/cli/commands/seller/setup.d.ts.map +1 -1
  220. package/dist/cli/commands/seller/setup.js +2 -1
  221. package/dist/cli/commands/seller/setup.js.map +1 -1
  222. package/dist/cli/commands/seller/stake.d.ts.map +1 -1
  223. package/dist/cli/commands/seller/stake.js +104 -65
  224. package/dist/cli/commands/seller/stake.js.map +1 -1
  225. package/dist/cli/commands/seller/stake.test.d.ts +2 -0
  226. package/dist/cli/commands/seller/stake.test.d.ts.map +1 -0
  227. package/dist/cli/commands/seller/stake.test.js +99 -0
  228. package/dist/cli/commands/seller/stake.test.js.map +1 -0
  229. package/dist/cli/commands/seller/start.d.ts.map +1 -1
  230. package/dist/cli/commands/seller/start.js +6 -0
  231. package/dist/cli/commands/seller/start.js.map +1 -1
  232. package/dist/cli/commands/seller/status.d.ts.map +1 -1
  233. package/dist/cli/commands/seller/status.js +44 -2
  234. package/dist/cli/commands/seller/status.js.map +1 -1
  235. package/dist/cli/index.js +2 -0
  236. package/dist/cli/index.js.map +1 -1
  237. package/dist/cli/payment-utils.d.ts +33 -2
  238. package/dist/cli/payment-utils.d.ts.map +1 -1
  239. package/dist/cli/payment-utils.js +101 -2
  240. package/dist/cli/payment-utils.js.map +1 -1
  241. package/dist/config/types.d.ts +20 -0
  242. package/dist/config/types.d.ts.map +1 -1
  243. package/dist/plugins/verifier-evidence.test.d.ts +2 -0
  244. package/dist/plugins/verifier-evidence.test.d.ts.map +1 -0
  245. package/dist/plugins/verifier-evidence.test.js +41 -0
  246. package/dist/plugins/verifier-evidence.test.js.map +1 -0
  247. package/dist/plugins/verifier.d.ts +8 -10
  248. package/dist/plugins/verifier.d.ts.map +1 -1
  249. package/dist/plugins/verifier.js +23 -51
  250. package/dist/plugins/verifier.js.map +1 -1
  251. package/dist/plugins/verifier.test.js +1 -37
  252. package/dist/plugins/verifier.test.js.map +1 -1
  253. package/dist/proxy/buyer-proxy.d.ts +2 -1
  254. package/dist/proxy/buyer-proxy.d.ts.map +1 -1
  255. package/dist/proxy/buyer-proxy.js +104 -28
  256. package/dist/proxy/buyer-proxy.js.map +1 -1
  257. package/dist/proxy/buyer-proxy.test.js +177 -19
  258. package/dist/proxy/buyer-proxy.test.js.map +1 -1
  259. package/dist/proxy/network-models.d.ts +1 -2
  260. package/dist/proxy/network-models.d.ts.map +1 -1
  261. package/dist/proxy/network-models.js +10 -23
  262. package/dist/proxy/network-models.js.map +1 -1
  263. package/dist/proxy/network-models.test.js +56 -27
  264. package/dist/proxy/network-models.test.js.map +1 -1
  265. package/dist/proxy/tee-control.d.ts +14 -0
  266. package/dist/proxy/tee-control.d.ts.map +1 -0
  267. package/dist/proxy/tee-control.js +100 -0
  268. package/dist/proxy/tee-control.js.map +1 -0
  269. package/dist/proxy/tee-control.test.d.ts +2 -0
  270. package/dist/proxy/tee-control.test.d.ts.map +1 -0
  271. package/dist/proxy/tee-control.test.js +56 -0
  272. package/dist/proxy/tee-control.test.js.map +1 -0
  273. package/dist/proxy/tee-verification.d.ts +24 -0
  274. package/dist/proxy/tee-verification.d.ts.map +1 -0
  275. package/dist/proxy/tee-verification.js +128 -0
  276. package/dist/proxy/tee-verification.js.map +1 -0
  277. package/dist/proxy/tee-verification.test.d.ts +2 -0
  278. package/dist/proxy/tee-verification.test.d.ts.map +1 -0
  279. package/dist/proxy/tee-verification.test.js +241 -0
  280. package/dist/proxy/tee-verification.test.js.map +1 -0
  281. package/package.json +8 -6
  282. package/dist/cli/commands/seller/emissions.d.ts +0 -3
  283. package/dist/cli/commands/seller/emissions.d.ts.map +0 -1
  284. package/dist/cli/commands/seller/emissions.js +0 -5
  285. 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, computeOnChainReputationScore, decodeSweepRequest, faultAttributionOf, faultCodeOf, isModelRouteEligible, modelRouteTotalPrice, peerSupportsCooperativeClose, rankModelRoutes, } from '@antseed/node';
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, normalizedModelReputationScore, parseModelTypeFilter, } from './network-models.js';
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 { getCachedVerdict, runVerifier, verifierSupportFingerprint } from '../plugins/verifier.js';
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
- if (typeof entry.displayName === 'string')
383
- peer.displayName = entry.displayName;
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
- if (peer.onChainReputationScore === undefined) {
470
- const derivedScore = computeOnChainReputationScore(peer, nowMs);
471
- if (derivedScore !== null)
472
- peer.onChainReputationScore = derivedScore;
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
- _verifyCache = new Map();
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/Staking.
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 staking/channel RPC and reputation-score implementations.
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
- // Fallback keeps pre-upgrade cache rows usable.
1045
- onChainReputationScore: p.onChainReputationScore ?? computeOnChainReputationScore(p) ?? null,
1046
- onChainTrustScore: p.onChainTrustScore ?? null,
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 VPR, but no route is set. `
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, this._now()) ?? -1,
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 key = `${peer.peerId}|${verifierSupportFingerprint(peer.capabilities)}`;
2426
- return getCachedVerdict(this._verifyCache, key, Date.now(), this._peerCacheTtlMs, VERIFY_CACHE_MAX_ENTRIES, () => runVerifier(policy, peer.peerId, peer.capabilities, makeReach, signal));
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'];