@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,381 @@
|
|
|
1
|
+
import { EXTERNAL_PROPOSAL_SETTLEMENT_TOKEN_SELECTION_UNSUPPORTED_CLAIM_ID } from "../core/proposal/types.js";
|
|
2
|
+
import { TOOL_NAMES } from "./toolNames.js";
|
|
3
|
+
export function interactionStatusUserAnswerUse() {
|
|
4
|
+
return {
|
|
5
|
+
canAnswer: [
|
|
6
|
+
"current_active_account_read_context",
|
|
7
|
+
"pending_local_wallet_identity_interactions",
|
|
8
|
+
"pending_local_review_interactions"
|
|
9
|
+
],
|
|
10
|
+
cannotAnswer: [
|
|
11
|
+
"wallet_login_or_authentication",
|
|
12
|
+
"wallet_custody_or_authorization",
|
|
13
|
+
"transaction_execution_result",
|
|
14
|
+
"transaction_building",
|
|
15
|
+
"signing_data_or_readiness",
|
|
16
|
+
"complete_wallet_history",
|
|
17
|
+
"profit_or_pnl"
|
|
18
|
+
],
|
|
19
|
+
answerFields: ["activeAccount", "pendingWalletIdentitySessions", "pendingReviewSessions"],
|
|
20
|
+
diagnosticOnlyFields: [
|
|
21
|
+
"pendingWalletIdentitySessions.truncated",
|
|
22
|
+
"pendingReviewSessions.truncated"
|
|
23
|
+
],
|
|
24
|
+
followUp: {
|
|
25
|
+
tool: TOOL_NAMES.sessionGetReviewStatus,
|
|
26
|
+
inputFields: ["pendingReviewSessions.items[].reviewSessionId"],
|
|
27
|
+
answerFields: ["pollingStatus", "statusCategory", "reviewState"],
|
|
28
|
+
reason: "Use for the current status of a specific pending review; interaction status is a local overview."
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export function walletIdentityUserAnswerUse(fields = {}) {
|
|
33
|
+
const hasAccount = fields.hasAccount ?? false;
|
|
34
|
+
const hasFailure = fields.hasFailure ?? false;
|
|
35
|
+
const hasWalletInfo = fields.hasWalletInfo ?? false;
|
|
36
|
+
const hasWaitOutcome = fields.hasWaitOutcome ?? false;
|
|
37
|
+
const hasOpenFields = fields.hasOpenFields ?? false;
|
|
38
|
+
const followUp = hasOpenFields || (!hasAccount && !hasFailure)
|
|
39
|
+
? {
|
|
40
|
+
tool: TOOL_NAMES.sessionWaitWalletIdentity,
|
|
41
|
+
inputFields: ["walletSessionId"],
|
|
42
|
+
answerFields: ["status", "account", "chain", "waitOutcome"],
|
|
43
|
+
reason: "Use after giving the walletUrl to check whether the local wallet identity capture connected, timed out, failed, or was rejected."
|
|
44
|
+
}
|
|
45
|
+
: hasAccount
|
|
46
|
+
? {
|
|
47
|
+
tool: TOOL_NAMES.accountGetActiveAccount,
|
|
48
|
+
answerFields: ["status", "account", "boundary"],
|
|
49
|
+
reason: "Use after a connected wallet identity result before telling the user which active account read context is stored."
|
|
50
|
+
}
|
|
51
|
+
: undefined;
|
|
52
|
+
return {
|
|
53
|
+
canAnswer: [
|
|
54
|
+
"local_wallet_identity_capture_status",
|
|
55
|
+
...(hasAccount ? ["active_account_candidate_captured_for_read_context"] : []),
|
|
56
|
+
...(hasFailure ? ["wallet_identity_failure_reason"] : []),
|
|
57
|
+
...(hasWaitOutcome ? ["whether_the_bounded_wait_finished_or_timed_out"] : [])
|
|
58
|
+
],
|
|
59
|
+
cannotAnswer: [
|
|
60
|
+
"wallet_login_or_authentication",
|
|
61
|
+
"wallet_custody_or_authorization",
|
|
62
|
+
"transaction_authorization",
|
|
63
|
+
"transaction_building",
|
|
64
|
+
"signing_data_or_readiness",
|
|
65
|
+
"wallet_balance_or_activity",
|
|
66
|
+
"complete_wallet_history",
|
|
67
|
+
"profit_or_pnl"
|
|
68
|
+
],
|
|
69
|
+
answerFields: [
|
|
70
|
+
...(hasWaitOutcome ? ["waitOutcome"] : []),
|
|
71
|
+
"walletSessionId",
|
|
72
|
+
...(hasOpenFields ? ["walletUrl", "openTarget", "accessScope"] : []),
|
|
73
|
+
"status",
|
|
74
|
+
...(hasAccount ? ["account", "chain"] : []),
|
|
75
|
+
...(hasFailure ? ["failureReason"] : []),
|
|
76
|
+
"expiresAt",
|
|
77
|
+
"lastActivityAt",
|
|
78
|
+
"pollingHint"
|
|
79
|
+
],
|
|
80
|
+
diagnosticOnlyFields: [
|
|
81
|
+
...(hasWalletInfo ? ["walletName", "walletId"] : []),
|
|
82
|
+
...(hasFailure ? ["failureDetail"] : [])
|
|
83
|
+
],
|
|
84
|
+
...(followUp === undefined ? {} : { followUp })
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
export function executionResultUserAnswerUse(fields = {}) {
|
|
88
|
+
const hasExecutionResult = fields.hasExecutionResult ?? false;
|
|
89
|
+
const hasWaitOutcome = fields.hasWaitOutcome ?? false;
|
|
90
|
+
return {
|
|
91
|
+
canAnswer: [
|
|
92
|
+
"current_local_execution_polling_status",
|
|
93
|
+
"whether_user_action_or_chain_polling_is_still_pending",
|
|
94
|
+
...(hasExecutionResult ? ["recorded_review_execution_result"] : [])
|
|
95
|
+
],
|
|
96
|
+
cannotAnswer: [
|
|
97
|
+
...(hasExecutionResult ? [] : ["recorded_review_execution_result_without_executionResult_field"]),
|
|
98
|
+
"transaction_execution_guarantee",
|
|
99
|
+
"absolute_safety_verdict",
|
|
100
|
+
"route_quality",
|
|
101
|
+
"wallet_custody_or_authorization",
|
|
102
|
+
"transaction_building",
|
|
103
|
+
"signing_data_or_readiness",
|
|
104
|
+
"complete_wallet_history",
|
|
105
|
+
"profit_or_pnl"
|
|
106
|
+
],
|
|
107
|
+
answerFields: [
|
|
108
|
+
...(hasWaitOutcome ? ["waitOutcome"] : []),
|
|
109
|
+
"reviewSessionId",
|
|
110
|
+
"status",
|
|
111
|
+
"statusCategory",
|
|
112
|
+
"lastActivityAt",
|
|
113
|
+
"pollingHint",
|
|
114
|
+
...(hasExecutionResult ? ["executionResult"] : [])
|
|
115
|
+
],
|
|
116
|
+
conclusionRuleFields: [
|
|
117
|
+
"statusCategory",
|
|
118
|
+
"pollingHint.finalStatuses",
|
|
119
|
+
"pollingHint.userActionRequiredStatuses",
|
|
120
|
+
"pollingHint.nonTerminalStatuses"
|
|
121
|
+
],
|
|
122
|
+
diagnosticOnlyFields: [],
|
|
123
|
+
followUp: {
|
|
124
|
+
tool: TOOL_NAMES.sessionGetReviewStatus,
|
|
125
|
+
inputFields: ["reviewSessionId"],
|
|
126
|
+
answerFields: ["pollingStatus", "statusCategory", "reviewState"],
|
|
127
|
+
reason: "Use for current review state and checks; execution polling status alone is not a safety or signing verdict."
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
export function reviewStatusUserAnswerUse(hasReviewState, hasAdapterLifecycle = false, hasHumanReadableReview = false, hasSimulation = false) {
|
|
132
|
+
return {
|
|
133
|
+
canAnswer: [
|
|
134
|
+
"current_local_review_session_status",
|
|
135
|
+
"current_review_checks_when_reviewState_is_present",
|
|
136
|
+
...(hasAdapterLifecycle ? ["current_deepbook_review_lifecycle_stage_status"] : []),
|
|
137
|
+
...(hasHumanReadableReview ? ["current_human_readable_review_facts_projected_from_verified_review_evidence"] : []),
|
|
138
|
+
...(hasSimulation ? ["current_review_time_simulation_summary_projected_from_private_review_evidence"] : []),
|
|
139
|
+
"whether_user_action_or_chain_polling_is_still_pending"
|
|
140
|
+
],
|
|
141
|
+
cannotAnswer: [
|
|
142
|
+
"transaction_execution_guarantee",
|
|
143
|
+
"absolute_safety_verdict",
|
|
144
|
+
"route_quality",
|
|
145
|
+
"wallet_custody_or_authorization",
|
|
146
|
+
"transaction_building",
|
|
147
|
+
"transaction_bytes_or_digest_values",
|
|
148
|
+
"signing_data_or_readiness",
|
|
149
|
+
"complete_wallet_history",
|
|
150
|
+
"profit_or_pnl"
|
|
151
|
+
],
|
|
152
|
+
answerFields: [
|
|
153
|
+
"reviewSessionId",
|
|
154
|
+
"internalStatus",
|
|
155
|
+
"pollingStatus",
|
|
156
|
+
"statusCategory",
|
|
157
|
+
...(hasReviewState
|
|
158
|
+
? [
|
|
159
|
+
"reviewState.status",
|
|
160
|
+
"reviewState.checks",
|
|
161
|
+
"reviewState.blockedReason",
|
|
162
|
+
"reviewState.refreshReason"
|
|
163
|
+
]
|
|
164
|
+
: []),
|
|
165
|
+
...(hasAdapterLifecycle
|
|
166
|
+
? [
|
|
167
|
+
"reviewState.adapterLifecycle",
|
|
168
|
+
"reviewState.adapterLifecycle.stageCatalogId",
|
|
169
|
+
"reviewState.adapterLifecycle.completedStages",
|
|
170
|
+
"reviewState.adapterLifecycle.missingStages"
|
|
171
|
+
]
|
|
172
|
+
: []),
|
|
173
|
+
...(hasHumanReadableReview
|
|
174
|
+
? [
|
|
175
|
+
"reviewState.humanReadableReview",
|
|
176
|
+
"reviewState.humanReadableReview.kind",
|
|
177
|
+
"reviewState.humanReadableReview.proposedAction",
|
|
178
|
+
"reviewState.humanReadableReview.assetFlow",
|
|
179
|
+
"reviewState.humanReadableReview.targets",
|
|
180
|
+
"reviewState.humanReadableReview.evidenceUsed",
|
|
181
|
+
"reviewState.humanReadableReview.missingEvidence",
|
|
182
|
+
"reviewState.humanReadableReview.requiredUserChoices",
|
|
183
|
+
"reviewState.humanReadableReview.freshness",
|
|
184
|
+
"reviewState.humanReadableReview.unsupportedClaims",
|
|
185
|
+
"reviewState.humanReadableReview.blockingChecks"
|
|
186
|
+
]
|
|
187
|
+
: []),
|
|
188
|
+
...(hasSimulation
|
|
189
|
+
? [
|
|
190
|
+
"reviewState.simulation",
|
|
191
|
+
"reviewState.simulation.provider",
|
|
192
|
+
"reviewState.simulation.checksEnabled",
|
|
193
|
+
"reviewState.simulation.success",
|
|
194
|
+
"reviewState.simulation.gasCostSummary",
|
|
195
|
+
"reviewState.simulation.gasCostSummary.computationCostRaw",
|
|
196
|
+
"reviewState.simulation.gasCostSummary.storageCostRaw",
|
|
197
|
+
"reviewState.simulation.gasCostSummary.storageRebateRaw",
|
|
198
|
+
"reviewState.simulation.gasCostSummary.nonRefundableStorageFeeRaw",
|
|
199
|
+
"reviewState.simulation.balanceChanges",
|
|
200
|
+
"reviewState.simulation.objectChanges"
|
|
201
|
+
]
|
|
202
|
+
: []),
|
|
203
|
+
"lastActivityAt"
|
|
204
|
+
],
|
|
205
|
+
diagnosticOnlyFields: [],
|
|
206
|
+
followUp: {
|
|
207
|
+
tool: TOOL_NAMES.sessionGetExecutionResult,
|
|
208
|
+
inputFields: ["reviewSessionId"],
|
|
209
|
+
answerFields: ["executionResult"],
|
|
210
|
+
reason: "Use when the user asks for a recorded execution result; status alone is not transaction execution proof."
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
export function reviewActivityListUserAnswerUse() {
|
|
215
|
+
return {
|
|
216
|
+
canAnswer: ["local_review_session_rows_for_the_selected_account", "current_stored_review_status_counts_by_row"],
|
|
217
|
+
cannotAnswer: [
|
|
218
|
+
"sui_wallet_transaction_history",
|
|
219
|
+
"complete_wallet_history",
|
|
220
|
+
"execution_result_detail",
|
|
221
|
+
"transaction_building",
|
|
222
|
+
"signing_data_or_readiness",
|
|
223
|
+
"profit_or_pnl"
|
|
224
|
+
],
|
|
225
|
+
answerFields: ["activities", "activities[].reviewSessionId", "activities[].currentStatus", "activities[].updatedAt"],
|
|
226
|
+
diagnosticOnlyFields: ["dataScope", "accountSource", "lowSampleWarning", "lowSampleThreshold", "truncated"],
|
|
227
|
+
followUp: {
|
|
228
|
+
tool: TOOL_NAMES.readGetReviewSessionDetail,
|
|
229
|
+
inputFields: ["activities[].reviewSessionId"],
|
|
230
|
+
answerFields: ["session", "planJson", "intentJson", "stateSnapshots", "transitions", "execution"],
|
|
231
|
+
reason: "Use for stored plan, state snapshot, transition, and execution detail for one review session."
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
export function reviewFunnelUserAnswerUse() {
|
|
236
|
+
return {
|
|
237
|
+
canAnswer: ["local_review_lifecycle_counts_for_the_selected_account"],
|
|
238
|
+
cannotAnswer: [
|
|
239
|
+
"sui_wallet_transaction_history",
|
|
240
|
+
"complete_wallet_history",
|
|
241
|
+
"execution_success_rate_for_all_wallet_activity",
|
|
242
|
+
"transaction_building",
|
|
243
|
+
"signing_data_or_readiness",
|
|
244
|
+
"profit_or_pnl"
|
|
245
|
+
],
|
|
246
|
+
answerFields: ["summary"],
|
|
247
|
+
diagnosticOnlyFields: ["dataScope", "accountSource", "lowSampleWarning", "lowSampleThreshold", "truncated"]
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
export function prepareActionReviewUserAnswerUse(fields = {}) {
|
|
251
|
+
const hasBlockingPreliminaryChecks = fields.hasBlockingPreliminaryChecks ?? false;
|
|
252
|
+
return {
|
|
253
|
+
canAnswer: [
|
|
254
|
+
"review_session_url_for_local_review_page",
|
|
255
|
+
"preliminary_check_results_for_proposed_plan",
|
|
256
|
+
"proposed_plan_asset_flow_preview",
|
|
257
|
+
...(hasBlockingPreliminaryChecks ? ["why_signing_is_currently_blocked_for_this_review"] : [])
|
|
258
|
+
],
|
|
259
|
+
cannotAnswer: [
|
|
260
|
+
"transaction_execution_guarantee",
|
|
261
|
+
"transaction_building",
|
|
262
|
+
"signing_data_or_readiness",
|
|
263
|
+
"wallet_custody_or_authorization",
|
|
264
|
+
"route_quality",
|
|
265
|
+
"fiat_usd_cash_out",
|
|
266
|
+
"profit_or_pnl"
|
|
267
|
+
],
|
|
268
|
+
answerFields: [
|
|
269
|
+
"reviewSessionId",
|
|
270
|
+
"reviewUrl",
|
|
271
|
+
"plans",
|
|
272
|
+
"plans[].title",
|
|
273
|
+
"plans[].summary",
|
|
274
|
+
"plans[].assetFlowPreview",
|
|
275
|
+
"plans[].preliminaryChecks",
|
|
276
|
+
"preliminaryChecks"
|
|
277
|
+
],
|
|
278
|
+
conclusionRuleFields: ["plans[].preliminaryChecks", "preliminaryChecks"],
|
|
279
|
+
diagnosticOnlyFields: ["plans[].adapterData", "plans[].createdAt", "plans[].id"],
|
|
280
|
+
followUp: {
|
|
281
|
+
tool: TOOL_NAMES.sessionGetReviewStatus,
|
|
282
|
+
inputFields: ["reviewSessionId"],
|
|
283
|
+
answerFields: ["pollingStatus", "statusCategory", "reviewState"],
|
|
284
|
+
reason: "Use for current review readiness; the prepare response only describes the proposal and any blocking preliminary checks."
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
export function prepareExternalProposalReviewUserAnswerUse() {
|
|
289
|
+
return {
|
|
290
|
+
canAnswer: [
|
|
291
|
+
"review_session_url_for_local_review_page",
|
|
292
|
+
"external_proposal_summary_for_local_review",
|
|
293
|
+
"proposal_asset_flow_preview",
|
|
294
|
+
"proposal_recipient_or_target_fields",
|
|
295
|
+
"missing_evidence_for_non_signable_review",
|
|
296
|
+
"required_user_choices_for_non_signable_review",
|
|
297
|
+
"unsupported_claims_for_non_signable_review",
|
|
298
|
+
"why_signing_is_currently_blocked_for_this_review"
|
|
299
|
+
],
|
|
300
|
+
cannotAnswer: [
|
|
301
|
+
"transaction_execution_guarantee",
|
|
302
|
+
"transaction_building",
|
|
303
|
+
"signing_data_or_readiness",
|
|
304
|
+
"wallet_custody_or_authorization",
|
|
305
|
+
"route_quality",
|
|
306
|
+
EXTERNAL_PROPOSAL_SETTLEMENT_TOKEN_SELECTION_UNSUPPORTED_CLAIM_ID,
|
|
307
|
+
"fiat_usd_cash_out",
|
|
308
|
+
"profit_or_pnl"
|
|
309
|
+
],
|
|
310
|
+
answerFields: [
|
|
311
|
+
"reviewSessionId",
|
|
312
|
+
"reviewUrl",
|
|
313
|
+
"plans",
|
|
314
|
+
"plans[].reviewModel.proposedAction",
|
|
315
|
+
"plans[].reviewModel.assetFlow",
|
|
316
|
+
"plans[].reviewModel.recipients",
|
|
317
|
+
"plans[].reviewModel.targets",
|
|
318
|
+
"plans[].reviewModel.evidenceUsed",
|
|
319
|
+
"plans[].reviewModel.missingEvidence",
|
|
320
|
+
"plans[].reviewModel.requiredUserChoices",
|
|
321
|
+
"plans[].reviewModel.unsupportedClaims",
|
|
322
|
+
"plans[].reviewModel.freshness",
|
|
323
|
+
"plans[].reviewModel.blockingChecks",
|
|
324
|
+
"plans[].reviewModel.nonSignableReason",
|
|
325
|
+
"preliminaryChecks"
|
|
326
|
+
],
|
|
327
|
+
conclusionRuleFields: [
|
|
328
|
+
"plans[].reviewModel.unsupportedClaims",
|
|
329
|
+
"plans[].reviewModel.nonSignableReason",
|
|
330
|
+
"preliminaryChecks"
|
|
331
|
+
],
|
|
332
|
+
diagnosticOnlyFields: [
|
|
333
|
+
"plans[].adapterData",
|
|
334
|
+
"plans[].createdAt",
|
|
335
|
+
"plans[].id",
|
|
336
|
+
"plans[].reviewModel.rejectedExecutableFields"
|
|
337
|
+
],
|
|
338
|
+
followUp: {
|
|
339
|
+
tool: TOOL_NAMES.sessionGetReviewStatus,
|
|
340
|
+
inputFields: ["reviewSessionId"],
|
|
341
|
+
answerFields: ["pollingStatus", "statusCategory", "reviewState"],
|
|
342
|
+
reason: "Use for current review status after the user opens the local page; the prepare response does not make the proposal signable."
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
export function reviewSessionDetailUserAnswerUse(hasExecution = false) {
|
|
347
|
+
return {
|
|
348
|
+
canAnswer: [
|
|
349
|
+
"stored_local_review_session_plan_and_lifecycle_detail",
|
|
350
|
+
"stored_review_state_snapshots",
|
|
351
|
+
...(hasExecution ? ["stored_review_execution_result"] : [])
|
|
352
|
+
],
|
|
353
|
+
cannotAnswer: [
|
|
354
|
+
"sui_wallet_transaction_history",
|
|
355
|
+
"complete_wallet_history",
|
|
356
|
+
...(hasExecution ? [] : ["stored_review_execution_result_without_execution_field"]),
|
|
357
|
+
"transaction_execution_guarantee",
|
|
358
|
+
"absolute_safety_verdict",
|
|
359
|
+
"route_quality",
|
|
360
|
+
"wallet_custody_or_authorization",
|
|
361
|
+
"transaction_building",
|
|
362
|
+
"signing_data_or_readiness",
|
|
363
|
+
"profit_or_pnl"
|
|
364
|
+
],
|
|
365
|
+
answerFields: [
|
|
366
|
+
"session",
|
|
367
|
+
"planJson",
|
|
368
|
+
"intentJson",
|
|
369
|
+
"stateSnapshots",
|
|
370
|
+
"transitions",
|
|
371
|
+
...(hasExecution ? ["execution", "execution.resultJson"] : [])
|
|
372
|
+
],
|
|
373
|
+
diagnosticOnlyFields: ["dataScope", "accountSource", "lowSampleWarning", "lowSampleThreshold", "truncated"],
|
|
374
|
+
followUp: {
|
|
375
|
+
tool: TOOL_NAMES.sessionGetReviewStatus,
|
|
376
|
+
inputFields: ["session.reviewSessionId"],
|
|
377
|
+
answerFields: ["pollingStatus", "reviewState"],
|
|
378
|
+
reason: "Use for the current in-memory review status; stored detail is local review history."
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { assertNoForbiddenMcpFields } from "../core/action/forbiddenFields.js";
|
|
2
|
+
export function okToolResult(data) {
|
|
3
|
+
const payload = { ok: true, data };
|
|
4
|
+
assertNoForbiddenMcpFields(payload);
|
|
5
|
+
return {
|
|
6
|
+
structuredContent: payload,
|
|
7
|
+
content: [{ type: "text", text: JSON.stringify(payload, null, 2) }]
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export function errorToolResult(error) {
|
|
11
|
+
const payload = { ok: false, error };
|
|
12
|
+
assertNoForbiddenMcpFields(payload);
|
|
13
|
+
return {
|
|
14
|
+
isError: true,
|
|
15
|
+
content: [{ type: "text", text: JSON.stringify(payload, null, 2) }]
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { registerMcpPrompts } from "./prompts.js";
|
|
3
|
+
import { registerMcpResources } from "./resources.js";
|
|
4
|
+
import { SERVER_INSTRUCTIONS, SERVER_NAME, SERVER_VERSION } from "./serverInfo.js";
|
|
5
|
+
import { assertAllToolNamesValid } from "./toolNames.js";
|
|
6
|
+
import { registerActionTools } from "./tools/action/prepareSuiActionReview.js";
|
|
7
|
+
import { registerAccountTools } from "./tools/account/index.js";
|
|
8
|
+
import { registerReadTools } from "./tools/read/index.js";
|
|
9
|
+
import { registerSettingsTools } from "./tools/settings/index.js";
|
|
10
|
+
import { registerSessionTools } from "./tools/session/index.js";
|
|
11
|
+
export function createMcpServer(deps) {
|
|
12
|
+
assertAllToolNamesValid();
|
|
13
|
+
const server = new McpServer({
|
|
14
|
+
name: SERVER_NAME,
|
|
15
|
+
version: SERVER_VERSION
|
|
16
|
+
}, {
|
|
17
|
+
instructions: SERVER_INSTRUCTIONS
|
|
18
|
+
});
|
|
19
|
+
registerMcpResources(server);
|
|
20
|
+
registerMcpPrompts(server, deps.promptSurfaces ?? []);
|
|
21
|
+
registerAccountTools(server, deps);
|
|
22
|
+
registerReadTools(server, deps);
|
|
23
|
+
registerSettingsTools(server, deps);
|
|
24
|
+
registerActionTools(server, deps);
|
|
25
|
+
registerSessionTools(server, deps);
|
|
26
|
+
return server;
|
|
27
|
+
}
|
|
28
|
+
export async function startMcp(server, transport) {
|
|
29
|
+
await server.connect(transport);
|
|
30
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { dirname, resolve } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { TOOL_NAMES } from "./toolNames.js";
|
|
5
|
+
const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), "../..");
|
|
6
|
+
const packageMetadata = JSON.parse(readFileSync(resolve(packageRoot, "package.json"), "utf8"));
|
|
7
|
+
export const PACKAGE_NAME = packageMetadata.name;
|
|
8
|
+
export const SERVER_NAME = "say-ur-intent";
|
|
9
|
+
export const SERVER_VERSION = packageMetadata.version;
|
|
10
|
+
export const SERVER_NETWORK = "mainnet";
|
|
11
|
+
export const SERVER_RUNTIME = "local_stdio";
|
|
12
|
+
export const SERVER_TRANSPORT = "grpc_graphql";
|
|
13
|
+
export const USD_INTENT_ANSWER_REQUIRED_TOOLS = [
|
|
14
|
+
TOOL_NAMES.readGetServerStatus,
|
|
15
|
+
TOOL_NAMES.readListSettlementAssetGroups,
|
|
16
|
+
TOOL_NAMES.readPreviewIntentEvidence
|
|
17
|
+
];
|
|
18
|
+
export const USD_PARITY_ANSWER_REQUIRED_TOOLS = [
|
|
19
|
+
TOOL_NAMES.readGetServerStatus,
|
|
20
|
+
TOOL_NAMES.readListSettlementAssetGroups,
|
|
21
|
+
TOOL_NAMES.readSummarizeSettlementAssetGroupParity
|
|
22
|
+
];
|
|
23
|
+
export const EVIDENCE_POLICY = {
|
|
24
|
+
version: "intent-evidence-alpha-2026-05-23",
|
|
25
|
+
releaseGate: "intent_evidence_v1",
|
|
26
|
+
requiredFirstCheck: true,
|
|
27
|
+
requiredStatusFields: [
|
|
28
|
+
"packageName",
|
|
29
|
+
"version",
|
|
30
|
+
"evidencePolicy.version",
|
|
31
|
+
"network",
|
|
32
|
+
"implementedToolsCount"
|
|
33
|
+
],
|
|
34
|
+
gates: [
|
|
35
|
+
"server_status_version_check",
|
|
36
|
+
"natural_language_settlement_asset_group_evidence",
|
|
37
|
+
"sdk_sot_no_duplicate_registry_or_amount_parser",
|
|
38
|
+
"requested_account_inference_policy",
|
|
39
|
+
"wallet_balance_snapshot_not_receipt_proof",
|
|
40
|
+
"deepbook_quote_no_fiat_or_route_inference",
|
|
41
|
+
"pnl_unsupported"
|
|
42
|
+
]
|
|
43
|
+
};
|
|
44
|
+
export const SERVER_INSTRUCTIONS = [
|
|
45
|
+
"Say Ur Intent is a mainnet-only Sui DeFi intent evidence toolkit. The MCP layer is a session gateway for local review, wallet identity/settings sessions; it does not execute transactions, request wallet signatures, or return transaction bytes. DeepBook review may build internal unsigned material, bind a Sui digest, and derive object ownership, quote/policy, human review, and review-time simulation evidence; not wallet handoff, signing data/readiness, or execution readiness. No custody, autonomous trading, fiat cash-out, P&L, peg proof, payment readiness, route choice, best-price advice, or silent settlement-token selection.",
|
|
46
|
+
"External proposals are untrusted facts; plans[].reviewModel is review context, not transaction material, route/settlement choice, signing/readiness, or execution readiness.",
|
|
47
|
+
"Future PTB graphs are diagnostics only; not transaction input, wallet authorization, signing/readiness, execution readiness, route quality, or safety.",
|
|
48
|
+
"Use response-local fields: userAnswerUse.answerFields/preconditionFields/conclusionRuleFields/cannotAnswer/diagnosticOnlyFields/followUp, pollingHint, and quantitySemantics.",
|
|
49
|
+
"For USD-denominated payment coverage, balance total, or shortfall questions, call read.get_server_status, then read.list_settlement_asset_groups, then read.preview_intent_evidence. If answerSourceStatus.canUseThisResponseForUserAnswer and responseSummary.doNotCallQuoteToolsForThisQuestion are true, answer from responseSummary; do not call wallet inventory or quote tools unless user asks a separate inventory or conversion question. For parity, use read.summarize_settlement_asset_group_parity. If answerSourceStatus cannot be used, say the current MCP server build cannot support the answer.",
|
|
50
|
+
"active account context is read context only; not login, transaction/signing auth, custody, or permission.",
|
|
51
|
+
"Unsupported: other chains, autonomous trading, alerts, investment advice, arbitrary Move/package calls, P&L/tax/cost basis.",
|
|
52
|
+
"Read sayurintent://docs/agent-behavior."
|
|
53
|
+
].join("\n");
|
|
54
|
+
export const IMPLEMENTED_TOOLS = [
|
|
55
|
+
TOOL_NAMES.readGetServerStatus,
|
|
56
|
+
TOOL_NAMES.readListSupportedProtocols,
|
|
57
|
+
TOOL_NAMES.readListDeepbookPools,
|
|
58
|
+
TOOL_NAMES.readListDeepbookTokens,
|
|
59
|
+
TOOL_NAMES.readInspectDeepbookOrderbook,
|
|
60
|
+
TOOL_NAMES.readGetDeepbookMidPrice,
|
|
61
|
+
TOOL_NAMES.readQuoteDeepbookAction,
|
|
62
|
+
TOOL_NAMES.readQuoteDeepbookDisplayAmount,
|
|
63
|
+
TOOL_NAMES.readListFlowxPools,
|
|
64
|
+
TOOL_NAMES.readQuoteFlowxSwap,
|
|
65
|
+
TOOL_NAMES.readSummarizeDeepbookAccountInventory,
|
|
66
|
+
TOOL_NAMES.readSummarizeWalletAssets,
|
|
67
|
+
TOOL_NAMES.readClassifyWalletAssets,
|
|
68
|
+
TOOL_NAMES.readListSettlementAssetGroups,
|
|
69
|
+
TOOL_NAMES.readSummarizeSettlementAssetGroupParity,
|
|
70
|
+
TOOL_NAMES.readPreviewIntentEvidence,
|
|
71
|
+
TOOL_NAMES.readListReviewActivity,
|
|
72
|
+
TOOL_NAMES.readSummarizeReviewFunnel,
|
|
73
|
+
TOOL_NAMES.readGetReviewSessionDetail,
|
|
74
|
+
TOOL_NAMES.readInspectSuiTransaction,
|
|
75
|
+
TOOL_NAMES.readScanSuiAccountActivity,
|
|
76
|
+
TOOL_NAMES.readSummarizeSuiActivityScan,
|
|
77
|
+
TOOL_NAMES.readScanSuiFunctionActivity,
|
|
78
|
+
TOOL_NAMES.readSummarizeSuiFunctionActivityScan,
|
|
79
|
+
TOOL_NAMES.readSummarizeSuiAccountActivity,
|
|
80
|
+
TOOL_NAMES.settingsCreateLocalSettingsSession,
|
|
81
|
+
TOOL_NAMES.settingsGetLocalSettings,
|
|
82
|
+
TOOL_NAMES.actionPrepareSuiActionReview,
|
|
83
|
+
TOOL_NAMES.actionPrepareExternalProposalReview,
|
|
84
|
+
TOOL_NAMES.accountGetActiveAccount,
|
|
85
|
+
TOOL_NAMES.accountClearActiveAccount,
|
|
86
|
+
TOOL_NAMES.sessionCreateWalletIdentity,
|
|
87
|
+
TOOL_NAMES.sessionGetWalletIdentity,
|
|
88
|
+
TOOL_NAMES.sessionWaitWalletIdentity,
|
|
89
|
+
TOOL_NAMES.sessionGetInteractionStatus,
|
|
90
|
+
TOOL_NAMES.sessionGetReviewStatus,
|
|
91
|
+
TOOL_NAMES.sessionGetExecutionResult,
|
|
92
|
+
TOOL_NAMES.sessionWaitExecutionResult
|
|
93
|
+
];
|
|
94
|
+
export const FAIL_CLOSED_TOOLS = [];
|
|
95
|
+
export function answerSourceStatus(requiredTools) {
|
|
96
|
+
const implemented = new Set(IMPLEMENTED_TOOLS);
|
|
97
|
+
const missingRequiredTools = requiredTools.filter((tool) => !implemented.has(tool));
|
|
98
|
+
return {
|
|
99
|
+
statusTool: TOOL_NAMES.readGetServerStatus,
|
|
100
|
+
packageName: PACKAGE_NAME,
|
|
101
|
+
version: SERVER_VERSION,
|
|
102
|
+
evidencePolicyVersion: EVIDENCE_POLICY.version,
|
|
103
|
+
network: SERVER_NETWORK,
|
|
104
|
+
implementedToolsCount: IMPLEMENTED_TOOLS.length,
|
|
105
|
+
requiredTools: requiredTools.map((name) => ({ name, available: implemented.has(name) })),
|
|
106
|
+
missingRequiredTools,
|
|
107
|
+
canUseThisResponseForUserAnswer: missingRequiredTools.length === 0,
|
|
108
|
+
cannotUseReason: missingRequiredTools.length === 0 ? null : "required_tool_missing_from_current_server_build"
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
export const SERVER_LIMITATIONS = [
|
|
112
|
+
"Active-account reads require active account context from wallet identity. Explicit-address coin balance reads are public-address snapshots and do not create active account context. Active account is read context only, not signing authorization, login, custody, or persistent permission.",
|
|
113
|
+
"Review activity tools summarize local Say Ur Intent review evidence only. Sui activity tools use user-requested bounded GraphQL reads and store normalized transaction facts only for known wallet context; function activity scans are sent-transaction scans only. They are not background indexers, complete history, balance history, complete gas history, affected-object history, or P&L.",
|
|
114
|
+
"Sui activity transactionContext facts are transaction-level facts without transaction-wide balance-change aggregates, and they are answer fields only when the response returns them. requestedAccountTransactionFacts, requestedAccount, and requestedAccountEffect are the account-specific balance-change surfaces. Activity quantitySemantics marks balance amountRaw fields as raw integers that require verified decimals for display conversion. accountBalanceChangeInferencePolicy marks whether returned account balance rows can be used or transaction-level context must not be used for account amount inference. Gas raw fields use MIST, and returned gasCost display facts use @mysten/sui MIST_PER_SUI.",
|
|
115
|
+
"Wallet asset classification covers only current coin balances returned by Sui gRPC listBalances for an explicit address or the active account. Wallet balance quantitySemantics marks those reads as current snapshots, not transaction history, receipt proof, acquisition source, object provenance, P&L, cost basis, or signing material. DeepBook account inventory is a separate active-account read surface; neither surface creates routes, funding plans, portfolio plans, or signing material.",
|
|
116
|
+
"High-risk read responses include userAnswerUse. Prefer userAnswerUse.preconditionFields before answering, userAnswerUse.answerFields for the answer path, userAnswerUse.conclusionRuleFields for conclusion limits, userAnswerUse.diagnosticOnlyFields for source or troubleshooting context, and userAnswerUse.followUp when a different tool and field are required. USD intent and parity responses also include answerSourceStatus as a precondition field for current server-build support.",
|
|
117
|
+
"Intent evidence maps natural-language USD-denominated targets to pinned DeepBook SDK settlement asset groups and current wallet balance evidence. responseSummary.answerCompleteness names the answer class and required fields. Settlement-asset-only answers use responseSummary; selected-target evidence requires user selection provenance and also uses selectedTarget, candidateConversions, and requiredUserChoices when userAnswerUse.answerFields lists them. Direct pool quote evidence is returned and supported only when a quoted candidate exists. responseSummary.doNotUseForConclusion names quote results, outside-settlement-group assets, and route-dependent support as excluded from the conclusion. Intent evidence does not silently choose settlement assets, rank venues or routes, evaluate gas reserve, build transactions, or produce signing material.",
|
|
118
|
+
"DeepBook quotes convert explicit raw or display source inputs through pinned token units and return scoped SDK simulation facts plus raw quote evidence. Their quantitySemantics says canUseForPaymentAnswer and canUseForShortfallAnswer are false, doNotCombineWithPaymentAnswer is true, requiredPaymentAnswerTool is read.preview_intent_evidence, and requiredPaymentAnswerField is responseSummary.",
|
|
119
|
+
"Action preparation creates local review sessions. DeepBook account-bound review may report adapterLifecycle.completedStages and missingStages as pre-signing review evidence progress through local transaction-material build, internal digest binding, object ownership evidence, quote/policy provenance, human-readable review evidence, and review-time simulation evidence; these fields do not expose transaction bytes, wallet handoff, signing readiness, or execution readiness. External proposal ingestion stores untrusted structured proposal facts for local review only, rejects forbidden executable or signing fields plus recognized sensitive key material, and never becomes signing authority. When every review evidence stage completes, the review layer emits a schema-validated wallet review contract with a PTB visualization on a ready_for_wallet_review state; the local review page can then request a digest-gated byte handoff and offer user-controlled wallet signing, recording execution receipts on the session. MCP responses never contain signing data, a wallet signature request, or signing readiness; this is not execution by the MCP layer.",
|
|
120
|
+
"read.list_deepbook_pools and read.list_deepbook_tokens return static SDK registry metadata, not live liquidity, live token discovery, or active pool state.",
|
|
121
|
+
"DeepBook orderbook, mid-price, and quote outputs are pinned-SDK snapshots at fetchedAt; treat them as stale if the user delays.",
|
|
122
|
+
"Settings mutations happen through local settings pages on the review server. MCP settings tools create settings sessions or read current settings only."
|
|
123
|
+
];
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { ActivityStoreReadError } from "../core/activity/activityStore.js";
|
|
2
|
+
import { TransactionActivityError } from "../core/activity/transactionActivityTypes.js";
|
|
3
|
+
import { LocalSettingsError, PreferencesStoreError } from "../core/preferences/preferencesStore.js";
|
|
4
|
+
import { SessionStoreError } from "../core/session/sessionStore.js";
|
|
5
|
+
import { WaitRequestAbortedError } from "../core/session/wait.js";
|
|
6
|
+
import { SuiEndpointError } from "../core/suiEndpoint.js";
|
|
7
|
+
import { errorToolResult } from "./result.js";
|
|
8
|
+
export function activityStoreToolError(error, logger) {
|
|
9
|
+
if (error instanceof ActivityStoreReadError) {
|
|
10
|
+
return errorToolResult({
|
|
11
|
+
kind: error.kind,
|
|
12
|
+
details: error.details
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
logger.error("activity store call failed", {
|
|
16
|
+
error: error instanceof Error ? error.message : String(error)
|
|
17
|
+
});
|
|
18
|
+
return errorToolResult({
|
|
19
|
+
kind: "internal_error",
|
|
20
|
+
details: { message: "Activity store call failed" }
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
export function transactionActivityToolError(error, logger) {
|
|
24
|
+
if (error instanceof TransactionActivityError) {
|
|
25
|
+
return errorToolResult({
|
|
26
|
+
kind: error.kind,
|
|
27
|
+
details: error.details
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
if (error instanceof ActivityStoreReadError) {
|
|
31
|
+
return errorToolResult({
|
|
32
|
+
kind: error.kind,
|
|
33
|
+
details: error.details
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
logger.error("transaction activity call failed", {
|
|
37
|
+
error: error instanceof Error ? error.message : String(error)
|
|
38
|
+
});
|
|
39
|
+
return errorToolResult({
|
|
40
|
+
kind: "internal_error",
|
|
41
|
+
details: { message: "Transaction activity call failed" }
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
export function sessionStoreToolError(error, logger) {
|
|
45
|
+
if (error instanceof WaitRequestAbortedError) {
|
|
46
|
+
return errorToolResult({
|
|
47
|
+
kind: "request_aborted",
|
|
48
|
+
details: { reason: error.reason }
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (error instanceof SessionStoreError) {
|
|
52
|
+
return errorToolResult({
|
|
53
|
+
kind: error.code,
|
|
54
|
+
details: { code: error.code, ...error.details }
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
logger.error("session store call failed", {
|
|
58
|
+
error: error instanceof Error ? error.message : String(error)
|
|
59
|
+
});
|
|
60
|
+
return errorToolResult({
|
|
61
|
+
kind: "internal_error",
|
|
62
|
+
details: { message: "Session store call failed" }
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
export function localSettingsToolError(error, logger) {
|
|
66
|
+
if (error instanceof LocalSettingsError) {
|
|
67
|
+
return errorToolResult({
|
|
68
|
+
kind: error.kind,
|
|
69
|
+
details: error.details
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
if (error instanceof PreferencesStoreError) {
|
|
73
|
+
logger.error("local settings store error", {
|
|
74
|
+
error: error.message,
|
|
75
|
+
details: error.details
|
|
76
|
+
});
|
|
77
|
+
return errorToolResult({
|
|
78
|
+
kind: "internal_error",
|
|
79
|
+
details: {
|
|
80
|
+
reason: error.kind,
|
|
81
|
+
message: error.message
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
if (error instanceof SuiEndpointError) {
|
|
86
|
+
logger.error("local settings endpoint value error", {
|
|
87
|
+
error: error.message,
|
|
88
|
+
kind: error.kind
|
|
89
|
+
});
|
|
90
|
+
return errorToolResult({
|
|
91
|
+
kind: "internal_error",
|
|
92
|
+
details: {
|
|
93
|
+
reason: error.kind,
|
|
94
|
+
message: error.message
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
logger.error("local settings call failed", {
|
|
99
|
+
error: error instanceof Error ? error.message : String(error)
|
|
100
|
+
});
|
|
101
|
+
return errorToolResult({
|
|
102
|
+
kind: "internal_error",
|
|
103
|
+
details: { message: "Local settings call failed" }
|
|
104
|
+
});
|
|
105
|
+
}
|