@wowok/agent-mcp 3.0.5 → 3.0.6
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/README.md +25 -20
- package/dist/customer/account-events.js +1 -1
- package/dist/graph/onchain/dataplane.d.ts +2 -2
- package/dist/graph/onchain/edge-schema.js +1 -1
- package/dist/graph/onchain/expand.js +1 -1
- package/dist/graph/onchain/onchain.spec.js +1 -1
- package/dist/graph/onchain/sdk-batch.d.ts +7 -1
- package/dist/graph/onchain/sdk-batch.js +1 -1
- package/dist/graph/onchain/sdk-dataplane.d.ts +6 -3
- package/dist/graph/onchain/sdk-dataplane.js +1 -1
- package/dist/graph/onchain/types.d.ts +2 -2
- package/dist/knowledge/account-marks.js +1 -1
- package/dist/knowledge/allocation-risk.js +1 -1
- package/dist/knowledge/allocation-templates.js +1 -1
- package/dist/knowledge/goal-completion.d.ts +12 -0
- package/dist/knowledge/goal-completion.js +1 -1
- package/dist/knowledge/guard-risk.js +1 -1
- package/dist/knowledge/index.d.ts +4 -0
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/migration-preflight.js +1 -1
- package/dist/knowledge/payment-tracker.d.ts +63 -0
- package/dist/knowledge/payment-tracker.js +1 -0
- package/dist/knowledge/recipient-constraint.d.ts +160 -0
- package/dist/knowledge/recipient-constraint.js +1 -0
- package/dist/knowledge/safety-rules.d.ts +1 -1
- package/dist/knowledge/safety-rules.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/tools-reference.js +1 -1
- package/dist/knowledge/workflow-guidance.js +1 -1
- package/dist/knowledge/workspace-lists.d.ts +4 -0
- package/dist/knowledge/workspace-lists.js +1 -1
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/participation/arbitrator-interest.d.ts +2 -0
- package/dist/participation/arbitrator-interest.js +1 -1
- package/dist/participation/collaborator-interest.d.ts +2 -0
- package/dist/participation/collaborator-interest.js +1 -1
- package/dist/participation/customer-interest.d.ts +2 -0
- package/dist/participation/customer-interest.js +1 -1
- package/dist/participation/merchant-interest.d.ts +2 -0
- package/dist/participation/merchant-interest.js +1 -1
- package/dist/participation/supplier-interest.d.ts +2 -0
- package/dist/participation/supplier-interest.js +1 -1
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/context-assembly.js +1 -1
- package/dist/playbooks/service-build/merchant-guide.d.ts +7 -0
- package/dist/playbooks/service-build/merchant-guide.js +1 -1
- package/dist/playbooks/service-build/participation-radar.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/relationship-profile.js +1 -1
- package/dist/playbooks/service-build/risk-aggregator.js +1 -1
- package/dist/playbooks/service-build/topology-query.js +1 -1
- package/dist/relationship/derivation.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/call/allocation.js +1 -1
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.js +1 -1
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/evaluation/index.d.ts +4 -4
- package/dist/schema/evaluation/index.js +1 -1
- package/dist/schema/goal/index.d.ts +21 -21
- package/dist/schema/goal/planning.d.ts +6 -6
- package/dist/schema/industry-pack/index.d.ts +6 -6
- package/dist/schema/industry-pack/modes.d.ts +6 -6
- package/dist/schema/intent-radar/index.d.ts +16 -16
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/messenger/index.d.ts +110 -8
- package/dist/schema/messenger/index.js +1 -1
- package/dist/schema/operations.d.ts +35 -27
- package/dist/schema/operations.js +1 -1
- package/dist/schema/persona/index.d.ts +155 -155
- package/dist/schema/query/bi.d.ts +26 -26
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/query/index.d.ts +5 -2
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-query/index.d.ts +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema/strategy-review/index.d.ts +1 -1
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/bridge_operation.schema.json +10 -10
- package/dist/schemas/evaluation_operation.schema.json +7 -7
- package/dist/schemas/guard2file.schema.json +2 -2
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/machineNode2file.schema.json +2 -2
- package/dist/schemas/messenger_operation.output.json +266 -38
- package/dist/schemas/messenger_operation.schema.json +27 -3
- package/dist/schemas/onchain_events.schema.json +1 -1
- package/dist/schemas/onchain_operations.schema.json +51 -51
- package/dist/schemas/onchain_operations_allocation.schema.json +5 -5
- package/dist/schemas/onchain_operations_arbitration.schema.json +2 -2
- 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_gen_passport.schema.json +2 -2
- package/dist/schemas/onchain_operations_gen_proof.schema.json +2 -2
- package/dist/schemas/onchain_operations_guard.schema.json +2 -2
- package/dist/schemas/onchain_operations_machine.schema.json +8 -8
- package/dist/schemas/onchain_operations_order.schema.json +2 -2
- package/dist/schemas/onchain_operations_payment.schema.json +3 -3
- package/dist/schemas/onchain_operations_permission.schema.json +2 -2
- package/dist/schemas/onchain_operations_personal.schema.json +2 -2
- package/dist/schemas/onchain_operations_progress.schema.json +2 -2
- package/dist/schemas/onchain_operations_proof.schema.json +2 -2
- package/dist/schemas/onchain_operations_repository.schema.json +2 -2
- package/dist/schemas/onchain_operations_reward.schema.json +2 -2
- package/dist/schemas/onchain_operations_service.schema.json +5 -5
- package/dist/schemas/onchain_operations_treasury.schema.json +4 -4
- package/dist/schemas/onchain_table_data.output.json +14 -14
- package/dist/schemas/query_toolkit.output.json +35 -8
- package/dist/schemas/query_toolkit.schema.json +39 -11
- package/dist/strategy/collectors.js +1 -1
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/evaluation.js +1 -1
- package/dist/tools/handlers/messenger.js +1 -1
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/permission.js +1 -1
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/handlers/strategy-review.js +1 -1
- package/dist/tools/handlers/workflow.js +1 -1
- package/dist/tools/registry/onchain.js +1 -1
- package/dist/tools/registry/query.js +1 -1
- package/dist/tools/rules-hook.d.ts +2 -0
- package/dist/tools/rules-hook.js +1 -1
- package/dist/tools/shared.js +1 -1
- package/package.json +2 -2
|
@@ -2618,7 +2618,7 @@
|
|
|
2618
2618
|
"additionalProperties": false,
|
|
2619
2619
|
"description": "Fund allocation item — one recipient's share of the Allocation balance. The `sharing` value's meaning depends on `mode` (see AllocationModeSchema). Multiple items in the same Allocator are evaluated together: Amount items first, Rate items second, Surplus last."
|
|
2620
2620
|
},
|
|
2621
|
-
"description": "Fund allocation item list. Each item specifies a recipient (who), a value (sharing), and a mode. Items can mix modes (Amount + Rate + Surplus) within the same Allocator. ALLOCATION ORDER: Amount items first (cached as fix) → Rate items (proportional to balance - fix) → Surplus item (remaining). CONSTRAINTS: max ONE Surplus item per Allocator; Rate sum must == 10000 (no Surplus) or <= 10000 (with Surplus); Amount sum must >= threshold (no Rate and no Surplus) and <= max (if max set)."
|
|
2621
|
+
"description": "Fund allocation item list. Each item specifies a recipient (who), a value (sharing), and a mode. Items can mix modes (Amount + Rate + Surplus) within the same Allocator. RECIPIENT SEMANTICS: the Guard constrains what each submission slot may be; a recipient's safety follows from the sufficiency of those constraints (run the recipient constraint audit). Canonical order pattern: recipient = the single submitted Order — funds land at that object and are receivable only by its owner. ALLOCATION ORDER: Amount items first (cached as fix) → Rate items (proportional to balance - fix) → Surplus item (remaining). CONSTRAINTS: max ONE Surplus item per Allocator; Rate sum must == 10000 (no Surplus) or <= 10000 (with Surplus); Amount sum must >= threshold (no Rate and no Surplus) and <= max (if max set)."
|
|
2622
2622
|
},
|
|
2623
2623
|
"fix": {
|
|
2624
2624
|
"description": "OUTPUT-ONLY (query result). Cached sum of all Amount-mode `sharing` values in this Allocator. Computed by the contract during `allocator_add` — DO NOT set this field at creation. Used internally to compute `total_rates = balance - fix` for Rate allocation.",
|
|
@@ -3841,7 +3841,7 @@
|
|
|
3841
3841
|
"additionalProperties": false,
|
|
3842
3842
|
"description": "Guard submission"
|
|
3843
3843
|
},
|
|
3844
|
-
"description": "
|
|
3844
|
+
"description": "Values persisted into the Progress history when this forward was accomplished. PROVENANCE: when the Machine forward lists retained_submission identifiers, the Guard is STILL fully verified first — the forward cannot complete without a passing Guard result. After verification, exactly the caller's submissions for the listed identifiers are copied here as Guard-verified facts (see MachineForwardGuardSchema)."
|
|
3845
3845
|
},
|
|
3846
3846
|
"msg": {
|
|
3847
3847
|
"type": "string",
|
|
@@ -4890,7 +4890,7 @@
|
|
|
4890
4890
|
"additionalProperties": false,
|
|
4891
4891
|
"description": "Fund allocation item — one recipient's share of the Allocation balance. The `sharing` value's meaning depends on `mode` (see AllocationModeSchema). Multiple items in the same Allocator are evaluated together: Amount items first, Rate items second, Surplus last."
|
|
4892
4892
|
},
|
|
4893
|
-
"description": "Fund allocation item list. Each item specifies a recipient (who), a value (sharing), and a mode. Items can mix modes (Amount + Rate + Surplus) within the same Allocator. ALLOCATION ORDER: Amount items first (cached as fix) → Rate items (proportional to balance - fix) → Surplus item (remaining). CONSTRAINTS: max ONE Surplus item per Allocator; Rate sum must == 10000 (no Surplus) or <= 10000 (with Surplus); Amount sum must >= threshold (no Rate and no Surplus) and <= max (if max set)."
|
|
4893
|
+
"description": "Fund allocation item list. Each item specifies a recipient (who), a value (sharing), and a mode. Items can mix modes (Amount + Rate + Surplus) within the same Allocator. RECIPIENT SEMANTICS: the Guard constrains what each submission slot may be; a recipient's safety follows from the sufficiency of those constraints (run the recipient constraint audit). Canonical order pattern: recipient = the single submitted Order — funds land at that object and are receivable only by its owner. ALLOCATION ORDER: Amount items first (cached as fix) → Rate items (proportional to balance - fix) → Surplus item (remaining). CONSTRAINTS: max ONE Surplus item per Allocator; Rate sum must == 10000 (no Surplus) or <= 10000 (with Surplus); Amount sum must >= threshold (no Rate and no Surplus) and <= max (if max set)."
|
|
4894
4894
|
},
|
|
4895
4895
|
"fix": {
|
|
4896
4896
|
"description": "OUTPUT-ONLY (query result). Cached sum of all Amount-mode `sharing` values in this Allocator. Computed by the contract during `allocator_add` — DO NOT set this field at creation. Used internally to compute `total_rates = balance - fix` for Rate allocation.",
|
|
@@ -4948,7 +4948,7 @@
|
|
|
4948
4948
|
"type": "object",
|
|
4949
4949
|
"properties": {
|
|
4950
4950
|
"for_object": {
|
|
4951
|
-
"description": "
|
|
4951
|
+
"description": "Object this distribution belongs to (e.g. the order for a per-order allocation, recorded at creation). Auditors can query it to see the distribution's business context.",
|
|
4952
4952
|
"anyOf": [
|
|
4953
4953
|
{
|
|
4954
4954
|
"type": "string"
|
|
@@ -7169,7 +7169,7 @@
|
|
|
7169
7169
|
"type": "object",
|
|
7170
7170
|
"properties": {
|
|
7171
7171
|
"for_object": {
|
|
7172
|
-
"description": "
|
|
7172
|
+
"description": "Object this distribution belongs to (e.g. the order for a per-order allocation, recorded at creation). Auditors can query it to see the distribution's business context.",
|
|
7173
7173
|
"anyOf": [
|
|
7174
7174
|
{
|
|
7175
7175
|
"type": "string"
|
|
@@ -14221,7 +14221,7 @@
|
|
|
14221
14221
|
"description": "Forward weight — the contribution this forward makes toward its Pair's threshold. ⚠️ SINGLE-OPERATOR LOCK: a forward contributes its weight AT MOST ONCE. It is locked by the first operator that accomplishes it (progress.move session_accomplish_imp); a second operator re-executing the same accomplished forward aborts E_NOT_THE_HOLDER. Therefore multi-operator cooperation (threshold > 1) needs one DISTINCT forward per contributing operator (e.g. threshold 2 → begin_a + begin_b, each weight 1) — never reuse one forward."
|
|
14222
14222
|
},
|
|
14223
14223
|
"guard": {
|
|
14224
|
-
"description": "Guard reference for this forward. Accepts TWO formats:\n• STRING (preferred): \"my_guard_name\" — the Guard's name or address as a plain string.\n• OBJECT (only when retained_submission is needed): {guard: \"my_guard_name\", retained_submission: [1,2,3]}.\nFOLLOW THE SCHEMA FIELD STRUCTURE: A Guard reference is fundamentally a STRING (the Guard object's name or address). Provide a string when you only need to reference a Guard — do NOT wrap a bare string in an object structure. The OBJECT form {guard: \"...\", retained_submission: [...]} exists ONLY to carry additional `retained_submission` data alongside the string reference; inside the object, the `guard` field is STILL a string. In short: string-in for a string reference, object-in only when you need to pass extra data.\nCOGNITIVE PRINCIPLE: Guard validation ALWAYS occurs BEFORE the forward operation. A Guard that queries state of the SAME Progress object this forward operates on (e.g. progress.current) will see the PRE-transition value (source node), NOT the target node. If the Guard checks progress.current == target_node, it will ALWAYS FAIL. Querying a DIFFERENT Progress object (cross-machine) is safe and reasonable — that progress is not modified by this forward. For target-node verification after transition, bind the Guard to the Allocator instead (allocation.alloc runs AFTER the state transition completes).\n⚠️ T1 LOSSY POINT (B-3): WoWok has NO on-chain cron. A business phrase like 'after N days, auto-X' is NOT an automatic trigger — it decomposes into (1) a time_guard that checks elapsed time, and (2) an OFF-CHAIN keeper that must submit the forward when the guard passes. Configuring a time_guard WITHOUT a keeper means nothing ever fires.",
|
|
14224
|
+
"description": "Guard reference for this forward. Accepts TWO formats:\n• STRING (preferred): \"my_guard_name\" — the Guard's name or address as a plain string.\n• OBJECT (only when retained_submission is needed): {guard: \"my_guard_name\", retained_submission: [1,2,3]}.\nFOLLOW THE SCHEMA FIELD STRUCTURE: A Guard reference is fundamentally a STRING (the Guard object's name or address). Provide a string when you only need to reference a Guard — do NOT wrap a bare string in an object structure. The OBJECT form {guard: \"...\", retained_submission: [...]} exists ONLY to carry additional `retained_submission` data alongside the string reference; inside the object, the `guard` field is STILL a string. In short: string-in for a string reference, object-in only when you need to pass extra data.\nCOGNITIVE PRINCIPLE: Guard validation ALWAYS occurs BEFORE the forward operation. A Guard that queries state of the SAME Progress object this forward operates on (e.g. progress.current) will see the PRE-transition value (source node), NOT the target node. If the Guard checks progress.current == target_node, it will ALWAYS FAIL. Querying a DIFFERENT Progress object (cross-machine) is safe and reasonable — that progress is not modified by this forward. For target-node verification after transition, bind the Guard to the Allocator instead (allocation.alloc runs AFTER the state transition completes).\n⚠️ T1 LOSSY POINT (B-3): WoWok has NO on-chain cron. A business phrase like 'after N days, auto-X' is NOT an automatic trigger — it decomposes into (1) a time_guard that checks elapsed time, and (2) an OFF-CHAIN keeper that must submit the forward when the guard passes. Configuring a time_guard WITHOUT a keeper means nothing ever fires.\nRETAINED_SUBMISSION: a non-empty retained_submission does NOT relax Guard verification — the forward's Guard is always validated first. The list only selects which of the caller's already-verified submissions are persisted into the Progress history (see the guard field above).",
|
|
14225
14225
|
"anyOf": [
|
|
14226
14226
|
{
|
|
14227
14227
|
"anyOf": [
|
|
@@ -14233,7 +14233,7 @@
|
|
|
14233
14233
|
"description": "Guard object name or address (string). Example: 'my_attendance_guard' or '0x1234...'"
|
|
14234
14234
|
},
|
|
14235
14235
|
"retained_submission": {
|
|
14236
|
-
"description": "
|
|
14236
|
+
"description": "Guard table identifiers whose verified values are persisted into the Progress history when the forward is accomplished. The Guard is ALWAYS fully verified first (regardless of this list): the forward cannot complete unless the Passport carries a passing result for it. After verification, exactly the caller's submissions for the listed identifiers are copied into history (passport::submissions_get) as Guard-verified facts; empty array (default) records nothing. Use it for audit and downstream queries, never as a way to relax Guard conditions.",
|
|
14237
14237
|
"anyOf": [
|
|
14238
14238
|
{
|
|
14239
14239
|
"type": "array",
|
|
@@ -15021,7 +15021,7 @@
|
|
|
15021
15021
|
"additionalProperties": false,
|
|
15022
15022
|
"description": "Guard submission"
|
|
15023
15023
|
},
|
|
15024
|
-
"description": "
|
|
15024
|
+
"description": "Values persisted into the Progress history when this forward was accomplished. PROVENANCE: when the Machine forward lists retained_submission identifiers, the Guard is STILL fully verified first — the forward cannot complete without a passing Guard result. After verification, exactly the caller's submissions for the listed identifiers are copied here as Guard-verified facts (see MachineForwardGuardSchema)."
|
|
15025
15025
|
},
|
|
15026
15026
|
"msg": {
|
|
15027
15027
|
"type": "string",
|
|
@@ -15722,6 +15722,33 @@
|
|
|
15722
15722
|
],
|
|
15723
15723
|
"additionalProperties": false
|
|
15724
15724
|
},
|
|
15725
|
+
{
|
|
15726
|
+
"type": "object",
|
|
15727
|
+
"properties": {
|
|
15728
|
+
"query_type": {
|
|
15729
|
+
"type": "string",
|
|
15730
|
+
"const": "onchain_block"
|
|
15731
|
+
},
|
|
15732
|
+
"result": {
|
|
15733
|
+
"anyOf": [
|
|
15734
|
+
{
|
|
15735
|
+
"type": "object",
|
|
15736
|
+
"propertyNames": {
|
|
15737
|
+
"type": "string"
|
|
15738
|
+
},
|
|
15739
|
+
"additionalProperties": {},
|
|
15740
|
+
"description": "RAW fullnode checkpoint summary, verbatim (no semantic shaping)"
|
|
15741
|
+
},
|
|
15742
|
+
{}
|
|
15743
|
+
]
|
|
15744
|
+
}
|
|
15745
|
+
},
|
|
15746
|
+
"required": [
|
|
15747
|
+
"query_type",
|
|
15748
|
+
"result"
|
|
15749
|
+
],
|
|
15750
|
+
"additionalProperties": false
|
|
15751
|
+
},
|
|
15725
15752
|
{
|
|
15726
15753
|
"type": "object",
|
|
15727
15754
|
"properties": {
|
|
@@ -513,6 +513,34 @@
|
|
|
513
513
|
"additionalProperties": false,
|
|
514
514
|
"description": "Verify what a specific transaction did on-chain — the 'OperationProof' primitive. After executing any operation, call this with the returned digest to confirm: status (success/failed), object changes (created/mutated/deleted), balance changes, gas used, and events. Essential for the 5-step loop's Verify step. Returns: TransactionDetail | undefined"
|
|
515
515
|
},
|
|
516
|
+
{
|
|
517
|
+
"type": "object",
|
|
518
|
+
"properties": {
|
|
519
|
+
"query_type": {
|
|
520
|
+
"type": "string",
|
|
521
|
+
"const": "onchain_block"
|
|
522
|
+
},
|
|
523
|
+
"block": {
|
|
524
|
+
"type": "string",
|
|
525
|
+
"description": "Checkpoint sequence number (e.g. \"12345\") or checkpoint digest. A checkpoint (block) is the chain's unit of finalization — use it to answer 'what happened at block N', look up block time/transaction count, or place a transaction in the global order (checkpoint sequences appear in onchain_transaction/onchain_object_history results)."
|
|
526
|
+
},
|
|
527
|
+
"network": {
|
|
528
|
+
"description": "Network to query: 'mainnet' or 'testnet'. If omitted, the SDK's current default network is used (check via wowok_buildin_info info='current network'); the response echoes the resolved network so results can never be misattributed.",
|
|
529
|
+
"type": "string",
|
|
530
|
+
"enum": [
|
|
531
|
+
"localnet",
|
|
532
|
+
"testnet",
|
|
533
|
+
"mainnet"
|
|
534
|
+
]
|
|
535
|
+
}
|
|
536
|
+
},
|
|
537
|
+
"required": [
|
|
538
|
+
"query_type",
|
|
539
|
+
"block"
|
|
540
|
+
],
|
|
541
|
+
"additionalProperties": false,
|
|
542
|
+
"description": "Query ONE checkpoint (block) by sequence number or digest — returns the RAW fullnode checkpoint summary VERBATIM (no semantic shaping): sequence, digest, timestampMs, transaction count, epoch bindings, networkTransactions, endOfEpoch data when present. Checkpoints are immutable, so the value is authoritative forever. Distinct from onchain_transaction (per-tx proof) — use this for block-level facts. Returns: raw checkpoint summary object | undefined"
|
|
543
|
+
},
|
|
516
544
|
{
|
|
517
545
|
"type": "object",
|
|
518
546
|
"properties": {
|
|
@@ -937,7 +965,7 @@
|
|
|
937
965
|
"mainnet",
|
|
938
966
|
"localnet"
|
|
939
967
|
],
|
|
940
|
-
"description": "Network for the query. Defaults to '
|
|
968
|
+
"description": "Network for the query. Defaults to the user's CURRENT network (client UI selection / authority config) when omitted. 'localnet' is for internal test use against a local fullnode."
|
|
941
969
|
}
|
|
942
970
|
},
|
|
943
971
|
"required": [
|
|
@@ -964,7 +992,7 @@
|
|
|
964
992
|
"mainnet",
|
|
965
993
|
"localnet"
|
|
966
994
|
],
|
|
967
|
-
"description": "Network for the query. Defaults to '
|
|
995
|
+
"description": "Network for the query. Defaults to the user's CURRENT network (client UI selection / authority config) when omitted. 'localnet' is for internal test use against a local fullnode."
|
|
968
996
|
}
|
|
969
997
|
},
|
|
970
998
|
"required": [
|
|
@@ -991,7 +1019,7 @@
|
|
|
991
1019
|
"mainnet",
|
|
992
1020
|
"localnet"
|
|
993
1021
|
],
|
|
994
|
-
"description": "Network for the query. Defaults to '
|
|
1022
|
+
"description": "Network for the query. Defaults to the user's CURRENT network (client UI selection / authority config) when omitted. 'localnet' is for internal test use against a local fullnode."
|
|
995
1023
|
}
|
|
996
1024
|
},
|
|
997
1025
|
"required": [
|
|
@@ -1018,7 +1046,7 @@
|
|
|
1018
1046
|
"mainnet",
|
|
1019
1047
|
"localnet"
|
|
1020
1048
|
],
|
|
1021
|
-
"description": "Network for the query. Defaults to '
|
|
1049
|
+
"description": "Network for the query. Defaults to the user's CURRENT network (client UI selection / authority config) when omitted. 'localnet' is for internal test use against a local fullnode."
|
|
1022
1050
|
}
|
|
1023
1051
|
},
|
|
1024
1052
|
"required": [
|
|
@@ -1052,7 +1080,7 @@
|
|
|
1052
1080
|
"mainnet",
|
|
1053
1081
|
"localnet"
|
|
1054
1082
|
],
|
|
1055
|
-
"description": "Network for the query. Defaults to '
|
|
1083
|
+
"description": "Network for the query. Defaults to the user's CURRENT network (client UI selection / authority config) when omitted. 'localnet' is for internal test use against a local fullnode."
|
|
1056
1084
|
},
|
|
1057
1085
|
"context_depth": {
|
|
1058
1086
|
"description": "BFS recursion depth for dependency expansion in assemble_context (default 0 = no expansion). When >0, the assembly recursively queries objects referenced by the center objects (permission, guard, machine, service, repositories, etc.) up to the given depth, using the same address-field extraction rules as extractAddressFields. Each level issues one batched query_objects call (≤50 IDs per batch). Cycles are detected and skipped via a visited set. Discovered dependencies are returned in `dependencies` (edge metadata) and `dependency_objects` (full object states). Recommended: 1–2 for most use cases; 3+ may pull large subgraphs (use context_include to constrain).",
|
|
@@ -1095,7 +1123,7 @@
|
|
|
1095
1123
|
"mainnet",
|
|
1096
1124
|
"localnet"
|
|
1097
1125
|
],
|
|
1098
|
-
"description": "Network for the query. Defaults to '
|
|
1126
|
+
"description": "Network for the query. Defaults to the user's CURRENT network (client UI selection / authority config) when omitted. 'localnet' is for internal test use against a local fullnode."
|
|
1099
1127
|
},
|
|
1100
1128
|
"reverse_order_amount": {
|
|
1101
1129
|
"description": "Escrowed order amount (smallest-unit string) for reverse_map — included in the report summary as the concrete escrow mention.",
|
|
@@ -1192,7 +1220,7 @@
|
|
|
1192
1220
|
"mainnet",
|
|
1193
1221
|
"localnet"
|
|
1194
1222
|
],
|
|
1195
|
-
"description": "Network for the query. Defaults to '
|
|
1223
|
+
"description": "Network for the query. Defaults to the user's CURRENT network (client UI selection / authority config) when omitted. 'localnet' is for internal test use against a local fullnode."
|
|
1196
1224
|
}
|
|
1197
1225
|
},
|
|
1198
1226
|
"required": [
|
|
@@ -1237,7 +1265,7 @@
|
|
|
1237
1265
|
"mainnet",
|
|
1238
1266
|
"localnet"
|
|
1239
1267
|
],
|
|
1240
|
-
"description": "Network for the query. Defaults to '
|
|
1268
|
+
"description": "Network for the query. Defaults to the user's CURRENT network (client UI selection / authority config) when omitted. 'localnet' is for internal test use against a local fullnode."
|
|
1241
1269
|
}
|
|
1242
1270
|
},
|
|
1243
1271
|
"required": [
|
|
@@ -1282,7 +1310,7 @@
|
|
|
1282
1310
|
"mainnet",
|
|
1283
1311
|
"localnet"
|
|
1284
1312
|
],
|
|
1285
|
-
"description": "Network for the query. Defaults to '
|
|
1313
|
+
"description": "Network for the query. Defaults to the user's CURRENT network (client UI selection / authority config) when omitted. 'localnet' is for internal test use against a local fullnode."
|
|
1286
1314
|
},
|
|
1287
1315
|
"account": {
|
|
1288
1316
|
"description": "Scope the aggregation to ONE account address (the client's current account). Omit to aggregate across ALL local accounts.",
|
|
@@ -1317,7 +1345,7 @@
|
|
|
1317
1345
|
"mainnet",
|
|
1318
1346
|
"localnet"
|
|
1319
1347
|
],
|
|
1320
|
-
"description": "Network for the query. Defaults to '
|
|
1348
|
+
"description": "Network for the query. Defaults to the user's CURRENT network (client UI selection / authority config) when omitted. 'localnet' is for internal test use against a local fullnode."
|
|
1321
1349
|
},
|
|
1322
1350
|
"account": {
|
|
1323
1351
|
"description": "Scope to ONE account address (the client's current account). Omit to merge across ALL local accounts.",
|
|
@@ -1393,7 +1421,7 @@
|
|
|
1393
1421
|
"mainnet",
|
|
1394
1422
|
"localnet"
|
|
1395
1423
|
],
|
|
1396
|
-
"description": "Network for the query. Defaults to '
|
|
1424
|
+
"description": "Network for the query. Defaults to the user's CURRENT network (client UI selection / authority config) when omitted. 'localnet' is for internal test use against a local fullnode."
|
|
1397
1425
|
},
|
|
1398
1426
|
"intent": {
|
|
1399
1427
|
"description": "SEMANTIC exploration strategy (G3) — what this topology call is trying to establish. Deterministically shapes the edge whitelist, per-family depth caps and budget: full_map=complete structural map; order_health=order lifecycle+completion+disputes; fund_flow=payments+allocation waterfall+guard-gated splits; workflow=Machine node graphs+transitions+progress; counterparty=who is on the other side (buyer/seller/agents/operators); reputation=votes+arbitration record+contacts; permission=permission groups+bindings+entity tables; supply_chain=multi-leg allocation/sub-order settlement; arbitration=dispute cases+voters; demand_match=demand presenters+guards+rewards. When omitted, defaults come from the persona system (role default intents < account persona preference), then industry templates; every applied layer is reported in result.strategy.trace.",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
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','培训','课'],'rental':['rental','rent','lease','租'],'freelance':['freelance','agency','studio','consulting','design'],'subscription':['subscription','membership','member','订阅'],'travel':['travel','tour','trip','游'],'retail':['shop','store','retail','boutique','商城','店']};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']??'
|
|
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','培训','课'],'rental':['rental','rent','lease','租'],'freelance':['freelance','agency','studio','consulting','design'],'subscription':['subscription','membership','member','订阅'],'travel':['travel','tour','trip','游'],'retail':['shop','store','retail','boutique','商城','店']};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};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{listServices,getServiceInfo,toggle as
|
|
1
|
+
import{listServices,getServiceInfo,toggle as a358a,setEnabled as a358b,reset as a358c}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=a358a(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.');a358b(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.');a358b(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.');a358c(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}};}
|
|
@@ -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{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=b['context_network']??'testnet',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=b['context_network']??'testnet',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=b['context_network']??'testnet',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=b['context_network']??'testnet',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=b['context_network']??'testnet',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':b['context_network']??'testnet','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{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 +1 @@
|
|
|
1
|
-
import{strictParse,MessengerOperationInputSchema}from'../../schema/index.js';import{watch_conversations,send_message,send_file,watch_messages,export_attachment,pull_messages,generate_wts,verify_wts,sign_wts,wts2html,proof_message,mark_messages_as_viewed,mark_conversation_as_viewed,blacklist,friendslist,guardlist,settings,LocalInfo}from'@wowok/wowok';import{classifyError,buildDataSemantic}from'../../schema/call/semantic.js';import{classifyCommunicationEvidence}from'../../communication/evidence.js';import{goalEngine}from'../../goal/GoalEngine.js';export function normalizeAccountOrMark(a){if(typeof a==='string')return{'name_or_address':a,'local_mark_first':!![]};return a;}export function normalizeManyAccountOrMark(a){if(Array['isArray'](a))return{'entities':a['map'](b=>typeof b==='string'?{'name_or_address':b,'local_mark_first':!![]}:b),'check_all_founded':!![]};return a;}function communicationEvidencePayload(a,b){const c=b??{};switch(a){case'send_message':case'send_file':{const d=typeof c['messageId']==='string'?c['messageId']:undefined;return{'detail':d?'message\x20'+d:'message\x20sent','data':d?{'message_id':d}:{}};}case'send_required_info':{const e=typeof c['messageId']==='string'?c['messageId']:undefined,f=Array['isArray'](c['sent_fields'])?c['sent_fields']:undefined;return{'detail':'required-info\x20confirmation\x20sent','data':{...e?{'message_id':e}:{},...f?{'sent_fields':f}:{}}};}case'generate_wts':{const g=typeof c['totalMessageCount']==='number'?c['totalMessageCount']:undefined,h=Array['isArray'](c['files'])?c['files']:undefined,i=Array['isArray'](c['htmlFiles'])?c['htmlFiles']:undefined;return{'detail':'WTS\x20evidence\x20packet\x20generated','data':{...g!==undefined?{'message_count':g}:{},...h?{'files':h}:{},...i?{'html_reports':i}:{}}};}case'verify_wts':{return{'detail':'WTS\x20evidence\x20verification','data':{'valid':c['valid']===!![]}};}case'sign_wts':{return{'detail':typeof b==='string'?b:'WTS\x20evidence\x20signed','data':{}};}case'proof_message':{const j=typeof c['proofAddress']==='string'?c['proofAddress']:undefined;return{'detail':j?'proof\x20'+j:'message\x20proofed\x20on-chain','data':j?{'proof_address':j}:{}};}default:return{'detail':a,'data':{}};}}export async function handleMessengerOperation(a){let b;try{b=strictParse(MessengerOperationInputSchema,a,'messenger_operation\x20input');const c=b['operation'];let d;switch(b['operation']){case'watch_conversations':{const g=await watch_conversations(b['filter']);d={'operation':'watch_conversations','result':g};break;}case'send_message':{const h=await send_message(b['from'],normalizeAccountOrMark(b['to']),b['content'],b['options']),i={...
|
|
1
|
+
import{strictParse,MessengerOperationInputSchema}from'../../schema/index.js';import{watch_conversations,send_message,send_file,watch_messages,export_attachment,pull_messages,generate_wts,verify_wts,sign_wts,wts2html,proof_message,mark_messages_as_viewed,mark_conversation_as_viewed,blacklist,friendslist,guardlist,settings,LocalInfo}from'@wowok/wowok';import{classifyError,buildDataSemantic}from'../../schema/call/semantic.js';import{classifyCommunicationEvidence}from'../../communication/evidence.js';import{goalEngine}from'../../goal/GoalEngine.js';export function normalizeAccountOrMark(a){if(typeof a==='string')return{'name_or_address':a,'local_mark_first':!![]};return a;}export function normalizeManyAccountOrMark(a){if(Array['isArray'](a))return{'entities':a['map'](b=>typeof b==='string'?{'name_or_address':b,'local_mark_first':!![]}:b),'check_all_founded':!![]};return a;}function communicationEvidencePayload(a,b){const c=b??{};switch(a){case'send_message':case'send_file':{const d=typeof c['messageId']==='string'?c['messageId']:undefined;return{'detail':d?'message\x20'+d:'message\x20sent','data':d?{'message_id':d}:{}};}case'send_required_info':{const e=typeof c['messageId']==='string'?c['messageId']:undefined,f=Array['isArray'](c['sent_fields'])?c['sent_fields']:undefined;return{'detail':'required-info\x20confirmation\x20sent','data':{...e?{'message_id':e}:{},...f?{'sent_fields':f}:{}}};}case'generate_wts':{const g=typeof c['totalMessageCount']==='number'?c['totalMessageCount']:undefined,h=Array['isArray'](c['files'])?c['files']:undefined,i=Array['isArray'](c['htmlFiles'])?c['htmlFiles']:undefined;return{'detail':'WTS\x20evidence\x20packet\x20generated','data':{...g!==undefined?{'message_count':g}:{},...h?{'files':h}:{},...i?{'html_reports':i}:{}}};}case'verify_wts':{return{'detail':'WTS\x20evidence\x20verification','data':{'valid':c['valid']===!![]}};}case'sign_wts':{return{'detail':typeof b==='string'?b:'WTS\x20evidence\x20signed','data':{}};}case'proof_message':{const j=typeof c['proofAddress']==='string'?c['proofAddress']:undefined;return{'detail':j?'proof\x20'+j:'message\x20proofed\x20on-chain','data':j?{'proof_address':j}:{}};}default:return{'detail':a,'data':{}};}}export async function handleMessengerOperation(a){let b;try{b=strictParse(MessengerOperationInputSchema,a,'messenger_operation\x20input');const c=b['operation'];let d;switch(b['operation']){case'watch_conversations':{const g=await watch_conversations(b['filter']);d={'operation':'watch_conversations','result':g};break;}case'send_message':{const h=await send_message(b['from'],normalizeAccountOrMark(b['to']),b['content'],b['options']);if(h['authRequired']){d={'operation':'send_message','result':h};break;}const i=h,j={...i,'merkleData':i['merkleData']?{'leafIndex':i['merkleData']['leafIndex'],'prevRoot':i['merkleData']['prevRoot'],'newRoot':i['merkleData']['newRoot'],'serverSignature':i['merkleData']['serverSignature'],'serverTimestamp':i['merkleData']['serverTimestamp'],'serverPublicKey':i['merkleData']['serverPublicKey']}:undefined};d={'operation':'send_message','result':j};break;}case'send_file':{const k=await send_file(b['from'],normalizeAccountOrMark(b['to']),b['filePath'],b['options']),l=k,m={...l,'merkleData':l['merkleData']?{'leafIndex':l['merkleData']['leafIndex'],'prevRoot':l['merkleData']['prevRoot'],'newRoot':l['merkleData']['newRoot'],'serverSignature':l['merkleData']['serverSignature'],'serverTimestamp':l['merkleData']['serverTimestamp'],'serverPublicKey':l['merkleData']['serverPublicKey']}:undefined};d={'operation':'send_file','result':m};break;}case'send_required_info':{let n=b['content'];const o=[];if(!n){const s=await LocalInfo['Instance']()['list'](),t=b['fields'],u=t&&t['length']>0x0?s['filter'](v=>t['includes'](v['name'])):s;if(u['length']===0x0)throw new Error('No\x20LocalInfo\x20fields\x20available.\x20Add\x20private\x20info\x20first\x20via\x20local_info_operation.');n=u['map'](v=>v['name']+':\x20'+v['default'])['join']('\x0a'),o['push'](...u['map'](v=>v['name']));}const p=await send_message(b['from'],normalizeAccountOrMark(b['to']),n,b['options']),q=p,r={...q,'merkleData':q['merkleData']?{'leafIndex':q['merkleData']['leafIndex'],'prevRoot':q['merkleData']['prevRoot'],'newRoot':q['merkleData']['newRoot'],'serverSignature':q['merkleData']['serverSignature'],'serverTimestamp':q['merkleData']['serverTimestamp'],'serverPublicKey':q['merkleData']['serverPublicKey']}:undefined,'sent_fields':o};d={'operation':'send_required_info','result':r};break;}case'watch_messages':{const v=b['filter']?{...b['filter'],'peerAddress':b['filter']['peerAddress']?normalizeAccountOrMark(b['filter']['peerAddress']):undefined}:undefined,w=await watch_messages(v);d={'operation':'watch_messages','result':w};break;}case'save_attachment':{const x=await export_attachment(b['account'],b['messageId'],{'outputDir':b['outputDir'],'saveAs':b['saveAs']});d={'operation':'save_attachment','result':x};break;}case'generate_wts':{const y=b['params']?{...b['params'],'peerAccount':normalizeAccountOrMark(b['params']['peerAccount'])}:undefined,z=await generate_wts(y);d={'operation':'generate_wts','result':z};break;}case'verify_wts':{const A=await verify_wts(b['wtsFilePath']);d={'operation':'verify_wts','result':A};break;}case'sign_wts':{const B=await sign_wts(b['wtsFilePath'],b['account'],b['outputPath']);d={'operation':'sign_wts','result':B};break;}case'wts2html':{const C=await wts2html(b['wtsPath'],b['options']);d={'operation':'wts2html','result':C};break;}case'proof_message':{const D=await proof_message(b['account'],b['messageId'],b['network']);d={'operation':'proof_message','result':D};break;}case'blacklist':{const E={'account':b['account'],'op':b['blacklist']['op']};'users'in b['blacklist']&&(E['users']=normalizeManyAccountOrMark(b['blacklist']['users']));const F=await blacklist(E);d={'operation':'blacklist','op':b['blacklist']['op'],'result':F['result']};break;}case'friendslist':{const G={'account':b['account'],'op':b['friendslist']['op']};'users'in b['friendslist']&&(G['users']=normalizeManyAccountOrMark(b['friendslist']['users']));const H=await friendslist(G);d={'operation':'friendslist','op':b['friendslist']['op'],'result':H['result']};break;}case'guardlist':{const I=await guardlist({'account':b['account'],...b['guardlist']});d={'operation':'guardlist','op':b['guardlist']['op'],'result':I['result']};break;}case'settings':{const J=await settings({'account':b['account'],...b['settings']});d={'operation':'settings','op':b['settings']['op'],'result':J['result']};break;}case'mark_messages_as_viewed':{const K=await mark_messages_as_viewed(b['messageIds'],b['account']);d={'operation':'mark_messages_as_viewed','result':K};break;}case'mark_conversation_as_viewed':{const L=await mark_conversation_as_viewed(normalizeAccountOrMark(b['peerAddress']),b['account']);d={'operation':'mark_conversation_as_viewed','result':L};break;}case'pull_messages':{const M=await pull_messages(b['account'],b['limit'],{'allAccounts':b['allAccounts'],'accounts':b['accounts'],'concurrency':b['concurrency']});d={'operation':'pull_messages','result':M};break;}default:throw new Error('Unknown\x20messenger\x20operation:\x20'+c);}const e=classifyCommunicationEvidence(c),f=b['goal_id'];if(e&&f){const N=d['result'],{detail:O,data:P}=communicationEvidencePayload(c,N);await goalEngine['recordCommunicationEvidence'](f,{'operation':c,'kind':e['kind'],'title':e['title'],'detail':O,'data':P},b['network']??'default');}return{'content':[{'type':'text','text':JSON['stringify'](d)}],'structuredContent':{'result':d}};}catch(Q){const R=Q instanceof Error?Q['message']:String(Q),S=b?{'operation_type':'messenger_'+b['operation'],'data':b}:undefined,T=classifyError(R),U={'operation':'error','error':R};if(T['error_code']!==undefined)U['error_code']=T['error_code'];if(T['retryable']!==undefined)U['retryable']=T['retryable'];if(T['recovery_hint']!==undefined)U['recovery_hint']=T['recovery_hint'];return{'content':[{'type':'text','text':'Error:\x20'+R}],'structuredContent':{'result':U,'semantic':buildDataSemantic(undefined,S,!![],R)}};}}
|