@wowok/agent-mcp 3.1.0 → 3.1.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/runtime.js +1 -1
- package/dist/customer/index.d.ts +3 -9
- package/dist/customer/index.js +1 -1
- package/dist/customer/industry-risks.d.ts +3 -17
- package/dist/customer/industry-risks.js +1 -1
- package/dist/customer/types.d.ts +1 -165
- package/dist/customer/types.js +1 -1
- package/dist/customer/user-preferences.d.ts +0 -49
- package/dist/customer/user-preferences.js +1 -1
- package/dist/evaluation/arbitration-game.js +1 -1
- package/dist/evaluation/architecture.spec.d.ts +1 -0
- package/dist/evaluation/architecture.spec.js +1 -0
- package/dist/evaluation/builtins/graph-service.d.ts +16 -0
- package/dist/evaluation/builtins/graph-service.js +1 -0
- package/dist/evaluation/builtins/graph-service.spec.d.ts +1 -0
- package/dist/evaluation/builtins/graph-service.spec.js +1 -0
- package/dist/evaluation/builtins/index.d.ts +1 -1
- package/dist/evaluation/builtins/index.js +1 -1
- package/dist/evaluation/builtins/purity.spec.d.ts +1 -0
- package/dist/evaluation/builtins/purity.spec.js +1 -0
- package/dist/evaluation/engine.js +1 -1
- package/dist/evaluation/facets/catalog.d.ts +19 -0
- package/dist/evaluation/facets/catalog.js +1 -0
- package/dist/evaluation/guard-scan.d.ts +10 -0
- package/dist/evaluation/guard-scan.js +1 -0
- package/dist/evaluation/location-match.js +1 -1
- package/dist/evaluation/standards.d.ts +31 -0
- package/dist/evaluation/standards.js +1 -0
- package/dist/evaluation/standards.spec.d.ts +1 -0
- package/dist/evaluation/standards.spec.js +1 -0
- package/dist/evaluation/types.d.ts +9 -0
- package/dist/experience/realtime-feedback.js +1 -1
- package/dist/extensions/index.d.ts +1 -1
- package/dist/extensions/index.js +1 -1
- package/dist/extensions/industry-layers.d.ts +6 -5
- package/dist/extensions/industry-layers.js +1 -1
- package/dist/extensions/industry-pack.js +1 -1
- package/dist/goal/GoalClassifier.js +1 -1
- package/dist/graph/onchain/analyze.d.ts +16 -3
- package/dist/graph/onchain/analyze.js +1 -1
- package/dist/graph/onchain/analyze.spec.js +1 -1
- package/dist/graph/onchain/dataplane.d.ts +1 -1
- package/dist/graph/onchain/dataplane.js +1 -1
- package/dist/graph/onchain/edge-batch.spec.d.ts +1 -0
- package/dist/graph/onchain/edge-batch.spec.js +1 -0
- package/dist/graph/onchain/edge-schema.d.ts +11 -3
- package/dist/graph/onchain/edge-schema.js +1 -1
- package/dist/graph/onchain/entity-profile.spec.d.ts +1 -0
- package/dist/graph/onchain/entity-profile.spec.js +1 -0
- package/dist/graph/onchain/event-history.spec.d.ts +1 -0
- package/dist/graph/onchain/event-history.spec.js +1 -0
- package/dist/graph/onchain/expand.js +1 -1
- package/dist/graph/onchain/extract-deep.spec.d.ts +1 -0
- package/dist/graph/onchain/extract-deep.spec.js +1 -0
- package/dist/graph/onchain/extract.d.ts +11 -3
- package/dist/graph/onchain/extract.js +1 -1
- package/dist/graph/onchain/facet-projection.d.ts +99 -0
- package/dist/graph/onchain/facet-projection.js +1 -0
- package/dist/graph/onchain/facet-projection.spec.d.ts +1 -0
- package/dist/graph/onchain/facet-projection.spec.js +1 -0
- package/dist/graph/onchain/facts.d.ts +103 -0
- package/dist/graph/onchain/facts.js +1 -0
- package/dist/graph/onchain/facts.spec.d.ts +1 -0
- package/dist/graph/onchain/facts.spec.js +1 -0
- package/dist/graph/onchain/field-manifest.d.ts +29 -0
- package/dist/graph/onchain/field-manifest.js +1 -0
- package/dist/graph/onchain/field-manifest.spec.d.ts +1 -0
- package/dist/graph/onchain/field-manifest.spec.js +1 -0
- package/dist/graph/onchain/fixtures.d.ts +80 -0
- package/dist/graph/onchain/fixtures.js +1 -0
- package/dist/graph/onchain/fixtures.spec.d.ts +1 -0
- package/dist/graph/onchain/fixtures.spec.js +1 -0
- package/dist/graph/onchain/index.d.ts +8 -2
- package/dist/graph/onchain/index.js +1 -1
- package/dist/graph/onchain/interest.js +1 -1
- package/dist/graph/onchain/label-lint.spec.d.ts +1 -0
- package/dist/graph/onchain/label-lint.spec.js +1 -0
- package/dist/graph/onchain/names.d.ts +23 -0
- package/dist/graph/onchain/names.js +1 -0
- package/dist/graph/onchain/names.spec.d.ts +1 -0
- package/dist/graph/onchain/names.spec.js +1 -0
- package/dist/graph/onchain/onchain.spec.js +1 -1
- package/dist/graph/onchain/proposal-graph.d.ts +11 -0
- package/dist/graph/onchain/proposal-graph.js +1 -0
- package/dist/graph/onchain/proposal-graph.spec.d.ts +1 -0
- package/dist/graph/onchain/proposal-graph.spec.js +1 -0
- package/dist/graph/onchain/sdk-batch.d.ts +5 -1
- package/dist/graph/onchain/sdk-batch.js +1 -1
- package/dist/graph/onchain/sdk-dataplane.js +1 -1
- package/dist/graph/onchain/strategy.d.ts +16 -0
- package/dist/graph/onchain/strategy.js +1 -1
- package/dist/graph/onchain/strategy.spec.js +1 -1
- package/dist/graph/onchain/table-ledger.spec.d.ts +1 -0
- package/dist/graph/onchain/table-ledger.spec.js +1 -0
- package/dist/graph/onchain/types.d.ts +51 -11
- package/dist/graph/onchain/viewport.d.ts +1 -0
- package/dist/graph/onchain/viewport.js +1 -1
- package/dist/harness/index.d.ts +1 -5
- package/dist/harness/index.js +1 -1
- package/dist/harness/verify.d.ts +6 -1
- package/dist/harness/verify.js +1 -1
- package/dist/index.js +1 -1
- package/dist/knowledge/allocation-ledger.d.ts +2 -0
- package/dist/knowledge/allocation-ledger.js +1 -1
- package/dist/knowledge/allocation-puzzle.js +1 -1
- package/dist/knowledge/allocation-risk.d.ts +2 -3
- package/dist/knowledge/allocation-risk.js +1 -1
- package/dist/knowledge/arb-risk.d.ts +0 -1
- package/dist/knowledge/arb-risk.js +1 -1
- package/dist/knowledge/arbitration-risk.d.ts +0 -2
- package/dist/knowledge/arbitration-risk.js +1 -1
- package/dist/knowledge/baselines/evaluation-baselines.json +79 -0
- package/dist/knowledge/baselines/guard-lint-baseline.spec.d.ts +1 -0
- package/dist/knowledge/baselines/guard-lint-baseline.spec.js +1 -0
- package/dist/knowledge/baselines/risk-baselines.spec.d.ts +1 -0
- package/dist/knowledge/baselines/risk-baselines.spec.js +1 -0
- package/dist/knowledge/baselines/risk-cases.d.ts +8 -0
- package/dist/knowledge/baselines/risk-cases.js +1 -0
- package/dist/knowledge/bridge-risk.d.ts +0 -1
- package/dist/knowledge/bridge-risk.js +1 -1
- package/dist/knowledge/contact-risk.d.ts +0 -1
- package/dist/knowledge/contact-risk.js +1 -1
- package/dist/knowledge/contract-invariants.d.ts +1 -0
- package/dist/knowledge/contract-invariants.js +1 -1
- package/dist/knowledge/demand-risk.d.ts +0 -1
- package/dist/knowledge/demand-risk.js +1 -1
- package/dist/knowledge/getting-started.js +1 -1
- package/dist/knowledge/guard-design-patterns.js +1 -1
- package/dist/knowledge/guard-eval.d.ts +15 -0
- package/dist/knowledge/guard-eval.js +1 -0
- package/dist/knowledge/guard-eval.spec.d.ts +1 -0
- package/dist/knowledge/guard-eval.spec.js +1 -0
- package/dist/knowledge/guard-field-cognition.d.ts +48 -0
- package/dist/knowledge/guard-field-cognition.js +1 -0
- package/dist/knowledge/guard-lint.d.ts +1 -1
- package/dist/knowledge/guard-lint.js +1 -1
- package/dist/knowledge/guard-risk.d.ts +4 -19
- package/dist/knowledge/guard-risk.js +1 -1
- package/dist/knowledge/index.d.ts +42 -43
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/industry-rule-node.d.ts +7 -0
- package/dist/knowledge/industry-rule-node.js +1 -0
- package/dist/knowledge/industry-strategy.js +1 -1
- package/dist/knowledge/jsonrpc-enum.js +1 -1
- package/dist/knowledge/machine-risk.d.ts +0 -6
- package/dist/knowledge/machine-risk.js +1 -1
- package/dist/knowledge/order-risk.d.ts +1 -9
- package/dist/knowledge/order-risk.js +1 -1
- package/dist/knowledge/payment-risk.d.ts +0 -1
- package/dist/knowledge/payment-risk.js +1 -1
- package/dist/knowledge/permission-risk.d.ts +0 -3
- package/dist/knowledge/permission-risk.js +1 -1
- package/dist/knowledge/personal-risk.d.ts +0 -1
- package/dist/knowledge/personal-risk.js +1 -1
- package/dist/knowledge/progress-risk.d.ts +0 -2
- package/dist/knowledge/progress-risk.js +1 -1
- package/dist/knowledge/proof-risk.d.ts +0 -1
- package/dist/knowledge/proof-risk.js +1 -1
- package/dist/knowledge/puzzle-projections.d.ts +11 -0
- package/dist/knowledge/puzzle-projections.js +1 -0
- package/dist/knowledge/recipient-constraint.d.ts +6 -1
- package/dist/knowledge/recipient-constraint.js +1 -1
- package/dist/knowledge/registrar-risk.d.ts +0 -1
- package/dist/knowledge/registrar-risk.js +1 -1
- package/dist/knowledge/repository-risk.d.ts +0 -1
- package/dist/knowledge/repository-risk.js +1 -1
- package/dist/knowledge/resource-risk.d.ts +0 -1
- package/dist/knowledge/resource-risk.js +1 -1
- package/dist/knowledge/reward-risk.d.ts +1 -5
- package/dist/knowledge/reward-risk.js +1 -1
- package/dist/knowledge/rule-node-analyzers.d.ts +43 -0
- package/dist/knowledge/rule-node-analyzers.js +1 -0
- package/dist/knowledge/rule-node-analyzers.spec.d.ts +1 -0
- package/dist/knowledge/rule-node-analyzers.spec.js +1 -0
- package/dist/knowledge/rule-outcome.d.ts +5 -0
- package/dist/knowledge/rule-outcome.js +1 -0
- package/dist/knowledge/safety-rules.js +1 -1
- package/dist/knowledge/scenario-topology.js +1 -1
- package/dist/knowledge/service-allocator-audit-node.d.ts +3 -0
- package/dist/knowledge/service-allocator-audit-node.js +1 -0
- package/dist/knowledge/service-risk-node.js +1 -1
- package/dist/knowledge/service-risk.d.ts +0 -3
- package/dist/knowledge/service-risk.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/tools-reference.js +1 -1
- package/dist/knowledge/treasury-risk.d.ts +2 -3
- package/dist/knowledge/treasury-risk.js +1 -1
- package/dist/knowledge/util-risk.d.ts +0 -1
- package/dist/knowledge/util-risk.js +1 -1
- package/dist/knowledge/workflow-guidance.d.ts +2 -0
- package/dist/knowledge/workflow-guidance.js +1 -1
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/persona/bridge.js +1 -1
- package/dist/persona/facet-profile.d.ts +33 -0
- package/dist/persona/facet-profile.js +1 -0
- package/dist/persona/model.d.ts +2 -1
- package/dist/persona/model.js +1 -1
- package/dist/persona/strategy-intent.js +1 -1
- package/dist/persona/topology-focus.d.ts +2 -2
- package/dist/persona/topology-focus.js +1 -1
- package/dist/persona/types.d.ts +12 -0
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/facet-money.d.ts +22 -0
- package/dist/playbooks/service-build/facet-money.js +1 -0
- package/dist/playbooks/service-build/facet-money.spec.d.ts +1 -0
- package/dist/playbooks/service-build/facet-money.spec.js +1 -0
- package/dist/playbooks/service-build/intent-analyzer.js +1 -1
- package/dist/playbooks/service-build/machine-panorama.d.ts +3 -0
- package/dist/playbooks/service-build/machine-panorama.js +1 -1
- package/dist/playbooks/service-build/object-panorama.d.ts +27 -27
- package/dist/playbooks/service-build/object-panorama.js +1 -1
- package/dist/playbooks/service-build/pipeline-actions.d.ts +2 -2
- package/dist/playbooks/service-build/pipeline-actions.js +1 -1
- package/dist/playbooks/service-build/risk-aggregator.d.ts +2 -1
- package/dist/playbooks/service-build/risk-aggregator.js +1 -1
- package/dist/playbooks/service-build/service-panorama.d.ts +4 -9
- package/dist/playbooks/service-build/service-panorama.js +1 -1
- package/dist/playbooks/service-build/topology-evaluation.spec.d.ts +1 -0
- package/dist/playbooks/service-build/topology-evaluation.spec.js +1 -0
- package/dist/playbooks/service-build/topology-query.d.ts +13 -2
- package/dist/playbooks/service-build/topology-query.js +1 -1
- package/dist/review/arb.d.ts +0 -2
- package/dist/review/arb.js +1 -1
- package/dist/review/order.d.ts +0 -1
- package/dist/review/order.js +1 -1
- package/dist/role/profiles.js +1 -1
- package/dist/rules.d.ts +1 -2
- package/dist/rules.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/safety/preview.js +1 -1
- package/dist/schema/call/base.d.ts +3372 -668
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/handler.js +1 -1
- package/dist/schema/call/receipt.d.ts +28 -0
- package/dist/schema/call/receipt.js +1 -0
- package/dist/schema/call/semantic-customer-advice.spec.d.ts +1 -0
- package/dist/schema/call/semantic-customer-advice.spec.js +1 -0
- package/dist/schema/call/semantic.d.ts +5 -2
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/treasury.js +1 -1
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/evaluation/index.d.ts +289 -211
- package/dist/schema/evaluation/index.js +1 -1
- package/dist/schema/goal/index.d.ts +1 -1
- package/dist/schema/goal/planning.d.ts +2 -2
- package/dist/schema/index.d.ts +0 -1
- package/dist/schema/index.js +1 -1
- package/dist/schema/industry-pack/index.d.ts +1 -1
- package/dist/schema/keeper/index.d.ts +1 -1
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/operations.d.ts +28 -10
- package/dist/schema/operations.js +1 -1
- package/dist/schema/persona/index.d.ts +24 -24
- package/dist/schema/query/bi.d.ts +629 -14
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/query/index.d.ts +9 -9
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema/workspace/index.d.ts +2 -2
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +10 -10
- package/dist/schemas/account_operation.schema.json +3 -3
- package/dist/schemas/bridge_operation.output.json +10 -10
- package/dist/schemas/evaluation_operation.output.json +697 -169
- package/dist/schemas/evaluation_operation.schema.json +5 -434
- package/dist/schemas/index.json +1 -7
- package/dist/schemas/keeper_operation.output.json +10 -10
- package/dist/schemas/local_history_operation.output.json +10 -10
- package/dist/schemas/local_info_operation.output.json +10 -10
- package/dist/schemas/local_mark_operation.output.json +10 -10
- package/dist/schemas/messenger_operation.output.json +10 -10
- package/dist/schemas/monitor_events.output.json +10 -10
- package/dist/schemas/monitor_subscription.output.json +10 -10
- package/dist/schemas/onchain_events.output.json +11 -11
- package/dist/schemas/onchain_operations.output.json +6369 -3736
- package/dist/schemas/onchain_operations.schema.json +48 -48
- package/dist/schemas/onchain_operations_allocation.schema.json +5 -5
- package/dist/schemas/onchain_operations_arbitration.schema.json +3 -3
- package/dist/schemas/onchain_operations_contact.schema.json +2 -2
- package/dist/schemas/onchain_operations_demand.schema.json +2 -2
- package/dist/schemas/onchain_operations_machine.schema.json +2 -2
- package/dist/schemas/onchain_operations_order.schema.json +2 -2
- package/dist/schemas/onchain_operations_payment.schema.json +2 -2
- package/dist/schemas/onchain_operations_permission.schema.json +2 -2
- package/dist/schemas/onchain_operations_progress.schema.json +2 -2
- package/dist/schemas/onchain_operations_repository.schema.json +2 -2
- package/dist/schemas/onchain_operations_reward.schema.json +6 -6
- package/dist/schemas/onchain_operations_service.schema.json +8 -8
- package/dist/schemas/onchain_operations_treasury.schema.json +10 -10
- package/dist/schemas/onchain_table_data.output.json +78 -84
- package/dist/schemas/query_toolkit.output.json +1087 -254
- package/dist/schemas/query_toolkit.schema.json +65 -3
- package/dist/strategy/collectors.js +1 -1
- package/dist/strategy/metrics.js +1 -1
- package/dist/task/playbook.js +1 -1
- package/dist/tools/handlers/bridge.js +1 -1
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/dispatch-expectations.d.ts +3 -0
- package/dist/tools/handlers/dispatch-expectations.js +1 -0
- package/dist/tools/handlers/evaluation.js +1 -1
- package/dist/tools/handlers/evaluation.spec.js +1 -1
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/registry/evaluation.d.ts +2 -0
- package/dist/tools/registry/evaluation.js +1 -0
- package/dist/tools/registry/monitor.js +1 -1
- package/dist/tools/registry/query.js +1 -1
- package/dist/tools/shared.d.ts +0 -1
- package/dist/tools/shared.js +1 -1
- package/dist/tools/wrap.js +1 -1
- package/package.json +4 -3
- package/dist/customer/customer-advice.d.ts +0 -32
- package/dist/customer/customer-advice.js +0 -1
- package/dist/customer/info-puzzle.d.ts +0 -146
- package/dist/customer/info-puzzle.js +0 -1
- package/dist/customer/order-strategy.d.ts +0 -17
- package/dist/customer/order-strategy.js +0 -1
- package/dist/customer/preorder-compare.d.ts +0 -24
- package/dist/customer/preorder-compare.js +0 -1
- package/dist/customer/reminder-system.d.ts +0 -42
- package/dist/customer/reminder-system.js +0 -1
- package/dist/customer/risk-assessment.d.ts +0 -13
- package/dist/customer/risk-assessment.js +0 -1
- package/dist/evaluation/builtins/service-risk.d.ts +0 -7
- package/dist/evaluation/builtins/service-risk.js +0 -1
- package/dist/knowledge/trust-metrics.d.ts +0 -66
- package/dist/knowledge/trust-metrics.js +0 -1
- package/dist/schema/trust/index.d.ts +0 -334
- package/dist/schema/trust/index.js +0 -1
- package/dist/schemas/trust_score.output.json +0 -847
- package/dist/schemas/trust_score.schema.json +0 -364
- package/dist/tools/handlers/trust.d.ts +0 -16
- package/dist/tools/handlers/trust.js +0 -1
- package/dist/tools/registry/trust.d.ts +0 -2
- package/dist/tools/registry/trust.js +0 -1
|
@@ -972,7 +972,7 @@
|
|
|
972
972
|
"query_type"
|
|
973
973
|
],
|
|
974
974
|
"additionalProperties": false,
|
|
975
|
-
"description": "ONE-CALL full business-intelligence context of an on-chain Service (K3 22 / Business Service tab): base data + machine workflow graph + buy_guard/permission/allocator guards + related objects + supply chain +
|
|
975
|
+
"description": "ONE-CALL full business-intelligence context of an on-chain Service (K3 22 / Business Service tab): base data + machine workflow graph + buy_guard/permission/allocator guards + related objects + supply chain + deterministic BusinessReport + recent orders. Every section degrades gracefully — failures are reported in `data_gaps`. Read-only."
|
|
976
976
|
},
|
|
977
977
|
{
|
|
978
978
|
"type": "object",
|
|
@@ -1012,6 +1012,10 @@
|
|
|
1012
1012
|
"description": "On-chain object address (0x followed by 32-64 hex chars) for object_panorama. Also accepts a LocalMark NAME (resolved automatically). H-06 fix: invalid formats are rejected at the handler level with a descriptive error.",
|
|
1013
1013
|
"type": "string"
|
|
1014
1014
|
},
|
|
1015
|
+
"filter": {
|
|
1016
|
+
"description": "DEPRECATED alias of object_address (accepted for call compatibility; must be a plain address or LocalMark NAME string, not an object). Prefer object_address. Example: {\"query_type\": \"object_panorama\", \"object_address\": \"0xabc...\"}.",
|
|
1017
|
+
"type": "string"
|
|
1018
|
+
},
|
|
1015
1019
|
"context_network": {
|
|
1016
1020
|
"type": "string",
|
|
1017
1021
|
"enum": [
|
|
@@ -1272,7 +1276,7 @@
|
|
|
1272
1276
|
"query_type"
|
|
1273
1277
|
],
|
|
1274
1278
|
"additionalProperties": false,
|
|
1275
|
-
"description": "Business Relationship Graph (K3/19): derive ONE account's full relationship web from on-chain power carriers (Permission memberships, Machine forwards, Orders, Demand presenters, Allocation sharing, Arbitration bindings, Contact ims). Each edge carries the three dimensions —
|
|
1279
|
+
"description": "Business Relationship Graph (K3/19): derive ONE account's full relationship web from on-chain power carriers (Permission memberships, Machine forwards, Orders, Demand presenters, Allocation sharing, Arbitration bindings, Contact ims). Each edge carries the three dimensions — power (what each side CAN do, and where that power lives on-chain), interest (gains/exposures, with registry-declared goal tensions like principal-agent divergence), and value flows (escrow → allocation → payment chains). Read-only; roles are DERIVED from chain data, never asserted."
|
|
1276
1280
|
},
|
|
1277
1281
|
{
|
|
1278
1282
|
"type": "object",
|
|
@@ -1461,7 +1465,7 @@
|
|
|
1461
1465
|
"type": "string"
|
|
1462
1466
|
},
|
|
1463
1467
|
"interest_role": {
|
|
1464
|
-
"description": "G2 role interest view — project THIS CommercialRole's complete interest view (
|
|
1468
|
+
"description": "G2 role interest view — project THIS CommercialRole's complete interest view (interest-assessment stakes + node-game actions + counterparties + risk reminders) for context_account (or the seed when it is an EOA) over the same expanded graph. The view is returned as result.role_interest and as one IR:<role> finding carrying the same structured payload. Scoring comes exclusively from the evaluation game modules; when omitted, defaults to the persona 'role' lens if provided.",
|
|
1465
1469
|
"type": "string",
|
|
1466
1470
|
"enum": [
|
|
1467
1471
|
"merchant",
|
|
@@ -1475,6 +1479,40 @@
|
|
|
1475
1479
|
"system"
|
|
1476
1480
|
]
|
|
1477
1481
|
},
|
|
1482
|
+
"facets": {
|
|
1483
|
+
"description": "Per-call facet overrides keyed by the ten facet ids (fund_safety/reputation/arbitration/fulfillment/offering_price/workflow/fund_flow/supply_chain/permission/my_stakes). Highest-precedence lens over role/industry/persona defaults; unknown facet ids are ignored.",
|
|
1484
|
+
"type": "object",
|
|
1485
|
+
"propertyNames": {
|
|
1486
|
+
"type": "string"
|
|
1487
|
+
},
|
|
1488
|
+
"additionalProperties": {
|
|
1489
|
+
"type": "object",
|
|
1490
|
+
"properties": {
|
|
1491
|
+
"visible": {
|
|
1492
|
+
"description": "Hide the facet from the returned items (default visible).",
|
|
1493
|
+
"type": "boolean"
|
|
1494
|
+
},
|
|
1495
|
+
"order": {
|
|
1496
|
+
"description": "Explicit reading-order rank.",
|
|
1497
|
+
"type": "integer",
|
|
1498
|
+
"exclusiveMinimum": 0,
|
|
1499
|
+
"maximum": 9007199254740991
|
|
1500
|
+
},
|
|
1501
|
+
"weight": {
|
|
1502
|
+
"description": "Facet emphasis — distributed to bound rules by document-default proportions (single scoring channel).",
|
|
1503
|
+
"type": "number",
|
|
1504
|
+
"minimum": 0
|
|
1505
|
+
},
|
|
1506
|
+
"threshold": {
|
|
1507
|
+
"description": "Card-highlight hint only; never an engine gate.",
|
|
1508
|
+
"type": "number",
|
|
1509
|
+
"minimum": 0,
|
|
1510
|
+
"maximum": 100
|
|
1511
|
+
}
|
|
1512
|
+
},
|
|
1513
|
+
"additionalProperties": false
|
|
1514
|
+
}
|
|
1515
|
+
},
|
|
1478
1516
|
"no_cache": {
|
|
1479
1517
|
"description": "Set true to bypass the SDK chain-read cache. In-call batching/dedup still applies.",
|
|
1480
1518
|
"type": "boolean"
|
|
@@ -1519,6 +1557,30 @@
|
|
|
1519
1557
|
]
|
|
1520
1558
|
}
|
|
1521
1559
|
},
|
|
1560
|
+
"event_edges": {
|
|
1561
|
+
"description": "Event-derived history edges to expand (channel D, append-only streams, windowless). Default: none (events are opt-in only). 'service.order_history' walks the shop's complete NewOrderEvent stream (beyond the FIFO 5200 shop-order window); 'eoa.order_history' the orders the account created as transacting buyer; 'arb.history' every dispute case an arbitration service handled. Page-budget truncation is reported (windowed confidence), never silent.",
|
|
1562
|
+
"type": "array",
|
|
1563
|
+
"items": {
|
|
1564
|
+
"type": "string",
|
|
1565
|
+
"enum": [
|
|
1566
|
+
"service.order_history",
|
|
1567
|
+
"eoa.order_history",
|
|
1568
|
+
"arb.history"
|
|
1569
|
+
]
|
|
1570
|
+
}
|
|
1571
|
+
},
|
|
1572
|
+
"schema_hops": {
|
|
1573
|
+
"description": "Per-edge-schema traversal caps: how many times an edge of this schema may be crossed on any seed→object path, e.g. {'guard.relies':1}. Only narrows contract-level caps; 0 blocks the schema entirely. Unknown schema ids and out-of-range values are dropped (reported in strategy.trace).",
|
|
1574
|
+
"type": "object",
|
|
1575
|
+
"propertyNames": {
|
|
1576
|
+
"type": "string"
|
|
1577
|
+
},
|
|
1578
|
+
"additionalProperties": {
|
|
1579
|
+
"type": "integer",
|
|
1580
|
+
"minimum": 0,
|
|
1581
|
+
"maximum": 8
|
|
1582
|
+
}
|
|
1583
|
+
},
|
|
1522
1584
|
"budget": {
|
|
1523
1585
|
"description": "Optional expansion-budget overrides. Every fetch stays batched (<=50 ids/request) regardless of these caps; exhaustion is reported honestly in budget_exhausted.",
|
|
1524
1586
|
"type": "object",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Config}from'@wowok/wowok/w/local';import{SdkDataPlane,expandTopology,orderCompletionInGraph}from'../graph/onchain/index.js';import{computeOrderFlow,computeMarketMetrics}from'../knowledge/market-metrics.js';import{computeJourneyFunnel,buildCustomerRelationships}from'../knowledge/market-operations.js';import{enumerateServices}from'../knowledge/jsonrpc-enum.js';import{assessArbitration}from'../evaluation/builtins/arbitration-score.js';import{runAccountEventWatchers}from'../customer/account-events.js';import{STRATEGY_METRIC_CATALOG}from'./metrics.js';const COMPLETED_RE=/completed|closed|finished|done/i;function toCustomerOrders(a){return a['map'](b=>({'id':b['id'],'customer':b['customer'],'time':b['time'],'disputed':b['disputed']??![]}));}const INDUSTRY_DISCOVERY_TERMS={'education':['education','tutor','course','class','learning','
|
|
1
|
+
import{Config}from'@wowok/wowok/w/local';import{SdkDataPlane,expandTopology,orderCompletionInGraph}from'../graph/onchain/index.js';import{computeOrderFlow,computeMarketMetrics}from'../knowledge/market-metrics.js';import{computeJourneyFunnel,buildCustomerRelationships}from'../knowledge/market-operations.js';import{enumerateServices}from'../knowledge/jsonrpc-enum.js';import{assessArbitration}from'../evaluation/builtins/arbitration-score.js';import{runAccountEventWatchers}from'../customer/account-events.js';import{STRATEGY_METRIC_CATALOG}from'./metrics.js';const COMPLETED_RE=/completed|closed|finished|done/i;function toCustomerOrders(a){return a['map'](b=>({'id':b['id'],'customer':b['customer'],'time':b['time'],'disputed':b['disputed']??![]}));}const INDUSTRY_DISCOVERY_TERMS={'education':['education','tutor','course','class','learning','training'],'rental':['rental','rent','lease'],'freelance':['freelance','agency','studio','consulting','design'],'subscription':['subscription','membership','member'],'travel':['travel','tour','trip'],'retail':['shop','store','retail','boutique','mall']};function discoveryTermsFor(a){const b=a['discovery_terms']??INDUSTRY_DISCOVERY_TERMS[a['industry']]??[a['industry']];return b['length']?b:[a['industry']];}const SHOP_ORDER_WINDOW_DEFAULT=0x64,MAX_PERMISSIONS_RESOLVED=0xa,MAX_SERVICES_RESOLVED=0x14,MAX_MACHINE_NODES=0xc8;export async function resolveShopOrderEvidence(a){const b=a['network']??await Config['Instance']()['network_get'](),c=Math['max'](0x1,a['limit']??SHOP_ORDER_WINDOW_DEFAULT),d=new SdkDataPlane(b,{'noCache':a['no_cache']}),f=await expandTopology(d,{'network':b,'seed':a['account'],'budget':{'maxDepth':0x4,'maxNodes':0x4b0,'maxFanoutPerNode':c,'maxRpcs':0x64,'perKindCaps':{'eoa.permission':MAX_PERMISSIONS_RESOLVED,'permission.core_binding':MAX_SERVICES_RESOLVED,'service.order':c,'machine.node':MAX_MACHINE_NODES}},'edges':{'schemas':['eoa.permission','permission.core_binding','service.order','order.machine','order.progress'],'tableEdges':['machine.node']}}),g=new Set();for(const i of f['edges']){if(i['schema']!=='permission.core_binding')continue;if(f['nodes']['get'](i['to']['toLowerCase']())?.['objectType']==='Service')g['add'](i['to']['toLowerCase']());}if(g['size']===0x0&&f['gaps']['length']>0x0)throw new Error('shop\x20topology\x20unreadable\x20for\x20'+a['account']+':\x20'+f['gaps']['slice'](0x0,0x3)['join'](';\x20'));const h=[];for(const j of f['edges']){if(j['schema']!=='service.order'||!g['has'](j['from']['toLowerCase']()))continue;const k=f['nodes']['get'](j['to']['toLowerCase']());if(k?.['objectType']!=='Order'||!k['raw'])continue;const l=k['raw']['data']??k['raw'];h['push']({'id':j['to'],'customer':String(l['builder']??''),'time':Number(BigInt(l['time']??0x0)),'disputed':Array['isArray'](l['dispute'])&&l['dispute']['length']>0x0,'status':orderCompletionInGraph(f,j['to'])['status']});}return h['sort']((m,n)=>n['time']-m['time']),{'orders':h['slice'](0x0,c),'service_count':g['size'],'observed_total':h['length'],'truncated':h['length']>c,'unknown_workflow':h['filter'](m=>m['status']==='unknown')['length']};}const marketOperationsFetcher={'id':'market_operations',async 'fetch'(a){const b={},c=a['orders']??[];if(c['length']===0x0)return b;const d=c['filter'](i=>i['status']?COMPLETED_RE['test'](i['status']):![])['length'],e=computeJourneyFunnel({'due_diligence':a['due_diligence']??0x0,'orders':c['length'],'completed':d,'reviews':a['reviews_count']??0x0});b['order_count']=e['orders'],b['completed_count']=e['completed'],b['completion_rate']=e['order_completion_rate'];if(e['due_diligence']>0x0)b['dd_to_order_rate']=e['dd_to_order_rate'];const f=buildCustomerRelationships(toCustomerOrders(c)),g=f['filter'](i=>i['order_count']>=0x2)['length'];b['repeat_customer_rate']=f['length']>0x0?g/f['length']:0x0;const h=c['filter'](i=>i['disputed'])['length'];return b['dispute_rate']=h/c['length'],b;}},orderFlowFetcher={'id':'order_flow',async 'fetch'(a){const b=a['network']??await Config['Instance']()['network_get'](),c=await computeOrderFlow(b,{'noCache':a['no_cache'],'maxPages':Math['max'](0x1,Math['ceil']((a['limit']??0x64)/0x32))}),d=c['gmv_by_coin']['filter'](f=>f['coin']!=='unknown');let e;if(d['length']===0x1&&c['unclassified_orders']===0x0){const f=BigInt(d[0x0]['amount']);e=f<=BigInt(Number['MAX_SAFE_INTEGER'])?Number(f):{'note':'exact\x20'+d[0x0]['coin']+'\x20GMV\x20'+d[0x0]['amount']+'\x20base\x20units\x20exceeds\x202^53'};}else{const g=c['gmv_by_coin']['map'](h=>h['coin']+'='+h['amount']+'\x20('+h['orders']+'\x20orders)')['join'](';\x20');e={'note':'order\x20volume\x20spans\x20multiple/unresolved\x20coin\x20types\x20and\x20cannot\x20be\x20summed\x20into\x20one\x20GMV\x20'+('('+c['window']+');\x20per-coin\x20base-unit\x20volume:\x20'+(g||'none'))};}return{'market_recent_orders':c['order_count'],'market_recent_gmv':e};}},marketMetricsFetcher={'id':'market_metrics',async 'fetch'(a){const b=a['network']??await Config['Instance']()['network_get'](),c=await computeMarketMetrics(b,a['no_cache']),d={'market_active_services':c['active_services']};if(c['supply_demand_ratio']!==null)d['supply_demand_ratio']=c['supply_demand_ratio'];return d;}},discoverServicesFetcher={'id':'discover_services',async 'fetch'(a){const b=discoveryTermsFor(a)['map'](g=>g['toLowerCase']()),c=a['network']??await Config['Instance']()['network_get'](),d=await enumerateServices(c,{'max_objects':a['limit']??0xc8,'no_cache':a['no_cache']}),e=d['services']['filter'](g=>{const h=((g['name']??'')+'\x20'+(g['json']?.['description']??'')+'\x20'+(g['json']?.['category']??''))['toLowerCase']();return b['some'](i=>h['includes'](i));}),f={'category_enumerated_count':d['total_enumerated']};return f['competitor_count']=e['length']>0x0?e['length']:{'note':'no\x20enumerated\x20service\x20matched\x20the\x20discovery\x20terms;\x20category\x20density\x20reported\x20as\x20category_enumerated_count'},f;}},arbitrationScoreFetcher={'id':'arbitration_score',async 'fetch'(a){const b={};if(!a['arbitration_object'])return b;const c=await assessArbitration({'arbitration':{'object':a['arbitration_object']}});return b['arbitration_trust_score']=c['combined'],b;}},accountEventsFetcher={'id':'account_events',async 'fetch'(a){const b=await runAccountEventWatchers({'account':a['account'],'network':a['network']??await Config['Instance']()['network_get'](),'order_history':(a['orders']??[])['map'](c=>({'id':c['id'],'status':c['status']??''}))});return{'open_attention_count':b['length']};}};export const DEFAULT_METRIC_FETCHERS=[marketOperationsFetcher,orderFlowFetcher,marketMetricsFetcher,discoverServicesFetcher,arbitrationScoreFetcher,accountEventsFetcher];export async function collectScorecard(a,b={}){const c=b['fetchers']??DEFAULT_METRIC_FETCHERS,d=new Set(b['metricIds']??STRATEGY_METRIC_CATALOG['map'](n=>n['id'])),e=Date['now'](),f=[],g=[],h=[],i=new Map();for(const m of STRATEGY_METRIC_CATALOG){if(!d['has'](m['id']))continue;const n=i['get'](m['source'])??[];n['push']({'id':m['id']}),i['set'](m['source'],n);}let j=a;const k=['market_operations','account_events'];if(!a['orders']&&k['some'](o=>i['has'](o)))try{const o=b['resolveOrders']??(q=>resolveShopOrderEvidence(q)['then'](s=>s['orders'])),p=await o(a);p['length']>0x0&&(j={...a,'orders':p});}catch{}await Promise['all']([...i['entries']()]['map'](async([q,r])=>{const s=c['find'](v=>v['id']===q);let t={},u=null;if(!s)u='no\x20fetcher\x20registered\x20for\x20source\x20\x27'+q+'\x27';else try{t=await s['fetch'](j);}catch(v){u=v['message'];}for(const w of r){const x=t[w['id']],y=typeof x==='number'?x:x?.['value'],z=typeof x==='number'?undefined:x?.['note'];if(u)f['push']({'id':w['id'],'source':q,'status':'error','note':u,'collected_at':e}),h['push']({'id':w['id'],'error':u});else typeof y==='number'&&Number['isFinite'](y)?f['push']({'id':w['id'],'source':q,'status':'ok','value':y,'note':z,'collected_at':e}):(f['push']({'id':w['id'],'source':q,'status':'unavailable','note':z,'collected_at':e}),g['push'](w['id']));}}));const l=new Map(STRATEGY_METRIC_CATALOG['map']((q,r)=>[q['id'],r]));return f['sort']((q,r)=>(l['get'](q['id'])??0x0)-(l['get'](r['id'])??0x0)),{'account':a['account'],'industry':a['industry'],'network':a['network']??await Config['Instance']()['network_get'](),'collected_at':e,'metrics':f,'unavailable':g,'errors':h};}
|
package/dist/strategy/metrics.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const w=(a,b,c)=>({'volume':a,'balanced':b,'margin':c});export const STRATEGY_METRIC_CATALOG=[{'id':'order_count','label':'Order\x20count\x20(evidence\x20window)','source':'market_operations','unit':'count','direction':'higher_better','weight':w(0.2,0.15,0.05),'good_threshold':0x14,'bad_threshold':0x5,'description':'Shop\x20orders\x20in\x20the\x20evidence\x20window:\x20resolved\x20from\x20chain\x20topology\x20(account\x20→\x20EntityPermission\x20→\x20Service\x20→\x20ObjectLinkerTx\x20orders,\x20recent\x20capped;\x20per-service\x20FIFO\x20≤5200),\x20or\x20from\x20explicitly\x20supplied\x20evidence.'},{'id':'completed_count','label':'Completed\x20orders','source':'market_operations','unit':'count','direction':'higher_better','weight':w(0.1,0.1,0.1),'description':'Orders\x20that\x20reached\x20the\x20finished/completed\x20progress\x20state.'},{'id':'completion_rate','label':'Order\x20completion\x20rate','source':'market_operations','unit':'rate','direction':'higher_better','weight':w(0.15,0.2,0.15),'good_threshold':0.9,'bad_threshold':0.6,'description':'completed\x20/\x20orders\x20—\x20workflow\x20reliability;\x20K1\x2090-day\x20gate\x20expects\x20100%\x20on-chain\x20dispute\x20closure.'},{'id':'repeat_customer_rate','label':'Repeat\x20customer\x20rate','source':'market_operations','unit':'rate','direction':'higher_better','weight':w(0.2,0.25,0.2),'good_threshold':0.25,'bad_threshold':0.1,'description':'Share\x20of\x20customers\x20with\x20≥2\x20orders;\x20K1\x20quality\x20gate:\x20>25%.'},{'id':'dispute_rate','label':'Dispute\x20rate','source':'market_operations','unit':'rate','direction':'lower_better','weight':w(0.1,0.15,0.2),'good_threshold':0.02,'bad_threshold':0.05,'description':'Orders\x20with\x20a\x20dispute\x20case;\x20>5%\x20triggers\x20a\x20guard-tightening\x20recommendation.'},{'id':'dd_to_order_rate','label':'Due-diligence\x20→\x20order\x20conversion','source':'market_operations','unit':'rate','direction':'higher_better','weight':w(0.15,0.1,0.05),'good_threshold':0.2,'bad_threshold':0.05,'description':'Funnel\x20conversion\x20from\
|
|
1
|
+
const w=(a,b,c)=>({'volume':a,'balanced':b,'margin':c});export const STRATEGY_METRIC_CATALOG=[{'id':'order_count','label':'Order\x20count\x20(evidence\x20window)','source':'market_operations','unit':'count','direction':'higher_better','weight':w(0.2,0.15,0.05),'good_threshold':0x14,'bad_threshold':0x5,'description':'Shop\x20orders\x20in\x20the\x20evidence\x20window:\x20resolved\x20from\x20chain\x20topology\x20(account\x20→\x20EntityPermission\x20→\x20Service\x20→\x20ObjectLinkerTx\x20orders,\x20recent\x20capped;\x20per-service\x20FIFO\x20≤5200),\x20or\x20from\x20explicitly\x20supplied\x20evidence.'},{'id':'completed_count','label':'Completed\x20orders','source':'market_operations','unit':'count','direction':'higher_better','weight':w(0.1,0.1,0.1),'description':'Orders\x20that\x20reached\x20the\x20finished/completed\x20progress\x20state.'},{'id':'completion_rate','label':'Order\x20completion\x20rate','source':'market_operations','unit':'rate','direction':'higher_better','weight':w(0.15,0.2,0.15),'good_threshold':0.9,'bad_threshold':0.6,'description':'completed\x20/\x20orders\x20—\x20workflow\x20reliability;\x20K1\x2090-day\x20gate\x20expects\x20100%\x20on-chain\x20dispute\x20closure.'},{'id':'repeat_customer_rate','label':'Repeat\x20customer\x20rate','source':'market_operations','unit':'rate','direction':'higher_better','weight':w(0.2,0.25,0.2),'good_threshold':0.25,'bad_threshold':0.1,'description':'Share\x20of\x20customers\x20with\x20≥2\x20orders;\x20K1\x20quality\x20gate:\x20>25%.'},{'id':'dispute_rate','label':'Dispute\x20rate','source':'market_operations','unit':'rate','direction':'lower_better','weight':w(0.1,0.15,0.2),'good_threshold':0.02,'bad_threshold':0.05,'description':'Orders\x20with\x20a\x20dispute\x20case;\x20>5%\x20triggers\x20a\x20guard-tightening\x20recommendation.'},{'id':'dd_to_order_rate','label':'Due-diligence\x20→\x20order\x20conversion','source':'market_operations','unit':'rate','direction':'higher_better','weight':w(0.15,0.1,0.05),'good_threshold':0.2,'bad_threshold':0.05,'description':'Funnel\x20conversion\x20from\x20due-diligence\x20graph\x20evaluations\x20(onchain_topology)\x20to\x20created\x20orders.'},{'id':'market_recent_orders','label':'Market\x20recent\x20orders\x20(finite\x20window)','source':'order_flow','unit':'count','direction':'higher_better','weight':w(0.05,0.02,0.02),'description':'Network-wide\x20recent\x20NewOrderEvent\x20count\x20—\x20market\x20temperature,\x20not\x20shop\x20performance.'},{'id':'market_recent_gmv','label':'Market\x20recent\x20order-volume\x20sum\x20(mixed\x20coin\x20base\x20units,\x20finite\x20window)','source':'order_flow','unit':'token_units','direction':'higher_better','weight':w(0.02,0.02,0.02),'description':'Network-wide\x20recent\x20NewOrderEvent\x20amount\x20sum.\x20NOT\x20a\x20comparable\x20GMV:\x20each\x20service\x20mints\x20orders\x20in\x20its\x20own\x20coin\x20type\x20T\x20(u64\x20base\x20units),\x20so\x20the\x20event\x20window\x20mixes\x20BTC/ETH/USDT/USDC/WOW\x20denominations;\x20use\x20only\x20as\x20coarse\x20market-temperature.\x20Unavailable\x20when\x20the\x20exact\x20bigint\x20sum\x20exceeds\x20the\x20safe\x20JS\x20integer\x20range.\x20True\x20per-coin\x20GMV\x20comes\x20from\x20the\x20topology\x20fund-flow\x20layer\x20(service\x20coin\x20type\x20→\x20Payment/Allocation\x20records).'},{'id':'supply_demand_ratio','label':'Supply\x20/\x20open-demand\x20ratio','source':'market_metrics','unit':'ratio','direction':'lower_better','weight':w(0.02,0.03,0.05),'good_threshold':0x1,'bad_threshold':0x4,'description':'Active\x20services\x20per\x20open\x20demand;\x20lower\x20=\x20less\x20supply\x20glut\x20for\x20the\x20shop\x27s\x20category.'},{'id':'market_active_services','label':'Market\x20active\x20services','source':'market_metrics','unit':'count','direction':'lower_better','weight':w(0.01,0.01,0.01),'description':'Published,\x20non-paused\x20network\x20supply\x20count\x20—\x20density\x20context.'},{'id':'competitor_count','label':'Competitor\x20services\x20matching\x20category','source':'discover_services','unit':'count','direction':'lower_better','weight':w(0.02,0.05,0.1),'good_threshold':0x5,'bad_threshold':0x1e,'description':'Services\x20in\x20the\x20event-enumeration\x20window\x20whose\x20name/description/category\x20actually\x20matches\x20the\x20industry\x20discovery\x20terms\x20(exact\x20semantic\x20match).\x20When\x20NOTHING\x20matches,\x20this\x20metric\x20is\x20unavailable\x20(an\x20uninformative\x20term\x20miss\x20is\x20not\x20evidence\x20of\x20zero\x20competition);\x20category_enumerated_count\x20carries\x20the\x20scan\x20density.'},{'id':'category_enumerated_count','label':'Services\x20enumerated\x20in\x20the\x20discovery\x20window','source':'discover_services','unit':'count','direction':'lower_better','weight':w(0.02,0.05,0.1),'description':'Total\x20distinct\x20services\x20the\x20event-driven\x20enumeration\x20could\x20scan\x20(event-window\x20bound,\x20has_more\x20honest).\x20The\x20density/coverage\x20denominator\x20behind\x20competitor_count;\x20contextual\x20only\x20—\x20it\x20counts\x20every\x20category,\x20not\x20just\x20matches.'},{'id':'arbitration_trust_score','label':'Bound\x20arbitration\x20trust\x20score','source':'arbitration_score','unit':'score','direction':'higher_better','weight':w(0.05,0.1,0.15),'good_threshold':0x50,'bad_threshold':0x32,'description':'0–100\x20combined\x20trust+fairness\x20assessment\x20of\x20the\x20shop\x27s\x20bound\x20Arbitration\x20object.'},{'id':'open_attention_count','label':'Open\x20attention\x20items','source':'account_events','unit':'count','direction':'lower_better','weight':w(0.03,0.03,0.05),'good_threshold':0x0,'bad_threshold':0x5,'description':'Account\x20events\x20currently\x20demanding\x20attention\x20(disputes/messages/tasks);\x20process\x20friction.'}];const METRIC_BY_ID=new Map(STRATEGY_METRIC_CATALOG['map'](a=>[a['id'],a]));export function getMetricDef(a){return METRIC_BY_ID['get'](a);}export function metricsBySource(a){return STRATEGY_METRIC_CATALOG['filter'](b=>b['source']===a);}export function listMetricSources(){return[...new Set(STRATEGY_METRIC_CATALOG['map'](a=>a['source']))];}
|
package/dist/task/playbook.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const registry=new Map();export function registerPlaybook(a){if(!a['name'])throw new Error('playbook\x20requires\x20a\x20name');if(a['stages']['length']===0x0)throw new Error('playbook\x20\x27'+a['name']+'\x27\x20requires\x20stages');registry['set'](a['name'],{...a,'stages':[...a['stages']]});}export function getPlaybook(a){return registry['get'](a);}export function listPlaybooks(){return[...registry['values']()];}export function hasPlaybook(a){return registry['has'](a);}export const GENERIC_PLAYBOOK='generic';export function playbookForGoalType(a){switch(a){case'publish_service':return registry['get']('service-build');case'fulfill_order':return registry['get']('order-fulfillment');case'capture_demand':return registry['get']('demand-capture');case'publish_demand':return registry['get']('demand-publish');case'purchase_service':return registry['get']('purchase');case'manage_assets':return registry['get']('governance');default:return registry['get'](GENERIC_PLAYBOOK);}}registerPlaybook({'name':GENERIC_PLAYBOOK,'stages':['prepare','execute','verify','close'],'description':'Fallback\x20stage\x20sequence\x20for\x20goals\x20without\x20a\x20dedicated\x20playbook.'}),registerPlaybook({'name':'service-build','stages':['namespace','puzzle','risk','doc','substeps'],'description':'Design\x20&\x20publish\x20a\x20commercial\x20service\x20(content:\x20src/playbooks/service-build/).'}),registerPlaybook({'name':'order-fulfillment','stages':['confirm','deliver','accept','settle'],'description':'Merchant-side\x20order\x20fulfillment.'}),registerPlaybook({'name':'demand-capture','stages':['discover','evaluate','engage','close'],'description':'Discover\x20and\x20capture\x20demand\x20opportunities.'}),registerPlaybook({'name':'demand-publish','stages':['draft','fund','publish','close'],'description':'Publish\x20a\x20funded\x20demand.'}),registerPlaybook({'name':'purchase','stages':['select','order','monitor','review'],'description':'Purchase\x20a\x20service\x20and\x20see\x20it\x20delivered.'}),registerPlaybook({'name':'governance','stages':['inventory','decide','execute','audit'],'description':'On-chain\x20permission/data/financial\x20governance\x20loop\x20(08\x20
|
|
1
|
+
const registry=new Map();export function registerPlaybook(a){if(!a['name'])throw new Error('playbook\x20requires\x20a\x20name');if(a['stages']['length']===0x0)throw new Error('playbook\x20\x27'+a['name']+'\x27\x20requires\x20stages');registry['set'](a['name'],{...a,'stages':[...a['stages']]});}export function getPlaybook(a){return registry['get'](a);}export function listPlaybooks(){return[...registry['values']()];}export function hasPlaybook(a){return registry['has'](a);}export const GENERIC_PLAYBOOK='generic';export function playbookForGoalType(a){switch(a){case'publish_service':return registry['get']('service-build');case'fulfill_order':return registry['get']('order-fulfillment');case'capture_demand':return registry['get']('demand-capture');case'publish_demand':return registry['get']('demand-publish');case'purchase_service':return registry['get']('purchase');case'manage_assets':return registry['get']('governance');default:return registry['get'](GENERIC_PLAYBOOK);}}registerPlaybook({'name':GENERIC_PLAYBOOK,'stages':['prepare','execute','verify','close'],'description':'Fallback\x20stage\x20sequence\x20for\x20goals\x20without\x20a\x20dedicated\x20playbook.'}),registerPlaybook({'name':'service-build','stages':['namespace','puzzle','risk','doc','substeps'],'description':'Design\x20&\x20publish\x20a\x20commercial\x20service\x20(content:\x20src/playbooks/service-build/).'}),registerPlaybook({'name':'order-fulfillment','stages':['confirm','deliver','accept','settle'],'description':'Merchant-side\x20order\x20fulfillment.'}),registerPlaybook({'name':'demand-capture','stages':['discover','evaluate','engage','close'],'description':'Discover\x20and\x20capture\x20demand\x20opportunities.'}),registerPlaybook({'name':'demand-publish','stages':['draft','fund','publish','close'],'description':'Publish\x20a\x20funded\x20demand.'}),registerPlaybook({'name':'purchase','stages':['select','order','monitor','review'],'description':'Purchase\x20a\x20service\x20and\x20see\x20it\x20delivered.'}),registerPlaybook({'name':'governance','stages':['inventory','decide','execute','audit'],'description':'On-chain\x20permission/data/financial\x20governance\x20loop\x20(08\x20§7\x20N-4;\x20skill:\x20wowok-governance).'});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BridgeClient,LocalMark}from'@wowok/wowok';import{classifyError,buildSemantic,buildDataSemantic}from'../../schema/call/semantic.js';let _bridgeClient=null,_bridgeClientEnv=null;function getBridgeClient(a){const b=a||{},c=b?.['account'],d=b?.['network'];return(_bridgeClient===null||_bridgeClientEnv===null||c!==_bridgeClientEnv?.['account']||d!==_bridgeClientEnv?.['network'])&&(_bridgeClient=new BridgeClient({'wowEnv':b}),_bridgeClientEnv=b),_bridgeClient;}function getBridgeClientForQuery(){if(_bridgeClient!==null)return _bridgeClient;return _bridgeClient=new BridgeClient({}),_bridgeClientEnv={},_bridgeClient;}function validateMainnet(a){const b=a?.['network'];if(b&&b!=='mainnet')throw new Error('Bridge\x20only\x20supports\x20WOW\x20mainnet\x20(current\x20network:\x20\x27'+b+'\x27).\x20Only\x20mainnet\x20provides\x20cross-chain\x20functionality.');}async function resolveWowAddress(a,b){if(!a){const c=b?.['account'];return c;}if(/^0x[0-9a-fA-F]{64}$/['test'](a))return a;try{const d=await LocalMark['Instance']()['get_address'](a);if(d)return d;return a;}catch{return a;}}function safeJson(a){return JSON['stringify'](a,(b,c)=>typeof c==='bigint'?c['toString']():c,0x2);}function convertBigInts(a){if(typeof a==='bigint')return a['toString']();if(Array['isArray'](a))return a['map'](convertBigInts);if(a&&typeof a==='object'){const b={};for(const c of Object['keys'](a))b[c]=convertBigInts(a[c]);return b;}return a;}function ok(a,b,c){const d=convertBigInts(b),e=buildSemantic(d,c),f={'message':a,'result':{'type':'data','data':d},'semantic':e};return{'content':[{'type':'text','text':a},{'type':'text','text':safeJson(d)}],'structuredContent':f};}function err(a,b){const c=classifyError(a),d=buildDataSemantic(undefined,b,!![],a),e={'message':a,'result':{'type':'error','error':a,'error_code':c['error_code'],'retryable':c['retryable'],'recovery_hint':c['recovery_hint']},'semantic':d};return{'content':[{'type':'text','text':a}],'structuredContent':e};}export async function handleBridgeOperations(a){if(!a||typeof a!=='object')return err('Invalid\x20args:\x20expected\x20an\x20object\x20with\x20operation_type');let b;try{const {strictParse:f}=await import('../../schema/call/base.js');b=f((await import('../../schema/call/bridge.js'))['BridgeOperationsSchema'],a,'bridge_operations\x20input');}catch(g){return err('Parameter\x20validation\x20failed:\x20'+(g?.['message']??String(g)));}const c=b['env'],d={'operation_type':'bridge_'+b['operation_type'],'data':b['data']};try{switch(b['operation_type']){case'cross_chain_wow_to_evm':{validateMainnet(c);const h=b['data'],i=getBridgeClient(c),j=await i['bridgeWowToEvmSimple']({'token':h['token'],'amount':BigInt(h['amount']),'withdrawTo':h['withdrawTo'],'waitForFinalization':![],'idempotencyKey':h['idempotencyKey'],'idempotentByParams':h['idempotentByParams']}),k=j['idempotentHit']?'\x20[IDEMPOTENT\x20HIT\x20—\x20no\x20new\x20deposit]':'';return ok('WOW→EVM\x20cross-chain\x20step\x201\x20(deposit)\x20submitted.\x20transferId='+j['transferId']+',\x20activeEvmAccount='+j['activeEvmAccount']+'.'+k+'\x20'+'Next:\x20poll\x20query_transfer_status\x20until\x20bridge\x20signs\x20(~1-5\x20min),\x20then\x20call\x20claim_wow_to_evm\x20to\x20complete.',j,d);}case'cross_chain_evm_to_wow':{validateMainnet(c);const l=b['data'],m=await resolveWowAddress(l['recipientWowAddress'],c),n=getBridgeClient(c),o=await n['bridgeEvmToWowSimple']({'token':l['token'],'amount':BigInt(l['amount']),'recipientWowAddress':m,'waitForFinalization':![],'idempotencyKey':l['idempotencyKey'],'idempotentByParams':l['idempotentByParams']}),p=o['idempotentHit']?'\x20[IDEMPOTENT\x20HIT\x20—\x20no\x20new\x20deposit]':'';return ok('EVM→WOW\x20cross-chain\x20submitted.\x20transferId='+o['transferId']+',\x20activeEvmAccount='+o['activeEvmAccount']+'.'+p+'\x20'+'Bridge\x20will\x20auto-claim\x20on\x20WOW\x20(~10-20\x20min).\x20Poll\x20query_transfer_status\x20to\x20monitor\x20progress.',o,d);}case'claim_wow_to_evm':{validateMainnet(c);const q=b['data'],r=getBridgeClient(c),s=await r['claimWowToEvm'](q['transferId']);return ok('WOW→EVM\x20claim\x20(step\x202)\x20completed.\x20transferId='+s['transferId']+',\x20claimTxHash='+s['claimTxHash'],s,d);}case'resume_transfer':{validateMainnet(c);const t=b['data'],u=getBridgeClient(c),v=await u['resumeTransfer'](t['transferId']);return ok('Transfer\x20'+t['transferId']+'\x20resumed.\x20Current\x20step:\x20'+v['step']+',\x20status:\x20'+v['status']+'.',v,d);}case'withdraw':{const w=b['data'],x=getBridgeClientForQuery();let y=w['tokenAddress'];if(!y&&w['token']&&w['token']!=='ETH'){const A=x['config'],B=A?.['evmChains']?.['find'](D=>D['name']===(w['network']??'mainnet')),C=B?.['tokens']?.['find'](D=>D['symbol']===w['token']);y=C?.['evmAddress'];if(!y)return err('Cannot\x20resolve\x20ERC20\x20token\x20address\x20for\x20symbol\x20\x27'+w['token']+'\x27\x20on\x20chain\x20\x27'+(w['network']??'mainnet')+'\x27.\x20Please\x20pass\x20tokenAddress\x20explicitly.',d);}const z=await x['withdrawFromActiveEvmAccount']({'to':w['to'],'amount':BigInt(w['amount']),'tokenAddress':y,'token':w['token']?w['token']:undefined,'network':w['network']});return ok('Withdrawal\x20submitted.\x20transferId='+z['transferId']+',\x20txHash='+z['txHash'],z,d);}case'query_active_evm_account':{const D=b['data']??{},E=getBridgeClientForQuery(),F=await E['queryActiveEvmAccount']({'network':D['network'],'tokens':D['tokens']});return ok('activeEvmAccount:\x20'+F['address']+'\x20('+F['chains']['length']+'\x20chain(s))',F,d);}case'query_supported_evm_chains':{const G=getBridgeClientForQuery(),H=await G['querySupportedEvmChains']();return ok(H['length']+'\x20EVM\x20chain(s)\x20supported:\x20'+H['map'](I=>I['name']+'(chainId='+I['chainId']+')')['join'](',\x20'),H,d);}case'query_supported_tokens':{const I=b['data']??{},J=getBridgeClientForQuery(),K=await J['querySupportedTokens']({'network':I['network']}),L=K['reduce']((M,N)=>M+N['tokens']['length'],0x0);return ok(K['length']+'\x20chain(s),\x20'+L+'\x20token\x20entries:\x20'+K['map'](M=>M['chainName']+'('+M['tokens']['length']+'\x20tokens)')['join'](',\x20'),K,d);}case'query_transfer_list':{const M=b['data']??{},N=getBridgeClientForQuery();let O=await N['queryTransferList']({'onlyActive':M['onlyActive']});M['status']&&(O=O['filter'](Q=>Q['status']===M['status']));M['direction']&&(O=O['filter'](Q=>Q['direction']===M['direction']));M['token']&&(O=O['filter'](Q=>Q['token']===M['token']));M['limit']&&M['limit']>0x0&&(O=O['slice'](0x0,M['limit']));const P=O['filter'](Q=>Q['status']!=='success'&&Q['status']!=='failed')['length'];return ok(O['length']+'\x20transfer\x20record(s)\x20('+P+'\x20in\x20progress)'+(M['status']||M['direction']||M['token']?'\x20(filtered)':''),O,d);}case'query_transfer_status':{const Q=b['data'],R=getBridgeClientForQuery(),S=Q['refresh']!==![];if(S)try{await Promise['race']([R['refreshTransferStatus'](Q['transferId']),new Promise((U,V)=>setTimeout(()=>V(new Error('refresh\x20timeout')),0x3a98))]);}catch{}const T=await R['queryTransferStatus'](Q['transferId']);if(!T)return err('transferId\x20\x27'+Q['transferId']+'\x27\x20not\x20found.\x20'+'Use\x20query_transfer_list\x20to\x20see\x20all\x20valid\x20transferIds.\x20'+'Note:\x20transfer\x20history\x20is\x20persisted\x20in\x20cache.db\x20and\x20restored\x20on\x20MCP\x20restart,\x20'+'so\x20this\x20transferId\x20may\x20never\x20have\x20been\x20created\x20in\x20this\x20environment.',d);return ok('Transfer\x20'+Q['transferId']+':\x20'+T['direction']+'\x20/\x20'+T['step']+'\x20/\x20'+T['status'],T,d);}case'manage_evm_rpc':{const U=b['data'],V=getBridgeClientForQuery(),W=await V['manageEvmRpc']({'op':U['op'],'network':U['network'],'rpcUrls':U['rpcUrls']});return ok('RPC\x20\x27'+U['op']+'\x27\x20operation\x20'+(W['success']?'succeeded':'failed'),W,d);}default:{return err('Unsupported\x20operation_type:\x20'+b['operation_type'],d);}}}catch(X){const Y=X?.['message']??String(X);return err('Bridge\x20operation\x20failed:\x20'+Y,d);}}
|
|
1
|
+
import{BridgeClient,LocalMark}from'@wowok/wowok';import{classifyError,buildSemantic,buildDataSemantic}from'../../schema/call/semantic.js';import{buildReceipt}from'../../schema/call/receipt.js';import{recover}from'../../harness/recover.js';let _bridgeClient=null,_bridgeClientEnv=null;function getBridgeClient(a){const b=a||{},c=b?.['account'],d=b?.['network'];return(_bridgeClient===null||_bridgeClientEnv===null||c!==_bridgeClientEnv?.['account']||d!==_bridgeClientEnv?.['network'])&&(_bridgeClient=new BridgeClient({'wowEnv':b}),_bridgeClientEnv=b),_bridgeClient;}function getBridgeClientForQuery(){if(_bridgeClient!==null)return _bridgeClient;return _bridgeClient=new BridgeClient({}),_bridgeClientEnv={},_bridgeClient;}function validateMainnet(a){const b=a?.['network'];if(b&&b!=='mainnet')throw new Error('Bridge\x20only\x20supports\x20WOW\x20mainnet\x20(current\x20network:\x20\x27'+b+'\x27).\x20Only\x20mainnet\x20provides\x20cross-chain\x20functionality.');}async function resolveWowAddress(a,b){if(!a){const c=b?.['account'];return c;}if(/^0x[0-9a-fA-F]{64}$/['test'](a))return a;try{const d=await LocalMark['Instance']()['get_address'](a);if(d)return d;return a;}catch{return a;}}function safeJson(a){return JSON['stringify'](a,(b,c)=>typeof c==='bigint'?c['toString']():c,0x2);}function convertBigInts(a){if(typeof a==='bigint')return a['toString']();if(Array['isArray'](a))return a['map'](convertBigInts);if(a&&typeof a==='object'){const b={};for(const c of Object['keys'](a))b[c]=convertBigInts(a[c]);return b;}return a;}function ok(a,b,c){const d=convertBigInts(b),e=buildSemantic(buildReceipt(d),c),f={'outcome':'executed','message':a,'result':{'type':'data','data':d},'semantic':e};return{'content':[{'type':'text','text':a},{'type':'text','text':safeJson(d)}],'structuredContent':f};}function err(a,b){const c=classifyError(a),d=buildDataSemantic(undefined,b,!![],a),e={'outcome':'failed','message':a,'result':{'type':'error','error':a,'error_code':c['error_code'],'retryable':c['retryable'],'recovery_hint':c['recovery_hint']},'recovery':recover(c['error_code']??'unknown',b?.['operation_id']??'bridge'),'semantic':d};return{'content':[{'type':'text','text':a}],'structuredContent':e};}export async function handleBridgeOperations(a){if(!a||typeof a!=='object')return err('Invalid\x20args:\x20expected\x20an\x20object\x20with\x20operation_type');let b;try{const {strictParse:f}=await import('../../schema/call/base.js');b=f((await import('../../schema/call/bridge.js'))['BridgeOperationsSchema'],a,'bridge_operations\x20input');}catch(g){return err('Parameter\x20validation\x20failed:\x20'+(g?.['message']??String(g)));}const c=b['env'],d={'operation_type':'bridge_'+b['operation_type'],'data':b['data']};try{switch(b['operation_type']){case'cross_chain_wow_to_evm':{validateMainnet(c);const h=b['data'],i=getBridgeClient(c),j=await i['bridgeWowToEvmSimple']({'token':h['token'],'amount':BigInt(h['amount']),'withdrawTo':h['withdrawTo'],'waitForFinalization':![],'idempotencyKey':h['idempotencyKey'],'idempotentByParams':h['idempotentByParams']}),k=j['idempotentHit']?'\x20[IDEMPOTENT\x20HIT\x20—\x20no\x20new\x20deposit]':'';return ok('WOW→EVM\x20cross-chain\x20step\x201\x20(deposit)\x20submitted.\x20transferId='+j['transferId']+',\x20activeEvmAccount='+j['activeEvmAccount']+'.'+k+'\x20'+'Next:\x20poll\x20query_transfer_status\x20until\x20bridge\x20signs\x20(~1-5\x20min),\x20then\x20call\x20claim_wow_to_evm\x20to\x20complete.',j,d);}case'cross_chain_evm_to_wow':{validateMainnet(c);const l=b['data'],m=await resolveWowAddress(l['recipientWowAddress'],c),n=getBridgeClient(c),o=await n['bridgeEvmToWowSimple']({'token':l['token'],'amount':BigInt(l['amount']),'recipientWowAddress':m,'waitForFinalization':![],'idempotencyKey':l['idempotencyKey'],'idempotentByParams':l['idempotentByParams']}),p=o['idempotentHit']?'\x20[IDEMPOTENT\x20HIT\x20—\x20no\x20new\x20deposit]':'';return ok('EVM→WOW\x20cross-chain\x20submitted.\x20transferId='+o['transferId']+',\x20activeEvmAccount='+o['activeEvmAccount']+'.'+p+'\x20'+'Bridge\x20will\x20auto-claim\x20on\x20WOW\x20(~10-20\x20min).\x20Poll\x20query_transfer_status\x20to\x20monitor\x20progress.',o,d);}case'claim_wow_to_evm':{validateMainnet(c);const q=b['data'],r=getBridgeClient(c),s=await r['claimWowToEvm'](q['transferId']);return ok('WOW→EVM\x20claim\x20(step\x202)\x20completed.\x20transferId='+s['transferId']+',\x20claimTxHash='+s['claimTxHash'],s,d);}case'resume_transfer':{validateMainnet(c);const t=b['data'],u=getBridgeClient(c),v=await u['resumeTransfer'](t['transferId']);return ok('Transfer\x20'+t['transferId']+'\x20resumed.\x20Current\x20step:\x20'+v['step']+',\x20status:\x20'+v['status']+'.',v,d);}case'withdraw':{const w=b['data'],x=getBridgeClientForQuery();let y=w['tokenAddress'];if(!y&&w['token']&&w['token']!=='ETH'){const A=x['config'],B=A?.['evmChains']?.['find'](D=>D['name']===(w['network']??'mainnet')),C=B?.['tokens']?.['find'](D=>D['symbol']===w['token']);y=C?.['evmAddress'];if(!y)return err('Cannot\x20resolve\x20ERC20\x20token\x20address\x20for\x20symbol\x20\x27'+w['token']+'\x27\x20on\x20chain\x20\x27'+(w['network']??'mainnet')+'\x27.\x20Please\x20pass\x20tokenAddress\x20explicitly.',d);}const z=await x['withdrawFromActiveEvmAccount']({'to':w['to'],'amount':BigInt(w['amount']),'tokenAddress':y,'token':w['token']?w['token']:undefined,'network':w['network']});return ok('Withdrawal\x20submitted.\x20transferId='+z['transferId']+',\x20txHash='+z['txHash'],z,d);}case'query_active_evm_account':{const D=b['data']??{},E=getBridgeClientForQuery(),F=await E['queryActiveEvmAccount']({'network':D['network'],'tokens':D['tokens']});return ok('activeEvmAccount:\x20'+F['address']+'\x20('+F['chains']['length']+'\x20chain(s))',F,d);}case'query_supported_evm_chains':{const G=getBridgeClientForQuery(),H=await G['querySupportedEvmChains']();return ok(H['length']+'\x20EVM\x20chain(s)\x20supported:\x20'+H['map'](I=>I['name']+'(chainId='+I['chainId']+')')['join'](',\x20'),H,d);}case'query_supported_tokens':{const I=b['data']??{},J=getBridgeClientForQuery(),K=await J['querySupportedTokens']({'network':I['network']}),L=K['reduce']((M,N)=>M+N['tokens']['length'],0x0);return ok(K['length']+'\x20chain(s),\x20'+L+'\x20token\x20entries:\x20'+K['map'](M=>M['chainName']+'('+M['tokens']['length']+'\x20tokens)')['join'](',\x20'),K,d);}case'query_transfer_list':{const M=b['data']??{},N=getBridgeClientForQuery();let O=await N['queryTransferList']({'onlyActive':M['onlyActive']});M['status']&&(O=O['filter'](Q=>Q['status']===M['status']));M['direction']&&(O=O['filter'](Q=>Q['direction']===M['direction']));M['token']&&(O=O['filter'](Q=>Q['token']===M['token']));M['limit']&&M['limit']>0x0&&(O=O['slice'](0x0,M['limit']));const P=O['filter'](Q=>Q['status']!=='success'&&Q['status']!=='failed')['length'];return ok(O['length']+'\x20transfer\x20record(s)\x20('+P+'\x20in\x20progress)'+(M['status']||M['direction']||M['token']?'\x20(filtered)':''),O,d);}case'query_transfer_status':{const Q=b['data'],R=getBridgeClientForQuery(),S=Q['refresh']!==![];if(S)try{await Promise['race']([R['refreshTransferStatus'](Q['transferId']),new Promise((U,V)=>setTimeout(()=>V(new Error('refresh\x20timeout')),0x3a98))]);}catch{}const T=await R['queryTransferStatus'](Q['transferId']);if(!T)return err('transferId\x20\x27'+Q['transferId']+'\x27\x20not\x20found.\x20'+'Use\x20query_transfer_list\x20to\x20see\x20all\x20valid\x20transferIds.\x20'+'Note:\x20transfer\x20history\x20is\x20persisted\x20in\x20cache.db\x20and\x20restored\x20on\x20MCP\x20restart,\x20'+'so\x20this\x20transferId\x20may\x20never\x20have\x20been\x20created\x20in\x20this\x20environment.',d);return ok('Transfer\x20'+Q['transferId']+':\x20'+T['direction']+'\x20/\x20'+T['step']+'\x20/\x20'+T['status'],T,d);}case'manage_evm_rpc':{const U=b['data'],V=getBridgeClientForQuery(),W=await V['manageEvmRpc']({'op':U['op'],'network':U['network'],'rpcUrls':U['rpcUrls']});return ok('RPC\x20\x27'+U['op']+'\x27\x20operation\x20'+(W['success']?'succeeded':'failed'),W,d);}default:{return err('Unsupported\x20operation_type:\x20'+b['operation_type'],d);}}}catch(X){const Y=X?.['message']??String(X);return err('Bridge\x20operation\x20failed:\x20'+Y,d);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{listServices,getServiceInfo,toggle as
|
|
1
|
+
import{listServices,getServiceInfo,toggle as a393a,setEnabled as a393b,reset as a393c}from'../../config/index.js';import{strictParse}from'../../schema/index.js';import{ConfigOperationInputSchema}from'../../schema/config/index.js';export async function handleConfigOperation(a){const b=strictParse(ConfigOperationInputSchema,a,'config_operation\x20input'),{action:c,service:d}=b;let e;switch(c){case'list':e={'action':'list','services':listServices()};break;case'toggle':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20toggle');const f=d,g=getServiceInfo(f);if(!g)throw new Error('Unknown\x20service:\x20'+f+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');if(f==='confirm_gate'&&g['enabled'])throw new Error('confirm_gate\x20cannot\x20be\x20disabled\x20at\x20runtime.\x20'+'Set\x20WOWOK_CONFIRM_GATE=0\x20in\x20the\x20server\x20environment\x20and\x20restart\x20if\x20you\x20really\x20want\x20it\x20off.');const h=a393a(f);e={'action':'toggle','service':f,'enabled':h,'reminder':g['reminder']};break;}case'disable':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20disable');const i=d,j=getServiceInfo(i);if(!j)throw new Error('Unknown\x20service:\x20'+i+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');if(i==='confirm_gate')throw new Error('confirm_gate\x20cannot\x20be\x20disabled\x20at\x20runtime.\x20'+'Set\x20WOWOK_CONFIRM_GATE=0\x20in\x20the\x20server\x20environment\x20and\x20restart\x20if\x20you\x20really\x20want\x20it\x20off.');a393b(i,![]),e={'action':'disable','service':i,'enabled':![],'reminder':j['reminder']};break;}case'enable':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20enable');const k=d,l=getServiceInfo(k);if(!l)throw new Error('Unknown\x20service:\x20'+k+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');a393b(k,!![]),e={'action':'enable','service':k,'enabled':!![],'reminder':l['reminder']};break;}case'reset':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20reset');const m=d,n=getServiceInfo(m);if(!n)throw new Error('Unknown\x20service:\x20'+m+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');a393c(m),e={'action':'reset','service':m,'enabled':getServiceInfo(m)?.['enabled'],'reminder':n['reminder'],'reset':!![]};break;}case'info':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20info');const o=d,p=getServiceInfo(o);if(!p)throw new Error('Unknown\x20service:\x20'+o+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');e={'action':'info',...p};break;}default:throw new Error('Unknown\x20config_operation\x20action:\x20'+String(c));}return{'content':[{'type':'text','text':JSON['stringify']({'result':e})}],'structuredContent':{'result':e}};}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ExpectedResult } from "../../harness/types.js";
|
|
2
|
+
export declare function declareDispatchExpectation(operationType: string, data?: Record<string, unknown>): ExpectedResult | undefined;
|
|
3
|
+
export declare function stableOperationId(operationType: string, data?: unknown): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{referencesExistingObject}from'../../schema/call/semantic.js';export function declareDispatchExpectation(a,b){const c={'result_type':'transaction'};let d=a,e=![];switch(a){case'service':if(b?.['publish']===!![]||b?.['bPublished']===!![])c['semantic_modified']=[{'role':'Service','expect_fields':{'bPublished':!![]}}],c['state_transition']={'from':'unpublished','to':'published'},c['events']=[{'type':'ServiceEvent','expect_count':'>=1'}],d='publish\x20service',e=!![];else referencesExistingObject(b)?(c['semantic_modified']=[{'role':'Service'}],d='modify\x20service',e=!![]):(c['semantic_created']=[{'role':'Service'}],d='create\x20service',e=!![]);break;case'machine':referencesExistingObject(b)?(c['semantic_modified']=[{'role':'Machine'}],d='modify\x20machine'):(c['semantic_created']=[{'role':'Machine'}],d='create\x20machine');e=!![];break;case'guard':c['semantic_created']=[{'role':'Guard'}],d='create\x20guard',e=!![];break;case'permission':referencesExistingObject(b)?(c['semantic_modified']=[{'role':'Permission'}],d='modify\x20permission'):(c['semantic_created']=[{'role':'Permission'}],d='create\x20permission');e=!![];break;case'order':b?.['arb']!==undefined?(c['state_transition']={'from':'ordered','to':'arbitration'},c['events']=[{'type':'ArbEvent','expect_count':'>=1'}],d='open\x20arbitration',e=!![]):(c['semantic_created']=[{'role':'Order'}],c['semantic_released']=[{'role':'payment'}],c['events']=[{'type':'NewOrderEvent','expect_count':'>=1'}],d='create\x20order',e=!![]);break;case'payment':c['semantic_released']=[{'role':'payment'}],c['events']=[{'type':'NewPaymentEvent','expect_count':'>=1'}],d='pay\x20order',e=!![];break;case'treasury':b?.['deposit']!==undefined?c['semantic_released']=[{'role':'deposit'}]:c['semantic_released']=[{'role':'release'}];c['events']=[{'type':'TreasuryEvent','expect_count':'>=1'},{'type':'NewPaymentEvent','expect_count':'>=1'}],d='treasury\x20fund\x20movement',e=!![];break;case'reward':if(b?.['claim']!==undefined||b?.['withdraw']!==undefined)c['semantic_released']=[{'role':'reward'}],c['events']=[{'type':'RewardClaimEvent','expect_count':'>=1'}],d='claim\x20reward',e=!![];else b?.['coin']!==undefined||b?.['add']!==undefined?(c['events']=[{'type':'RewardFundEvent','expect_count':'>=1'}],d='fund\x20reward',e=!![]):(c['semantic_created']=[{'role':'Reward'}],d='create\x20reward',e=!![]);break;case'allocation':c['semantic_released']=[{'role':'release'}],c['events']=[{'type':'AllocationEvent','expect_count':'>=1'},{'type':'NewPaymentEvent','expect_count':'>=1'}],d='run\x20allocation',e=!![];break;case'demand':if(b?.['submit']!==undefined||b?.['present']!==undefined)c['semantic_modified']=[{'role':'Demand'}],c['events']=[{'type':'DemandPresentEvent','expect_count':'>=1'}],d='present\x20demand',e=!![];else b?.['reward']!==undefined||b?.['rewards']!==undefined?(c['events']=[{'type':'DemandChangedEvent','expect_count':'>=1'}],d='bind\x20demand\x20reward',e=!![]):(c['semantic_created']=[{'role':'Demand'}],d='create\x20demand',e=!![]);break;case'progress':c['events']=[{'type':'ProgressEvent','expect_count':'>=1'}],d='progress\x20order',e=!![];break;default:return undefined;}if(!e)return undefined;return{'operation':a,'intent':d,'pre_conditions':[],'expected':c};}export function stableOperationId(a,b){return a+':'+fnv1a(canonicalJson(b??null))['toString'](0x10);}function fnv1a(a){let b=0x811c9dc5;for(let c=0x0;c<a['length'];c++){b^=a['charCodeAt'](c),b=Math['imul'](b,0x1000193)>>>0x0;}return b>>>0x0;}function canonicalJson(a){if(a===null||typeof a!=='object')return JSON['stringify'](a)??'null';if(Array['isArray'](a))return'['+a['map'](canonicalJson)['join'](',')+']';const b=Object['keys'](a)['sort']()['map'](c=>JSON['stringify'](c)+':'+canonicalJson(a[c]));return'{'+b['join'](',')+'}';}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{strictParse}from'../../schema/index.js';import{EvaluationOperationInputSchema}from'../../schema/evaluation/index.js';import{evaluateArbGame}from'../../evaluation/arbitration-game.js';import{evaluateNodeGame}from'../../evaluation/node-game.js';import{evaluatePathReasoning}from'../../evaluation/path-reasoning.js';import{assessEvidenceReview,reviewEvidenceList}from'../../knowledge/evidence-review.js';import{expandSearchScope,inferSensitivity,rankByLocation}from'../../evaluation/location-match.js';import{query_objects,ArbStatus}from'@wowok/wowok';import{enumerateServices,enumerateDemands,enumerateArbs}from'../../knowledge/jsonrpc-enum.js';import{fetchObjectLinkerCore,batchQueryObjectsByIds}from'../../graph/onchain/sdk-batch.js';import{summarizeCapabilityGaps}from'../../evaluation/gap.js';import{resolveNetwork}from'./network.js';import{composeServicesForDemand}from'../../evaluation/composer.js';import{matchDemandToServices,matchServiceToDemands}from'../../evaluation/builtins/demand-match.js';import{nextOperationForServiceMatch,nextOperationForDemandMatch,nextOperationForServiceOrder}from'../../evaluation/match-operation.js';import{extractDemandCapability}from'../../evaluation/extract.js';import{assessServiceRisk}from'../../evaluation/builtins/service-risk.js';import{assessArbitration}from'../../evaluation/builtins/arbitration-score.js';import{resolveCategoryMatchRules,toSoftWeightInjection,applyHardConstraints}from'../../evaluation/category-match-rules.js';import{computeMarketMetrics,computeOrderFlow}from'../../knowledge/market-metrics.js';import{workflowSubgraphFromRows}from'../../graph/onchain/index.js';import{assessAntiCheat}from'../../knowledge/anti-cheat.js';import{computeJourneyFunnel,attributeReferrals,buildCustomerRelationships}from'../../knowledge/market-operations.js';import{suggestPricing}from'../../knowledge/dynamic-pricing.js';import{runAccountEventWatchers}from'../../customer/account-events.js';import{registerBuiltinEvaluations}from'../../evaluation/builtins/index.js';import{getEffectivePersona,mergeInjections}from'../../persona/index.js';import{buildUserInjection}from'../../evaluation/injection.js';registerBuiltinEvaluations();function arbCaseFromObject(b){const c=typeof b['time']==='number'?b['time']:Number(b['time']??0x0);return{'status':b['status'],'time':Number['isFinite'](c)?c:undefined,'resolved_time':typeof b['indemnity']?.['time']==='number'?b['indemnity']['time']:b['compensation_time']??undefined,'indemnity_amount':b['indemnity']?.['amount'],'objected':b['status']===ArbStatus['Objectionable']||b['objection']!=null&&b['objection']['length']>0x0};}async function arbCasesWithRoles(a,b){const c=a['map'](arbCaseFromObject),d=Array['from'](new Set(a['map'](j=>j['order'])['filter'](Boolean))),e=new Map(),f=[];if(d['length']>0x0){const j=await batchQueryObjectsByIds(d,b);for(const k of j){const l=k;if(!l?.['object'])continue;e['set'](l['object'],l);if(l['service'])f['push'](l['service']);}}const g=new Map(),h=Array['from'](new Set(f));if(h['length']>0x0){const m=await batchQueryObjectsByIds(h,b);for(const n of m){const p=n;if(p?.['object'])g['set'](p['object'],p);}}for(let q=0x0;q<a['length'];q++){const r=e['get'](a[q]['order']);if(!r)continue;c[q]['customer']=r['builder']||undefined;const t=g['get'](r['service']);if(t)c[q]['merchant']=t['permission']||undefined;}return c;}function capabilityFromInput(a){return{'id':a['id'],'kind':a['kind'],'owner':a['owner']??'','industry':a['industry'],'industry_confidence':a['industry_confidence']??0x0,'region':a['region'],'price_min':a['price_min']!==undefined?BigInt(a['price_min']):undefined,'price_max':a['price_max']!==undefined?BigInt(a['price_max']):undefined,'token_type':a['token_type']??'','ticket_size':a['ticket_size']??'medium','trust_score':a['trust_score']??0x32,'reputation_like_ratio':a['reputation_like_ratio']??0x1,'arbitration_independent':a['arbitration_independent']??![],'merchant_history_count':a['merchant_history_count']??0x0,'capabilities':a['capabilities'],'tags':a['tags']??[],'keywords':a['keywords']??[]};}function puzzleRawFromInput(a){return{'service':{...a['service'],'priceRaw':a['service']['priceRaw']!==undefined?BigInt(a['service']['priceRaw']):undefined,'compensation_fund':a['service']['compensation_fund']?{'balance':a['service']['compensation_fund']['balance']!==undefined?BigInt(a['service']['compensation_fund']['balance']):undefined}:undefined},'machine_nodes':a['machine_nodes'],'machine_published':a['machine_published'],'machine_paused':a['machine_paused'],'reviews':a['reviews'],'events':a['events'],'similar_services':a['similar_services']?.['map'](b=>({'price':BigInt(b['price'])})),'order_amount':a['order_amount']!==undefined?BigInt(a['order_amount']):undefined,'trust_score':a['trust_score'],'arbitration_owner':a['arbitration_owner'],'service_owner':a['service_owner'],'wip_verified':a['wip_verified'],'order_history':a['order_history'],'merchant_reputation':a['merchant_reputation']};}async function resolveInjection(a,b){return mergeInjections(await buildUserInjection(a),b);}function serviceSummaryToExtract(a){const b=a['json']??{},c=f=>typeof f==='string'?f:undefined,d=f=>typeof f==='string'?f:null,e=Array['isArray'](b['sales'])?b['sales']['map'](f=>({'name':typeof f?.['name']==='string'?f['name']:undefined,'price':typeof f?.['price']==='string'?f['price']:f?.['price']!=null?String(f['price']):'0','wip_hash':typeof f?.['wip_hash']==='string'?f['wip_hash']:undefined})):[];return{'object':a['object'],'description':c(b['description'])??'','location':a['location']??c(b['location'])??'','sales':e,'arbitrations':Array['isArray'](b['arbitrations'])?b['arbitrations']['map'](String):[],'compensation_fund':c(b['compensation_fund']),'buy_guard':d(b['buy_guard']),'machine':d(b['machine']),'um':d(b['um']),'bPublished':b['bPublished']===!![],'bPaused':b['bPaused']===!![]};}export async function handleEvaluationOperation(a){const b=strictParse(EvaluationOperationInputSchema,a,'evaluation_operation\x20input');let c;switch(b['action']){case'arb_game':{const e=b['account']?await getEffectivePersona(b['account']):null,f=b['appetite']??e?.['layer']['preferences']?.['risk_appetite'],g=b['requirements']??e?.['layer']['requirements'];c={'action':'arb_game',...evaluateArbGame(b['status'],b['perspective'],{'risk_appetite':f,'requirements':g})};break;}case'node_game':{const h=b['account']?await getEffectivePersona(b['account']):null,i=b['appetite']??h?.['layer']['preferences']?.['risk_appetite'],j=b['requirements']??h?.['layer']['requirements'];c={'action':'node_game',...evaluateNodeGame({'current_node':b['current_node'],'perspective':b['perspective'],'appetite':i,'requirements':j,'threshold':b['threshold'],'allocation':b['allocation'],'order_amount':b['order_amount'],'compensation_fund':b['compensation_fund'],'operable':b['operable'],'waiting_on':b['waiting_on']??[]})};break;}case'capability_gap':{c={'action':'capability_gap','report':summarizeCapabilityGaps(capabilityFromInput(b['demand']),capabilityFromInput(b['service']))};break;}case'compose_service':{c={'action':'compose_service','plan':composeServicesForDemand(capabilityFromInput(b['demand']),b['services']['map'](capabilityFromInput))};break;}case'demand_match':{const k=await matchDemandToServices(capabilityFromInput(b['demand_cap']),b['services'],await resolveInjection(b['account'],b['injection']),0x5,b['presenter_history']);c={'action':'demand_match','matches':k['map'](l=>({'service':l['service'],'result':l['result'],'next':nextOperationForDemandMatch(l['service']),'order':nextOperationForServiceOrder(l['service'])}))};break;}case'service_match':{const l=await matchServiceToDemands(capabilityFromInput(b['service_cap']),b['demands'],await resolveInjection(b['account'],b['injection']),0x5,b['presenter_history']);c={'action':'service_match','matches':l['map'](n=>({'demand':n['demand'],'result':n['result'],'next':nextOperationForServiceMatch(n['demand'],null)}))};break;}case'service_risk':{c={'action':'service_risk','result':await assessServiceRisk(b['service_id'],puzzleRawFromInput(b['puzzle_raw']),await resolveInjection(b['account'],b['injection']),b['depth']??'preorder',b['presenter_history'])};break;}case'path_reasoning':{const m=b['account']?await getEffectivePersona(b['account']):null,n=b['appetite']??m?.['layer']['preferences']?.['risk_appetite'],o=b['requirements']??m?.['layer']['requirements'];c={'action':'path_reasoning',...evaluatePathReasoning({'current_node':b['current_node'],'perspective':b['perspective'],'workflow':workflowSubgraphFromRows(b['machine_nodes']),'node_annotations':b['node_annotations'],'appetite':n,'requirements':o,'order_amount':b['order_amount'],'max_depth':b['max_depth']})};break;}case'evidence_review':{b['items']&&b['items']['length']>0x0?c={'action':'evidence_review','list':reviewEvidenceList(b['items'])}:c={'action':'evidence_review','review':assessEvidenceReview({'kind':b['kind'],'hash_committed':b['hash_committed'],'digital_check_passed':b['digital_check_passed'],'contradiction':b['contradiction']})};break;}case'discover_services':{const p=!b['sensitivity']?inferSensitivity(b['description']??''):null,q=b['sensitivity']??p['sensitivity'],r=p?.['signals']??[],s=await resolveNetwork(b['context_network']),t={'raw':b['location'],...b['region']??{}},u=expandSearchScope(q,t),v=await enumerateServices(s,{'max_objects':b['max_objects'],'no_cache':b['no_cache'],'location_any':u['search_terms']}),w=rankByLocation(q,t,v['services']['map'](x=>({'id':x['object'],'name':x['name'],'location':x['location']})));c={'action':'discover_services','sensitivity':q,'inference_signals':r,'services':w['map'](x=>{const y=v['services']['find'](z=>z['object']===x['id']);return{'object':x['id'],'name':y?.['name'],'location':y?.['location'],'relation':x['relation'],'satisfied':x['satisfied'],'score':x['score'],'reason':x['reason']};}),'total_enumerated':v['total_enumerated'],'has_more':v['has_more'],'scope_advice':{'search_terms':u['search_terms'],'ai_enrichment_note':u['ai_enrichment_note']}};break;}case'discover_demands':{const x=await resolveNetwork(b['context_network']),y=await enumerateDemands(x,{'max_objects':b['max_objects'],'no_cache':b['no_cache']}),z=b['location']?.['toLowerCase'](),A=y['demands']['filter'](B=>!z||(B['location']??'')['toLowerCase']()['includes'](z))['map'](B=>({'object':B['object'],'description':B['description']??'','location':B['location']??'','presenters_count':B['presenters_count']??0x0,'permission':B['permission']??''}));c={'action':'discover_demands','demands':A,'total_enumerated':y['total_enumerated'],'has_more':y['has_more']};break;}case'demand_present':{const B=await resolveNetwork(b['context_network']),C=await enumerateDemands(B,{'max_objects':b['max_objects'],'no_cache':b['no_cache']}),D=b['location']?.['toLowerCase'](),E=C['demands']['filter'](I=>!D||(I['location']??'')['toLowerCase']()['includes'](D)),F=new Map(E['map'](I=>[I['object'],(I['guards']?.['length']??0x0)>0x0])),G=E['map'](I=>({'object':I['object'],'description':I['description']??'','location':I['location']??'','rewards':I['rewards']??[],'um':I['um']??null})),H=await matchServiceToDemands(capabilityFromInput(b['service_cap']),G,await resolveInjection(b['account'],b['injection']),b['limit']??0x5);c={'action':'demand_present','matches':H['map'](I=>{const J=F['get'](I['demand']['object'])??![];return{'demand':I['demand'],'result':I['result'],'next':nextOperationForServiceMatch(I['demand'],J)};}),'total_enumerated':C['total_enumerated'],'has_more':C['has_more']};break;}case'market_metrics':{const I=await resolveNetwork(b['context_network']),J=await computeMarketMetrics(I,b['no_cache']),K=await computeOrderFlow(I,{'noCache':b['no_cache'],'maxPages':b['limit']?Math['max'](0x1,Math['ceil'](b['limit']/0x32)):undefined});c={'action':'market_metrics',...J,'order_flow':K};break;}case'anti_cheat':{const L=assessAntiCheat({'service':{'object':b['service']['object'],'arbitrations':b['service']['arbitrations'],'compensation_fund':b['service']['compensation_fund'],'machine':b['service']['machine'],'bPublished':b['service']['bPublished']},'orders':b['orders'],'reviews':b['reviews']});c={'action':'anti_cheat','signals':L};break;}case'market_operations':{if(b['op']==='journey_funnel')c={'action':'market_operations','result':computeJourneyFunnel({'due_diligence':b['due_diligence']??0x0,'orders':b['orders']??0x0,'completed':b['completed']??0x0,'reviews':b['reviews']??0x0})};else{if(b['op']==='referral_attribution')c={'action':'market_operations','result':attributeReferrals(b['referral_orders']??[])};else{if(b['op']==='dynamic_pricing'){const M=b['market_signals'];if(!M)throw new Error('dynamic_pricing\x20op\x20requires\x20market_signals');c={'action':'market_operations','result':suggestPricing({'supplyCount':M['supplyCount'],'demandCount':M['demandCount'],'avgPrice':M['avgPrice'],'myPrice':M['myPrice'],'competitorPrices':M['competitorPrices'],'recentOrderCount':M['recentOrderCount'],'repeatCustomerRate':M['repeatCustomerRate']})};}else c={'action':'market_operations','result':buildCustomerRelationships(b['customer_orders']??[])};}}break;}case'match_discover':{const N=!b['sensitivity']?inferSensitivity(b['description']??''):null,O=b['sensitivity']??N['sensitivity'],P=N?.['signals']??[],Q=await resolveNetwork(b['context_network']),R={'raw':b['location'],...b['region']??{}},S=expandSearchScope(O,R),T=await enumerateServices(Q,{'max_objects':b['max_objects'],'no_cache':b['no_cache'],'location_any':S['search_terms']}),U=new Set(b['required_capabilities']??[]),V=extractDemandCapability({'object':'intent','description':b['description'],'location':b['location'],'owner':b['account']},{'price_max':b['budget']!==undefined?BigInt(b['budget']):undefined,'capabilities':{'has_arbitration':U['has']('has_arbitration'),'has_refund_path':U['has']('has_refund_path'),'has_milestone_nodes':U['has']('has_milestone_nodes'),'has_compensation_fund':U['has']('has_compensation_fund'),'has_wip_verification':U['has']('has_wip_verification'),'has_messenger':U['has']('has_messenger'),'has_buy_guard':U['has']('has_buy_guard'),'has_dynamic_pricing':U['has']('has_dynamic_pricing'),'is_published':!![],'is_paused':![]}}),W=rankByLocation(O,R,T['services']['map'](a7=>({'id':a7['object'],'name':a7['name'],'location':a7['location']}))),X=W['filter'](a7=>a7['satisfied']),Y=T['services']['filter'](a7=>X['some'](a8=>a8['id']===a7['object']))['map'](serviceSummaryToExtract),Z=resolveCategoryMatchRules(b['category']);let a0=Y;const a1=[];if(Z){const a7=applyHardConstraints(Z,Y);a0=a7['passed'];for(const a8 of a7['dropped']){a1['push']({'object':a8['candidate']['object'],'reason':a8['constraint']['description']});}}let a2=await resolveInjection(b['account'],b['injection']);Z&&(a2=mergeInjections(a2,toSoftWeightInjection(Z)));const a3=await matchDemandToServices(V,a0,a2,a0['length'],b['presenter_history']),a4=new Map(a3['map'](a9=>[a9['service']['object'],a9['result']])),a5=new Set(a0['map'](a9=>a9['object'])),a6=X['filter'](a9=>a5['has'](a9['id']))['map'](a9=>{const aa=T['services']['find'](ab=>ab['object']===a9['id']);return{'service':serviceSummaryToExtract(aa),'location':{'relation':a9['relation'],'satisfied':a9['satisfied'],'score':a9['score'],'reason':a9['reason']},'result':a4['get'](a9['id'])};});c={'action':'match_discover','sensitivity':O,'inference_signals':P,'matches':a6,'total_enumerated':T['total_enumerated'],'has_more':T['has_more'],'scope_advice':{'search_terms':S['search_terms'],'ai_enrichment_note':S['ai_enrichment_note']}};break;}case'arbitration_score':{let a9=b['history'];const aa=b['context_network']??'testnet';if((!a9||a9['length']===0x0)&&b['arbitration']['object'])try{const ac=await enumerateArbs(aa,{'arbitration':b['arbitration']['object']});a9=await arbCasesWithRoles(ac['arbs'],aa);}catch{a9=b['history'];}if((!a9||a9['length']===0x0)&&b['arbitration']['object'])try{const ad=await query_objects({'objects':[b['arbitration']['object']],'network':aa}),ae=ad?.['objects']?.[0x0];if(ae?.['permission']){const af=await fetchObjectLinkerCore(ae['permission'],aa),ag=(af?.['items']??[])['map'](ai=>ai['who'])['filter'](ai=>ai!==b['arbitration']['object']),ah=[];for(const ai of ag['slice'](0x0,0xa)){const aj=await enumerateArbs(aa,{'arbitration':ai})['catch'](()=>undefined);aj?.['arbs']?.['length']&&ah['push'](...await arbCasesWithRoles(aj['arbs'],aa));}if(ah['length']>0x0)a9=ah;}}catch{}const ab=await assessArbitration({'arbitration':{'object':b['arbitration']['object'],'fee':b['arbitration']['fee'],'balance':b['arbitration']['balance'],'voting_guard_count':b['arbitration']['voting_guard_count'],'bPaused':b['arbitration']['bPaused'],'location':b['arbitration']['location'],'has_verified_identity':b['arbitration']['has_verified_identity']},'history':a9,'entity_votes':b['entity_votes'],'fee_median':b['fee_median']},await resolveInjection(b['account'],b['injection']));c={'action':'arbitration_score',...ab};break;}case'account_events':{const ak=await runAccountEventWatchers({'account':b['account'],'network':await resolveNetwork(b['context_network']),'reviews':b['reviews']?.['map'](al=>({'reviewer':al['reviewer'],'rating':al['rating'],'tags':al['tags'],'comment':al['comment'],'orderRef':al['orderRef'],'timestamp':al['timestamp'],'verified':al['verified']??![]})),'order_history':b['order_history']},b['categories']);c={'action':'account_events','events':ak};break;}default:throw new Error('Unknown\x20evaluation_operation\x20action');}return{'content':[{'type':'text','text':JSON['stringify']({'result':c})}],'structuredContent':{'result':c}};}
|
|
1
|
+
import{strictParse}from'../../schema/index.js';import{EvaluationOperationInputSchema}from'../../schema/evaluation/index.js';import{evaluateArbGame}from'../../evaluation/arbitration-game.js';import{evaluateNodeGame}from'../../evaluation/node-game.js';import{evaluatePathReasoning}from'../../evaluation/path-reasoning.js';import{assessEvidenceReview,reviewEvidenceList}from'../../knowledge/evidence-review.js';import{expandSearchScope,inferSensitivity,rankByLocation}from'../../evaluation/location-match.js';import{query_objects,ArbStatus}from'@wowok/wowok';import{enumerateServices,enumerateDemands,enumerateArbs}from'../../knowledge/jsonrpc-enum.js';import{fetchObjectLinkerCore,batchQueryObjectsByIds}from'../../graph/onchain/sdk-batch.js';import{summarizeCapabilityGaps}from'../../evaluation/gap.js';import{resolveNetwork}from'./network.js';import{composeServicesForDemand}from'../../evaluation/composer.js';import{matchDemandToServices,matchServiceToDemands}from'../../evaluation/builtins/demand-match.js';import{nextOperationForServiceMatch,nextOperationForDemandMatch,nextOperationForServiceOrder}from'../../evaluation/match-operation.js';import{extractDemandCapability}from'../../evaluation/extract.js';import{assessArbitration}from'../../evaluation/builtins/arbitration-score.js';import{resolveCategoryMatchRules,toSoftWeightInjection,applyHardConstraints}from'../../evaluation/category-match-rules.js';import{computeMarketMetrics,computeOrderFlow}from'../../knowledge/market-metrics.js';import{workflowSubgraphFromRows}from'../../graph/onchain/index.js';import{assessAntiCheat}from'../../knowledge/anti-cheat.js';import{computeJourneyFunnel,attributeReferrals,buildCustomerRelationships}from'../../knowledge/market-operations.js';import{suggestPricing}from'../../knowledge/dynamic-pricing.js';import{runAccountEventWatchers}from'../../customer/account-events.js';import{registerBuiltinEvaluations}from'../../evaluation/builtins/index.js';import{getEffectivePersona,mergeInjections}from'../../persona/index.js';import{buildUserInjection}from'../../evaluation/injection.js';registerBuiltinEvaluations();function arbCaseFromObject(b){const c=typeof b['time']==='number'?b['time']:Number(b['time']??0x0);return{'status':b['status'],'time':Number['isFinite'](c)?c:undefined,'resolved_time':typeof b['indemnity']?.['time']==='number'?b['indemnity']['time']:b['compensation_time']??undefined,'indemnity_amount':b['indemnity']?.['amount'],'objected':b['status']===ArbStatus['Objectionable']||b['objection']!=null&&b['objection']['length']>0x0};}async function arbCasesWithRoles(a,b){const c=a['map'](arbCaseFromObject),d=Array['from'](new Set(a['map'](j=>j['order'])['filter'](Boolean))),e=new Map(),f=[];if(d['length']>0x0){const j=await batchQueryObjectsByIds(d,b);for(const k of j){const l=k;if(!l?.['object'])continue;e['set'](l['object'],l);if(l['service'])f['push'](l['service']);}}const g=new Map(),h=Array['from'](new Set(f));if(h['length']>0x0){const m=await batchQueryObjectsByIds(h,b);for(const n of m){const p=n;if(p?.['object'])g['set'](p['object'],p);}}for(let q=0x0;q<a['length'];q++){const r=e['get'](a[q]['order']);if(!r)continue;c[q]['customer']=r['builder']||undefined;const t=g['get'](r['service']);if(t)c[q]['merchant']=t['permission']||undefined;}return c;}function capabilityFromInput(a){return{'id':a['id'],'kind':a['kind'],'owner':a['owner']??'','industry':a['industry'],'industry_confidence':a['industry_confidence']??0x0,'region':a['region'],'price_min':a['price_min']!==undefined?BigInt(a['price_min']):undefined,'price_max':a['price_max']!==undefined?BigInt(a['price_max']):undefined,'token_type':a['token_type']??'','ticket_size':a['ticket_size']??'medium','trust_score':a['trust_score']??0x32,'reputation_like_ratio':a['reputation_like_ratio']??0x1,'arbitration_independent':a['arbitration_independent']??![],'merchant_history_count':a['merchant_history_count']??0x0,'capabilities':a['capabilities'],'tags':a['tags']??[],'keywords':a['keywords']??[]};}async function resolveInjection(a,b){return mergeInjections(await buildUserInjection(a),b);}function serviceSummaryToExtract(a){const b=a['json']??{},c=f=>typeof f==='string'?f:undefined,d=f=>typeof f==='string'?f:null,e=Array['isArray'](b['sales'])?b['sales']['map'](f=>({'name':typeof f?.['name']==='string'?f['name']:undefined,'price':typeof f?.['price']==='string'?f['price']:f?.['price']!=null?String(f['price']):'0','wip_hash':typeof f?.['wip_hash']==='string'?f['wip_hash']:undefined})):[];return{'object':a['object'],'description':c(b['description'])??'','location':a['location']??c(b['location'])??'','sales':e,'arbitrations':Array['isArray'](b['arbitrations'])?b['arbitrations']['map'](String):[],'compensation_fund':c(b['compensation_fund']),'buy_guard':d(b['buy_guard']),'machine':d(b['machine']),'um':d(b['um']),'bPublished':b['bPublished']===!![],'bPaused':b['bPaused']===!![]};}export async function handleEvaluationOperation(a){const b=strictParse(EvaluationOperationInputSchema,a,'evaluation_operation\x20input');let c;switch(b['action']){case'arb_game':{const e=b['account']?await getEffectivePersona(b['account']):null,f=b['appetite']??e?.['layer']['preferences']?.['risk_appetite'],g=b['requirements']??e?.['layer']['requirements'];c={'action':'arb_game',...evaluateArbGame(b['status'],b['perspective'],{'risk_appetite':f,'requirements':g})};break;}case'node_game':{const h=b['account']?await getEffectivePersona(b['account']):null,i=b['appetite']??h?.['layer']['preferences']?.['risk_appetite'],j=b['requirements']??h?.['layer']['requirements'];c={'action':'node_game',...evaluateNodeGame({'current_node':b['current_node'],'perspective':b['perspective'],'appetite':i,'requirements':j,'threshold':b['threshold'],'allocation':b['allocation'],'order_amount':b['order_amount'],'compensation_fund':b['compensation_fund'],'operable':b['operable'],'waiting_on':b['waiting_on']??[]})};break;}case'capability_gap':{c={'action':'capability_gap','report':summarizeCapabilityGaps(capabilityFromInput(b['demand']),capabilityFromInput(b['service']))};break;}case'compose_service':{c={'action':'compose_service','plan':composeServicesForDemand(capabilityFromInput(b['demand']),b['services']['map'](capabilityFromInput))};break;}case'demand_match':{const k=await matchDemandToServices(capabilityFromInput(b['demand_cap']),b['services'],await resolveInjection(b['account'],b['injection']),0x5,b['presenter_history']);c={'action':'demand_match','matches':k['map'](l=>({'service':l['service'],'result':l['result'],'next':nextOperationForDemandMatch(l['service']),'order':nextOperationForServiceOrder(l['service'])}))};break;}case'service_match':{const l=await matchServiceToDemands(capabilityFromInput(b['service_cap']),b['demands'],await resolveInjection(b['account'],b['injection']),0x5,b['presenter_history']);c={'action':'service_match','matches':l['map'](n=>({'demand':n['demand'],'result':n['result'],'next':nextOperationForServiceMatch(n['demand'],null)}))};break;}case'path_reasoning':{const m=b['account']?await getEffectivePersona(b['account']):null,n=b['appetite']??m?.['layer']['preferences']?.['risk_appetite'],o=b['requirements']??m?.['layer']['requirements'];c={'action':'path_reasoning',...evaluatePathReasoning({'current_node':b['current_node'],'perspective':b['perspective'],'workflow':workflowSubgraphFromRows(b['machine_nodes']),'node_annotations':b['node_annotations'],'appetite':n,'requirements':o,'order_amount':b['order_amount'],'max_depth':b['max_depth']})};break;}case'evidence_review':{b['items']&&b['items']['length']>0x0?c={'action':'evidence_review','list':reviewEvidenceList(b['items'])}:c={'action':'evidence_review','review':assessEvidenceReview({'kind':b['kind'],'hash_committed':b['hash_committed'],'digital_check_passed':b['digital_check_passed'],'contradiction':b['contradiction']})};break;}case'discover_services':{const p=!b['sensitivity']?inferSensitivity(b['description']??''):null,q=b['sensitivity']??p['sensitivity'],r=p?.['signals']??[],s=await resolveNetwork(b['context_network']),t={'raw':b['location'],...b['region']??{}},u=expandSearchScope(q,t),v=await enumerateServices(s,{'max_objects':b['max_objects'],'no_cache':b['no_cache'],'location_any':u['search_terms']}),w=rankByLocation(q,t,v['services']['map'](x=>({'id':x['object'],'name':x['name'],'location':x['location']})));c={'action':'discover_services','sensitivity':q,'inference_signals':r,'services':w['map'](x=>{const y=v['services']['find'](z=>z['object']===x['id']);return{'object':x['id'],'name':y?.['name'],'location':y?.['location'],'relation':x['relation'],'satisfied':x['satisfied'],'score':x['score'],'reason':x['reason']};}),'total_enumerated':v['total_enumerated'],'has_more':v['has_more'],'scope_advice':{'search_terms':u['search_terms'],'ai_enrichment_note':u['ai_enrichment_note']}};break;}case'discover_demands':{const x=await resolveNetwork(b['context_network']),y=await enumerateDemands(x,{'max_objects':b['max_objects'],'no_cache':b['no_cache']}),z=b['location']?.['toLowerCase'](),A=y['demands']['filter'](B=>!z||(B['location']??'')['toLowerCase']()['includes'](z))['map'](B=>({'object':B['object'],'description':B['description']??'','location':B['location']??'','presenters_count':B['presenters_count']??0x0,'permission':B['permission']??''}));c={'action':'discover_demands','demands':A,'total_enumerated':y['total_enumerated'],'has_more':y['has_more']};break;}case'demand_present':{const B=await resolveNetwork(b['context_network']),C=await enumerateDemands(B,{'max_objects':b['max_objects'],'no_cache':b['no_cache']}),D=b['location']?.['toLowerCase'](),E=C['demands']['filter'](I=>!D||(I['location']??'')['toLowerCase']()['includes'](D)),F=new Map(E['map'](I=>[I['object'],(I['guards']?.['length']??0x0)>0x0])),G=E['map'](I=>({'object':I['object'],'description':I['description']??'','location':I['location']??'','rewards':I['rewards']??[],'um':I['um']??null})),H=await matchServiceToDemands(capabilityFromInput(b['service_cap']),G,await resolveInjection(b['account'],b['injection']),b['limit']??0x5);c={'action':'demand_present','matches':H['map'](I=>{const J=F['get'](I['demand']['object'])??![];return{'demand':I['demand'],'result':I['result'],'next':nextOperationForServiceMatch(I['demand'],J)};}),'total_enumerated':C['total_enumerated'],'has_more':C['has_more']};break;}case'market_metrics':{const I=await resolveNetwork(b['context_network']),J=await computeMarketMetrics(I,b['no_cache']),K=await computeOrderFlow(I,{'noCache':b['no_cache'],'maxPages':b['limit']?Math['max'](0x1,Math['ceil'](b['limit']/0x32)):undefined});c={'action':'market_metrics',...J,'order_flow':K};break;}case'anti_cheat':{const L=assessAntiCheat({'service':{'object':b['service']['object'],'arbitrations':b['service']['arbitrations'],'compensation_fund':b['service']['compensation_fund'],'machine':b['service']['machine'],'bPublished':b['service']['bPublished']},'orders':b['orders'],'reviews':b['reviews']});c={'action':'anti_cheat','signals':L};break;}case'market_operations':{if(b['op']==='journey_funnel')c={'action':'market_operations','result':computeJourneyFunnel({'due_diligence':b['due_diligence']??0x0,'orders':b['orders']??0x0,'completed':b['completed']??0x0,'reviews':b['reviews']??0x0})};else{if(b['op']==='referral_attribution')c={'action':'market_operations','result':attributeReferrals(b['referral_orders']??[])};else{if(b['op']==='dynamic_pricing'){const M=b['market_signals'];if(!M)throw new Error('dynamic_pricing\x20op\x20requires\x20market_signals');c={'action':'market_operations','result':suggestPricing({'supplyCount':M['supplyCount'],'demandCount':M['demandCount'],'avgPrice':M['avgPrice'],'myPrice':M['myPrice'],'competitorPrices':M['competitorPrices'],'recentOrderCount':M['recentOrderCount'],'repeatCustomerRate':M['repeatCustomerRate']})};}else c={'action':'market_operations','result':buildCustomerRelationships(b['customer_orders']??[])};}}break;}case'match_discover':{const N=!b['sensitivity']?inferSensitivity(b['description']??''):null,O=b['sensitivity']??N['sensitivity'],P=N?.['signals']??[],Q=await resolveNetwork(b['context_network']),R={'raw':b['location'],...b['region']??{}},S=expandSearchScope(O,R),T=await enumerateServices(Q,{'max_objects':b['max_objects'],'no_cache':b['no_cache'],'location_any':S['search_terms']}),U=new Set(b['required_capabilities']??[]),V=extractDemandCapability({'object':'intent','description':b['description'],'location':b['location'],'owner':b['account']},{'price_max':b['budget']!==undefined?BigInt(b['budget']):undefined,'capabilities':{'has_arbitration':U['has']('has_arbitration'),'has_refund_path':U['has']('has_refund_path'),'has_milestone_nodes':U['has']('has_milestone_nodes'),'has_compensation_fund':U['has']('has_compensation_fund'),'has_wip_verification':U['has']('has_wip_verification'),'has_messenger':U['has']('has_messenger'),'has_buy_guard':U['has']('has_buy_guard'),'has_dynamic_pricing':U['has']('has_dynamic_pricing'),'is_published':!![],'is_paused':![]}}),W=rankByLocation(O,R,T['services']['map'](a7=>({'id':a7['object'],'name':a7['name'],'location':a7['location']}))),X=W['filter'](a7=>a7['satisfied']),Y=T['services']['filter'](a7=>X['some'](a8=>a8['id']===a7['object']))['map'](serviceSummaryToExtract),Z=resolveCategoryMatchRules(b['category']);let a0=Y;const a1=[];if(Z){const a7=applyHardConstraints(Z,Y);a0=a7['passed'];for(const a8 of a7['dropped']){a1['push']({'object':a8['candidate']['object'],'reason':a8['constraint']['description']});}}let a2=await resolveInjection(b['account'],b['injection']);Z&&(a2=mergeInjections(a2,toSoftWeightInjection(Z)));const a3=await matchDemandToServices(V,a0,a2,a0['length'],b['presenter_history']),a4=new Map(a3['map'](a9=>[a9['service']['object'],a9['result']])),a5=new Set(a0['map'](a9=>a9['object'])),a6=X['filter'](a9=>a5['has'](a9['id']))['map'](a9=>{const aa=T['services']['find'](ab=>ab['object']===a9['id']);return{'service':serviceSummaryToExtract(aa),'location':{'relation':a9['relation'],'satisfied':a9['satisfied'],'score':a9['score'],'reason':a9['reason']},'result':a4['get'](a9['id'])};});c={'action':'match_discover','sensitivity':O,'inference_signals':P,'matches':a6,'total_enumerated':T['total_enumerated'],'has_more':T['has_more'],'scope_advice':{'search_terms':S['search_terms'],'ai_enrichment_note':S['ai_enrichment_note']}};break;}case'arbitration_score':{let a9=b['history'];const aa=b['context_network']??'testnet';if((!a9||a9['length']===0x0)&&b['arbitration']['object'])try{const ac=await enumerateArbs(aa,{'arbitration':b['arbitration']['object']});a9=await arbCasesWithRoles(ac['arbs'],aa);}catch{a9=b['history'];}if((!a9||a9['length']===0x0)&&b['arbitration']['object'])try{const ad=await query_objects({'objects':[b['arbitration']['object']],'network':aa}),ae=ad?.['objects']?.[0x0];if(ae?.['permission']){const af=await fetchObjectLinkerCore(ae['permission'],aa),ag=(af?.['items']??[])['map'](ai=>ai['who'])['filter'](ai=>ai!==b['arbitration']['object']),ah=[];for(const ai of ag['slice'](0x0,0xa)){const aj=await enumerateArbs(aa,{'arbitration':ai})['catch'](()=>undefined);aj?.['arbs']?.['length']&&ah['push'](...await arbCasesWithRoles(aj['arbs'],aa));}if(ah['length']>0x0)a9=ah;}}catch{}const ab=await assessArbitration({'arbitration':{'object':b['arbitration']['object'],'fee':b['arbitration']['fee'],'balance':b['arbitration']['balance'],'voting_guard_count':b['arbitration']['voting_guard_count'],'bPaused':b['arbitration']['bPaused'],'location':b['arbitration']['location'],'has_verified_identity':b['arbitration']['has_verified_identity']},'history':a9,'entity_votes':b['entity_votes'],'fee_median':b['fee_median']},await resolveInjection(b['account'],b['injection']));c={'action':'arbitration_score',...ab};break;}case'account_events':{const ak=await runAccountEventWatchers({'account':b['account'],'network':await resolveNetwork(b['context_network']),'reviews':b['reviews']?.['map'](al=>({'reviewer':al['reviewer'],'rating':al['rating'],'tags':al['tags'],'comment':al['comment'],'orderRef':al['orderRef'],'timestamp':al['timestamp'],'verified':al['verified']??![]})),'order_history':b['order_history']},b['categories']);c={'action':'account_events','events':ak};break;}default:throw new Error('Unknown\x20evaluation_operation\x20action');}return{'content':[{'type':'text','text':JSON['stringify']({'result':c})}],'structuredContent':{'result':c}};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{describe,expect,it}from'vitest';import{handleEvaluationOperation}from'./evaluation.js';function resultOf(a){return a['structuredContent']['result'];}const demandCap={'id':'0xdemand1','kind':'demand','industry':'freelance','region':{'mode':'physical','city':'Shanghai','raw':'Shanghai'},'keywords':['design'],'capabilities':{'has_arbitration':![],'has_refund_path':![],'has_milestone_nodes':![],'has_compensation_fund':![],'has_wip_verification':![],'has_messenger':![],'has_buy_guard':![],'has_dynamic_pricing':![],'is_published':!![],'is_paused':![]}},service={'object':'0xsvc1','description':'freelance\x20logo\x20design','location':'Shanghai','sales':[{'price':'100','wip_hash':'abc'}],'bPublished':!![],'bPaused':![]};describe('evaluation_operation\x20demand_match\x20presenter_history\x20(P2-2)',()=>{it('acceptance\x20rule\x20scores\x20the\x20rated\x20history\x20in\x20the\x20breakdown',async()=>{const a=await handleEvaluationOperation({'action':'demand_match','demand_cap':demandCap,'services':[service],'presenter_history':[{'acceptance_score':0x50},{'acceptance_score':0x5a}]}),c=resultOf(a);expect(c['action'])['toBe']('demand_match');const d=c['matches'][0x0]['result']['breakdown']['find'](e=>e['rule_id']==='acceptance');expect(d)['toBeDefined'](),expect(d['score'])['toBe'](0x55);}),it('omitted\x20history\x20→\x20acceptance\x20stays\x20neutral',async()=>{const a=await handleEvaluationOperation({'action':'demand_match','demand_cap':demandCap,'services':[service]}),c=resultOf(a)['matches'][0x0]['result']['breakdown']['find'](d=>d['rule_id']==='acceptance');expect(c)['toBeDefined'](),expect(c['score'])['toBe'](0x32),expect(c['reason'])['toContain']('neutral');}),it('schema\x20rejects\x20a\x20malformed\x20presenter_history\x20entry',async()=>{await expect(handleEvaluationOperation({'action':'demand_match','demand_cap':demandCap,'services':[service],'presenter_history':[{'acceptance_score':0x50,'bogus':!![]}]}))['rejects']['toThrow']();});}),describe('evaluation_operation\x20demand_match\x20order\x20bridge\x20(N-2\x20/\x2008\x20
|
|
1
|
+
import{describe,expect,it}from'vitest';import{handleEvaluationOperation}from'./evaluation.js';function resultOf(a){return a['structuredContent']['result'];}const demandCap={'id':'0xdemand1','kind':'demand','industry':'freelance','region':{'mode':'physical','city':'Shanghai','raw':'Shanghai'},'keywords':['design'],'capabilities':{'has_arbitration':![],'has_refund_path':![],'has_milestone_nodes':![],'has_compensation_fund':![],'has_wip_verification':![],'has_messenger':![],'has_buy_guard':![],'has_dynamic_pricing':![],'is_published':!![],'is_paused':![]}},service={'object':'0xsvc1','description':'freelance\x20logo\x20design','location':'Shanghai','sales':[{'price':'100','wip_hash':'abc'}],'bPublished':!![],'bPaused':![]};describe('evaluation_operation\x20demand_match\x20presenter_history\x20(P2-2)',()=>{it('acceptance\x20rule\x20scores\x20the\x20rated\x20history\x20in\x20the\x20breakdown',async()=>{const a=await handleEvaluationOperation({'action':'demand_match','demand_cap':demandCap,'services':[service],'presenter_history':[{'acceptance_score':0x50},{'acceptance_score':0x5a}]}),c=resultOf(a);expect(c['action'])['toBe']('demand_match');const d=c['matches'][0x0]['result']['breakdown']['find'](e=>e['rule_id']==='acceptance');expect(d)['toBeDefined'](),expect(d['score'])['toBe'](0x55);}),it('omitted\x20history\x20→\x20acceptance\x20stays\x20neutral',async()=>{const a=await handleEvaluationOperation({'action':'demand_match','demand_cap':demandCap,'services':[service]}),c=resultOf(a)['matches'][0x0]['result']['breakdown']['find'](d=>d['rule_id']==='acceptance');expect(c)['toBeDefined'](),expect(c['score'])['toBe'](0x32),expect(c['reason'])['toContain']('neutral');}),it('schema\x20rejects\x20a\x20malformed\x20presenter_history\x20entry',async()=>{await expect(handleEvaluationOperation({'action':'demand_match','demand_cap':demandCap,'services':[service],'presenter_history':[{'acceptance_score':0x50,'bogus':!![]}]}))['rejects']['toThrow']();});}),describe('evaluation_operation\x20demand_match\x20order\x20bridge\x20(N-2\x20/\x2008\x20§7)',()=>{it('each\x20match\x20carries\x20the\x20service.order_new\x20transaction-formation\x20bridge',async()=>{const a=await handleEvaluationOperation({'action':'demand_match','demand_cap':demandCap,'services':[service]}),b=resultOf(a)['matches'][0x0];expect(b['order'])['toBeDefined'](),expect(b['order']['operation'])['toBe']('service.order_new'),expect(b['order']['operation_type'])['toBe']('service'),expect(b['order']['preconditions']['some'](c=>c['includes']('acceptance_score')))['toBe'](!![]),expect(b['order']['rationale'])['toContain']('0xsvc1'),expect(b['next']['operation'])['toBe']('demand.publish'),expect(b['next']['operation_type'])['toBe']('demand'),expect(b['next']['rationale'])['toContain']('service.order_new');});}),describe('evaluation_operation\x20evidence_review\x20list\x20mode\x20(P2-3)',()=>{it('items\x20mode\x20→\x20structured\x20usable/manual/rejected\x20+\x20proof\x20candidates',async()=>{const a=await handleEvaluationOperation({'action':'evidence_review','items':[{'id':'chat.wts','kind':'signature_photo','hash_committed':!![],'digital_check_passed':!![],'proof_ref':'0xproof1'},{'id':'waybill.jpg','kind':'delivery_proof','hash_committed':!![]},{'id':'voice.mp3','kind':'voice_recording','hash_committed':![]}]}),b=resultOf(a);expect(b['action'])['toBe']('evidence_review'),expect(b['list']['items'])['toHaveLength'](0x3),expect(b['list']['usable'])['toHaveLength'](0x1),expect(b['list']['manual'])['toHaveLength'](0x1),expect(b['list']['rejected'])['toHaveLength'](0x1),expect(b['list']['proof_candidates'])['toHaveLength'](0x1),expect(b['list']['proof_candidates'][0x0]['proof_ref'])['toBe']('0xproof1'),expect(b['list']['dispute_hint'])['toContain']('1\x20Proof\x20reference\x20candidate(s)\x20ready');}),it('single-item\x20mode\x20still\x20works\x20(backwards\x20compatible)',async()=>{const a=await handleEvaluationOperation({'action':'evidence_review','kind':'signature_photo','hash_committed':!![],'digital_check_passed':!![]});expect(resultOf(a)['review']['status'])['toBe']('auto_pass');}),it('schema\x20refinement:\x20neither\x20items\x20nor\x20kind+hash_committed\x20→\x20error',async()=>{await expect(handleEvaluationOperation({'action':'evidence_review'}))['rejects']['toThrow']();});});
|