@wowok/agent-mcp 2.2.13 → 2.2.15
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 +19 -11
- package/dist/index.js +44 -100
- package/dist/schema/query/index.js +1 -1
- 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/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/README.md
CHANGED
|
@@ -39,18 +39,26 @@ Skills provide structured guidance for AI assistants:
|
|
|
39
39
|
- **Tool usage failures** — Correct parameter formats, tool selection, error recovery
|
|
40
40
|
- **Safety & authorization** — User confirmation for important operations
|
|
41
41
|
|
|
42
|
-
#### Available Skills
|
|
43
|
-
|
|
44
|
-
| Skill | Purpose |
|
|
45
|
-
|
|
46
|
-
| `wowok-
|
|
47
|
-
| `wowok-
|
|
48
|
-
| `wowok-
|
|
49
|
-
| `wowok-
|
|
50
|
-
| `wowok-
|
|
51
|
-
| `wowok-
|
|
42
|
+
#### Available Skills (Organized by Role)
|
|
43
|
+
|
|
44
|
+
| Skill | Role | Purpose |
|
|
45
|
+
|-------|------|---------|
|
|
46
|
+
| `wowok-order` | 👤 Customer | Order lifecycle — place orders, track progress, submit disputes, claim compensation |
|
|
47
|
+
| `wowok-provider` | 🏪 Provider | Service provider guide — create Service, design Machine, configure Allocators |
|
|
48
|
+
| `wowok-machine` | 🏪 Provider | Workflow design — state machines, node definitions, progress tracking |
|
|
49
|
+
| `wowok-arbitrator` | ⚖️ Arbitrator | Arbitration service — dispute resolution, voting organization, fee management |
|
|
50
|
+
| `wowok-guard` | 🛠️ Shared | Guard design mastery — programmable trust rules, multi-signature authorization |
|
|
51
|
+
| `wowok-tools` | 🛠️ Shared | MCP tool usage mastery — 13+ tools, parameter formats, schema references |
|
|
52
|
+
| `wowok-safety` | 🛠️ Shared | Safety protocol — dry-run validation, user confirmation checkpoints |
|
|
53
|
+
|
|
54
|
+
#### Role-Based Skill Selection
|
|
55
|
+
|
|
56
|
+
- **Use `wowok-order`** when user acts as a customer/buyer placing orders
|
|
57
|
+
- **Use `wowok-provider`** + `wowok-machine` when user is a merchant/service provider
|
|
58
|
+
- **Use `wowok-arbitrator`** when user operates dispute resolution services
|
|
59
|
+
- **Use `wowok-tools`** + `wowok-safety`** (always loaded) for all roles
|
|
60
|
+
- **Use `wowok-guard`** when designing complex validation rules
|
|
52
61
|
|
|
53
62
|
#### Using Skills
|
|
54
63
|
|
|
55
64
|
Once installed, Claude Code will automatically use these skills when working with WoWok tools.
|
|
56
|
-
|
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
|
|
@@ -89,7 +89,7 @@ Token amounts are HIGHLY SENSITIVE. Always:
|
|
|
89
89
|
| Send encrypted file via messenger | messenger_operation (send_file) | wip_file |
|
|
90
90
|
| Generate witness timestamp (WTS) | messenger_operation (generate_wts) | wip_file |
|
|
91
91
|
| Query protocol constants | wowok_buildin_info | query_toolkit |
|
|
92
|
-
|
|
|
92
|
+
| Query tool schemas | schema_query | wowok_buildin_info |
|
|
93
93
|
|
|
94
94
|
## Local vs On-chain Operations
|
|
95
95
|
|
|
@@ -107,7 +107,7 @@ Token amounts are HIGHLY SENSITIVE. Always:
|
|
|
107
107
|
- query_toolkit
|
|
108
108
|
- onchain_events
|
|
109
109
|
- wowok_buildin_info
|
|
110
|
-
-
|
|
110
|
+
- schema_query
|
|
111
111
|
- guard2file
|
|
112
112
|
- machineNode2file
|
|
113
113
|
`;
|
|
@@ -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;
|
|
@@ -117,7 +117,7 @@ export const ObjectOrderSchema = ObjectBaseSchema.extend({
|
|
|
117
117
|
amount: BalanceTypeSchema.describe("Order amount"),
|
|
118
118
|
builder: z.string().describe("Purchaser ID"),
|
|
119
119
|
service: z.string().describe("Service ID"),
|
|
120
|
-
dispute: z.array(z.string()).describe("
|
|
120
|
+
dispute: z.array(z.string()).describe("Arb object ID list. When unsatisfied with order delivery, dispute objects can be created."),
|
|
121
121
|
agent: z.array(z.string()).describe("Agent ID list. Agents handle all order operations except payment collection."),
|
|
122
122
|
allocation: z.union([z.string(), z.null()]).describe("Order amount allocation object ID"),
|
|
123
123
|
claimed_by: z.union([z.string(), z.null()]).describe("Order dispute object ID that has claimed order arbitration amount."),
|
|
@@ -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
|
+
}
|