@wowok/agent-mcp 2.6.1 → 2.6.4
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/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 +9 -2
- package/dist/customer/info-puzzle.js +34 -7
- 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 +30 -7
- package/dist/customer/types.d.ts +7 -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 +59 -0
- package/dist/examples/guard-template-time-lock.json +60 -0
- 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 +119 -0
- package/dist/examples/payment-scenario-bound.json +45 -0
- package/dist/examples/rental-ziroom-machine-create.json +149 -0
- package/dist/examples/rental-ziroom-permission-create.json +42 -0
- package/dist/examples/rental-ziroom-service-create.json +89 -0
- 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/retail-myshop-service-create.json +88 -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 +216 -29
- package/dist/extensions/constraint-registry.js +21 -19
- package/dist/extensions/metric-registry.js +14 -14
- package/dist/extensions/mode-evaluator.js +16 -16
- package/dist/extensions/modes.js +141 -49
- package/dist/extensions/registry.d.ts +16 -9
- package/dist/extensions/registry.js +132 -44
- package/dist/extensions/types.d.ts +2 -0
- package/dist/index.js +50 -0
- package/dist/knowledge/deployment-scanner.js +1 -1
- package/dist/knowledge/fund-layer.d.ts +138 -0
- package/dist/knowledge/fund-layer.js +969 -0
- package/dist/knowledge/guard-render.d.ts +57 -0
- package/dist/knowledge/guard-render.js +700 -0
- package/dist/knowledge/guard-submission-prompt.d.ts +31 -0
- package/dist/knowledge/guard-submission-prompt.js +171 -0
- 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-ledger.js +1 -1
- package/dist/knowledge/machine-render.d.ts +41 -0
- package/dist/knowledge/machine-render.js +565 -0
- package/dist/knowledge/machine-risk.js +4 -1
- package/dist/knowledge/machine-templates.js +4 -4
- 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/reward-confirm.js +2 -2
- package/dist/knowledge/reward-puzzle.js +1 -1
- package/dist/knowledge/reward-risk.js +9 -9
- package/dist/knowledge/reward-templates.js +2 -2
- 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/service-confirm.d.ts +1 -1
- package/dist/knowledge/service-confirm.js +3 -3
- package/dist/knowledge/service-context.js +1 -1
- package/dist/knowledge/service-ledger.js +1 -1
- package/dist/knowledge/service-risk.d.ts +1 -1
- package/dist/knowledge/service-risk.js +3 -3
- package/dist/knowledge/service-templates.js +2 -2
- package/dist/knowledge/service-translation.d.ts +1 -1
- package/dist/knowledge/service-translation.js +7 -7
- 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/deployment-bridge.js +6 -5
- package/dist/project/deployment-doc.js +5 -5
- package/dist/project/edit-planner.d.ts +123 -0
- package/dist/project/edit-planner.js +1342 -0
- package/dist/project/evaluation.d.ts +36 -0
- package/dist/project/evaluation.js +734 -68
- package/dist/project/game-theory.d.ts +43 -0
- package/dist/project/game-theory.js +177 -0
- package/dist/project/graph-builder.js +7 -1
- package/dist/project/handlers.d.ts +137 -2
- package/dist/project/handlers.js +423 -51
- 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/project/stage-gate.js +4 -4
- package/dist/schema/call/allocation.d.ts +11 -11
- package/dist/schema/call/allocation.js +13 -3
- package/dist/schema/call/arbitration.d.ts +21 -21
- package/dist/schema/call/arbitration.js +30 -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/contact.js +2 -2
- package/dist/schema/call/demand.d.ts +3 -3
- package/dist/schema/call/demand.js +2 -2
- package/dist/schema/call/guard.d.ts +11 -11
- package/dist/schema/call/guard.js +2 -2
- package/dist/schema/call/machine.d.ts +2072 -679
- package/dist/schema/call/machine.js +51 -5
- package/dist/schema/call/order.d.ts +7 -7
- package/dist/schema/call/order.js +3 -6
- package/dist/schema/call/payment.d.ts +3 -3
- package/dist/schema/call/permission.d.ts +3 -3
- package/dist/schema/call/permission.js +2 -2
- 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/repository.js +2 -2
- package/dist/schema/call/reward.d.ts +57 -57
- package/dist/schema/call/reward.js +3 -3
- package/dist/schema/call/semantic.js +48 -2
- package/dist/schema/call/service.d.ts +285 -113
- package/dist/schema/call/service.js +92 -28
- package/dist/schema/call/treasury.d.ts +57 -57
- package/dist/schema/call/treasury.js +3 -3
- package/dist/schema/common/index.d.ts +2 -0
- package/dist/schema/common/index.js +46 -10
- package/dist/schema/local/index.js +5 -1
- package/dist/schema/messenger/index.js +4 -1
- package/dist/schema/operations.d.ts +1318 -317
- package/dist/schema/operations.js +76 -7
- package/dist/schema/project/index.d.ts +5662 -164
- package/dist/schema/project/index.js +1136 -5
- package/dist/schema/query/index.d.ts +580 -19
- package/dist/schema/query/index.js +88 -36
- package/dist/schema/schema-query/index.d.ts +59 -3
- package/dist/schema/schema-query/index.js +45 -6
- package/dist/schema/trust/index.d.ts +1012 -6
- package/dist/schema/trust/index.js +212 -11
- package/dist/schema/utils/node-parser.js +13 -0
- package/dist/schema/utils/object-type-utils.d.ts +12 -0
- package/dist/schema/utils/object-type-utils.js +35 -0
- package/dist/schema/utils/permission-machine-check.d.ts +49 -0
- package/dist/schema/utils/permission-machine-check.js +121 -0
- package/dist/schema/utils/skills-recommendation.d.ts +2 -0
- package/dist/schema/utils/skills-recommendation.js +77 -0
- package/dist/schema-query/index.d.ts +17 -1
- package/dist/schema-query/index.js +359 -3
- package/dist/schemas/account_operation.schema.json +1 -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_events.output.json +1 -1
- package/dist/schemas/onchain_operations.output.json +2820 -0
- package/dist/schemas/onchain_operations.schema.json +255 -65
- package/dist/schemas/onchain_operations_allocation.schema.json +7 -6
- package/dist/schemas/onchain_operations_arbitration.schema.json +14 -10
- package/dist/schemas/onchain_operations_contact.schema.json +4 -3
- package/dist/schemas/onchain_operations_demand.schema.json +4 -3
- package/dist/schemas/onchain_operations_gen_passport.schema.json +4 -2
- package/dist/schemas/onchain_operations_gen_proof.schema.json +2 -0
- package/dist/schemas/onchain_operations_guard.schema.json +579 -1
- package/dist/schemas/onchain_operations_machine.schema.json +5 -4
- package/dist/schemas/onchain_operations_order.schema.json +7 -6
- package/dist/schemas/onchain_operations_payment.schema.json +2 -1
- package/dist/schemas/onchain_operations_permission.schema.json +3 -2
- package/dist/schemas/onchain_operations_personal.schema.json +37 -0
- package/dist/schemas/onchain_operations_progress.schema.json +91 -4
- package/dist/schemas/onchain_operations_proof.schema.json +2 -1
- package/dist/schemas/onchain_operations_repository.schema.json +4 -3
- package/dist/schemas/onchain_operations_reward.schema.json +7 -6
- package/dist/schemas/onchain_operations_service.schema.json +80 -19
- package/dist/schemas/onchain_operations_treasury.schema.json +5 -4
- package/dist/schemas/onchain_table_data.output.json +1 -1
- package/dist/schemas/onchain_table_data.schema.json +10 -9
- package/dist/schemas/project_operation.output.json +3318 -57
- package/dist/schemas/project_operation.schema.json +728 -4
- package/dist/schemas/query_toolkit.output.json +16 -16
- package/dist/schemas/query_toolkit.schema.json +40 -3
- package/dist/schemas/schema_query.output.json +65 -2
- package/dist/schemas/schema_query.schema.json +31 -5
- package/dist/schemas/trust_score.output.json +392 -1
- package/dist/schemas/trust_score.schema.json +275 -1
- package/dist/schemas/wowok_buildin_info.output.json +81 -8
- package/dist/schemas/wowok_buildin_info.schema.json +46 -2
- package/dist/tools/handlers/onchain.js +636 -6
- package/dist/tools/handlers/project.js +71 -2
- package/dist/tools/handlers/query.js +117 -2
- package/dist/tools/handlers/schema-query.js +65 -1
- package/dist/tools/handlers/trust.js +192 -6
- package/dist/tools/index.d.ts +8 -0
- package/dist/tools/index.js +229 -15
- package/dist/tools/wrap.js +194 -15
- package/package.json +2 -2
|
@@ -3,10 +3,16 @@ import { generateDeploymentDocFromProject } from "../../project/deployment-bridg
|
|
|
3
3
|
import { LocalProject } from "@wowok/wowok";
|
|
4
4
|
import { validateStageGate } from "../../project/stage-gate.js";
|
|
5
5
|
import { scanDeployment } from "../../knowledge/deployment-scanner.js";
|
|
6
|
-
import { handleListProjects, handleCreateProject, handleCreateProjectFromOnchain, handleUpdateProject, handleGetProjectDetail, handleAddObject, handleRemoveObject, handleUpdateObject, handleCreateVersion, handleBuildGraph, handleGetGraph, handleEvaluateProject, handleSaveEvaluation, handleCompareProjects, handleRefreshObjects, handleGetObjectDiff, handleDeleteProject, handleGetMachineGraph, handlePreEvaluateCheck, handleVerifyDeployment, handleCloneProjectToNetwork, } from "../../project/handlers.js";
|
|
6
|
+
import { handleListProjects, handleCreateProject, handleCreateProjectFromOnchain, handleUpdateProject, handleGetProjectDetail, handleAddObject, handleRemoveObject, handleUpdateObject, handleCreateVersion, handleBuildGraph, handleGetGraph, handleEvaluateProject, handleSaveEvaluation, handleCompareProjects, handleRefreshObjects, handleGetObjectDiff, handleDeleteProject, handleGetMachineGraph, handleGetGuardGraph, handlePreEvaluateCheck, handleVerifyDeployment, handleCloneProjectToNetwork, handleMigrateToMainnet, } from "../../project/handlers.js";
|
|
7
|
+
import { handlePlanObjectEdit, handleApplyObjectEdit, handlePatchMachineNodes, handlePatchGuardTree, } from "../../project/edit-planner.js";
|
|
8
|
+
import { handleRecommendIndustry, handleListModes, handleDeriveUserMode, handleEvolveUserMode, handleRegisterUserMode, handleUnregisterUserMode, handleRegisterCustomMetric, handleRegisterCustomConstraint, handleListMetricsConstraints, } from "../../project/mode-actions.js";
|
|
9
|
+
import { handleAnalyzeIntent, handleAggregateRisks, handleTraceSubsteps, } from "../../project/pipeline-actions.js";
|
|
10
|
+
import { handleMerchantGuide } from "../../project/merchant-guide.js";
|
|
11
|
+
import { handleParticipationRadar } from "../../project/participation-radar.js";
|
|
7
12
|
import { strictParse } from "../../schema/index.js";
|
|
8
13
|
import { ProjectOperationInputSchema } from "../../schema/project/index.js";
|
|
9
14
|
import { getStageCache } from "../../project/index.js";
|
|
15
|
+
import { getSkillsHintForProject } from "../../schema/utils/skills-recommendation.js";
|
|
10
16
|
export async function handleProjectOperation(args) {
|
|
11
17
|
const validated = strictParse(ProjectOperationInputSchema, args, "project_operation input");
|
|
12
18
|
const { action } = validated;
|
|
@@ -66,6 +72,9 @@ export async function handleProjectOperation(args) {
|
|
|
66
72
|
case "get_machine_graph":
|
|
67
73
|
result = await handleGetMachineGraph(validated);
|
|
68
74
|
break;
|
|
75
|
+
case "get_guard_graph":
|
|
76
|
+
result = await handleGetGuardGraph(validated);
|
|
77
|
+
break;
|
|
69
78
|
case "assemble_context":
|
|
70
79
|
result = await assembleContext(validated);
|
|
71
80
|
break;
|
|
@@ -132,11 +141,71 @@ export async function handleProjectOperation(args) {
|
|
|
132
141
|
case "migrate_network":
|
|
133
142
|
result = await handleCloneProjectToNetwork(validated);
|
|
134
143
|
break;
|
|
144
|
+
case "migrate_to_mainnet":
|
|
145
|
+
result = await handleMigrateToMainnet(validated);
|
|
146
|
+
break;
|
|
147
|
+
case "plan_object_edit":
|
|
148
|
+
result = await handlePlanObjectEdit(validated);
|
|
149
|
+
break;
|
|
150
|
+
case "apply_object_edit":
|
|
151
|
+
result = await handleApplyObjectEdit(validated);
|
|
152
|
+
break;
|
|
153
|
+
case "patch_machine_nodes":
|
|
154
|
+
result = await handlePatchMachineNodes(validated);
|
|
155
|
+
break;
|
|
156
|
+
case "patch_guard_tree":
|
|
157
|
+
result = await handlePatchGuardTree(validated);
|
|
158
|
+
break;
|
|
159
|
+
case "recommend_industry":
|
|
160
|
+
result = handleRecommendIndustry(validated);
|
|
161
|
+
break;
|
|
162
|
+
case "list_modes":
|
|
163
|
+
result = await handleListModes();
|
|
164
|
+
break;
|
|
165
|
+
case "derive_user_mode":
|
|
166
|
+
result = await handleDeriveUserMode(validated);
|
|
167
|
+
break;
|
|
168
|
+
case "evolve_user_mode":
|
|
169
|
+
result = await handleEvolveUserMode(validated);
|
|
170
|
+
break;
|
|
171
|
+
case "register_user_mode":
|
|
172
|
+
result = await handleRegisterUserMode(validated);
|
|
173
|
+
break;
|
|
174
|
+
case "unregister_user_mode":
|
|
175
|
+
result = await handleUnregisterUserMode(validated);
|
|
176
|
+
break;
|
|
177
|
+
case "register_custom_metric":
|
|
178
|
+
result = handleRegisterCustomMetric(validated);
|
|
179
|
+
break;
|
|
180
|
+
case "register_custom_constraint":
|
|
181
|
+
result = handleRegisterCustomConstraint(validated);
|
|
182
|
+
break;
|
|
183
|
+
case "list_metrics_constraints":
|
|
184
|
+
result = handleListMetricsConstraints(validated);
|
|
185
|
+
break;
|
|
186
|
+
case "analyze_intent":
|
|
187
|
+
result = handleAnalyzeIntent(validated);
|
|
188
|
+
break;
|
|
189
|
+
case "aggregate_risks":
|
|
190
|
+
result = handleAggregateRisks(validated);
|
|
191
|
+
break;
|
|
192
|
+
case "trace_substeps":
|
|
193
|
+
result = handleTraceSubsteps(validated);
|
|
194
|
+
break;
|
|
195
|
+
case "merchant_guide":
|
|
196
|
+
result = await handleMerchantGuide(validated);
|
|
197
|
+
break;
|
|
198
|
+
case "participation_radar":
|
|
199
|
+
result = await handleParticipationRadar(validated);
|
|
200
|
+
break;
|
|
135
201
|
default:
|
|
136
202
|
throw new Error(`Unknown project_operation action: ${String(action)}`);
|
|
137
203
|
}
|
|
204
|
+
const skillsHint = getSkillsHintForProject(action);
|
|
138
205
|
return {
|
|
139
206
|
content: [{ type: "text", text: JSON.stringify({ result }) }],
|
|
140
|
-
structuredContent:
|
|
207
|
+
structuredContent: skillsHint
|
|
208
|
+
? { result, skills_recommended: skillsHint }
|
|
209
|
+
: { result },
|
|
141
210
|
};
|
|
142
211
|
}
|
|
@@ -1,7 +1,46 @@
|
|
|
1
1
|
import { strictParse, WatchQueryOperationsSchema, OnchainTableDataSchema, OnchainEventsInputSchema, ProtocolInfoQuerySchema, } from "../../schema/index.js";
|
|
2
2
|
import { 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, queryTableItem_RepositoryData, queryTableItem_PermissionPerm, queryTableItem_RewardRecord, queryTableItem_DemandPresenter, queryTableItem_TreasuryHistory, queryTableItem_MachineNode, queryTableItem_ProgressHistory, queryTableItem_AddressMark, queryTableItem_EntityRegistrar, queryTableItem_EntityLinker, query_received, queryProtocolInfo, query_events, query_transaction, query_object_history, query_address_activity, generateNodeComments, } from "@wowok/wowok";
|
|
3
3
|
import { buildDataSemantic, } from "../../schema/call/semantic.js";
|
|
4
|
+
import { formatChainValue, annotateObjectMonetaryFields, annotateTableItemMonetaryFields, annotateEventsMonetaryFields, annotateBalanceChanges, resolveParentObjectTokenType, convertTokenValue, } from "../../knowledge/fund-layer.js";
|
|
4
5
|
import { normalizeAccountOrMark } from "./messenger.js";
|
|
6
|
+
async function annotateAccountBalance(result, network) {
|
|
7
|
+
if (!result || typeof result !== "object")
|
|
8
|
+
return;
|
|
9
|
+
const displays = {};
|
|
10
|
+
const convert = (raw, coinType) => {
|
|
11
|
+
if (raw === null || raw === undefined)
|
|
12
|
+
return undefined;
|
|
13
|
+
if (typeof raw !== "string" && typeof raw !== "number" && typeof raw !== "bigint")
|
|
14
|
+
return undefined;
|
|
15
|
+
if (typeof coinType !== "string" || !coinType)
|
|
16
|
+
return undefined;
|
|
17
|
+
return formatChainValue(raw, coinType, network);
|
|
18
|
+
};
|
|
19
|
+
const balance = result.balance;
|
|
20
|
+
if (balance && typeof balance === "object") {
|
|
21
|
+
const coinType = balance.coinType;
|
|
22
|
+
const total = await convert(balance.totalBalance, coinType);
|
|
23
|
+
if (total)
|
|
24
|
+
displays["balance.totalBalance"] = total;
|
|
25
|
+
if (balance.lockedBalance !== undefined) {
|
|
26
|
+
const locked = await convert(balance.lockedBalance, coinType);
|
|
27
|
+
if (locked)
|
|
28
|
+
displays["balance.lockedBalance"] = locked;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const coinData = result.coin?.data;
|
|
32
|
+
if (Array.isArray(coinData)) {
|
|
33
|
+
for (let i = 0; i < coinData.length; i++) {
|
|
34
|
+
const c = coinData[i];
|
|
35
|
+
const d = await convert(c?.balance, c?.coinType);
|
|
36
|
+
if (d)
|
|
37
|
+
displays[`coin.data[${i}].balance`] = d;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (Object.keys(displays).length > 0) {
|
|
41
|
+
result._money_display = displays;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
5
44
|
export async function handleWatchQueryOperations(args) {
|
|
6
45
|
const validated = strictParse(WatchQueryOperationsSchema, args, "watch_and_query input");
|
|
7
46
|
let result;
|
|
@@ -34,6 +73,7 @@ export async function handleWatchQueryOperations(args) {
|
|
|
34
73
|
coin: validated.coin,
|
|
35
74
|
network: validated.network,
|
|
36
75
|
});
|
|
76
|
+
await annotateAccountBalance(queryResult, validated.network);
|
|
37
77
|
result = { query_type: "account_balance", result: queryResult };
|
|
38
78
|
break;
|
|
39
79
|
}
|
|
@@ -100,6 +140,13 @@ export async function handleWatchQueryOperations(args) {
|
|
|
100
140
|
}
|
|
101
141
|
return obj;
|
|
102
142
|
});
|
|
143
|
+
for (const obj of queryResult.objects) {
|
|
144
|
+
try {
|
|
145
|
+
await annotateObjectMonetaryFields(obj, validated.network);
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
}
|
|
149
|
+
}
|
|
103
150
|
}
|
|
104
151
|
result = { query_type: "onchain_objects", result: queryResult };
|
|
105
152
|
break;
|
|
@@ -113,7 +160,37 @@ export async function handleWatchQueryOperations(args) {
|
|
|
113
160
|
no_cache: validated.no_cache,
|
|
114
161
|
network: validated.network,
|
|
115
162
|
});
|
|
116
|
-
|
|
163
|
+
const qr = queryResult;
|
|
164
|
+
if (qr && typeof qr === "object" && typeof qr.balance === "bigint") {
|
|
165
|
+
const tokenType = qr.token_type;
|
|
166
|
+
qr.balance = qr.balance.toString();
|
|
167
|
+
if (Array.isArray(qr.received)) {
|
|
168
|
+
for (const item of qr.received) {
|
|
169
|
+
if (item && typeof item.balance === "bigint") {
|
|
170
|
+
item.balance = item.balance.toString();
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (tokenType) {
|
|
175
|
+
try {
|
|
176
|
+
const displays = {
|
|
177
|
+
balance: await formatChainValue(qr.balance, tokenType, validated.network),
|
|
178
|
+
};
|
|
179
|
+
if (Array.isArray(qr.received)) {
|
|
180
|
+
for (let i = 0; i < qr.received.length; i++) {
|
|
181
|
+
const b = qr.received[i]?.balance;
|
|
182
|
+
if (b !== undefined && b !== null) {
|
|
183
|
+
displays[`received[${i}].balance`] = await formatChainValue(b, tokenType, validated.network);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
qr._money_display = displays;
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
result = { query_type: "onchain_received", result: qr };
|
|
117
194
|
break;
|
|
118
195
|
}
|
|
119
196
|
case "onchain_transaction": {
|
|
@@ -122,6 +199,11 @@ export async function handleWatchQueryOperations(args) {
|
|
|
122
199
|
no_cache: validated.no_cache,
|
|
123
200
|
network: validated.network,
|
|
124
201
|
});
|
|
202
|
+
try {
|
|
203
|
+
await annotateBalanceChanges(queryResult?.balance_changes, validated.network);
|
|
204
|
+
}
|
|
205
|
+
catch {
|
|
206
|
+
}
|
|
125
207
|
result = { query_type: "onchain_transaction", result: queryResult };
|
|
126
208
|
break;
|
|
127
209
|
}
|
|
@@ -152,8 +234,20 @@ export async function handleWatchQueryOperations(args) {
|
|
|
152
234
|
result = { query_type: "onchain_address_activity", result: queryResult };
|
|
153
235
|
break;
|
|
154
236
|
}
|
|
237
|
+
case "token_value_convert": {
|
|
238
|
+
const hasRaw = validated.raw !== undefined;
|
|
239
|
+
const hasUnit = validated.unit !== undefined;
|
|
240
|
+
if (hasRaw === hasUnit) {
|
|
241
|
+
throw new Error(`token_value_convert: provide EXACTLY ONE of 'raw' (u64 smallest units → unit value) ` +
|
|
242
|
+
`or 'unit' (unit value → u64 raw). Received raw=${JSON.stringify(validated.raw)}, ` +
|
|
243
|
+
`unit=${JSON.stringify(validated.unit)}.`);
|
|
244
|
+
}
|
|
245
|
+
const conversion = await convertTokenValue(validated.token_type, hasRaw ? { raw: validated.raw } : { unit: validated.unit }, validated.network);
|
|
246
|
+
result = { query_type: "token_value_convert", result: conversion };
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
155
249
|
default:
|
|
156
|
-
throw new Error(`Unknown query type. Valid query_types are: "local_mark_list", "account_list", "local_info_list", "token_list", "account_balance", "local_names", "onchain_personal_profile", "onchain_objects", "onchain_received", "onchain_transaction", "onchain_object_history", "onchain_address_activity". For table queries, use the "onchain_table_data" tool.`);
|
|
250
|
+
throw new Error(`Unknown query type. Valid query_types are: "local_mark_list", "account_list", "local_info_list", "token_list", "account_balance", "local_names", "onchain_personal_profile", "onchain_objects", "onchain_received", "onchain_transaction", "onchain_object_history", "onchain_address_activity", "token_value_convert". For table queries, use the "onchain_table_data" tool.`);
|
|
157
251
|
}
|
|
158
252
|
return {
|
|
159
253
|
content: [{ type: "text", text: JSON.stringify({ result }) }],
|
|
@@ -202,6 +296,14 @@ export async function handleOnchainTableData(args) {
|
|
|
202
296
|
parent: validated.parent, address: validated.address,
|
|
203
297
|
no_cache: validated.no_cache, network: validated.network,
|
|
204
298
|
});
|
|
299
|
+
if (queryResult) {
|
|
300
|
+
try {
|
|
301
|
+
const parentToken = await resolveParentObjectTokenType(validated.parent, validated.network);
|
|
302
|
+
await annotateTableItemMonetaryFields(queryResult, parentToken, validated.network);
|
|
303
|
+
}
|
|
304
|
+
catch {
|
|
305
|
+
}
|
|
306
|
+
}
|
|
205
307
|
result = { query_type: "onchain_table_item_reward_record", result: queryResult };
|
|
206
308
|
break;
|
|
207
309
|
}
|
|
@@ -218,6 +320,14 @@ export async function handleOnchainTableData(args) {
|
|
|
218
320
|
parent: validated.parent, address: validated.address,
|
|
219
321
|
no_cache: validated.no_cache, network: validated.network,
|
|
220
322
|
});
|
|
323
|
+
if (queryResult) {
|
|
324
|
+
try {
|
|
325
|
+
const parentToken = await resolveParentObjectTokenType(validated.parent, validated.network);
|
|
326
|
+
await annotateTableItemMonetaryFields(queryResult, parentToken, validated.network);
|
|
327
|
+
}
|
|
328
|
+
catch {
|
|
329
|
+
}
|
|
330
|
+
}
|
|
221
331
|
result = { query_type: "onchain_table_item_treasury_history", result: queryResult };
|
|
222
332
|
break;
|
|
223
333
|
}
|
|
@@ -298,6 +408,11 @@ export async function handleOnchainEvents(args) {
|
|
|
298
408
|
no_cache: validated.no_cache,
|
|
299
409
|
network: validated.network,
|
|
300
410
|
});
|
|
411
|
+
try {
|
|
412
|
+
await annotateEventsMonetaryFields(queryResult?.data, validated.network);
|
|
413
|
+
}
|
|
414
|
+
catch {
|
|
415
|
+
}
|
|
301
416
|
return {
|
|
302
417
|
content: [{ type: "text", text: JSON.stringify({ result: queryResult }) }],
|
|
303
418
|
structuredContent: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { processSchemaQuery, } from "../../schema-query/index.js";
|
|
1
|
+
import { processSchemaQuery, EXAMPLES_DIR, } from "../../schema-query/index.js";
|
|
2
2
|
import { strictParse } from "../../schema/index.js";
|
|
3
3
|
import { SchemaQueryInputSchema } from "../../schema/schema-query/index.js";
|
|
4
4
|
export async function handleSchemaQuery(args) {
|
|
@@ -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);
|
|
@@ -92,6 +94,68 @@ export async function handleSchemaQuery(args) {
|
|
|
92
94
|
textContent += "\n\nNo schemas found. Try 'list' to browse all available schemas, or use a broader search term.";
|
|
93
95
|
}
|
|
94
96
|
break;
|
|
97
|
+
case "search_examples": {
|
|
98
|
+
const items = (Array.isArray(data) ? data : []);
|
|
99
|
+
if (items.length > 0) {
|
|
100
|
+
textContent += `\n\nFound ${items.length} example(s) matching '${request.query ?? ""}':\n`;
|
|
101
|
+
for (const item of items) {
|
|
102
|
+
textContent += `\n • [score: ${item.score}] ${item.file}`;
|
|
103
|
+
textContent += `\n Title: ${item.title}`;
|
|
104
|
+
textContent += `\n Industry: ${item.industry} | Operation: ${item.operation_type} | Verified: ${item.verified ? "yes" : "no"}`;
|
|
105
|
+
textContent += `\n Tags: ${item.tags.join(", ")}`;
|
|
106
|
+
textContent += `\n Matched fields: ${item.matched_fields.join(", ")}`;
|
|
107
|
+
const descPreview = item.description.length > 120
|
|
108
|
+
? `${item.description.slice(0, 120)}...`
|
|
109
|
+
: item.description;
|
|
110
|
+
textContent += `\n Description: ${descPreview}`;
|
|
111
|
+
textContent += "\n";
|
|
112
|
+
}
|
|
113
|
+
textContent += `\n To view the full example JSON, read files from: ${EXAMPLES_DIR}`;
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
textContent += "\n\nNo examples found. Try broader terms like 'service', 'machine', 'guard', 'permission', or an industry name like 'rental' or 'retail'.";
|
|
117
|
+
}
|
|
118
|
+
break;
|
|
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
|
+
}
|
|
95
159
|
default:
|
|
96
160
|
throw new Error(`Unknown schema_query action: ${String(request.action)}`);
|
|
97
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.d.ts
CHANGED
|
@@ -2,6 +2,14 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
2
2
|
import type { ToolEntry, ToolDispatchResult, DispatchOptions } from "./types.js";
|
|
3
3
|
export declare const TOOL_REGISTRY: ToolEntry[];
|
|
4
4
|
export declare const TOOL_REGISTRY_MAP: Map<string, ToolEntry>;
|
|
5
|
+
export interface StructuredSchemaError {
|
|
6
|
+
path: string;
|
|
7
|
+
code: string;
|
|
8
|
+
message: string;
|
|
9
|
+
expected?: string;
|
|
10
|
+
received_value?: unknown;
|
|
11
|
+
suggestion: string;
|
|
12
|
+
}
|
|
5
13
|
export declare function dispatchToolCall(name: string, args: unknown, options?: DispatchOptions): Promise<ToolDispatchResult>;
|
|
6
14
|
export interface ToolListEntry {
|
|
7
15
|
name: string;
|