@wowok/agent-mcp 2.2.13 → 2.2.14
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/dist/index.js +42 -98
- package/dist/schema-query/index.d.ts +29 -0
- package/dist/schema-query/index.js +149 -0
- package/dist/schemas/account_operation.schema.json +255 -0
- package/dist/schemas/guard2file.schema.json +71 -0
- package/dist/schemas/index.json +139 -0
- package/dist/schemas/local_info_operation.schema.json +142 -0
- package/dist/schemas/local_mark_operation.schema.json +119 -0
- package/dist/schemas/machineNode2file.schema.json +71 -0
- package/dist/schemas/messenger_operation.schema.json +1393 -0
- package/dist/schemas/onchain_events.schema.json +113 -0
- package/dist/schemas/onchain_operations.schema.json +376 -0
- package/dist/schemas/onchain_operations_allocation.schema.json +914 -0
- package/dist/schemas/onchain_operations_arbitration.schema.json +1166 -0
- package/dist/schemas/onchain_operations_contact.schema.json +853 -0
- package/dist/schemas/onchain_operations_demand.schema.json +984 -0
- package/dist/schemas/onchain_operations_gen_passport.schema.json +1141 -0
- package/dist/schemas/onchain_operations_guard.schema.json +713 -0
- package/dist/schemas/onchain_operations_machine.schema.json +1347 -0
- package/dist/schemas/onchain_operations_order.schema.json +830 -0
- package/dist/schemas/onchain_operations_payment.schema.json +717 -0
- package/dist/schemas/onchain_operations_permission.schema.json +1088 -0
- package/dist/schemas/onchain_operations_personal.schema.json +1282 -0
- package/dist/schemas/onchain_operations_progress.schema.json +751 -0
- package/dist/schemas/onchain_operations_repository.schema.json +1572 -0
- package/dist/schemas/onchain_operations_reward.schema.json +955 -0
- package/dist/schemas/onchain_operations_service.schema.json +1411 -0
- package/dist/schemas/onchain_operations_treasury.schema.json +1155 -0
- package/dist/schemas/onchain_table_data.schema.json +35 -0
- package/dist/schemas/operations/guard.json +163 -0
- package/dist/schemas/operations/permission.json +22 -0
- package/dist/schemas/query_toolkit.schema.json +32 -0
- package/dist/schemas/schema_query.schema.json +33 -0
- package/dist/schemas/wip_file.schema.json +27 -0
- package/dist/schemas/wowok_buildin_info.schema.json +487 -0
- package/package.json +7 -5
- package/dist/docs/index.d.ts +0 -3
- package/dist/docs/index.js +0 -2
- package/dist/docs/loader.d.ts +0 -12
- package/dist/docs/loader.js +0 -177
- package/dist/docs/search.d.ts +0 -17
- package/dist/docs/search.js +0 -325
- package/dist/docs/types.d.ts +0 -55
- package/dist/docs/types.js +0 -1
- package/docs/README.md +0 -249
- package/docs/WIP.md +0 -388
- package/docs/WTS.md +0 -536
- package/docs/docs/account.md +0 -914
- package/docs/docs/allocation.md +0 -635
- package/docs/docs/arbitration.md +0 -1804
- package/docs/docs/arbitration_state_machine.md +0 -270
- package/docs/docs/contact.md +0 -709
- package/docs/docs/demand.md +0 -948
- package/docs/docs/guard.md +0 -1465
- package/docs/docs/localinfo.md +0 -432
- package/docs/docs/localmark.md +0 -583
- package/docs/docs/machine.md +0 -2490
- package/docs/docs/messenger.md +0 -2098
- package/docs/docs/onchain_events.md +0 -267
- package/docs/docs/order.md +0 -1001
- package/docs/docs/payment.md +0 -512
- package/docs/docs/permission.md +0 -1438
- package/docs/docs/personal.md +0 -742
- package/docs/docs/progress.md +0 -1748
- package/docs/docs/query.md +0 -467
- package/docs/docs/repository.md +0 -1043
- package/docs/docs/reward.md +0 -833
- package/docs/docs/service.md +0 -2130
- package/docs/docs/stage-01-introduction.md +0 -243
- package/docs/docs/stage-02-trust.md +0 -302
- package/docs/docs/stage-03-collaboration.md +0 -337
- package/docs/docs/stage-04-transaction.md +0 -277
- package/docs/docs/stage-05-business.md +0 -151
- package/docs/docs/stage-06-personal.md +0 -203
- package/docs/docs/stage-07-query.md +0 -572
- package/docs/docs/stage-08-examples.md +0 -184
- package/docs/docs/treasury.md +0 -1149
- package/docs/docs/wowok_buildin_info.md +0 -740
- package/docs/examples/Insurance/Insurance.md +0 -594
- package/docs/examples/Insurance/Insurance_TestResults.md +0 -481
- package/docs/examples/Insurance/insurance_complete_guard_v1.json +0 -50
- package/docs/examples/MyShop/MyShop.md +0 -1353
- package/docs/examples/MyShop/MyShop_TestResults.md +0 -1003
- package/docs/examples/MyShop_Advanced/MyShop_Advanced.md +0 -1898
- package/docs/examples/MyShop_Advanced/MyShop_Advanced_MerchantSystem_TestResults.md +0 -1297
- package/docs/examples/MyShop_Advanced/MyShop_Advanced_OrderFlow_TestResults.md +0 -743
- package/docs/examples/MyShop_Advanced/machine_nodes.json +0 -222
- package/docs/examples/ThreeBody_Signature/ThreeBody_Signature.md +0 -776
- package/docs/examples/ThreeBody_Signature/ThreeBody_Signature_TestResults.md +0 -599
- package/docs/examples/Travel/Travel.md +0 -1157
- package/docs/examples/Travel/Travel_TestResults.md +0 -743
- package/docs/examples/Travel/calc-weather-timestamps.js +0 -8
- package/docs/examples/Travel/travel_machine_v2_export.json +0 -104
- package/docs/examples/Travel/weather_check_guard_v1.json +0 -51
- package/docs/skills/WOWOK.md +0 -650
- package/docs/skills/onchain_operations/_common.md +0 -406
- package/docs/skills/onchain_operations/_index.md +0 -196
- package/docs/skills/onchain_operations/allocation.md +0 -28
- package/docs/skills/onchain_operations/arbitration.md +0 -106
- package/docs/skills/onchain_operations/contact.md +0 -40
- package/docs/skills/onchain_operations/demand.md +0 -53
- package/docs/skills/onchain_operations/gen_passport.md +0 -23
- package/docs/skills/onchain_operations/guard.md +0 -56
- package/docs/skills/onchain_operations/machine.md +0 -89
- package/docs/skills/onchain_operations/order.md +0 -56
- package/docs/skills/onchain_operations/payment.md +0 -24
- package/docs/skills/onchain_operations/permission.md +0 -68
- package/docs/skills/onchain_operations/personal.md +0 -58
- package/docs/skills/onchain_operations/progress.md +0 -38
- package/docs/skills/onchain_operations/repository.md +0 -70
- package/docs/skills/onchain_operations/reward.md +0 -38
- package/docs/skills/onchain_operations/service.md +0 -78
- package/docs/skills/onchain_operations/treasury.md +0 -68
- package/docs/skills/schema-account_operation.md +0 -402
- package/docs/skills/schema-guard2file.md +0 -153
- package/docs/skills/schema-local_info_operation.md +0 -160
- package/docs/skills/schema-local_mark_operation.md +0 -148
- package/docs/skills/schema-machineNode2file.md +0 -155
- package/docs/skills/schema-messenger_operation.md +0 -547
- package/docs/skills/schema-onchain_events.md +0 -201
- package/docs/skills/schema-onchain_table_data.md +0 -334
- package/docs/skills/schema-query_toolkit.md +0 -395
- package/docs/skills/schema-wip_file.md +0 -240
- package/docs/skills/schema-wowok_buildin_info.md +0 -296
- package/docs/wip-examples/three_body.html +0 -57
- package/docs/wip-examples/three_body.wip +0 -30
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { resolve } from "path";
|
|
|
7
7
|
const packageJson = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf-8"));
|
|
8
8
|
import { CallService_DataSchema, CallMachine_DataSchema, MachineNode2File_InputSchema, MachineNode2File_OutputWrappedSchema, CallProgress_DataSchema, CallPermission_DataSchema, CallGuard_DataSchema, Guard2File_InputSchema, Guard2File_OutputWrappedSchema, CallArbitration_DataSchema, CallRepository_DataSchema, CallContact_DataSchema, CallTreasury_DataSchema, CallReward_DataSchema, CallAllocation_DataSchema, CallPersonal_DataSchema, CallPayment_DataSchema, CallDemand_DataSchema, CallOrder_DataSchema, CallEnvSchema, SubmissionCallSchema, strictParse, CallOutputSchema, handleCallResult, createServerConfig, createCapabilitiesConfig, createToolMeta, transformSubmission, getEnvConfig, WipGenerationOptionsSchema, WipToHtmlOptionsSchema, TokenDataFilterSchema, LocalInfoFilterSchema, LocalMarkFilterSchema, AccountFilterSchema, TokenTypeSchema, OnchainEventsInputSchema, OnchainEventsResultSchema, ProtocolInfoQuerySchema, ProtocolInfoResultSchema, TableAnswerSchema, TableItem_RepositoryDataSchema, TableItem_PermissionPermSchema, TableItem_EntityRegistrarSchema, TableItem_EntityLinkerSchema, TableItem_RewardRecordSchema, TableItem_DemandPresenterSchema, TableItem_TreasuryHistorySchema, TableItem_MachineNodeSchema, TableItem_ProgressHistorySchema, TableItem_AddressMarkSchema, NameOrAddressSchema, ObjectBaseSchema, AccountOrMark_AddressSchema, AccountOrMark_AddressAISchema, EntrypointSchema, AccountOperationOutputWrappedSchema, LocalMarkOperationOutputWrappedSchema, LocalInfoOperationOutputWrappedSchema, WipOperationOutputSchema, MessengerOperationOutputSchema, AccountOperationSchema, LocalMarkOperationSchema, LocalInfoOperationSchema, parseMachineNodesFromText, formatNodeErrors as formatMachineNodeErrors, MessengerOperationInputSchema, } from "./schema/index.js";
|
|
9
9
|
import { CallService, CallMachine, CallProgress, CallPermission, CallGuard, CallArbitration, CallRepository, CallContact, CallTreasury, CallReward, CallAllocation, CallPersonal, CallPayment, CallDemand, CallOrder, gen_passport, guard2file, parseGuardFile, formatGuardParseErrors, machineNode2file, generateNodeComments, generate_wip, verify_wip, sign_wip, wip2html, account_operation, local_mark_operation, local_info_operation, watch_conversations, send_message, send_file, watch_messages, extract_zip_messages, generate_wts, verify_wts, sign_wts, wts2html, proof_message, mark_messages_as_viewed, mark_conversation_as_viewed, query_local_mark_list, query_account_list, query_local_info_list, query_local_token_list, query_account, GetLocalNamesByAddresses, query_personal, query_objects, query_table, query_tableItem, queryProtocolInfo, query_received, queryTableItem_RepositoryData, queryTableItem_PermissionPerm, queryTableItem_RewardRecord, queryTableItem_DemandPresenter, queryTableItem_TreasuryHistory, queryTableItem_MachineNode, queryTableItem_ProgressHistory, queryTableItem_AddressMark, queryTableItem_EntityRegistrar, queryTableItem_EntityLinker, query_events, blacklist, friendslist, guardlist, settings, AmountType, } from "@wowok/wowok";
|
|
10
|
-
import {
|
|
10
|
+
import { areSchemasAvailable, getSchemaIndex, processSchemaQuery, } from "./schema-query/index.js";
|
|
11
11
|
const SERVER_DESCRIPTION = `WoWok MCP Server - Making It Easy for AI Agents to Communicate, Collaborate, Trade, and Trust.
|
|
12
12
|
|
|
13
13
|
## Token System Overview
|
|
@@ -1306,19 +1306,14 @@ async function handleMachineNode2File(args) {
|
|
|
1306
1306
|
}
|
|
1307
1307
|
export { OnchainOperationsSchema, WipOperationsSchema, WatchQueryOperationsSchema, AccountOperationSchema, LocalMarkOperationSchema, LocalInfoOperationSchema, ProtocolInfoQuerySchema, CallOutputSchema, MessengerOperationInputSchema, MessengerOperationOutputSchema };
|
|
1308
1308
|
async function main() {
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
const stats = getDocStats();
|
|
1314
|
-
console.error(`Documentation loaded: ${stats.total} files (${stats.skills} skills, ${stats.examples} examples)`);
|
|
1315
|
-
}
|
|
1316
|
-
catch (error) {
|
|
1317
|
-
console.error("Failed to load documentation:", error);
|
|
1309
|
+
if (areSchemasAvailable()) {
|
|
1310
|
+
const index = getSchemaIndex();
|
|
1311
|
+
if (index) {
|
|
1312
|
+
console.error(`Schema system ready: ${index.tools?.length || 0} tools, ${index.operations?.length || 0} operations`);
|
|
1318
1313
|
}
|
|
1319
1314
|
}
|
|
1320
1315
|
else {
|
|
1321
|
-
console.error("
|
|
1316
|
+
console.error("Schema files not available. Run 'npm run generate:schemas' to generate them.");
|
|
1322
1317
|
}
|
|
1323
1318
|
server.registerTool("onchain_operations", {
|
|
1324
1319
|
title: "⛓️ On-chain Operations",
|
|
@@ -1444,119 +1439,68 @@ async function main() {
|
|
|
1444
1439
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
1445
1440
|
_meta: createToolMeta("WoWok info", ["build-in", "constants", "permissions", "guard", "network", "value-types"]),
|
|
1446
1441
|
}, handleWowokInfo);
|
|
1447
|
-
server.registerTool("
|
|
1448
|
-
title: "
|
|
1449
|
-
description: "
|
|
1442
|
+
server.registerTool("schema_query", {
|
|
1443
|
+
title: "📋 Schema Query",
|
|
1444
|
+
description: "Query JSON schemas for all WoWok MCP tools and operations. Use this tool to understand the exact structure required for calling other tools. Returns complete JSON Schema definitions with all properties, types, and descriptions. This is the authoritative source for tool schemas.",
|
|
1450
1445
|
inputSchema: z.object({
|
|
1451
|
-
action: z.enum(["
|
|
1452
|
-
.describe("Action to perform: '
|
|
1453
|
-
|
|
1454
|
-
query: z.string().optional().describe("Search query for
|
|
1455
|
-
example: z.string().optional().describe("Example name to learn from (e.g., 'MyShop', 'Travel', 'Insurance')"),
|
|
1456
|
-
operationType: z.string().optional().describe("Operation type for schema lookup (e.g., 'service', 'guard', 'machine', 'order')"),
|
|
1457
|
-
toolName: z.string().optional().describe("Tool name for schema lookup (e.g., 'query_toolkit', 'messenger_operation')"),
|
|
1446
|
+
action: z.enum(["list", "get", "search", "list_operations"])
|
|
1447
|
+
.describe("Action to perform: 'list' to see all available schemas, 'get' to retrieve a specific schema, 'search' to find schemas by keyword, 'list_operations' to list all on-chain operations"),
|
|
1448
|
+
name: z.string().optional().describe("Schema name for 'get' action (e.g., 'onchain_operations', 'account_operation', 'onchain_operations_permission')"),
|
|
1449
|
+
query: z.string().optional().describe("Search query for 'search' action"),
|
|
1458
1450
|
}),
|
|
1459
1451
|
outputSchema: z.object({
|
|
1460
1452
|
success: z.boolean().describe("Whether the request was successful"),
|
|
1461
1453
|
action: z.string().describe("The action that was performed"),
|
|
1462
|
-
data: z.any().describe("Response data
|
|
1454
|
+
data: z.any().describe("Response data - JSON Schema object for 'get', array of schema info for 'list'/'search'/'list_operations'"),
|
|
1463
1455
|
message: z.string().describe("Human-readable message describing the result"),
|
|
1464
1456
|
suggestions: z.array(z.string()).optional().describe("Suggested next steps or alternatives"),
|
|
1465
1457
|
}),
|
|
1466
|
-
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint:
|
|
1467
|
-
_meta: createToolMeta("
|
|
1458
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
1459
|
+
_meta: createToolMeta("schema", ["schema", "json-schema", "types", "structure", "validation", "reference"]),
|
|
1468
1460
|
}, async (args) => {
|
|
1469
|
-
if (!docIndex) {
|
|
1470
|
-
return {
|
|
1471
|
-
content: [{
|
|
1472
|
-
type: "text",
|
|
1473
|
-
text: "Documentation system is not available. Please ensure docs/skills and docs/examples are copied to the package.",
|
|
1474
|
-
}],
|
|
1475
|
-
structuredContent: {
|
|
1476
|
-
success: false,
|
|
1477
|
-
action: args.action,
|
|
1478
|
-
data: null,
|
|
1479
|
-
message: "Documentation system unavailable",
|
|
1480
|
-
suggestions: ["Check that docs/ directory exists", "Ensure docs/skills and docs/examples subdirectories are present"],
|
|
1481
|
-
},
|
|
1482
|
-
};
|
|
1483
|
-
}
|
|
1484
1461
|
const request = {
|
|
1485
1462
|
action: args.action,
|
|
1486
|
-
|
|
1463
|
+
name: args.name,
|
|
1487
1464
|
query: args.query,
|
|
1488
|
-
example: args.example,
|
|
1489
|
-
operationType: args.operationType,
|
|
1490
|
-
toolName: args.toolName,
|
|
1491
1465
|
};
|
|
1492
|
-
const response =
|
|
1466
|
+
const response = processSchemaQuery(request);
|
|
1493
1467
|
let textContent = response.message;
|
|
1494
1468
|
const data = response.data;
|
|
1495
1469
|
if (response.success && data) {
|
|
1496
1470
|
switch (args.action) {
|
|
1497
|
-
case "
|
|
1471
|
+
case "list":
|
|
1472
|
+
case "list_operations":
|
|
1498
1473
|
if (Array.isArray(data) && data.length > 0) {
|
|
1499
|
-
textContent += "\n\
|
|
1474
|
+
textContent += "\n\nAvailable schemas:\n";
|
|
1500
1475
|
for (const item of data) {
|
|
1501
|
-
textContent += `\n
|
|
1502
|
-
if (item.
|
|
1503
|
-
textContent += `
|
|
1476
|
+
textContent += `\n • ${item.name}`;
|
|
1477
|
+
if (item.title) {
|
|
1478
|
+
textContent += ` - ${item.title}`;
|
|
1504
1479
|
}
|
|
1480
|
+
if (item.description) {
|
|
1481
|
+
textContent += `\n ${item.description.slice(0, 100)}...`;
|
|
1482
|
+
}
|
|
1483
|
+
textContent += "\n";
|
|
1505
1484
|
}
|
|
1506
1485
|
}
|
|
1507
1486
|
break;
|
|
1508
|
-
case "
|
|
1509
|
-
if (data
|
|
1510
|
-
textContent +=
|
|
1511
|
-
textContent +=
|
|
1512
|
-
|
|
1513
|
-
if (data.description) {
|
|
1514
|
-
textContent += `${data.description}\n\n`;
|
|
1515
|
-
}
|
|
1516
|
-
if (data.dataSchema) {
|
|
1517
|
-
textContent += "## Data Schema\n\n";
|
|
1518
|
-
textContent += "```typescript\n";
|
|
1519
|
-
textContent += data.dataSchema.slice(0, 1000);
|
|
1487
|
+
case "get":
|
|
1488
|
+
if (data) {
|
|
1489
|
+
textContent += "\n\n## JSON Schema\n\n";
|
|
1490
|
+
textContent += "```json\n";
|
|
1491
|
+
textContent += JSON.stringify(data, null, 2);
|
|
1520
1492
|
textContent += "\n```\n";
|
|
1521
1493
|
}
|
|
1522
|
-
if (data.relatedOperations && data.relatedOperations.length > 0) {
|
|
1523
|
-
textContent += `\nRelated operations: ${data.relatedOperations.join(", ")}\n`;
|
|
1524
|
-
}
|
|
1525
1494
|
break;
|
|
1526
|
-
case "
|
|
1527
|
-
if (data.
|
|
1528
|
-
textContent += `\n\
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
textContent += "Documents:\n";
|
|
1536
|
-
for (const doc of data.documents) {
|
|
1537
|
-
textContent += ` • ${doc.title}\n`;
|
|
1538
|
-
}
|
|
1539
|
-
}
|
|
1540
|
-
if (data.hasTestResults) {
|
|
1541
|
-
textContent += "\n✓ Test results available\n";
|
|
1542
|
-
}
|
|
1543
|
-
break;
|
|
1544
|
-
case "guide":
|
|
1545
|
-
if (data.content) {
|
|
1546
|
-
const maxLength = 3000;
|
|
1547
|
-
let content = data.content;
|
|
1548
|
-
if (content.length > maxLength) {
|
|
1549
|
-
content = content.slice(0, maxLength) + "\n\n... [Content truncated, use search for specific topics]";
|
|
1550
|
-
}
|
|
1551
|
-
textContent += `\n\n${content}\n`;
|
|
1552
|
-
}
|
|
1553
|
-
break;
|
|
1554
|
-
case "list_operations":
|
|
1555
|
-
case "list_examples":
|
|
1556
|
-
if (Array.isArray(response.data)) {
|
|
1557
|
-
textContent += `\n\nAvailable ${args.action === "list_operations" ? "operations" : "examples"}:\n`;
|
|
1558
|
-
for (const item of response.data) {
|
|
1559
|
-
textContent += ` • ${item.name}${item.title ? ` - ${item.title}` : ""}\n`;
|
|
1495
|
+
case "search":
|
|
1496
|
+
if (Array.isArray(data) && data.length > 0) {
|
|
1497
|
+
textContent += `\n\nFound ${data.length} schemas matching '${args.query}':\n`;
|
|
1498
|
+
for (const item of data) {
|
|
1499
|
+
textContent += `\n • ${item.name}`;
|
|
1500
|
+
if (item.title) {
|
|
1501
|
+
textContent += ` - ${item.title}`;
|
|
1502
|
+
}
|
|
1503
|
+
textContent += "\n";
|
|
1560
1504
|
}
|
|
1561
1505
|
}
|
|
1562
1506
|
break;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface SchemaInfo {
|
|
2
|
+
name: string;
|
|
3
|
+
title: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
path: string;
|
|
6
|
+
}
|
|
7
|
+
export interface SchemaQueryRequest {
|
|
8
|
+
action: "list" | "get" | "search" | "list_operations";
|
|
9
|
+
name?: string;
|
|
10
|
+
query?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface SchemaQueryResponse {
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
success: boolean;
|
|
15
|
+
action: string;
|
|
16
|
+
data: any;
|
|
17
|
+
message: string;
|
|
18
|
+
suggestions?: string[];
|
|
19
|
+
}
|
|
20
|
+
export declare function areSchemasAvailable(): boolean;
|
|
21
|
+
export declare function getSchemaIndex(): {
|
|
22
|
+
tools: SchemaInfo[];
|
|
23
|
+
operations: SchemaInfo[];
|
|
24
|
+
} | null;
|
|
25
|
+
export declare function listSchemas(): SchemaInfo[];
|
|
26
|
+
export declare function getSchema(name: string): any | null;
|
|
27
|
+
export declare function searchSchemas(query: string): SchemaInfo[];
|
|
28
|
+
export declare function listOperations(): SchemaInfo[];
|
|
29
|
+
export declare function processSchemaQuery(request: SchemaQueryRequest): SchemaQueryResponse;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { readFileSync, existsSync } from "fs";
|
|
2
|
+
import { resolve, join } from "path";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
5
|
+
const __dirname = fileURLToPath(new URL(".", import.meta.url));
|
|
6
|
+
const SCHEMAS_DIR = resolve(__dirname, "../../dist/schemas");
|
|
7
|
+
export function areSchemasAvailable() {
|
|
8
|
+
return existsSync(SCHEMAS_DIR) && existsSync(join(SCHEMAS_DIR, "index.json"));
|
|
9
|
+
}
|
|
10
|
+
export function getSchemaIndex() {
|
|
11
|
+
try {
|
|
12
|
+
const indexPath = join(SCHEMAS_DIR, "index.json");
|
|
13
|
+
if (!existsSync(indexPath))
|
|
14
|
+
return null;
|
|
15
|
+
const content = readFileSync(indexPath, "utf-8");
|
|
16
|
+
return JSON.parse(content);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function listSchemas() {
|
|
23
|
+
const index = getSchemaIndex();
|
|
24
|
+
if (!index)
|
|
25
|
+
return [];
|
|
26
|
+
return [
|
|
27
|
+
...(index.tools || []),
|
|
28
|
+
...(index.operations || []),
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
export function getSchema(name) {
|
|
32
|
+
try {
|
|
33
|
+
let schemaPath = join(SCHEMAS_DIR, `${name}.schema.json`);
|
|
34
|
+
if (!existsSync(schemaPath)) {
|
|
35
|
+
schemaPath = join(SCHEMAS_DIR, `${name}.json`);
|
|
36
|
+
}
|
|
37
|
+
if (!existsSync(schemaPath)) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
const content = readFileSync(schemaPath, "utf-8");
|
|
41
|
+
return JSON.parse(content);
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export function searchSchemas(query) {
|
|
48
|
+
const allSchemas = listSchemas();
|
|
49
|
+
const lowerQuery = query.toLowerCase();
|
|
50
|
+
return allSchemas.filter(schema => {
|
|
51
|
+
const nameMatch = schema.name.toLowerCase().includes(lowerQuery);
|
|
52
|
+
const titleMatch = schema.title?.toLowerCase().includes(lowerQuery);
|
|
53
|
+
const descMatch = schema.description?.toLowerCase().includes(lowerQuery);
|
|
54
|
+
return nameMatch || titleMatch || descMatch;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
export function listOperations() {
|
|
58
|
+
const index = getSchemaIndex();
|
|
59
|
+
if (!index)
|
|
60
|
+
return [];
|
|
61
|
+
return (index.operations || []).filter(op => op.name.startsWith("onchain_operations_"));
|
|
62
|
+
}
|
|
63
|
+
export function processSchemaQuery(request) {
|
|
64
|
+
const { action, name, query } = request;
|
|
65
|
+
if (!areSchemasAvailable()) {
|
|
66
|
+
return {
|
|
67
|
+
success: false,
|
|
68
|
+
action,
|
|
69
|
+
data: null,
|
|
70
|
+
message: "Schema files are not available. Please run 'npm run generate:schemas' first.",
|
|
71
|
+
suggestions: ["Run 'npm run generate:schemas' to generate schema files", "Ensure the dist/schemas directory exists"],
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
switch (action) {
|
|
75
|
+
case "list": {
|
|
76
|
+
const schemas = listSchemas();
|
|
77
|
+
return {
|
|
78
|
+
success: true,
|
|
79
|
+
action,
|
|
80
|
+
data: schemas,
|
|
81
|
+
message: `Found ${schemas.length} available schemas`,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
case "get": {
|
|
85
|
+
if (!name) {
|
|
86
|
+
return {
|
|
87
|
+
success: false,
|
|
88
|
+
action,
|
|
89
|
+
data: null,
|
|
90
|
+
message: "Schema name is required for 'get' action",
|
|
91
|
+
suggestions: ["Provide a schema name", "Use 'list' action to see available schemas"],
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
const schema = getSchema(name);
|
|
95
|
+
if (!schema) {
|
|
96
|
+
const suggestions = searchSchemas(name).slice(0, 5);
|
|
97
|
+
return {
|
|
98
|
+
success: false,
|
|
99
|
+
action,
|
|
100
|
+
data: null,
|
|
101
|
+
message: `Schema '${name}' not found`,
|
|
102
|
+
suggestions: suggestions.length > 0
|
|
103
|
+
? suggestions.map(s => `Did you mean: ${s.name}?`)
|
|
104
|
+
: ["Use 'list' action to see available schemas"],
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
success: true,
|
|
109
|
+
action,
|
|
110
|
+
data: schema,
|
|
111
|
+
message: `Retrieved schema: ${name}`,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
case "search": {
|
|
115
|
+
if (!query) {
|
|
116
|
+
return {
|
|
117
|
+
success: false,
|
|
118
|
+
action,
|
|
119
|
+
data: null,
|
|
120
|
+
message: "Search query is required for 'search' action",
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
const results = searchSchemas(query);
|
|
124
|
+
return {
|
|
125
|
+
success: true,
|
|
126
|
+
action,
|
|
127
|
+
data: results,
|
|
128
|
+
message: `Found ${results.length} schemas matching '${query}'`,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
case "list_operations": {
|
|
132
|
+
const operations = listOperations();
|
|
133
|
+
return {
|
|
134
|
+
success: true,
|
|
135
|
+
action,
|
|
136
|
+
data: operations,
|
|
137
|
+
message: `Found ${operations.length} on-chain operations`,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
default:
|
|
141
|
+
return {
|
|
142
|
+
success: false,
|
|
143
|
+
action,
|
|
144
|
+
data: null,
|
|
145
|
+
message: `Unknown action: ${action}`,
|
|
146
|
+
suggestions: ["Use 'list', 'get', 'search', or 'list_operations'"],
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "https://wowok.net/schemas/account_operation.json",
|
|
4
|
+
"title": "Account Operations",
|
|
5
|
+
"description": "Manage WoWok accounts locally: generate, suspend, resume, faucet-test, operate assets, sign data",
|
|
6
|
+
"$ref": "#/definitions/account_operation",
|
|
7
|
+
"definitions": {
|
|
8
|
+
"account_operation": {
|
|
9
|
+
"type": "object",
|
|
10
|
+
"properties": {
|
|
11
|
+
"gen": {
|
|
12
|
+
"type": "object",
|
|
13
|
+
"properties": {
|
|
14
|
+
"name": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "Account name (max 64 characters). Use empty string '' or omit for the default account."
|
|
17
|
+
},
|
|
18
|
+
"replaceExistName": {
|
|
19
|
+
"type": "boolean",
|
|
20
|
+
"description": "If true, existing account with the same name will lose the name; if false (default), throw error when name exists"
|
|
21
|
+
},
|
|
22
|
+
"m": {
|
|
23
|
+
"anyOf": [
|
|
24
|
+
{
|
|
25
|
+
"$ref": "#/definitions/account_operation/properties/gen/properties/name"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"type": "null"
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"description": "Messenger name to enable messenger for this account (max 64 characters). If null, disable messenger. Omit to leave messenger unchanged."
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"additionalProperties": false,
|
|
35
|
+
"description": "Generate new account"
|
|
36
|
+
},
|
|
37
|
+
"faucet": {
|
|
38
|
+
"type": "object",
|
|
39
|
+
"properties": {
|
|
40
|
+
"name_or_address": {
|
|
41
|
+
"type": "string",
|
|
42
|
+
"description": "Account name or address. Use empty string '' for the default account. Defaults to '' if omitted."
|
|
43
|
+
},
|
|
44
|
+
"network": {
|
|
45
|
+
"type": "string",
|
|
46
|
+
"enum": [
|
|
47
|
+
"localnet",
|
|
48
|
+
"testnet"
|
|
49
|
+
],
|
|
50
|
+
"description": "Network entrypoint for Faucet: Specifies which network the operation occurs on"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"required": [
|
|
54
|
+
"network"
|
|
55
|
+
],
|
|
56
|
+
"additionalProperties": false,
|
|
57
|
+
"description": "Distribute test coins from faucet to the specified account"
|
|
58
|
+
},
|
|
59
|
+
"suspend": {
|
|
60
|
+
"type": "object",
|
|
61
|
+
"properties": {
|
|
62
|
+
"name_or_address": {
|
|
63
|
+
"$ref": "#/definitions/account_operation/properties/faucet/properties/name_or_address",
|
|
64
|
+
"description": "Account name or address. Use empty string '' for the default account. Defaults to '' if omitted."
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"additionalProperties": false,
|
|
68
|
+
"description": "Remove account from active account list (cannot sign transactions), and delete its name"
|
|
69
|
+
},
|
|
70
|
+
"resume": {
|
|
71
|
+
"type": "object",
|
|
72
|
+
"properties": {
|
|
73
|
+
"address": {
|
|
74
|
+
"type": "string",
|
|
75
|
+
"description": "Valid ID: 0x prefix + 64 hex characters, or builtin ID (0x5-0x9, @0xaaa, @0xaab, @0x403, @0xacc, @0xc)"
|
|
76
|
+
},
|
|
77
|
+
"name": {
|
|
78
|
+
"$ref": "#/definitions/account_operation/properties/gen/properties/name",
|
|
79
|
+
"description": "New name for the resumed account. Omit to leave unnamed."
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"required": [
|
|
83
|
+
"address"
|
|
84
|
+
],
|
|
85
|
+
"additionalProperties": false,
|
|
86
|
+
"description": "Add account back to active account list"
|
|
87
|
+
},
|
|
88
|
+
"rename": {
|
|
89
|
+
"type": "object",
|
|
90
|
+
"properties": {
|
|
91
|
+
"name_or_address": {
|
|
92
|
+
"$ref": "#/definitions/account_operation/properties/faucet/properties/name_or_address",
|
|
93
|
+
"description": "Source account name or address. Use empty string '' for the default account. Defaults to '' if omitted. Can be a name or address."
|
|
94
|
+
},
|
|
95
|
+
"new_name": {
|
|
96
|
+
"$ref": "#/definitions/account_operation/properties/gen/properties/name",
|
|
97
|
+
"description": "New account name (max 64 characters). Must be a name (not an address)."
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
"required": [
|
|
101
|
+
"new_name"
|
|
102
|
+
],
|
|
103
|
+
"additionalProperties": false,
|
|
104
|
+
"description": "Rename account. name_or_address can be name or address, new_name must be a name."
|
|
105
|
+
},
|
|
106
|
+
"swap_name": {
|
|
107
|
+
"type": "object",
|
|
108
|
+
"properties": {
|
|
109
|
+
"name1": {
|
|
110
|
+
"$ref": "#/definitions/account_operation/properties/gen/properties/name",
|
|
111
|
+
"description": "First account name. Use empty string '' for the default account."
|
|
112
|
+
},
|
|
113
|
+
"name2": {
|
|
114
|
+
"$ref": "#/definitions/account_operation/properties/gen/properties/name",
|
|
115
|
+
"description": "Second account name. Use empty string '' for the default account."
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
"additionalProperties": false,
|
|
119
|
+
"description": "Swap the names of two accounts"
|
|
120
|
+
},
|
|
121
|
+
"transfer": {
|
|
122
|
+
"type": "object",
|
|
123
|
+
"properties": {
|
|
124
|
+
"name_or_address_from": {
|
|
125
|
+
"$ref": "#/definitions/account_operation/properties/faucet/properties/name_or_address",
|
|
126
|
+
"description": "Sender account name or address. Use empty string '' for the default account."
|
|
127
|
+
},
|
|
128
|
+
"name_or_address_to": {
|
|
129
|
+
"$ref": "#/definitions/account_operation/properties/faucet/properties/name_or_address",
|
|
130
|
+
"description": "Recipient account name or address. Use empty string '' for the default account."
|
|
131
|
+
},
|
|
132
|
+
"amount": {
|
|
133
|
+
"type": [
|
|
134
|
+
"number",
|
|
135
|
+
"string"
|
|
136
|
+
],
|
|
137
|
+
"description": "Amount of tokens to transfer"
|
|
138
|
+
},
|
|
139
|
+
"token_type": {
|
|
140
|
+
"type": "string",
|
|
141
|
+
"description": "Token type; default token type is 0x2::wow::WOW"
|
|
142
|
+
},
|
|
143
|
+
"network": {
|
|
144
|
+
"type": "string",
|
|
145
|
+
"enum": [
|
|
146
|
+
"localnet",
|
|
147
|
+
"testnet"
|
|
148
|
+
],
|
|
149
|
+
"description": "Network entrypoint: Specifies which network the operation occurs on"
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
"required": [
|
|
153
|
+
"amount"
|
|
154
|
+
],
|
|
155
|
+
"additionalProperties": false,
|
|
156
|
+
"description": "Transfer tokens from one account to another"
|
|
157
|
+
},
|
|
158
|
+
"get": {
|
|
159
|
+
"type": "object",
|
|
160
|
+
"properties": {
|
|
161
|
+
"name_or_address": {
|
|
162
|
+
"$ref": "#/definitions/account_operation/properties/faucet/properties/name_or_address",
|
|
163
|
+
"description": "Account name or address. Use empty string '' for the default account."
|
|
164
|
+
},
|
|
165
|
+
"balance_required": {
|
|
166
|
+
"type": [
|
|
167
|
+
"string",
|
|
168
|
+
"number"
|
|
169
|
+
],
|
|
170
|
+
"description": "Required balance amount"
|
|
171
|
+
},
|
|
172
|
+
"token_type": {
|
|
173
|
+
"type": "string",
|
|
174
|
+
"description": "Token type; default token type is 0x2::wow::WOW"
|
|
175
|
+
},
|
|
176
|
+
"network": {
|
|
177
|
+
"$ref": "#/definitions/account_operation/properties/transfer/properties/network",
|
|
178
|
+
"description": "Network entrypoint: Specifies which network the operation occurs on"
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
"required": [
|
|
182
|
+
"balance_required"
|
|
183
|
+
],
|
|
184
|
+
"additionalProperties": false,
|
|
185
|
+
"description": "Generate new coin object ID from account by required amount and return"
|
|
186
|
+
},
|
|
187
|
+
"signData": {
|
|
188
|
+
"type": "object",
|
|
189
|
+
"properties": {
|
|
190
|
+
"name_or_address": {
|
|
191
|
+
"$ref": "#/definitions/account_operation/properties/faucet/properties/name_or_address",
|
|
192
|
+
"description": "Account name or address. Use empty string '' for the default account."
|
|
193
|
+
},
|
|
194
|
+
"data": {
|
|
195
|
+
"type": "string",
|
|
196
|
+
"description": "Data to sign. If data_encoding is not specified, treated as UTF-8 string."
|
|
197
|
+
},
|
|
198
|
+
"data_encoding": {
|
|
199
|
+
"anyOf": [
|
|
200
|
+
{
|
|
201
|
+
"type": "string",
|
|
202
|
+
"const": "utf8",
|
|
203
|
+
"description": "Data is UTF-8 encoded string"
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"type": "string",
|
|
207
|
+
"const": "base64",
|
|
208
|
+
"description": "Data is base64 encoded bytes"
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"type": "string",
|
|
212
|
+
"const": "hex",
|
|
213
|
+
"description": "Data is hex encoded bytes (with or without 0x prefix)"
|
|
214
|
+
}
|
|
215
|
+
],
|
|
216
|
+
"description": "Encoding format of the data field. If not specified, defaults to utf8."
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
"required": [
|
|
220
|
+
"data"
|
|
221
|
+
],
|
|
222
|
+
"additionalProperties": false,
|
|
223
|
+
"description": "Sign data with account's private key"
|
|
224
|
+
},
|
|
225
|
+
"messenger": {
|
|
226
|
+
"type": "object",
|
|
227
|
+
"properties": {
|
|
228
|
+
"name_or_account": {
|
|
229
|
+
"$ref": "#/definitions/account_operation/properties/faucet/properties/name_or_address",
|
|
230
|
+
"description": "Account name or address. Use empty string '' for the default account. Defaults to '' if omitted."
|
|
231
|
+
},
|
|
232
|
+
"m": {
|
|
233
|
+
"anyOf": [
|
|
234
|
+
{
|
|
235
|
+
"$ref": "#/definitions/account_operation/properties/gen/properties/name"
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
"type": "null"
|
|
239
|
+
}
|
|
240
|
+
],
|
|
241
|
+
"description": "Messenger name to enable messenger for this account (max 64 characters). If null, disable messenger."
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
"required": [
|
|
245
|
+
"m"
|
|
246
|
+
],
|
|
247
|
+
"additionalProperties": false,
|
|
248
|
+
"description": "Enable or disable messenger for an account"
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
"additionalProperties": false,
|
|
252
|
+
"description": "Account operations"
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|