@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.
- package/README.md +4 -39
- package/dist/adapters/adapterLifecycleValidators.js +7 -0
- package/dist/adapters/adapterPromptSurfaces.js +71 -0
- package/dist/adapters/deepbook/deepbookHumanReviewProducer.js +175 -0
- package/dist/adapters/deepbook/deepbookQuotePolicy.js +112 -0
- package/dist/adapters/deepbook/deepbookReviewEvidence.js +507 -0
- package/dist/adapters/deepbook/deepbookReviewLifecycle.js +85 -0
- package/dist/adapters/deepbook/deepbookSwapIntent.js +79 -0
- package/dist/adapters/deepbook/deepbookTransactionMaterialProducer.js +269 -0
- package/dist/adapters/flowx/flowxSwapHumanReviewProducer.js +176 -0
- package/dist/adapters/flowx/flowxSwapIntent.js +79 -0
- package/dist/adapters/flowx/flowxSwapQuotePolicy.js +104 -0
- package/dist/adapters/flowx/flowxSwapReviewEvidence.js +468 -0
- package/dist/adapters/flowx/flowxSwapReviewLifecycle.js +85 -0
- package/dist/adapters/flowx/flowxSwapTransactionMaterialProducer.js +362 -0
- package/dist/adapters/intentPlanFactories.js +59 -0
- package/dist/adapters/reviewAdapters.js +81 -0
- package/dist/core/action/adapterLifecycleValidation.js +12 -0
- package/dist/core/action/forbiddenFields.js +43 -0
- package/dist/core/action/humanReadableReviewEvidence.js +203 -0
- package/dist/core/action/humanReadableReviewProjectionVerifier.js +29 -0
- package/dist/core/action/ptbVisualizationProducer.js +66 -0
- package/dist/core/action/reviewCheckResults.js +6 -0
- package/dist/core/action/reviewStateValidation.js +11 -0
- package/dist/core/action/reviewTimeSimulationEvidence.js +471 -0
- package/dist/core/action/schemas.js +529 -0
- package/dist/core/action/signableAdapterContract.js +993 -0
- package/dist/core/action/swapHumanReadableReviewProjection.js +124 -0
- package/dist/core/action/swapQuotePolicyEvidence.js +278 -0
- package/dist/core/action/transactionObjectOwnershipEvidence.js +247 -0
- package/dist/core/action/transactionObjectOwnershipProducer.js +329 -0
- package/dist/core/action/types.js +35 -0
- package/dist/core/action/walletReviewContractAssembler.js +282 -0
- package/dist/core/activity/activityStore.js +15 -0
- package/dist/core/activity/localDataService.js +258 -0
- package/dist/core/activity/localDataTypes.js +11 -0
- package/dist/core/activity/localDataValidation.js +396 -0
- package/dist/core/activity/schemaVersion.js +1 -0
- package/dist/core/activity/sqliteActivityStore.js +820 -0
- package/dist/core/activity/sqliteActivityStoreRows.js +430 -0
- package/dist/core/activity/sqliteActivityStoreSchema.js +258 -0
- package/dist/core/activity/sqliteActivityStoreTypes.js +5 -0
- package/dist/core/activity/suiFunctionTarget.js +43 -0
- package/dist/core/activity/transactionActivityAccountEffects.js +189 -0
- package/dist/core/activity/transactionActivityAnalysis.js +295 -0
- package/dist/core/activity/transactionActivityClassifier.js +306 -0
- package/dist/core/activity/transactionActivityDetails.js +229 -0
- package/dist/core/activity/transactionActivityProtocolRules.js +218 -0
- package/dist/core/activity/transactionActivityScanPolicy.js +170 -0
- package/dist/core/activity/transactionActivityService.js +379 -0
- package/dist/core/activity/transactionActivityTypes.js +18 -0
- package/dist/core/eventlog/sink.js +35 -0
- package/dist/core/evidence/settlementFamilies.js +87 -0
- package/dist/core/evidence/userAnswerUse.js +1 -0
- package/dist/core/numeric/rawU64.js +63 -0
- package/dist/core/preferences/preferencesStore.js +26 -0
- package/dist/core/preferences/sqlitePreferencesRepository.js +136 -0
- package/dist/core/proposal/externalProposalReview.js +347 -0
- package/dist/core/proposal/schemas.js +208 -0
- package/dist/core/proposal/types.js +35 -0
- package/dist/core/read/amounts.js +14 -0
- package/dist/core/read/coinMetadata.js +60 -0
- package/dist/core/read/deepbookRawQuoteClient.js +86 -0
- package/dist/core/read/deepbookReadHelpers.js +265 -0
- package/dist/core/read/deepbookRegistry.js +133 -0
- package/dist/core/read/flowxQuoteClient.js +117 -0
- package/dist/core/read/flowxReadHelpers.js +145 -0
- package/dist/core/read/flowxRegistry.js +174 -0
- package/dist/core/read/intentEvidenceResponseFormatting.js +228 -0
- package/dist/core/read/readResponseGuidance.js +451 -0
- package/dist/core/read/readService.js +1164 -0
- package/dist/core/read/readServiceTypes.js +59 -0
- package/dist/core/read/settlementParityFormatting.js +82 -0
- package/dist/core/read/walletReadHelpers.js +99 -0
- package/dist/core/review/reviewChecks.js +54 -0
- package/dist/core/review/reviewComputation.js +38 -0
- package/dist/core/review/reviewComputationResult.js +87 -0
- package/dist/core/session/localSession.js +31 -0
- package/dist/core/session/privateReviewArtifacts.js +73 -0
- package/dist/core/session/sessionErrors.js +9 -0
- package/dist/core/session/sessionStore.js +821 -0
- package/dist/core/session/settingsSession.js +1 -0
- package/dist/core/session/settingsSessions.js +43 -0
- package/dist/core/session/status.js +86 -0
- package/dist/core/session/transactionMaterialStore.js +205 -0
- package/dist/core/session/wait.js +102 -0
- package/dist/core/session/walletIdentity.js +103 -0
- package/dist/core/session/walletIdentitySessions.js +189 -0
- package/dist/core/suiAddress.js +18 -0
- package/dist/core/suiEndpoint.js +72 -0
- package/dist/mcp/activeAccountResponse.js +24 -0
- package/dist/mcp/prompts.js +146 -0
- package/dist/mcp/registerTool.js +19 -0
- package/dist/mcp/resources.js +72 -0
- package/dist/mcp/responseGuidance.js +381 -0
- package/dist/mcp/result.js +17 -0
- package/dist/mcp/schemas.js +8 -0
- package/dist/mcp/server.js +30 -0
- package/dist/mcp/serverInfo.js +123 -0
- package/dist/mcp/toolErrors.js +105 -0
- package/dist/mcp/toolNames.js +50 -0
- package/dist/mcp/tools/account/index.js +44 -0
- package/dist/mcp/tools/action/prepareSuiActionReview.js +120 -0
- package/dist/mcp/tools/read/commonSchemas.js +43 -0
- package/dist/mcp/tools/read/deepbookReadTools.js +453 -0
- package/dist/mcp/tools/read/flowxReadTools.js +135 -0
- package/dist/mcp/tools/read/index.js +16 -0
- package/dist/mcp/tools/read/readToolHelpers.js +68 -0
- package/dist/mcp/tools/read/reviewActivityTools.js +176 -0
- package/dist/mcp/tools/read/serverStatusTools.js +103 -0
- package/dist/mcp/tools/read/transactionActivityOutput.js +300 -0
- package/dist/mcp/tools/read/transactionActivityTools.js +544 -0
- package/dist/mcp/tools/read/walletReadTools.js +733 -0
- package/dist/mcp/tools/session/executionResultTools.js +92 -0
- package/dist/mcp/tools/session/index.js +8 -0
- package/dist/mcp/tools/session/shared.js +79 -0
- package/dist/mcp/tools/session/statusTools.js +134 -0
- package/dist/mcp/tools/session/walletIdentityTools.js +119 -0
- package/dist/mcp/tools/settings/index.js +64 -0
- package/dist/review-app/analysis.css +1 -0
- package/dist/review-app/analysis.js +1 -0
- package/dist/review-app/arc-BjIacwQm.js +1 -0
- package/dist/review-app/architecture-U656AL7Q-aSB9x1OK.js +1 -0
- package/dist/review-app/architectureDiagram-VXUJARFQ-C5W6re2I.js +36 -0
- package/dist/review-app/array-BmXUUrU6.js +1 -0
- package/dist/review-app/blockDiagram-VD42YOAC-20MLNcUm.js +122 -0
- package/dist/review-app/c4Diagram-YG6GDRKO-BZXRrcck.js +10 -0
- package/dist/review-app/channel-lk2p_CUu.js +1 -0
- package/dist/review-app/chunk-4BX2VUAB-BPITOdjX.js +1 -0
- package/dist/review-app/chunk-55IACEB6-Dz-pyw5k.js +1 -0
- package/dist/review-app/chunk-76Q3JFCE-cK_X1P_l.js +1 -0
- package/dist/review-app/chunk-ABZYJK2D-Dt4W53JI.js +81 -0
- package/dist/review-app/chunk-ATLVNIR6-fZHLXURb.js +1 -0
- package/dist/review-app/chunk-B4BG7PRW-BbgcjusC.js +165 -0
- package/dist/review-app/chunk-BJD4TVEz.js +1 -0
- package/dist/review-app/chunk-CVBHYZKI-CViawAKX.js +1 -0
- package/dist/review-app/chunk-DI55MBZ5-C5aoul-d.js +220 -0
- package/dist/review-app/chunk-FMBD7UC4-Chxmw62A.js +15 -0
- package/dist/review-app/chunk-FPAJGGOC-DDHjQ09H.js +80 -0
- package/dist/review-app/chunk-FWNWRKHM-CVVQUptk.js +1 -0
- package/dist/review-app/chunk-HN2XXSSU-yzNpjaSZ.js +1 -0
- package/dist/review-app/chunk-JA3XYJ7Z-C5ZJdU01.js +70 -0
- package/dist/review-app/chunk-JZLCHNYA-BBST4Cnk.js +54 -0
- package/dist/review-app/chunk-LBM3YZW2-CdwAPuHr.js +1 -0
- package/dist/review-app/chunk-LHMN2FUI-BtB5uDcp.js +1 -0
- package/dist/review-app/chunk-O7ZBX7Z2-pxdK4Sa3.js +1 -0
- package/dist/review-app/chunk-QN33PNHL-CbVv3uGK.js +1 -0
- package/dist/review-app/chunk-QXUST7PY-DKM2-t2c.js +7 -0
- package/dist/review-app/chunk-QZHKN3VN-C5ni2pN_.js +1 -0
- package/dist/review-app/chunk-S3R3BYOJ-BWvOhDs0.js +2 -0
- package/dist/review-app/chunk-S6J4BHB3-D9Fk0YeD.js +1 -0
- package/dist/review-app/chunk-T53DSG4Q-C1qEyzyV.js +1 -0
- package/dist/review-app/chunk-TZMSLE5B-B--7eU69.js +1 -0
- package/dist/review-app/classDiagram-2ON5EDUG-DlL1m2bp.js +1 -0
- package/dist/review-app/classDiagram-v2-WZHVMYZB-FXRskT1j.js +1 -0
- package/dist/review-app/clone-BZZb7gpZ.js +1 -0
- package/dist/review-app/cose-bilkent-S5V4N54A-CRIb8XEO.js +1 -0
- package/dist/review-app/cytoscape.esm-C7jYqDP5.js +321 -0
- package/dist/review-app/dagre-6UL2VRFP-FNCAXbdE.js +4 -0
- package/dist/review-app/dagre-Be46QtUd.js +1 -0
- package/dist/review-app/defaultLocale-BaWNtAUL.js +1 -0
- package/dist/review-app/diagram-PSM6KHXK-ylLWjiNM.js +24 -0
- package/dist/review-app/diagram-QEK2KX5R-BCDcESxs.js +43 -0
- package/dist/review-app/diagram-S2PKOQOG-Vdrc-vrO.js +24 -0
- package/dist/review-app/dist-WPc74x_f.js +1 -0
- package/dist/review-app/erDiagram-Q2GNP2WA-E5ZsUbDF.js +60 -0
- package/dist/review-app/flatten-DHf9IeNI.js +1 -0
- package/dist/review-app/flowDiagram-NV44I4VS-DBSQuj6x.js +162 -0
- package/dist/review-app/ganttDiagram-LVOFAZNH-CKUOsqwl.js +267 -0
- package/dist/review-app/gitGraph-F6HP7TQM-DsAD6qK1.js +1 -0
- package/dist/review-app/gitGraphDiagram-NY62KEGX-BCeIMWdl.js +65 -0
- package/dist/review-app/graphlib-CiX5CXxR.js +1 -0
- package/dist/review-app/http-DMvwuuFk.js +1 -0
- package/dist/review-app/identity-DY8PXc6t.js +1 -0
- package/dist/review-app/info-NVLQJR56-Dlx1nZic.js +1 -0
- package/dist/review-app/infoDiagram-F6ZHWCRC-CAuANIrz.js +2 -0
- package/dist/review-app/init-BvqephKz.js +1 -0
- package/dist/review-app/journeyDiagram-XKPGCS4Q-C-Z9phnx.js +139 -0
- package/dist/review-app/kanban-definition-3W4ZIXB7-DufgZABq.js +89 -0
- package/dist/review-app/katex-B-Z-NXXN.js +257 -0
- package/dist/review-app/line-DiIv3Jgw.js +1 -0
- package/dist/review-app/linear-Cv-UPvo1.js +1 -0
- package/dist/review-app/math-kmyYrkHL.js +1 -0
- package/dist/review-app/mermaid-parser.core-DkwUYTPl.js +4 -0
- package/dist/review-app/mindmap-definition-VGOIOE7T-TM_CqdmV.js +68 -0
- package/dist/review-app/ordinal-BliTlkoG.js +1 -0
- package/dist/review-app/packet-BFZMPI3H-DqbnU92v.js +1 -0
- package/dist/review-app/path-AEo9W6mQ.js +1 -0
- package/dist/review-app/pie-7BOR55EZ-LJzaLkgr.js +1 -0
- package/dist/review-app/pieDiagram-ADFJNKIX-BAs8OfRS.js +30 -0
- package/dist/review-app/quadrantDiagram-AYHSOK5B-CyUDZP5S.js +7 -0
- package/dist/review-app/radar-NHE76QYJ-DBpHc8_Y.js +1 -0
- package/dist/review-app/reduce-B-HuPpdd.js +1 -0
- package/dist/review-app/requirementDiagram-UZGBJVZJ-BEHix78P.js +64 -0
- package/dist/review-app/review.css +1 -0
- package/dist/review-app/review.js +43 -0
- package/dist/review-app/sankeyDiagram-TZEHDZUN-B2bKbmsm.js +10 -0
- package/dist/review-app/sequenceDiagram-WL72ISMW-DVLOORFJ.js +145 -0
- package/dist/review-app/settings.css +1 -0
- package/dist/review-app/settings.js +1 -0
- package/dist/review-app/src-Buml7cM5.js +1 -0
- package/dist/review-app/stateDiagram-FKZM4ZOC-sFGGp2kV.js +1 -0
- package/dist/review-app/stateDiagram-v2-4FDKWEC3-BHfCF4dX.js +1 -0
- package/dist/review-app/timeline-definition-IT6M3QCI-BESnBijC.js +61 -0
- package/dist/review-app/treemap-KMMF4GRG-wnVLBDeQ.js +1 -0
- package/dist/review-app/walletStatus-CcojOdGy.js +7 -0
- package/dist/review-app/xychartDiagram-PRI3JC2R-BGWVfCx4.js +7 -0
- package/dist/review-server/assets.js +48 -0
- package/dist/review-server/html.js +66 -0
- package/dist/review-server/http.js +47 -0
- package/dist/review-server/middleware/hostOrigin.js +48 -0
- package/dist/review-server/middleware/reviewToken.js +7 -0
- package/dist/review-server/reviewServerPolicy.js +10 -0
- package/dist/review-server/server.js +568 -0
- package/dist/review-server/settingsApi.js +182 -0
- package/dist/review-server/walletIdentityResponse.js +13 -0
- package/dist/runtime/config.js +103 -0
- package/dist/runtime/localSettingsService.js +198 -0
- package/dist/runtime/logger.js +50 -0
- package/dist/runtime/reviewServerAcquire.js +128 -0
- package/dist/runtime/smokeMainnetRead.js +529 -0
- package/dist/runtime/smokeMainnetReadAssertions.js +308 -0
- package/dist/runtime/start.js +295 -0
- package/dist/runtime/suiEndpoint.js +97 -0
- package/dist/runtime/suiTransactionGraphqlMapping.js +200 -0
- package/dist/runtime/suiTransactionGraphqlQueries.js +231 -0
- package/dist/runtime/suiTransactionGraphqlSource.js +148 -0
- package/docs/AGENT_BEHAVIOR.md +1 -1
- package/docs/AGENT_DEVELOPMENT_POLICY.md +20 -0
- package/docs/FRONTEND_POLICY.md +4 -3
- package/docs/MCP_SETUP.md +59 -7
- package/docs/MCP_TOOLS.md +1 -1
- package/docs/SDK_API.md +5 -1
- package/package.json +3 -2
|
@@ -0,0 +1,733 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { DEEPBOOK_SCALAR_UNIT_SOURCE, DISPLAY_AMOUNT_SOURCE, SUI_METADATA_UNIT_SOURCE } from "../../../core/read/coinMetadata.js";
|
|
3
|
+
import { DEEPBOOK_MID_PRICE_DIRECTION, DEEPBOOK_MID_PRICE_PRECISION, DEFAULT_DEEPBOOK_SIMULATION_SENDER, INTENT_EVIDENCE_QUANTITY_KIND, INTENT_EVIDENCE_TARGET_ASSET_SELECTION_SOURCES, SETTLEMENT_ASSET_GROUP_PARITY_QUANTITY_KIND, SUI_USD_SETTLEMENT_ASSET_GROUP_ID, WALLET_BALANCE_QUANTITY_KIND } from "../../../core/read/readServiceTypes.js";
|
|
4
|
+
import { suiAddressStringSchema } from "../../../core/suiAddress.js";
|
|
5
|
+
import { successOutputSchema } from "../../schemas.js";
|
|
6
|
+
import { okToolResult } from "../../result.js";
|
|
7
|
+
import { answerSourceStatus, USD_INTENT_ANSWER_REQUIRED_TOOLS, USD_PARITY_ANSWER_REQUIRED_TOOLS } from "../../serverInfo.js";
|
|
8
|
+
import { TOOL_NAMES } from "../../toolNames.js";
|
|
9
|
+
import { fetchedAtSchema, readSourceSchema, userAnswerUseSchema } from "./commonSchemas.js";
|
|
10
|
+
import { readServiceError, resolveExplicitOrActiveAccount } from "./readToolHelpers.js";
|
|
11
|
+
function withAnswerSourceStatus(data, requiredTools) {
|
|
12
|
+
const preconditionFields = new Set(data.userAnswerUse.preconditionFields ?? []);
|
|
13
|
+
preconditionFields.add("answerSourceStatus");
|
|
14
|
+
return {
|
|
15
|
+
...data,
|
|
16
|
+
userAnswerUse: {
|
|
17
|
+
...data.userAnswerUse,
|
|
18
|
+
preconditionFields: [...preconditionFields]
|
|
19
|
+
},
|
|
20
|
+
answerSourceStatus: answerSourceStatus(requiredTools)
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const answerSourceStatusSchema = z.object({
|
|
24
|
+
statusTool: z.literal(TOOL_NAMES.readGetServerStatus),
|
|
25
|
+
packageName: z.string(),
|
|
26
|
+
version: z.string(),
|
|
27
|
+
evidencePolicyVersion: z.string(),
|
|
28
|
+
network: z.literal("mainnet"),
|
|
29
|
+
implementedToolsCount: z.number().int().nonnegative(),
|
|
30
|
+
requiredTools: z.array(z.object({ name: z.string(), available: z.boolean() })),
|
|
31
|
+
missingRequiredTools: z.array(z.string()),
|
|
32
|
+
canUseThisResponseForUserAnswer: z.boolean(),
|
|
33
|
+
cannotUseReason: z.literal("required_tool_missing_from_current_server_build").nullable()
|
|
34
|
+
}).strict();
|
|
35
|
+
const walletBalanceUnitSchema = z.discriminatedUnion("status", [
|
|
36
|
+
z.object({
|
|
37
|
+
status: z.literal("available"),
|
|
38
|
+
source: z.enum([SUI_METADATA_UNIT_SOURCE, DEEPBOOK_SCALAR_UNIT_SOURCE]),
|
|
39
|
+
decimals: z.number().int().nonnegative(),
|
|
40
|
+
symbol: z.string(),
|
|
41
|
+
name: z.string(),
|
|
42
|
+
cacheStatus: z.enum(["hit", "miss", "expired_refetched"]).optional()
|
|
43
|
+
}),
|
|
44
|
+
z.object({
|
|
45
|
+
status: z.literal("unavailable"),
|
|
46
|
+
reason: z.enum([
|
|
47
|
+
"metadata_not_found",
|
|
48
|
+
"metadata_lookup_failed",
|
|
49
|
+
"coin_type_unresolved",
|
|
50
|
+
"no_verified_decimals"
|
|
51
|
+
])
|
|
52
|
+
})
|
|
53
|
+
]);
|
|
54
|
+
const walletBalanceDisplaySchema = z.object({
|
|
55
|
+
amount: z.string(),
|
|
56
|
+
symbol: z.string(),
|
|
57
|
+
source: z.literal(DISPLAY_AMOUNT_SOURCE)
|
|
58
|
+
});
|
|
59
|
+
const walletBalanceQuantitySemanticsSchema = z.object({
|
|
60
|
+
kind: z.literal(WALLET_BALANCE_QUANTITY_KIND),
|
|
61
|
+
allowedUse: z.literal("current_coin_balance_snapshot"),
|
|
62
|
+
currentBalanceSnapshot: z.literal(true),
|
|
63
|
+
transactionHistoryAvailable: z.literal(false),
|
|
64
|
+
transactionReceiptProofAvailable: z.literal(false),
|
|
65
|
+
transactionBalanceDeltaAvailable: z.literal(false),
|
|
66
|
+
acquisitionSourceAvailable: z.literal(false),
|
|
67
|
+
objectProvenanceAvailable: z.literal(false),
|
|
68
|
+
fiatUsdCashOutAvailable: z.literal(false),
|
|
69
|
+
profitAndLossAvailable: z.literal(false),
|
|
70
|
+
costBasisAvailable: z.literal(false),
|
|
71
|
+
notFor: z.tuple([
|
|
72
|
+
z.literal("transaction_history"),
|
|
73
|
+
z.literal("transaction_receipt_proof"),
|
|
74
|
+
z.literal("specific_transaction_balance_delta"),
|
|
75
|
+
z.literal("acquisition_source"),
|
|
76
|
+
z.literal("object_provenance"),
|
|
77
|
+
z.literal("fiat_usd_cash_out"),
|
|
78
|
+
z.literal("profit_or_pnl"),
|
|
79
|
+
z.literal("cost_basis"),
|
|
80
|
+
z.literal("signing_data")
|
|
81
|
+
])
|
|
82
|
+
}).strict();
|
|
83
|
+
const walletBalanceSchema = z.object({
|
|
84
|
+
coinType: z.string(),
|
|
85
|
+
balance: z.string(),
|
|
86
|
+
coinBalance: z.string(),
|
|
87
|
+
addressBalance: z.string(),
|
|
88
|
+
unit: walletBalanceUnitSchema,
|
|
89
|
+
display: walletBalanceDisplaySchema.optional()
|
|
90
|
+
});
|
|
91
|
+
const classifiedWalletAssetSchema = z.object({
|
|
92
|
+
balance: walletBalanceSchema,
|
|
93
|
+
classification: z.object({
|
|
94
|
+
assetClass: z.literal("coin_balance"),
|
|
95
|
+
spendability: z.enum(["spendable", "zero_balance"]),
|
|
96
|
+
roles: z.array(z.enum(["gas_candidate", "deepbook_registered"]))
|
|
97
|
+
})
|
|
98
|
+
});
|
|
99
|
+
const uninspectedAssetClassSchema = z.discriminatedUnion("assetClass", [
|
|
100
|
+
z.object({
|
|
101
|
+
assetClass: z.literal("staked_or_locked_asset"),
|
|
102
|
+
reason: z.literal("requires_separate_stake_read_not_inspected")
|
|
103
|
+
}),
|
|
104
|
+
z.object({
|
|
105
|
+
assetClass: z.literal("deepbook_balance_manager_or_open_order"),
|
|
106
|
+
reason: z.literal("requires_separate_deepbook_account_read_not_inspected")
|
|
107
|
+
}),
|
|
108
|
+
z.object({
|
|
109
|
+
assetClass: z.literal("lp_vault_or_position"),
|
|
110
|
+
reason: z.literal("requires_separate_protocol_read_not_inspected")
|
|
111
|
+
}),
|
|
112
|
+
z.object({
|
|
113
|
+
assetClass: z.literal("nft_or_object_asset"),
|
|
114
|
+
reason: z.literal("requires_separate_object_read_not_inspected")
|
|
115
|
+
})
|
|
116
|
+
]);
|
|
117
|
+
const settlementAssetGroupAliasSchema = z.enum([
|
|
118
|
+
"dollar",
|
|
119
|
+
"dollars",
|
|
120
|
+
"usd",
|
|
121
|
+
"usd-like",
|
|
122
|
+
"stablecoin",
|
|
123
|
+
"stablecoins"
|
|
124
|
+
]);
|
|
125
|
+
const settlementAssetGroupAssetSchema = z.object({
|
|
126
|
+
symbol: z.string(),
|
|
127
|
+
coinType: z.string(),
|
|
128
|
+
decimals: z.number().int().nonnegative(),
|
|
129
|
+
unitSource: z.literal(DEEPBOOK_SCALAR_UNIT_SOURCE),
|
|
130
|
+
poolKeys: z.array(z.string())
|
|
131
|
+
});
|
|
132
|
+
const settlementAssetGroupExcludedAssetSchema = z.object({
|
|
133
|
+
symbol: z.string(),
|
|
134
|
+
coinType: z.string(),
|
|
135
|
+
reason: z.enum([
|
|
136
|
+
"protocol_fee_asset",
|
|
137
|
+
"gas_or_volatile_asset",
|
|
138
|
+
"volatile_or_non_usd_asset",
|
|
139
|
+
"not_in_usd_settlement_asset_group"
|
|
140
|
+
])
|
|
141
|
+
});
|
|
142
|
+
const settlementAssetGroupEvidenceSourcesSchema = z.object({
|
|
143
|
+
sdk: z.literal("@mysten/deepbook-v3"),
|
|
144
|
+
registry: z.tuple([z.literal("mainnetCoins"), z.literal("mainnetPools")]),
|
|
145
|
+
network: z.literal("mainnet"),
|
|
146
|
+
unitSource: z.literal(DEEPBOOK_SCALAR_UNIT_SOURCE)
|
|
147
|
+
});
|
|
148
|
+
const settlementAssetGroupLimitationsSchema = z.tuple([
|
|
149
|
+
z.literal("static_pinned_sdk_registry_not_live_liquidity"),
|
|
150
|
+
z.literal("not_fiat_usd_cash_out"),
|
|
151
|
+
z.literal("not_payment_execution"),
|
|
152
|
+
z.literal("not_route_recommendation"),
|
|
153
|
+
z.literal("not_signing_readiness")
|
|
154
|
+
]);
|
|
155
|
+
const settlementAssetGroupSchema = z.object({
|
|
156
|
+
id: z.literal(SUI_USD_SETTLEMENT_ASSET_GROUP_ID),
|
|
157
|
+
label: z.literal("Sui USD-denominated settlement assets"),
|
|
158
|
+
aliases: z.array(settlementAssetGroupAliasSchema),
|
|
159
|
+
includedAssets: z.array(settlementAssetGroupAssetSchema),
|
|
160
|
+
excludedAssets: z.array(settlementAssetGroupExcludedAssetSchema),
|
|
161
|
+
evidenceSources: settlementAssetGroupEvidenceSourcesSchema,
|
|
162
|
+
limitations: settlementAssetGroupLimitationsSchema
|
|
163
|
+
});
|
|
164
|
+
const settlementAssetGroupParityQuantitySemanticsSchema = z.object({
|
|
165
|
+
kind: z.literal(SETTLEMENT_ASSET_GROUP_PARITY_QUANTITY_KIND),
|
|
166
|
+
allowedUse: z.literal("settlement_asset_group_internal_parity_evidence"),
|
|
167
|
+
referenceAssetRole: z.literal("measurement_reference_not_settlement_choice"),
|
|
168
|
+
priceSource: z.literal("deepbook_mid_price_snapshot"),
|
|
169
|
+
fiatUsdCashOutAvailable: z.literal(false),
|
|
170
|
+
externalMarketPriceConversionAvailable: z.literal(false),
|
|
171
|
+
externalMarketLookupAvailable: z.literal(false),
|
|
172
|
+
usdPegAssumptionAvailable: z.literal(false),
|
|
173
|
+
settlementTokenSelectionAvailable: z.literal(false),
|
|
174
|
+
paymentExecutionReadinessAvailable: z.literal(false),
|
|
175
|
+
routeRecommendationAvailable: z.literal(false),
|
|
176
|
+
profitAndLossAvailable: z.literal(false),
|
|
177
|
+
costBasisAvailable: z.literal(false),
|
|
178
|
+
notFor: z.tuple([
|
|
179
|
+
z.literal("settlement_token_selection"),
|
|
180
|
+
z.literal("fiat_usd_cash_out"),
|
|
181
|
+
z.literal("external_market_price_conversion"),
|
|
182
|
+
z.literal("external_market_lookup"),
|
|
183
|
+
z.literal("usd_peg_assumption"),
|
|
184
|
+
z.literal("bank_cash_out_estimate"),
|
|
185
|
+
z.literal("payment_execution_readiness"),
|
|
186
|
+
z.literal("route_recommendation"),
|
|
187
|
+
z.literal("best_route"),
|
|
188
|
+
z.literal("transaction_building"),
|
|
189
|
+
z.literal("signing_readiness"),
|
|
190
|
+
z.literal("profit_or_pnl"),
|
|
191
|
+
z.literal("cost_basis")
|
|
192
|
+
])
|
|
193
|
+
});
|
|
194
|
+
const settlementAssetGroupParityAssetSchema = z.discriminatedUnion("status", [
|
|
195
|
+
settlementAssetGroupAssetSchema.extend({
|
|
196
|
+
status: z.literal("reference_asset"),
|
|
197
|
+
parityPrice: z.number().positive(),
|
|
198
|
+
parityDirection: z.literal("reference_asset_per_group_asset"),
|
|
199
|
+
reason: z.literal("reference_asset_is_measurement_baseline_not_settlement_choice")
|
|
200
|
+
}),
|
|
201
|
+
settlementAssetGroupAssetSchema.extend({
|
|
202
|
+
status: z.literal("measured"),
|
|
203
|
+
parityPrice: z.number().positive(),
|
|
204
|
+
parityDirection: z.literal("reference_asset_per_group_asset"),
|
|
205
|
+
poolKey: z.string(),
|
|
206
|
+
direction: z.enum(["base_to_quote", "quote_to_base"]),
|
|
207
|
+
poolMidPrice: z.number().positive(),
|
|
208
|
+
poolMidPriceDirection: z.literal(DEEPBOOK_MID_PRICE_DIRECTION)
|
|
209
|
+
}),
|
|
210
|
+
settlementAssetGroupAssetSchema.extend({
|
|
211
|
+
status: z.literal("no_direct_deepbook_pool"),
|
|
212
|
+
reason: z.string()
|
|
213
|
+
}),
|
|
214
|
+
settlementAssetGroupAssetSchema.extend({
|
|
215
|
+
status: z.literal("mid_price_unavailable"),
|
|
216
|
+
poolKey: z.string(),
|
|
217
|
+
direction: z.enum(["base_to_quote", "quote_to_base"]),
|
|
218
|
+
reason: z.string()
|
|
219
|
+
})
|
|
220
|
+
]);
|
|
221
|
+
const settlementAssetGroupParityUnsupportedClaimsSchema = z.enum([
|
|
222
|
+
"settlement_token_selection",
|
|
223
|
+
"fiat_usd_cash_out",
|
|
224
|
+
"payment_execution_readiness",
|
|
225
|
+
"route_recommendation",
|
|
226
|
+
"best_route",
|
|
227
|
+
"transaction_building",
|
|
228
|
+
"signing_readiness",
|
|
229
|
+
"profit_or_pnl",
|
|
230
|
+
"cost_basis"
|
|
231
|
+
]);
|
|
232
|
+
const settlementAssetGroupParityResponseSummarySchema = z.object({
|
|
233
|
+
questionKind: z.literal("settlement_asset_group_parity"),
|
|
234
|
+
conclusionKind: z.literal("parity_statistics_available"),
|
|
235
|
+
assetGroupId: z.literal(SUI_USD_SETTLEMENT_ASSET_GROUP_ID),
|
|
236
|
+
referenceAssetSymbol: z.string(),
|
|
237
|
+
referenceAssetRole: z.literal("measurement_reference_not_settlement_choice"),
|
|
238
|
+
parityDirection: z.literal("reference_asset_per_group_asset"),
|
|
239
|
+
min: z.object({
|
|
240
|
+
symbol: z.string(),
|
|
241
|
+
parityPrice: z.number().positive()
|
|
242
|
+
}),
|
|
243
|
+
max: z.object({
|
|
244
|
+
symbol: z.string(),
|
|
245
|
+
parityPrice: z.number().positive()
|
|
246
|
+
}),
|
|
247
|
+
mean: z.object({
|
|
248
|
+
parityPrice: z.number().positive()
|
|
249
|
+
}),
|
|
250
|
+
median: z.object({
|
|
251
|
+
parityPrice: z.number().positive()
|
|
252
|
+
}),
|
|
253
|
+
excludedFromConclusion: z.tuple([
|
|
254
|
+
z.literal("settlement_token_selection"),
|
|
255
|
+
z.literal("fiat_usd_cash_out"),
|
|
256
|
+
z.literal("payment_execution_readiness"),
|
|
257
|
+
z.literal("route_recommendation"),
|
|
258
|
+
z.literal("best_route"),
|
|
259
|
+
z.literal("transaction_building"),
|
|
260
|
+
z.literal("signing_readiness"),
|
|
261
|
+
z.literal("profit_or_pnl"),
|
|
262
|
+
z.literal("cost_basis")
|
|
263
|
+
])
|
|
264
|
+
});
|
|
265
|
+
const intentEvidenceQuantitySemanticsSchema = z.object({
|
|
266
|
+
kind: z.literal(INTENT_EVIDENCE_QUANTITY_KIND),
|
|
267
|
+
allowedUse: z.literal("pre_transaction_evidence"),
|
|
268
|
+
naturalLanguageIntentEvidence: z.literal(true),
|
|
269
|
+
transactionBuildingAvailable: z.literal(false),
|
|
270
|
+
signingReadinessAvailable: z.literal(false),
|
|
271
|
+
routeRecommendationAvailable: z.literal(false),
|
|
272
|
+
fiatUsdCashOutAvailable: z.literal(false),
|
|
273
|
+
profitAndLossAvailable: z.literal(false),
|
|
274
|
+
costBasisAvailable: z.literal(false),
|
|
275
|
+
notFor: z.tuple([
|
|
276
|
+
z.literal("transaction_building"),
|
|
277
|
+
z.literal("signing_data"),
|
|
278
|
+
z.literal("signing_readiness"),
|
|
279
|
+
z.literal("payment_execution"),
|
|
280
|
+
z.literal("best_route"),
|
|
281
|
+
z.literal("route_recommendation"),
|
|
282
|
+
z.literal("fiat_usd_cash_out"),
|
|
283
|
+
z.literal("external_market_price_conversion"),
|
|
284
|
+
z.literal("profit_or_pnl"),
|
|
285
|
+
z.literal("cost_basis")
|
|
286
|
+
])
|
|
287
|
+
});
|
|
288
|
+
const intentEvidenceUnsupportedClaimsSchema = z.enum([
|
|
289
|
+
"settlement_token_selection",
|
|
290
|
+
"fiat_usd_cash_out",
|
|
291
|
+
"gas_reserve_or_fee_readiness",
|
|
292
|
+
"best_route_or_venue_comparison",
|
|
293
|
+
"route_dependent_payment_support",
|
|
294
|
+
"payment_execution_readiness",
|
|
295
|
+
"transaction_building",
|
|
296
|
+
"signing_readiness",
|
|
297
|
+
"profit_or_pnl",
|
|
298
|
+
"cost_basis"
|
|
299
|
+
]);
|
|
300
|
+
const intentEvidenceAssetGroupBalanceSchema = settlementAssetGroupAssetSchema.extend({
|
|
301
|
+
currentRawAmount: z.string().regex(/^\d+$/),
|
|
302
|
+
currentDisplayAmount: z.string(),
|
|
303
|
+
walletBalanceEvidence: z.literal("current_wallet_coin_balance_snapshot")
|
|
304
|
+
});
|
|
305
|
+
const intentEvidenceAggregateSchema = z.discriminatedUnion("status", [
|
|
306
|
+
z.object({
|
|
307
|
+
status: z.literal("available"),
|
|
308
|
+
requiredDisplayAmount: z.string().optional(),
|
|
309
|
+
requiredRawAmount: z.string().regex(/^\d+$/).optional(),
|
|
310
|
+
currentRawAmount: z.string().regex(/^\d+$/),
|
|
311
|
+
currentDisplayAmount: z.string(),
|
|
312
|
+
shortfallRawAmount: z.string().regex(/^\d+$/).optional(),
|
|
313
|
+
shortfallDisplayAmount: z.string().optional(),
|
|
314
|
+
decimals: z.number().int().nonnegative(),
|
|
315
|
+
unitSource: z.literal(DEEPBOOK_SCALAR_UNIT_SOURCE)
|
|
316
|
+
}),
|
|
317
|
+
z.object({
|
|
318
|
+
status: z.literal("unavailable_mixed_decimals"),
|
|
319
|
+
requiredDisplayAmount: z.string().optional()
|
|
320
|
+
}),
|
|
321
|
+
z.object({
|
|
322
|
+
status: z.literal("unavailable_wallet_balance_scan_incomplete"),
|
|
323
|
+
requiredDisplayAmount: z.string().optional(),
|
|
324
|
+
reason: z.enum(["wallet_balance_page_limit_exceeded", "wallet_balance_pagination_did_not_advance"])
|
|
325
|
+
})
|
|
326
|
+
]);
|
|
327
|
+
const intentEvidenceSettlementAssetCoverageBoundarySchema = z.tuple([
|
|
328
|
+
z.literal("current_wallet_coin_balance_snapshot"),
|
|
329
|
+
z.literal("settlement_asset_assets_only"),
|
|
330
|
+
z.literal("not_settlement_token_selection"),
|
|
331
|
+
z.literal("not_route_dependent_payment_support"),
|
|
332
|
+
z.literal("not_payment_execution_readiness"),
|
|
333
|
+
z.literal("not_gas_readiness")
|
|
334
|
+
]);
|
|
335
|
+
const intentEvidenceSettlementAssetCoverageSchema = z.discriminatedUnion("status", [
|
|
336
|
+
z.object({
|
|
337
|
+
status: z.literal("balance_total_only"),
|
|
338
|
+
currentRawAmount: z.string().regex(/^\d+$/),
|
|
339
|
+
currentDisplayAmount: z.string(),
|
|
340
|
+
decimals: z.number().int().nonnegative(),
|
|
341
|
+
unitSource: z.literal(DEEPBOOK_SCALAR_UNIT_SOURCE),
|
|
342
|
+
boundary: intentEvidenceSettlementAssetCoverageBoundarySchema
|
|
343
|
+
}),
|
|
344
|
+
z.object({
|
|
345
|
+
status: z.enum(["covered_by_settlement_asset_balance", "shortfall_in_settlement_asset_balance"]),
|
|
346
|
+
requiredDisplayAmount: z.string(),
|
|
347
|
+
requiredRawAmount: z.string().regex(/^\d+$/),
|
|
348
|
+
currentRawAmount: z.string().regex(/^\d+$/),
|
|
349
|
+
currentDisplayAmount: z.string(),
|
|
350
|
+
shortfallRawAmount: z.string().regex(/^\d+$/),
|
|
351
|
+
shortfallDisplayAmount: z.string(),
|
|
352
|
+
decimals: z.number().int().nonnegative(),
|
|
353
|
+
unitSource: z.literal(DEEPBOOK_SCALAR_UNIT_SOURCE),
|
|
354
|
+
boundary: intentEvidenceSettlementAssetCoverageBoundarySchema
|
|
355
|
+
}),
|
|
356
|
+
z.object({
|
|
357
|
+
status: z.literal("unavailable_mixed_decimals"),
|
|
358
|
+
requiredDisplayAmount: z.string().optional(),
|
|
359
|
+
reason: z.literal("asset_group_assets_do_not_share_verified_decimals"),
|
|
360
|
+
boundary: intentEvidenceSettlementAssetCoverageBoundarySchema
|
|
361
|
+
}),
|
|
362
|
+
z.object({
|
|
363
|
+
status: z.literal("unavailable_wallet_balance_scan_incomplete"),
|
|
364
|
+
requiredDisplayAmount: z.string().optional(),
|
|
365
|
+
reason: z.enum(["wallet_balance_page_limit_exceeded", "wallet_balance_pagination_did_not_advance"]),
|
|
366
|
+
boundary: intentEvidenceSettlementAssetCoverageBoundarySchema
|
|
367
|
+
})
|
|
368
|
+
]);
|
|
369
|
+
const intentEvidenceSelectedTargetSchema = settlementAssetGroupAssetSchema.extend({
|
|
370
|
+
selectionSource: z.enum(INTENT_EVIDENCE_TARGET_ASSET_SELECTION_SOURCES),
|
|
371
|
+
requiredRawAmount: z.string().regex(/^\d+$/),
|
|
372
|
+
currentRawAmount: z.string().regex(/^\d+$/),
|
|
373
|
+
currentDisplayAmount: z.string(),
|
|
374
|
+
shortfallRawAmount: z.string().regex(/^\d+$/),
|
|
375
|
+
shortfallDisplayAmount: z.string()
|
|
376
|
+
});
|
|
377
|
+
const intentEvidenceResponseEvidenceSchema = z.discriminatedUnion("mode", [
|
|
378
|
+
z.object({
|
|
379
|
+
mode: z.literal("settlement_asset_only"),
|
|
380
|
+
primaryEvidenceFields: z.tuple([z.literal("responseSummary")]),
|
|
381
|
+
supportedResponseClaims: z.array(z.enum([
|
|
382
|
+
"current_settlement_asset_total",
|
|
383
|
+
"settlement_asset_coverage_status",
|
|
384
|
+
"settlement_asset_shortfall",
|
|
385
|
+
"settlement_asset_coverage_unavailable",
|
|
386
|
+
"selected_target_shortfall",
|
|
387
|
+
"direct_pool_quote_evidence",
|
|
388
|
+
"required_user_choices",
|
|
389
|
+
"unsupported_inferences"
|
|
390
|
+
]))
|
|
391
|
+
}),
|
|
392
|
+
z.object({
|
|
393
|
+
mode: z.literal("selected_target_context"),
|
|
394
|
+
primaryEvidenceFields: z.tuple([
|
|
395
|
+
z.literal("responseSummary"),
|
|
396
|
+
z.literal("selectedTarget"),
|
|
397
|
+
z.literal("candidateConversions"),
|
|
398
|
+
z.literal("requiredUserChoices")
|
|
399
|
+
]),
|
|
400
|
+
supportedResponseClaims: z.array(z.enum([
|
|
401
|
+
"current_settlement_asset_total",
|
|
402
|
+
"settlement_asset_coverage_status",
|
|
403
|
+
"settlement_asset_shortfall",
|
|
404
|
+
"settlement_asset_coverage_unavailable",
|
|
405
|
+
"selected_target_shortfall",
|
|
406
|
+
"direct_pool_quote_evidence",
|
|
407
|
+
"required_user_choices",
|
|
408
|
+
"unsupported_inferences"
|
|
409
|
+
]))
|
|
410
|
+
})
|
|
411
|
+
]);
|
|
412
|
+
const intentEvidenceResponseSummarySchema = z.object({
|
|
413
|
+
questionKind: z.enum(["payment_coverage", "settlement_asset_group_balance_total"]),
|
|
414
|
+
conclusionKind: z.enum([
|
|
415
|
+
"covered_by_settlement_asset_balance",
|
|
416
|
+
"shortfall_in_settlement_asset_balance",
|
|
417
|
+
"current_settlement_asset_total",
|
|
418
|
+
"settlement_asset_coverage_unavailable"
|
|
419
|
+
]),
|
|
420
|
+
answerCompleteness: z.object({
|
|
421
|
+
answerCompleteFor: z.enum([
|
|
422
|
+
"settlement_asset_group_answer",
|
|
423
|
+
"selected_target_context_answer",
|
|
424
|
+
"settlement_asset_coverage_unavailable_answer"
|
|
425
|
+
]),
|
|
426
|
+
requiredAnswerFields: z.array(z.string()),
|
|
427
|
+
notCompleteFor: z.array(z.string())
|
|
428
|
+
}),
|
|
429
|
+
doNotCallQuoteToolsForThisQuestion: z.literal(true),
|
|
430
|
+
coverageBasis: z.literal("settlement_asset_wallet_balance_only"),
|
|
431
|
+
assetGroupId: z.literal(SUI_USD_SETTLEMENT_ASSET_GROUP_ID),
|
|
432
|
+
currentDisplayAmount: z.string().nullable(),
|
|
433
|
+
requiredDisplayAmount: z.string().nullable(),
|
|
434
|
+
shortfallDisplayAmount: z.string().nullable(),
|
|
435
|
+
unavailableReason: z
|
|
436
|
+
.enum([
|
|
437
|
+
"asset_group_assets_do_not_share_verified_decimals",
|
|
438
|
+
"wallet_balance_page_limit_exceeded",
|
|
439
|
+
"wallet_balance_pagination_did_not_advance"
|
|
440
|
+
])
|
|
441
|
+
.optional(),
|
|
442
|
+
amountsUsedForAnswer: z.object({
|
|
443
|
+
currentDisplayAmount: z.literal("current_wallet_balance_in_settlement_asset_group").nullable(),
|
|
444
|
+
requiredDisplayAmount: z.literal("amount_requested_by_user").nullable(),
|
|
445
|
+
shortfallDisplayAmount: z.literal("required_amount_minus_current_settlement_asset_balance").nullable()
|
|
446
|
+
}),
|
|
447
|
+
separateQuoteOutputs: z.object({
|
|
448
|
+
usedForPaymentAnswer: z.literal(false),
|
|
449
|
+
usedForShortfallAnswer: z.literal(false),
|
|
450
|
+
reason: z.literal("separate_quote_tool_outputs_are_price_estimates_only"),
|
|
451
|
+
paymentAnswerField: z.literal("responseSummary")
|
|
452
|
+
}),
|
|
453
|
+
requiredUserChoices: z.array(z.string()),
|
|
454
|
+
doNotUseForConclusion: z.tuple([
|
|
455
|
+
z.literal("separate_quote_tool_results"),
|
|
456
|
+
z.literal("assets_outside_settlement_group"),
|
|
457
|
+
z.literal("route_dependent_payment_support")
|
|
458
|
+
]),
|
|
459
|
+
excludedFromConclusion: z.tuple([
|
|
460
|
+
z.literal("separate_quote_tool_results"),
|
|
461
|
+
z.literal("candidate_conversion_quote_evidence"),
|
|
462
|
+
z.literal("assets_outside_settlement_group"),
|
|
463
|
+
z.literal("settlement_token_selection"),
|
|
464
|
+
z.literal("route_dependent_payment_support"),
|
|
465
|
+
z.literal("gas_reserve_or_fee_readiness"),
|
|
466
|
+
z.literal("payment_execution_readiness"),
|
|
467
|
+
z.literal("transaction_building"),
|
|
468
|
+
z.literal("signing_readiness"),
|
|
469
|
+
z.literal("fiat_usd_cash_out"),
|
|
470
|
+
z.literal("profit_or_pnl"),
|
|
471
|
+
z.literal("cost_basis")
|
|
472
|
+
])
|
|
473
|
+
});
|
|
474
|
+
const intentEvidenceCandidateConversionSchema = z.union([
|
|
475
|
+
z.object({
|
|
476
|
+
sourceSymbol: z.string(),
|
|
477
|
+
targetSymbol: z.string(),
|
|
478
|
+
sourceRawAmount: z.string().regex(/^\d+$/),
|
|
479
|
+
sourceDisplayAmount: z.string(),
|
|
480
|
+
status: z.literal("quoted"),
|
|
481
|
+
directPool: z.object({
|
|
482
|
+
poolKey: z.string(),
|
|
483
|
+
direction: z.enum(["base_to_quote", "quote_to_base"])
|
|
484
|
+
}),
|
|
485
|
+
quote: z.object({ status: z.literal("ok") }).passthrough(),
|
|
486
|
+
boundary: z.tuple([
|
|
487
|
+
z.literal("quote_snapshot_only"),
|
|
488
|
+
z.literal("not_final_min_out"),
|
|
489
|
+
z.literal("not_route_recommendation"),
|
|
490
|
+
z.literal("not_route_dependent_payment_support"),
|
|
491
|
+
z.literal("not_payment_readiness"),
|
|
492
|
+
z.literal("not_signing_readiness")
|
|
493
|
+
])
|
|
494
|
+
}),
|
|
495
|
+
z.object({
|
|
496
|
+
sourceSymbol: z.string(),
|
|
497
|
+
targetSymbol: z.string().optional(),
|
|
498
|
+
sourceRawAmount: z.string().regex(/^\d+$/),
|
|
499
|
+
sourceDisplayAmount: z.string(),
|
|
500
|
+
status: z.enum([
|
|
501
|
+
"target_asset_not_selected",
|
|
502
|
+
"no_direct_deepbook_pool",
|
|
503
|
+
"quote_unavailable",
|
|
504
|
+
"filtered_by_accepted_source_assets"
|
|
505
|
+
]),
|
|
506
|
+
reason: z.string(),
|
|
507
|
+
directPool: z
|
|
508
|
+
.object({
|
|
509
|
+
poolKey: z.string(),
|
|
510
|
+
direction: z.enum(["base_to_quote", "quote_to_base"])
|
|
511
|
+
})
|
|
512
|
+
.optional()
|
|
513
|
+
})
|
|
514
|
+
]);
|
|
515
|
+
const intentEvidenceSettlementAssetGroupSchema = settlementAssetGroupSchema.omit({ excludedAssets: true });
|
|
516
|
+
export function registerWalletReadTools(server, deps) {
|
|
517
|
+
server.registerTool(TOOL_NAMES.readSummarizeWalletAssets, {
|
|
518
|
+
title: "Summarize wallet assets",
|
|
519
|
+
description: "Snapshot current Sui mainnet coin balances via gRPC listBalances. Not transaction history or receipt proof.",
|
|
520
|
+
inputSchema: {
|
|
521
|
+
account: suiAddressStringSchema.optional(),
|
|
522
|
+
cursor: z.string().min(1).optional()
|
|
523
|
+
},
|
|
524
|
+
outputSchema: successOutputSchema({
|
|
525
|
+
account: z.string(),
|
|
526
|
+
status: z.literal("ok"),
|
|
527
|
+
fetchedAt: fetchedAtSchema,
|
|
528
|
+
userAnswerUse: userAnswerUseSchema,
|
|
529
|
+
quantitySemantics: walletBalanceQuantitySemanticsSchema,
|
|
530
|
+
source: readSourceSchema,
|
|
531
|
+
balances: z.array(walletBalanceSchema),
|
|
532
|
+
hasNextPage: z.boolean(),
|
|
533
|
+
cursor: z.string().nullable()
|
|
534
|
+
}),
|
|
535
|
+
annotations: { readOnlyHint: false, openWorldHint: false }
|
|
536
|
+
}, async ({ account, cursor }) => {
|
|
537
|
+
const target = await resolveExplicitOrActiveAccount(account, deps);
|
|
538
|
+
if (target.status === "error") {
|
|
539
|
+
return target.result;
|
|
540
|
+
}
|
|
541
|
+
try {
|
|
542
|
+
return okToolResult(await deps.readService.summarizeWalletAssets({ account: target.account, cursor }));
|
|
543
|
+
}
|
|
544
|
+
catch (error) {
|
|
545
|
+
return readServiceError(error, deps);
|
|
546
|
+
}
|
|
547
|
+
});
|
|
548
|
+
server.registerTool(TOOL_NAMES.readClassifyWalletAssets, {
|
|
549
|
+
title: "Classify wallet assets",
|
|
550
|
+
description: "Classify current Sui mainnet coin balances. Not transaction history, receipt proof, or P&L.",
|
|
551
|
+
inputSchema: {
|
|
552
|
+
account: suiAddressStringSchema.optional(),
|
|
553
|
+
cursor: z.string().min(1).optional()
|
|
554
|
+
},
|
|
555
|
+
outputSchema: successOutputSchema({
|
|
556
|
+
account: z.string(),
|
|
557
|
+
status: z.literal("ok"),
|
|
558
|
+
fetchedAt: fetchedAtSchema,
|
|
559
|
+
userAnswerUse: userAnswerUseSchema,
|
|
560
|
+
quantitySemantics: walletBalanceQuantitySemanticsSchema,
|
|
561
|
+
source: readSourceSchema,
|
|
562
|
+
classifiedAssets: z.array(classifiedWalletAssetSchema),
|
|
563
|
+
uninspectedAssetClasses: z.array(uninspectedAssetClassSchema),
|
|
564
|
+
hasNextPage: z.boolean(),
|
|
565
|
+
cursor: z.string().nullable()
|
|
566
|
+
}),
|
|
567
|
+
annotations: { readOnlyHint: false, openWorldHint: false }
|
|
568
|
+
}, async ({ account, cursor }) => {
|
|
569
|
+
const target = await resolveExplicitOrActiveAccount(account, deps);
|
|
570
|
+
if (target.status === "error") {
|
|
571
|
+
return target.result;
|
|
572
|
+
}
|
|
573
|
+
try {
|
|
574
|
+
return okToolResult(await deps.readService.classifyWalletAssets({ account: target.account, cursor }));
|
|
575
|
+
}
|
|
576
|
+
catch (error) {
|
|
577
|
+
return readServiceError(error, deps);
|
|
578
|
+
}
|
|
579
|
+
});
|
|
580
|
+
server.registerTool(TOOL_NAMES.readListSettlementAssetGroups, {
|
|
581
|
+
title: "List settlement asset groups",
|
|
582
|
+
description: "List supported mainnet settlement asset groups derived from pinned SDK registries.",
|
|
583
|
+
inputSchema: z.object({}).optional(),
|
|
584
|
+
outputSchema: successOutputSchema({
|
|
585
|
+
status: z.literal("ok"),
|
|
586
|
+
fetchedAt: fetchedAtSchema,
|
|
587
|
+
assetGroups: z.array(settlementAssetGroupSchema)
|
|
588
|
+
}),
|
|
589
|
+
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
590
|
+
}, async () => {
|
|
591
|
+
try {
|
|
592
|
+
return okToolResult(deps.readService.listSettlementAssetGroups());
|
|
593
|
+
}
|
|
594
|
+
catch (error) {
|
|
595
|
+
return readServiceError(error, deps);
|
|
596
|
+
}
|
|
597
|
+
});
|
|
598
|
+
server.registerTool(TOOL_NAMES.readSummarizeSettlementAssetGroupParity, {
|
|
599
|
+
title: "Summarize settlement asset group parity",
|
|
600
|
+
description: "Summarize USD-denominated asset group parity from direct DeepBook mid-price snapshots. Not settlement selection or fiat cash-out.",
|
|
601
|
+
inputSchema: {
|
|
602
|
+
denomination: z.string().min(1),
|
|
603
|
+
referenceAssetSymbol: z.string().min(1).optional()
|
|
604
|
+
},
|
|
605
|
+
outputSchema: successOutputSchema({
|
|
606
|
+
status: z.literal("ok"),
|
|
607
|
+
fetchedAt: fetchedAtSchema,
|
|
608
|
+
denomination: settlementAssetGroupAliasSchema,
|
|
609
|
+
assetGroupId: z.literal(SUI_USD_SETTLEMENT_ASSET_GROUP_ID),
|
|
610
|
+
userAnswerUse: userAnswerUseSchema,
|
|
611
|
+
answerSourceStatus: answerSourceStatusSchema,
|
|
612
|
+
referenceAsset: settlementAssetGroupAssetSchema.extend({
|
|
613
|
+
role: z.literal("measurement_reference_not_settlement_choice")
|
|
614
|
+
}),
|
|
615
|
+
quantitySemantics: settlementAssetGroupParityQuantitySemanticsSchema,
|
|
616
|
+
evidenceSources: z.object({
|
|
617
|
+
settlementAssetGroup: settlementAssetGroupEvidenceSourcesSchema,
|
|
618
|
+
midPrice: z.object({
|
|
619
|
+
sdk: z.literal("@mysten/deepbook-v3"),
|
|
620
|
+
transport: z.literal("grpc"),
|
|
621
|
+
simulation: z.literal("client.core.simulateTransaction"),
|
|
622
|
+
method: z.literal("midPrice"),
|
|
623
|
+
precision: z.literal(DEEPBOOK_MID_PRICE_PRECISION)
|
|
624
|
+
})
|
|
625
|
+
}),
|
|
626
|
+
assets: z.array(settlementAssetGroupParityAssetSchema),
|
|
627
|
+
statistics: z.object({
|
|
628
|
+
status: z.literal("available"),
|
|
629
|
+
sampleCount: z.number().int().nonnegative(),
|
|
630
|
+
unavailableAssetCount: z.number().int().nonnegative(),
|
|
631
|
+
parityDirection: z.literal("reference_asset_per_group_asset"),
|
|
632
|
+
calculation: z.literal("computed_from_available_direct_deepbook_mid_price_snapshots"),
|
|
633
|
+
min: z.object({
|
|
634
|
+
symbol: z.string(),
|
|
635
|
+
parityPrice: z.number().positive()
|
|
636
|
+
}),
|
|
637
|
+
max: z.object({
|
|
638
|
+
symbol: z.string(),
|
|
639
|
+
parityPrice: z.number().positive()
|
|
640
|
+
}),
|
|
641
|
+
mean: z.object({
|
|
642
|
+
parityPrice: z.number().positive()
|
|
643
|
+
}),
|
|
644
|
+
median: z.object({
|
|
645
|
+
parityPrice: z.number().positive()
|
|
646
|
+
})
|
|
647
|
+
}),
|
|
648
|
+
responseSummary: settlementAssetGroupParityResponseSummarySchema,
|
|
649
|
+
unsupportedClaims: z.array(settlementAssetGroupParityUnsupportedClaimsSchema)
|
|
650
|
+
}),
|
|
651
|
+
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
652
|
+
}, async ({ denomination, referenceAssetSymbol }) => {
|
|
653
|
+
try {
|
|
654
|
+
return okToolResult(withAnswerSourceStatus(await deps.readService.summarizeSettlementAssetGroupParity({
|
|
655
|
+
denomination,
|
|
656
|
+
referenceAssetSymbol,
|
|
657
|
+
simulationSender: DEFAULT_DEEPBOOK_SIMULATION_SENDER
|
|
658
|
+
}), USD_PARITY_ANSWER_REQUIRED_TOOLS));
|
|
659
|
+
}
|
|
660
|
+
catch (error) {
|
|
661
|
+
return readServiceError(error, deps);
|
|
662
|
+
}
|
|
663
|
+
});
|
|
664
|
+
server.registerTool(TOOL_NAMES.readPreviewIntentEvidence, {
|
|
665
|
+
title: "Preview intent evidence",
|
|
666
|
+
description: "Build wallet and DeepBook evidence for a natural-language settlement intent.",
|
|
667
|
+
inputSchema: {
|
|
668
|
+
account: suiAddressStringSchema.optional(),
|
|
669
|
+
intentKind: z.enum(["cover_payment_like_amount", "summarize_settlement_asset_group_balance"]),
|
|
670
|
+
denomination: z.string().min(1),
|
|
671
|
+
requiredDisplayAmount: z.string().min(1).optional(),
|
|
672
|
+
targetAssetSymbol: z.string().min(1).optional(),
|
|
673
|
+
targetAssetSelectionSource: z.enum(INTENT_EVIDENCE_TARGET_ASSET_SELECTION_SOURCES).optional(),
|
|
674
|
+
acceptedSourceAssetSymbols: z.array(z.string().min(1)).optional()
|
|
675
|
+
},
|
|
676
|
+
outputSchema: successOutputSchema({
|
|
677
|
+
status: z.literal("ok"),
|
|
678
|
+
account: z.string(),
|
|
679
|
+
fetchedAt: fetchedAtSchema,
|
|
680
|
+
userAnswerUse: userAnswerUseSchema,
|
|
681
|
+
answerSourceStatus: answerSourceStatusSchema,
|
|
682
|
+
intent: z.object({
|
|
683
|
+
intentKind: z.enum(["cover_payment_like_amount", "summarize_settlement_asset_group_balance"]),
|
|
684
|
+
denomination: settlementAssetGroupAliasSchema,
|
|
685
|
+
requiredDisplayAmount: z.string().optional(),
|
|
686
|
+
targetAssetSymbol: z.string().optional(),
|
|
687
|
+
targetAssetSelectionSource: z.enum(INTENT_EVIDENCE_TARGET_ASSET_SELECTION_SOURCES).optional(),
|
|
688
|
+
acceptedSourceAssetSymbols: z.array(z.string()).optional()
|
|
689
|
+
}),
|
|
690
|
+
quantitySemantics: intentEvidenceQuantitySemanticsSchema,
|
|
691
|
+
evidenceSources: z.object({
|
|
692
|
+
walletBalances: readSourceSchema,
|
|
693
|
+
settlementAssetGroup: settlementAssetGroupEvidenceSourcesSchema,
|
|
694
|
+
quoteEvidence: z.literal("pinned_deepbook_sdk_when_target_asset_selected")
|
|
695
|
+
}),
|
|
696
|
+
settlementAssetGroup: intentEvidenceSettlementAssetGroupSchema,
|
|
697
|
+
balances: z.array(intentEvidenceAssetGroupBalanceSchema),
|
|
698
|
+
aggregate: intentEvidenceAggregateSchema,
|
|
699
|
+
settlementAssetCoverage: intentEvidenceSettlementAssetCoverageSchema,
|
|
700
|
+
selectedTarget: intentEvidenceSelectedTargetSchema.optional(),
|
|
701
|
+
candidateConversions: z.array(intentEvidenceCandidateConversionSchema),
|
|
702
|
+
blockedReasons: z.array(z.enum(["wallet_balance_page_limit_exceeded", "wallet_balance_pagination_did_not_advance"])),
|
|
703
|
+
responseEvidence: intentEvidenceResponseEvidenceSchema,
|
|
704
|
+
responseSummary: intentEvidenceResponseSummarySchema,
|
|
705
|
+
requiredUserChoices: z.array(z.string()),
|
|
706
|
+
supportedClaims: z.array(z.string()),
|
|
707
|
+
unsupportedClaims: z.array(intentEvidenceUnsupportedClaimsSchema),
|
|
708
|
+
uninspectedAssetClasses: z.array(uninspectedAssetClassSchema),
|
|
709
|
+
inspectedBalancePages: z.number().int().nonnegative(),
|
|
710
|
+
inspectedCoinBalanceCount: z.number().int().nonnegative()
|
|
711
|
+
}),
|
|
712
|
+
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
713
|
+
}, async ({ account, intentKind, denomination, requiredDisplayAmount, targetAssetSymbol, targetAssetSelectionSource, acceptedSourceAssetSymbols }) => {
|
|
714
|
+
const target = await resolveExplicitOrActiveAccount(account, deps);
|
|
715
|
+
if (target.status === "error") {
|
|
716
|
+
return target.result;
|
|
717
|
+
}
|
|
718
|
+
try {
|
|
719
|
+
return okToolResult(withAnswerSourceStatus(await deps.readService.previewIntentEvidence({
|
|
720
|
+
account: target.account,
|
|
721
|
+
intentKind,
|
|
722
|
+
denomination,
|
|
723
|
+
requiredDisplayAmount,
|
|
724
|
+
targetAssetSymbol,
|
|
725
|
+
targetAssetSelectionSource,
|
|
726
|
+
acceptedSourceAssetSymbols
|
|
727
|
+
}), USD_INTENT_ANSWER_REQUIRED_TOOLS));
|
|
728
|
+
}
|
|
729
|
+
catch (error) {
|
|
730
|
+
return readServiceError(error, deps);
|
|
731
|
+
}
|
|
732
|
+
});
|
|
733
|
+
}
|