@wowok/agent-mcp 2.7.1 → 2.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/index.js +1 -1
- package/dist/config/runtime.js +1 -238
- package/dist/customer/account-events.d.ts +32 -0
- package/dist/customer/account-events.js +1 -0
- package/dist/customer/customer-advice.d.ts +1 -0
- 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.d.ts +1 -1
- 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.d.ts +2 -0
- package/dist/customer/reminder-system.js +1 -316
- package/dist/customer/risk-assessment.d.ts +1 -0
- package/dist/customer/risk-assessment.js +1 -397
- package/dist/customer/types.d.ts +2 -0
- 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/arbitration-score.d.ts +41 -0
- package/dist/evaluation/builtins/arbitration-score.js +1 -0
- package/dist/evaluation/builtins/demand-match.js +1 -153
- package/dist/evaluation/builtins/index.d.ts +1 -0
- 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/category-match-rules.d.ts +30 -0
- package/dist/evaluation/category-match-rules.js +1 -0
- 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 +2 -0
- package/dist/evaluation/index.js +1 -11
- package/dist/evaluation/location-match.d.ts +42 -0
- package/dist/evaluation/location-match.js +1 -0
- package/dist/evaluation/node-game.d.ts +31 -3
- package/dist/evaluation/node-game.js +1 -57
- package/dist/evaluation/path-reasoning.d.ts +35 -0
- package/dist/evaluation/path-reasoning.js +1 -0
- package/dist/evaluation/region.d.ts +6 -0
- package/dist/evaluation/region.js +1 -36
- package/dist/evaluation/types.d.ts +18 -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.d.ts +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.d.ts +6 -0
- package/dist/extensions/index.js +1 -6
- package/dist/extensions/industry-layers.d.ts +75 -0
- package/dist/extensions/industry-layers.js +1 -0
- package/dist/extensions/industry-pack.d.ts +105 -0
- package/dist/extensions/industry-pack.js +1 -0
- package/dist/extensions/metric-registry.js +1 -257
- package/dist/extensions/mode-evaluator.d.ts +1 -1
- package/dist/extensions/mode-evaluator.js +1 -170
- package/dist/extensions/modes.js +1 -499
- package/dist/extensions/registry.d.ts +1 -0
- package/dist/extensions/registry.js +1 -717
- package/dist/extensions/types.js +1 -1
- package/dist/graph/base.d.ts +8 -0
- package/dist/graph/base.js +1 -0
- package/dist/harness/auto-escalation.js +1 -68
- package/dist/harness/checkpoint.js +1 -129
- package/dist/harness/index.d.ts +1 -0
- package/dist/harness/index.js +1 -78
- package/dist/harness/plan.d.ts +2 -0
- package/dist/harness/plan.js +1 -315
- package/dist/harness/recover.d.ts +1 -1
- package/dist/harness/recover.js +1 -139
- package/dist/harness/types.d.ts +2 -3
- 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/anti-cheat.d.ts +37 -0
- package/dist/knowledge/anti-cheat.js +1 -0
- package/dist/knowledge/arb-confirm.d.ts +28 -0
- package/dist/knowledge/arb-confirm.js +1 -0
- package/dist/knowledge/arb-risk.js +1 -210
- package/dist/knowledge/arb-translation.d.ts +48 -0
- package/dist/knowledge/arb-translation.js +1 -0
- 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/audit-rules.js +1 -141
- package/dist/knowledge/bridge-confirm.d.ts +26 -0
- package/dist/knowledge/bridge-confirm.js +1 -0
- package/dist/knowledge/bridge-risk.js +1 -263
- package/dist/knowledge/bridge-translation.d.ts +37 -0
- package/dist/knowledge/bridge-translation.js +1 -0
- package/dist/knowledge/contact-confirm.d.ts +27 -0
- package/dist/knowledge/contact-confirm.js +1 -0
- package/dist/knowledge/contact-risk.js +1 -200
- package/dist/knowledge/contact-templates.js +1 -60
- package/dist/knowledge/contact-translation.d.ts +39 -0
- package/dist/knowledge/contact-translation.js +1 -0
- package/dist/knowledge/demand-confirm.js +1 -206
- package/dist/knowledge/demand-context.d.ts +17 -0
- package/dist/knowledge/demand-context.js +1 -0
- package/dist/knowledge/demand-ledger.d.ts +26 -0
- package/dist/knowledge/demand-ledger.js +1 -0
- package/dist/knowledge/demand-matching.js +1 -132
- package/dist/knowledge/demand-puzzle.d.ts +29 -0
- package/dist/knowledge/demand-puzzle.js +1 -0
- package/dist/knowledge/demand-risk.js +1 -240
- package/dist/knowledge/demand-templates.d.ts +12 -0
- package/dist/knowledge/demand-templates.js +1 -0
- 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/evidence-review.d.ts +12 -0
- package/dist/knowledge/evidence-review.js +1 -0
- package/dist/knowledge/examples-scanner-cli.js +1 -26
- package/dist/knowledge/examples-scanner.js +1 -843
- package/dist/knowledge/flywheel-loop.d.ts +0 -1
- 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.d.ts +1 -1
- 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.d.ts +71 -3
- 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/market-metrics.d.ts +12 -0
- package/dist/knowledge/market-metrics.js +1 -0
- package/dist/knowledge/market-operations.d.ts +46 -0
- package/dist/knowledge/market-operations.js +1 -0
- package/dist/knowledge/mcp-schema-audit-cli.js +1 -45
- package/dist/knowledge/mcp-schema-audit.d.ts +22 -22
- 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-confirm.d.ts +26 -0
- package/dist/knowledge/payment-confirm.js +1 -0
- package/dist/knowledge/payment-risk.js +1 -249
- package/dist/knowledge/payment-translation.d.ts +37 -0
- package/dist/knowledge/payment-translation.js +1 -0
- package/dist/knowledge/permission-confirm.js +1 -426
- package/dist/knowledge/permission-context.js +1 -224
- package/dist/knowledge/permission-ledger.d.ts +11 -0
- 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-confirm.d.ts +29 -0
- package/dist/knowledge/personal-confirm.js +1 -0
- package/dist/knowledge/personal-risk.js +1 -212
- package/dist/knowledge/personal-translation.d.ts +37 -0
- package/dist/knowledge/personal-translation.js +1 -0
- package/dist/knowledge/process-model.d.ts +1 -11
- 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-context.d.ts +17 -0
- package/dist/knowledge/proof-context.js +1 -0
- package/dist/knowledge/proof-ledger.d.ts +34 -0
- package/dist/knowledge/proof-ledger.js +1 -0
- package/dist/knowledge/proof-puzzle.d.ts +35 -0
- package/dist/knowledge/proof-puzzle.js +1 -0
- package/dist/knowledge/proof-risk.js +1 -207
- package/dist/knowledge/proof-templates.d.ts +22 -0
- package/dist/knowledge/proof-templates.js +1 -0
- package/dist/knowledge/proof-translation.js +1 -283
- package/dist/knowledge/registrar-confirm.d.ts +26 -0
- package/dist/knowledge/registrar-confirm.js +1 -0
- package/dist/knowledge/registrar-risk.js +1 -217
- package/dist/knowledge/registrar-translation.d.ts +37 -0
- package/dist/knowledge/registrar-translation.js +1 -0
- package/dist/knowledge/repository-confirm.js +1 -286
- package/dist/knowledge/repository-context.d.ts +12 -0
- package/dist/knowledge/repository-context.js +1 -0
- package/dist/knowledge/repository-ledger.d.ts +25 -0
- package/dist/knowledge/repository-ledger.js +1 -0
- package/dist/knowledge/repository-puzzle.d.ts +30 -0
- package/dist/knowledge/repository-puzzle.js +1 -0
- package/dist/knowledge/repository-risk.js +1 -373
- package/dist/knowledge/repository-templates.d.ts +14 -0
- package/dist/knowledge/repository-templates.js +1 -0
- package/dist/knowledge/repository-translation.js +1 -445
- package/dist/knowledge/reputation-rules.js +1 -99
- package/dist/knowledge/resource-confirm.d.ts +25 -0
- package/dist/knowledge/resource-confirm.js +1 -0
- package/dist/knowledge/resource-risk.js +1 -157
- package/dist/knowledge/resource-translation.d.ts +37 -0
- package/dist/knowledge/resource-translation.js +1 -0
- package/dist/knowledge/reward-confirm.js +1 -526
- package/dist/knowledge/reward-context.d.ts +2 -2
- 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.d.ts +1 -0
- 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.d.ts +1 -1
- 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/universal-template.d.ts +22 -0
- package/dist/knowledge/universal-template.js +1 -0
- package/dist/knowledge/util-confirm.d.ts +24 -0
- package/dist/knowledge/util-confirm.js +1 -0
- package/dist/knowledge/util-risk.js +1 -135
- package/dist/knowledge/util-translation.d.ts +38 -0
- package/dist/knowledge/util-translation.js +1 -0
- package/dist/knowledge/workflow-guidance.d.ts +116 -0
- package/dist/knowledge/workflow-guidance.js +1 -0
- 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/employee-kpi.d.ts +25 -0
- package/dist/participation/employee-kpi.js +1 -0
- package/dist/participation/employee-store.d.ts +16 -0
- package/dist/participation/employee-store.js +1 -0
- package/dist/participation/index.d.ts +2 -0
- package/dist/participation/index.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.d.ts +9 -2
- package/dist/persona/index.js +1 -71
- package/dist/persona/local-region.d.ts +20 -0
- package/dist/persona/local-region.js +1 -0
- package/dist/persona/model.js +1 -111
- package/dist/persona/overrides.d.ts +10 -0
- package/dist/persona/overrides.js +1 -0
- package/dist/persona/pack-personae.d.ts +11 -0
- package/dist/persona/pack-personae.js +1 -0
- package/dist/persona/store.js +1 -62
- package/dist/persona/strategy-intent.d.ts +20 -0
- package/dist/persona/strategy-intent.js +1 -0
- package/dist/persona/types.d.ts +6 -2
- package/dist/persona/types.js +1 -5
- package/dist/project/business-puzzle.d.ts +1 -1
- 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.d.ts +37 -1
- 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.d.ts +3 -6
- package/dist/project/graph.js +1 -340
- package/dist/project/handlers.d.ts +33 -2
- package/dist/project/handlers.js +1 -1784
- package/dist/project/index.d.ts +2 -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.d.ts +19 -0
- 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.d.ts +3 -5
- 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/project/workflow-design-assessment.d.ts +24 -0
- package/dist/project/workflow-design-assessment.js +1 -0
- 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.d.ts +1 -1
- 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.d.ts +186 -1385
- package/dist/schema/call/allocation.js +1 -34
- package/dist/schema/call/arbitration.d.ts +272 -1871
- package/dist/schema/call/arbitration.js +1 -113
- package/dist/schema/call/base.d.ts +1831 -9076
- package/dist/schema/call/base.js +1 -370
- package/dist/schema/call/bridge.d.ts +911 -3171
- package/dist/schema/call/bridge.js +1 -458
- package/dist/schema/call/contact.d.ts +135 -931
- package/dist/schema/call/contact.js +1 -37
- package/dist/schema/call/demand.d.ts +164 -1194
- package/dist/schema/call/demand.js +1 -47
- package/dist/schema/call/guard.d.ts +298 -1140
- 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.d.ts +459 -5403
- package/dist/schema/call/machine.js +1 -193
- package/dist/schema/call/order.d.ts +137 -844
- package/dist/schema/call/order.js +1 -35
- package/dist/schema/call/payment.d.ts +74 -561
- package/dist/schema/call/payment.js +1 -37
- package/dist/schema/call/permission-handler.js +1 -54
- package/dist/schema/call/permission.d.ts +335 -2791
- package/dist/schema/call/permission.js +1 -105
- package/dist/schema/call/personal.d.ts +227 -1814
- package/dist/schema/call/personal.js +1 -78
- package/dist/schema/call/progress.d.ts +140 -843
- package/dist/schema/call/progress.js +1 -47
- package/dist/schema/call/proof.d.ts +42 -258
- package/dist/schema/call/proof.js +1 -33
- package/dist/schema/call/repository.d.ts +324 -2222
- package/dist/schema/call/repository.js +1 -77
- package/dist/schema/call/reward.d.ts +153 -1183
- package/dist/schema/call/reward.js +1 -30
- package/dist/schema/call/semantic.js +1 -1679
- package/dist/schema/call/service.d.ts +376 -3431
- package/dist/schema/call/service.js +1 -184
- package/dist/schema/call/treasury.d.ts +252 -2158
- package/dist/schema/call/treasury.js +1 -71
- package/dist/schema/common/index.d.ts +222 -697
- package/dist/schema/common/index.js +1 -407
- package/dist/schema/config/index.d.ts +18 -161
- package/dist/schema/config/index.js +1 -68
- package/dist/schema/employee/index.d.ts +99 -0
- package/dist/schema/employee/index.js +1 -0
- package/dist/schema/evaluation/index.d.ts +1062 -3748
- package/dist/schema/evaluation/index.js +1 -356
- package/dist/schema/index.d.ts +3 -0
- package/dist/schema/index.js +1 -17
- package/dist/schema/industry-pack/index.d.ts +132 -0
- package/dist/schema/industry-pack/index.js +1 -0
- package/dist/schema/intent-radar/index.d.ts +92 -245
- package/dist/schema/intent-radar/index.js +1 -89
- package/dist/schema/local/index.d.ts +2045 -18080
- package/dist/schema/local/index.js +1 -927
- package/dist/schema/local/wip.d.ts +61 -651
- package/dist/schema/local/wip.js +1 -187
- package/dist/schema/messenger/index.d.ts +949 -5557
- package/dist/schema/messenger/index.js +1 -475
- package/dist/schema/operations.d.ts +2969 -26518
- package/dist/schema/operations.js +1 -520
- package/dist/schema/persona/index.d.ts +469 -1820
- package/dist/schema/persona/index.js +1 -148
- package/dist/schema/project/index.d.ts +1027 -8408
- package/dist/schema/project/index.js +1 -2057
- package/dist/schema/query/index.d.ts +12041 -75261
- package/dist/schema/query/index.js +1 -1646
- package/dist/schema/schema-query/index.d.ts +35 -98
- package/dist/schema/schema-query/index.js +1 -104
- package/dist/schema/schema-version.js +1 -76
- package/dist/schema/task-status.d.ts +26 -132
- package/dist/schema/task-status.js +1 -36
- package/dist/schema/trust/index.d.ts +194 -1290
- 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.d.ts +1 -0
- package/dist/schema/utils/skills-recommendation.js +1 -77
- package/dist/schema/workspace/index.d.ts +69 -0
- package/dist/schema/workspace/index.js +1 -0
- package/dist/schema-query-impl/index.js +1 -0
- package/dist/schemas/account_operation.output.json +3147 -1652
- package/dist/schemas/account_operation.schema.json +225 -218
- package/dist/schemas/bridge_operation.output.json +1168 -650
- package/dist/schemas/bridge_operation.schema.json +736 -504
- package/dist/schemas/config_operation.output.json +185 -179
- package/dist/schemas/config_operation.schema.json +21 -26
- package/dist/schemas/employee_operation.output.json +207 -0
- package/dist/schemas/employee_operation.schema.json +176 -0
- package/dist/schemas/evaluation_operation.output.json +2329 -557
- package/dist/schemas/evaluation_operation.schema.json +2939 -720
- package/dist/schemas/guard2file.output.json +58 -64
- package/dist/schemas/guard2file.schema.json +79 -81
- package/dist/schemas/index.json +29 -11
- package/dist/schemas/industry_pack_operation.output.json +594 -0
- package/dist/schemas/industry_pack_operation.schema.json +55 -0
- package/dist/schemas/intent_radar.output.json +275 -200
- package/dist/schemas/intent_radar.schema.json +124 -123
- package/dist/schemas/local_info_operation.output.json +1174 -657
- package/dist/schemas/local_info_operation.schema.json +119 -125
- package/dist/schemas/local_mark_operation.output.json +1239 -689
- package/dist/schemas/local_mark_operation.schema.json +91 -96
- package/dist/schemas/machineNode2file.output.json +63 -69
- package/dist/schemas/machineNode2file.schema.json +79 -81
- package/dist/schemas/messenger_operation.output.json +2722 -1528
- package/dist/schemas/messenger_operation.schema.json +1482 -1264
- package/dist/schemas/onchain_events.output.json +2590 -975
- package/dist/schemas/onchain_events.schema.json +117 -99
- package/dist/schemas/onchain_operations.output.json +3957 -2309
- package/dist/schemas/onchain_operations.schema.json +20799 -9285
- package/dist/schemas/onchain_operations_allocation.schema.json +172 -108
- package/dist/schemas/onchain_operations_arbitration.schema.json +233 -146
- package/dist/schemas/onchain_operations_contact.schema.json +129 -90
- package/dist/schemas/onchain_operations_demand.schema.json +170 -112
- package/dist/schemas/onchain_operations_gen_passport.schema.json +61 -646
- package/dist/schemas/onchain_operations_gen_proof.schema.json +40 -172
- package/dist/schemas/onchain_operations_guard.schema.json +3765 -294
- package/dist/schemas/onchain_operations_machine.schema.json +537 -164
- package/dist/schemas/onchain_operations_order.schema.json +126 -96
- package/dist/schemas/onchain_operations_payment.schema.json +82 -67
- package/dist/schemas/onchain_operations_permission.schema.json +331 -93
- package/dist/schemas/onchain_operations_personal.schema.json +636 -96
- package/dist/schemas/onchain_operations_progress.schema.json +125 -92
- package/dist/schemas/onchain_operations_proof.schema.json +76 -69
- package/dist/schemas/onchain_operations_repository.schema.json +636 -249
- package/dist/schemas/onchain_operations_reward.schema.json +218 -108
- package/dist/schemas/onchain_operations_service.schema.json +679 -221
- package/dist/schemas/onchain_operations_treasury.schema.json +401 -135
- package/dist/schemas/onchain_table_data.output.json +6018 -2430
- package/dist/schemas/onchain_table_data.schema.json +544 -430
- package/dist/schemas/persona_operation.output.json +1568 -265
- package/dist/schemas/persona_operation.schema.json +346 -202
- package/dist/schemas/project_operation.output.json +6957 -5147
- package/dist/schemas/project_operation.schema.json +1050 -1020
- package/dist/schemas/query_task_status.output.json +195 -99
- package/dist/schemas/query_task_status.schema.json +12 -18
- package/dist/schemas/query_toolkit.output.json +18870 -14566
- package/dist/schemas/query_toolkit.schema.json +614 -522
- package/dist/schemas/schema_query.output.json +127 -129
- package/dist/schemas/schema_query.schema.json +64 -69
- package/dist/schemas/trust_score.output.json +678 -587
- package/dist/schemas/trust_score.schema.json +289 -277
- package/dist/schemas/wip_file.output.json +116 -124
- package/dist/schemas/wip_file.schema.json +142 -143
- package/dist/schemas/workspace_operation.output.json +277 -0
- package/dist/schemas/workspace_operation.schema.json +45 -0
- package/dist/schemas/wowok_buildin_info.output.json +1693 -723
- package/dist/schemas/wowok_buildin_info.schema.json +576 -512
- 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.d.ts +8 -1
- package/dist/tools/handlers/bridge.js +1 -1
- package/dist/tools/handlers/config.js +1 -74
- package/dist/tools/handlers/employee.d.ts +2 -0
- package/dist/tools/handlers/employee.js +1 -0
- package/dist/tools/handlers/evaluation.js +1 -123
- package/dist/tools/handlers/file-export.js +1 -90
- package/dist/tools/handlers/industry-pack.d.ts +2 -0
- package/dist/tools/handlers/industry-pack.js +1 -0
- 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/handlers/workspace.d.ts +2 -0
- package/dist/tools/handlers/workspace.js +1 -0
- package/dist/tools/index.d.ts +2 -1
- package/dist/tools/index.js +1 -1382
- package/dist/tools/retry.js +1 -85
- package/dist/tools/rules-hook.d.ts +1 -1
- package/dist/tools/rules-hook.js +1 -23
- package/dist/tools/shared.d.ts +1 -1
- package/dist/tools/shared.js +1 -130
- package/dist/tools/types.d.ts +2 -1
- 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 +7 -6
- package/dist/knowledge/arbitration-trust.d.ts +0 -24
- package/dist/knowledge/arbitration-trust.js +0 -117
- package/dist/schema/call/bridge-handler.d.ts +0 -8
- package/dist/schema/call/bridge-handler.js +0 -265
- package/dist/schema/sync-layer4.d.ts +0 -21
- package/dist/schema/sync-layer4.js +0 -286
- package/dist/schema-query/index.js +0 -810
- /package/dist/{schema-query → schema-query-impl}/index.d.ts +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { CommercialRole } from "../role/types.js";
|
|
2
|
+
export type OperationOutcome = "completion" | "refund" | "advance";
|
|
3
|
+
export type RiskAppetite = "conservative" | "balanced" | "aggressive";
|
|
4
|
+
export declare const OUTCOME_SEMANTICS: Record<OperationOutcome, string[]>;
|
|
5
|
+
export interface RoleInterests {
|
|
6
|
+
prefer: string[];
|
|
7
|
+
avoid: string[];
|
|
8
|
+
sensitivity: number;
|
|
9
|
+
}
|
|
10
|
+
export declare const ROLE_INTERESTS: Record<CommercialRole, RoleInterests>;
|
|
11
|
+
export declare function classifyOutcome(consequence?: string): OperationOutcome;
|
|
12
|
+
export declare function appetiteMultiplier(appetite?: RiskAppetite): number;
|
|
13
|
+
export declare function interestsOf(role: CommercialRole): RoleInterests;
|
|
14
|
+
export interface PersonaDrive {
|
|
15
|
+
risk_appetite?: RiskAppetite;
|
|
16
|
+
requirements?: string[];
|
|
17
|
+
}
|
|
18
|
+
export declare function resolveInterests(role: CommercialRole, drive?: PersonaDrive): RoleInterests;
|
|
19
|
+
export interface OutcomeEvaluation {
|
|
20
|
+
gain_score: number;
|
|
21
|
+
risk_score: number;
|
|
22
|
+
net_score: number;
|
|
23
|
+
gains: string[];
|
|
24
|
+
risks: string[];
|
|
25
|
+
}
|
|
26
|
+
export declare function evaluateOutcome(outcome: OperationOutcome, role: CommercialRole, drive?: PersonaDrive): OutcomeEvaluation;
|
|
27
|
+
export declare function consistencyScore(outcome: OperationOutcome, role: CommercialRole): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const OUTCOME_SEMANTICS={'completion':['fund_released_to_merchant','refund_leverage_given_up'],'refund':['fund_returned_to_buyer','arbitration_review_triggered'],'advance':['node_advanced']};export const ROLE_INTERESTS={'customer':{'prefer':['fund_returned_to_buyer'],'avoid':['fund_released_to_merchant','refund_leverage_given_up'],'sensitivity':0x1},'merchant':{'prefer':['fund_released_to_merchant'],'avoid':['fund_returned_to_buyer','arbitration_review_triggered'],'sensitivity':0x1},'collaborator':{'prefer':['node_advanced'],'avoid':[],'sensitivity':0x1},'supplier':{'prefer':['fund_released_to_merchant','node_advanced'],'avoid':['fund_returned_to_buyer'],'sensitivity':0x1},'prospect':{'prefer':['fund_returned_to_buyer'],'avoid':['fund_released_to_merchant','arbitration_review_triggered','refund_leverage_given_up'],'sensitivity':0x1},'arbitrator':{'prefer':[],'avoid':['arbitration_review_triggered'],'sensitivity':0x1},'system':{'prefer':[],'avoid':[],'sensitivity':0x1}};export function classifyOutcome(a){if(a?.['startsWith']('Completion'))return'completion';if(a?.['startsWith']('Refund'))return'refund';return'advance';}export function appetiteMultiplier(a){switch(a){case'conservative':return 1.5;case'aggressive':return 0.6;default:return 0x1;}}export function interestsOf(a){return ROLE_INTERESTS[a]??{'prefer':[],'avoid':[],'sensitivity':0x1};}function dedupe(a){return Array['from'](new Set(a));}export function resolveInterests(a,b){const c=interestsOf(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']('arbitration_review_triggered');if(h['includes']('refund')&&!i)e['push']('fund_returned_to_buyer');if((h['includes']('upfront')||h['includes']('before\x20delivery'))&&i)f['push']('fund_released_to_merchant');if(h['includes']('milestone')&&!i)e['push']('node_advanced');}return{'prefer':dedupe(e),'avoid':dedupe(f),'sensitivity':d};}export function evaluateOutcome(a,b,c){const d=OUTCOME_SEMANTICS[a]??[],e=resolveInterests(b,c),f=e['sensitivity'],g=[],h=[];for(const l of d){if(e['prefer']['includes'](l))g['push'](l);if(e['avoid']['includes'](l))h['push'](l);}const i=g['length']*0x14,j=Math['round'](h['length']*0x19*f),k=Math['max'](0x0,Math['min'](0x64,0x3c+i-j));return{'gain_score':i,'risk_score':j,'net_score':k,'gains':g,'risks':h};}export function consistencyScore(a,b){return evaluateOutcome(a,b)['net_score'];}
|
package/dist/evaluation/gap.js
CHANGED
|
@@ -1,100 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { relateRegion } from "./region.js";
|
|
3
|
-
const IMPACT = {
|
|
4
|
-
has_arbitration: "critical",
|
|
5
|
-
has_refund_path: "critical",
|
|
6
|
-
has_compensation_fund: "major",
|
|
7
|
-
has_wip_verification: "major",
|
|
8
|
-
has_milestone_nodes: "minor",
|
|
9
|
-
has_messenger: "minor",
|
|
10
|
-
has_buy_guard: "minor",
|
|
11
|
-
has_dynamic_pricing: "minor",
|
|
12
|
-
};
|
|
13
|
-
const SUGGEST = {
|
|
14
|
-
has_arbitration: "bind an independent Arbitration object to the Service",
|
|
15
|
-
has_refund_path: "configure a refund path (Arbitration + compensation_fund, or a refund Allocator)",
|
|
16
|
-
has_compensation_fund: "deposit compensation_fund to cover the order amount",
|
|
17
|
-
has_wip_verification: "set a wip_hash on the sale to prevent tampering",
|
|
18
|
-
has_milestone_nodes: "add milestone nodes to the Machine workflow",
|
|
19
|
-
has_messenger: "bind a Contact (um) to enable Messenger",
|
|
20
|
-
has_buy_guard: "configure a buy_guard for purchase eligibility",
|
|
21
|
-
has_dynamic_pricing: "configure discount/dynamic pricing",
|
|
22
|
-
};
|
|
23
|
-
export function summarizeCapabilityGaps(demand, service) {
|
|
24
|
-
const satisfied = [];
|
|
25
|
-
const missing = [];
|
|
26
|
-
for (const k of requiredCapabilities(demand.capabilities)) {
|
|
27
|
-
const ok = service.capabilities[k];
|
|
28
|
-
const gap = {
|
|
29
|
-
dimension: k,
|
|
30
|
-
requirement: `requires ${k}`,
|
|
31
|
-
provided: ok ? "provided" : "missing",
|
|
32
|
-
status: ok ? "satisfied" : "missing",
|
|
33
|
-
impact: ok ? "minor" : (IMPACT[k] ?? "minor"),
|
|
34
|
-
suggestion: ok ? "" : (SUGGEST[k] ?? ""),
|
|
35
|
-
};
|
|
36
|
-
(ok ? satisfied : missing).push(gap);
|
|
37
|
-
}
|
|
38
|
-
if (demand.industry !== "general" && demand.industry !== service.industry) {
|
|
39
|
-
missing.push({
|
|
40
|
-
dimension: "industry",
|
|
41
|
-
requirement: demand.industry,
|
|
42
|
-
provided: service.industry,
|
|
43
|
-
status: "missing",
|
|
44
|
-
impact: "major",
|
|
45
|
-
suggestion: `switch to a service in the '${demand.industry}' industry`,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
const rel = relateRegion(demand.region, service.region);
|
|
49
|
-
if (rel === "mismatch") {
|
|
50
|
-
missing.push({
|
|
51
|
-
dimension: "region",
|
|
52
|
-
requirement: demand.region.raw,
|
|
53
|
-
provided: service.region.raw,
|
|
54
|
-
status: "missing",
|
|
55
|
-
impact: "critical",
|
|
56
|
-
suggestion: "choose a service in a compatible region",
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
else if (rel === "overlap") {
|
|
60
|
-
missing.push({
|
|
61
|
-
dimension: "region",
|
|
62
|
-
requirement: demand.region.raw,
|
|
63
|
-
provided: service.region.raw,
|
|
64
|
-
status: "partial",
|
|
65
|
-
impact: "minor",
|
|
66
|
-
suggestion: "different city in the same province",
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
if (demand.price_max !== undefined && service.price_min !== undefined && service.price_min > demand.price_max) {
|
|
70
|
-
missing.push({
|
|
71
|
-
dimension: "price",
|
|
72
|
-
requirement: `≤ ${demand.price_max}`,
|
|
73
|
-
provided: `${service.price_min}`,
|
|
74
|
-
status: "missing",
|
|
75
|
-
impact: "major",
|
|
76
|
-
suggestion: "negotiate a lower price or raise the budget",
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
if (service.trust_score < demand.trust_score) {
|
|
80
|
-
missing.push({
|
|
81
|
-
dimension: "trust",
|
|
82
|
-
requirement: `≥ ${demand.trust_score}`,
|
|
83
|
-
provided: `${service.trust_score}`,
|
|
84
|
-
status: "missing",
|
|
85
|
-
impact: "major",
|
|
86
|
-
suggestion: "find a more trustworthy merchant or require more safeguards",
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
const total = satisfied.length + missing.length;
|
|
90
|
-
const coverage = total === 0 ? 100 : Math.round((satisfied.length / total) * 100);
|
|
91
|
-
return {
|
|
92
|
-
entity_id: service.id,
|
|
93
|
-
satisfied,
|
|
94
|
-
missing,
|
|
95
|
-
coverage_score: coverage,
|
|
96
|
-
summary: missing.length === 0
|
|
97
|
-
? `Service fully covers the demand's requirements (${coverage}/100)`
|
|
98
|
-
: `${missing.length} requirement(s) unmet (coverage ${coverage}/100): ${missing.map((m) => m.dimension).join(", ")}`,
|
|
99
|
-
};
|
|
100
|
-
}
|
|
1
|
+
import{requiredCapabilities}from'./capability.js';import{relateRegion}from'./region.js';const IMPACT={'has_arbitration':'critical','has_refund_path':'critical','has_compensation_fund':'major','has_wip_verification':'major','has_milestone_nodes':'minor','has_messenger':'minor','has_buy_guard':'minor','has_dynamic_pricing':'minor'},SUGGEST={'has_arbitration':'bind\x20an\x20independent\x20Arbitration\x20object\x20to\x20the\x20Service','has_refund_path':'configure\x20a\x20refund\x20path\x20(Arbitration\x20+\x20compensation_fund,\x20or\x20a\x20refund\x20Allocator)','has_compensation_fund':'deposit\x20compensation_fund\x20to\x20cover\x20the\x20order\x20amount','has_wip_verification':'set\x20a\x20wip_hash\x20on\x20the\x20sale\x20to\x20prevent\x20tampering','has_milestone_nodes':'add\x20milestone\x20nodes\x20to\x20the\x20Machine\x20workflow','has_messenger':'bind\x20a\x20Contact\x20(um)\x20to\x20enable\x20Messenger','has_buy_guard':'configure\x20a\x20buy_guard\x20for\x20purchase\x20eligibility','has_dynamic_pricing':'configure\x20discount/dynamic\x20pricing'};export function summarizeCapabilityGaps(a,b){const c=[],d=[];for(const h of requiredCapabilities(a['capabilities'])){const i=b['capabilities'][h],j={'dimension':h,'requirement':'requires\x20'+h,'provided':i?'provided':'missing','status':i?'satisfied':'missing','impact':i?'minor':IMPACT[h]??'minor','suggestion':i?'':SUGGEST[h]??''};(i?c:d)['push'](j);}a['industry']!=='general'&&a['industry']!==b['industry']&&d['push']({'dimension':'industry','requirement':a['industry'],'provided':b['industry'],'status':'missing','impact':'major','suggestion':'switch\x20to\x20a\x20service\x20in\x20the\x20\x27'+a['industry']+'\x27\x20industry'});const e=relateRegion(a['region'],b['region']);if(e==='mismatch')d['push']({'dimension':'region','requirement':a['region']['raw'],'provided':b['region']['raw'],'status':'missing','impact':'critical','suggestion':'choose\x20a\x20service\x20in\x20a\x20compatible\x20region'});else e==='overlap'&&d['push']({'dimension':'region','requirement':a['region']['raw'],'provided':b['region']['raw'],'status':'partial','impact':'minor','suggestion':'different\x20city\x20in\x20the\x20same\x20province'});a['price_max']!==undefined&&b['price_min']!==undefined&&b['price_min']>a['price_max']&&d['push']({'dimension':'price','requirement':'≤\x20'+a['price_max'],'provided':''+b['price_min'],'status':'missing','impact':'major','suggestion':'negotiate\x20a\x20lower\x20price\x20or\x20raise\x20the\x20budget'});b['trust_score']<a['trust_score']&&d['push']({'dimension':'trust','requirement':'≥\x20'+a['trust_score'],'provided':''+b['trust_score'],'status':'missing','impact':'major','suggestion':'find\x20a\x20more\x20trustworthy\x20merchant\x20or\x20require\x20more\x20safeguards'});const f=c['length']+d['length'],g=f===0x0?0x64:Math['round'](c['length']/f*0x64);return{'entity_id':b['id'],'satisfied':c,'missing':d,'coverage_score':g,'summary':d['length']===0x0?'Service\x20fully\x20covers\x20the\x20demand\x27s\x20requirements\x20('+g+'/100)':d['length']+'\x20requirement(s)\x20unmet\x20(coverage\x20'+g+'/100):\x20'+d['map'](l=>l['dimension'])['join'](',\x20')};}
|
|
@@ -5,7 +5,9 @@ export * from "./capability.js";
|
|
|
5
5
|
export * from "./extract.js";
|
|
6
6
|
export * from "./gap.js";
|
|
7
7
|
export * from "./composer.js";
|
|
8
|
+
export * from "./game-strategy.js";
|
|
8
9
|
export * from "./node-game.js";
|
|
9
10
|
export * from "./arbitration-game.js";
|
|
11
|
+
export * from "./path-reasoning.js";
|
|
10
12
|
export * from "./builtins/index.js";
|
|
11
13
|
export { EvaluationEngine, getEvaluationEngine, levelFromScore } from "./engine.js";
|
package/dist/evaluation/index.js
CHANGED
|
@@ -1,11 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from "./user-injection.js";
|
|
3
|
-
export * from "./region.js";
|
|
4
|
-
export * from "./capability.js";
|
|
5
|
-
export * from "./extract.js";
|
|
6
|
-
export * from "./gap.js";
|
|
7
|
-
export * from "./composer.js";
|
|
8
|
-
export * from "./node-game.js";
|
|
9
|
-
export * from "./arbitration-game.js";
|
|
10
|
-
export * from "./builtins/index.js";
|
|
11
|
-
export { EvaluationEngine, getEvaluationEngine, levelFromScore } from "./engine.js";
|
|
1
|
+
export*from'./types.js';export*from'./user-injection.js';export*from'./region.js';export*from'./capability.js';export*from'./extract.js';export*from'./gap.js';export*from'./composer.js';export*from'./game-strategy.js';export*from'./node-game.js';export*from'./arbitration-game.js';export*from'./path-reasoning.js';export*from'./builtins/index.js';export{EvaluationEngine,getEvaluationEngine,levelFromScore}from'./engine.js';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type RegionRelation } from "./region.js";
|
|
2
|
+
export type LocationSensitivity = "strict" | "near" | "logistics";
|
|
3
|
+
export interface RegionEnrichment {
|
|
4
|
+
country?: string;
|
|
5
|
+
province?: string;
|
|
6
|
+
city?: string;
|
|
7
|
+
}
|
|
8
|
+
export type LocationInput = string | ({
|
|
9
|
+
raw: string;
|
|
10
|
+
} & RegionEnrichment);
|
|
11
|
+
export interface LocationGateResult {
|
|
12
|
+
relation: RegionRelation;
|
|
13
|
+
satisfied: boolean;
|
|
14
|
+
score: number;
|
|
15
|
+
reason: string;
|
|
16
|
+
}
|
|
17
|
+
export interface ServiceLocationInput {
|
|
18
|
+
id: string;
|
|
19
|
+
name?: string;
|
|
20
|
+
location?: LocationInput;
|
|
21
|
+
}
|
|
22
|
+
export interface RankedServiceLocation {
|
|
23
|
+
id: string;
|
|
24
|
+
name?: string;
|
|
25
|
+
location?: string;
|
|
26
|
+
relation: RegionRelation;
|
|
27
|
+
satisfied: boolean;
|
|
28
|
+
score: number;
|
|
29
|
+
reason: string;
|
|
30
|
+
}
|
|
31
|
+
export interface ScopeExpansionAdvice {
|
|
32
|
+
sensitivity: LocationSensitivity;
|
|
33
|
+
search_terms: string[];
|
|
34
|
+
ai_enrichment_note: string;
|
|
35
|
+
}
|
|
36
|
+
export declare function gateLocation(sensitivity: LocationSensitivity, demandLocation: LocationInput, serviceLocation: LocationInput | undefined): LocationGateResult;
|
|
37
|
+
export declare function rankByLocation(sensitivity: LocationSensitivity, demandLocation: LocationInput, services: ServiceLocationInput[]): RankedServiceLocation[];
|
|
38
|
+
export declare function expandSearchScope(sensitivity: LocationSensitivity, demandLocation: LocationInput): ScopeExpansionAdvice;
|
|
39
|
+
export declare function inferSensitivity(description: string): {
|
|
40
|
+
sensitivity: LocationSensitivity;
|
|
41
|
+
signals: string[];
|
|
42
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{parseRegion,relateRegion}from'./region.js';function toRegion(a){if(a===undefined)return parseRegion('');if(typeof a==='string')return parseRegion(a);const b=parseRegion(a['raw']);return{...b,'country':a['country']??b['country'],'province':a['province']??b['province'],'city':a['city']??b['city']};}export function gateLocation(a,b,c){const d=toRegion(b),e=toRegion(c);if(!d['raw']?.['trim']())return{'relation':'mismatch','satisfied':a!=='strict','score':0.5,'reason':'No\x20demand-side\x20location\x20stated\x20—\x20location\x20is\x20not\x20discriminating;\x20other\x20dimensions\x20decide.'};if(!e['raw']?.['trim']())return{'relation':'mismatch','satisfied':a!=='strict','score':a==='strict'?0x0:0.3,'reason':a==='strict'?'Service\x20has\x20NO\x20location\x20set\x20—\x20merchant\x20location\x20hygiene\x20issue;\x20excluded\x20under\x20strict\x20sensitivity.':'Service\x20has\x20no\x20location\x20set\x20—\x20kept\x20(soft\x20signal)\x20because\x20sensitivity\x20is\x20not\x20strict.'};const f=relateRegion(d,e),{satisfied:g,score:h,reason:i}=judge(a,f);return{'relation':f,'satisfied':g,'score':h,'reason':i};}function judge(a,b){switch(b){case'exact':return{'satisfied':!![],'score':0x1,'reason':'Location\x20exact\x20match.'};case'contains':return{'satisfied':!![],'score':0.9,'reason':'Location\x20containment\x20match\x20(one\x20region\x20covers\x20the\x20other).'};case'overlap':if(a==='strict')return{'satisfied':![],'score':0.4,'reason':'Same\x20province\x20but\x20different\x20city\x20—\x20fails\x20the\x20100%\x20location\x20gate\x20(strict).\x20Consider\x20\x27near\x27\x20sensitivity\x20to\x20accept\x20neighboring\x20cities.'};return{'satisfied':!![],'score':0.6,'reason':'Neighboring\x20city\x20within\x20the\x20same\x20province\x20—\x20accepted\x20(near/logistics).'};case'compatible':return{'satisfied':!![],'score':0.8,'reason':'Remote\x20service\x20serves\x20any\x20physical\x20region\x20(or\x20vice\x20versa).'};case'mismatch':default:return{'satisfied':a==='logistics','score':0x0,'reason':a==='logistics'?'Region\x20mismatch\x20—\x20soft\x20warning\x20only\x20(goods\x20can\x20ship\x20via\x20logistics).':'Region\x20mismatch\x20—\x20excluded\x20under\x20strict/near\x20sensitivity.'};}}export function rankByLocation(a,b,c){return c['map'](d=>{const e=gateLocation(a,b,d['location']);return{'id':d['id'],'name':d['name'],'location':typeof d['location']==='string'?d['location']:d['location']?.['raw'],'relation':e['relation'],'satisfied':e['satisfied'],'score':e['score'],'reason':e['reason']};})['sort']((d,e)=>{if(d['satisfied']!==e['satisfied'])return d['satisfied']?-0x1:0x1;if(e['score']!==d['score'])return e['score']-d['score'];return 0x0;});}export function expandSearchScope(a,b){const c=toRegion(b),d=c['city']?.['trim'](),e=c['province']?.['trim']();if(a==='strict')return{'sensitivity':a,'search_terms':d?[d]:[c['raw']]['filter'](Boolean),'ai_enrichment_note':'Strict:\x20do\x20NOT\x20widen\x20geographically.\x20If\x20nothing\x20matches,\x20report\x20honestly\x20and\x20suggest\x20switching\x20sensitivity\x20to\x20\x27near\x27\x20(user\x20decision)\x20instead\x20of\x20silently\x20expanding.'};if(a==='near'){const f=[c['raw'],d,e]['filter'](Boolean);return{'sensitivity':a,'search_terms':f,'ai_enrichment_note':'Near:\x20AI\x20enriches\x20neighboring\x20cities\x20of\x20the\x20demand\x20city\x20from\x20public\x20web\x20data\x20(authoritative\x20preferred),\x20confirms\x20the\x20list\x20with\x20the\x20user,\x20then\x20re-runs\x20discovery\x20with\x20the\x20expanded\x20terms.'};}return{'sensitivity':a,'search_terms':[c['raw'],e,'remote','online','nationwide','china','global']['filter'](Boolean),'ai_enrichment_note':'Logistics:\x20location\x20is\x20a\x20soft\x20signal.\x20Enumerate\x20broadly\x20(nationwide/remote\x20services),\x20rank\x20by\x20location\x20fit,\x20but\x20let\x20price/trust/tags\x20dominate\x20the\x20final\x20recommendation.'};}const ON_SITE_EN=/\b(hotel|accommodation|restaurant|dining|gym)\b/,ON_SITE_CJK=['民宿','酒店','餐厅','健身房'],LOGISTICS_EN=/\b(shipping|delivery|ship to home|mail)\b/,LOGISTICS_CJK=['快递','物流','邮寄','配送到家'],REMOTE_EN=/\b(online|remote)\b/,REMOTE_CJK=['在线','远程'],hits=(a,b,c)=>b['test'](a)||c['some'](d=>a['includes'](d));export function inferSensitivity(a){const b=(a??'')['toLowerCase'](),c=[];hits(b,ON_SITE_EN,ON_SITE_CJK)&&c['push']('on-site\x20consumption');hits(b,LOGISTICS_EN,LOGISTICS_CJK)&&c['push']('physical\x20logistics');hits(b,REMOTE_EN,REMOTE_CJK)&&c['push']('remote\x20service');if(c['includes']('on-site\x20consumption')&&!c['includes']('physical\x20logistics'))return{'sensitivity':'strict','signals':c};if(c['includes']('physical\x20logistics'))return{'sensitivity':'logistics','signals':c};if(c['includes']('remote\x20service'))return{'sensitivity':'near','signals':c};return{'sensitivity':'near','signals':c['length']?c:['no\x20explicit\x20signal\x20—\x20defaulted\x20to\x20near']};}
|
|
@@ -1,14 +1,29 @@
|
|
|
1
|
-
import type { ExecutionPath
|
|
1
|
+
import type { ExecutionPath } from "../participation/radar-core.js";
|
|
2
|
+
import type { CommercialRole } from "../role/types.js";
|
|
3
|
+
import { type RiskAppetite } from "./game-strategy.js";
|
|
2
4
|
export interface NodeForwardInput {
|
|
3
5
|
name: string;
|
|
4
6
|
to_node: string;
|
|
5
7
|
execution_path: ExecutionPath;
|
|
6
8
|
guard?: string;
|
|
7
9
|
consequence?: string;
|
|
10
|
+
weight?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface AllocationSummary {
|
|
13
|
+
recipient_slots: number;
|
|
14
|
+
guard_gated_slots: number;
|
|
15
|
+
direct_to_me_slots: number;
|
|
16
|
+
to_payer_slots: number;
|
|
8
17
|
}
|
|
9
18
|
export interface NodeGameInput {
|
|
10
19
|
current_node: string;
|
|
11
|
-
perspective:
|
|
20
|
+
perspective: CommercialRole;
|
|
21
|
+
appetite?: RiskAppetite;
|
|
22
|
+
threshold?: number;
|
|
23
|
+
allocation?: AllocationSummary;
|
|
24
|
+
requirements?: string[];
|
|
25
|
+
order_amount?: string;
|
|
26
|
+
compensation_fund?: string;
|
|
12
27
|
operable: NodeForwardInput[];
|
|
13
28
|
waiting_on: Array<{
|
|
14
29
|
role: string;
|
|
@@ -21,14 +36,27 @@ export interface NodeGameAction {
|
|
|
21
36
|
execution_path: ExecutionPath;
|
|
22
37
|
guard?: string;
|
|
23
38
|
favorability: number;
|
|
39
|
+
gain_score: number;
|
|
40
|
+
risk_score: number;
|
|
24
41
|
is_optimal: boolean;
|
|
25
42
|
payoff_note: string;
|
|
26
43
|
risk: "low" | "medium" | "high";
|
|
27
44
|
}
|
|
45
|
+
export interface CooperationInfo {
|
|
46
|
+
threshold: number;
|
|
47
|
+
my_weight: number;
|
|
48
|
+
needed_from_others: number;
|
|
49
|
+
collaborators: string[];
|
|
50
|
+
allocation?: AllocationSummary;
|
|
51
|
+
allocation_note?: string;
|
|
52
|
+
}
|
|
28
53
|
export interface NodeGameAdvice {
|
|
29
54
|
current_node: string;
|
|
30
|
-
perspective:
|
|
55
|
+
perspective: CommercialRole;
|
|
31
56
|
actions: NodeGameAction[];
|
|
57
|
+
cooperation?: CooperationInfo;
|
|
58
|
+
value_at_stake?: string;
|
|
59
|
+
risk_exposure?: string;
|
|
32
60
|
summary: string;
|
|
33
61
|
}
|
|
34
62
|
export declare function evaluateNodeGame(input: NodeGameInput): NodeGameAdvice;
|
|
@@ -1,57 +1 @@
|
|
|
1
|
-
export function evaluateNodeGame(
|
|
2
|
-
const actions = input.operable.map((f) => {
|
|
3
|
-
const s = scoreForward(f, input.perspective);
|
|
4
|
-
return {
|
|
5
|
-
forward: f.name,
|
|
6
|
-
to_node: f.to_node,
|
|
7
|
-
execution_path: f.execution_path,
|
|
8
|
-
guard: f.guard,
|
|
9
|
-
favorability: s.favorability,
|
|
10
|
-
is_optimal: false,
|
|
11
|
-
payoff_note: s.payoff,
|
|
12
|
-
risk: s.risk,
|
|
13
|
-
};
|
|
14
|
-
});
|
|
15
|
-
actions.sort((a, b) => b.favorability - a.favorability);
|
|
16
|
-
if (actions.length > 0) {
|
|
17
|
-
actions[0].is_optimal = true;
|
|
18
|
-
}
|
|
19
|
-
return {
|
|
20
|
-
current_node: input.current_node,
|
|
21
|
-
perspective: input.perspective,
|
|
22
|
-
actions,
|
|
23
|
-
summary: buildSummary(input, actions),
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
function scoreForward(f, perspective) {
|
|
27
|
-
const isCompletion = !!f.consequence?.startsWith("Completion");
|
|
28
|
-
const isRefund = !!f.consequence?.startsWith("Refund");
|
|
29
|
-
if (perspective === "customer") {
|
|
30
|
-
if (isRefund) {
|
|
31
|
-
return { favorability: 90, payoff: "funds return to you (refund/cancel path)", risk: "low" };
|
|
32
|
-
}
|
|
33
|
-
if (isCompletion) {
|
|
34
|
-
return { favorability: 40, payoff: "releases escrowed funds to the merchant — only confirm if the deliverable matches the agreement", risk: "high" };
|
|
35
|
-
}
|
|
36
|
-
return { favorability: 60, payoff: "advances the order to the next node", risk: "medium" };
|
|
37
|
-
}
|
|
38
|
-
if (perspective === "operator") {
|
|
39
|
-
if (isCompletion) {
|
|
40
|
-
return { favorability: 90, payoff: "settlement + shorter fund-settlement cycle", risk: "low" };
|
|
41
|
-
}
|
|
42
|
-
if (isRefund) {
|
|
43
|
-
return { favorability: 20, payoff: "refund — downside, recorded on-chain (arb-loss/stall stats)", risk: "high" };
|
|
44
|
-
}
|
|
45
|
-
return { favorability: 70, payoff: "advance the workflow to shorten settlement", risk: "low" };
|
|
46
|
-
}
|
|
47
|
-
return { favorability: 50, payoff: "neutral (observer)", risk: "medium" };
|
|
48
|
-
}
|
|
49
|
-
function buildSummary(input, actions) {
|
|
50
|
-
if (actions.length === 0) {
|
|
51
|
-
return input.waiting_on.length > 0
|
|
52
|
-
? `Waiting on ${input.waiting_on.map((w) => w.role).join(", ")}`
|
|
53
|
-
: `No operable actions at node '${input.current_node || "(entry)"}'`;
|
|
54
|
-
}
|
|
55
|
-
const top = actions[0];
|
|
56
|
-
return `Optimal for ${input.perspective}: '${top.forward}' → '${top.to_node}' (${top.payoff_note})`;
|
|
57
|
-
}
|
|
1
|
+
import{classifyOutcome,evaluateOutcome}from'./game-strategy.js';export function evaluateNodeGame(a){const b=a['operable']['map'](c=>{const d=scoreForward(c,a['perspective'],{'risk_appetite':a['appetite'],'requirements':a['requirements']},a['order_amount']);return{'forward':c['name'],'to_node':c['to_node'],'execution_path':c['execution_path'],'guard':c['guard'],'favorability':d['favorability'],'gain_score':d['gain_score'],'risk_score':d['risk_score'],'is_optimal':![],'payoff_note':d['payoff'],'risk':d['risk']};});return b['sort']((c,d)=>d['favorability']-c['favorability']),b['length']>0x0&&(b[0x0]['is_optimal']=!![]),{'current_node':a['current_node'],'perspective':a['perspective'],'actions':b,'cooperation':evaluateCooperation(a),'value_at_stake':a['order_amount'],'risk_exposure':a['compensation_fund'],'summary':buildSummary(a,b)};}function evaluateCooperation(a){if(!a['threshold']||a['threshold']<=0x1)return undefined;const b=a['operable']['reduce']((g,h)=>g+(h['weight']??0x1),0x0),c=a['threshold']-b,d=c>0x0?a['waiting_on']['map'](f=>f['role']):[],e=a['allocation'];return{'threshold':a['threshold'],'my_weight':b,'needed_from_others':Math['max'](0x0,c),'collaborators':d,'allocation':e,'allocation_note':e?describeAllocation(e):undefined};}function describeAllocation(b){const c=['settlement\x20splits\x20across\x20'+b['recipient_slots']+'\x20recipient\x20slot(s)'];if(b['direct_to_me_slots']>0x0)c['push'](b['direct_to_me_slots']+'\x20pay\x20directly\x20to\x20you');if(b['guard_gated_slots']>0x0)c['push'](b['guard_gated_slots']+'\x20are\x20guard-resolved\x20(may\x20pay\x20a\x20cooperating\x20party)');if(b['to_payer_slots']>0x0)c['push'](b['to_payer_slots']+'\x20route\x20back\x20to\x20the\x20payer\x20(refund-oriented)');return c['join'](';\x20')+'.';}function scoreForward(a,b,c,d){const e=classifyOutcome(a['consequence']),g=evaluateOutcome(e,b,c);return{'favorability':g['net_score'],'gain_score':g['gain_score'],'risk_score':g['risk_score'],'payoff':payoffNote(e,b,d),'risk':riskOf(e,b)};}function amountSuffix(a){return a!=null?'\x20('+a+'\x20raw\x20units)':'';}function payoffNote(a,b,c){if(b==='customer'||b==='prospect')switch(a){case'refund':return'funds\x20return\x20to\x20you'+amountSuffix(c)+'\x20(refund/cancel\x20path)';case'completion':return'releases\x20escrowed\x20funds'+amountSuffix(c)+'\x20to\x20the\x20merchant\x20—\x20only\x20confirm\x20if\x20the\x20deliverable\x20matches\x20the\x20agreement';case'advance':return'advances\x20the\x20order\x20to\x20the\x20next\x20node\x20(funds'+amountSuffix(c)+'\x20stay\x20escrowed)';}if(b==='merchant'||b==='collaborator'||b==='supplier')switch(a){case'completion':return'settlement'+amountSuffix(c)+'\x20released\x20to\x20you\x20+\x20shorter\x20fund-settlement\x20cycle';case'refund':return'refund'+amountSuffix(c)+'\x20—\x20downside,\x20recorded\x20on-chain\x20(arb-loss/stall\x20stats)';case'advance':return'advance\x20the\x20workflow\x20to\x20shorten\x20settlement'+amountSuffix(c);}return'neutral\x20for\x20'+b;}function riskOf(a,b){if(b==='customer'||b==='prospect'){if(a==='completion')return'high';if(a==='refund')return'low';return'medium';}if(b==='merchant'||b==='collaborator'||b==='supplier'){if(a==='refund')return'high';return'low';}return'medium';}function buildSummary(a,b){if(b['length']===0x0)return a['waiting_on']['length']>0x0?'Waiting\x20on\x20'+a['waiting_on']['map'](e=>e['role'])['join'](',\x20'):'No\x20operable\x20actions\x20at\x20node\x20\x27'+(a['current_node']||'(entry)')+'\x27';const c=b[0x0];let d='Optimal\x20for\x20'+a['perspective']+':\x20\x27'+c['forward']+'\x27\x20→\x20\x27'+c['to_node']+'\x27\x20('+c['payoff_note']+')';return b['length']>0x1&&(d+='\x20—\x20choosing\x20this\x20closes\x20the\x20other\x20'+(b['length']-0x1)+'\x20option(s)\x20(opportunity\x20competition:\x20your\x20gain\x20may\x20be\x20another\x20role\x27s\x20lost\x20chance).'),d;}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { CommercialRole } from "../role/types.js";
|
|
2
|
+
import type { RadarMachineNode, NodeAnnotations } from "../participation/radar-core.js";
|
|
3
|
+
import { type RiskAppetite } from "./game-strategy.js";
|
|
4
|
+
export interface WorkflowPath {
|
|
5
|
+
id: string;
|
|
6
|
+
nodes: string[];
|
|
7
|
+
forwards: string[];
|
|
8
|
+
terminal: "completed" | "refunded" | "open";
|
|
9
|
+
guard_gates: number;
|
|
10
|
+
length: number;
|
|
11
|
+
terminal_value: number;
|
|
12
|
+
gain_score: number;
|
|
13
|
+
risk_score: number;
|
|
14
|
+
score: number;
|
|
15
|
+
rationale: string;
|
|
16
|
+
}
|
|
17
|
+
export interface PathReasoningInput {
|
|
18
|
+
current_node: string;
|
|
19
|
+
perspective: CommercialRole;
|
|
20
|
+
machine_nodes: RadarMachineNode[];
|
|
21
|
+
node_annotations?: NodeAnnotations;
|
|
22
|
+
appetite?: RiskAppetite;
|
|
23
|
+
requirements?: string[];
|
|
24
|
+
order_amount?: string;
|
|
25
|
+
max_depth?: number;
|
|
26
|
+
}
|
|
27
|
+
export interface PathReasoningAdvice {
|
|
28
|
+
current_node: string;
|
|
29
|
+
perspective: CommercialRole;
|
|
30
|
+
ranked_paths: WorkflowPath[];
|
|
31
|
+
optimal_path?: WorkflowPath;
|
|
32
|
+
foregone_terminals: string[];
|
|
33
|
+
summary: string;
|
|
34
|
+
}
|
|
35
|
+
export declare function evaluatePathReasoning(input: PathReasoningInput): PathReasoningAdvice;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{evaluateOutcome}from'./game-strategy.js';const DEFAULT_COMPLETED=['completed','done','finished','received','finalized','active','accepted'],DEFAULT_REFUNDED=['refunded','refund','cancelled','canceled','disputed','expired'];function terminalNames(a){return{'completed':a?.['completed']?.['length']?a['completed']:DEFAULT_COMPLETED,'refunded':a?.['refunded']?.['length']?a['refunded']:DEFAULT_REFUNDED};}function isTerminal(a,b,c){const d=a['toLowerCase']();if(b['some'](e=>d===e['toLowerCase']()||d['includes'](e['toLowerCase']())))return'completed';if(c['some'](e=>d===e['toLowerCase']()||d['includes'](e['toLowerCase']())))return'refunded';return null;}function buildAdjacency(a){const b=new Map();for(const c of a){for(const d of c['pairs']??[]){const e=d['prev_node']||'';if(!b['has'](e))b['set'](e,[]);b['get'](e)['push']({'to_node':c['name'],'threshold':d['threshold'],'forwards':(d['forwards']??[])['map'](g=>({'name':g['name'],'guard':g['guard'],'weight':g['weight']}))});}}return b;}function enumeratePaths(a,b,c,d,e){const f=[],g=(h,i,j)=>{if(i['length']>0x0){const l=isTerminal(h,c,d);if(l){f['push']({'nodes':i['map'](m=>m['node']),'forwards':i['map'](m=>m['forward']),'terminal':l,'guard_gates':i['filter'](m=>m['guard'])['length']});return;}}if(i['length']>=e){f['push']({'nodes':i['map'](m=>m['node']),'forwards':i['map'](m=>m['forward']),'terminal':'open','guard_gates':i['filter'](m=>m['guard'])['length']});return;}const k=a['get'](h)??[];if(k['length']===0x0&&i['length']>0x0){f['push']({'nodes':i['map'](m=>m['node']),'forwards':i['map'](m=>m['forward']),'terminal':'open','guard_gates':i['filter'](m=>m['guard'])['length']});return;}for(const m of k){if(j['has'](m['to_node']))continue;for(const n of m['forwards']){const o=new Set(j);o['add'](m['to_node']),g(m['to_node'],[...i,{'node':m['to_node'],'forward':n['name'],'guard':!!n['guard']}],o);}}};return g(b,[],new Set([b])),f;}function terminalScore(a,b,c){const d=a==='refunded'?'refund':a==='completed'?'completion':'advance',e=evaluateOutcome(d,b,c);return{'net':e['net_score'],'gain':e['gain_score'],'risk':e['risk_score']};}const LENGTH_COST=0x4,GATE_COST=0x5;export function evaluatePathReasoning(a){const {current_node:b,perspective:c,machine_nodes:d,node_annotations:e,appetite:f,requirements:g}=a,h=a['max_depth']??0xc,{completed:i,refunded:j}=terminalNames(e),k=buildAdjacency(d),l=f||g?.['length']?{'risk_appetite':f,'requirements':g}:undefined,m=enumeratePaths(k,b,i,j,h),n=m['map'](u=>{const v=terminalScore(u['terminal'],c,l),w=u['forwards']['length'],x=w*LENGTH_COST,y=u['guard_gates']*GATE_COST,z=Math['max'](0x0,Math['min'](0x64,v['net']-x-y));return{'id':[b,...u['nodes']]['join']('→'),'nodes':u['nodes'],'forwards':u['forwards'],'terminal':u['terminal'],'guard_gates':u['guard_gates'],'length':w,'terminal_value':v['net'],'gain_score':v['gain'],'risk_score':v['risk'],'score':z,'rationale':'terminal='+u['terminal']+'\x20value='+v['net']+'/100;\x20'+w+'\x20step(s),\x20'+u['guard_gates']+'\x20guard\x20gate(s)\x20(−'+(x+y)+')'};});n['sort']((t,u)=>{const v=t['terminal']==='open'?0x1:0x0,w=u['terminal']==='open'?0x1:0x0;if(v!==w)return v-w;return u['score']-t['score'];});const o=n['length']>0x0&&n[0x0]['terminal']!=='open'?n[0x0]:undefined,p=o?.['terminal'],q=new Set(n['filter'](t=>t['terminal']!=='open')['map'](t=>t['terminal']));q['delete'](p);const r=o?Array['from'](q):[];let s;return!o?s='No\x20terminal\x20path\x20reachable\x20from\x20\x27'+(b||'(entry)')+'\x27\x20—\x20workflow\x20may\x20be\x20stuck\x20or\x20unannotated.':(s='Optimal\x20path\x20for\x20'+c+':\x20'+o['id']+'\x20→\x20'+o['terminal']+'\x20(score\x20'+o['score']+'/100,\x20'+o['length']+'\x20step(s),\x20'+o['guard_gates']+'\x20guard\x20gate(s))',r['length']>0x0&&(s+='\x20—\x20choosing\x20it\x20foregoes\x20'+r['join']('/')+'\x20(opportunity\x20competition:\x20your\x20gain\x20may\x20close\x20another\x20outcome).')),{'current_node':b,'perspective':c,'ranked_paths':n,'optimal_path':o,'foregone_terminals':r,'summary':s};}
|
|
@@ -7,4 +7,10 @@ export interface Region {
|
|
|
7
7
|
}
|
|
8
8
|
export type RegionRelation = "exact" | "contains" | "overlap" | "compatible" | "mismatch";
|
|
9
9
|
export declare function parseRegion(raw: string): Region;
|
|
10
|
+
export interface RegionValidation {
|
|
11
|
+
region: Region;
|
|
12
|
+
valid: boolean;
|
|
13
|
+
reminder?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function validateRegionInput(raw: string): RegionValidation;
|
|
10
16
|
export declare function relateRegion(a: Region, b: Region): RegionRelation;
|
|
@@ -1,36 +1 @@
|
|
|
1
|
-
const REMOTE_KEYWORDS =
|
|
2
|
-
export function parseRegion(raw) {
|
|
3
|
-
const trimmed = raw?.trim() ?? "";
|
|
4
|
-
const lower = trimmed.toLowerCase();
|
|
5
|
-
const isRemote = REMOTE_KEYWORDS.some((k) => lower.includes(k));
|
|
6
|
-
if (isRemote) {
|
|
7
|
-
return { mode: "remote", raw: trimmed };
|
|
8
|
-
}
|
|
9
|
-
return { mode: "physical", raw: trimmed };
|
|
10
|
-
}
|
|
11
|
-
export function relateRegion(a, b) {
|
|
12
|
-
if (a.mode === "remote" || b.mode === "remote") {
|
|
13
|
-
return "compatible";
|
|
14
|
-
}
|
|
15
|
-
const na = normalizePhysical(a.raw);
|
|
16
|
-
const nb = normalizePhysical(b.raw);
|
|
17
|
-
if (!na || !nb) {
|
|
18
|
-
return "mismatch";
|
|
19
|
-
}
|
|
20
|
-
if (na === nb) {
|
|
21
|
-
return "exact";
|
|
22
|
-
}
|
|
23
|
-
if (na.includes(nb) || nb.includes(na)) {
|
|
24
|
-
return "contains";
|
|
25
|
-
}
|
|
26
|
-
if (a.province && b.province && a.province === b.province) {
|
|
27
|
-
return "overlap";
|
|
28
|
-
}
|
|
29
|
-
return "mismatch";
|
|
30
|
-
}
|
|
31
|
-
function normalizePhysical(raw) {
|
|
32
|
-
return raw
|
|
33
|
-
.trim()
|
|
34
|
-
.toLowerCase()
|
|
35
|
-
.replace(/\s+/g, "");
|
|
36
|
-
}
|
|
1
|
+
const REMOTE_KEYWORDS=['remote','online','anywhere'];export function parseRegion(a){const b=a?.['trim']()??'',c=b['toLowerCase'](),d=REMOTE_KEYWORDS['some'](e=>c['includes'](e));if(d)return{'mode':'remote','raw':b};return{'mode':'physical','raw':b};}export function validateRegionInput(a){const b=parseRegion(a),c=a?.['trim']()??'';if(!c)return{'region':b,'valid':![],'reminder':'Location\x20is\x20empty\x20—\x20provide\x20a\x20city/region\x20or\x20\x27remote\x27.'};if(b['mode']==='physical'&&!b['country']&&!b['city'])return{'region':b,'valid':!![],'reminder':'Physical\x20location\x20not\x20yet\x20resolved\x20to\x20country/city\x20—\x20AI\x20enrichment\x20will\x20resolve\x20it;\x20confirm\x20or\x20add\x20a\x20city.'};return{'region':b,'valid':!![]};}export function relateRegion(c,d){if(c['mode']==='remote'||d['mode']==='remote')return'compatible';const e=normalizePhysical(c['raw']),f=normalizePhysical(d['raw']);if(!e||!f)return'mismatch';if(e===f)return'exact';if(e['includes'](f)||f['includes'](e))return'contains';if(c['province']&&d['province']&&c['province']===d['province'])return'overlap';return'mismatch';}function normalizePhysical(a){return a['trim']()['toLowerCase']()['replace'](/\s+/g,'');}
|
|
@@ -2,6 +2,7 @@ export interface DataSource {
|
|
|
2
2
|
id: string;
|
|
3
3
|
description: string;
|
|
4
4
|
evaluation_ids?: string[];
|
|
5
|
+
priority?: number;
|
|
5
6
|
isEnabled?: (ctx: EvaluationContext) => boolean;
|
|
6
7
|
extract(ctx: EvaluationContext): Promise<Record<string, unknown>> | Record<string, unknown>;
|
|
7
8
|
}
|
|
@@ -64,6 +65,18 @@ export interface EvaluationTraceEntry {
|
|
|
64
65
|
id: string;
|
|
65
66
|
detail: string;
|
|
66
67
|
}
|
|
68
|
+
export interface CriterionScore {
|
|
69
|
+
name: string;
|
|
70
|
+
score: number;
|
|
71
|
+
weight: number;
|
|
72
|
+
rationale: string;
|
|
73
|
+
}
|
|
74
|
+
export interface EvaluationFinding {
|
|
75
|
+
criterion: string;
|
|
76
|
+
severity: "critical" | "warning" | "info";
|
|
77
|
+
message: string;
|
|
78
|
+
deduction: number;
|
|
79
|
+
}
|
|
67
80
|
export interface EvaluationResult {
|
|
68
81
|
evaluation_id: string;
|
|
69
82
|
total: number;
|
|
@@ -73,4 +86,9 @@ export interface EvaluationResult {
|
|
|
73
86
|
blocked: boolean;
|
|
74
87
|
trace: EvaluationTraceEntry[];
|
|
75
88
|
summary: string;
|
|
89
|
+
criterionScores?: CriterionScore[];
|
|
90
|
+
findings?: EvaluationFinding[];
|
|
91
|
+
strengths?: string[];
|
|
92
|
+
needsLlm?: boolean;
|
|
93
|
+
llmPrompt?: string;
|
|
76
94
|
}
|
package/dist/evaluation/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{};
|
|
@@ -1,27 +1 @@
|
|
|
1
|
-
export const REQUIREMENT_PASS_THRESHOLD =
|
|
2
|
-
export function normalizeInjection(injection) {
|
|
3
|
-
return {
|
|
4
|
-
intent: injection?.intent,
|
|
5
|
-
preferences: injection?.preferences,
|
|
6
|
-
requirements: injection?.requirements ?? [],
|
|
7
|
-
overrides: injection?.overrides ?? {},
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
export function isRuleEnabled(ruleId, injection) {
|
|
11
|
-
const override = injection?.overrides?.rules?.[ruleId];
|
|
12
|
-
if (override && override.enabled !== undefined)
|
|
13
|
-
return override.enabled;
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
export function isDataSourceEnabled(dataSourceId, injection) {
|
|
17
|
-
const override = injection?.overrides?.data_sources?.[dataSourceId];
|
|
18
|
-
if (override && override.enabled !== undefined)
|
|
19
|
-
return override.enabled;
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
export function effectiveWeight(rule, injection) {
|
|
23
|
-
const override = injection?.overrides?.rules?.[rule.id];
|
|
24
|
-
if (override && override.weight !== undefined)
|
|
25
|
-
return override.weight;
|
|
26
|
-
return rule.weight;
|
|
27
|
-
}
|
|
1
|
+
export const REQUIREMENT_PASS_THRESHOLD=0x3c;export function normalizeInjection(a){return{'intent':a?.['intent'],'preferences':a?.['preferences'],'requirements':a?.['requirements']??[],'overrides':a?.['overrides']??{}};}export function isRuleEnabled(a,b){const c=b?.['overrides']?.['rules']?.[a];if(c&&c['enabled']!==undefined)return c['enabled'];return!![];}export function isDataSourceEnabled(a,b){const c=b?.['overrides']?.['data_sources']?.[a];if(c&&c['enabled']!==undefined)return c['enabled'];return!![];}export function effectiveWeight(a,b){const c=b?.['overrides']?.['rules']?.[a['id']];if(c&&c['weight']!==undefined)return c['weight'];return a['weight'];}
|
|
@@ -1,103 +1 @@
|
|
|
1
|
-
import { extractSignals }
|
|
2
|
-
const MAX_HISTORY = 200;
|
|
3
|
-
const history = [];
|
|
4
|
-
export function recordSignature(sig) {
|
|
5
|
-
try {
|
|
6
|
-
history.push(sig);
|
|
7
|
-
if (history.length > MAX_HISTORY) {
|
|
8
|
-
history.shift();
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
catch {
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
export function findMatches(intent, operation_type, data, limit = 3) {
|
|
15
|
-
try {
|
|
16
|
-
const currentSignals = extractSignals(operation_type, data);
|
|
17
|
-
const now = Date.now();
|
|
18
|
-
const scored = history
|
|
19
|
-
.map((sig) => {
|
|
20
|
-
const relevance = computeRelevance(sig, intent, currentSignals, now);
|
|
21
|
-
return { signature: sig, relevance };
|
|
22
|
-
})
|
|
23
|
-
.filter((s) => s.relevance > 0.3)
|
|
24
|
-
.sort((a, b) => b.relevance - a.relevance)
|
|
25
|
-
.slice(0, limit);
|
|
26
|
-
return scored.map((s) => formatMatch(s.signature, s.relevance));
|
|
27
|
-
}
|
|
28
|
-
catch {
|
|
29
|
-
return [];
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
function computeRelevance(sig, currentIntent, currentSignals, now) {
|
|
33
|
-
let score = 0;
|
|
34
|
-
if (sig.intent === currentIntent) {
|
|
35
|
-
score += 0.5;
|
|
36
|
-
}
|
|
37
|
-
else if (sig.intent.startsWith(currentIntent.split("_")[0])) {
|
|
38
|
-
score += 0.2;
|
|
39
|
-
}
|
|
40
|
-
const sigKeys = Object.keys(sig.signals);
|
|
41
|
-
if (sigKeys.length > 0) {
|
|
42
|
-
const overlap = sigKeys.filter((k) => {
|
|
43
|
-
const sigVal = JSON.stringify(sig.signals[k]);
|
|
44
|
-
const curVal = JSON.stringify(currentSignals[k]);
|
|
45
|
-
return sigVal === curVal;
|
|
46
|
-
}).length;
|
|
47
|
-
score += (overlap / sigKeys.length) * 0.3;
|
|
48
|
-
}
|
|
49
|
-
const ageDays = (now - sig.timestamp) / (1000 * 60 * 60 * 24);
|
|
50
|
-
const decay = Math.exp(-ageDays / 30);
|
|
51
|
-
score *= decay;
|
|
52
|
-
return Math.min(1, score);
|
|
53
|
-
}
|
|
54
|
-
function formatMatch(sig, relevance) {
|
|
55
|
-
const advice = buildAdvice(sig);
|
|
56
|
-
const avoid = buildAvoid(sig);
|
|
57
|
-
return {
|
|
58
|
-
signature: sig,
|
|
59
|
-
relevance,
|
|
60
|
-
advice,
|
|
61
|
-
avoid,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
function buildAdvice(sig) {
|
|
65
|
-
if (sig.outcome === "success") {
|
|
66
|
-
if (sig.recovery_path && sig.recovery_path.length > 0) {
|
|
67
|
-
return `Last ${sig.intent} succeeded (after ${sig.recovery_path.length} recovery steps), you can follow the same path.`;
|
|
68
|
-
}
|
|
69
|
-
return `Last ${sig.intent} succeeded, parameter configuration is valid.`;
|
|
70
|
-
}
|
|
71
|
-
if (sig.outcome === "failed" && sig.error_code) {
|
|
72
|
-
return `Last ${sig.intent} failed (${sig.error_code}), please check the relevant parameters.`;
|
|
73
|
-
}
|
|
74
|
-
return `Last ${sig.intent} partially succeeded, check result completeness.`;
|
|
75
|
-
}
|
|
76
|
-
function buildAvoid(sig) {
|
|
77
|
-
const avoid = [];
|
|
78
|
-
if (sig.outcome !== "success" && sig.error_code) {
|
|
79
|
-
avoid.push(`Avoid triggering ${sig.error_code} error`);
|
|
80
|
-
}
|
|
81
|
-
if (sig.recovery_path && sig.recovery_path.length > 0) {
|
|
82
|
-
avoid.push(`Note: last time required ${sig.recovery_path.length} recovery steps to succeed`);
|
|
83
|
-
}
|
|
84
|
-
return avoid;
|
|
85
|
-
}
|
|
86
|
-
export function getHistory(intent) {
|
|
87
|
-
if (intent) {
|
|
88
|
-
return history.filter((h) => h.intent === intent);
|
|
89
|
-
}
|
|
90
|
-
return [...history];
|
|
91
|
-
}
|
|
92
|
-
export function clearHistory() {
|
|
93
|
-
history.length = 0;
|
|
94
|
-
}
|
|
95
|
-
export function getHistoryStats() {
|
|
96
|
-
const byOutcome = {};
|
|
97
|
-
const byIntent = {};
|
|
98
|
-
for (const h of history) {
|
|
99
|
-
byOutcome[h.outcome] = (byOutcome[h.outcome] ?? 0) + 1;
|
|
100
|
-
byIntent[h.intent] = (byIntent[h.intent] ?? 0) + 1;
|
|
101
|
-
}
|
|
102
|
-
return { total: history.length, by_outcome: byOutcome, by_intent: byIntent };
|
|
103
|
-
}
|
|
1
|
+
import{extractSignals}from'./intent-distill.js';const MAX_HISTORY=0xc8,history=[];export function recordSignature(a){try{history['push'](a),history['length']>MAX_HISTORY&&history['shift']();}catch{}}export function findMatches(a,b,c,d=0x3){try{const e=extractSignals(b,c),f=Date['now'](),g=history['map'](h=>{const i=computeRelevance(h,a,e,f);return{'signature':h,'relevance':i};})['filter'](h=>h['relevance']>0.3)['sort']((h,i)=>i['relevance']-h['relevance'])['slice'](0x0,d);return g['map'](h=>formatMatch(h['signature'],h['relevance']));}catch{return[];}}function computeRelevance(a,b,c,d){let e=0x0;if(a['intent']===b)e+=0.5;else a['intent']['startsWith'](b['split']('_')[0x0])&&(e+=0.2);const f=Object['keys'](a['signals']);if(f['length']>0x0){const i=f['filter'](j=>{const l=JSON['stringify'](a['signals'][j]),m=JSON['stringify'](c[j]);return l===m;})['length'];e+=i/f['length']*0.3;}const g=(d-a['timestamp'])/(0x3e8*0x3c*0x3c*0x18),h=Math['exp'](-g/0x1e);return e*=h,Math['min'](0x1,e);}function formatMatch(a,b){const c=buildAdvice(a),d=buildAvoid(a);return{'signature':a,'relevance':b,'advice':c,'avoid':d};}function buildAdvice(a){if(a['outcome']==='success'){if(a['recovery_path']&&a['recovery_path']['length']>0x0)return'Last\x20'+a['intent']+'\x20succeeded\x20(after\x20'+a['recovery_path']['length']+'\x20recovery\x20steps),\x20you\x20can\x20follow\x20the\x20same\x20path.';return'Last\x20'+a['intent']+'\x20succeeded,\x20parameter\x20configuration\x20is\x20valid.';}if(a['outcome']==='failed'&&a['error_code'])return'Last\x20'+a['intent']+'\x20failed\x20('+a['error_code']+'),\x20please\x20check\x20the\x20relevant\x20parameters.';return'Last\x20'+a['intent']+'\x20partially\x20succeeded,\x20check\x20result\x20completeness.';}function buildAvoid(a){const b=[];return a['outcome']!=='success'&&a['error_code']&&b['push']('Avoid\x20triggering\x20'+a['error_code']+'\x20error'),a['recovery_path']&&a['recovery_path']['length']>0x0&&b['push']('Note:\x20last\x20time\x20required\x20'+a['recovery_path']['length']+'\x20recovery\x20steps\x20to\x20succeed'),b;}export function getHistory(a){if(a)return history['filter'](b=>b['intent']===a);return[...history];}export function clearHistory(){history['length']=0x0;}export function getHistoryStats(){const a={},b={};for(const c of history){a[c['outcome']]=(a[c['outcome']]??0x0)+0x1,b[c['intent']]=(b[c['intent']]??0x0)+0x1;}return{'total':history['length'],'by_outcome':a,'by_intent':b};}
|