@wowok/agent-mcp 2.6.3 → 2.6.6
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 +13 -9
- package/dist/customer/customer-advice.d.ts +31 -0
- package/dist/customer/customer-advice.js +129 -0
- package/dist/customer/index.d.ts +2 -0
- package/dist/customer/index.js +2 -0
- package/dist/customer/info-puzzle.d.ts +8 -1
- package/dist/customer/info-puzzle.js +30 -5
- package/dist/customer/order-monitor.d.ts +2 -0
- package/dist/customer/order-monitor.js +3 -2
- package/dist/customer/post-purchase.d.ts +2 -0
- package/dist/customer/post-purchase.js +6 -5
- package/dist/customer/preorder-compare.d.ts +24 -0
- package/dist/customer/preorder-compare.js +34 -0
- package/dist/customer/reminder-system.d.ts +2 -0
- package/dist/customer/reminder-system.js +2 -1
- package/dist/customer/risk-assessment.js +4 -3
- package/dist/customer/types.d.ts +5 -0
- package/dist/examples/arbitration-dispute-create.json +41 -0
- package/dist/examples/arbitration-vote-weighted.json +35 -0
- package/dist/examples/arbitration-voting-guard-add.json +38 -0
- package/dist/examples/demand-present-service.json +33 -0
- package/dist/examples/gen-passport-verify-guard.json +48 -0
- package/dist/examples/guard-template-balance-check.json +36 -15
- package/dist/examples/guard-template-time-lock.json +33 -12
- package/dist/examples/insurance-guard-claim-timelock.json +75 -0
- package/dist/examples/insurance-guard-withdraw-allocation.json +96 -0
- package/dist/examples/insurance-machine-create-publish.json +75 -0
- package/dist/examples/insurance-service-allocators-publish.json +56 -0
- package/dist/examples/machine-multisig-threshold.json +86 -0
- package/dist/examples/machine-template-7node-rental.json +99 -94
- package/dist/examples/payment-scenario-bound.json +45 -0
- package/dist/examples/rental-ziroom-machine-create.json +126 -114
- package/dist/examples/rental-ziroom-permission-create.json +10 -3
- package/dist/examples/rental-ziroom-service-create.json +27 -18
- package/dist/examples/retail-adv-guard-customer-win-create.json +80 -0
- package/dist/examples/retail-adv-guard-messenger-proof-create.json +65 -0
- package/dist/examples/retail-adv-guard-reward-timeout-create.json +92 -0
- package/dist/examples/retail-adv-reward-guard-add.json +51 -0
- package/dist/examples/retail-myshop-allocation-activate.json +55 -0
- package/dist/examples/retail-myshop-arbitration-create.json +40 -0
- package/dist/examples/retail-myshop-contact-create.json +43 -0
- package/dist/examples/retail-myshop-order-create.json +56 -0
- package/dist/examples/retail-myshop-progress-operate.json +38 -0
- package/dist/examples/retail-myshop-reward-create.json +35 -0
- package/dist/examples/service-discount-issue.json +46 -0
- package/dist/examples/threebody-guard-create.json +56 -0
- package/dist/examples/threebody-machine-create.json +72 -0
- package/dist/examples/threebody-permission-create.json +38 -0
- package/dist/examples/threebody-service-allocators.json +49 -0
- package/dist/examples/travel-guard-time-lock.json +69 -0
- package/dist/examples/travel-guard-weather-oracle.json +70 -0
- package/dist/examples/travel-machine-create.json +136 -0
- package/dist/examples/travel-repository-create.json +47 -0
- package/dist/examples/travel-service-create.json +102 -0
- package/dist/examples/travel-treasury-create.json +34 -0
- package/dist/examples/treasury-deposit.json +37 -0
- package/dist/examples/treasury-withdraw.json +38 -0
- package/dist/extensions/business-modules.d.ts +49 -0
- package/dist/extensions/business-modules.js +287 -0
- package/dist/extensions/capability-manifest.js +192 -5
- package/dist/extensions/constraint-registry.js +3 -1
- package/dist/extensions/modes.js +10 -4
- package/dist/extensions/registry.d.ts +14 -9
- package/dist/extensions/registry.js +69 -14
- package/dist/extensions/types.d.ts +1 -0
- package/dist/knowledge/fund-layer.d.ts +67 -1
- package/dist/knowledge/fund-layer.js +561 -12
- package/dist/knowledge/guard-templates.d.ts +10 -0
- package/dist/knowledge/guard-templates.js +50 -0
- package/dist/knowledge/index.d.ts +2 -2
- package/dist/knowledge/index.js +2 -2
- package/dist/knowledge/machine-risk.js +4 -1
- package/dist/knowledge/progress-context.js +1 -1
- package/dist/knowledge/progress-ledger.js +3 -3
- package/dist/knowledge/progress-templates.js +1 -1
- package/dist/knowledge/progress-translation.js +1 -1
- package/dist/knowledge/safety-rules.d.ts +83 -1
- package/dist/knowledge/safety-rules.js +166 -2
- package/dist/knowledge/scenario-modes.d.ts +1 -1
- package/dist/knowledge/scenario-modes.js +13 -11
- package/dist/knowledge/template-registry.d.ts +48 -0
- package/dist/knowledge/template-registry.js +341 -0
- package/dist/knowledge/tool-constraints.js +6 -6
- package/dist/knowledge/tools-reference.js +11 -8
- package/dist/participation/merchant-interest.d.ts +32 -0
- package/dist/participation/merchant-interest.js +100 -0
- package/dist/participation/radar-core.d.ts +104 -0
- package/dist/participation/radar-core.js +269 -0
- package/dist/project/context-assembly.js +8 -0
- package/dist/project/edit-planner.js +27 -56
- package/dist/project/evaluation.d.ts +36 -0
- package/dist/project/evaluation.js +422 -56
- package/dist/project/game-theory.d.ts +43 -0
- package/dist/project/game-theory.js +177 -0
- package/dist/project/graph-builder.js +1 -0
- package/dist/project/handlers.d.ts +38 -0
- package/dist/project/handlers.js +65 -35
- package/dist/project/intent-analyzer.d.ts +71 -0
- package/dist/project/intent-analyzer.js +149 -0
- package/dist/project/machine-nodes.d.ts +2 -0
- package/dist/project/machine-nodes.js +36 -0
- package/dist/project/merchant-guide.d.ts +165 -0
- package/dist/project/merchant-guide.js +264 -0
- package/dist/project/mode-actions.d.ts +199 -0
- package/dist/project/mode-actions.js +309 -0
- package/dist/project/participation-radar.d.ts +18 -0
- package/dist/project/participation-radar.js +428 -0
- package/dist/project/pipeline-actions.d.ts +101 -0
- package/dist/project/pipeline-actions.js +109 -0
- package/dist/project/semantic-graph.d.ts +95 -0
- package/dist/project/semantic-graph.js +245 -0
- package/dist/schema/call/allocation.d.ts +11 -11
- package/dist/schema/call/allocation.js +11 -1
- package/dist/schema/call/arbitration.d.ts +21 -21
- package/dist/schema/call/arbitration.js +17 -9
- package/dist/schema/call/base.d.ts +2 -2
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/bridge.d.ts +127 -127
- package/dist/schema/call/bridge.js +12 -12
- package/dist/schema/call/contact.d.ts +3 -3
- package/dist/schema/call/demand.d.ts +3 -3
- package/dist/schema/call/guard.d.ts +11 -11
- package/dist/schema/call/guard.js +1 -1
- package/dist/schema/call/machine.d.ts +216 -21
- package/dist/schema/call/machine.js +1 -1
- package/dist/schema/call/order.d.ts +7 -7
- package/dist/schema/call/payment.d.ts +3 -3
- package/dist/schema/call/permission.d.ts +3 -3
- package/dist/schema/call/personal.d.ts +337 -3
- package/dist/schema/call/personal.js +10 -0
- package/dist/schema/call/progress.d.ts +177 -9
- package/dist/schema/call/progress.js +7 -3
- package/dist/schema/call/proof.d.ts +6 -6
- package/dist/schema/call/repository.d.ts +3 -3
- package/dist/schema/call/reward.d.ts +57 -57
- package/dist/schema/call/semantic.js +41 -1
- package/dist/schema/call/service.d.ts +114 -114
- package/dist/schema/call/service.js +11 -2
- package/dist/schema/call/treasury.d.ts +57 -57
- package/dist/schema/messenger/index.js +4 -1
- package/dist/schema/operations.d.ts +713 -291
- package/dist/schema/operations.js +33 -0
- package/dist/schema/project/index.d.ts +4635 -100
- package/dist/schema/project/index.js +868 -1
- package/dist/schema/query/index.d.ts +363 -19
- package/dist/schema/query/index.js +25 -3
- package/dist/schema/schema-query/index.d.ts +13 -7
- package/dist/schema/schema-query/index.js +29 -5
- package/dist/schema/trust/index.d.ts +1012 -6
- package/dist/schema/trust/index.js +212 -11
- package/dist/schema/utils/skills-recommendation.js +1 -0
- package/dist/schema-query/index.d.ts +4 -1
- package/dist/schema-query/index.js +255 -1
- package/dist/schemas/bridge_operation.schema.json +14 -7
- package/dist/schemas/guard2file.schema.json +2 -0
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/machineNode2file.schema.json +2 -0
- package/dist/schemas/messenger_operation.schema.json +1 -1
- package/dist/schemas/onchain_operations.schema.json +143 -15
- package/dist/schemas/onchain_operations_allocation.schema.json +2 -1
- package/dist/schemas/onchain_operations_arbitration.schema.json +7 -5
- package/dist/schemas/onchain_operations_contact.schema.json +1 -0
- package/dist/schemas/onchain_operations_demand.schema.json +1 -0
- package/dist/schemas/onchain_operations_gen_passport.schema.json +2 -0
- package/dist/schemas/onchain_operations_gen_proof.schema.json +2 -0
- package/dist/schemas/onchain_operations_guard.schema.json +578 -0
- package/dist/schemas/onchain_operations_machine.schema.json +1 -0
- package/dist/schemas/onchain_operations_order.schema.json +4 -3
- package/dist/schemas/onchain_operations_payment.schema.json +1 -0
- package/dist/schemas/onchain_operations_permission.schema.json +1 -0
- package/dist/schemas/onchain_operations_personal.schema.json +37 -0
- package/dist/schemas/onchain_operations_progress.schema.json +90 -3
- package/dist/schemas/onchain_operations_proof.schema.json +1 -0
- package/dist/schemas/onchain_operations_repository.schema.json +1 -0
- package/dist/schemas/onchain_operations_reward.schema.json +1 -0
- package/dist/schemas/onchain_operations_service.schema.json +4 -3
- package/dist/schemas/onchain_operations_treasury.schema.json +1 -0
- package/dist/schemas/project_operation.output.json +2243 -1
- package/dist/schemas/project_operation.schema.json +683 -1
- package/dist/schemas/query_toolkit.output.json +1 -1
- package/dist/schemas/query_toolkit.schema.json +37 -0
- package/dist/schemas/schema_query.output.json +1 -1
- package/dist/schemas/schema_query.schema.json +30 -5
- package/dist/schemas/trust_score.output.json +392 -1
- package/dist/schemas/trust_score.schema.json +275 -1
- package/dist/tools/handlers/onchain.js +73 -8
- package/dist/tools/handlers/project.js +46 -0
- package/dist/tools/handlers/query.js +117 -2
- package/dist/tools/handlers/schema-query.js +41 -0
- package/dist/tools/handlers/trust.js +192 -6
- package/dist/tools/index.js +52 -9
- package/dist/tools/wrap.js +194 -15
- package/package.json +2 -2
|
@@ -9,6 +9,8 @@ export async function handleSchemaQuery(args) {
|
|
|
9
9
|
query: validated.query,
|
|
10
10
|
field_path: validated.field_path,
|
|
11
11
|
template: validated.template,
|
|
12
|
+
object_type: validated.object_type,
|
|
13
|
+
params: validated.params,
|
|
12
14
|
output_file: validated.output_file,
|
|
13
15
|
};
|
|
14
16
|
const response = processSchemaQuery(request);
|
|
@@ -115,6 +117,45 @@ export async function handleSchemaQuery(args) {
|
|
|
115
117
|
}
|
|
116
118
|
break;
|
|
117
119
|
}
|
|
120
|
+
case "get_tool_reference": {
|
|
121
|
+
textContent += "\n\n## MCP Tool Reference\n\n";
|
|
122
|
+
textContent += "```json\n";
|
|
123
|
+
textContent += JSON.stringify(data, null, 2);
|
|
124
|
+
textContent += "\n```\n";
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
case "get_guard_design_patterns": {
|
|
128
|
+
textContent += "\n\n## Guard Design Patterns\n\n";
|
|
129
|
+
textContent += "```json\n";
|
|
130
|
+
textContent += JSON.stringify(data, null, 2);
|
|
131
|
+
textContent += "\n```\n";
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
case "get_safety_rules": {
|
|
135
|
+
textContent += "\n\n## Safety Rules (sunk from wowok-safety skill)\n\n";
|
|
136
|
+
textContent += "```json\n";
|
|
137
|
+
textContent += JSON.stringify(data, null, 2);
|
|
138
|
+
textContent += "\n```\n";
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
case "get_templates": {
|
|
142
|
+
textContent += "\n\n## Unified Template Registry (92-review D.2)\n\n";
|
|
143
|
+
const listData = data;
|
|
144
|
+
if (Array.isArray(listData.templates) && !request.template) {
|
|
145
|
+
textContent += `\n${listData.total ?? listData.templates.length} template(s). `;
|
|
146
|
+
textContent += "Call with 'template'=<id> for detail; add 'params' (JSON string) to instantiate.\n";
|
|
147
|
+
for (const t of listData.templates) {
|
|
148
|
+
textContent += `\n • ${t.id} [${t.object_type}${t.instantiable ? "" : ", guidance-only"}] — ${t.name} (${t.parameters?.length ?? 0} params)`;
|
|
149
|
+
}
|
|
150
|
+
textContent += "\n";
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
textContent += "```json\n";
|
|
154
|
+
textContent += JSON.stringify(data, null, 2);
|
|
155
|
+
textContent += "\n```\n";
|
|
156
|
+
}
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
118
159
|
default:
|
|
119
160
|
throw new Error(`Unknown schema_query action: ${String(request.action)}`);
|
|
120
161
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { strictParse, TrustScoreInputSchema, } from "../../schema/index.js";
|
|
2
|
-
import { query_objects, } from "@wowok/wowok";
|
|
2
|
+
import { query_objects, query_personal, } from "@wowok/wowok";
|
|
3
3
|
import { computeServiceTrustScore, } from "../../knowledge/index.js";
|
|
4
|
-
import { assembleInfoPuzzle, assessRisk, } from "../../customer/index.js";
|
|
4
|
+
import { assembleInfoPuzzle, assemblePreorderAdvice, assessRisk, buildPreorderComparison, getDefaultPreferences, inferIndustry, mergePreferences, validatePreferences, } from "../../customer/index.js";
|
|
5
|
+
import { getProfile } from "../../experience/user-profile.js";
|
|
5
6
|
function extractTrustMetrics(serviceObj) {
|
|
6
7
|
const data = serviceObj?.data ?? serviceObj ?? {};
|
|
7
8
|
const sales = Array.isArray(data.sales) ? data.sales : [];
|
|
@@ -113,8 +114,75 @@ function extractBalance(b) {
|
|
|
113
114
|
}
|
|
114
115
|
return 0n;
|
|
115
116
|
}
|
|
116
|
-
|
|
117
|
-
|
|
117
|
+
function toUserMetricsConfig(input) {
|
|
118
|
+
return {
|
|
119
|
+
version: 1,
|
|
120
|
+
metrics: input.metrics.map((m) => ({
|
|
121
|
+
name: m.name,
|
|
122
|
+
label: m.label,
|
|
123
|
+
evaluator: m.evaluator,
|
|
124
|
+
params: {
|
|
125
|
+
...m.params,
|
|
126
|
+
threshold: m.params.threshold !== undefined ? String(m.params.threshold) : undefined,
|
|
127
|
+
},
|
|
128
|
+
weight: m.weight,
|
|
129
|
+
advice_on_fail: m.advice_on_fail,
|
|
130
|
+
advice_on_pass: m.advice_on_pass,
|
|
131
|
+
})),
|
|
132
|
+
adjustment_cap: input.adjustment_cap,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function derivePreferences(validated, industry) {
|
|
136
|
+
const profile = getProfile();
|
|
137
|
+
const withProfile = mergePreferences(getDefaultPreferences(industry), {
|
|
138
|
+
risk_appetite: profile.risk_appetite,
|
|
139
|
+
min_trust_score: profile.risk_appetite === "conservative" ? 70
|
|
140
|
+
: profile.risk_appetite === "aggressive" ? 30 : 50,
|
|
141
|
+
});
|
|
142
|
+
const manualInput = validated.preferences;
|
|
143
|
+
const manual = manualInput
|
|
144
|
+
? {
|
|
145
|
+
...manualInput,
|
|
146
|
+
budget_range: manualInput.budget_range
|
|
147
|
+
? {
|
|
148
|
+
min: BigInt(manualInput.budget_range.min),
|
|
149
|
+
max: BigInt(manualInput.budget_range.max),
|
|
150
|
+
}
|
|
151
|
+
: undefined,
|
|
152
|
+
}
|
|
153
|
+
: undefined;
|
|
154
|
+
const prefs = manual ? mergePreferences(withProfile, manual) : withProfile;
|
|
155
|
+
return { prefs, issues: validatePreferences(prefs) };
|
|
156
|
+
}
|
|
157
|
+
async function fetchMerchantReputation(permissionAddr, network, noCache) {
|
|
158
|
+
try {
|
|
159
|
+
if (typeof permissionAddr !== "string" || !permissionAddr.startsWith("0x")) {
|
|
160
|
+
return undefined;
|
|
161
|
+
}
|
|
162
|
+
const permResult = await query_objects({
|
|
163
|
+
objects: [permissionAddr],
|
|
164
|
+
no_cache: noCache,
|
|
165
|
+
network,
|
|
166
|
+
});
|
|
167
|
+
const permObj = permResult?.objects?.[0];
|
|
168
|
+
const builder = (permObj?.data ?? permObj)?.builder;
|
|
169
|
+
if (typeof builder !== "string" || !builder.startsWith("0x")) {
|
|
170
|
+
return undefined;
|
|
171
|
+
}
|
|
172
|
+
const personal = await query_personal({
|
|
173
|
+
account: builder,
|
|
174
|
+
no_cache: noCache,
|
|
175
|
+
network,
|
|
176
|
+
});
|
|
177
|
+
if (!personal)
|
|
178
|
+
return undefined;
|
|
179
|
+
return { likes: personal.like ?? 0, dislikes: personal.dislike ?? 0 };
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
return undefined;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
async function runTrustEvaluation(validated) {
|
|
118
186
|
const depth = (validated.depth ?? "evaluate");
|
|
119
187
|
const queryResult = await query_objects({
|
|
120
188
|
objects: [validated.service],
|
|
@@ -142,11 +210,50 @@ export async function handleTrustScore(args) {
|
|
|
142
210
|
: salePriceRaw;
|
|
143
211
|
let riskScore;
|
|
144
212
|
let infoPuzzle;
|
|
213
|
+
let preorderAdvice;
|
|
214
|
+
let preferenceIssues;
|
|
145
215
|
if (depth === "evaluate" || depth === "preorder") {
|
|
146
216
|
const puzzleRaw = buildPuzzleRawData(serviceObj, orderAmount, { score: trustScore.score, level: trustScore.level }, undefined);
|
|
217
|
+
if (validated.user_metrics) {
|
|
218
|
+
puzzleRaw.user_metrics_config = toUserMetricsConfig(validated.user_metrics);
|
|
219
|
+
}
|
|
220
|
+
if (depth === "preorder") {
|
|
221
|
+
const reputation = await fetchMerchantReputation((serviceObj?.data ?? serviceObj)?.permission, validated.network, validated.no_cache);
|
|
222
|
+
if (reputation)
|
|
223
|
+
puzzleRaw.merchant_reputation = reputation;
|
|
224
|
+
}
|
|
147
225
|
infoPuzzle = assembleInfoPuzzle(validated.service, puzzleRaw, depth);
|
|
148
226
|
riskScore = assessRisk(infoPuzzle);
|
|
227
|
+
if (depth === "preorder") {
|
|
228
|
+
const industry = validated.industry ?? inferIndustry(infoPuzzle);
|
|
229
|
+
const { prefs, issues } = derivePreferences(validated, industry);
|
|
230
|
+
preferenceIssues = issues.length > 0 ? issues : undefined;
|
|
231
|
+
preorderAdvice = assemblePreorderAdvice({
|
|
232
|
+
puzzle: infoPuzzle,
|
|
233
|
+
risk: riskScore,
|
|
234
|
+
preferences: prefs,
|
|
235
|
+
industry,
|
|
236
|
+
});
|
|
237
|
+
}
|
|
149
238
|
}
|
|
239
|
+
return {
|
|
240
|
+
serviceId: validated.service,
|
|
241
|
+
serviceName: serviceObj?.data?.name ?? serviceObj?.name ?? validated.service,
|
|
242
|
+
serviceObj,
|
|
243
|
+
sales,
|
|
244
|
+
trustScore,
|
|
245
|
+
orderAmount,
|
|
246
|
+
infoPuzzle,
|
|
247
|
+
riskScore,
|
|
248
|
+
preorderAdvice,
|
|
249
|
+
preferenceIssues,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
export async function handleTrustScore(args) {
|
|
253
|
+
const validated = strictParse(TrustScoreInputSchema, args, "trust_score input");
|
|
254
|
+
const depth = (validated.depth ?? "evaluate");
|
|
255
|
+
const core = await runTrustEvaluation(validated);
|
|
256
|
+
const { serviceObj, sales, trustScore, orderAmount, infoPuzzle, riskScore, preorderAdvice, preferenceIssues } = core;
|
|
150
257
|
const result = {
|
|
151
258
|
service_id: validated.service,
|
|
152
259
|
service_name: serviceObj?.data?.name ?? serviceObj?.name ?? validated.service,
|
|
@@ -186,9 +293,88 @@ export async function handleTrustScore(args) {
|
|
|
186
293
|
assembled_at: infoPuzzle.assembled_at,
|
|
187
294
|
},
|
|
188
295
|
} : {}),
|
|
296
|
+
...(preorderAdvice ? {
|
|
297
|
+
preorder_advice: {
|
|
298
|
+
confidence: preorderAdvice.confidence,
|
|
299
|
+
industry: preorderAdvice.industry,
|
|
300
|
+
strategies: preorderAdvice.strategies.map((s) => ({
|
|
301
|
+
scenario: s.scenario,
|
|
302
|
+
merchant_tactic: s.strategy.merchant_tactic,
|
|
303
|
+
user_strategy: s.strategy.user_strategy,
|
|
304
|
+
nash_equilibrium: s.strategy.nash_equilibrium,
|
|
305
|
+
confidence: s.confidence,
|
|
306
|
+
fallback: s.fallback,
|
|
307
|
+
rationale: s.rationale,
|
|
308
|
+
})),
|
|
309
|
+
...(preorderAdvice.preference_match
|
|
310
|
+
? { preference_match: preorderAdvice.preference_match }
|
|
311
|
+
: {}),
|
|
312
|
+
...(preferenceIssues ? { preference_issues: preferenceIssues } : {}),
|
|
313
|
+
...(preorderAdvice.industry_risks
|
|
314
|
+
? {
|
|
315
|
+
industry_risks: {
|
|
316
|
+
score_adjustment: preorderAdvice.industry_risks.score_adjustment,
|
|
317
|
+
summary: preorderAdvice.industry_risks.summary,
|
|
318
|
+
checks: preorderAdvice.industry_risks.checks,
|
|
319
|
+
unmet_needs: preorderAdvice.industry_risks.unmet_needs.map((n) => ({
|
|
320
|
+
id: n.id,
|
|
321
|
+
tier: n.tier,
|
|
322
|
+
description: n.description,
|
|
323
|
+
advice: n.advice,
|
|
324
|
+
})),
|
|
325
|
+
},
|
|
326
|
+
}
|
|
327
|
+
: {}),
|
|
328
|
+
reminders: preorderAdvice.reminders,
|
|
329
|
+
blocking_reminders: preorderAdvice.blocking_reminders,
|
|
330
|
+
summary: preorderAdvice.summary,
|
|
331
|
+
},
|
|
332
|
+
} : {}),
|
|
189
333
|
};
|
|
334
|
+
let comparison;
|
|
335
|
+
if (depth === "preorder" && validated.compare_with && validated.compare_with.length > 0) {
|
|
336
|
+
const rows = [coreToCompareRow(core)];
|
|
337
|
+
for (const candidate of validated.compare_with) {
|
|
338
|
+
try {
|
|
339
|
+
const candidateCore = await runTrustEvaluation({
|
|
340
|
+
...validated,
|
|
341
|
+
service: candidate,
|
|
342
|
+
depth: "preorder",
|
|
343
|
+
});
|
|
344
|
+
rows.push(coreToCompareRow(candidateCore));
|
|
345
|
+
}
|
|
346
|
+
catch (e) {
|
|
347
|
+
rows.push({
|
|
348
|
+
service_id: candidate,
|
|
349
|
+
service_name: candidate,
|
|
350
|
+
error: e.message,
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
comparison = buildPreorderComparison(rows);
|
|
355
|
+
}
|
|
356
|
+
const finalResult = comparison ? { ...result, comparison } : result;
|
|
357
|
+
return {
|
|
358
|
+
content: [{ type: "text", text: JSON.stringify({ result: finalResult }) }],
|
|
359
|
+
structuredContent: { result: finalResult },
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
function coreToCompareRow(core) {
|
|
363
|
+
const reputation = core.infoPuzzle?.merchant_behavior?.reputation;
|
|
190
364
|
return {
|
|
191
|
-
|
|
192
|
-
|
|
365
|
+
service_id: core.serviceId,
|
|
366
|
+
service_name: core.serviceName,
|
|
367
|
+
industry: core.preorderAdvice?.industry,
|
|
368
|
+
confidence: core.preorderAdvice?.confidence.score,
|
|
369
|
+
risk_total: core.riskScore?.total,
|
|
370
|
+
risk_level: core.riskScore?.level,
|
|
371
|
+
trust_score: core.trustScore.score,
|
|
372
|
+
trust_level: core.trustScore.level,
|
|
373
|
+
preference_match: core.preorderAdvice?.preference_match?.score,
|
|
374
|
+
reputation_like_ratio: reputation?.like_ratio,
|
|
375
|
+
reputation_votes: reputation ? reputation.likes + reputation.dislikes : undefined,
|
|
376
|
+
red_flags_count: core.riskScore?.red_flags.length,
|
|
377
|
+
blocking_reminders_count: core.preorderAdvice?.blocking_reminders.length,
|
|
378
|
+
info_gaps_count: core.infoPuzzle?.gaps.length,
|
|
193
379
|
};
|
|
194
380
|
}
|
package/dist/tools/index.js
CHANGED
|
@@ -33,7 +33,7 @@ export const TOOL_REGISTRY = [
|
|
|
33
33
|
handler: handleOnchainOperations,
|
|
34
34
|
config: {
|
|
35
35
|
title: "⛓️ On-chain Operations",
|
|
36
|
-
description: "On-chain operations for WoWok object: service (marketplace listings), machine (workflow templates), progress (order tracking), repository (on-chain database), arbitration (dispute resolution), contact (IM management), treasury (team funds), reward (incentive pools), allocation (auto-distribution), permission (access control), guard (programmable trust rules), personal (public profile), payment (direct coin transfers), demand (service requests), order (order management), gen_passport (verified credentials), proof (on-chain proof objects), gen_proof (generate proof shortcut).\n\n📌 Project association: Pass env.project='<prefix>' to auto-tag the object on-chain AND auto-associate it to the SQLite project (created objects are automatically added). For complex builds, create a project first (project_operation action='create_project'). For single objects, just pass env.project. See PROJECT ASSOCIATION POLICY in system prompt.\n\n💡 Schema hint: Use schema_query with action='get' and name='onchain_operations' to retrieve the complete parameter schema. For individual operation schemas (e.g., 'onchain_operations_permission'), use schema_query with action='list_operations' to see all available operation schemas.",
|
|
36
|
+
description: "On-chain operations for WoWok object: service (marketplace listings), machine (workflow templates), progress (order tracking), repository (on-chain database), arbitration (dispute resolution), contact (IM management), treasury (team funds), reward (incentive pools), allocation (auto-distribution), permission (access control), guard (programmable trust rules), personal (public profile), payment (direct coin transfers), demand (service requests), order (order management), gen_passport (verified credentials), proof (on-chain proof objects), gen_proof (generate proof shortcut).\n\n💰 FUND SAFETY (service/arbitration/treasury/reward/allocation/payment): amounts are parsed against the target object's IMMUTABLE generic token type (e.g. Treasury<USDT> accepts ONLY USDT — mismatched coins/token_types are BLOCKED before execution). Monetary input with unresolvable token precision is BLOCKED (never guesses decimals) with known-token suggestions; retry once the token info resolves. Display-format amounts like \"2WOW\" are converted to raw u64 using the token's own decimals.\n\n📌 Project association: Pass env.project='<prefix>' to auto-tag the object on-chain AND auto-associate it to the SQLite project (created objects are automatically added). For complex builds, create a project first (project_operation action='create_project'). For single objects, just pass env.project. See PROJECT ASSOCIATION POLICY in system prompt.\n\n💡 Schema hint: Use schema_query with action='get' and name='onchain_operations' to retrieve the complete parameter schema. For individual operation schemas (e.g., 'onchain_operations_permission'), use schema_query with action='list_operations' to see all available operation schemas.",
|
|
37
37
|
inputSchema: OnchainOperationsSchema,
|
|
38
38
|
outputSchema: CallOutputSchema,
|
|
39
39
|
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
|
|
@@ -139,18 +139,22 @@ export const TOOL_REGISTRY = [
|
|
|
139
139
|
handler: handleWatchQueryOperations,
|
|
140
140
|
config: {
|
|
141
141
|
title: "🔍 Data Query Toolkit",
|
|
142
|
-
description: "WOWOK data query toolkit —
|
|
142
|
+
description: "WOWOK data query toolkit — 13 query types covering local device data and on-chain blockchain data:\n\n"
|
|
143
143
|
+ "LOCAL (device-only, never on-chain):\n"
|
|
144
144
|
+ "1. local_mark_list — Query your LOCAL address book: maps human-readable names to blockchain addresses with optional tags. Use to resolve names→addresses or find addresses by tag.\n"
|
|
145
145
|
+ "2. account_list — Query your LOCAL accounts (addresses, messenger status, suspension state). Use filter.includePubkey=true to also include public keys. Use to discover available accounts before operations.\n"
|
|
146
146
|
+ "3. local_info_list — Query your LOCAL private info: sensitive data like delivery addresses, phone numbers, contacts stored ONLY on this device.\n"
|
|
147
147
|
+ "4. token_list — Query cached token metadata: symbol, decimals, icon URL, description for tokens previously fetched from chain. Use to look up token precision/decimals before performing token operations. Returns: TokenTypeInfo[] (type, alias, name, symbol, decimals, iconUrl).\n"
|
|
148
|
-
+ "5. account_balance — Query an account's coin balance OR Paginated coin objects. Use balance=true for total amount, or coin={cursor,limit} to list individual coin objects. Supports multi-token via token_type parameter.\n"
|
|
148
|
+
+ "5. account_balance — Query an account's coin balance OR Paginated coin objects. Use balance=true for total amount, or coin={cursor,limit} to list individual coin objects. Supports multi-token via token_type parameter. Results include `_money_display` with unit-converted values + decimals reminder.\n"
|
|
149
149
|
+ "6. local_names — Query local names by a list of addresses. For each address, returns the resolved account name (if exists) and local mark name (if exists). Returns: { account?, local_mark?, address }[].\n\n"
|
|
150
150
|
+ "ONCHAIN (blockchain):\n"
|
|
151
151
|
+ "7. onchain_personal_profile — Query any user's PUBLIC on-chain profile: social links, reputation (likes/dislikes), personal info records, voting history, referrer.\n"
|
|
152
|
-
+ "8. onchain_objects — Batch query on-chain WOWOK objects by ID or name: supports Service, Machine, Order, Treasury, Reward, Arb, Personal, Contact, and more.\n"
|
|
153
|
-
+ "9. onchain_received — Query objects (Payments, Tokens, NFTs) received by a specific object. Supports pagination and type filter
|
|
152
|
+
+ "8. onchain_objects — Batch query on-chain WOWOK objects by ID or name: supports Service, Machine, Order, Treasury, Reward, Arb, Personal, Contact, and more. Monetary fields include `_money_display` annotations (token type from the object's immutable generic).\n"
|
|
153
|
+
+ "9. onchain_received — Query objects (Payments, Tokens, NFTs) received by a specific object. Supports pagination and type filter. CoinWrapper mode returns token-aware `_money_display`.\n"
|
|
154
|
+
+ "10. onchain_transaction — Verify what a specific transaction did on-chain (status, object changes, balance changes, gas, events). Balance changes include `_money_display` (unit-converted via each change's own coin_type; signed amounts supported).\n"
|
|
155
|
+
+ "11. onchain_object_history — FORENSICS: all transactions that touched an object (auditing only — prefer assemble_context for AI context building).\n"
|
|
156
|
+
+ "12. onchain_address_activity — FORENSICS: all transactions sent by an address (auditing only).\n"
|
|
157
|
+
+ "13. token_value_convert — Convert between raw on-chain smallest units (u64) and human unit values in EITHER direction (e.g. \"2200000000\" ↔ \"2.2\" WOW). Unit→raw is REFUSED when token precision cannot be resolved (never guesses decimals).\n\n"
|
|
154
158
|
+ "For dynamic table data queries (pagination, table items), use the 'onchain_table_data' tool.\n\n"
|
|
155
159
|
+ "💡 Schema hint: Use schema_query with action='get' and name='query_toolkit' to retrieve the exact parameter schema with all query types and field definitions.",
|
|
156
160
|
inputSchema: WatchQueryOperationsSchema,
|
|
@@ -189,7 +193,7 @@ export const TOOL_REGISTRY = [
|
|
|
189
193
|
handler: handleOnchainEvents,
|
|
190
194
|
config: {
|
|
191
195
|
title: "📅 Watch WoWok On-chain Events",
|
|
192
|
-
description: "Watch on-chain WoWok events by type. Supports arbitration events, new order events, progress events, demand presentation events, demand feedback events, and new entity registration events. Use pagination cursor for fetching large result sets.\n\n💡 Schema hint: Use schema_query with action='get' and name='onchain_events' to retrieve the exact parameter schema with all event types and field definitions.",
|
|
196
|
+
description: "Watch on-chain WoWok events by type. Supports arbitration events, new order events, progress events, demand presentation events, demand feedback events, and new entity registration events. Use pagination cursor for fetching large result sets. NewOrderEvent.amount includes `_money_display` annotation (unit-converted via the order's Service generic token type; raw-only with retry hint when precision is unavailable).\n\n💡 Schema hint: Use schema_query with action='get' and name='onchain_events' to retrieve the exact parameter schema with all event types and field definitions.",
|
|
193
197
|
inputSchema: OnchainEventsInputSchema,
|
|
194
198
|
outputSchema: OnchainEventsResultSchema,
|
|
195
199
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
@@ -201,7 +205,7 @@ export const TOOL_REGISTRY = [
|
|
|
201
205
|
handler: handleWowokInfo,
|
|
202
206
|
config: {
|
|
203
207
|
title: "ℹ️ WoWok Build-in Information",
|
|
204
|
-
description: "Query WoWok protocol information: 'constants', 'built-in permissions', 'guard instructions', 'current network', 'value types', or 'mainnet bridge tokens'. For 'mainnet bridge tokens': returns cross-chain bridge tokens (ETH, WETH, WBTC, USDC, USDT) with each token's symbol, WOW-side type tag (wowTypeTag), EVM address, decimals, and description. The wowTypeTag (format {address}::{module}::{struct}) can be used directly as the `type_parameter` of Service / Treasury / Reward / Allocation objects to set their payment token — e.g. use USDT's wowTypeTag to create a Service that accepts USDT payments.",
|
|
208
|
+
description: "Query WoWok protocol information: 'constants', 'built-in permissions', 'common mistakes', 'guard instructions', 'current network', 'value types', or 'mainnet bridge tokens'. Use 'common mistakes' to proactively learn known field-name/unit/workflow pitfalls before submitting an operation (e.g. filter operation:\"compensation_fund_add\"). For 'mainnet bridge tokens': returns cross-chain bridge tokens (ETH, WETH, WBTC, USDC, USDT) with each token's symbol, WOW-side type tag (wowTypeTag), EVM address, decimals, and description. The wowTypeTag (format {address}::{module}::{struct}) can be used directly as the `type_parameter` of Service / Treasury / Reward / Allocation objects to set their payment token — e.g. use USDT's wowTypeTag to create a Service that accepts USDT payments.",
|
|
205
209
|
inputSchema: ProtocolInfoQuerySchema,
|
|
206
210
|
outputSchema: ProtocolInfoResultSchema,
|
|
207
211
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
@@ -220,8 +224,14 @@ export const TOOL_REGISTRY = [
|
|
|
220
224
|
" 'list' - Show all available schemas (tools + on-chain operations). Start here to discover what exists.\n" +
|
|
221
225
|
" 'get' - Fetch the full input JSON Schema by name (e.g. 'onchain_operations'). Use with the 'name' param.\n" +
|
|
222
226
|
" 'get_output' - Fetch the output JSON Schema of a tool by name (e.g. 'onchain_operations'). Use with the 'name' param. Use this to understand a tool's return value structure.\n" +
|
|
227
|
+
" 'get_field' - Query a single field by dot-path (e.g. field_path='data.node.nodes.0.pairs'). Cheaper than 'get' when you only need one subtree.\n" +
|
|
223
228
|
" 'search' - Find schemas by keyword, matching name/title/description. Use with the 'query' param.\n" +
|
|
224
|
-
" 'list_operations' - Show only on-chain operation schemas (prefixed 'onchain_operations_'). Narrower than 'list'
|
|
229
|
+
" 'list_operations' - Show only on-chain operation schemas (prefixed 'onchain_operations_'). Narrower than 'list'.\n" +
|
|
230
|
+
" 'get_guard_templates' - Guard creation templates + best practices (e.g. signer_verification, progress_node_check). Omit 'template' to list all.\n" +
|
|
231
|
+
" 'search_examples' - Search verified example files by keyword (matches title/description/tags/operation_type/industry). Use with the 'query' param.\n" +
|
|
232
|
+
" 'get_tool_reference' - MCP tool usage reference (summaries, actions, prerequisites, notes). Pass name='<tool>' for one tool, query='<keyword>' to search, or omit for the full catalog.\n" +
|
|
233
|
+
" 'get_guard_design_patterns' - Curated Guard design patterns (business requirement → logic tree template). Pass name='<pattern_id>', query='<host>' (e.g. 'service_buy_guard', 'machine_forward'), or omit for the full catalog.\n" +
|
|
234
|
+
" 'get_safety_rules' - Safety rule tables sunk from the wowok-safety skill: object reuse, immutability-after-publish, LOCAL/ONCHAIN/QUERY classification, naming conventions.",
|
|
225
235
|
inputSchema: SchemaQueryInputSchema,
|
|
226
236
|
outputSchema: SchemaQueryOutputSchema,
|
|
227
237
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
@@ -286,6 +296,39 @@ export const TOOL_REGISTRY = [
|
|
|
286
296
|
" • refresh_objects — Refresh object cache from chain (batch query, rate-limited).\n" +
|
|
287
297
|
" • get_object_diff — Get field-level diff of an object between two timestamps.\n\n" +
|
|
288
298
|
"═══════════════════════════════════════════════════════════════\n" +
|
|
299
|
+
" INDUSTRY MODE RECOMMENDATION + REGISTRY (9 actions, GLM6/92 §E)\n" +
|
|
300
|
+
"═══════════════════════════════════════════════════════════════\n" +
|
|
301
|
+
" • recommend_industry — CALL THIS FIRST when the user describes a business without naming an industry. " +
|
|
302
|
+
"Returns top-3 similar industries + verified reference examples ('from scratch vs giants' shoulders').\n" +
|
|
303
|
+
" • list_modes — List builtin industry modes + your custom modes.\n" +
|
|
304
|
+
" • derive_user_mode — Derive a custom mode from a builtin (modify machine_shape/allocator/config). R-M1-11 enforced.\n" +
|
|
305
|
+
" • evolve_user_mode — Iterate a custom mode (version bump + evolution history).\n" +
|
|
306
|
+
" • register_user_mode — Register a fully custom mode (requires machine_shape + key_risk).\n" +
|
|
307
|
+
" • unregister_user_mode — Delete a custom mode.\n" +
|
|
308
|
+
" • register_custom_metric / register_custom_constraint — Extend the evaluation registries.\n" +
|
|
309
|
+
" • list_metrics_constraints — List metrics + constraints (filterable by type/scope).\n\n" +
|
|
310
|
+
"═══════════════════════════════════════════════════════════════\n" +
|
|
311
|
+
" INTENT → RISK → SUBSTEP PIPELINE (3 actions, GLM5-31 §V3/V4)\n" +
|
|
312
|
+
"═══════════════════════════════════════════════════════════════\n" +
|
|
313
|
+
" • analyze_intent (C1) — Business intent text → parsed intent (primary/secondary objects, " +
|
|
314
|
+
"detected scenes, industry) + per-object puzzle snapshots + recommended creation order. " +
|
|
315
|
+
"Required: intent.\n" +
|
|
316
|
+
" • aggregate_risks (C2) — Puzzle snapshots → calibrated risks (CRITICAL/HIGH/MEDIUM/LOW/INFO) " +
|
|
317
|
+
"with blocking status (RISK_BLOCKED / RISK_PENDING_CONFIRM / RISK_PASSED). Required: project + " +
|
|
318
|
+
"(puzzles OR intent — when intent is given, analyze_intent runs first automatically). " +
|
|
319
|
+
"Optional: planned_objects (OBJECT_REUSE check), planned_operations (IMMUTABILITY check).\n" +
|
|
320
|
+
" • trace_substeps (C3) — Substep execution records → DAG coherence analysis (dangling inputs, " +
|
|
321
|
+
"circular refs, missing outputs, cross-step breaks, topological order, D-10 verdict). " +
|
|
322
|
+
"Required: project + substeps.\n\n" +
|
|
323
|
+
"═══════════════════════════════════════════════════════════════\n" +
|
|
324
|
+
" MERCHANT ONBOARDING WIZARD (1 action, GLM6/93 §5)\n" +
|
|
325
|
+
"═══════════════════════════════════════════════════════════════\n" +
|
|
326
|
+
" • merchant_guide — 10-step guided flow from 'I want to sell X' to a validated creation plan: " +
|
|
327
|
+
"intent analysis → industry matching → module adoption → semantic blueprint → evaluation preview → " +
|
|
328
|
+
"harness check → ordered creation plan. Stateless: pass guide_state UNCHANGED between calls, " +
|
|
329
|
+
"advance via guide_confirm. NEVER executes on-chain — materialize the plan via create_project + " +
|
|
330
|
+
"onchain_operations. Required: intent (first call) or guide_state.\n\n" +
|
|
331
|
+
"═══════════════════════════════════════════════════════════════\n" +
|
|
289
332
|
" CONTEXT ASSEMBLY (1 action)\n" +
|
|
290
333
|
"═══════════════════════════════════════════════════════════════\n" +
|
|
291
334
|
" • assemble_context — Query on-chain object states + extract embedded history + optional events, " +
|
|
@@ -1226,7 +1269,7 @@ export function listTools() {
|
|
|
1226
1269
|
name: "wowok",
|
|
1227
1270
|
title: "WoWok MCP",
|
|
1228
1271
|
description: WOWOK_TOOL_DESCRIPTION,
|
|
1229
|
-
inputSchema: zodToJsonSchemaSafe(WowokToolDisplaySchema, "wowok"),
|
|
1272
|
+
inputSchema: resolveSchemaRefs(zodToJsonSchemaSafe(WowokToolDisplaySchema, "wowok")),
|
|
1230
1273
|
}];
|
|
1231
1274
|
}
|
|
1232
1275
|
export function registerAllTools(server) {
|