@wowok/agent-mcp 2.7.1 → 2.7.2
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/config/index.js +1 -1
- package/dist/config/runtime.js +1 -238
- package/dist/customer/customer-advice.js +1 -130
- package/dist/customer/index.js +1 -11
- package/dist/customer/industry-risks.js +1 -438
- package/dist/customer/info-puzzle.js +1 -681
- package/dist/customer/order-monitor.js +1 -328
- package/dist/customer/order-strategy.js +1 -373
- package/dist/customer/post-purchase.js +1 -351
- package/dist/customer/preorder-compare.js +1 -34
- package/dist/customer/reminder-system.js +1 -316
- package/dist/customer/risk-assessment.js +1 -397
- package/dist/customer/types.js +1 -13
- package/dist/customer/user-preferences.js +1 -460
- package/dist/evaluation/arbitration-game.d.ts +9 -2
- package/dist/evaluation/arbitration-game.js +1 -48
- package/dist/evaluation/builtins/demand-match.js +1 -153
- package/dist/evaluation/builtins/index.js +1 -10
- package/dist/evaluation/builtins/service-risk.js +1 -55
- package/dist/evaluation/capability.js +1 -13
- package/dist/evaluation/composer.js +1 -40
- package/dist/evaluation/engine.js +1 -175
- package/dist/evaluation/extract.js +1 -115
- package/dist/evaluation/game-strategy.d.ts +27 -0
- package/dist/evaluation/game-strategy.js +1 -0
- package/dist/evaluation/gap.js +1 -100
- package/dist/evaluation/index.d.ts +1 -0
- package/dist/evaluation/index.js +1 -11
- package/dist/evaluation/node-game.d.ts +31 -3
- package/dist/evaluation/node-game.js +1 -57
- package/dist/evaluation/region.js +1 -36
- package/dist/evaluation/types.d.ts +1 -0
- package/dist/evaluation/types.js +1 -1
- package/dist/evaluation/user-injection.js +1 -27
- package/dist/experience/experience-reuse.js +1 -103
- package/dist/experience/index.js +1 -5
- package/dist/experience/intent-distill.js +1 -83
- package/dist/experience/realtime-feedback.js +1 -94
- package/dist/experience/types.js +1 -1
- package/dist/experience/user-profile.js +1 -171
- package/dist/extensions/business-modules.js +1 -287
- package/dist/extensions/capability-manifest.js +1 -781
- package/dist/extensions/constraint-registry.js +1 -198
- package/dist/extensions/index.js +1 -6
- package/dist/extensions/metric-registry.js +1 -257
- package/dist/extensions/mode-evaluator.js +1 -170
- package/dist/extensions/modes.js +1 -499
- package/dist/extensions/registry.js +1 -717
- package/dist/extensions/types.js +1 -1
- package/dist/harness/auto-escalation.js +1 -68
- package/dist/harness/checkpoint.js +1 -129
- package/dist/harness/index.js +1 -78
- package/dist/harness/plan.js +1 -315
- package/dist/harness/recover.js +1 -139
- package/dist/harness/types.js +1 -1
- package/dist/harness/verify.js +1 -237
- package/dist/index.js +1 -273
- package/dist/intent/enrich.js +1 -67
- package/dist/intent/index.js +1 -60
- package/dist/intent/matcher.js +1 -81
- package/dist/intent/store.js +1 -55
- package/dist/intent/types.js +1 -10
- package/dist/knowledge/acquisition-flywheel.js +1 -192
- package/dist/knowledge/allocation-confirm.js +1 -534
- package/dist/knowledge/allocation-context.js +1 -249
- package/dist/knowledge/allocation-ledger.js +1 -463
- package/dist/knowledge/allocation-puzzle.js +1 -298
- package/dist/knowledge/allocation-risk.js +1 -568
- package/dist/knowledge/allocation-templates.js +1 -970
- package/dist/knowledge/allocation-translation.js +1 -585
- package/dist/knowledge/arb-risk.js +1 -210
- package/dist/knowledge/arbitration-confirm.js +1 -559
- package/dist/knowledge/arbitration-context.js +1 -505
- package/dist/knowledge/arbitration-ledger.js +1 -521
- package/dist/knowledge/arbitration-puzzle.js +1 -304
- package/dist/knowledge/arbitration-risk.js +1 -423
- package/dist/knowledge/arbitration-templates.js +1 -276
- package/dist/knowledge/arbitration-translation.js +1 -487
- package/dist/knowledge/arbitration-trust.js +1 -117
- package/dist/knowledge/audit-rules.js +1 -141
- package/dist/knowledge/bridge-risk.js +1 -263
- package/dist/knowledge/contact-risk.js +1 -200
- package/dist/knowledge/contact-templates.js +1 -60
- package/dist/knowledge/demand-confirm.js +1 -206
- package/dist/knowledge/demand-matching.js +1 -132
- package/dist/knowledge/demand-risk.js +1 -240
- package/dist/knowledge/demand-translation.js +1 -354
- package/dist/knowledge/deployment-scanner.js +1 -823
- package/dist/knowledge/dynamic-pricing.js +1 -87
- package/dist/knowledge/examples-scanner-cli.js +1 -26
- package/dist/knowledge/examples-scanner.js +1 -843
- package/dist/knowledge/flywheel-loop.js +1 -404
- package/dist/knowledge/fund-layer.js +1 -973
- package/dist/knowledge/glossary.js +1 -211
- package/dist/knowledge/guard-confirm.js +1 -406
- package/dist/knowledge/guard-context.js +1 -287
- package/dist/knowledge/guard-design-patterns.js +1 -360
- package/dist/knowledge/guard-ledger.js +1 -260
- package/dist/knowledge/guard-lint.js +1 -670
- package/dist/knowledge/guard-migration.js +1 -228
- package/dist/knowledge/guard-puzzle.js +1 -805
- package/dist/knowledge/guard-render.js +1 -700
- package/dist/knowledge/guard-risk.js +1 -1879
- package/dist/knowledge/guard-submission-prompt.js +1 -171
- package/dist/knowledge/guard-templates.js +1 -1105
- package/dist/knowledge/guard-translation.js +1 -1119
- package/dist/knowledge/index.js +1 -436
- package/dist/knowledge/industry-evolution.js +1 -323
- package/dist/knowledge/industry-generalizer.js +1 -381
- package/dist/knowledge/industry-registry.js +1 -174
- package/dist/knowledge/intent-metrics.d.ts +4 -3
- package/dist/knowledge/intent-metrics.js +1 -566
- package/dist/knowledge/machine-confirm.js +1 -559
- package/dist/knowledge/machine-context.js +1 -833
- package/dist/knowledge/machine-ledger.js +1 -338
- package/dist/knowledge/machine-puzzle.js +1 -494
- package/dist/knowledge/machine-render.js +1 -565
- package/dist/knowledge/machine-risk.js +1 -669
- package/dist/knowledge/machine-templates.js +1 -1597
- package/dist/knowledge/machine-topology.js +1 -234
- package/dist/knowledge/machine-translation.js +1 -513
- package/dist/knowledge/mcp-schema-audit-cli.js +1 -45
- package/dist/knowledge/mcp-schema-audit.js +1 -777
- package/dist/knowledge/onchain-constants.js +1 -35
- package/dist/knowledge/order-confirm.js +1 -573
- package/dist/knowledge/order-context.js +1 -390
- package/dist/knowledge/order-ledger.js +1 -341
- package/dist/knowledge/order-puzzle.js +1 -255
- package/dist/knowledge/order-risk.js +1 -653
- package/dist/knowledge/order-templates.js +1 -368
- package/dist/knowledge/order-translation.js +1 -550
- package/dist/knowledge/overrides-loader.js +1 -65
- package/dist/knowledge/passport-confirm.js +1 -531
- package/dist/knowledge/passport-context.js +1 -306
- package/dist/knowledge/passport-ledger.js +1 -282
- package/dist/knowledge/passport-puzzle.js +1 -333
- package/dist/knowledge/passport-risk.js +1 -450
- package/dist/knowledge/passport-templates.js +1 -568
- package/dist/knowledge/passport-translation.js +1 -516
- package/dist/knowledge/payment-risk.js +1 -249
- package/dist/knowledge/permission-confirm.js +1 -426
- package/dist/knowledge/permission-context.js +1 -224
- package/dist/knowledge/permission-ledger.js +1 -403
- package/dist/knowledge/permission-puzzle.js +1 -173
- package/dist/knowledge/permission-risk.js +1 -411
- package/dist/knowledge/permission-templates.js +1 -234
- package/dist/knowledge/permission-translation.js +1 -350
- package/dist/knowledge/personal-risk.js +1 -212
- package/dist/knowledge/process-model.js +1 -160
- package/dist/knowledge/progress-confirm.js +1 -456
- package/dist/knowledge/progress-context.js +1 -452
- package/dist/knowledge/progress-ledger.js +1 -330
- package/dist/knowledge/progress-puzzle.js +1 -219
- package/dist/knowledge/progress-risk.js +1 -461
- package/dist/knowledge/progress-templates.js +1 -228
- package/dist/knowledge/progress-translation.js +1 -405
- package/dist/knowledge/proof-confirm.js +1 -187
- package/dist/knowledge/proof-risk.js +1 -207
- package/dist/knowledge/proof-translation.js +1 -283
- package/dist/knowledge/registrar-risk.js +1 -217
- package/dist/knowledge/repository-confirm.js +1 -286
- package/dist/knowledge/repository-risk.js +1 -373
- package/dist/knowledge/repository-translation.js +1 -445
- package/dist/knowledge/reputation-rules.js +1 -99
- package/dist/knowledge/resource-risk.js +1 -157
- package/dist/knowledge/reward-confirm.js +1 -526
- package/dist/knowledge/reward-context.js +1 -504
- package/dist/knowledge/reward-ledger.js +1 -502
- package/dist/knowledge/reward-puzzle.js +1 -300
- package/dist/knowledge/reward-risk.js +1 -627
- package/dist/knowledge/reward-templates.js +1 -197
- package/dist/knowledge/reward-translation.js +1 -501
- package/dist/knowledge/safety-rules.js +1 -404
- package/dist/knowledge/scenario-modes.js +1 -321
- package/dist/knowledge/service-confirm.js +1 -807
- package/dist/knowledge/service-context.js +1 -403
- package/dist/knowledge/service-ledger.js +1 -609
- package/dist/knowledge/service-puzzle.js +1 -236
- package/dist/knowledge/service-risk.js +1 -651
- package/dist/knowledge/service-templates.js +1 -456
- package/dist/knowledge/service-translation.js +1 -622
- package/dist/knowledge/template-registry.js +1 -353
- package/dist/knowledge/tool-constraints.js +1 -195
- package/dist/knowledge/tools-reference.js +1 -178
- package/dist/knowledge/treasury-confirm.js +1 -512
- package/dist/knowledge/treasury-context.js +1 -363
- package/dist/knowledge/treasury-ledger.js +1 -300
- package/dist/knowledge/treasury-puzzle.js +1 -216
- package/dist/knowledge/treasury-risk.js +1 -440
- package/dist/knowledge/treasury-templates.js +1 -358
- package/dist/knowledge/treasury-translation.js +1 -498
- package/dist/knowledge/trust-metrics.js +1 -198
- package/dist/knowledge/util-risk.js +1 -135
- package/dist/loop-engineering/aggregate.js +1 -132
- package/dist/loop-engineering/context-collect.js +1 -83
- package/dist/loop-engineering/diagnose.js +1 -273
- package/dist/loop-engineering/improve.js +1 -405
- package/dist/loop-engineering/index.js +1 -4
- package/dist/loop-engineering/pipeline.js +1 -56
- package/dist/mode-market/index.js +1 -3
- package/dist/mode-market/registry.js +1 -124
- package/dist/mode-market/review.js +1 -214
- package/dist/mode-market/submission.js +1 -85
- package/dist/participation/collaborator-interest.d.ts +23 -0
- package/dist/participation/collaborator-interest.js +1 -0
- package/dist/participation/customer-interest.d.ts +25 -0
- package/dist/participation/customer-interest.js +1 -0
- package/dist/participation/merchant-interest.js +1 -100
- package/dist/participation/radar-core.d.ts +13 -3
- package/dist/participation/radar-core.js +1 -269
- package/dist/participation/supplier-interest.d.ts +25 -0
- package/dist/participation/supplier-interest.js +1 -0
- package/dist/persona/analyzer.js +1 -66
- package/dist/persona/bridge.js +1 -86
- package/dist/persona/defaults.js +1 -195
- package/dist/persona/experience-bridge.js +1 -23
- package/dist/persona/index.js +1 -71
- package/dist/persona/model.js +1 -111
- package/dist/persona/store.js +1 -62
- package/dist/persona/types.d.ts +3 -1
- package/dist/persona/types.js +1 -5
- package/dist/project/business-puzzle.js +1 -383
- package/dist/project/context-assembly.js +1 -254
- package/dist/project/deployment-bridge.js +1 -120
- package/dist/project/deployment-doc.js +1 -1126
- package/dist/project/edit-planner.js +1 -1342
- package/dist/project/evaluation.js +1 -2011
- package/dist/project/game-theory.js +1 -177
- package/dist/project/graph-builder.js +1 -656
- package/dist/project/graph.js +1 -340
- package/dist/project/handlers.js +1 -1784
- package/dist/project/index.d.ts +1 -0
- package/dist/project/index.js +1 -301
- package/dist/project/intent-analyzer.js +1 -149
- package/dist/project/machine-nodes.js +1 -36
- package/dist/project/merchant-guide.js +1 -264
- package/dist/project/migration.js +1 -125
- package/dist/project/mode-actions.js +1 -309
- package/dist/project/namespace.js +1 -206
- package/dist/project/participation-radar.js +1 -428
- package/dist/project/pipeline-actions.js +1 -109
- package/dist/project/project-store.js +1 -422
- package/dist/project/query.js +1 -153
- package/dist/project/reverse-mapping.d.ts +34 -0
- package/dist/project/reverse-mapping.js +1 -0
- package/dist/project/risk-aggregator.js +1 -295
- package/dist/project/rollback-policy.js +1 -290
- package/dist/project/semantic-assembler.js +1 -345
- package/dist/project/semantic-graph.js +1 -292
- package/dist/project/stage-gate.js +1 -369
- package/dist/project/substep-trace.js +1 -332
- package/dist/project/task-tracker.js +1 -78
- package/dist/role/derivation.d.ts +18 -0
- package/dist/role/derivation.js +1 -0
- package/dist/role/index.d.ts +5 -0
- package/dist/role/index.js +1 -0
- package/dist/role/model.d.ts +8 -0
- package/dist/role/model.js +1 -0
- package/dist/role/resolution.d.ts +11 -0
- package/dist/role/resolution.js +1 -0
- package/dist/role/types.d.ts +11 -0
- package/dist/role/types.js +1 -0
- package/dist/rules.js +1 -52
- package/dist/safety/confirm-gate.js +1 -88
- package/dist/safety/index.js +1 -3
- package/dist/safety/preview.js +1 -52
- package/dist/schema/call/allocation.js +1 -34
- package/dist/schema/call/arbitration.js +1 -113
- package/dist/schema/call/base.d.ts +15 -15
- package/dist/schema/call/base.js +1 -370
- package/dist/schema/call/bridge-handler.js +1 -265
- package/dist/schema/call/bridge.d.ts +7 -7
- package/dist/schema/call/bridge.js +1 -458
- package/dist/schema/call/contact.js +1 -37
- package/dist/schema/call/demand.js +1 -47
- package/dist/schema/call/guard.js +1 -161
- package/dist/schema/call/handler.js +1 -322
- package/dist/schema/call/index.js +1 -20
- package/dist/schema/call/machine.js +1 -193
- package/dist/schema/call/order.js +1 -35
- package/dist/schema/call/payment.js +1 -37
- package/dist/schema/call/permission-handler.js +1 -54
- package/dist/schema/call/permission.js +1 -105
- package/dist/schema/call/personal.js +1 -78
- package/dist/schema/call/progress.js +1 -47
- package/dist/schema/call/proof.js +1 -33
- package/dist/schema/call/repository.js +1 -77
- package/dist/schema/call/reward.js +1 -30
- package/dist/schema/call/semantic.js +1 -1679
- package/dist/schema/call/service.js +1 -184
- package/dist/schema/call/treasury.js +1 -71
- package/dist/schema/common/index.js +1 -407
- package/dist/schema/config/index.js +1 -68
- package/dist/schema/evaluation/index.d.ts +213 -16
- package/dist/schema/evaluation/index.js +1 -356
- package/dist/schema/index.js +1 -17
- package/dist/schema/intent-radar/index.d.ts +13 -13
- package/dist/schema/intent-radar/index.js +1 -89
- package/dist/schema/local/index.d.ts +21 -21
- package/dist/schema/local/index.js +1 -927
- package/dist/schema/local/wip.js +1 -187
- package/dist/schema/messenger/index.d.ts +7 -7
- package/dist/schema/messenger/index.js +1 -475
- package/dist/schema/operations.d.ts +7 -7
- package/dist/schema/operations.js +1 -520
- package/dist/schema/persona/index.d.ts +54 -54
- package/dist/schema/persona/index.js +1 -148
- package/dist/schema/project/index.d.ts +94 -48
- package/dist/schema/project/index.js +1 -2057
- package/dist/schema/query/index.d.ts +423 -7
- package/dist/schema/query/index.js +1 -1646
- package/dist/schema/schema-query/index.js +1 -104
- package/dist/schema/schema-version.js +1 -76
- package/dist/schema/sync-layer4.js +1 -286
- package/dist/schema/task-status.js +1 -36
- package/dist/schema/trust/index.js +1 -314
- package/dist/schema/utils/guard-parser.js +1 -419
- package/dist/schema/utils/guard-query-utils.js +1 -46
- package/dist/schema/utils/node-parser.js +1 -369
- package/dist/schema/utils/object-type-utils.js +1 -35
- package/dist/schema/utils/permission-index-utils.js +1 -7
- package/dist/schema/utils/permission-machine-check.js +1 -121
- package/dist/schema/utils/skills-recommendation.js +1 -77
- package/dist/schema-query/index.js +1 -810
- package/dist/schemas/account_operation.output.json +5 -2
- package/dist/schemas/bridge_operation.output.json +5 -2
- package/dist/schemas/evaluation_operation.output.json +112 -7
- package/dist/schemas/evaluation_operation.schema.json +93 -6
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/intent_radar.output.json +4 -1
- package/dist/schemas/intent_radar.schema.json +4 -1
- package/dist/schemas/local_info_operation.output.json +5 -2
- package/dist/schemas/local_mark_operation.output.json +5 -2
- package/dist/schemas/messenger_operation.output.json +5 -2
- package/dist/schemas/onchain_events.output.json +5 -2
- package/dist/schemas/onchain_operations.output.json +5 -2
- package/dist/schemas/onchain_operations.schema.json +4 -4
- package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
- package/dist/schemas/onchain_operations_machine.schema.json +2 -2
- package/dist/schemas/onchain_operations_service.schema.json +1 -1
- package/dist/schemas/onchain_table_data.output.json +6 -3
- package/dist/schemas/persona_operation.output.json +4 -1
- package/dist/schemas/persona_operation.schema.json +4 -1
- package/dist/schemas/project_operation.output.json +28 -8
- package/dist/schemas/query_toolkit.output.json +8 -5
- package/dist/schemas/wowok_buildin_info.output.json +132 -0
- package/dist/schemas/wowok_buildin_info.schema.json +14 -0
- package/dist/telemetry/index.js +1 -112
- package/dist/telemetry/redact.js +1 -23
- package/dist/telemetry/storage.js +1 -80
- package/dist/tools/handlers/bridge.js +1 -1
- package/dist/tools/handlers/config.js +1 -74
- package/dist/tools/handlers/evaluation.js +1 -123
- package/dist/tools/handlers/file-export.js +1 -90
- package/dist/tools/handlers/intent-radar.js +1 -76
- package/dist/tools/handlers/local.js +1 -53
- package/dist/tools/handlers/messenger.js +1 -188
- package/dist/tools/handlers/onchain.js +1 -1180
- package/dist/tools/handlers/persona.js +1 -89
- package/dist/tools/handlers/project.js +1 -211
- package/dist/tools/handlers/query.js +1 -434
- package/dist/tools/handlers/schema-query.js +1 -176
- package/dist/tools/handlers/task-status.js +1 -26
- package/dist/tools/handlers/trust.js +1 -380
- package/dist/tools/handlers/wip.js +1 -90
- package/dist/tools/index.js +1 -1382
- package/dist/tools/retry.js +1 -85
- package/dist/tools/rules-hook.js +1 -23
- package/dist/tools/shared.js +1 -130
- package/dist/tools/types.js +1 -1
- package/dist/tools/upgrade-check.d.ts +19 -0
- package/dist/tools/upgrade-check.js +1 -0
- package/dist/tools/wip-deploy-assist.js +1 -306
- package/dist/tools/wrap.js +1 -500
- package/package.json +4 -2
|
@@ -1,26 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
export async function handleQueryTaskStatus(args) {
|
|
3
|
-
const validated = (args && typeof args === "object" ? args : {});
|
|
4
|
-
if (validated.task_id) {
|
|
5
|
-
const task = TaskTracker.get(validated.task_id);
|
|
6
|
-
const result = {
|
|
7
|
-
task_id: validated.task_id,
|
|
8
|
-
task: task ?? null,
|
|
9
|
-
tasks: undefined,
|
|
10
|
-
};
|
|
11
|
-
return {
|
|
12
|
-
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
13
|
-
structuredContent: result,
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
const tasks = TaskTracker.list(validated.project_id).slice(0, 50);
|
|
17
|
-
const result = {
|
|
18
|
-
task_id: undefined,
|
|
19
|
-
task: null,
|
|
20
|
-
tasks,
|
|
21
|
-
};
|
|
22
|
-
return {
|
|
23
|
-
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
24
|
-
structuredContent: result,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
1
|
+
import{TaskTracker}from'../../project/task-tracker.js';export async function handleQueryTaskStatus(a){const b=a&&typeof a==='object'?a:{};if(b['task_id']){const e=TaskTracker['get'](b['task_id']),f={'task_id':b['task_id'],'task':e??null,'tasks':undefined};return{'content':[{'type':'text','text':JSON['stringify'](f)}],'structuredContent':f};}const c=TaskTracker['list'](b['project_id'])['slice'](0x0,0x32),d={'task_id':undefined,'task':null,'tasks':c};return{'content':[{'type':'text','text':JSON['stringify'](d)}],'structuredContent':d};}
|
|
@@ -1,380 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { query_objects, query_personal, } from "@wowok/wowok";
|
|
3
|
-
import { computeServiceTrustScore, } from "../../knowledge/index.js";
|
|
4
|
-
import { assembleInfoPuzzle, assemblePreorderAdvice, assessRisk, buildPreorderComparison, getDefaultPreferences, inferIndustry, mergePreferences, validatePreferences, } from "../../customer/index.js";
|
|
5
|
-
import { getProfile } from "../../experience/user-profile.js";
|
|
6
|
-
function extractTrustMetrics(serviceObj) {
|
|
7
|
-
const data = serviceObj?.data ?? serviceObj ?? {};
|
|
8
|
-
const sales = Array.isArray(data.sales) ? data.sales : [];
|
|
9
|
-
const activeSales = sales.filter((s) => s && !s.suspension);
|
|
10
|
-
void activeSales;
|
|
11
|
-
const compensationFund = data.compensation_fund;
|
|
12
|
-
const compBalance = (() => {
|
|
13
|
-
if (compensationFund === null || compensationFund === undefined)
|
|
14
|
-
return undefined;
|
|
15
|
-
if (typeof compensationFund === "bigint")
|
|
16
|
-
return compensationFund;
|
|
17
|
-
if (typeof compensationFund === "number")
|
|
18
|
-
return BigInt(compensationFund);
|
|
19
|
-
if (typeof compensationFund === "string") {
|
|
20
|
-
try {
|
|
21
|
-
return BigInt(compensationFund);
|
|
22
|
-
}
|
|
23
|
-
catch {
|
|
24
|
-
return undefined;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
if (typeof compensationFund === "object") {
|
|
28
|
-
const bal = compensationFund.balance;
|
|
29
|
-
if (bal === null || bal === undefined)
|
|
30
|
-
return undefined;
|
|
31
|
-
try {
|
|
32
|
-
return BigInt(bal);
|
|
33
|
-
}
|
|
34
|
-
catch {
|
|
35
|
-
return undefined;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return undefined;
|
|
39
|
-
})();
|
|
40
|
-
return {
|
|
41
|
-
arbitrationCases: Array.isArray(data.arbitrations) ? data.arbitrations.length : undefined,
|
|
42
|
-
compensationFundBalance: compBalance,
|
|
43
|
-
hasMachineBound: typeof data.machine === "string" && data.machine.length > 0,
|
|
44
|
-
hasBuyGuard: typeof data.buy_guard === "string" && data.buy_guard.length > 0,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
function buildPuzzleRawData(serviceObj, orderAmount, trustScore, serviceOwner) {
|
|
48
|
-
const data = serviceObj?.data ?? serviceObj ?? {};
|
|
49
|
-
const sales = Array.isArray(data.sales) ? data.sales : [];
|
|
50
|
-
const order_allocators = data.order_allocators
|
|
51
|
-
? Array.isArray(data.order_allocators.allocators)
|
|
52
|
-
? data.order_allocators
|
|
53
|
-
: { allocators: data.order_allocators }
|
|
54
|
-
: undefined;
|
|
55
|
-
const serviceRaw = {
|
|
56
|
-
name: data.name ?? serviceObj?.id,
|
|
57
|
-
bPublished: data.bPublished,
|
|
58
|
-
bPaused: data.bPaused,
|
|
59
|
-
price: sales[0]?.price != null ? String(sales[0].price) : "0",
|
|
60
|
-
priceRaw: sales[0]?.price != null ? BigInt(sales[0].price) : 0n,
|
|
61
|
-
token_type: sales[0]?.price_type ?? (compensation_fund_token(data) ?? "0x2::wow::WOW"),
|
|
62
|
-
sales,
|
|
63
|
-
machine: data.machine ?? undefined,
|
|
64
|
-
buy_guard: data.buy_guard ?? undefined,
|
|
65
|
-
customer_required: data.customer_required,
|
|
66
|
-
arbitrations: data.arbitrations,
|
|
67
|
-
compensation_fund: data.compensation_fund
|
|
68
|
-
? { balance: extractBalance(data.compensation_fund) }
|
|
69
|
-
: undefined,
|
|
70
|
-
compensation_lock_duration: typeof data.setting_lock_duration === "number"
|
|
71
|
-
? data.setting_lock_duration
|
|
72
|
-
: undefined,
|
|
73
|
-
um: data.um ?? undefined,
|
|
74
|
-
order_allocators: order_allocators ? [order_allocators] : undefined,
|
|
75
|
-
};
|
|
76
|
-
return {
|
|
77
|
-
service: serviceRaw,
|
|
78
|
-
order_amount: orderAmount,
|
|
79
|
-
trust_score: trustScore,
|
|
80
|
-
service_owner: serviceOwner,
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
function compensation_fund_token(data) {
|
|
84
|
-
if (data?.compensation_fund && typeof data.compensation_fund === "object") {
|
|
85
|
-
return data.compensation_fund.token_type;
|
|
86
|
-
}
|
|
87
|
-
return undefined;
|
|
88
|
-
}
|
|
89
|
-
function extractBalance(b) {
|
|
90
|
-
if (b === null || b === undefined)
|
|
91
|
-
return 0n;
|
|
92
|
-
if (typeof b === "bigint")
|
|
93
|
-
return b;
|
|
94
|
-
if (typeof b === "number")
|
|
95
|
-
return BigInt(b);
|
|
96
|
-
if (typeof b === "string") {
|
|
97
|
-
try {
|
|
98
|
-
return BigInt(b);
|
|
99
|
-
}
|
|
100
|
-
catch {
|
|
101
|
-
return 0n;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
if (typeof b === "object") {
|
|
105
|
-
const bal = b.balance;
|
|
106
|
-
if (bal === null || bal === undefined)
|
|
107
|
-
return 0n;
|
|
108
|
-
try {
|
|
109
|
-
return BigInt(bal);
|
|
110
|
-
}
|
|
111
|
-
catch {
|
|
112
|
-
return 0n;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return 0n;
|
|
116
|
-
}
|
|
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) {
|
|
186
|
-
const depth = (validated.depth ?? "evaluate");
|
|
187
|
-
const queryResult = await query_objects({
|
|
188
|
-
objects: [validated.service],
|
|
189
|
-
no_cache: validated.no_cache,
|
|
190
|
-
network: validated.network,
|
|
191
|
-
});
|
|
192
|
-
const objects = queryResult?.objects;
|
|
193
|
-
if (!objects || !Array.isArray(objects) || objects.length === 0) {
|
|
194
|
-
throw new Error(`Service object not found for '${validated.service}'. ` +
|
|
195
|
-
`Verify the ID/name and network, or use query_toolkit with query_type='onchain_objects' to debug.`);
|
|
196
|
-
}
|
|
197
|
-
const serviceObj = objects[0];
|
|
198
|
-
const objType = serviceObj?.data?.object_type ?? serviceObj?.object_type ?? serviceObj?.type;
|
|
199
|
-
if (objType && typeof objType === "string" && !objType.includes("Service")) {
|
|
200
|
-
throw new Error(`Object '${validated.service}' is not a Service (type: ${objType}). ` +
|
|
201
|
-
`trust_score only evaluates Service objects.`);
|
|
202
|
-
}
|
|
203
|
-
const metrics = extractTrustMetrics(serviceObj);
|
|
204
|
-
const trustScore = computeServiceTrustScore(metrics);
|
|
205
|
-
const sales = Array.isArray(serviceObj?.data?.sales) ? serviceObj.data.sales : [];
|
|
206
|
-
const activeSale = sales.find((s) => s && !s.suspension) ?? sales[0];
|
|
207
|
-
const salePriceRaw = activeSale?.price != null ? BigInt(activeSale.price) : 0n;
|
|
208
|
-
const orderAmount = validated.order_amount != null
|
|
209
|
-
? BigInt(validated.order_amount)
|
|
210
|
-
: salePriceRaw;
|
|
211
|
-
let riskScore;
|
|
212
|
-
let infoPuzzle;
|
|
213
|
-
let preorderAdvice;
|
|
214
|
-
let preferenceIssues;
|
|
215
|
-
if (depth === "evaluate" || depth === "preorder") {
|
|
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
|
-
}
|
|
225
|
-
infoPuzzle = assembleInfoPuzzle(validated.service, puzzleRaw, depth);
|
|
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
|
-
}
|
|
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;
|
|
257
|
-
const result = {
|
|
258
|
-
service_id: validated.service,
|
|
259
|
-
service_name: serviceObj?.data?.name ?? serviceObj?.name ?? validated.service,
|
|
260
|
-
service_basics: {
|
|
261
|
-
bPublished: serviceObj?.data?.bPublished ?? false,
|
|
262
|
-
bPaused: serviceObj?.data?.bPaused ?? false,
|
|
263
|
-
sales_count: sales.filter((s) => s && !s.suspension).length,
|
|
264
|
-
has_machine: !!serviceObj?.data?.machine,
|
|
265
|
-
has_buy_guard: !!serviceObj?.data?.buy_guard,
|
|
266
|
-
has_um_contact: !!serviceObj?.data?.um,
|
|
267
|
-
arbitrations_count: Array.isArray(serviceObj?.data?.arbitrations)
|
|
268
|
-
? serviceObj.data.arbitrations.length
|
|
269
|
-
: 0,
|
|
270
|
-
},
|
|
271
|
-
trust_score: {
|
|
272
|
-
score: trustScore.score,
|
|
273
|
-
level: trustScore.level,
|
|
274
|
-
summary: trustScore.summary,
|
|
275
|
-
warnings: trustScore.warnings,
|
|
276
|
-
breakdown: trustScore.breakdown,
|
|
277
|
-
},
|
|
278
|
-
order_amount: orderAmount.toString(),
|
|
279
|
-
depth,
|
|
280
|
-
...(riskScore ? {
|
|
281
|
-
risk_score: {
|
|
282
|
-
total: riskScore.total,
|
|
283
|
-
level: riskScore.level,
|
|
284
|
-
red_flags: riskScore.red_flags,
|
|
285
|
-
advice: riskScore.advice,
|
|
286
|
-
dimensions: riskScore.dimensions,
|
|
287
|
-
},
|
|
288
|
-
} : {}),
|
|
289
|
-
...(infoPuzzle ? {
|
|
290
|
-
info_puzzle: {
|
|
291
|
-
completeness: infoPuzzle.completeness,
|
|
292
|
-
gaps: infoPuzzle.gaps,
|
|
293
|
-
assembled_at: infoPuzzle.assembled_at,
|
|
294
|
-
},
|
|
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
|
-
} : {}),
|
|
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;
|
|
364
|
-
return {
|
|
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,
|
|
379
|
-
};
|
|
380
|
-
}
|
|
1
|
+
import{strictParse,TrustScoreInputSchema}from'../../schema/index.js';import{query_objects,query_personal}from'@wowok/wowok';import{computeServiceTrustScore}from'../../knowledge/index.js';import{assembleInfoPuzzle,assemblePreorderAdvice,assessRisk,buildPreorderComparison,getDefaultPreferences,inferIndustry,mergePreferences,validatePreferences}from'../../customer/index.js';import{getProfile}from'../../experience/user-profile.js';function extractTrustMetrics(a){const b=a?.['data']??a??{},c=Array['isArray'](b['sales'])?b['sales']:[],d=c['filter'](g=>g&&!g['suspension']);void d;const e=b['compensation_fund'],f=((()=>{if(e===null||e===undefined)return undefined;if(typeof e==='bigint')return e;if(typeof e==='number')return BigInt(e);if(typeof e==='string')try{return BigInt(e);}catch{return undefined;}if(typeof e==='object'){const g=e['balance'];if(g===null||g===undefined)return undefined;try{return BigInt(g);}catch{return undefined;}}return undefined;})());return{'arbitrationCases':Array['isArray'](b['arbitrations'])?b['arbitrations']['length']:undefined,'compensationFundBalance':f,'hasMachineBound':typeof b['machine']==='string'&&b['machine']['length']>0x0,'hasBuyGuard':typeof b['buy_guard']==='string'&&b['buy_guard']['length']>0x0};}function buildPuzzleRawData(a,b,c,d){const e=a?.['data']??a??{},f=Array['isArray'](e['sales'])?e['sales']:[],g=e['order_allocators']?Array['isArray'](e['order_allocators']['allocators'])?e['order_allocators']:{'allocators':e['order_allocators']}:undefined,h={'name':e['name']??a?.['id'],'bPublished':e['bPublished'],'bPaused':e['bPaused'],'price':f[0x0]?.['price']!=null?String(f[0x0]['price']):'0','priceRaw':f[0x0]?.['price']!=null?BigInt(f[0x0]['price']):0x0n,'token_type':f[0x0]?.['price_type']??(compensation_fund_token(e)??'0x2::wow::WOW'),'sales':f,'machine':e['machine']??undefined,'buy_guard':e['buy_guard']??undefined,'customer_required':e['customer_required'],'arbitrations':e['arbitrations'],'compensation_fund':e['compensation_fund']?{'balance':extractBalance(e['compensation_fund'])}:undefined,'compensation_lock_duration':typeof e['setting_lock_duration']==='number'?e['setting_lock_duration']:undefined,'um':e['um']??undefined,'order_allocators':g?[g]:undefined};return{'service':h,'order_amount':b,'trust_score':c,'service_owner':d};}function compensation_fund_token(a){if(a?.['compensation_fund']&&typeof a['compensation_fund']==='object')return a['compensation_fund']['token_type'];return undefined;}function extractBalance(a){if(a===null||a===undefined)return 0x0n;if(typeof a==='bigint')return a;if(typeof a==='number')return BigInt(a);if(typeof a==='string')try{return BigInt(a);}catch{return 0x0n;}if(typeof a==='object'){const c=a['balance'];if(c===null||c===undefined)return 0x0n;try{return BigInt(c);}catch{return 0x0n;}}return 0x0n;}function toUserMetricsConfig(a){return{'version':0x1,'metrics':a['metrics']['map'](b=>({'name':b['name'],'label':b['label'],'evaluator':b['evaluator'],'params':{...b['params'],'threshold':b['params']['threshold']!==undefined?String(b['params']['threshold']):undefined},'weight':b['weight'],'advice_on_fail':b['advice_on_fail'],'advice_on_pass':b['advice_on_pass']})),'adjustment_cap':a['adjustment_cap']};}function derivePreferences(a,b){const c=getProfile(),d=mergePreferences(getDefaultPreferences(b),{'risk_appetite':c['risk_appetite'],'min_trust_score':c['risk_appetite']==='conservative'?0x46:c['risk_appetite']==='aggressive'?0x1e:0x32}),e=a['preferences'],f=e?{...e,'budget_range':e['budget_range']?{'min':BigInt(e['budget_range']['min']),'max':BigInt(e['budget_range']['max'])}:undefined}:undefined,g=f?mergePreferences(d,f):d;return{'prefs':g,'issues':validatePreferences(g)};}async function fetchMerchantReputation(a,b,c){try{if(typeof a!=='string'||!a['startsWith']('0x'))return undefined;const d=await query_objects({'objects':[a],'no_cache':c,'network':b}),e=d?.['objects']?.[0x0],f=(e?.['data']??e)?.['builder'];if(typeof f!=='string'||!f['startsWith']('0x'))return undefined;const g=await query_personal({'account':f,'no_cache':c,'network':b});if(!g)return undefined;return{'likes':g['like']??0x0,'dislikes':g['dislike']??0x0};}catch{return undefined;}}async function runTrustEvaluation(a){const b=a['depth']??'evaluate',c=await query_objects({'objects':[a['service']],'no_cache':a['no_cache'],'network':a['network']}),d=c?.['objects'];if(!d||!Array['isArray'](d)||d['length']===0x0)throw new Error('Service\x20object\x20not\x20found\x20for\x20\x27'+a['service']+'\x27.\x20'+'Verify\x20the\x20ID/name\x20and\x20network,\x20or\x20use\x20query_toolkit\x20with\x20query_type=\x27onchain_objects\x27\x20to\x20debug.');const e=d[0x0],f=e?.['data']?.['object_type']??e?.['object_type']??e?.['type'];if(f&&typeof f==='string'&&!f['includes']('Service'))throw new Error('Object\x20\x27'+a['service']+'\x27\x20is\x20not\x20a\x20Service\x20(type:\x20'+f+').\x20'+'trust_score\x20only\x20evaluates\x20Service\x20objects.');const g=extractTrustMetrics(e),h=computeServiceTrustScore(g),i=Array['isArray'](e?.['data']?.['sales'])?e['data']['sales']:[],j=i['find'](q=>q&&!q['suspension'])??i[0x0],k=j?.['price']!=null?BigInt(j['price']):0x0n,l=a['order_amount']!=null?BigInt(a['order_amount']):k;let m,n,o,p;if(b==='evaluate'||b==='preorder'){const q=buildPuzzleRawData(e,l,{'score':h['score'],'level':h['level']},undefined);a['user_metrics']&&(q['user_metrics_config']=toUserMetricsConfig(a['user_metrics']));if(b==='preorder'){const r=await fetchMerchantReputation((e?.['data']??e)?.['permission'],a['network'],a['no_cache']);if(r)q['merchant_reputation']=r;}n=assembleInfoPuzzle(a['service'],q,b),m=assessRisk(n);if(b==='preorder'){const s=a['industry']??inferIndustry(n),{prefs:t,issues:u}=derivePreferences(a,s);p=u['length']>0x0?u:undefined,o=assemblePreorderAdvice({'puzzle':n,'risk':m,'preferences':t,'industry':s});}}return{'serviceId':a['service'],'serviceName':e?.['data']?.['name']??e?.['name']??a['service'],'serviceObj':e,'sales':i,'trustScore':h,'orderAmount':l,'infoPuzzle':n,'riskScore':m,'preorderAdvice':o,'preferenceIssues':p};}export async function handleTrustScore(a){const b=strictParse(TrustScoreInputSchema,a,'trust_score\x20input'),c=b['depth']??'evaluate',d=await runTrustEvaluation(b),{serviceObj:f,sales:g,trustScore:h,orderAmount:i,infoPuzzle:j,riskScore:k,preorderAdvice:l,preferenceIssues:m}=d,n={'service_id':b['service'],'service_name':f?.['data']?.['name']??f?.['name']??b['service'],'service_basics':{'bPublished':f?.['data']?.['bPublished']??![],'bPaused':f?.['data']?.['bPaused']??![],'sales_count':g['filter'](q=>q&&!q['suspension'])['length'],'has_machine':!!f?.['data']?.['machine'],'has_buy_guard':!!f?.['data']?.['buy_guard'],'has_um_contact':!!f?.['data']?.['um'],'arbitrations_count':Array['isArray'](f?.['data']?.['arbitrations'])?f['data']['arbitrations']['length']:0x0},'trust_score':{'score':h['score'],'level':h['level'],'summary':h['summary'],'warnings':h['warnings'],'breakdown':h['breakdown']},'order_amount':i['toString'](),'depth':c,...k?{'risk_score':{'total':k['total'],'level':k['level'],'red_flags':k['red_flags'],'advice':k['advice'],'dimensions':k['dimensions']}}:{},...j?{'info_puzzle':{'completeness':j['completeness'],'gaps':j['gaps'],'assembled_at':j['assembled_at']}}:{},...l?{'preorder_advice':{'confidence':l['confidence'],'industry':l['industry'],'strategies':l['strategies']['map'](q=>({'scenario':q['scenario'],'merchant_tactic':q['strategy']['merchant_tactic'],'user_strategy':q['strategy']['user_strategy'],'nash_equilibrium':q['strategy']['nash_equilibrium'],'confidence':q['confidence'],'fallback':q['fallback'],'rationale':q['rationale']})),...l['preference_match']?{'preference_match':l['preference_match']}:{},...m?{'preference_issues':m}:{},...l['industry_risks']?{'industry_risks':{'score_adjustment':l['industry_risks']['score_adjustment'],'summary':l['industry_risks']['summary'],'checks':l['industry_risks']['checks'],'unmet_needs':l['industry_risks']['unmet_needs']['map'](q=>({'id':q['id'],'tier':q['tier'],'description':q['description'],'advice':q['advice']}))}}:{},'reminders':l['reminders'],'blocking_reminders':l['blocking_reminders'],'summary':l['summary']}}:{}};let o;if(c==='preorder'&&b['compare_with']&&b['compare_with']['length']>0x0){const q=[coreToCompareRow(d)];for(const r of b['compare_with']){try{const s=await runTrustEvaluation({...b,'service':r,'depth':'preorder'});q['push'](coreToCompareRow(s));}catch(t){q['push']({'service_id':r,'service_name':r,'error':t['message']});}}o=buildPreorderComparison(q);}const p=o?{...n,'comparison':o}:n;return{'content':[{'type':'text','text':JSON['stringify']({'result':p})}],'structuredContent':{'result':p}};}function coreToCompareRow(a){const b=a['infoPuzzle']?.['merchant_behavior']?.['reputation'];return{'service_id':a['serviceId'],'service_name':a['serviceName'],'industry':a['preorderAdvice']?.['industry'],'confidence':a['preorderAdvice']?.['confidence']['score'],'risk_total':a['riskScore']?.['total'],'risk_level':a['riskScore']?.['level'],'trust_score':a['trustScore']['score'],'trust_level':a['trustScore']['level'],'preference_match':a['preorderAdvice']?.['preference_match']?.['score'],'reputation_like_ratio':b?.['like_ratio'],'reputation_votes':b?b['likes']+b['dislikes']:undefined,'red_flags_count':a['riskScore']?.['red_flags']['length'],'blocking_reminders_count':a['preorderAdvice']?.['blocking_reminders']['length'],'info_gaps_count':a['infoPuzzle']?.['gaps']['length']};}
|
|
@@ -1,90 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { generate_wip, verify_wip, sign_wip, wip2html, } from "@wowok/wowok";
|
|
3
|
-
import { analyzeWipDeployment, formatDeployHints, } from "../wip-deploy-assist.js";
|
|
4
|
-
export async function handleWipOperations(args) {
|
|
5
|
-
if (typeof args === "object" && args !== null
|
|
6
|
-
&& args.type === "deploy_assist") {
|
|
7
|
-
const wipPath = args.wipFilePath;
|
|
8
|
-
if (typeof wipPath !== "string") {
|
|
9
|
-
return {
|
|
10
|
-
content: [{
|
|
11
|
-
type: "text",
|
|
12
|
-
text: "Error: 'wipFilePath' is required for deploy_assist action",
|
|
13
|
-
}],
|
|
14
|
-
structuredContent: {
|
|
15
|
-
result: {
|
|
16
|
-
type: "error",
|
|
17
|
-
error: "'wipFilePath' is required for deploy_assist action",
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
const suggestion = analyzeWipDeployment(wipPath);
|
|
23
|
-
const hints = formatDeployHints(suggestion);
|
|
24
|
-
return {
|
|
25
|
-
content: [{ type: "text", text: hints || "No deployment needed." }],
|
|
26
|
-
structuredContent: {
|
|
27
|
-
result: {
|
|
28
|
-
type: "deploy_assist",
|
|
29
|
-
...suggestion,
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
const validated = strictParse(WipOperationsSchema, args, "wip_file input");
|
|
35
|
-
let structuredContent;
|
|
36
|
-
switch (validated.type) {
|
|
37
|
-
case "generate": {
|
|
38
|
-
const result = await generate_wip(validated.options, validated.outputPath);
|
|
39
|
-
structuredContent = { result: { type: "generate", filePath: result } };
|
|
40
|
-
break;
|
|
41
|
-
}
|
|
42
|
-
case "verify": {
|
|
43
|
-
const deploySuggestion = analyzeWipDeployment(validated.wipFilePath);
|
|
44
|
-
const result = await verify_wip(validated.wipFilePath, validated.hash_equal, validated.requireSignature);
|
|
45
|
-
const attachHints = deploySuggestion.needs_deployment
|
|
46
|
-
|| (!result.valid && deploySuggestion.classification.type !== "data_url");
|
|
47
|
-
if (attachHints) {
|
|
48
|
-
const hints = formatDeployHints(deploySuggestion);
|
|
49
|
-
structuredContent = {
|
|
50
|
-
result: {
|
|
51
|
-
type: "verify",
|
|
52
|
-
...result,
|
|
53
|
-
deployment_assistance: deploySuggestion,
|
|
54
|
-
},
|
|
55
|
-
deployment_hints: hints,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
structuredContent = { result: { type: "verify", ...result } };
|
|
60
|
-
}
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
case "sign": {
|
|
64
|
-
const result = await sign_wip(validated.wipFilePath, validated.account, validated.outputPath);
|
|
65
|
-
structuredContent = { result: { type: "sign", filePath: result } };
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
case "wip2html": {
|
|
69
|
-
const result = await wip2html(validated.wipPath, validated.options);
|
|
70
|
-
const output = { type: "wip2html" };
|
|
71
|
-
if (typeof result === "string") {
|
|
72
|
-
output.html = result;
|
|
73
|
-
}
|
|
74
|
-
else if (Array.isArray(result)) {
|
|
75
|
-
output.files = result;
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
output.html = String(result);
|
|
79
|
-
}
|
|
80
|
-
structuredContent = { result: output };
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
default:
|
|
84
|
-
throw new Error("Unknown WIP operation type");
|
|
85
|
-
}
|
|
86
|
-
return {
|
|
87
|
-
content: [{ type: "text", text: JSON.stringify(structuredContent) }],
|
|
88
|
-
structuredContent,
|
|
89
|
-
};
|
|
90
|
-
}
|
|
1
|
+
import{strictParse,WipOperationsSchema}from'../../schema/index.js';import{generate_wip,verify_wip,sign_wip,wip2html}from'@wowok/wowok';import{analyzeWipDeployment,formatDeployHints}from'../wip-deploy-assist.js';export async function handleWipOperations(a){if(typeof a==='object'&&a!==null&&a['type']==='deploy_assist'){const d=a['wipFilePath'];if(typeof d!=='string')return{'content':[{'type':'text','text':'Error:\x20\x27wipFilePath\x27\x20is\x20required\x20for\x20deploy_assist\x20action'}],'structuredContent':{'result':{'type':'error','error':'\x27wipFilePath\x27\x20is\x20required\x20for\x20deploy_assist\x20action'}}};const e=analyzeWipDeployment(d),f=formatDeployHints(e);return{'content':[{'type':'text','text':f||'No\x20deployment\x20needed.'}],'structuredContent':{'result':{'type':'deploy_assist',...e}}};}const b=strictParse(WipOperationsSchema,a,'wip_file\x20input');let c;switch(b['type']){case'generate':{const g=await generate_wip(b['options'],b['outputPath']);c={'result':{'type':'generate','filePath':g}};break;}case'verify':{const h=analyzeWipDeployment(b['wipFilePath']),i=await verify_wip(b['wipFilePath'],b['hash_equal'],b['requireSignature']),j=h['needs_deployment']||!i['valid']&&h['classification']['type']!=='data_url';if(j){const k=formatDeployHints(h);c={'result':{'type':'verify',...i,'deployment_assistance':h},'deployment_hints':k};}else c={'result':{'type':'verify',...i}};break;}case'sign':{const l=await sign_wip(b['wipFilePath'],b['account'],b['outputPath']);c={'result':{'type':'sign','filePath':l}};break;}case'wip2html':{const m=await wip2html(b['wipPath'],b['options']),n={'type':'wip2html'};if(typeof m==='string')n['html']=m;else Array['isArray'](m)?n['files']=m:n['html']=String(m);c={'result':n};break;}default:throw new Error('Unknown\x20WIP\x20operation\x20type');}return{'content':[{'type':'text','text':JSON['stringify'](c)}],'structuredContent':c};}
|