@stelis/say-ur-intent 0.0.0 → 0.0.2

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 (234) hide show
  1. package/README.md +4 -39
  2. package/dist/adapters/adapterLifecycleValidators.js +7 -0
  3. package/dist/adapters/adapterPromptSurfaces.js +71 -0
  4. package/dist/adapters/deepbook/deepbookHumanReviewProducer.js +175 -0
  5. package/dist/adapters/deepbook/deepbookQuotePolicy.js +112 -0
  6. package/dist/adapters/deepbook/deepbookReviewEvidence.js +507 -0
  7. package/dist/adapters/deepbook/deepbookReviewLifecycle.js +85 -0
  8. package/dist/adapters/deepbook/deepbookSwapIntent.js +79 -0
  9. package/dist/adapters/deepbook/deepbookTransactionMaterialProducer.js +269 -0
  10. package/dist/adapters/flowx/flowxSwapHumanReviewProducer.js +176 -0
  11. package/dist/adapters/flowx/flowxSwapIntent.js +79 -0
  12. package/dist/adapters/flowx/flowxSwapQuotePolicy.js +104 -0
  13. package/dist/adapters/flowx/flowxSwapReviewEvidence.js +468 -0
  14. package/dist/adapters/flowx/flowxSwapReviewLifecycle.js +85 -0
  15. package/dist/adapters/flowx/flowxSwapTransactionMaterialProducer.js +362 -0
  16. package/dist/adapters/intentPlanFactories.js +59 -0
  17. package/dist/adapters/reviewAdapters.js +81 -0
  18. package/dist/core/action/adapterLifecycleValidation.js +12 -0
  19. package/dist/core/action/forbiddenFields.js +43 -0
  20. package/dist/core/action/humanReadableReviewEvidence.js +203 -0
  21. package/dist/core/action/humanReadableReviewProjectionVerifier.js +29 -0
  22. package/dist/core/action/ptbVisualizationProducer.js +66 -0
  23. package/dist/core/action/reviewCheckResults.js +6 -0
  24. package/dist/core/action/reviewStateValidation.js +11 -0
  25. package/dist/core/action/reviewTimeSimulationEvidence.js +471 -0
  26. package/dist/core/action/schemas.js +529 -0
  27. package/dist/core/action/signableAdapterContract.js +993 -0
  28. package/dist/core/action/swapHumanReadableReviewProjection.js +124 -0
  29. package/dist/core/action/swapQuotePolicyEvidence.js +278 -0
  30. package/dist/core/action/transactionObjectOwnershipEvidence.js +247 -0
  31. package/dist/core/action/transactionObjectOwnershipProducer.js +329 -0
  32. package/dist/core/action/types.js +35 -0
  33. package/dist/core/action/walletReviewContractAssembler.js +282 -0
  34. package/dist/core/activity/activityStore.js +15 -0
  35. package/dist/core/activity/localDataService.js +258 -0
  36. package/dist/core/activity/localDataTypes.js +11 -0
  37. package/dist/core/activity/localDataValidation.js +396 -0
  38. package/dist/core/activity/schemaVersion.js +1 -0
  39. package/dist/core/activity/sqliteActivityStore.js +820 -0
  40. package/dist/core/activity/sqliteActivityStoreRows.js +430 -0
  41. package/dist/core/activity/sqliteActivityStoreSchema.js +258 -0
  42. package/dist/core/activity/sqliteActivityStoreTypes.js +5 -0
  43. package/dist/core/activity/suiFunctionTarget.js +43 -0
  44. package/dist/core/activity/transactionActivityAccountEffects.js +189 -0
  45. package/dist/core/activity/transactionActivityAnalysis.js +295 -0
  46. package/dist/core/activity/transactionActivityClassifier.js +306 -0
  47. package/dist/core/activity/transactionActivityDetails.js +229 -0
  48. package/dist/core/activity/transactionActivityProtocolRules.js +218 -0
  49. package/dist/core/activity/transactionActivityScanPolicy.js +170 -0
  50. package/dist/core/activity/transactionActivityService.js +379 -0
  51. package/dist/core/activity/transactionActivityTypes.js +18 -0
  52. package/dist/core/eventlog/sink.js +35 -0
  53. package/dist/core/evidence/settlementFamilies.js +87 -0
  54. package/dist/core/evidence/userAnswerUse.js +1 -0
  55. package/dist/core/numeric/rawU64.js +63 -0
  56. package/dist/core/preferences/preferencesStore.js +26 -0
  57. package/dist/core/preferences/sqlitePreferencesRepository.js +136 -0
  58. package/dist/core/proposal/externalProposalReview.js +347 -0
  59. package/dist/core/proposal/schemas.js +208 -0
  60. package/dist/core/proposal/types.js +35 -0
  61. package/dist/core/read/amounts.js +14 -0
  62. package/dist/core/read/coinMetadata.js +60 -0
  63. package/dist/core/read/deepbookRawQuoteClient.js +86 -0
  64. package/dist/core/read/deepbookReadHelpers.js +265 -0
  65. package/dist/core/read/deepbookRegistry.js +133 -0
  66. package/dist/core/read/flowxQuoteClient.js +117 -0
  67. package/dist/core/read/flowxReadHelpers.js +145 -0
  68. package/dist/core/read/flowxRegistry.js +174 -0
  69. package/dist/core/read/intentEvidenceResponseFormatting.js +228 -0
  70. package/dist/core/read/readResponseGuidance.js +451 -0
  71. package/dist/core/read/readService.js +1164 -0
  72. package/dist/core/read/readServiceTypes.js +59 -0
  73. package/dist/core/read/settlementParityFormatting.js +82 -0
  74. package/dist/core/read/walletReadHelpers.js +99 -0
  75. package/dist/core/review/reviewChecks.js +54 -0
  76. package/dist/core/review/reviewComputation.js +38 -0
  77. package/dist/core/review/reviewComputationResult.js +87 -0
  78. package/dist/core/session/localSession.js +31 -0
  79. package/dist/core/session/privateReviewArtifacts.js +73 -0
  80. package/dist/core/session/sessionErrors.js +9 -0
  81. package/dist/core/session/sessionStore.js +821 -0
  82. package/dist/core/session/settingsSession.js +1 -0
  83. package/dist/core/session/settingsSessions.js +43 -0
  84. package/dist/core/session/status.js +86 -0
  85. package/dist/core/session/transactionMaterialStore.js +205 -0
  86. package/dist/core/session/wait.js +102 -0
  87. package/dist/core/session/walletIdentity.js +103 -0
  88. package/dist/core/session/walletIdentitySessions.js +189 -0
  89. package/dist/core/suiAddress.js +18 -0
  90. package/dist/core/suiEndpoint.js +72 -0
  91. package/dist/mcp/activeAccountResponse.js +24 -0
  92. package/dist/mcp/prompts.js +146 -0
  93. package/dist/mcp/registerTool.js +19 -0
  94. package/dist/mcp/resources.js +72 -0
  95. package/dist/mcp/responseGuidance.js +381 -0
  96. package/dist/mcp/result.js +17 -0
  97. package/dist/mcp/schemas.js +8 -0
  98. package/dist/mcp/server.js +30 -0
  99. package/dist/mcp/serverInfo.js +123 -0
  100. package/dist/mcp/toolErrors.js +105 -0
  101. package/dist/mcp/toolNames.js +50 -0
  102. package/dist/mcp/tools/account/index.js +44 -0
  103. package/dist/mcp/tools/action/prepareSuiActionReview.js +120 -0
  104. package/dist/mcp/tools/read/commonSchemas.js +43 -0
  105. package/dist/mcp/tools/read/deepbookReadTools.js +453 -0
  106. package/dist/mcp/tools/read/flowxReadTools.js +135 -0
  107. package/dist/mcp/tools/read/index.js +16 -0
  108. package/dist/mcp/tools/read/readToolHelpers.js +68 -0
  109. package/dist/mcp/tools/read/reviewActivityTools.js +176 -0
  110. package/dist/mcp/tools/read/serverStatusTools.js +103 -0
  111. package/dist/mcp/tools/read/transactionActivityOutput.js +300 -0
  112. package/dist/mcp/tools/read/transactionActivityTools.js +544 -0
  113. package/dist/mcp/tools/read/walletReadTools.js +733 -0
  114. package/dist/mcp/tools/session/executionResultTools.js +92 -0
  115. package/dist/mcp/tools/session/index.js +8 -0
  116. package/dist/mcp/tools/session/shared.js +79 -0
  117. package/dist/mcp/tools/session/statusTools.js +134 -0
  118. package/dist/mcp/tools/session/walletIdentityTools.js +119 -0
  119. package/dist/mcp/tools/settings/index.js +64 -0
  120. package/dist/review-app/analysis.css +1 -0
  121. package/dist/review-app/analysis.js +1 -0
  122. package/dist/review-app/arc-BjIacwQm.js +1 -0
  123. package/dist/review-app/architecture-U656AL7Q-aSB9x1OK.js +1 -0
  124. package/dist/review-app/architectureDiagram-VXUJARFQ-C5W6re2I.js +36 -0
  125. package/dist/review-app/array-BmXUUrU6.js +1 -0
  126. package/dist/review-app/blockDiagram-VD42YOAC-20MLNcUm.js +122 -0
  127. package/dist/review-app/c4Diagram-YG6GDRKO-BZXRrcck.js +10 -0
  128. package/dist/review-app/channel-lk2p_CUu.js +1 -0
  129. package/dist/review-app/chunk-4BX2VUAB-BPITOdjX.js +1 -0
  130. package/dist/review-app/chunk-55IACEB6-Dz-pyw5k.js +1 -0
  131. package/dist/review-app/chunk-76Q3JFCE-cK_X1P_l.js +1 -0
  132. package/dist/review-app/chunk-ABZYJK2D-Dt4W53JI.js +81 -0
  133. package/dist/review-app/chunk-ATLVNIR6-fZHLXURb.js +1 -0
  134. package/dist/review-app/chunk-B4BG7PRW-BbgcjusC.js +165 -0
  135. package/dist/review-app/chunk-BJD4TVEz.js +1 -0
  136. package/dist/review-app/chunk-CVBHYZKI-CViawAKX.js +1 -0
  137. package/dist/review-app/chunk-DI55MBZ5-C5aoul-d.js +220 -0
  138. package/dist/review-app/chunk-FMBD7UC4-Chxmw62A.js +15 -0
  139. package/dist/review-app/chunk-FPAJGGOC-DDHjQ09H.js +80 -0
  140. package/dist/review-app/chunk-FWNWRKHM-CVVQUptk.js +1 -0
  141. package/dist/review-app/chunk-HN2XXSSU-yzNpjaSZ.js +1 -0
  142. package/dist/review-app/chunk-JA3XYJ7Z-C5ZJdU01.js +70 -0
  143. package/dist/review-app/chunk-JZLCHNYA-BBST4Cnk.js +54 -0
  144. package/dist/review-app/chunk-LBM3YZW2-CdwAPuHr.js +1 -0
  145. package/dist/review-app/chunk-LHMN2FUI-BtB5uDcp.js +1 -0
  146. package/dist/review-app/chunk-O7ZBX7Z2-pxdK4Sa3.js +1 -0
  147. package/dist/review-app/chunk-QN33PNHL-CbVv3uGK.js +1 -0
  148. package/dist/review-app/chunk-QXUST7PY-DKM2-t2c.js +7 -0
  149. package/dist/review-app/chunk-QZHKN3VN-C5ni2pN_.js +1 -0
  150. package/dist/review-app/chunk-S3R3BYOJ-BWvOhDs0.js +2 -0
  151. package/dist/review-app/chunk-S6J4BHB3-D9Fk0YeD.js +1 -0
  152. package/dist/review-app/chunk-T53DSG4Q-C1qEyzyV.js +1 -0
  153. package/dist/review-app/chunk-TZMSLE5B-B--7eU69.js +1 -0
  154. package/dist/review-app/classDiagram-2ON5EDUG-DlL1m2bp.js +1 -0
  155. package/dist/review-app/classDiagram-v2-WZHVMYZB-FXRskT1j.js +1 -0
  156. package/dist/review-app/clone-BZZb7gpZ.js +1 -0
  157. package/dist/review-app/cose-bilkent-S5V4N54A-CRIb8XEO.js +1 -0
  158. package/dist/review-app/cytoscape.esm-C7jYqDP5.js +321 -0
  159. package/dist/review-app/dagre-6UL2VRFP-FNCAXbdE.js +4 -0
  160. package/dist/review-app/dagre-Be46QtUd.js +1 -0
  161. package/dist/review-app/defaultLocale-BaWNtAUL.js +1 -0
  162. package/dist/review-app/diagram-PSM6KHXK-ylLWjiNM.js +24 -0
  163. package/dist/review-app/diagram-QEK2KX5R-BCDcESxs.js +43 -0
  164. package/dist/review-app/diagram-S2PKOQOG-Vdrc-vrO.js +24 -0
  165. package/dist/review-app/dist-WPc74x_f.js +1 -0
  166. package/dist/review-app/erDiagram-Q2GNP2WA-E5ZsUbDF.js +60 -0
  167. package/dist/review-app/flatten-DHf9IeNI.js +1 -0
  168. package/dist/review-app/flowDiagram-NV44I4VS-DBSQuj6x.js +162 -0
  169. package/dist/review-app/ganttDiagram-LVOFAZNH-CKUOsqwl.js +267 -0
  170. package/dist/review-app/gitGraph-F6HP7TQM-DsAD6qK1.js +1 -0
  171. package/dist/review-app/gitGraphDiagram-NY62KEGX-BCeIMWdl.js +65 -0
  172. package/dist/review-app/graphlib-CiX5CXxR.js +1 -0
  173. package/dist/review-app/http-DMvwuuFk.js +1 -0
  174. package/dist/review-app/identity-DY8PXc6t.js +1 -0
  175. package/dist/review-app/info-NVLQJR56-Dlx1nZic.js +1 -0
  176. package/dist/review-app/infoDiagram-F6ZHWCRC-CAuANIrz.js +2 -0
  177. package/dist/review-app/init-BvqephKz.js +1 -0
  178. package/dist/review-app/journeyDiagram-XKPGCS4Q-C-Z9phnx.js +139 -0
  179. package/dist/review-app/kanban-definition-3W4ZIXB7-DufgZABq.js +89 -0
  180. package/dist/review-app/katex-B-Z-NXXN.js +257 -0
  181. package/dist/review-app/line-DiIv3Jgw.js +1 -0
  182. package/dist/review-app/linear-Cv-UPvo1.js +1 -0
  183. package/dist/review-app/math-kmyYrkHL.js +1 -0
  184. package/dist/review-app/mermaid-parser.core-DkwUYTPl.js +4 -0
  185. package/dist/review-app/mindmap-definition-VGOIOE7T-TM_CqdmV.js +68 -0
  186. package/dist/review-app/ordinal-BliTlkoG.js +1 -0
  187. package/dist/review-app/packet-BFZMPI3H-DqbnU92v.js +1 -0
  188. package/dist/review-app/path-AEo9W6mQ.js +1 -0
  189. package/dist/review-app/pie-7BOR55EZ-LJzaLkgr.js +1 -0
  190. package/dist/review-app/pieDiagram-ADFJNKIX-BAs8OfRS.js +30 -0
  191. package/dist/review-app/quadrantDiagram-AYHSOK5B-CyUDZP5S.js +7 -0
  192. package/dist/review-app/radar-NHE76QYJ-DBpHc8_Y.js +1 -0
  193. package/dist/review-app/reduce-B-HuPpdd.js +1 -0
  194. package/dist/review-app/requirementDiagram-UZGBJVZJ-BEHix78P.js +64 -0
  195. package/dist/review-app/review.css +1 -0
  196. package/dist/review-app/review.js +43 -0
  197. package/dist/review-app/sankeyDiagram-TZEHDZUN-B2bKbmsm.js +10 -0
  198. package/dist/review-app/sequenceDiagram-WL72ISMW-DVLOORFJ.js +145 -0
  199. package/dist/review-app/settings.css +1 -0
  200. package/dist/review-app/settings.js +1 -0
  201. package/dist/review-app/src-Buml7cM5.js +1 -0
  202. package/dist/review-app/stateDiagram-FKZM4ZOC-sFGGp2kV.js +1 -0
  203. package/dist/review-app/stateDiagram-v2-4FDKWEC3-BHfCF4dX.js +1 -0
  204. package/dist/review-app/timeline-definition-IT6M3QCI-BESnBijC.js +61 -0
  205. package/dist/review-app/treemap-KMMF4GRG-wnVLBDeQ.js +1 -0
  206. package/dist/review-app/walletStatus-CcojOdGy.js +7 -0
  207. package/dist/review-app/xychartDiagram-PRI3JC2R-BGWVfCx4.js +7 -0
  208. package/dist/review-server/assets.js +48 -0
  209. package/dist/review-server/html.js +66 -0
  210. package/dist/review-server/http.js +47 -0
  211. package/dist/review-server/middleware/hostOrigin.js +48 -0
  212. package/dist/review-server/middleware/reviewToken.js +7 -0
  213. package/dist/review-server/reviewServerPolicy.js +10 -0
  214. package/dist/review-server/server.js +568 -0
  215. package/dist/review-server/settingsApi.js +182 -0
  216. package/dist/review-server/walletIdentityResponse.js +13 -0
  217. package/dist/runtime/config.js +103 -0
  218. package/dist/runtime/localSettingsService.js +198 -0
  219. package/dist/runtime/logger.js +50 -0
  220. package/dist/runtime/reviewServerAcquire.js +128 -0
  221. package/dist/runtime/smokeMainnetRead.js +529 -0
  222. package/dist/runtime/smokeMainnetReadAssertions.js +308 -0
  223. package/dist/runtime/start.js +295 -0
  224. package/dist/runtime/suiEndpoint.js +97 -0
  225. package/dist/runtime/suiTransactionGraphqlMapping.js +200 -0
  226. package/dist/runtime/suiTransactionGraphqlQueries.js +231 -0
  227. package/dist/runtime/suiTransactionGraphqlSource.js +148 -0
  228. package/docs/AGENT_BEHAVIOR.md +1 -1
  229. package/docs/AGENT_DEVELOPMENT_POLICY.md +20 -0
  230. package/docs/FRONTEND_POLICY.md +4 -3
  231. package/docs/MCP_SETUP.md +59 -7
  232. package/docs/MCP_TOOLS.md +1 -1
  233. package/docs/SDK_API.md +5 -1
  234. package/package.json +3 -2
@@ -0,0 +1,453 @@
1
+ import { mainnetPools } from "@mysten/deepbook-v3";
2
+ import { z } from "zod";
3
+ import { unknownRecordSchema } from "../../../core/action/schemas.js";
4
+ import { DEEPBOOK_SCALAR_UNIT_SOURCE } from "../../../core/read/coinMetadata.js";
5
+ import { DEEPBOOK_MID_PRICE_DIRECTION, DEEPBOOK_MID_PRICE_PRECISION, DEEPBOOK_MID_PRICE_SEMANTICS_KIND, DEEPBOOK_MID_PRICE_TYPE, DEEPBOOK_ACCOUNT_QUANTITY_KIND, DEEPBOOK_QUOTE_QUANTITY_KIND, DEFAULT_DEEPBOOK_SIMULATION_SENDER, MAX_DEEPBOOK_ACCOUNT_OPEN_ORDER_IDS, MAX_DEEPBOOK_ORDERBOOK_TICKS } from "../../../core/read/readService.js";
6
+ import { noParamsInputSchema, successOutputSchema } from "../../schemas.js";
7
+ import { errorToolResult, okToolResult } from "../../result.js";
8
+ import { activityStoreToolError } from "../../toolErrors.js";
9
+ import { TOOL_NAMES } from "../../toolNames.js";
10
+ import { fetchedAtSchema, readSourceSchema, userAnswerUseSchema } from "./commonSchemas.js";
11
+ import { readServiceError } from "./readToolHelpers.js";
12
+ const deepbookMidPriceSourceSchema = z.object({
13
+ sdk: z.string(),
14
+ transport: z.literal("grpc"),
15
+ simulation: z.literal("client.core.simulateTransaction"),
16
+ method: z.literal("midPrice"),
17
+ precision: z.literal(DEEPBOOK_MID_PRICE_PRECISION)
18
+ });
19
+ const deepbookDisplayQuoteSourceSchema = z.object({
20
+ sdk: z.literal("@mysten/deepbook-v3"),
21
+ transport: z.literal("grpc"),
22
+ simulation: z.literal("client.core.simulateTransaction"),
23
+ method: z.enum(["getQuoteQuantityOut", "getBaseQuantityOut"]),
24
+ returnValueEncoding: z.literal("bcs.u64")
25
+ });
26
+ const deepbookAccountInventorySourceSchema = z.object({
27
+ sdk: z.literal("@mysten/deepbook-v3"),
28
+ transport: z.literal("grpc"),
29
+ simulation: z.literal("client.core.simulateTransaction"),
30
+ methods: z.array(z.enum(["getBalanceManagerIds", "accountExists", "account", "lockedBalance", "accountOpenOrders"]))
31
+ });
32
+ const deepbookDisplayAccountBalancesSchema = z.object({
33
+ base: z.number().refine(Number.isFinite),
34
+ quote: z.number().refine(Number.isFinite),
35
+ deep: z.number().refine(Number.isFinite)
36
+ });
37
+ const deepbookAccountQuantitySemanticsSchema = z.object({
38
+ kind: z.literal(DEEPBOOK_ACCOUNT_QUANTITY_KIND),
39
+ rawAmountAvailable: z.literal(false),
40
+ notFor: z.tuple([
41
+ z.literal("signing"),
42
+ z.literal("funding"),
43
+ z.literal("route_liquidity"),
44
+ z.literal("withdrawal_readiness"),
45
+ z.literal("transaction_building")
46
+ ])
47
+ });
48
+ const deepbookMidPriceSemanticsSchema = z.object({
49
+ kind: z.literal(DEEPBOOK_MID_PRICE_SEMANTICS_KIND),
50
+ allowedUse: z.literal("deepbook_pool_mid_price_snapshot"),
51
+ globalMarketPriceAvailable: z.literal(false),
52
+ fiatUsdCashOutAvailable: z.literal(false),
53
+ externalMarketPriceConversionAvailable: z.literal(false),
54
+ externalMarketLookupAvailable: z.literal(false),
55
+ usdPegAssumptionAvailable: z.literal(false),
56
+ bankCashOutEstimateAvailable: z.literal(false),
57
+ quoteComparisonAvailable: z.literal(false),
58
+ priceImpactAvailable: z.literal(false),
59
+ venueComparisonAvailable: z.literal(false),
60
+ routeRecommendationAvailable: z.literal(false),
61
+ profitAndLossAvailable: z.literal(false),
62
+ costBasisAvailable: z.literal(false),
63
+ notFor: z.tuple([
64
+ z.literal("global_market_price"),
65
+ z.literal("fiat_usd_cash_out"),
66
+ z.literal("external_market_price_conversion"),
67
+ z.literal("external_market_lookup"),
68
+ z.literal("usd_peg_assumption"),
69
+ z.literal("bank_cash_out_estimate"),
70
+ z.literal("price_impact"),
71
+ z.literal("mid_price_slippage"),
72
+ z.literal("quote_vs_mid_slippage"),
73
+ z.literal("effective_quote_price"),
74
+ z.literal("venue_comparison"),
75
+ z.literal("best_route"),
76
+ z.literal("route_recommendation"),
77
+ z.literal("transaction_building"),
78
+ z.literal("signing_data"),
79
+ z.literal("signing_readiness"),
80
+ z.literal("profit_or_pnl"),
81
+ z.literal("cost_basis")
82
+ ])
83
+ });
84
+ const deepbookQuoteQuantitySemanticsSchema = z.object({
85
+ kind: z.literal(DEEPBOOK_QUOTE_QUANTITY_KIND),
86
+ inputAmountKind: z.enum(["raw_u64", "display_source_amount_converted_to_raw_u64"]),
87
+ allowedUse: z.literal("indicative_deepbook_pool_quote"),
88
+ rawAmountAvailable: z.literal(true),
89
+ rawEvidenceField: z.literal("rawQuote"),
90
+ paymentCoverageAvailable: z.literal(false),
91
+ shortfallContributionAvailable: z.literal(false),
92
+ routeDependentPaymentSupportAvailable: z.literal(false),
93
+ requiresIntentEvidenceForCoverage: z.literal(true),
94
+ canUseForPaymentAnswer: z.literal(false),
95
+ canUseForShortfallAnswer: z.literal(false),
96
+ doNotCombineWithPaymentAnswer: z.literal(true),
97
+ requiredPaymentAnswerTool: z.literal("read.preview_intent_evidence"),
98
+ paymentAnswerUseBlockedReason: z.literal("quote_output_is_price_reference_not_payment_answer"),
99
+ requiredPaymentAnswerField: z.literal("responseSummary"),
100
+ fiatUsdCashOutAvailable: z.literal(false),
101
+ externalMarketPriceConversionAvailable: z.literal(false),
102
+ externalMarketLookupAvailable: z.literal(false),
103
+ usdPegAssumptionAvailable: z.literal(false),
104
+ bankCashOutEstimateAvailable: z.literal(false),
105
+ profitAndLossAvailable: z.literal(false),
106
+ costBasisAvailable: z.literal(false),
107
+ priceImpactAvailable: z.literal(false),
108
+ midPriceSlippageAvailable: z.literal(false),
109
+ venueComparisonAvailable: z.literal(false),
110
+ routeRecommendationAvailable: z.literal(false),
111
+ notFor: z.tuple([
112
+ z.literal("signing"),
113
+ z.literal("funding"),
114
+ z.literal("payment_coverage"),
115
+ z.literal("shortfall_contribution"),
116
+ z.literal("route_dependent_payment_support"),
117
+ z.literal("route_liquidity"),
118
+ z.literal("min_out"),
119
+ z.literal("liquidity_verdict"),
120
+ z.literal("price_impact"),
121
+ z.literal("mid_price_slippage"),
122
+ z.literal("quote_vs_mid_slippage"),
123
+ z.literal("effective_price"),
124
+ z.literal("venue_comparison"),
125
+ z.literal("best_route"),
126
+ z.literal("route_recommendation"),
127
+ z.literal("transaction_building"),
128
+ z.literal("fiat_usd_cash_out"),
129
+ z.literal("external_market_price_conversion"),
130
+ z.literal("external_market_lookup"),
131
+ z.literal("usd_peg_assumption"),
132
+ z.literal("bank_cash_out_estimate"),
133
+ z.literal("profit_or_pnl"),
134
+ z.literal("cost_basis")
135
+ ])
136
+ });
137
+ const deepbookDisplayQuoteInputAmountSchema = z.object({
138
+ display: z.string(),
139
+ raw: z.string().regex(/^[1-9]\d*$/),
140
+ asset: z.object({
141
+ symbol: z.string(),
142
+ coinType: z.string(),
143
+ decimals: z.number().int().nonnegative(),
144
+ unitSource: z.literal(DEEPBOOK_SCALAR_UNIT_SOURCE)
145
+ })
146
+ });
147
+ const deepbookDisplayQuoteSchema = z.object({
148
+ baseOut: z.string().regex(/^\d+(?:\.\d+)?$/),
149
+ quoteOut: z.string().regex(/^\d+(?:\.\d+)?$/),
150
+ deepRequired: z.string().regex(/^\d+(?:\.\d+)?$/)
151
+ });
152
+ const deepbookRawQuoteAmountSchema = z.object({
153
+ raw: z.string().regex(/^\d+$/),
154
+ symbol: z.string(),
155
+ coinType: z.string(),
156
+ decimals: z.number().int().nonnegative(),
157
+ unitSource: z.literal(DEEPBOOK_SCALAR_UNIT_SOURCE)
158
+ });
159
+ const deepbookRawQuoteSchema = z.object({
160
+ kind: z.literal("deepbook_quote_raw_u64"),
161
+ sourceMoveFunction: z.enum(["pool::get_quote_quantity_out", "pool::get_base_quantity_out"]),
162
+ returnValueSourceMoveFunction: z.literal("pool::get_quantity_out"),
163
+ returnValueOrder: z.tuple([
164
+ z.literal("base_quantity_out"),
165
+ z.literal("quote_quantity_out"),
166
+ z.literal("deep_quantity_required")
167
+ ]),
168
+ inputAmount: deepbookRawQuoteAmountSchema,
169
+ baseOut: deepbookRawQuoteAmountSchema,
170
+ quoteOut: deepbookRawQuoteAmountSchema,
171
+ deepRequired: deepbookRawQuoteAmountSchema,
172
+ directionalOutput: deepbookRawQuoteAmountSchema,
173
+ boundary: z.object({
174
+ outputBeforeSlippagePolicy: z.literal(true),
175
+ notFor: z.tuple([
176
+ z.literal("final_min_out"),
177
+ z.literal("transaction_building"),
178
+ z.literal("signing_data"),
179
+ z.literal("signing_readiness"),
180
+ z.literal("price_impact"),
181
+ z.literal("mid_price_slippage"),
182
+ z.literal("quote_vs_mid_slippage"),
183
+ z.literal("effective_price"),
184
+ z.literal("venue_comparison"),
185
+ z.literal("best_route"),
186
+ z.literal("route_recommendation"),
187
+ z.literal("fiat_usd_cash_out"),
188
+ z.literal("external_market_price_conversion"),
189
+ z.literal("external_market_lookup"),
190
+ z.literal("usd_peg_assumption"),
191
+ z.literal("bank_cash_out_estimate"),
192
+ z.literal("profit_or_pnl"),
193
+ z.literal("cost_basis")
194
+ ])
195
+ })
196
+ });
197
+ const deepbookAccountInventoryDetailStatusSchema = z.enum([
198
+ "manager_discovery_only",
199
+ "pool_key_required",
200
+ "manager_address_required",
201
+ "manager_address_not_discovered_for_active_account",
202
+ "account_not_found",
203
+ "available"
204
+ ]);
205
+ const deepbookAccountSummarySchema = z.object({
206
+ epoch: z.string(),
207
+ settledBalances: deepbookDisplayAccountBalancesSchema,
208
+ owedBalances: deepbookDisplayAccountBalancesSchema,
209
+ unclaimedRebates: deepbookDisplayAccountBalancesSchema
210
+ });
211
+ const deepbookTokenRegistryEntrySchema = z.object({
212
+ symbol: z.string(),
213
+ address: z.string(),
214
+ type: z.string(),
215
+ scalar: z.number(),
216
+ decimals: z.number().int().nonnegative(),
217
+ unitSource: z.literal(DEEPBOOK_SCALAR_UNIT_SOURCE),
218
+ feed: z.string().optional(),
219
+ currencyId: z.string().optional(),
220
+ priceInfoObjectId: z.string().optional(),
221
+ poolKeys: z.array(z.string())
222
+ });
223
+ export function registerDeepbookReadTools(server, deps) {
224
+ server.registerTool(TOOL_NAMES.readListDeepbookPools, {
225
+ title: "List DeepBook pools",
226
+ description: "List DeepBook mainnet pools from pinned SDK constants. Static registry only; not live liquidity.",
227
+ inputSchema: noParamsInputSchema,
228
+ outputSchema: successOutputSchema({
229
+ source: z.string(),
230
+ pools: z.array(unknownRecordSchema)
231
+ }),
232
+ annotations: { readOnlyHint: true, openWorldHint: false }
233
+ }, async () => okToolResult({
234
+ source: "@mysten/deepbook-v3 mainnetPools",
235
+ pools: Object.entries(mainnetPools).map(([key, pool]) => ({ key, ...pool }))
236
+ }));
237
+ server.registerTool(TOOL_NAMES.readListDeepbookTokens, {
238
+ title: "List DeepBook tokens",
239
+ description: "List DeepBook mainnet tokens from the pinned SDK constants.",
240
+ inputSchema: noParamsInputSchema,
241
+ outputSchema: successOutputSchema({
242
+ source: z.string(),
243
+ tokens: z.array(deepbookTokenRegistryEntrySchema)
244
+ }),
245
+ annotations: { readOnlyHint: true, openWorldHint: false }
246
+ }, async () => {
247
+ try {
248
+ return okToolResult({
249
+ source: "@mysten/deepbook-v3 mainnetCoins",
250
+ tokens: deps.readService.listDeepbookTokenRegistry()
251
+ });
252
+ }
253
+ catch (error) {
254
+ return readServiceError(error, deps);
255
+ }
256
+ });
257
+ server.registerTool(TOOL_NAMES.readInspectDeepbookOrderbook, {
258
+ title: "Inspect DeepBook orderbook",
259
+ description: "Return a pinned-SDK DeepBook mainnet orderbook snapshot at fetchedAt. Not a live stream.",
260
+ inputSchema: {
261
+ poolKey: z.string().min(1),
262
+ ticks: z.number().int().min(1).max(MAX_DEEPBOOK_ORDERBOOK_TICKS).optional()
263
+ },
264
+ outputSchema: successOutputSchema({
265
+ status: z.literal("ok"),
266
+ poolKey: z.string().optional(),
267
+ ticks: z.number().int().positive().optional(),
268
+ fetchedAt: fetchedAtSchema.optional(),
269
+ userAnswerUse: userAnswerUseSchema,
270
+ source: readSourceSchema.optional(),
271
+ midPrice: z.number().optional(),
272
+ poolBookParams: unknownRecordSchema.optional(),
273
+ level2TicksFromMid: unknownRecordSchema.optional()
274
+ }),
275
+ annotations: { readOnlyHint: true, openWorldHint: false }
276
+ }, async ({ poolKey, ticks }) => {
277
+ try {
278
+ return okToolResult(await deps.readService.inspectDeepbookOrderbook({
279
+ poolKey,
280
+ ticks: ticks ?? 5,
281
+ simulationSender: DEFAULT_DEEPBOOK_SIMULATION_SENDER
282
+ }));
283
+ }
284
+ catch (error) {
285
+ return readServiceError(error, deps);
286
+ }
287
+ });
288
+ server.registerTool(TOOL_NAMES.readGetDeepbookMidPrice, {
289
+ title: "Get DeepBook mid price",
290
+ description: "Return a DeepBook pool mid-price snapshot. Not price impact, route quality, global market price, fiat cash-out, transaction building, or signing readiness.",
291
+ inputSchema: {
292
+ poolKey: z.string().min(1)
293
+ },
294
+ outputSchema: successOutputSchema({
295
+ status: z.literal("ok"),
296
+ poolKey: z.string(),
297
+ base: z.string(),
298
+ quote: z.string(),
299
+ price: z.number(),
300
+ userAnswerUse: userAnswerUseSchema,
301
+ priceDirection: z.literal(DEEPBOOK_MID_PRICE_DIRECTION),
302
+ priceType: z.literal(DEEPBOOK_MID_PRICE_TYPE),
303
+ fetchedAt: fetchedAtSchema,
304
+ source: deepbookMidPriceSourceSchema,
305
+ priceSemantics: deepbookMidPriceSemanticsSchema
306
+ }),
307
+ annotations: { readOnlyHint: true, openWorldHint: false }
308
+ }, async ({ poolKey }) => {
309
+ try {
310
+ return okToolResult(await deps.readService.getDeepbookMidPrice({
311
+ poolKey,
312
+ simulationSender: DEFAULT_DEEPBOOK_SIMULATION_SENDER
313
+ }));
314
+ }
315
+ catch (error) {
316
+ return readServiceError(error, deps);
317
+ }
318
+ });
319
+ server.registerTool(TOOL_NAMES.readQuoteDeepbookAction, {
320
+ title: "Quote DeepBook action",
321
+ description: "Pinned-SDK DeepBook raw-quantity quote evidence. Not P&L, price impact, route quality, fiat cash-out, external USD lookup, signing data, or execution promise.",
322
+ inputSchema: {
323
+ poolKey: z.string().min(1),
324
+ direction: z.enum(["base_to_quote", "quote_to_base"]),
325
+ amountRaw: z.string().regex(/^[1-9]\d*$/)
326
+ },
327
+ outputSchema: successOutputSchema({
328
+ status: z.literal("ok"),
329
+ poolKey: z.string().optional(),
330
+ direction: z.enum(["base_to_quote", "quote_to_base"]).optional(),
331
+ amountRaw: z.string().optional(),
332
+ fetchedAt: fetchedAtSchema.optional(),
333
+ userAnswerUse: userAnswerUseSchema,
334
+ source: readSourceSchema.optional(),
335
+ quote: deepbookDisplayQuoteSchema.optional(),
336
+ rawQuote: deepbookRawQuoteSchema.optional(),
337
+ quantitySemantics: deepbookQuoteQuantitySemanticsSchema.optional()
338
+ }),
339
+ annotations: { readOnlyHint: true, openWorldHint: false }
340
+ }, async ({ poolKey, direction, amountRaw }) => {
341
+ try {
342
+ return okToolResult(await deps.readService.quoteDeepbookAction({
343
+ poolKey,
344
+ direction,
345
+ amountRaw,
346
+ simulationSender: DEFAULT_DEEPBOOK_SIMULATION_SENDER
347
+ }));
348
+ }
349
+ catch (error) {
350
+ return readServiceError(error, deps);
351
+ }
352
+ });
353
+ server.registerTool(TOOL_NAMES.readQuoteDeepbookDisplayAmount, {
354
+ title: "Quote DeepBook display amount",
355
+ description: "Pinned-SDK DeepBook display-amount quote evidence. Not fiat cash-out, external USD lookup, P&L, price impact, route, final min-out, signing data, or signing readiness.",
356
+ inputSchema: {
357
+ poolKey: z.string().min(1),
358
+ direction: z.enum(["base_to_quote", "quote_to_base"]),
359
+ amountDisplay: z.string().min(1)
360
+ },
361
+ outputSchema: successOutputSchema({
362
+ status: z.literal("ok"),
363
+ pool: z.object({
364
+ poolKey: z.string(),
365
+ base: z.string(),
366
+ quote: z.string()
367
+ }),
368
+ direction: z.enum(["base_to_quote", "quote_to_base"]),
369
+ inputAmount: deepbookDisplayQuoteInputAmountSchema,
370
+ fetchedAt: fetchedAtSchema,
371
+ userAnswerUse: userAnswerUseSchema,
372
+ source: deepbookDisplayQuoteSourceSchema,
373
+ quote: deepbookDisplayQuoteSchema,
374
+ rawQuote: deepbookRawQuoteSchema,
375
+ quantitySemantics: deepbookQuoteQuantitySemanticsSchema
376
+ }),
377
+ annotations: { readOnlyHint: true, openWorldHint: false }
378
+ }, async ({ poolKey, direction, amountDisplay }) => {
379
+ try {
380
+ return okToolResult(await deps.readService.quoteDeepbookDisplayAmount({
381
+ poolKey,
382
+ direction,
383
+ amountDisplay,
384
+ simulationSender: DEFAULT_DEEPBOOK_SIMULATION_SENDER
385
+ }));
386
+ }
387
+ catch (error) {
388
+ return readServiceError(error, deps);
389
+ }
390
+ });
391
+ server.registerTool(TOOL_NAMES.readSummarizeDeepbookAccountInventory, {
392
+ title: "Summarize DeepBook account inventory",
393
+ description: "Pinned-SDK DeepBook BalanceManager inventory. Display-like facts, not raw amounts or signing readiness.",
394
+ inputSchema: {
395
+ poolKey: z.string().min(1).optional(),
396
+ managerAddress: z.string().min(1).optional()
397
+ },
398
+ outputSchema: successOutputSchema({
399
+ account: z.string(),
400
+ status: z.literal("ok"),
401
+ fetchedAt: fetchedAtSchema,
402
+ source: deepbookAccountInventorySourceSchema,
403
+ requested: z.object({
404
+ poolKey: z.string().optional(),
405
+ managerAddress: z.string().optional()
406
+ }),
407
+ detailStatus: deepbookAccountInventoryDetailStatusSchema,
408
+ managerAddresses: z.array(z.string()),
409
+ userAnswerUse: userAnswerUseSchema,
410
+ quantitySemantics: deepbookAccountQuantitySemanticsSchema,
411
+ pool: z
412
+ .object({
413
+ poolKey: z.string(),
414
+ base: z.string(),
415
+ quote: z.string()
416
+ })
417
+ .optional(),
418
+ accountExists: z.boolean().optional(),
419
+ accountSummary: deepbookAccountSummarySchema.optional(),
420
+ lockedBalances: deepbookDisplayAccountBalancesSchema.optional(),
421
+ openOrderIds: z.array(z.string()).max(MAX_DEEPBOOK_ACCOUNT_OPEN_ORDER_IDS).optional(),
422
+ openOrderCount: z.number().int().nonnegative().optional(),
423
+ openOrderIdsTruncated: z.boolean().optional()
424
+ }),
425
+ annotations: { readOnlyHint: true, openWorldHint: false }
426
+ }, async ({ poolKey, managerAddress }) => {
427
+ let active;
428
+ try {
429
+ active = await deps.activityStore.getActiveAccount();
430
+ }
431
+ catch (error) {
432
+ return activityStoreToolError(error, deps.logger);
433
+ }
434
+ if (!active) {
435
+ return errorToolResult({
436
+ kind: "active_account_not_set",
437
+ details: {
438
+ action: "connect_wallet_identity"
439
+ }
440
+ });
441
+ }
442
+ try {
443
+ return okToolResult(await deps.readService.summarizeDeepbookAccountInventory({
444
+ account: active.address,
445
+ poolKey,
446
+ managerAddress
447
+ }));
448
+ }
449
+ catch (error) {
450
+ return readServiceError(error, deps);
451
+ }
452
+ });
453
+ }
@@ -0,0 +1,135 @@
1
+ import { z } from "zod";
2
+ import { FLOWX_CLMM_MAINNET, FLOWX_CLMM_PROTOCOL_ID, FLOWX_CLMM_UNIT_SOURCE, FLOWX_SWAP_QUOTE_QUANTITY_KIND, listFlowxPoolRegistry } from "../../../core/read/readService.js";
3
+ import { noParamsInputSchema, successOutputSchema } from "../../schemas.js";
4
+ import { okToolResult } from "../../result.js";
5
+ import { TOOL_NAMES } from "../../toolNames.js";
6
+ import { fetchedAtSchema, userAnswerUseSchema } from "./commonSchemas.js";
7
+ import { readServiceError } from "./readToolHelpers.js";
8
+ const flowxPoolRegistryEntrySchema = z.object({
9
+ poolKey: z.string(),
10
+ poolId: z.string(),
11
+ symbolX: z.string(),
12
+ symbolY: z.string(),
13
+ coinTypeX: z.string(),
14
+ coinTypeY: z.string(),
15
+ decimalsX: z.number().int().nonnegative(),
16
+ decimalsY: z.number().int().nonnegative(),
17
+ feeRate: z.number().int().nonnegative(),
18
+ tickSpacing: z.number().int().positive(),
19
+ unitSource: z.literal(FLOWX_CLMM_UNIT_SOURCE)
20
+ });
21
+ const flowxQuoteSourceSchema = z.object({
22
+ sdk: z.literal("@flowx-finance/sdk"),
23
+ transport: z.literal("https"),
24
+ method: z.literal("AggregatorQuoter.getRoutes"),
25
+ chainVerified: z.literal(false)
26
+ });
27
+ const flowxQuoteAmountSchema = z.object({
28
+ raw: z.string().regex(/^\d+$/),
29
+ display: z.string().regex(/^\d+(?:\.\d+)?$/),
30
+ decimals: z.number().int().nonnegative()
31
+ });
32
+ const flowxRouteEvidenceSchema = z.object({
33
+ kind: z.literal("flowx_aggregator_route"),
34
+ routeSource: z.literal("flowx_quoter_api"),
35
+ routeChosenBy: z.literal("flowx_router_not_this_server"),
36
+ singleHop: z.literal(true),
37
+ pools: z.array(z.object({
38
+ poolKey: z.string(),
39
+ poolId: z.string(),
40
+ feeRate: z.number().int().nonnegative(),
41
+ tickSpacing: z.number().int().positive(),
42
+ swapXToY: z.boolean()
43
+ })),
44
+ protocolConfigPinMatch: z.literal(true)
45
+ });
46
+ const flowxQuoteQuantitySemanticsSchema = z.object({
47
+ kind: z.literal(FLOWX_SWAP_QUOTE_QUANTITY_KIND),
48
+ inputAmountKind: z.literal("display_source_amount_converted_to_raw"),
49
+ allowedUse: z.literal("indicative_flowx_route_quote"),
50
+ rawAmountAvailable: z.literal(true),
51
+ rawEvidenceField: z.literal("routeEvidence"),
52
+ chainVerified: z.literal(false),
53
+ paymentCoverageAvailable: z.literal(false),
54
+ shortfallContributionAvailable: z.literal(false),
55
+ routeDependentPaymentSupportAvailable: z.literal(false),
56
+ requiresIntentEvidenceForCoverage: z.literal(true),
57
+ canUseForPaymentAnswer: z.literal(false),
58
+ canUseForShortfallAnswer: z.literal(false),
59
+ doNotCombineWithPaymentAnswer: z.literal(true),
60
+ requiredPaymentAnswerTool: z.literal("read.preview_intent_evidence"),
61
+ paymentAnswerUseBlockedReason: z.literal("quote_output_is_price_reference_not_payment_answer"),
62
+ requiredPaymentAnswerField: z.literal("responseSummary"),
63
+ fiatUsdCashOutAvailable: z.literal(false),
64
+ externalMarketPriceConversionAvailable: z.literal(false),
65
+ externalMarketLookupAvailable: z.literal(false),
66
+ usdPegAssumptionAvailable: z.literal(false),
67
+ bankCashOutEstimateAvailable: z.literal(false),
68
+ profitAndLossAvailable: z.literal(false),
69
+ costBasisAvailable: z.literal(false),
70
+ priceImpactAvailable: z.literal(false),
71
+ midPriceSlippageAvailable: z.literal(false),
72
+ venueComparisonAvailable: z.literal(false),
73
+ routeRecommendationAvailable: z.literal(false),
74
+ notFor: z.array(z.string()).min(1)
75
+ });
76
+ export function registerFlowxReadTools(server, deps) {
77
+ server.registerTool(TOOL_NAMES.readListFlowxPools, {
78
+ title: "List FlowX pools",
79
+ description: "List pinned FlowX CLMM mainnet pools for supported pairs. Static registry only; not live liquidity, pool ranking, or route advice.",
80
+ inputSchema: noParamsInputSchema,
81
+ outputSchema: successOutputSchema({
82
+ protocolId: z.literal(FLOWX_CLMM_PROTOCOL_ID),
83
+ source: z.string(),
84
+ currentPackageId: z.string(),
85
+ poolRegistryObjectId: z.string(),
86
+ feeRateDenominator: z.number().int().positive(),
87
+ pools: z.array(flowxPoolRegistryEntrySchema)
88
+ }),
89
+ annotations: { readOnlyHint: true, openWorldHint: false }
90
+ }, async () => okToolResult({
91
+ protocolId: FLOWX_CLMM_PROTOCOL_ID,
92
+ source: "flowx pinned registry (chain-verified snapshot)",
93
+ currentPackageId: FLOWX_CLMM_MAINNET.currentPackageId,
94
+ poolRegistryObjectId: FLOWX_CLMM_MAINNET.poolRegistry.objectId,
95
+ feeRateDenominator: FLOWX_CLMM_MAINNET.feeRateDenominator,
96
+ pools: listFlowxPoolRegistry().map((pool) => ({ ...pool }))
97
+ }));
98
+ server.registerTool(TOOL_NAMES.readQuoteFlowxSwap, {
99
+ title: "Quote FlowX swap",
100
+ description: "Indicative FlowX route quote with the router-selected pool reported as evidence. Not min-out, price impact, route advice, payment coverage, or signing readiness.",
101
+ inputSchema: {
102
+ sourceSymbol: z.string().min(1),
103
+ targetSymbol: z.string().min(1),
104
+ amountDisplay: z.string().min(1)
105
+ },
106
+ outputSchema: successOutputSchema({
107
+ status: z.literal("ok"),
108
+ pair: z.object({
109
+ sourceSymbol: z.string(),
110
+ targetSymbol: z.string(),
111
+ sourceCoinType: z.string(),
112
+ targetCoinType: z.string()
113
+ }),
114
+ amountIn: flowxQuoteAmountSchema,
115
+ amountOut: flowxQuoteAmountSchema.extend({ indicative: z.literal(true) }),
116
+ routeEvidence: flowxRouteEvidenceSchema,
117
+ fetchedAt: fetchedAtSchema,
118
+ userAnswerUse: userAnswerUseSchema,
119
+ quantitySemantics: flowxQuoteQuantitySemanticsSchema,
120
+ source: flowxQuoteSourceSchema
121
+ }),
122
+ annotations: { readOnlyHint: true, openWorldHint: true }
123
+ }, async ({ sourceSymbol, targetSymbol, amountDisplay }) => {
124
+ try {
125
+ return okToolResult(await deps.readService.quoteFlowxSwap({
126
+ sourceSymbol,
127
+ targetSymbol,
128
+ amountDisplay
129
+ }));
130
+ }
131
+ catch (error) {
132
+ return readServiceError(error, deps);
133
+ }
134
+ });
135
+ }
@@ -0,0 +1,16 @@
1
+ import { registerDeepbookReadTools } from "./deepbookReadTools.js";
2
+ import { registerFlowxReadTools } from "./flowxReadTools.js";
3
+ import { registerReviewActivityListTool, registerReviewActivitySummaryTools } from "./reviewActivityTools.js";
4
+ import { registerServerStatusTools, SUPPORTED_PROTOCOLS } from "./serverStatusTools.js";
5
+ import { registerTransactionActivityTools } from "./transactionActivityTools.js";
6
+ import { registerWalletReadTools } from "./walletReadTools.js";
7
+ export { SUPPORTED_PROTOCOLS };
8
+ export function registerReadTools(server, deps) {
9
+ registerServerStatusTools(server);
10
+ registerDeepbookReadTools(server, deps);
11
+ registerFlowxReadTools(server, deps);
12
+ registerWalletReadTools(server, deps);
13
+ registerReviewActivityListTool(server, deps);
14
+ registerTransactionActivityTools(server, deps);
15
+ registerReviewActivitySummaryTools(server, deps);
16
+ }
@@ -0,0 +1,68 @@
1
+ import { ReadServiceCacheError, ReadServiceInputError } from "../../../core/read/readService.js";
2
+ import { parseSuiAddress } from "../../../core/suiAddress.js";
3
+ import { errorToolResult } from "../../result.js";
4
+ import { activityStoreToolError } from "../../toolErrors.js";
5
+ export async function resolveExplicitOrActiveAccount(account, deps) {
6
+ if (account !== undefined) {
7
+ const explicitAccount = parseSuiAddress(account);
8
+ if (explicitAccount === undefined) {
9
+ return {
10
+ status: "error",
11
+ result: errorToolResult({
12
+ kind: "input_invalid",
13
+ details: {
14
+ field: "account"
15
+ }
16
+ })
17
+ };
18
+ }
19
+ return { status: "ok", account: explicitAccount };
20
+ }
21
+ let active;
22
+ try {
23
+ active = await deps.activityStore.getActiveAccount();
24
+ }
25
+ catch (error) {
26
+ return { status: "error", result: activityStoreToolError(error, deps.logger) };
27
+ }
28
+ if (!active) {
29
+ return {
30
+ status: "error",
31
+ result: errorToolResult({
32
+ kind: "active_account_not_set",
33
+ details: {
34
+ action: "connect_wallet_identity"
35
+ }
36
+ })
37
+ };
38
+ }
39
+ return { status: "ok", account: active.address };
40
+ }
41
+ export function readServiceError(error, deps) {
42
+ if (error instanceof ReadServiceCacheError) {
43
+ deps.logger.error("read service metadata cache failed", {
44
+ operation: error.details.operation,
45
+ error: error.cause instanceof Error ? error.cause.message : String(error.cause)
46
+ });
47
+ return errorToolResult({
48
+ kind: error.kind,
49
+ details: error.details
50
+ });
51
+ }
52
+ if (error instanceof ReadServiceInputError) {
53
+ return errorToolResult({
54
+ kind: error.kind,
55
+ details: error.details
56
+ });
57
+ }
58
+ deps.logger.error("read service call failed", {
59
+ error: error instanceof Error ? error.message : String(error)
60
+ });
61
+ return errorToolResult({
62
+ kind: "internal_error",
63
+ details: { message: "Read service call failed" }
64
+ });
65
+ }
66
+ export function activityStoreReadError(error, deps) {
67
+ return activityStoreToolError(error, deps.logger);
68
+ }