@wowok/agent-mcp 2.7.0 → 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.d.ts +5 -1
- 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 +23 -0
- package/dist/evaluation/arbitration-game.js +1 -0
- package/dist/evaluation/builtins/demand-match.d.ts +15 -0
- package/dist/evaluation/builtins/demand-match.js +1 -0
- package/dist/evaluation/builtins/index.d.ts +3 -0
- package/dist/evaluation/builtins/index.js +1 -0
- package/dist/evaluation/builtins/service-risk.d.ts +6 -0
- package/dist/evaluation/builtins/service-risk.js +1 -0
- package/dist/evaluation/capability.d.ts +50 -0
- package/dist/evaluation/capability.js +1 -0
- package/dist/evaluation/composer.d.ts +13 -0
- package/dist/evaluation/composer.js +1 -0
- package/dist/evaluation/engine.d.ts +18 -0
- package/dist/evaluation/engine.js +1 -0
- package/dist/evaluation/extract.d.ts +30 -0
- package/dist/evaluation/extract.js +1 -0
- package/dist/evaluation/game-strategy.d.ts +27 -0
- package/dist/evaluation/game-strategy.js +1 -0
- package/dist/evaluation/gap.d.ts +2 -0
- package/dist/evaluation/gap.js +1 -0
- package/dist/evaluation/index.d.ts +12 -0
- package/dist/evaluation/index.js +1 -0
- package/dist/evaluation/node-game.d.ts +62 -0
- package/dist/evaluation/node-game.js +1 -0
- package/dist/evaluation/region.d.ts +10 -0
- package/dist/evaluation/region.js +1 -0
- package/dist/evaluation/types.d.ts +77 -0
- package/dist/evaluation/types.js +1 -0
- package/dist/evaluation/user-injection.d.ts +6 -0
- package/dist/evaluation/user-injection.js +1 -0
- package/dist/examples/education-contact-create.json +40 -0
- package/dist/examples/freelance-contact-create.json +40 -0
- package/dist/examples/insurance-machine-create.json +1 -1
- package/dist/examples/insurance-service-allocators.json +1 -1
- package/dist/examples/machine-publish.json +1 -1
- package/dist/examples/rental-ziroom-service-create.json +1 -1
- package/dist/examples/retail-adv-guard-messenger-proof-create.json +1 -1
- package/dist/examples/retail-myshop-service-create.json +1 -1
- package/dist/examples/retail-myshop-service-customer-required.json +1 -1
- package/dist/examples/subscription-contact-create.json +40 -0
- package/dist/examples/threebody-machine-create.json +1 -1
- package/dist/examples/travel-machine-create.json +1 -1
- package/dist/examples/travel-service-create.json +1 -1
- 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 -276
- 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.d.ts +1 -0
- package/dist/intent/enrich.js +1 -0
- package/dist/intent/index.d.ts +23 -0
- package/dist/intent/index.js +1 -0
- package/dist/intent/matcher.d.ts +2 -0
- package/dist/intent/matcher.js +1 -0
- package/dist/intent/store.d.ts +19 -0
- package/dist/intent/store.js +1 -0
- package/dist/intent/types.d.ts +33 -0
- package/dist/intent/types.js +1 -0
- 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 -433
- 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.d.ts +27 -0
- package/dist/knowledge/contact-templates.js +1 -0
- 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 -825
- 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 -670
- 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.d.ts +1 -1
- package/dist/knowledge/mcp-schema-audit.js +1 -773
- 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 -615
- package/dist/knowledge/service-templates.js +1 -456
- package/dist/knowledge/service-translation.js +1 -622
- package/dist/knowledge/template-registry.d.ts +1 -1
- package/dist/knowledge/template-registry.js +1 -341
- package/dist/knowledge/tool-constraints.js +1 -195
- package/dist/knowledge/tools-reference.js +1 -155
- 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.d.ts +16 -0
- package/dist/persona/analyzer.js +1 -0
- package/dist/persona/bridge.d.ts +5 -0
- package/dist/persona/bridge.js +1 -0
- package/dist/persona/defaults.d.ts +4 -0
- package/dist/persona/defaults.js +1 -0
- package/dist/persona/experience-bridge.d.ts +3 -0
- package/dist/persona/experience-bridge.js +1 -0
- package/dist/persona/index.d.ts +18 -0
- package/dist/persona/index.js +1 -0
- package/dist/persona/model.d.ts +7 -0
- package/dist/persona/model.js +1 -0
- package/dist/persona/store.d.ts +19 -0
- package/dist/persona/store.js +1 -0
- package/dist/persona/types.d.ts +45 -0
- package/dist/persona/types.js +1 -0
- 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.d.ts +5 -0
- package/dist/project/handlers.js +1 -1762
- 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 -245
- 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.d.ts +2 -0
- package/dist/rules.js +1 -9
- 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 -1657
- package/dist/schema/call/service.js +1 -178
- 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 +4436 -0
- package/dist/schema/evaluation/index.js +1 -0
- package/dist/schema/index.d.ts +4 -0
- package/dist/schema/index.js +1 -13
- package/dist/schema/intent-radar/index.d.ts +284 -0
- package/dist/schema/intent-radar/index.js +1 -0
- 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 +1985 -0
- package/dist/schema/persona/index.js +1 -0
- package/dist/schema/project/index.d.ts +96 -50
- package/dist/schema/project/index.js +1 -2057
- package/dist/schema/query/index.d.ts +423 -7
- package/dist/schema/query/index.js +1 -1640
- package/dist/schema/schema-query/index.js +1 -104
- package/dist/schema/schema-version.js +1 -76
- package/dist/schema/sync-layer4.d.ts +1 -1
- package/dist/schema/sync-layer4.js +1 -282
- package/dist/schema/task-status.d.ts +168 -0
- package/dist/schema/task-status.js +1 -0
- 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 +782 -0
- package/dist/schemas/evaluation_operation.schema.json +990 -0
- package/dist/schemas/index.json +25 -1
- package/dist/schemas/intent_radar.output.json +232 -0
- package/dist/schemas/intent_radar.schema.json +138 -0
- 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 +6 -6
- 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 +3 -3
- package/dist/schemas/onchain_table_data.output.json +6 -3
- package/dist/schemas/persona_operation.output.json +392 -0
- package/dist/schemas/persona_operation.schema.json +250 -0
- package/dist/schemas/project_operation.output.json +28 -8
- package/dist/schemas/query_task_status.output.json +115 -0
- package/dist/schemas/query_task_status.schema.json +24 -0
- package/dist/schemas/query_toolkit.output.json +9 -6
- package/dist/schemas/trust_score.schema.json +1 -1
- 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.d.ts +2 -0
- package/dist/tools/handlers/evaluation.js +1 -0
- package/dist/tools/handlers/file-export.js +1 -90
- package/dist/tools/handlers/intent-radar.d.ts +2 -0
- package/dist/tools/handlers/intent-radar.js +1 -0
- package/dist/tools/handlers/local.js +1 -53
- package/dist/tools/handlers/messenger.js +1 -188
- package/dist/tools/handlers/onchain.js +1 -1082
- package/dist/tools/handlers/persona.d.ts +4 -0
- package/dist/tools/handlers/persona.js +1 -0
- 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.d.ts +0 -168
- package/dist/tools/handlers/task-status.js +1 -55
- package/dist/tools/handlers/trust.js +1 -380
- package/dist/tools/handlers/wip.js +1 -90
- package/dist/tools/index.js +1 -1306
- 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.d.ts +1 -1
- package/dist/tools/wip-deploy-assist.js +1 -278
- package/dist/tools/wrap.js +1 -500
- package/package.json +5 -3
|
@@ -1,460 +1 @@
|
|
|
1
|
-
import { CUSTOMER_INTELLIGENCE_VERSION } from "./types.js";
|
|
2
|
-
export const SUPPORTED_INDUSTRIES = [
|
|
3
|
-
"freelance", "rental", "education", "travel", "subscription", "retail",
|
|
4
|
-
];
|
|
5
|
-
const INDUSTRY_TEMPLATES = {
|
|
6
|
-
freelance: {
|
|
7
|
-
max_acceptable_cycle: 30, response_time_expectation: 4,
|
|
8
|
-
require_arbitration: true, require_compensation_fund: true,
|
|
9
|
-
risk_appetite: "balanced", delivery_speed_priority: "normal",
|
|
10
|
-
after_sales_expectation: "full",
|
|
11
|
-
},
|
|
12
|
-
rental: {
|
|
13
|
-
max_acceptable_cycle: 7, response_time_expectation: 8,
|
|
14
|
-
require_arbitration: true, require_compensation_fund: true,
|
|
15
|
-
risk_appetite: "conservative", delivery_speed_priority: "normal",
|
|
16
|
-
after_sales_expectation: "full",
|
|
17
|
-
},
|
|
18
|
-
education: {
|
|
19
|
-
max_acceptable_cycle: 90, response_time_expectation: 24,
|
|
20
|
-
require_arbitration: true, require_compensation_fund: true,
|
|
21
|
-
risk_appetite: "conservative", delivery_speed_priority: "flexible",
|
|
22
|
-
after_sales_expectation: "full",
|
|
23
|
-
},
|
|
24
|
-
travel: {
|
|
25
|
-
max_acceptable_cycle: 14, response_time_expectation: 2,
|
|
26
|
-
require_arbitration: true, require_compensation_fund: true,
|
|
27
|
-
risk_appetite: "conservative", delivery_speed_priority: "urgent",
|
|
28
|
-
after_sales_expectation: "full",
|
|
29
|
-
},
|
|
30
|
-
subscription: {
|
|
31
|
-
max_acceptable_cycle: 30, response_time_expectation: 24,
|
|
32
|
-
require_arbitration: false, require_compensation_fund: false,
|
|
33
|
-
risk_appetite: "aggressive", delivery_speed_priority: "normal",
|
|
34
|
-
after_sales_expectation: "basic",
|
|
35
|
-
},
|
|
36
|
-
retail: {
|
|
37
|
-
max_acceptable_cycle: 7, response_time_expectation: 8,
|
|
38
|
-
require_arbitration: true, require_compensation_fund: true,
|
|
39
|
-
risk_appetite: "balanced", delivery_speed_priority: "normal",
|
|
40
|
-
after_sales_expectation: "full",
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
const BASE_DEFAULTS = {
|
|
44
|
-
price_sensitivity: "medium",
|
|
45
|
-
value_orientation: "balanced",
|
|
46
|
-
discount_sensitivity: 0.3,
|
|
47
|
-
delivery_speed_priority: "normal",
|
|
48
|
-
max_acceptable_cycle: 14,
|
|
49
|
-
response_time_expectation: 8,
|
|
50
|
-
merchant_preference: "neutral",
|
|
51
|
-
min_order_history: 3,
|
|
52
|
-
bargain_hunting: 0.3,
|
|
53
|
-
reward_seeking: false,
|
|
54
|
-
referral_participation: false,
|
|
55
|
-
communication_style: "friendly",
|
|
56
|
-
transparency_demand: 0.5,
|
|
57
|
-
after_sales_expectation: "basic",
|
|
58
|
-
risk_appetite: "balanced",
|
|
59
|
-
min_trust_score: 50,
|
|
60
|
-
require_arbitration: true,
|
|
61
|
-
require_compensation_fund: true,
|
|
62
|
-
preferred_industries: [],
|
|
63
|
-
preferred_tokens: ["0x2::wow::WOW"],
|
|
64
|
-
preferred_merchants: [],
|
|
65
|
-
};
|
|
66
|
-
export function getDefaultPreferences(industry) {
|
|
67
|
-
if (!industry || !INDUSTRY_TEMPLATES[industry]) {
|
|
68
|
-
return { ...BASE_DEFAULTS };
|
|
69
|
-
}
|
|
70
|
-
const tpl = INDUSTRY_TEMPLATES[industry];
|
|
71
|
-
return {
|
|
72
|
-
...BASE_DEFAULTS,
|
|
73
|
-
max_acceptable_cycle: tpl.max_acceptable_cycle,
|
|
74
|
-
response_time_expectation: tpl.response_time_expectation,
|
|
75
|
-
require_arbitration: tpl.require_arbitration,
|
|
76
|
-
require_compensation_fund: tpl.require_compensation_fund,
|
|
77
|
-
risk_appetite: tpl.risk_appetite,
|
|
78
|
-
delivery_speed_priority: tpl.delivery_speed_priority,
|
|
79
|
-
after_sales_expectation: tpl.after_sales_expectation,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
let _registryLookup = null;
|
|
83
|
-
export function _setRegistryLookup(fn) {
|
|
84
|
-
_registryLookup = fn;
|
|
85
|
-
}
|
|
86
|
-
export function getIndustryTemplate(industry) {
|
|
87
|
-
if (_registryLookup) {
|
|
88
|
-
const profile = _registryLookup(industry);
|
|
89
|
-
if (profile?.preference_template)
|
|
90
|
-
return { ...profile.preference_template };
|
|
91
|
-
}
|
|
92
|
-
return { ...INDUSTRY_TEMPLATES[industry] };
|
|
93
|
-
}
|
|
94
|
-
export function inferPreferences(history, basePrefs) {
|
|
95
|
-
const prefs = { ...(basePrefs ?? getDefaultPreferences()) };
|
|
96
|
-
const confidence = {};
|
|
97
|
-
const signals = [];
|
|
98
|
-
if (history.length < 3) {
|
|
99
|
-
signals.push(`history=${history.length} < 3, keeping default preferences`);
|
|
100
|
-
return { preferences: prefs, confidence, signals };
|
|
101
|
-
}
|
|
102
|
-
const lowPricePicks = history.filter((h) => h.avg_market_price > 0n && h.price < (h.avg_market_price * 90n) / 100n);
|
|
103
|
-
if (lowPricePicks.length >= 3) {
|
|
104
|
-
prefs.price_sensitivity = "high";
|
|
105
|
-
prefs.value_orientation = "budget";
|
|
106
|
-
confidence.price_sensitivity = 0.8;
|
|
107
|
-
confidence.value_orientation = 0.7;
|
|
108
|
-
signals.push(`Consecutive ${lowPricePicks.length} picks of Service priced 10%+ below average → price_sensitivity=high`);
|
|
109
|
-
}
|
|
110
|
-
else if (lowPricePicks.length >= 1) {
|
|
111
|
-
prefs.price_sensitivity = "medium";
|
|
112
|
-
confidence.price_sensitivity = 0.5;
|
|
113
|
-
signals.push(`${lowPricePicks.length} low-price picks → price_sensitivity=medium`);
|
|
114
|
-
}
|
|
115
|
-
const discountUsers = history.filter((h) => h.used_discount);
|
|
116
|
-
if (discountUsers.length >= 2) {
|
|
117
|
-
prefs.discount_sensitivity = 0.8;
|
|
118
|
-
confidence.discount_sensitivity = 0.85;
|
|
119
|
-
signals.push(`Used discount ${discountUsers.length} times → discount_sensitivity=0.8`);
|
|
120
|
-
}
|
|
121
|
-
if (history.some((h) => h.used_referral)) {
|
|
122
|
-
prefs.referral_participation = true;
|
|
123
|
-
confidence.referral_participation = 1.0;
|
|
124
|
-
signals.push("Has used a referral code → referral_participation=true");
|
|
125
|
-
}
|
|
126
|
-
if (discountUsers.length >= 2 || history.some((h) => h.used_referral)) {
|
|
127
|
-
prefs.reward_seeking = true;
|
|
128
|
-
confidence.reward_seeking = 0.75;
|
|
129
|
-
signals.push("Reward behavior detected → reward_seeking=true");
|
|
130
|
-
}
|
|
131
|
-
const bargainSignals = discountUsers.length + (history.some((h) => h.used_referral) ? 1 : 0);
|
|
132
|
-
if (bargainSignals >= 3) {
|
|
133
|
-
prefs.bargain_hunting = 0.8;
|
|
134
|
-
confidence.bargain_hunting = 0.8;
|
|
135
|
-
}
|
|
136
|
-
else if (bargainSignals >= 1) {
|
|
137
|
-
prefs.bargain_hunting = 0.5;
|
|
138
|
-
confidence.bargain_hunting = 0.6;
|
|
139
|
-
}
|
|
140
|
-
const industryCounts = new Map();
|
|
141
|
-
for (const h of history) {
|
|
142
|
-
if (h.industry) {
|
|
143
|
-
industryCounts.set(h.industry, (industryCounts.get(h.industry) ?? 0) + 1);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
const preferredIndustries = Array.from(industryCounts.entries())
|
|
147
|
-
.filter(([, c]) => c >= 1)
|
|
148
|
-
.sort((a, b) => b[1] - a[1])
|
|
149
|
-
.slice(0, 3)
|
|
150
|
-
.map(([ind]) => ind);
|
|
151
|
-
if (preferredIndustries.length > 0) {
|
|
152
|
-
prefs.preferred_industries = preferredIndustries;
|
|
153
|
-
confidence.preferred_industries = Math.min(1, (industryCounts.get(preferredIndustries[0]) ?? 0) / 5);
|
|
154
|
-
signals.push(`Preferred industries: ${preferredIndustries.join(", ")}`);
|
|
155
|
-
}
|
|
156
|
-
const arbPicks = history.filter((h) => h.has_arbitration);
|
|
157
|
-
if (arbPicks.length >= 3 && arbPicks.length === history.length) {
|
|
158
|
-
prefs.require_arbitration = true;
|
|
159
|
-
confidence.require_arbitration = 0.85;
|
|
160
|
-
signals.push("100% of historical orders picked Services with arbitration → require_arbitration=true (confirmed)");
|
|
161
|
-
}
|
|
162
|
-
else if (arbPicks.length < history.length / 2) {
|
|
163
|
-
prefs.require_arbitration = false;
|
|
164
|
-
confidence.require_arbitration = 0.5;
|
|
165
|
-
signals.push(`${arbPicks.length}/${history.length} orders had arbitration → require_arbitration=false`);
|
|
166
|
-
}
|
|
167
|
-
const compPicks = history.filter((h) => h.has_compensation);
|
|
168
|
-
if (compPicks.length >= 3 && compPicks.length === history.length) {
|
|
169
|
-
prefs.require_compensation_fund = true;
|
|
170
|
-
confidence.require_compensation_fund = 0.85;
|
|
171
|
-
signals.push("100% of historical orders had compensation fund → require_compensation_fund=true (confirmed)");
|
|
172
|
-
}
|
|
173
|
-
else if (compPicks.length < history.length / 2) {
|
|
174
|
-
prefs.require_compensation_fund = false;
|
|
175
|
-
confidence.require_compensation_fund = 0.5;
|
|
176
|
-
}
|
|
177
|
-
const riskScores = history
|
|
178
|
-
.map((h) => h.risk_score_at_purchase)
|
|
179
|
-
.filter((s) => typeof s === "number");
|
|
180
|
-
if (riskScores.length >= 5) {
|
|
181
|
-
const minRisk = Math.min(...riskScores);
|
|
182
|
-
if (minRisk >= 70) {
|
|
183
|
-
prefs.risk_appetite = "conservative";
|
|
184
|
-
prefs.min_trust_score = 70;
|
|
185
|
-
confidence.risk_appetite = 0.8;
|
|
186
|
-
confidence.min_trust_score = 0.7;
|
|
187
|
-
signals.push(`Lowest risk score in history ${minRisk} ≥ 70 → risk_appetite=conservative`);
|
|
188
|
-
}
|
|
189
|
-
else if (minRisk < 50) {
|
|
190
|
-
prefs.risk_appetite = "aggressive";
|
|
191
|
-
prefs.min_trust_score = Math.max(0, minRisk - 10);
|
|
192
|
-
confidence.risk_appetite = 0.7;
|
|
193
|
-
signals.push(`Lowest risk score in history ${minRisk} < 50 → risk_appetite=aggressive`);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
const messengerUsers = history.filter((h) => h.used_messenger);
|
|
197
|
-
if (messengerUsers.length >= 2) {
|
|
198
|
-
const avgMsgs = messengerUsers.reduce((s, h) => s + (h.messenger_messages ?? 0), 0) / messengerUsers.length;
|
|
199
|
-
if (avgMsgs >= 10) {
|
|
200
|
-
prefs.communication_style = "formal";
|
|
201
|
-
confidence.communication_style = 0.6;
|
|
202
|
-
signals.push(`Average ${avgMsgs.toFixed(1)} Messenger messages → communication_style=formal`);
|
|
203
|
-
}
|
|
204
|
-
else if (avgMsgs <= 3) {
|
|
205
|
-
prefs.communication_style = "casual";
|
|
206
|
-
confidence.communication_style = 0.5;
|
|
207
|
-
signals.push(`Average ${avgMsgs.toFixed(1)} Messenger messages → communication_style=casual`);
|
|
208
|
-
}
|
|
209
|
-
prefs.transparency_demand = Math.min(1, avgMsgs / 20);
|
|
210
|
-
confidence.transparency_demand = 0.6;
|
|
211
|
-
}
|
|
212
|
-
const disputedCount = history.filter((h) => h.has_dispute).length;
|
|
213
|
-
if (disputedCount > 0) {
|
|
214
|
-
prefs.transparency_demand = Math.max(prefs.transparency_demand, 0.7);
|
|
215
|
-
prefs.after_sales_expectation = "full";
|
|
216
|
-
confidence.transparency_demand = Math.max(confidence.transparency_demand ?? 0, 0.7);
|
|
217
|
-
confidence.after_sales_expectation = 0.7;
|
|
218
|
-
signals.push(`${disputedCount} disputes → transparency_demand increased, after_sales=full`);
|
|
219
|
-
}
|
|
220
|
-
const merchantCounts = new Map();
|
|
221
|
-
for (const h of history) {
|
|
222
|
-
if (h.service_owner) {
|
|
223
|
-
merchantCounts.set(h.service_owner, (merchantCounts.get(h.service_owner) ?? 0) + 1);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
prefs.preferred_merchants = Array.from(merchantCounts.entries())
|
|
227
|
-
.filter(([, c]) => c >= 2)
|
|
228
|
-
.sort((a, b) => b[1] - a[1])
|
|
229
|
-
.slice(0, 5)
|
|
230
|
-
.map(([m]) => m);
|
|
231
|
-
if (prefs.preferred_merchants.length > 0) {
|
|
232
|
-
confidence.preferred_merchants = 0.8;
|
|
233
|
-
signals.push(`Patronized ${prefs.preferred_merchants.length} merchants ≥2 times`);
|
|
234
|
-
}
|
|
235
|
-
return { preferences: prefs, confidence, signals };
|
|
236
|
-
}
|
|
237
|
-
export function matchServiceToPreferences(service, prefs) {
|
|
238
|
-
const matches = [];
|
|
239
|
-
const mismatches = [];
|
|
240
|
-
const warnings = [];
|
|
241
|
-
let score = 0;
|
|
242
|
-
let maxScore = 0;
|
|
243
|
-
maxScore += 25;
|
|
244
|
-
if (prefs.budget_range) {
|
|
245
|
-
if (service.price >= prefs.budget_range.min && service.price <= prefs.budget_range.max) {
|
|
246
|
-
score += 20;
|
|
247
|
-
matches.push("Price within budget range");
|
|
248
|
-
}
|
|
249
|
-
else if (service.price < prefs.budget_range.min) {
|
|
250
|
-
score += 15;
|
|
251
|
-
matches.push("Price below budget minimum");
|
|
252
|
-
}
|
|
253
|
-
else {
|
|
254
|
-
mismatches.push("Price exceeds budget maximum");
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
else if (service.avg_market_price && service.avg_market_price > 0n) {
|
|
258
|
-
const ratio = Number((service.price * 100n) / service.avg_market_price) / 100;
|
|
259
|
-
if (prefs.price_sensitivity === "high") {
|
|
260
|
-
if (ratio <= 0.9) {
|
|
261
|
-
score += 25;
|
|
262
|
-
matches.push(`Price is ${(1 - ratio) * 100 | 0}% below average (bonus for high-sensitivity user)`);
|
|
263
|
-
}
|
|
264
|
-
else if (ratio <= 1.1) {
|
|
265
|
-
score += 15;
|
|
266
|
-
matches.push("Price on par with average");
|
|
267
|
-
}
|
|
268
|
-
else {
|
|
269
|
-
mismatches.push(`Price is ${((ratio - 1) * 100 | 0)}% above average (high-sensitivity user)`);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
else if (prefs.price_sensitivity === "low") {
|
|
273
|
-
score += 20;
|
|
274
|
-
matches.push("Low price sensitivity");
|
|
275
|
-
}
|
|
276
|
-
else {
|
|
277
|
-
if (ratio <= 1.0) {
|
|
278
|
-
score += 20;
|
|
279
|
-
matches.push("Price not above average");
|
|
280
|
-
}
|
|
281
|
-
else if (ratio <= 1.2) {
|
|
282
|
-
score += 12;
|
|
283
|
-
}
|
|
284
|
-
else {
|
|
285
|
-
mismatches.push("Price significantly above average");
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
else {
|
|
290
|
-
score += 12;
|
|
291
|
-
}
|
|
292
|
-
maxScore += 15;
|
|
293
|
-
const cycle = service.estimated_cycle_days ?? 0;
|
|
294
|
-
if (cycle > 0) {
|
|
295
|
-
if (cycle <= prefs.max_acceptable_cycle) {
|
|
296
|
-
score += 10;
|
|
297
|
-
matches.push(`Delivery cycle ${cycle} days ≤ expected ${prefs.max_acceptable_cycle} days`);
|
|
298
|
-
if (prefs.delivery_speed_priority === "urgent" && cycle <= Math.max(1, prefs.max_acceptable_cycle / 3)) {
|
|
299
|
-
score += 5;
|
|
300
|
-
matches.push("Urgent delivery need satisfied");
|
|
301
|
-
}
|
|
302
|
-
else if (prefs.delivery_speed_priority === "urgent") {
|
|
303
|
-
warnings.push("Urgent delivery need but cycle is long");
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
else {
|
|
307
|
-
mismatches.push(`Delivery cycle ${cycle} days > expected ${prefs.max_acceptable_cycle} days`);
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
else {
|
|
311
|
-
score += 7;
|
|
312
|
-
}
|
|
313
|
-
maxScore += 10;
|
|
314
|
-
if (prefs.preferred_region) {
|
|
315
|
-
if (service.merchant_region && service.merchant_region === prefs.preferred_region) {
|
|
316
|
-
score += 10;
|
|
317
|
-
matches.push(`Merchant region ${service.merchant_region} matches preference`);
|
|
318
|
-
}
|
|
319
|
-
else if (service.merchant_region) {
|
|
320
|
-
mismatches.push(`Merchant region ${service.merchant_region} does not match preference ${prefs.preferred_region}`);
|
|
321
|
-
}
|
|
322
|
-
else {
|
|
323
|
-
score += 5;
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
else {
|
|
327
|
-
score += 7;
|
|
328
|
-
}
|
|
329
|
-
maxScore += 10;
|
|
330
|
-
if (service.merchant_order_history_count >= prefs.min_order_history) {
|
|
331
|
-
score += 7;
|
|
332
|
-
matches.push(`Merchant history ${service.merchant_order_history_count} orders ≥ required ${prefs.min_order_history} orders`);
|
|
333
|
-
}
|
|
334
|
-
else {
|
|
335
|
-
mismatches.push(`Merchant history ${service.merchant_order_history_count} orders < required ${prefs.min_order_history} orders`);
|
|
336
|
-
}
|
|
337
|
-
if (prefs.merchant_preference !== "neutral") {
|
|
338
|
-
if (service.merchant_age === prefs.merchant_preference) {
|
|
339
|
-
score += 3;
|
|
340
|
-
matches.push(`Merchant type ${service.merchant_age} matches preference`);
|
|
341
|
-
}
|
|
342
|
-
else if (service.merchant_age !== "unknown") {
|
|
343
|
-
mismatches.push(`Merchant type ${service.merchant_age} ≠ preference ${prefs.merchant_preference}`);
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
else {
|
|
347
|
-
score += 3;
|
|
348
|
-
}
|
|
349
|
-
maxScore += 15;
|
|
350
|
-
let bargainScore = 0;
|
|
351
|
-
if (service.has_reward_activity) {
|
|
352
|
-
bargainScore += 8;
|
|
353
|
-
matches.push("Has Reward activity");
|
|
354
|
-
}
|
|
355
|
-
if (service.has_discount) {
|
|
356
|
-
bargainScore += 7;
|
|
357
|
-
matches.push("Has discount");
|
|
358
|
-
}
|
|
359
|
-
if (prefs.bargain_hunting >= 0.7 && bargainScore === 0) {
|
|
360
|
-
mismatches.push("User has high bargain_hunting but no Reward/discount");
|
|
361
|
-
}
|
|
362
|
-
else if (prefs.bargain_hunting < 0.3) {
|
|
363
|
-
if (bargainScore === 0)
|
|
364
|
-
bargainScore = 10;
|
|
365
|
-
else
|
|
366
|
-
bargainScore = Math.min(bargainScore, 5);
|
|
367
|
-
}
|
|
368
|
-
else if (prefs.bargain_hunting < 0.7 && bargainScore === 0) {
|
|
369
|
-
bargainScore = 5;
|
|
370
|
-
}
|
|
371
|
-
score += bargainScore;
|
|
372
|
-
maxScore += 10;
|
|
373
|
-
if (service.after_sales_support_level === prefs.after_sales_expectation) {
|
|
374
|
-
score += 5;
|
|
375
|
-
matches.push(`After-sales support ${service.after_sales_support_level} matches expectation`);
|
|
376
|
-
}
|
|
377
|
-
else if ((prefs.after_sales_expectation === "full" && service.after_sales_support_level === "basic") ||
|
|
378
|
-
(prefs.after_sales_expectation === "full" && service.after_sales_support_level === "minimal") ||
|
|
379
|
-
(prefs.after_sales_expectation === "basic" && service.after_sales_support_level === "minimal")) {
|
|
380
|
-
mismatches.push(`After-sales support ${service.after_sales_support_level} < expectation ${prefs.after_sales_expectation}`);
|
|
381
|
-
}
|
|
382
|
-
else {
|
|
383
|
-
score += 3;
|
|
384
|
-
}
|
|
385
|
-
if (prefs.transparency_demand >= 0.7 && service.requires_messenger) {
|
|
386
|
-
score += 5;
|
|
387
|
-
matches.push("Merchant supports Messenger communication (high transparency demand)");
|
|
388
|
-
}
|
|
389
|
-
else if (prefs.transparency_demand >= 0.7 && !service.requires_messenger) {
|
|
390
|
-
mismatches.push("High transparency demand but merchant has no Messenger");
|
|
391
|
-
}
|
|
392
|
-
else {
|
|
393
|
-
score += 3;
|
|
394
|
-
}
|
|
395
|
-
maxScore += 15;
|
|
396
|
-
if (service.risk_score >= prefs.min_trust_score) {
|
|
397
|
-
score += 8;
|
|
398
|
-
matches.push(`Risk score ${service.risk_score} ≥ required ${prefs.min_trust_score}`);
|
|
399
|
-
}
|
|
400
|
-
else {
|
|
401
|
-
mismatches.push(`Risk score ${service.risk_score} < required ${prefs.min_trust_score}`);
|
|
402
|
-
}
|
|
403
|
-
if (prefs.require_arbitration) {
|
|
404
|
-
if (service.has_arbitration) {
|
|
405
|
-
score += 4;
|
|
406
|
-
matches.push("Arbitration configured");
|
|
407
|
-
}
|
|
408
|
-
else {
|
|
409
|
-
mismatches.push("User requires arbitration but Service is not configured");
|
|
410
|
-
warnings.push("⚠️ No arbitration: user preference requires arbitration as mandatory");
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
else {
|
|
414
|
-
score += 4;
|
|
415
|
-
}
|
|
416
|
-
if (prefs.require_compensation_fund) {
|
|
417
|
-
if (service.has_compensation_fund) {
|
|
418
|
-
score += 3;
|
|
419
|
-
matches.push("Has compensation fund");
|
|
420
|
-
}
|
|
421
|
-
else {
|
|
422
|
-
mismatches.push("User requires compensation fund but Service has none");
|
|
423
|
-
warnings.push("⚠️ No compensation fund: user preference requires it as mandatory");
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
else {
|
|
427
|
-
score += 3;
|
|
428
|
-
}
|
|
429
|
-
const normalized = maxScore > 0 ? Math.round((score / maxScore) * 100) : 0;
|
|
430
|
-
return { score: normalized, matches, mismatches, warnings };
|
|
431
|
-
}
|
|
432
|
-
export function mergePreferences(inferred, manual) {
|
|
433
|
-
return { ...inferred, ...manual };
|
|
434
|
-
}
|
|
435
|
-
export function validatePreferences(prefs) {
|
|
436
|
-
const issues = [];
|
|
437
|
-
if (prefs.budget_range && prefs.budget_range.min > prefs.budget_range.max) {
|
|
438
|
-
issues.push("budget_range.min > budget_range.max");
|
|
439
|
-
}
|
|
440
|
-
if (prefs.discount_sensitivity < 0 || prefs.discount_sensitivity > 1) {
|
|
441
|
-
issues.push("discount_sensitivity must be in [0,1]");
|
|
442
|
-
}
|
|
443
|
-
if (prefs.bargain_hunting < 0 || prefs.bargain_hunting > 1) {
|
|
444
|
-
issues.push("bargain_hunting must be in [0,1]");
|
|
445
|
-
}
|
|
446
|
-
if (prefs.transparency_demand < 0 || prefs.transparency_demand > 1) {
|
|
447
|
-
issues.push("transparency_demand must be in [0,1]");
|
|
448
|
-
}
|
|
449
|
-
if (prefs.min_trust_score < 0 || prefs.min_trust_score > 100) {
|
|
450
|
-
issues.push("min_trust_score must be in [0,100]");
|
|
451
|
-
}
|
|
452
|
-
if (prefs.max_acceptable_cycle < 0) {
|
|
453
|
-
issues.push("max_acceptable_cycle must be ≥ 0");
|
|
454
|
-
}
|
|
455
|
-
if (prefs.response_time_expectation < 0) {
|
|
456
|
-
issues.push("response_time_expectation must be ≥ 0");
|
|
457
|
-
}
|
|
458
|
-
return issues;
|
|
459
|
-
}
|
|
460
|
-
export { CUSTOMER_INTELLIGENCE_VERSION };
|
|
1
|
+
import{CUSTOMER_INTELLIGENCE_VERSION}from'./types.js';export const SUPPORTED_INDUSTRIES=['freelance','rental','education','travel','subscription','retail'];const INDUSTRY_TEMPLATES={'freelance':{'max_acceptable_cycle':0x1e,'response_time_expectation':0x4,'require_arbitration':!![],'require_compensation_fund':!![],'risk_appetite':'balanced','delivery_speed_priority':'normal','after_sales_expectation':'full'},'rental':{'max_acceptable_cycle':0x7,'response_time_expectation':0x8,'require_arbitration':!![],'require_compensation_fund':!![],'risk_appetite':'conservative','delivery_speed_priority':'normal','after_sales_expectation':'full'},'education':{'max_acceptable_cycle':0x5a,'response_time_expectation':0x18,'require_arbitration':!![],'require_compensation_fund':!![],'risk_appetite':'conservative','delivery_speed_priority':'flexible','after_sales_expectation':'full'},'travel':{'max_acceptable_cycle':0xe,'response_time_expectation':0x2,'require_arbitration':!![],'require_compensation_fund':!![],'risk_appetite':'conservative','delivery_speed_priority':'urgent','after_sales_expectation':'full'},'subscription':{'max_acceptable_cycle':0x1e,'response_time_expectation':0x18,'require_arbitration':![],'require_compensation_fund':![],'risk_appetite':'aggressive','delivery_speed_priority':'normal','after_sales_expectation':'basic'},'retail':{'max_acceptable_cycle':0x7,'response_time_expectation':0x8,'require_arbitration':!![],'require_compensation_fund':!![],'risk_appetite':'balanced','delivery_speed_priority':'normal','after_sales_expectation':'full'}},BASE_DEFAULTS={'price_sensitivity':'medium','value_orientation':'balanced','discount_sensitivity':0.3,'delivery_speed_priority':'normal','max_acceptable_cycle':0xe,'response_time_expectation':0x8,'merchant_preference':'neutral','min_order_history':0x3,'bargain_hunting':0.3,'reward_seeking':![],'referral_participation':![],'communication_style':'friendly','transparency_demand':0.5,'after_sales_expectation':'basic','risk_appetite':'balanced','min_trust_score':0x32,'require_arbitration':!![],'require_compensation_fund':!![],'preferred_industries':[],'preferred_tokens':['0x2::wow::WOW'],'preferred_merchants':[]};export function getDefaultPreferences(a){if(!a||!INDUSTRY_TEMPLATES[a])return{...BASE_DEFAULTS};const b=INDUSTRY_TEMPLATES[a];return{...BASE_DEFAULTS,'max_acceptable_cycle':b['max_acceptable_cycle'],'response_time_expectation':b['response_time_expectation'],'require_arbitration':b['require_arbitration'],'require_compensation_fund':b['require_compensation_fund'],'risk_appetite':b['risk_appetite'],'delivery_speed_priority':b['delivery_speed_priority'],'after_sales_expectation':b['after_sales_expectation']};}let _registryLookup=null;export function _setRegistryLookup(a){_registryLookup=a;}export function getIndustryTemplate(a){if(_registryLookup){const b=_registryLookup(a);if(b?.['preference_template'])return{...b['preference_template']};}return{...INDUSTRY_TEMPLATES[a]};}export function inferPreferences(a,b){const c={...b??getDefaultPreferences()},d={},e=[];if(a['length']<0x3)return e['push']('history='+a['length']+'\x20<\x203,\x20keeping\x20default\x20preferences'),{'preferences':c,'confidence':d,'signals':e};const f=a['filter'](r=>r['avg_market_price']>0x0n&&r['price']<r['avg_market_price']*0x5an/0x64n);if(f['length']>=0x3)c['price_sensitivity']='high',c['value_orientation']='budget',d['price_sensitivity']=0.8,d['value_orientation']=0.7,e['push']('Consecutive\x20'+f['length']+'\x20picks\x20of\x20Service\x20priced\x2010%+\x20below\x20average\x20→\x20price_sensitivity=high');else f['length']>=0x1&&(c['price_sensitivity']='medium',d['price_sensitivity']=0.5,e['push'](f['length']+'\x20low-price\x20picks\x20→\x20price_sensitivity=medium'));const g=a['filter'](r=>r['used_discount']);g['length']>=0x2&&(c['discount_sensitivity']=0.8,d['discount_sensitivity']=0.85,e['push']('Used\x20discount\x20'+g['length']+'\x20times\x20→\x20discount_sensitivity=0.8'));a['some'](r=>r['used_referral'])&&(c['referral_participation']=!![],d['referral_participation']=0x1,e['push']('Has\x20used\x20a\x20referral\x20code\x20→\x20referral_participation=true'));(g['length']>=0x2||a['some'](r=>r['used_referral']))&&(c['reward_seeking']=!![],d['reward_seeking']=0.75,e['push']('Reward\x20behavior\x20detected\x20→\x20reward_seeking=true'));const i=g['length']+(a['some'](r=>r['used_referral'])?0x1:0x0);if(i>=0x3)c['bargain_hunting']=0.8,d['bargain_hunting']=0.8;else i>=0x1&&(c['bargain_hunting']=0.5,d['bargain_hunting']=0.6);const j=new Map();for(const r of a){r['industry']&&j['set'](r['industry'],(j['get'](r['industry'])??0x0)+0x1);}const k=Array['from'](j['entries']())['filter'](([,s])=>s>=0x1)['sort']((s,t)=>t[0x1]-s[0x1])['slice'](0x0,0x3)['map'](([s])=>s);k['length']>0x0&&(c['preferred_industries']=k,d['preferred_industries']=Math['min'](0x1,(j['get'](k[0x0])??0x0)/0x5),e['push']('Preferred\x20industries:\x20'+k['join'](',\x20')));const l=a['filter'](s=>s['has_arbitration']);if(l['length']>=0x3&&l['length']===a['length'])c['require_arbitration']=!![],d['require_arbitration']=0.85,e['push']('100%\x20of\x20historical\x20orders\x20picked\x20Services\x20with\x20arbitration\x20→\x20require_arbitration=true\x20(confirmed)');else l['length']<a['length']/0x2&&(c['require_arbitration']=![],d['require_arbitration']=0.5,e['push'](l['length']+'/'+a['length']+'\x20orders\x20had\x20arbitration\x20→\x20require_arbitration=false'));const m=a['filter'](s=>s['has_compensation']);if(m['length']>=0x3&&m['length']===a['length'])c['require_compensation_fund']=!![],d['require_compensation_fund']=0.85,e['push']('100%\x20of\x20historical\x20orders\x20had\x20compensation\x20fund\x20→\x20require_compensation_fund=true\x20(confirmed)');else m['length']<a['length']/0x2&&(c['require_compensation_fund']=![],d['require_compensation_fund']=0.5);const n=a['map'](s=>s['risk_score_at_purchase'])['filter'](t=>typeof t==='number');if(n['length']>=0x5){const s=Math['min'](...n);if(s>=0x46)c['risk_appetite']='conservative',c['min_trust_score']=0x46,d['risk_appetite']=0.8,d['min_trust_score']=0.7,e['push']('Lowest\x20risk\x20score\x20in\x20history\x20'+s+'\x20≥\x2070\x20→\x20risk_appetite=conservative');else s<0x32&&(c['risk_appetite']='aggressive',c['min_trust_score']=Math['max'](0x0,s-0xa),d['risk_appetite']=0.7,e['push']('Lowest\x20risk\x20score\x20in\x20history\x20'+s+'\x20<\x2050\x20→\x20risk_appetite=aggressive'));}const o=a['filter'](t=>t['used_messenger']);if(o['length']>=0x2){const t=o['reduce']((u,v)=>u+(v['messenger_messages']??0x0),0x0)/o['length'];if(t>=0xa)c['communication_style']='formal',d['communication_style']=0.6,e['push']('Average\x20'+t['toFixed'](0x1)+'\x20Messenger\x20messages\x20→\x20communication_style=formal');else t<=0x3&&(c['communication_style']='casual',d['communication_style']=0.5,e['push']('Average\x20'+t['toFixed'](0x1)+'\x20Messenger\x20messages\x20→\x20communication_style=casual'));c['transparency_demand']=Math['min'](0x1,t/0x14),d['transparency_demand']=0.6;}const p=a['filter'](u=>u['has_dispute'])['length'];p>0x0&&(c['transparency_demand']=Math['max'](c['transparency_demand'],0.7),c['after_sales_expectation']='full',d['transparency_demand']=Math['max'](d['transparency_demand']??0x0,0.7),d['after_sales_expectation']=0.7,e['push'](p+'\x20disputes\x20→\x20transparency_demand\x20increased,\x20after_sales=full'));const q=new Map();for(const u of a){u['service_owner']&&q['set'](u['service_owner'],(q['get'](u['service_owner'])??0x0)+0x1);}return c['preferred_merchants']=Array['from'](q['entries']())['filter'](([,v])=>v>=0x2)['sort']((v,w)=>w[0x1]-v[0x1])['slice'](0x0,0x5)['map'](([v])=>v),c['preferred_merchants']['length']>0x0&&(d['preferred_merchants']=0.8,e['push']('Patronized\x20'+c['preferred_merchants']['length']+'\x20merchants\x20≥2\x20times')),{'preferences':c,'confidence':d,'signals':e};}export function matchServiceToPreferences(a,b){const c=[],d=[],e=[];let f=0x0,g=0x0;g+=0x19;if(b['budget_range']){if(a['price']>=b['budget_range']['min']&&a['price']<=b['budget_range']['max'])f+=0x14,c['push']('Price\x20within\x20budget\x20range');else a['price']<b['budget_range']['min']?(f+=0xf,c['push']('Price\x20below\x20budget\x20minimum')):d['push']('Price\x20exceeds\x20budget\x20maximum');}else{if(a['avg_market_price']&&a['avg_market_price']>0x0n){const k=Number(a['price']*0x64n/a['avg_market_price'])/0x64;if(b['price_sensitivity']==='high'){if(k<=0.9)f+=0x19,c['push']('Price\x20is\x20'+((0x1-k)*0x64|0x0)+'%\x20below\x20average\x20(bonus\x20for\x20high-sensitivity\x20user)');else k<=1.1?(f+=0xf,c['push']('Price\x20on\x20par\x20with\x20average')):d['push']('Price\x20is\x20'+((k-0x1)*0x64|0x0)+'%\x20above\x20average\x20(high-sensitivity\x20user)');}else{if(b['price_sensitivity']==='low')f+=0x14,c['push']('Low\x20price\x20sensitivity');else{if(k<=0x1)f+=0x14,c['push']('Price\x20not\x20above\x20average');else k<=1.2?f+=0xc:d['push']('Price\x20significantly\x20above\x20average');}}}else f+=0xc;}g+=0xf;const h=a['estimated_cycle_days']??0x0;if(h>0x0){if(h<=b['max_acceptable_cycle']){f+=0xa,c['push']('Delivery\x20cycle\x20'+h+'\x20days\x20≤\x20expected\x20'+b['max_acceptable_cycle']+'\x20days');if(b['delivery_speed_priority']==='urgent'&&h<=Math['max'](0x1,b['max_acceptable_cycle']/0x3))f+=0x5,c['push']('Urgent\x20delivery\x20need\x20satisfied');else b['delivery_speed_priority']==='urgent'&&e['push']('Urgent\x20delivery\x20need\x20but\x20cycle\x20is\x20long');}else d['push']('Delivery\x20cycle\x20'+h+'\x20days\x20>\x20expected\x20'+b['max_acceptable_cycle']+'\x20days');}else f+=0x7;g+=0xa;if(b['preferred_region']){if(a['merchant_region']&&a['merchant_region']===b['preferred_region'])f+=0xa,c['push']('Merchant\x20region\x20'+a['merchant_region']+'\x20matches\x20preference');else a['merchant_region']?d['push']('Merchant\x20region\x20'+a['merchant_region']+'\x20does\x20not\x20match\x20preference\x20'+b['preferred_region']):f+=0x5;}else f+=0x7;g+=0xa;a['merchant_order_history_count']>=b['min_order_history']?(f+=0x7,c['push']('Merchant\x20history\x20'+a['merchant_order_history_count']+'\x20orders\x20≥\x20required\x20'+b['min_order_history']+'\x20orders')):d['push']('Merchant\x20history\x20'+a['merchant_order_history_count']+'\x20orders\x20<\x20required\x20'+b['min_order_history']+'\x20orders');if(b['merchant_preference']!=='neutral'){if(a['merchant_age']===b['merchant_preference'])f+=0x3,c['push']('Merchant\x20type\x20'+a['merchant_age']+'\x20matches\x20preference');else a['merchant_age']!=='unknown'&&d['push']('Merchant\x20type\x20'+a['merchant_age']+'\x20≠\x20preference\x20'+b['merchant_preference']);}else f+=0x3;g+=0xf;let i=0x0;a['has_reward_activity']&&(i+=0x8,c['push']('Has\x20Reward\x20activity'));a['has_discount']&&(i+=0x7,c['push']('Has\x20discount'));if(b['bargain_hunting']>=0.7&&i===0x0)d['push']('User\x20has\x20high\x20bargain_hunting\x20but\x20no\x20Reward/discount');else{if(b['bargain_hunting']<0.3){if(i===0x0)i=0xa;else i=Math['min'](i,0x5);}else b['bargain_hunting']<0.7&&i===0x0&&(i=0x5);}f+=i,g+=0xa;if(a['after_sales_support_level']===b['after_sales_expectation'])f+=0x5,c['push']('After-sales\x20support\x20'+a['after_sales_support_level']+'\x20matches\x20expectation');else b['after_sales_expectation']==='full'&&a['after_sales_support_level']==='basic'||b['after_sales_expectation']==='full'&&a['after_sales_support_level']==='minimal'||b['after_sales_expectation']==='basic'&&a['after_sales_support_level']==='minimal'?d['push']('After-sales\x20support\x20'+a['after_sales_support_level']+'\x20<\x20expectation\x20'+b['after_sales_expectation']):f+=0x3;if(b['transparency_demand']>=0.7&&a['requires_messenger'])f+=0x5,c['push']('Merchant\x20supports\x20Messenger\x20communication\x20(high\x20transparency\x20demand)');else b['transparency_demand']>=0.7&&!a['requires_messenger']?d['push']('High\x20transparency\x20demand\x20but\x20merchant\x20has\x20no\x20Messenger'):f+=0x3;g+=0xf;a['risk_score']>=b['min_trust_score']?(f+=0x8,c['push']('Risk\x20score\x20'+a['risk_score']+'\x20≥\x20required\x20'+b['min_trust_score'])):d['push']('Risk\x20score\x20'+a['risk_score']+'\x20<\x20required\x20'+b['min_trust_score']);b['require_arbitration']?a['has_arbitration']?(f+=0x4,c['push']('Arbitration\x20configured')):(d['push']('User\x20requires\x20arbitration\x20but\x20Service\x20is\x20not\x20configured'),e['push']('⚠️\x20No\x20arbitration:\x20user\x20preference\x20requires\x20arbitration\x20as\x20mandatory')):f+=0x4;b['require_compensation_fund']?a['has_compensation_fund']?(f+=0x3,c['push']('Has\x20compensation\x20fund')):(d['push']('User\x20requires\x20compensation\x20fund\x20but\x20Service\x20has\x20none'),e['push']('⚠️\x20No\x20compensation\x20fund:\x20user\x20preference\x20requires\x20it\x20as\x20mandatory')):f+=0x3;const j=g>0x0?Math['round'](f/g*0x64):0x0;return{'score':j,'matches':c,'mismatches':d,'warnings':e};}export function mergePreferences(a,b){return{...a,...b};}export function validatePreferences(a){const b=[];return a['budget_range']&&a['budget_range']['min']>a['budget_range']['max']&&b['push']('budget_range.min\x20>\x20budget_range.max'),(a['discount_sensitivity']<0x0||a['discount_sensitivity']>0x1)&&b['push']('discount_sensitivity\x20must\x20be\x20in\x20[0,1]'),(a['bargain_hunting']<0x0||a['bargain_hunting']>0x1)&&b['push']('bargain_hunting\x20must\x20be\x20in\x20[0,1]'),(a['transparency_demand']<0x0||a['transparency_demand']>0x1)&&b['push']('transparency_demand\x20must\x20be\x20in\x20[0,1]'),(a['min_trust_score']<0x0||a['min_trust_score']>0x64)&&b['push']('min_trust_score\x20must\x20be\x20in\x20[0,100]'),a['max_acceptable_cycle']<0x0&&b['push']('max_acceptable_cycle\x20must\x20be\x20≥\x200'),a['response_time_expectation']<0x0&&b['push']('response_time_expectation\x20must\x20be\x20≥\x200'),b;}export{CUSTOMER_INTELLIGENCE_VERSION};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ArbStatus } from "../knowledge/arbitration-ledger.js";
|
|
2
|
+
import { type RiskAppetite } from "./game-strategy.js";
|
|
3
|
+
export type ArbGamePerspective = "customer" | "merchant" | "arbitrator";
|
|
4
|
+
export interface ArbGameAction {
|
|
5
|
+
action: string;
|
|
6
|
+
favorability: number;
|
|
7
|
+
gain_score: number;
|
|
8
|
+
risk_score: number;
|
|
9
|
+
is_optimal: boolean;
|
|
10
|
+
payoff_note: string;
|
|
11
|
+
risk: "low" | "medium" | "high";
|
|
12
|
+
}
|
|
13
|
+
export interface ArbGameAdvice {
|
|
14
|
+
status: ArbStatus;
|
|
15
|
+
perspective: ArbGamePerspective;
|
|
16
|
+
actions: ArbGameAction[];
|
|
17
|
+
summary: string;
|
|
18
|
+
}
|
|
19
|
+
export interface ArbPersonaDrive {
|
|
20
|
+
risk_appetite?: RiskAppetite;
|
|
21
|
+
requirements?: string[];
|
|
22
|
+
}
|
|
23
|
+
export declare function evaluateArbGame(status: ArbStatus, perspective: ArbGamePerspective, drive?: ArbPersonaDrive): ArbGameAdvice;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{appetiteMultiplier}from'./game-strategy.js';const ARB_ROLE_INTERESTS={'arbitrator':{'prefer':['case_advanced','fees_received','case_closed'],'avoid':['case_extended'],'sensitivity':0x1},'customer':{'prefer':['reversal_chance','case_closed'],'avoid':['adverse_ruling','case_extended'],'sensitivity':0x1},'merchant':{'prefer':['case_closed','fees_received'],'avoid':['adverse_ruling','reversal_chance','case_extended'],'sensitivity':0x1}},ARB_MOVE_SEMANTICS={'Principal_confirming':[{'action':'principal_confirm','perspective':'customer','gain':['case_advanced'],'risk':[],'payoff':'confirm\x20the\x20proposition\x20to\x20move\x20to\x20arbitrator\x20confirmation','base_risk':'low'},{'action':'proposition_change','perspective':'customer','gain':[],'risk':['case_extended'],'payoff':'modify\x20the\x20proposition\x20before\x20confirming\x20(extends\x20the\x20case)','base_risk':'medium'}],'Arbitrator_confirming':[{'action':'confirm','perspective':'arbitrator','gain':['case_advanced'],'risk':[],'payoff':'confirm\x20to\x20open\x20voting','base_risk':'low'},{'action':'reset','perspective':'arbitrator','gain':[],'risk':['case_extended'],'payoff':'reset\x20back\x20to\x20principal\x20confirmation\x20(extends\x20the\x20case)','base_risk':'high'}],'Voting':[{'action':'vote','perspective':'arbitrator','gain':['case_advanced'],'risk':[],'payoff':'vote\x20before\x20the\x20deadline','base_risk':'low'}],'Arbitrated':[{'action':'objection','perspective':'customer','gain':['reversal_chance'],'risk':[],'payoff':'object\x20the\x20ruling\x20(only\x20window\x20to\x20overturn)','base_risk':'medium'},{'action':'accept','perspective':'customer','gain':['case_closed'],'risk':['adverse_ruling'],'payoff':'accept\x20and\x20await\x20compensation','base_risk':'low'}],'Objectionable':[{'action':'reset','perspective':'arbitrator','gain':['case_advanced'],'risk':['case_extended'],'payoff':'reset\x20to\x20re-review\x20(extends\x20the\x20case)','base_risk':'medium'}],'Finished':[{'action':'arb_withdraw','perspective':'all','gain':['fees_received','case_closed'],'risk':[],'payoff':'withdraw\x20fees\x20/\x20compensation','base_risk':'low'}],'Withdrawn':[{'action':'done','perspective':'all','gain':['case_closed'],'risk':[],'payoff':'case\x20closed','base_risk':'low'}]};function dedupe(a){return Array['from'](new Set(a));}function resolveArbInterests(a,b){const c=ARB_ROLE_INTERESTS[a],d=c['sensitivity']*appetiteMultiplier(b?.['risk_appetite']),e=[...c['prefer']],f=[...c['avoid']];for(const g of b?.['requirements']??[]){const h=g['toLowerCase'](),i=/forbid|never|\bno\b/['test'](h);if(h['includes']('arbitration')&&i)f['push']('case_extended');if(h['includes']('refund')&&!i)e['push']('reversal_chance');if(h['includes']('prolong')||h['includes']('delay')||h['includes']('拖延'))f['push']('case_extended');}return{'prefer':dedupe(e),'avoid':dedupe(f),'sensitivity':d};}function scoreMove(a,b,c){const d=resolveArbInterests(b,c),e=a['gain']['filter'](j=>d['prefer']['includes'](j)),f=a['risk']['filter'](j=>d['avoid']['includes'](j)),g=e['length']*0x14,h=Math['round'](f['length']*0x19*d['sensitivity']),i=Math['max'](0x0,Math['min'](0x64,0x3c+g-h));return{'favorability':i,'gain_score':g,'risk_score':h};}export function evaluateArbGame(a,b,c){const d=ARB_MOVE_SEMANTICS[a]??[],e=d['filter'](g=>g['perspective']==='all'||g['perspective']===b),f=e['map'](g=>{const h=scoreMove(g,b,c);return{'action':g['action'],'favorability':h['favorability'],'gain_score':h['gain_score'],'risk_score':h['risk_score'],'is_optimal':![],'payoff_note':g['payoff'],'risk':g['base_risk']};})['sort']((g,h)=>h['favorability']-g['favorability']);return f['length']>0x0&&(f[0x0]['is_optimal']=!![]),{'status':a,'perspective':b,'actions':f,'summary':f['length']===0x0?'No\x20recommended\x20moves\x20for\x20'+b+'\x20in\x20status\x20\x27'+a+'\x27':'Optimal\x20for\x20'+b+'\x20in\x20\x27'+a+'\x27:\x20\x27'+f[0x0]['action']+'\x27\x20('+f[0x0]['payoff_note']+')'};}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type CapabilityVector } from "../capability.js";
|
|
2
|
+
import { type DemandExtractInput, type ServiceExtractInput } from "../extract.js";
|
|
3
|
+
import type { EvaluationResult, UserInjection } from "../types.js";
|
|
4
|
+
export declare const DEMAND_MATCH_EVALUATION = "demand_match";
|
|
5
|
+
export declare function registerDemandMatchEvaluation(engine?: import("../engine.js").EvaluationEngine): void;
|
|
6
|
+
export interface DemandMatch {
|
|
7
|
+
service: ServiceExtractInput;
|
|
8
|
+
result: EvaluationResult;
|
|
9
|
+
}
|
|
10
|
+
export declare function matchDemandToServices(demandCap: CapabilityVector, services: ServiceExtractInput[], injection?: UserInjection, limit?: number): Promise<DemandMatch[]>;
|
|
11
|
+
export interface ServiceMatch {
|
|
12
|
+
demand: DemandExtractInput;
|
|
13
|
+
result: EvaluationResult;
|
|
14
|
+
}
|
|
15
|
+
export declare function matchServiceToDemands(serviceCap: CapabilityVector, demands: DemandExtractInput[], injection?: UserInjection, limit?: number): Promise<ServiceMatch[]>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{requiredCapabilities}from'../capability.js';import{getEvaluationEngine}from'../engine.js';import{extractDemandCapability,extractServiceCapability}from'../extract.js';import{relateRegion}from'../region.js';export const DEMAND_MATCH_EVALUATION='demand_match';const REGION_SCORE={'exact':0x64,'contains':0x55,'compatible':0x3c,'overlap':0x28,'mismatch':0x0},dsCaps={'id':'ds_caps','description':'Extract\x20demand\x20+\x20service\x20capability\x20vectors\x20(either\x20may\x20be\x20pre-computed\x20or\x20raw)','evaluation_ids':[DEMAND_MATCH_EVALUATION],'extract':a=>({'demand_cap':a['entities']['demand_cap']??extractDemandCapability(a['entities']['demand']),'service_cap':a['entities']['service_cap']??extractServiceCapability(a['entities']['service'])})},regionRule={'id':'region','description':'Geographic\x20region\x20relation\x20between\x20demand\x20and\x20service','dimension':'region','weight':0xf,'evaluation_ids':[DEMAND_MATCH_EVALUATION],'evaluate':a=>{const b=a['facts']['demand_cap'],c=a['facts']['service_cap'],e=relateRegion(b['region'],c['region']);return{'score':REGION_SCORE[e],'weight':0xf,'reason':'region\x20'+e};}},industryRule={'id':'industry','description':'Industry\x20scenario\x20match','dimension':'industry','weight':0x14,'evaluation_ids':[DEMAND_MATCH_EVALUATION],'evaluate':a=>{const b=a['facts']['demand_cap'],c=a['facts']['service_cap'];if(b['industry']==='general'||c['industry']==='general')return{'score':0x32,'weight':0x14,'reason':'industry\x20unknown\x20(neutral)'};const e=b['industry']===c['industry']?0x64:0x0;return{'score':e,'weight':0x14,'reason':b['industry']+'\x20vs\x20'+c['industry']};}},priceRule={'id':'price','description':'Service\x20price\x20within\x20demand\x20budget','dimension':'price','weight':0xf,'evaluation_ids':[DEMAND_MATCH_EVALUATION],'evaluate':a=>{const b=a['facts']['demand_cap'],c=a['facts']['service_cap'];if(b['price_max']===undefined||c['price_min']===undefined)return{'score':0x32,'weight':0xf,'reason':'price\x20unknown\x20(neutral)'};if(c['price_min']<=b['price_max'])return{'score':0x64,'weight':0xf,'reason':'within\x20budget'};if(c['price_min']<=b['price_max']*0x6en/0x64n)return{'score':0x32,'weight':0xf,'reason':'slightly\x20over\x20budget'};return{'score':0x0,'weight':0xf,'reason':'over\x20budget'};}},trustRule={'id':'trust','description':'Service\x20trust\x20score','dimension':'trust','weight':0xf,'evaluation_ids':[DEMAND_MATCH_EVALUATION],'evaluate':a=>{const b=a['facts']['service_cap'],c=b['trust_score'],d=c>=0x4b?0x64:c>=0x32?0x3c:c>=0x19?0x1e:0x0;return{'score':d,'weight':0xf,'reason':'trust\x20'+c};}},capabilitiesRule={'id':'capabilities','description':'Demand\x20capability\x20requirements\x20covered\x20by\x20the\x20service','dimension':'capabilities','weight':0x1e,'evaluation_ids':[DEMAND_MATCH_EVALUATION],'evaluate':a=>{const b=a['facts']['demand_cap'],c=a['facts']['service_cap'],e=requiredCapabilities(b['capabilities']);if(e['length']===0x0)return{'score':0x32,'weight':0x1e,'reason':'no\x20capability\x20requirement\x20(neutral)'};const f=e['filter'](g=>c['capabilities'][g]);return{'score':Math['round'](f['length']/e['length']*0x64),'weight':0x1e,'matched':f,'mismatched':e['filter'](g=>!c['capabilities'][g]),'reason':f['length']+'/'+e['length']+'\x20required\x20capabilities\x20covered'};}},tagsRule={'id':'tags','description':'Keyword/tag\x20overlap','dimension':'tags','weight':0x5,'evaluation_ids':[DEMAND_MATCH_EVALUATION],'evaluate':a=>{const b=a['facts']['demand_cap'],c=a['facts']['service_cap'],e=new Set((b['keywords']??[])['map'](h=>h['toLowerCase']())),f=new Set([...c['tags']??[],...c['keywords']??[]]['map'](h=>h['toLowerCase']()));if(e['size']===0x0)return{'score':0x32,'weight':0x5,'reason':'no\x20keywords\x20(neutral)'};const g=[...e]['filter'](h=>f['has'](h))['length'];return{'score':Math['round'](g/e['size']*0x64),'weight':0x5,'reason':g+'/'+e['size']+'\x20keywords'};}};export function registerDemandMatchEvaluation(a=getEvaluationEngine()){a['registerDataSource'](dsCaps);for(const b of[regionRule,industryRule,priceRule,trustRule,capabilitiesRule,tagsRule]){a['registerRule'](b);}}export async function matchDemandToServices(a,b,c,d=0x5){const e=getEvaluationEngine(),f=[];for(const g of b){const h=await e['evaluate'](DEMAND_MATCH_EVALUATION,{'demand_cap':a,'service':g},c);f['push']({'service':g,'result':h});}return f['sort']((i,j)=>j['result']['total']-i['result']['total']),f['slice'](0x0,d);}export async function matchServiceToDemands(a,b,c,d=0x5){const e=getEvaluationEngine(),f=[];for(const g of b){const h=await e['evaluate'](DEMAND_MATCH_EVALUATION,{'service_cap':a,'demand':g},c);f['push']({'demand':g,'result':h});}return f['sort']((i,j)=>j['result']['total']-i['result']['total']),f['slice'](0x0,d);}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function registerBuiltinEvaluations(): void;
|
|
2
|
+
export { registerDemandMatchEvaluation, matchDemandToServices, matchServiceToDemands, DEMAND_MATCH_EVALUATION, type DemandMatch, type ServiceMatch, } from "./demand-match.js";
|
|
3
|
+
export { registerServiceRiskEvaluation, assessServiceRisk, SERVICE_RISK_EVALUATION, } from "./service-risk.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getEvaluationEngine}from'../engine.js';import{registerDemandMatchEvaluation}from'./demand-match.js';import{registerServiceRiskEvaluation}from'./service-risk.js';export function registerBuiltinEvaluations(){const a=getEvaluationEngine();registerDemandMatchEvaluation(a),registerServiceRiskEvaluation(a);}export{registerDemandMatchEvaluation,matchDemandToServices,matchServiceToDemands,DEMAND_MATCH_EVALUATION}from'./demand-match.js';export{registerServiceRiskEvaluation,assessServiceRisk,SERVICE_RISK_EVALUATION}from'./service-risk.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type PuzzleRawData } from "../../customer/info-puzzle.js";
|
|
2
|
+
import type { PuzzleDepth } from "../../customer/types.js";
|
|
3
|
+
import type { EvaluationResult, UserInjection } from "../types.js";
|
|
4
|
+
export declare const SERVICE_RISK_EVALUATION = "service_risk";
|
|
5
|
+
export declare function registerServiceRiskEvaluation(engine?: import("../engine.js").EvaluationEngine): void;
|
|
6
|
+
export declare function assessServiceRisk(serviceId: string, raw: PuzzleRawData, injection?: UserInjection, depth?: PuzzleDepth): Promise<EvaluationResult>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{assembleInfoPuzzle}from'../../customer/info-puzzle.js';import{assessWorkflowRisk,assessFundRisk,assessTrustRisk,assessBehaviorRisk}from'../../customer/risk-assessment.js';import{getEvaluationEngine}from'../engine.js';export const SERVICE_RISK_EVALUATION='service_risk';const dsPuzzle={'id':'ds_puzzle','description':'Assemble\x20the\x20service\x20info\x20puzzle\x20from\x20raw\x20chain\x20data','evaluation_ids':[SERVICE_RISK_EVALUATION],'extract':a=>{const b=a['entities']['service_id'],c=a['entities']['puzzle_raw'],d=a['entities']['depth']??'preorder';return{'puzzle':assembleInfoPuzzle(b,c,d)};}};function dimensionRule(a,b,c,d){return{'id':a,'description':b+'\x20risk\x20dimension','dimension':b,'weight':c,'evaluation_ids':[SERVICE_RISK_EVALUATION],'evaluate':e=>{const f=e['facts']['puzzle'],g=d(f),h=g['max_score']>0x0?Math['round'](g['score']/g['max_score']*0x64):0x0,i=g['checks']['filter'](l=>l['passed']),j=g['checks']['filter'](l=>!l['passed']),k=j['filter'](l=>l['advice']?.['startsWith']('🔴'));return{'score':h,'weight':c,'reason':k['length']>0x0?k['map'](l=>'['+g['name']+']\x20'+l['description']+':\x20'+l['advice'])['join'](';\x20'):g['name']+'\x20'+g['score']+'/'+g['max_score'],'matched':i['map'](l=>l['id']),'mismatched':j['map'](l=>l['id']),'red_flag':k['length']>0x0};}};}const workflowRule=dimensionRule('workflow','workflow',0x23,assessWorkflowRisk),fundRule=dimensionRule('fund','fund',0x19,assessFundRisk),trustRule=dimensionRule('trust','trust',0x14,assessTrustRisk),behaviorRule=dimensionRule('behavior','behavior',0x14,assessBehaviorRisk);export function registerServiceRiskEvaluation(a=getEvaluationEngine()){a['registerDataSource'](dsPuzzle);for(const b of[workflowRule,fundRule,trustRule,behaviorRule]){a['registerRule'](b);}}export async function assessServiceRisk(a,b,c,d='preorder'){return getEvaluationEngine()['evaluate'](SERVICE_RISK_EVALUATION,{'service_id':a,'puzzle_raw':b,'depth':d},c);}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Region } from "./region.js";
|
|
2
|
+
export type IndustryScenario = "freelance" | "rental" | "education" | "travel" | "subscription" | "retail" | "general" | "custom";
|
|
3
|
+
export interface WorkflowCapabilities {
|
|
4
|
+
has_arbitration: boolean;
|
|
5
|
+
has_refund_path: boolean;
|
|
6
|
+
has_milestone_nodes: boolean;
|
|
7
|
+
has_compensation_fund: boolean;
|
|
8
|
+
has_wip_verification: boolean;
|
|
9
|
+
has_messenger: boolean;
|
|
10
|
+
has_buy_guard: boolean;
|
|
11
|
+
has_dynamic_pricing: boolean;
|
|
12
|
+
is_published: boolean;
|
|
13
|
+
is_paused: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface CapabilityVector {
|
|
16
|
+
id: string;
|
|
17
|
+
kind: "service" | "demand";
|
|
18
|
+
owner: string;
|
|
19
|
+
industry: IndustryScenario;
|
|
20
|
+
industry_confidence: number;
|
|
21
|
+
region: Region;
|
|
22
|
+
price_min?: bigint;
|
|
23
|
+
price_max?: bigint;
|
|
24
|
+
token_type: string;
|
|
25
|
+
ticket_size: "micro" | "small" | "medium" | "large";
|
|
26
|
+
trust_score: number;
|
|
27
|
+
reputation_like_ratio: number;
|
|
28
|
+
arbitration_independent: boolean;
|
|
29
|
+
merchant_history_count: number;
|
|
30
|
+
capabilities: WorkflowCapabilities;
|
|
31
|
+
tags: string[];
|
|
32
|
+
keywords: string[];
|
|
33
|
+
}
|
|
34
|
+
export interface CapabilityGap {
|
|
35
|
+
dimension: keyof WorkflowCapabilities | "industry" | "region" | "price" | "trust";
|
|
36
|
+
requirement: string;
|
|
37
|
+
provided: string;
|
|
38
|
+
status: "satisfied" | "partial" | "missing";
|
|
39
|
+
impact: "critical" | "major" | "minor";
|
|
40
|
+
suggestion: string;
|
|
41
|
+
}
|
|
42
|
+
export interface CapabilityGapReport {
|
|
43
|
+
entity_id: string;
|
|
44
|
+
satisfied: CapabilityGap[];
|
|
45
|
+
missing: CapabilityGap[];
|
|
46
|
+
coverage_score: number;
|
|
47
|
+
summary: string;
|
|
48
|
+
}
|
|
49
|
+
export declare const REQUIREMENT_CAPABILITY_KEYS: Array<keyof WorkflowCapabilities>;
|
|
50
|
+
export declare function requiredCapabilities(c: WorkflowCapabilities): Array<keyof WorkflowCapabilities>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const REQUIREMENT_CAPABILITY_KEYS=['has_arbitration','has_refund_path','has_milestone_nodes','has_compensation_fund','has_wip_verification','has_messenger','has_buy_guard','has_dynamic_pricing'];export function requiredCapabilities(a){return REQUIREMENT_CAPABILITY_KEYS['filter'](b=>a[b]===!![]);}
|