@zktx.io/sui-mcp 0.5.0
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/LICENSE +21 -0
- package/LICENSES/@mysten-bcs-2.0.5-Apache-2.0.txt +205 -0
- package/LICENSES/@mysten-sui-2.17.0-Apache-2.0.txt +201 -0
- package/LICENSES/@mysten-utils-0.3.3-Apache-2.0.txt +205 -0
- package/LICENSES/fancy-canvas-2.1.0-MIT.txt +7 -0
- package/LICENSES/lightweight-charts-5.2.0-NOTICE.txt +2 -0
- package/README.md +288 -0
- package/dist/adapters/adapterLifecycleValidators.js +5 -0
- package/dist/adapters/adapterPromptSurfaces.js +60 -0
- package/dist/adapters/deepbook/deepbookHumanReviewProducer.js +178 -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 +254 -0
- package/dist/adapters/intentPlanFactories.js +51 -0
- package/dist/adapters/reviewAdapters.js +47 -0
- package/dist/core/action/adapterLifecycleValidation.js +12 -0
- package/dist/core/action/contractNameRegistry.js +151 -0
- package/dist/core/action/forbiddenFields.js +43 -0
- package/dist/core/action/humanReadableReviewEvidence.js +193 -0
- package/dist/core/action/humanReadableReviewProjectionVerifier.js +29 -0
- package/dist/core/action/ptbVisualizationProducer.js +71 -0
- package/dist/core/action/receiptPtbGraph.js +29 -0
- package/dist/core/action/reviewCheckResults.js +6 -0
- package/dist/core/action/reviewStateValidation.js +11 -0
- package/dist/core/action/reviewTimeSimulationEvidence.js +470 -0
- package/dist/core/action/schemas.js +491 -0
- package/dist/core/action/signableAdapterContract.js +998 -0
- package/dist/core/action/suiChainReceiptEvidence.js +106 -0
- package/dist/core/action/suiChainReceiptMapping.js +107 -0
- package/dist/core/action/suiChainReceiptReader.js +211 -0
- package/dist/core/action/suiChainReceiptVerifier.js +178 -0
- package/dist/core/action/swapHumanReadableReviewProjection.js +130 -0
- package/dist/core/action/swapQuotePolicyEvidence.js +271 -0
- package/dist/core/action/transactionFunding.js +244 -0
- package/dist/core/action/transactionObjectOwnershipEvidence.js +256 -0
- package/dist/core/action/transactionObjectOwnershipProducer.js +323 -0
- package/dist/core/action/types.js +33 -0
- package/dist/core/action/walletReviewContractAssembler.js +286 -0
- package/dist/core/activity/accountAssetTimeline.js +157 -0
- package/dist/core/activity/accountAssetTimelineUsdcReferences.js +120 -0
- package/dist/core/activity/activityStore.js +16 -0
- package/dist/core/activity/externalActivityCoverage.js +76 -0
- package/dist/core/activity/externalActivityTransactionStream.js +82 -0
- package/dist/core/activity/localDataService.js +296 -0
- package/dist/core/activity/localDataTypes.js +11 -0
- package/dist/core/activity/localDataValidation.js +439 -0
- package/dist/core/activity/schemaVersion.js +2 -0
- package/dist/core/activity/sqliteActivityStore.js +1068 -0
- package/dist/core/activity/sqliteActivityStoreRows.js +389 -0
- package/dist/core/activity/sqliteActivityStoreSchema.js +367 -0
- package/dist/core/activity/sqliteActivityStoreTypes.js +5 -0
- package/dist/core/activity/suiFunctionTarget.js +43 -0
- package/dist/core/activity/transactionActivityAccountEffects.js +186 -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 +85 -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/deepbookOfficialIndexerSource.js +373 -0
- package/dist/core/read/deepbookRawQuoteClient.js +86 -0
- package/dist/core/read/deepbookReadHelpers.js +321 -0
- package/dist/core/read/deepbookRegistry.js +157 -0
- package/dist/core/read/deepbookSourceOwners.js +159 -0
- package/dist/core/read/deepbookUsdcChartService.js +342 -0
- package/dist/core/read/intentEvidenceResponseFormatting.js +228 -0
- package/dist/core/read/readCardInputs.js +19 -0
- package/dist/core/read/readCardResult.js +40 -0
- package/dist/core/read/readResponseGuidance.js +402 -0
- package/dist/core/read/readService.js +1639 -0
- package/dist/core/read/readServiceTypes.js +88 -0
- package/dist/core/read/settlementParityFormatting.js +82 -0
- package/dist/core/read/walletReadHelpers.js +99 -0
- package/dist/core/review/reviewChecks.js +45 -0
- package/dist/core/review/reviewComputation.js +38 -0
- package/dist/core/review/reviewComputationResult.js +87 -0
- package/dist/core/session/cardSession.js +31 -0
- package/dist/core/session/cardSessionStore.js +204 -0
- package/dist/core/session/keyedRecordStore.js +18 -0
- package/dist/core/session/liveReviewSessionContract.js +3 -0
- package/dist/core/session/localSession.js +31 -0
- package/dist/core/session/privateReviewArtifacts.js +75 -0
- package/dist/core/session/reviewValidity.js +49 -0
- package/dist/core/session/sessionErrors.js +9 -0
- package/dist/core/session/sessionRecordStore.js +40 -0
- package/dist/core/session/sessionStore.js +655 -0
- package/dist/core/session/settingsSession.js +1 -0
- package/dist/core/session/settingsSessions.js +45 -0
- package/dist/core/session/sqliteCardStore.js +88 -0
- package/dist/core/session/sqliteSessionStore.js +213 -0
- package/dist/core/session/sqliteTransactionMaterialStore.js +64 -0
- package/dist/core/session/sqliteWalletWorkflowStore.js +821 -0
- package/dist/core/session/status.js +60 -0
- package/dist/core/session/transactionMaterialStore.js +221 -0
- package/dist/core/session/transactionRequest.js +72 -0
- package/dist/core/session/wait.js +79 -0
- package/dist/core/session/walletConnection.js +92 -0
- package/dist/core/session/walletRuntime.js +38 -0
- package/dist/core/session/walletWorkflow.js +608 -0
- package/dist/core/session/workflowState.js +80 -0
- package/dist/core/session/workflowView.js +150 -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 +326 -0
- package/dist/mcp/result.js +17 -0
- package/dist/mcp/schemas.js +11 -0
- package/dist/mcp/server.js +32 -0
- package/dist/mcp/serverInfo.js +131 -0
- package/dist/mcp/toolErrors.js +118 -0
- package/dist/mcp/toolNames.js +58 -0
- package/dist/mcp/tools/account/index.js +44 -0
- package/dist/mcp/tools/action/prepareSuiActionReview.js +126 -0
- package/dist/mcp/tools/read/commonSchemas.js +43 -0
- package/dist/mcp/tools/read/deepbookReadTools.js +686 -0
- package/dist/mcp/tools/read/index.js +14 -0
- package/dist/mcp/tools/read/readToolHelpers.js +97 -0
- package/dist/mcp/tools/read/reviewActivityTools.js +179 -0
- package/dist/mcp/tools/read/serverStatusTools.js +100 -0
- package/dist/mcp/tools/read/transactionActivityOutput.js +371 -0
- package/dist/mcp/tools/read/transactionActivityTools.js +858 -0
- package/dist/mcp/tools/read/walletReadTools.js +734 -0
- package/dist/mcp/tools/session/executionResultTools.js +44 -0
- package/dist/mcp/tools/session/index.js +8 -0
- package/dist/mcp/tools/session/shared.js +36 -0
- package/dist/mcp/tools/session/statusTools.js +69 -0
- package/dist/mcp/tools/session/walletConnectionTools.js +69 -0
- package/dist/mcp/tools/settings/index.js +66 -0
- package/dist/mcp-app/account.html +3133 -0
- package/dist/mcp-app/account.notices.txt +973 -0
- package/dist/mcp-app/chart.html +3354 -0
- package/dist/mcp-app/chart.notices.txt +1194 -0
- package/dist/mcp-app/connect.html +3179 -0
- package/dist/mcp-app/connect.notices.txt +1012 -0
- package/dist/mcp-app/receipt.html +8430 -0
- package/dist/mcp-app/receipt.notices.txt +3549 -0
- package/dist/mcp-app/review.html +8430 -0
- package/dist/mcp-app/review.notices.txt +3549 -0
- package/dist/mcp-ui/contracts.js +31 -0
- package/dist/mcp-ui/readCards.js +28 -0
- package/dist/mcp-ui/tools.js +134 -0
- package/dist/review-app/brand-dark.svg +1 -0
- package/dist/review-app/brand-light.svg +1 -0
- package/dist/review-app/favicon.svg +1 -0
- package/dist/review-app/settings.css +1 -0
- package/dist/review-app/settings.js +1 -0
- package/dist/review-app/ui.css +809 -0
- package/dist/review-server/assets.js +48 -0
- package/dist/review-server/html.js +45 -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 +1 -0
- package/dist/review-server/server.js +72 -0
- package/dist/review-server/settingsApi.js +158 -0
- package/dist/runtime/application.js +203 -0
- package/dist/runtime/config.js +97 -0
- package/dist/runtime/localSettingsService.js +198 -0
- package/dist/runtime/logger.js +66 -0
- package/dist/runtime/reviewDependencies.js +58 -0
- package/dist/runtime/reviewServerAcquire.js +93 -0
- package/dist/runtime/runtimeTermination.js +60 -0
- package/dist/runtime/shared/authenticatedFetch.js +127 -0
- package/dist/runtime/shared/control.js +93 -0
- package/dist/runtime/shared/dataAccess.js +66 -0
- package/dist/runtime/shared/mcpHttp.js +84 -0
- package/dist/runtime/shared/ownerLease.js +50 -0
- package/dist/runtime/shared/server.js +98 -0
- package/dist/runtime/shared/stdio.js +113 -0
- package/dist/runtime/smokeMainnetRead.js +391 -0
- package/dist/runtime/smokeMainnetReadAssertions.js +306 -0
- package/dist/runtime/smokeReview.js +40 -0
- package/dist/runtime/start.js +90 -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/dist/runtime/walletConnectConfig.js +3 -0
- package/dist/runtime/walletConnectStorage.js +99 -0
- package/dist/runtime/walletConnectTransport.js +128 -0
- package/dist/runtime/walletSdkChild.js +3 -0
- package/dist/runtime/walletSdkChildRuntime.js +160 -0
- package/dist/runtime/walletSdkIpc.js +26 -0
- package/dist/runtime/walletSdkProcess.js +358 -0
- package/docs/AGENT_BEHAVIOR.md +524 -0
- package/docs/AGENT_DEVELOPMENT_POLICY.md +815 -0
- package/docs/FRONTEND_POLICY.md +534 -0
- package/docs/LOCAL_DB_ARCHITECTURE.md +381 -0
- package/docs/MCP_SETUP.md +742 -0
- package/docs/MCP_TOOLS.md +1318 -0
- package/docs/SDK_API.md +206 -0
- package/docs/SIGNABLE_ADAPTER_CONTRACT.md +396 -0
- package/docs/TRANSACTION_ACTIVITY_LOG.md +194 -0
- package/docs/UTILITY_INDEX.md +275 -0
- package/docs/WALLET_CONNECTION.md +238 -0
- package/docs/golden-scenarios/BEHAVIOR_MATRIX.md +166 -0
- package/docs/golden-scenarios/INTENT_EVIDENCE_GOLDEN_ANSWERS.md +161 -0
- package/docs/golden-scenarios/INTENT_EVIDENCE_MATRIX.md +259 -0
- package/package.json +79 -0
- package/protocols/deepbook-margin.md +15 -0
- package/protocols/deepbook-v3.md +24 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { waitForExecutionResult, WAIT_OUTCOMES } from "../../../core/session/wait.js";
|
|
3
|
+
import { reviewStatusResponse } from "../../../core/session/status.js";
|
|
4
|
+
import { errorToolResult, okToolResult } from "../../result.js";
|
|
5
|
+
import { successOutputSchema } from "../../schemas.js";
|
|
6
|
+
import { sessionStoreToolError } from "../../toolErrors.js";
|
|
7
|
+
import { TOOL_NAMES } from "../../toolNames.js";
|
|
8
|
+
import { executionResultUserAnswerUse } from "../../responseGuidance.js";
|
|
9
|
+
import { userAnswerUseSchema } from "../read/commonSchemas.js";
|
|
10
|
+
import { reviewStatusResponseShape, waitExecutionInputSchema, readCurrentReview } from "./shared.js";
|
|
11
|
+
export function registerExecutionResultTools(server, deps) {
|
|
12
|
+
server.registerTool(TOOL_NAMES.sessionGetExecutionResult, {
|
|
13
|
+
title: "Get transaction request result", description: "Read one review session's transaction request and any observed chain result.",
|
|
14
|
+
inputSchema: { reviewSessionId: z.string().min(1) },
|
|
15
|
+
outputSchema: successOutputSchema({ ...reviewStatusResponseShape, userAnswerUse: userAnswerUseSchema }),
|
|
16
|
+
annotations: { readOnlyHint: false, openWorldHint: false }
|
|
17
|
+
}, async ({ reviewSessionId }) => {
|
|
18
|
+
try {
|
|
19
|
+
const state = await readCurrentReview(deps, reviewSessionId, true);
|
|
20
|
+
if (!state)
|
|
21
|
+
return errorToolResult({ kind: "session_not_found", details: { reviewSessionId } });
|
|
22
|
+
const request = state.request;
|
|
23
|
+
return okToolResult({ ...reviewStatusResponse(state), userAnswerUse: executionResultUserAnswerUse({ hasConnectionConflict: !!state.connectionConflict, hasRequest: !!request, hasExecutionResult: !!request?.execution }) });
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
return sessionStoreToolError(error, deps.logger);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
server.registerTool(TOOL_NAMES.sessionWaitExecutionResult, {
|
|
30
|
+
title: "Wait for transaction request result", description: "Wait briefly for one admitted request or required user action.",
|
|
31
|
+
inputSchema: waitExecutionInputSchema(),
|
|
32
|
+
outputSchema: successOutputSchema({ waitOutcome: z.enum(WAIT_OUTCOMES), ...reviewStatusResponseShape, userAnswerUse: userAnswerUseSchema }),
|
|
33
|
+
annotations: { readOnlyHint: false, openWorldHint: false }
|
|
34
|
+
}, async ({ reviewSessionId, timeoutMs }, extra) => {
|
|
35
|
+
try {
|
|
36
|
+
const result = await waitForExecutionResult((id) => readCurrentReview(deps, id), reviewSessionId, { timeoutMs, signal: extra.signal });
|
|
37
|
+
return okToolResult({ waitOutcome: result.waitOutcome, ...reviewStatusResponse(result),
|
|
38
|
+
userAnswerUse: executionResultUserAnswerUse({ hasConnectionConflict: !!result.connectionConflict, hasRequest: !!result.request, hasExecutionResult: !!result.request?.execution, hasWaitOutcome: true }) });
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
return sessionStoreToolError(error, deps.logger);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { registerExecutionResultTools } from "./executionResultTools.js";
|
|
2
|
+
import { registerSessionStatusTools } from "./statusTools.js";
|
|
3
|
+
import { registerWalletConnectionTools } from "./walletConnectionTools.js";
|
|
4
|
+
export function registerSessionTools(server, deps) {
|
|
5
|
+
registerWalletConnectionTools(server, deps);
|
|
6
|
+
registerSessionStatusTools(server, deps);
|
|
7
|
+
registerExecutionResultTools(server, deps);
|
|
8
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { walletObservationSchema } from "../../../core/session/walletRuntime.js";
|
|
2
|
+
import { walletAvailabilitySchema, workflowProgressSchema, walletUnavailable, connectionConflictSchema } from "../../../core/session/walletConnection.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { actionPlanSchema, executionPollingStatusSchema, internalSessionStatusSchema, reviewStateOutputSchema } from "../../../core/action/schemas.js";
|
|
5
|
+
import { EXECUTION_STATUS_CATEGORIES } from "../../../core/session/status.js";
|
|
6
|
+
import { transactionExecutionSummarySchema, transactionRequestSchema, transactionRequestStatusSchema } from "../../../core/session/transactionRequest.js";
|
|
7
|
+
import { DEFAULT_WAIT_TIMEOUT_MS, MAX_WAIT_TIMEOUT_MS } from "../../../core/session/wait.js";
|
|
8
|
+
export const INTERACTION_STATUS_LIMIT = 5;
|
|
9
|
+
export function executionPollingHintSchema() {
|
|
10
|
+
return z.object({ nonTerminalStatuses: z.array(executionPollingStatusSchema), waitStoppingStatuses: z.array(executionPollingStatusSchema),
|
|
11
|
+
finalStatuses: z.array(executionPollingStatusSchema), userActionRequiredStatuses: z.array(executionPollingStatusSchema),
|
|
12
|
+
recommendedIntervalSeconds: z.number().int().positive() });
|
|
13
|
+
}
|
|
14
|
+
export function executionStatusCategorySchema() { return z.enum(EXECUTION_STATUS_CATEGORIES); }
|
|
15
|
+
export const timeoutInputSchema = z.number().int().min(1).max(MAX_WAIT_TIMEOUT_MS).default(DEFAULT_WAIT_TIMEOUT_MS).optional();
|
|
16
|
+
export function waitExecutionInputSchema() { return { reviewSessionId: z.string().min(1), timeoutMs: timeoutInputSchema }; }
|
|
17
|
+
export const reviewStatusResponseShape = {
|
|
18
|
+
connectionConflict: connectionConflictSchema.optional(), walletAvailability: walletAvailabilitySchema, walletObservation: walletObservationSchema.optional(), progress: workflowProgressSchema,
|
|
19
|
+
reviewSessionId: z.string(), status: internalSessionStatusSchema, reviewRevision: z.number().int().nonnegative(),
|
|
20
|
+
account: z.string().optional(), plans: z.array(actionPlanSchema), reviewState: reviewStateOutputSchema.optional(),
|
|
21
|
+
pollingStatus: executionPollingStatusSchema, statusCategory: executionStatusCategorySchema(), pollingHint: executionPollingHintSchema(),
|
|
22
|
+
expiresAt: z.string(), lastActivityAt: z.string(), attemptId: z.string().optional(), requestStatus: transactionRequestStatusSchema.optional(),
|
|
23
|
+
request: transactionRequestSchema.optional(), executionResult: transactionExecutionSummarySchema.optional()
|
|
24
|
+
};
|
|
25
|
+
export function latest(items) {
|
|
26
|
+
const sorted = [...items].sort((left, right) => right.lastActivityAt.localeCompare(left.lastActivityAt));
|
|
27
|
+
return { limit: INTERACTION_STATUS_LIMIT, items: sorted.slice(0, INTERACTION_STATUS_LIMIT), truncated: sorted.length > INTERACTION_STATUS_LIMIT };
|
|
28
|
+
}
|
|
29
|
+
// Runtime workflows own reconciliation/observation. A server without a wallet
|
|
30
|
+
// workflow can still expose ordinary preparation facts, with explicit absence.
|
|
31
|
+
export async function readCurrentReview(deps, id, explicitResult = false) {
|
|
32
|
+
if (deps.workflow)
|
|
33
|
+
return deps.workflow.readReview(id, explicitResult);
|
|
34
|
+
const session = await deps.sessions.getReviewSession(id);
|
|
35
|
+
return session ? { session, hasReviewInput: false, walletAvailability: walletUnavailable("initialization_failed"), progress: { status: "idle" } } : undefined;
|
|
36
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { walletAvailabilitySchema, workflowProgressSchema, walletUnavailable, connectionConflictSchema } from "../../../core/session/walletConnection.js";
|
|
2
|
+
import { walletObservationSchema } from "../../../core/session/walletRuntime.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { activeAccountResponse, activeAccountResponseSchema } from "../../activeAccountResponse.js";
|
|
5
|
+
import { errorToolResult, okToolResult } from "../../result.js";
|
|
6
|
+
import { noParamsInputSchema, successOutputSchema } from "../../schemas.js";
|
|
7
|
+
import { activityStoreToolError, sessionStoreToolError } from "../../toolErrors.js";
|
|
8
|
+
import { TOOL_NAMES } from "../../toolNames.js";
|
|
9
|
+
import { interactionStatusUserAnswerUse, reviewStatusUserAnswerUse } from "../../responseGuidance.js";
|
|
10
|
+
import { userAnswerUseSchema } from "../read/commonSchemas.js";
|
|
11
|
+
import { isReviewInteractionPending, reviewStatusResponse } from "../../../core/session/status.js";
|
|
12
|
+
import { latest, reviewStatusResponseShape, readCurrentReview } from "./shared.js";
|
|
13
|
+
import { pendingConnectionStatusSchema, connectionViewSchema, assetReadAccountSchema } from "../../../core/session/workflowView.js";
|
|
14
|
+
export function registerSessionStatusTools(server, deps) {
|
|
15
|
+
server.registerTool(TOOL_NAMES.sessionGetInteractionStatus, {
|
|
16
|
+
title: "Get local interaction status", description: "Read wallet connections, the default asset account, and pending interactions.",
|
|
17
|
+
inputSchema: noParamsInputSchema,
|
|
18
|
+
outputSchema: successOutputSchema({ walletAvailability: walletAvailabilitySchema, walletObservation: walletObservationSchema.optional(), activeAccount: activeAccountResponseSchema,
|
|
19
|
+
connections: z.array(connectionViewSchema), assetReadAccount: assetReadAccountSchema,
|
|
20
|
+
connectionConflict: connectionConflictSchema.optional(),
|
|
21
|
+
pendingWalletConnections: z.object({ limit: z.number().int().positive(), truncated: z.boolean(),
|
|
22
|
+
items: z.array(z.object({ cardId: z.string(), connectionId: z.string().optional(),
|
|
23
|
+
status: pendingConnectionStatusSchema, progress: workflowProgressSchema, lastActivityAt: z.string() })) }),
|
|
24
|
+
pendingReviewSessions: z.object({ limit: z.number().int().positive(), truncated: z.boolean(), items: z.array(z.object(reviewStatusResponseShape)) }),
|
|
25
|
+
userAnswerUse: userAnswerUseSchema }),
|
|
26
|
+
annotations: { readOnlyHint: false, openWorldHint: false }
|
|
27
|
+
}, async () => {
|
|
28
|
+
let active;
|
|
29
|
+
try {
|
|
30
|
+
active = await deps.activityStore.getActiveAccount();
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
return activityStoreToolError(error, deps.logger);
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
// Connection reconciliation can invalidate reviews and interrupt requests.
|
|
37
|
+
// Complete that maintenance before projecting its dependent review facts.
|
|
38
|
+
const context = deps.workflow?.readConnectionContext() ?? { connections: [],
|
|
39
|
+
assetReadAccount: { status: "address_required" }, walletAvailability: walletUnavailable("initialization_failed") };
|
|
40
|
+
const connections = deps.workflow?.pendingConnections() ?? [];
|
|
41
|
+
const states = await Promise.all(deps.sessions.reviewSessionIds().map((id) => readCurrentReview(deps, id)));
|
|
42
|
+
const reviews = states.flatMap((state) => state && isReviewInteractionPending(state) ? [reviewStatusResponse(state)] : []);
|
|
43
|
+
return okToolResult({ activeAccount: activeAccountResponse(active), pendingWalletConnections: latest(connections),
|
|
44
|
+
pendingReviewSessions: latest(reviews), ...context,
|
|
45
|
+
userAnswerUse: interactionStatusUserAnswerUse("walletObservation" in context && context.walletObservation !== undefined, "connectionConflict" in context && !!context.connectionConflict) });
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
return sessionStoreToolError(error, deps.logger);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
server.registerTool(TOOL_NAMES.sessionGetReviewStatus, {
|
|
52
|
+
title: "Get review status", description: "Read one review session, its admitted request and any observed chain result.",
|
|
53
|
+
inputSchema: { reviewSessionId: z.string().min(1) },
|
|
54
|
+
outputSchema: successOutputSchema({ ...reviewStatusResponseShape, userAnswerUse: userAnswerUseSchema }),
|
|
55
|
+
annotations: { readOnlyHint: false, openWorldHint: false }
|
|
56
|
+
}, async ({ reviewSessionId }) => {
|
|
57
|
+
try {
|
|
58
|
+
const state = await readCurrentReview(deps, reviewSessionId);
|
|
59
|
+
if (!state)
|
|
60
|
+
return errorToolResult({ kind: "session_not_found", details: { reviewSessionId } });
|
|
61
|
+
const session = state.session;
|
|
62
|
+
return okToolResult({ ...reviewStatusResponse(state),
|
|
63
|
+
userAnswerUse: reviewStatusUserAnswerUse(!!session.reviewState, !!session.reviewState?.adapterLifecycle, !!session.reviewState?.humanReadableReview, !!session.reviewState?.simulation, !!state.connectionConflict) });
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
return sessionStoreToolError(error, deps.logger);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { cardMetadata, createWorkflowCard } from "../../../mcp-ui/tools.js";
|
|
3
|
+
import { cardSnapshotSchema } from "../../../mcp-ui/contracts.js";
|
|
4
|
+
import { waitForWalletConnection, WAIT_OUTCOMES } from "../../../core/session/wait.js";
|
|
5
|
+
import { okToolResult } from "../../result.js";
|
|
6
|
+
import { successOutputSchema } from "../../schemas.js";
|
|
7
|
+
import { TOOL_NAMES } from "../../toolNames.js";
|
|
8
|
+
import { timeoutInputSchema } from "./shared.js";
|
|
9
|
+
import { CardError } from "../../../core/session/cardSessionStore.js";
|
|
10
|
+
import { sessionStoreToolError } from "../../toolErrors.js";
|
|
11
|
+
export function registerWalletConnectionTools(server, deps) {
|
|
12
|
+
const failure = (error) => sessionStoreToolError(error, deps.logger);
|
|
13
|
+
server.registerTool(TOOL_NAMES.sessionCreateWalletConnection, {
|
|
14
|
+
title: "Open wallet connection controls", description: "Open a card for Sui wallet connection, disconnection and account selection.",
|
|
15
|
+
inputSchema: { intent: z.enum(["manage", "connect", "disconnect"]).default("manage") }, outputSchema: successOutputSchema(cardSnapshotSchema.shape),
|
|
16
|
+
_meta: cardMetadata("connect"), annotations: { readOnlyHint: false, openWorldHint: false }
|
|
17
|
+
}, async ({ intent }) => { try {
|
|
18
|
+
return await createWorkflowCard(server, deps, "connect", { intent });
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
return failure(error);
|
|
22
|
+
} });
|
|
23
|
+
server.registerTool(TOOL_NAMES.sessionGetWalletConnection, {
|
|
24
|
+
title: "Get wallet connection", description: "Read the saved state of one wallet connection card.",
|
|
25
|
+
inputSchema: { cardId: z.string().min(1) }, outputSchema: successOutputSchema(cardSnapshotSchema.shape),
|
|
26
|
+
annotations: { readOnlyHint: false, openWorldHint: false }
|
|
27
|
+
}, async ({ cardId }) => {
|
|
28
|
+
try {
|
|
29
|
+
if (!deps.cards)
|
|
30
|
+
return failure(new CardError("Wallet card is unavailable."));
|
|
31
|
+
const snapshot = await deps.cards.store.readSaved(cardId);
|
|
32
|
+
if (snapshot.kind !== "connect")
|
|
33
|
+
return failure(new CardError("Wallet card is unavailable."));
|
|
34
|
+
return okToolResult(snapshot);
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
return failure(error);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
server.registerTool(TOOL_NAMES.sessionWaitWalletConnection, {
|
|
41
|
+
title: "Wait for wallet connection", description: "Wait briefly for a wallet connection card's approval or required user input.",
|
|
42
|
+
inputSchema: { cardId: z.string().min(1), timeoutMs: timeoutInputSchema },
|
|
43
|
+
outputSchema: successOutputSchema({ waitOutcome: z.enum(WAIT_OUTCOMES), card: cardSnapshotSchema }),
|
|
44
|
+
annotations: { readOnlyHint: false, openWorldHint: false }
|
|
45
|
+
}, async ({ cardId, timeoutMs }, extra) => {
|
|
46
|
+
try {
|
|
47
|
+
if (!deps.cards)
|
|
48
|
+
return failure(new CardError("Wallet card is unavailable."));
|
|
49
|
+
const result = await waitForWalletConnection(deps.cards.store, cardId, { timeoutMs, signal: extra.signal });
|
|
50
|
+
return okToolResult({ waitOutcome: result.waitOutcome, card: result.snapshot });
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
return failure(error);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
server.registerTool(TOOL_NAMES.sessionOpenReviewManagement, {
|
|
57
|
+
title: "Open transaction request management", description: "Open management for one existing review session and transaction attempt.",
|
|
58
|
+
inputSchema: { reviewSessionId: z.string().min(1), attemptId: z.string().min(1) },
|
|
59
|
+
outputSchema: successOutputSchema(cardSnapshotSchema.shape), _meta: cardMetadata("review"),
|
|
60
|
+
annotations: { readOnlyHint: false, openWorldHint: false }
|
|
61
|
+
}, async (input) => {
|
|
62
|
+
try {
|
|
63
|
+
return await createWorkflowCard(server, deps, "review", { ...input, mode: "manage" });
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
return failure(error);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { SETTINGS_APPLIES_AFTER_RESTART } from "../../../core/preferences/preferencesStore.js";
|
|
3
|
+
import { registerSuiMcpTool } from "../../registerTool.js";
|
|
4
|
+
import { errorToolResult, okToolResult } from "../../result.js";
|
|
5
|
+
import { noParamsInputSchema, successOutputSchema } from "../../schemas.js";
|
|
6
|
+
import { localSettingsToolError, sessionStoreToolError } from "../../toolErrors.js";
|
|
7
|
+
import { TOOL_NAMES } from "../../toolNames.js";
|
|
8
|
+
const endpointSettingSchema = z.object({
|
|
9
|
+
storedValue: z.string(),
|
|
10
|
+
effectiveValue: z.string(),
|
|
11
|
+
source: z.enum(["environment", "local_db", "builtin_default"]),
|
|
12
|
+
pendingStoredValue: z.string().optional(),
|
|
13
|
+
appliesAfter: z.literal(SETTINGS_APPLIES_AFTER_RESTART).optional()
|
|
14
|
+
});
|
|
15
|
+
export function registerSettingsTools(server, deps) {
|
|
16
|
+
server.registerTool(TOOL_NAMES.settingsCreateLocalSettingsSession, {
|
|
17
|
+
title: "Create local settings session",
|
|
18
|
+
description: "Create a local settings page session.",
|
|
19
|
+
inputSchema: noParamsInputSchema,
|
|
20
|
+
outputSchema: successOutputSchema({
|
|
21
|
+
settingsSessionId: z.string(),
|
|
22
|
+
settingsUrl: z.string(),
|
|
23
|
+
status: z.literal("created"),
|
|
24
|
+
openTarget: z.literal("system_browser"),
|
|
25
|
+
accessScope: z.literal("same_machine_loopback"),
|
|
26
|
+
expiresAt: z.string(),
|
|
27
|
+
lastActivityAt: z.string()
|
|
28
|
+
}),
|
|
29
|
+
annotations: { readOnlyHint: false, openWorldHint: false }
|
|
30
|
+
}, async () => {
|
|
31
|
+
try {
|
|
32
|
+
if (!deps.reviewBaseUrl)
|
|
33
|
+
return errorToolResult({ kind: "ui_unavailable", details: { reason: "Settings UI is unavailable in this runtime." } });
|
|
34
|
+
const created = await deps.sessions.createSettingsSession();
|
|
35
|
+
return okToolResult({
|
|
36
|
+
settingsSessionId: created.session.id,
|
|
37
|
+
settingsUrl: `${deps.reviewBaseUrl}/settings/${created.session.id}#${created.token}`,
|
|
38
|
+
status: "created",
|
|
39
|
+
openTarget: "system_browser",
|
|
40
|
+
accessScope: "same_machine_loopback",
|
|
41
|
+
expiresAt: created.session.expiresAt,
|
|
42
|
+
lastActivityAt: created.session.lastActivityAt
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
return sessionStoreToolError(error, deps.logger);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
registerSuiMcpTool(server, TOOL_NAMES.settingsGetLocalSettings, {
|
|
50
|
+
title: "Get local settings",
|
|
51
|
+
description: "Read local Sui MCP settings.",
|
|
52
|
+
inputSchema: noParamsInputSchema,
|
|
53
|
+
outputSchema: successOutputSchema({
|
|
54
|
+
suiGrpcUrl: endpointSettingSchema,
|
|
55
|
+
suiGraphqlUrl: endpointSettingSchema
|
|
56
|
+
}),
|
|
57
|
+
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
58
|
+
}, async () => {
|
|
59
|
+
try {
|
|
60
|
+
return okToolResult(await deps.localSettings.getLocalSettings());
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
return localSettingsToolError(error, deps.logger);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|