@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,50 @@
|
|
|
1
|
+
export const TOOL_NAMES = {
|
|
2
|
+
readGetServerStatus: "read.get_server_status",
|
|
3
|
+
readListSupportedProtocols: "read.list_supported_protocols",
|
|
4
|
+
readListDeepbookPools: "read.list_deepbook_pools",
|
|
5
|
+
readListDeepbookTokens: "read.list_deepbook_tokens",
|
|
6
|
+
readInspectDeepbookOrderbook: "read.inspect_deepbook_orderbook",
|
|
7
|
+
readGetDeepbookMidPrice: "read.get_deepbook_mid_price",
|
|
8
|
+
readQuoteDeepbookAction: "read.quote_deepbook_action",
|
|
9
|
+
readQuoteDeepbookDisplayAmount: "read.quote_deepbook_display_amount",
|
|
10
|
+
readListFlowxPools: "read.list_flowx_pools",
|
|
11
|
+
readQuoteFlowxSwap: "read.quote_flowx_swap",
|
|
12
|
+
readSummarizeDeepbookAccountInventory: "read.summarize_deepbook_account_inventory",
|
|
13
|
+
readSummarizeWalletAssets: "read.summarize_wallet_assets",
|
|
14
|
+
readClassifyWalletAssets: "read.classify_wallet_assets",
|
|
15
|
+
readListSettlementAssetGroups: "read.list_settlement_asset_groups",
|
|
16
|
+
readSummarizeSettlementAssetGroupParity: "read.summarize_settlement_asset_group_parity",
|
|
17
|
+
readPreviewIntentEvidence: "read.preview_intent_evidence",
|
|
18
|
+
readListReviewActivity: "read.list_review_activity",
|
|
19
|
+
readSummarizeReviewFunnel: "read.summarize_review_funnel",
|
|
20
|
+
readGetReviewSessionDetail: "read.get_review_session_detail",
|
|
21
|
+
readInspectSuiTransaction: "read.inspect_sui_transaction",
|
|
22
|
+
readScanSuiAccountActivity: "read.scan_sui_account_activity",
|
|
23
|
+
readSummarizeSuiActivityScan: "read.summarize_sui_activity_scan",
|
|
24
|
+
readScanSuiFunctionActivity: "read.scan_sui_function_activity",
|
|
25
|
+
readSummarizeSuiFunctionActivityScan: "read.summarize_sui_function_activity_scan",
|
|
26
|
+
readSummarizeSuiAccountActivity: "read.summarize_sui_account_activity",
|
|
27
|
+
settingsCreateLocalSettingsSession: "settings.create_local_settings_session",
|
|
28
|
+
settingsGetLocalSettings: "settings.get_local_settings",
|
|
29
|
+
actionPrepareSuiActionReview: "action.prepare_sui_action_review",
|
|
30
|
+
actionPrepareExternalProposalReview: "action.prepare_external_proposal_review",
|
|
31
|
+
sessionCreateWalletIdentity: "session.create_wallet_identity",
|
|
32
|
+
sessionGetWalletIdentity: "session.get_wallet_identity",
|
|
33
|
+
sessionWaitWalletIdentity: "session.wait_wallet_identity",
|
|
34
|
+
sessionGetInteractionStatus: "session.get_interaction_status",
|
|
35
|
+
sessionGetReviewStatus: "session.get_review_status",
|
|
36
|
+
sessionGetExecutionResult: "session.get_execution_result",
|
|
37
|
+
sessionWaitExecutionResult: "session.wait_execution_result",
|
|
38
|
+
accountGetActiveAccount: "account.get_active_account",
|
|
39
|
+
accountClearActiveAccount: "account.clear_active_account"
|
|
40
|
+
};
|
|
41
|
+
export function assertValidToolName(name) {
|
|
42
|
+
if (!/^[A-Za-z0-9_.-]{1,128}$/.test(name)) {
|
|
43
|
+
throw new Error(`Invalid MCP tool name: ${name}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export function assertAllToolNamesValid() {
|
|
47
|
+
for (const name of Object.values(TOOL_NAMES)) {
|
|
48
|
+
assertValidToolName(name);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { activeAccountResponse, activeAccountResponseSchema } from "../../activeAccountResponse.js";
|
|
3
|
+
import { registerSayUrIntentTool } from "../../registerTool.js";
|
|
4
|
+
import { okToolResult } from "../../result.js";
|
|
5
|
+
import { noParamsInputSchema, successOutputSchema } from "../../schemas.js";
|
|
6
|
+
import { activityStoreToolError } from "../../toolErrors.js";
|
|
7
|
+
import { TOOL_NAMES } from "../../toolNames.js";
|
|
8
|
+
export function registerAccountTools(server, deps) {
|
|
9
|
+
server.registerTool(TOOL_NAMES.accountGetActiveAccount, {
|
|
10
|
+
title: "Get active account read context",
|
|
11
|
+
description: "Return the active account address for wallet-account reads. Read context only; not signing authorization.",
|
|
12
|
+
inputSchema: noParamsInputSchema,
|
|
13
|
+
outputSchema: {
|
|
14
|
+
ok: z.literal(true),
|
|
15
|
+
data: activeAccountResponseSchema
|
|
16
|
+
},
|
|
17
|
+
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
18
|
+
}, async () => {
|
|
19
|
+
try {
|
|
20
|
+
const active = await deps.activityStore.getActiveAccount();
|
|
21
|
+
return okToolResult(activeAccountResponse(active));
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
return activityStoreToolError(error, deps.logger);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
registerSayUrIntentTool(server, TOOL_NAMES.accountClearActiveAccount, {
|
|
28
|
+
title: "Clear active account read context",
|
|
29
|
+
description: "Remove the active read context. Does not disconnect a wallet or revoke onchain permission.",
|
|
30
|
+
inputSchema: noParamsInputSchema,
|
|
31
|
+
outputSchema: successOutputSchema({
|
|
32
|
+
status: z.literal("cleared")
|
|
33
|
+
}),
|
|
34
|
+
annotations: { readOnlyHint: false, openWorldHint: false }
|
|
35
|
+
}, async () => {
|
|
36
|
+
try {
|
|
37
|
+
await deps.activityStore.clearActiveAccount();
|
|
38
|
+
return okToolResult({ status: "cleared" });
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
return activityStoreToolError(error, deps.logger);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { INTENT_PLAN_FACTORIES, resolveIntentPlanFactory, swapIntentInputSchema } from "../../../adapters/intentPlanFactories.js";
|
|
3
|
+
import { actionPlanSchema, reviewCheckSchema } from "../../../core/action/schemas.js";
|
|
4
|
+
import { externalProposalToActionPlan } from "../../../core/proposal/externalProposalReview.js";
|
|
5
|
+
import { externalProposalSchema } from "../../../core/proposal/schemas.js";
|
|
6
|
+
import { prepareActionReviewUserAnswerUse, prepareExternalProposalReviewUserAnswerUse } from "../../responseGuidance.js";
|
|
7
|
+
import { registerSayUrIntentTool } from "../../registerTool.js";
|
|
8
|
+
import { successOutputSchema } from "../../schemas.js";
|
|
9
|
+
import { errorToolResult, okToolResult } from "../../result.js";
|
|
10
|
+
import { activityStoreToolError, sessionStoreToolError } from "../../toolErrors.js";
|
|
11
|
+
import { TOOL_NAMES } from "../../toolNames.js";
|
|
12
|
+
import { userAnswerUseSchema } from "../read/commonSchemas.js";
|
|
13
|
+
export function registerActionTools(server, deps) {
|
|
14
|
+
server.registerTool(TOOL_NAMES.actionPrepareSuiActionReview, {
|
|
15
|
+
title: "Prepare swap review",
|
|
16
|
+
description: "Create a local swap review session on a supported protocol. Returns a review URL; the local review page owns user-controlled signing, and this response contains no signing data.",
|
|
17
|
+
inputSchema: {
|
|
18
|
+
intent: swapIntentInputSchema
|
|
19
|
+
},
|
|
20
|
+
outputSchema: successOutputSchema({
|
|
21
|
+
reviewSessionId: z.string(),
|
|
22
|
+
reviewUrl: z.string(),
|
|
23
|
+
plans: z.array(actionPlanSchema),
|
|
24
|
+
preliminaryChecks: z.array(reviewCheckSchema),
|
|
25
|
+
userAnswerUse: userAnswerUseSchema
|
|
26
|
+
}),
|
|
27
|
+
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: false }
|
|
28
|
+
}, async ({ intent }) => {
|
|
29
|
+
const now = new Date();
|
|
30
|
+
// A swap review is account-bound: its evidence (balances, transaction
|
|
31
|
+
// material, digest, simulation) is computed for a specific sender, and
|
|
32
|
+
// no transaction can be built without that account. Refuse here when no
|
|
33
|
+
// wallet account is connected instead of creating a hollow proposal that
|
|
34
|
+
// can never be computed or signed. Connect first via
|
|
35
|
+
// session.create_wallet_identity.
|
|
36
|
+
let activeAccount;
|
|
37
|
+
try {
|
|
38
|
+
activeAccount = await deps.activityStore.getActiveAccount();
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
return activityStoreToolError(error, deps.logger);
|
|
42
|
+
}
|
|
43
|
+
if (!activeAccount) {
|
|
44
|
+
return errorToolResult({
|
|
45
|
+
kind: "active_account_not_set",
|
|
46
|
+
details: { action: "connect_wallet_identity" }
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
const { protocol: protocolSlug, ...swapIntent } = intent;
|
|
50
|
+
const resolution = resolveIntentPlanFactory(INTENT_PLAN_FACTORIES, swapIntent.type, protocolSlug);
|
|
51
|
+
if (resolution.status !== "resolved") {
|
|
52
|
+
return errorToolResult({
|
|
53
|
+
kind: resolution.status === "unsupported_action" ? "unsupported_action" : "input_invalid",
|
|
54
|
+
details: resolution.status === "unsupported_action"
|
|
55
|
+
? { reason: "unsupported_action", actionKind: resolution.actionKind }
|
|
56
|
+
: resolution.status === "unknown_protocol"
|
|
57
|
+
? {
|
|
58
|
+
reason: "unknown_protocol",
|
|
59
|
+
protocol: resolution.protocolSlug,
|
|
60
|
+
availableProtocols: resolution.available
|
|
61
|
+
}
|
|
62
|
+
: {
|
|
63
|
+
reason: "protocol_choice_required",
|
|
64
|
+
availableProtocols: resolution.available,
|
|
65
|
+
guidance: "Several protocols support this action; set intent.protocol to one of availableProtocols. Ask the user - do not pick a protocol silently."
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
const plan = resolution.factory.createPlan(swapIntent, now);
|
|
70
|
+
try {
|
|
71
|
+
const { session, token } = await deps.sessions.createReviewSession([plan], now);
|
|
72
|
+
const preliminaryChecks = plan.preliminaryChecks ?? [];
|
|
73
|
+
const hasBlockingPreliminaryChecks = preliminaryChecks.some((check) => check.status === "fail");
|
|
74
|
+
const payload = {
|
|
75
|
+
reviewSessionId: session.id,
|
|
76
|
+
reviewUrl: `${deps.reviewBaseUrl}/review/${session.id}#${token}`,
|
|
77
|
+
plans: session.plans,
|
|
78
|
+
preliminaryChecks,
|
|
79
|
+
userAnswerUse: prepareActionReviewUserAnswerUse({ hasBlockingPreliminaryChecks })
|
|
80
|
+
};
|
|
81
|
+
return okToolResult(payload);
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
return sessionStoreToolError(error, deps.logger);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
registerSayUrIntentTool(server, TOOL_NAMES.actionPrepareExternalProposalReview, {
|
|
88
|
+
title: "Prepare external proposal review",
|
|
89
|
+
description: "Create a local non-signable review session from an untrusted external Sui proposal.",
|
|
90
|
+
inputSchema: {
|
|
91
|
+
proposal: externalProposalSchema
|
|
92
|
+
},
|
|
93
|
+
outputSchema: successOutputSchema({
|
|
94
|
+
reviewSessionId: z.string(),
|
|
95
|
+
reviewUrl: z.string(),
|
|
96
|
+
plans: z.array(actionPlanSchema),
|
|
97
|
+
preliminaryChecks: z.array(reviewCheckSchema),
|
|
98
|
+
userAnswerUse: userAnswerUseSchema
|
|
99
|
+
}),
|
|
100
|
+
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: false }
|
|
101
|
+
}, async ({ proposal }) => {
|
|
102
|
+
const now = new Date();
|
|
103
|
+
const plan = externalProposalToActionPlan(proposal, now);
|
|
104
|
+
try {
|
|
105
|
+
const { session, token } = await deps.sessions.createReviewSession([plan], now);
|
|
106
|
+
const preliminaryChecks = plan.preliminaryChecks ?? [];
|
|
107
|
+
const payload = {
|
|
108
|
+
reviewSessionId: session.id,
|
|
109
|
+
reviewUrl: `${deps.reviewBaseUrl}/review/${session.id}#${token}`,
|
|
110
|
+
plans: session.plans,
|
|
111
|
+
preliminaryChecks,
|
|
112
|
+
userAnswerUse: prepareExternalProposalReviewUserAnswerUse()
|
|
113
|
+
};
|
|
114
|
+
return okToolResult(payload);
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
return sessionStoreToolError(error, deps.logger);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { DEEPBOOK_MID_PRICE_PRECISION } from "../../../core/read/readService.js";
|
|
3
|
+
export const fetchedAtSchema = z.string().refine((value) => {
|
|
4
|
+
const parsed = new Date(value);
|
|
5
|
+
return !Number.isNaN(parsed.getTime()) && parsed.toISOString() === value;
|
|
6
|
+
}, "Expected ISO 8601 UTC timestamp");
|
|
7
|
+
export const readSourceSchema = z.object({
|
|
8
|
+
sdk: z.string(),
|
|
9
|
+
transport: z.literal("grpc"),
|
|
10
|
+
simulation: z.literal("client.core.simulateTransaction").optional(),
|
|
11
|
+
method: z.string().optional(),
|
|
12
|
+
methods: z.array(z.string()).optional(),
|
|
13
|
+
returnValueEncoding: z.string().optional(),
|
|
14
|
+
precision: z.literal(DEEPBOOK_MID_PRICE_PRECISION).optional()
|
|
15
|
+
});
|
|
16
|
+
export const reviewActivityAccountSourceSchema = z.enum(["active_account_context", "explicit_filter"]);
|
|
17
|
+
export const reviewActivityDataScopeSchema = z.object({
|
|
18
|
+
account: z.string(),
|
|
19
|
+
from: fetchedAtSchema.optional(),
|
|
20
|
+
to: fetchedAtSchema.optional(),
|
|
21
|
+
recordCount: z.number().int().nonnegative()
|
|
22
|
+
});
|
|
23
|
+
export const reviewActivityInputSchema = {
|
|
24
|
+
account: z.string().min(1).optional(),
|
|
25
|
+
from: fetchedAtSchema.optional(),
|
|
26
|
+
to: fetchedAtSchema.optional()
|
|
27
|
+
};
|
|
28
|
+
export const userAnswerUseSchema = z.object({
|
|
29
|
+
canAnswer: z.array(z.string()),
|
|
30
|
+
cannotAnswer: z.array(z.string()),
|
|
31
|
+
answerFields: z.array(z.string()),
|
|
32
|
+
preconditionFields: z.array(z.string()).optional(),
|
|
33
|
+
conclusionRuleFields: z.array(z.string()).optional(),
|
|
34
|
+
diagnosticOnlyFields: z.array(z.string()).optional(),
|
|
35
|
+
followUp: z
|
|
36
|
+
.object({
|
|
37
|
+
tool: z.string(),
|
|
38
|
+
inputFields: z.array(z.string()).optional(),
|
|
39
|
+
answerFields: z.array(z.string()),
|
|
40
|
+
reason: z.string()
|
|
41
|
+
})
|
|
42
|
+
.optional()
|
|
43
|
+
}).strict();
|