@wowok/agent-mcp 2.3.18 → 2.4.3
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/customer/industry-risks.js +31 -31
- package/dist/customer/order-monitor.js +57 -57
- package/dist/customer/order-strategy.js +89 -89
- package/dist/customer/post-purchase.js +97 -97
- package/dist/customer/reminder-system.js +26 -26
- package/dist/customer/risk-assessment.js +46 -46
- package/dist/customer/types.d.ts +4 -4
- package/dist/customer/types.js +4 -4
- package/dist/customer/user-preferences.js +50 -50
- package/dist/experience/intent-distill.js +6 -6
- package/dist/index.d.ts +2 -2
- package/dist/index.js +11 -1624
- package/dist/knowledge/acquisition-flywheel.js +64 -64
- package/dist/knowledge/arbitration-trust.js +10 -10
- package/dist/knowledge/demand-matching.js +8 -8
- package/dist/knowledge/dynamic-pricing.js +18 -18
- package/dist/knowledge/flywheel-loop.js +11 -11
- package/dist/knowledge/glossary.js +22 -22
- package/dist/knowledge/guard-ledger.d.ts +1 -1
- package/dist/knowledge/guard-ledger.js +145 -104
- package/dist/knowledge/guard-lint.d.ts +77 -0
- package/dist/knowledge/guard-lint.js +670 -0
- package/dist/knowledge/guard-migration.d.ts +48 -0
- package/dist/knowledge/guard-migration.js +228 -0
- package/dist/knowledge/guard-puzzle.d.ts +109 -14
- package/dist/knowledge/guard-puzzle.js +627 -101
- package/dist/knowledge/guard-risk.d.ts +10 -1
- package/dist/knowledge/guard-risk.js +1634 -292
- package/dist/knowledge/guard-templates.d.ts +38 -0
- package/dist/knowledge/guard-templates.js +605 -0
- package/dist/knowledge/guard-translation.d.ts +14 -2
- package/dist/knowledge/guard-translation.js +825 -194
- package/dist/knowledge/index.d.ts +8 -4
- package/dist/knowledge/index.js +9 -5
- package/dist/knowledge/industry-evolution.js +29 -29
- package/dist/knowledge/industry-generalizer.js +52 -52
- package/dist/knowledge/industry-registry.js +20 -33
- package/dist/knowledge/intent-metrics.js +67 -67
- package/dist/knowledge/process-model.js +80 -80
- package/dist/knowledge/reputation-rules.js +9 -9
- package/dist/knowledge/reward-templates.js +51 -51
- package/dist/knowledge/safety-rules.js +3 -3
- package/dist/knowledge/tool-constraints.js +20 -4
- package/dist/knowledge/trust-metrics.js +26 -26
- package/dist/project/graph.d.ts +1 -0
- package/dist/project/graph.js +27 -1
- package/dist/project/index.d.ts +1 -0
- package/dist/project/index.js +39 -2
- package/dist/project/namespace.d.ts +11 -1
- package/dist/project/namespace.js +27 -2
- package/dist/project/query.d.ts +2 -0
- package/dist/project/query.js +56 -15
- package/dist/rules.d.ts +12 -0
- package/dist/rules.js +9 -0
- package/dist/schema/call/allocation.d.ts +10 -10
- package/dist/schema/call/base.js +19 -19
- package/dist/schema/call/bridge.d.ts +32 -32
- package/dist/schema/call/demand.d.ts +84 -84
- package/dist/schema/call/guard.d.ts +153 -0
- package/dist/schema/call/guard.js +50 -0
- package/dist/schema/call/machine.d.ts +38 -38
- package/dist/schema/call/permission.d.ts +78 -78
- package/dist/schema/call/repository.d.ts +22 -22
- package/dist/schema/call/semantic.js +229 -25
- package/dist/schema/call/service.d.ts +7 -7
- package/dist/schema/local/wip.d.ts +39 -19
- package/dist/schema/local/wip.js +5 -5
- package/dist/schema/messenger/index.d.ts +26 -26
- package/dist/schema/messenger/index.js +2 -2
- package/dist/schema/operations.d.ts +270 -192
- package/dist/schema/query/index.d.ts +184 -184
- package/dist/schema/query/index.js +15 -9
- package/dist/schema/trust/index.d.ts +4 -4
- package/dist/schema/utils/guard-parser.js +4 -4
- package/dist/schema/utils/guard-query-utils.d.ts +7 -0
- package/dist/schema/utils/guard-query-utils.js +14 -1
- package/dist/schema/utils/node-parser.js +14 -14
- package/dist/schemas/bridge_operation.output.json +15 -15
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/messenger_operation.output.json +18 -16
- package/dist/schemas/onchain_events.output.json +15 -15
- package/dist/schemas/onchain_operations.output.json +16 -16
- package/dist/schemas/onchain_operations.schema.json +11 -20
- package/dist/schemas/onchain_operations_allocation.schema.json +7 -10
- package/dist/schemas/onchain_operations_machine.schema.json +2 -5
- package/dist/schemas/onchain_operations_service.schema.json +2 -5
- package/dist/schemas/onchain_table_data.output.json +20 -26
- package/dist/schemas/wip_file.output.json +24 -1
- package/dist/tools/handlers/bridge.d.ts +1 -0
- package/dist/tools/handlers/bridge.js +1 -0
- package/dist/tools/handlers/config.d.ts +2 -0
- package/dist/tools/handlers/config.js +71 -0
- package/dist/tools/handlers/file-export.d.ts +3 -0
- package/dist/tools/handlers/file-export.js +90 -0
- package/dist/tools/handlers/local.d.ts +30 -0
- package/dist/tools/handlers/local.js +27 -0
- package/dist/tools/handlers/messenger.d.ts +16 -0
- package/dist/tools/handlers/messenger.js +187 -0
- package/dist/tools/handlers/onchain.d.ts +2 -0
- package/dist/tools/handlers/onchain.js +246 -0
- package/dist/tools/handlers/project.d.ts +2 -0
- package/dist/tools/handlers/project.js +53 -0
- package/dist/tools/handlers/query.d.ts +5 -0
- package/dist/tools/handlers/query.js +256 -0
- package/dist/tools/handlers/schema-query.d.ts +2 -0
- package/dist/tools/handlers/schema-query.js +92 -0
- package/dist/tools/handlers/trust.d.ts +2 -0
- package/dist/tools/handlers/trust.js +194 -0
- package/dist/tools/handlers/wip.d.ts +2 -0
- package/dist/tools/handlers/wip.js +44 -0
- package/dist/tools/index.d.ts +13 -0
- package/dist/tools/index.js +479 -0
- package/dist/tools/rules-hook.d.ts +2 -0
- package/dist/tools/rules-hook.js +22 -0
- package/dist/tools/shared.d.ts +29 -0
- package/dist/tools/shared.js +130 -0
- package/dist/tools/types.d.ts +35 -0
- package/dist/tools/types.js +1 -0
- package/dist/tools/wrap.d.ts +6 -0
- package/dist/tools/wrap.js +55 -0
- package/package.json +19 -5
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { strictParse, TrustScoreInputSchema, } from "../../schema/index.js";
|
|
2
|
+
import { query_objects, } from "@wowok/wowok";
|
|
3
|
+
import { computeServiceTrustScore, } from "../../knowledge/index.js";
|
|
4
|
+
import { assembleInfoPuzzle, assessRisk, } from "../../customer/index.js";
|
|
5
|
+
function extractTrustMetrics(serviceObj) {
|
|
6
|
+
const data = serviceObj?.data ?? serviceObj ?? {};
|
|
7
|
+
const sales = Array.isArray(data.sales) ? data.sales : [];
|
|
8
|
+
const activeSales = sales.filter((s) => s && !s.suspension);
|
|
9
|
+
void activeSales;
|
|
10
|
+
const compensationFund = data.compensation_fund;
|
|
11
|
+
const compBalance = (() => {
|
|
12
|
+
if (compensationFund === null || compensationFund === undefined)
|
|
13
|
+
return undefined;
|
|
14
|
+
if (typeof compensationFund === "bigint")
|
|
15
|
+
return compensationFund;
|
|
16
|
+
if (typeof compensationFund === "number")
|
|
17
|
+
return BigInt(compensationFund);
|
|
18
|
+
if (typeof compensationFund === "string") {
|
|
19
|
+
try {
|
|
20
|
+
return BigInt(compensationFund);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (typeof compensationFund === "object") {
|
|
27
|
+
const bal = compensationFund.balance;
|
|
28
|
+
if (bal === null || bal === undefined)
|
|
29
|
+
return undefined;
|
|
30
|
+
try {
|
|
31
|
+
return BigInt(bal);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return undefined;
|
|
38
|
+
})();
|
|
39
|
+
return {
|
|
40
|
+
arbitrationCases: Array.isArray(data.arbitrations) ? data.arbitrations.length : undefined,
|
|
41
|
+
compensationFundBalance: compBalance,
|
|
42
|
+
hasMachineBound: typeof data.machine === "string" && data.machine.length > 0,
|
|
43
|
+
hasBuyGuard: typeof data.buy_guard === "string" && data.buy_guard.length > 0,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function buildPuzzleRawData(serviceObj, orderAmount, trustScore, serviceOwner) {
|
|
47
|
+
const data = serviceObj?.data ?? serviceObj ?? {};
|
|
48
|
+
const sales = Array.isArray(data.sales) ? data.sales : [];
|
|
49
|
+
const order_allocators = data.order_allocators
|
|
50
|
+
? Array.isArray(data.order_allocators.allocators)
|
|
51
|
+
? data.order_allocators
|
|
52
|
+
: { allocators: data.order_allocators }
|
|
53
|
+
: undefined;
|
|
54
|
+
const serviceRaw = {
|
|
55
|
+
name: data.name ?? serviceObj?.id,
|
|
56
|
+
bPublished: data.bPublished,
|
|
57
|
+
bPaused: data.bPaused,
|
|
58
|
+
price: sales[0]?.price != null ? String(sales[0].price) : "0",
|
|
59
|
+
priceRaw: sales[0]?.price != null ? BigInt(sales[0].price) : 0n,
|
|
60
|
+
token_type: sales[0]?.price_type ?? (compensation_fund_token(data) ?? "0x2::wow::WOW"),
|
|
61
|
+
sales,
|
|
62
|
+
machine: data.machine ?? undefined,
|
|
63
|
+
buy_guard: data.buy_guard ?? undefined,
|
|
64
|
+
customer_required: data.customer_required,
|
|
65
|
+
arbitrations: data.arbitrations,
|
|
66
|
+
compensation_fund: data.compensation_fund
|
|
67
|
+
? { balance: extractBalance(data.compensation_fund) }
|
|
68
|
+
: undefined,
|
|
69
|
+
compensation_lock_duration: typeof data.setting_lock_duration === "number"
|
|
70
|
+
? data.setting_lock_duration
|
|
71
|
+
: undefined,
|
|
72
|
+
um: data.um ?? undefined,
|
|
73
|
+
order_allocators: order_allocators ? [order_allocators] : undefined,
|
|
74
|
+
};
|
|
75
|
+
return {
|
|
76
|
+
service: serviceRaw,
|
|
77
|
+
order_amount: orderAmount,
|
|
78
|
+
trust_score: trustScore,
|
|
79
|
+
service_owner: serviceOwner,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function compensation_fund_token(data) {
|
|
83
|
+
if (data?.compensation_fund && typeof data.compensation_fund === "object") {
|
|
84
|
+
return data.compensation_fund.token_type;
|
|
85
|
+
}
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
function extractBalance(b) {
|
|
89
|
+
if (b === null || b === undefined)
|
|
90
|
+
return 0n;
|
|
91
|
+
if (typeof b === "bigint")
|
|
92
|
+
return b;
|
|
93
|
+
if (typeof b === "number")
|
|
94
|
+
return BigInt(b);
|
|
95
|
+
if (typeof b === "string") {
|
|
96
|
+
try {
|
|
97
|
+
return BigInt(b);
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
return 0n;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (typeof b === "object") {
|
|
104
|
+
const bal = b.balance;
|
|
105
|
+
if (bal === null || bal === undefined)
|
|
106
|
+
return 0n;
|
|
107
|
+
try {
|
|
108
|
+
return BigInt(bal);
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
return 0n;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return 0n;
|
|
115
|
+
}
|
|
116
|
+
export async function handleTrustScore(args) {
|
|
117
|
+
const validated = strictParse(TrustScoreInputSchema, args, "trust_score input");
|
|
118
|
+
const depth = (validated.depth ?? "evaluate");
|
|
119
|
+
const queryResult = await query_objects({
|
|
120
|
+
objects: [validated.service],
|
|
121
|
+
no_cache: validated.no_cache,
|
|
122
|
+
network: validated.network,
|
|
123
|
+
});
|
|
124
|
+
const objects = queryResult?.objects;
|
|
125
|
+
if (!objects || !Array.isArray(objects) || objects.length === 0) {
|
|
126
|
+
throw new Error(`Service object not found for '${validated.service}'. ` +
|
|
127
|
+
`Verify the ID/name and network, or use query_toolkit with query_type='onchain_objects' to debug.`);
|
|
128
|
+
}
|
|
129
|
+
const serviceObj = objects[0];
|
|
130
|
+
const objType = serviceObj?.data?.object_type ?? serviceObj?.object_type ?? serviceObj?.type;
|
|
131
|
+
if (objType && typeof objType === "string" && !objType.includes("Service")) {
|
|
132
|
+
throw new Error(`Object '${validated.service}' is not a Service (type: ${objType}). ` +
|
|
133
|
+
`trust_score only evaluates Service objects.`);
|
|
134
|
+
}
|
|
135
|
+
const metrics = extractTrustMetrics(serviceObj);
|
|
136
|
+
const trustScore = computeServiceTrustScore(metrics);
|
|
137
|
+
const sales = Array.isArray(serviceObj?.data?.sales) ? serviceObj.data.sales : [];
|
|
138
|
+
const activeSale = sales.find((s) => s && !s.suspension) ?? sales[0];
|
|
139
|
+
const salePriceRaw = activeSale?.price != null ? BigInt(activeSale.price) : 0n;
|
|
140
|
+
const orderAmount = validated.order_amount != null
|
|
141
|
+
? BigInt(validated.order_amount)
|
|
142
|
+
: salePriceRaw;
|
|
143
|
+
let riskScore = undefined;
|
|
144
|
+
let infoPuzzle = undefined;
|
|
145
|
+
if (depth === "evaluate" || depth === "preorder") {
|
|
146
|
+
const puzzleRaw = buildPuzzleRawData(serviceObj, orderAmount, { score: trustScore.score, level: trustScore.level }, undefined);
|
|
147
|
+
infoPuzzle = assembleInfoPuzzle(validated.service, puzzleRaw, depth);
|
|
148
|
+
riskScore = assessRisk(infoPuzzle);
|
|
149
|
+
}
|
|
150
|
+
const result = {
|
|
151
|
+
service_id: validated.service,
|
|
152
|
+
service_name: serviceObj?.data?.name ?? serviceObj?.name ?? validated.service,
|
|
153
|
+
service_basics: {
|
|
154
|
+
bPublished: serviceObj?.data?.bPublished ?? false,
|
|
155
|
+
bPaused: serviceObj?.data?.bPaused ?? false,
|
|
156
|
+
sales_count: sales.filter((s) => s && !s.suspension).length,
|
|
157
|
+
has_machine: !!serviceObj?.data?.machine,
|
|
158
|
+
has_buy_guard: !!serviceObj?.data?.buy_guard,
|
|
159
|
+
has_um_contact: !!serviceObj?.data?.um,
|
|
160
|
+
arbitrations_count: Array.isArray(serviceObj?.data?.arbitrations)
|
|
161
|
+
? serviceObj.data.arbitrations.length
|
|
162
|
+
: 0,
|
|
163
|
+
},
|
|
164
|
+
trust_score: {
|
|
165
|
+
score: trustScore.score,
|
|
166
|
+
level: trustScore.level,
|
|
167
|
+
summary: trustScore.summary,
|
|
168
|
+
warnings: trustScore.warnings,
|
|
169
|
+
breakdown: trustScore.breakdown,
|
|
170
|
+
},
|
|
171
|
+
order_amount: orderAmount.toString(),
|
|
172
|
+
depth,
|
|
173
|
+
...(riskScore ? {
|
|
174
|
+
risk_score: {
|
|
175
|
+
total: riskScore.total,
|
|
176
|
+
level: riskScore.level,
|
|
177
|
+
red_flags: riskScore.red_flags,
|
|
178
|
+
advice: riskScore.advice,
|
|
179
|
+
dimensions: riskScore.dimensions,
|
|
180
|
+
},
|
|
181
|
+
} : {}),
|
|
182
|
+
...(infoPuzzle ? {
|
|
183
|
+
info_puzzle: {
|
|
184
|
+
completeness: infoPuzzle.completeness,
|
|
185
|
+
gaps: infoPuzzle.gaps,
|
|
186
|
+
assembled_at: infoPuzzle.assembled_at,
|
|
187
|
+
},
|
|
188
|
+
} : {}),
|
|
189
|
+
};
|
|
190
|
+
return {
|
|
191
|
+
content: [{ type: "text", text: JSON.stringify({ result }) }],
|
|
192
|
+
structuredContent: { result },
|
|
193
|
+
};
|
|
194
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { strictParse, WipOperationsSchema, } from "../../schema/index.js";
|
|
2
|
+
import { generate_wip, verify_wip, sign_wip, wip2html, } from "@wowok/wowok";
|
|
3
|
+
export async function handleWipOperations(args) {
|
|
4
|
+
const validated = strictParse(WipOperationsSchema, args, "wip_file input");
|
|
5
|
+
let structuredContent;
|
|
6
|
+
switch (validated.type) {
|
|
7
|
+
case "generate": {
|
|
8
|
+
const result = await generate_wip(validated.options, validated.outputPath);
|
|
9
|
+
structuredContent = { result: { type: "generate", filePath: result } };
|
|
10
|
+
break;
|
|
11
|
+
}
|
|
12
|
+
case "verify": {
|
|
13
|
+
const result = await verify_wip(validated.wipFilePath, validated.hash_equal, validated.requireSignature);
|
|
14
|
+
structuredContent = { result: { type: "verify", ...result } };
|
|
15
|
+
break;
|
|
16
|
+
}
|
|
17
|
+
case "sign": {
|
|
18
|
+
const result = await sign_wip(validated.wipFilePath, validated.account, validated.outputPath);
|
|
19
|
+
structuredContent = { result: { type: "sign", filePath: result } };
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
case "wip2html": {
|
|
23
|
+
const result = await wip2html(validated.wipPath, validated.options);
|
|
24
|
+
let output = { type: "wip2html" };
|
|
25
|
+
if (typeof result === "string") {
|
|
26
|
+
output.html = result;
|
|
27
|
+
}
|
|
28
|
+
else if (Array.isArray(result)) {
|
|
29
|
+
output.files = result;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
output.html = String(result);
|
|
33
|
+
}
|
|
34
|
+
structuredContent = { result: output };
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
default:
|
|
38
|
+
throw new Error("Unknown WIP operation type");
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
content: [{ type: "text", text: JSON.stringify(structuredContent) }],
|
|
42
|
+
structuredContent,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import type { ToolEntry, ToolDispatchResult, DispatchOptions } from "./types.js";
|
|
3
|
+
export declare const TOOL_REGISTRY: ToolEntry[];
|
|
4
|
+
export declare const TOOL_REGISTRY_MAP: Map<string, ToolEntry>;
|
|
5
|
+
export declare function dispatchToolCall(name: string, args: any, options?: DispatchOptions): Promise<ToolDispatchResult>;
|
|
6
|
+
export interface ToolListEntry {
|
|
7
|
+
name: string;
|
|
8
|
+
title: string;
|
|
9
|
+
description: string;
|
|
10
|
+
inputSchema: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
export declare function listTools(): ToolListEntry[];
|
|
13
|
+
export declare function registerAllTools(server: McpServer): void;
|