@wowok/agent-mcp 3.3.5 → 3.3.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/dist/chain-semantics/eval-order.d.ts +17 -0
- package/dist/chain-semantics/eval-order.js +1 -0
- package/dist/chain-semantics/freeze-map.js +1 -1
- package/dist/chain-semantics/fund-flow.js +1 -1
- package/dist/chain-semantics/index.d.ts +1 -0
- package/dist/chain-semantics/index.js +1 -1
- package/dist/chain-semantics/object-graph.js +1 -1
- package/dist/composition/audit.js +1 -1
- package/dist/composition/compile.d.ts +1 -1
- package/dist/composition/compile.js +1 -1
- package/dist/data/api/api.spec.d.ts +1 -0
- package/dist/data/api/api.spec.js +1 -0
- package/dist/data/api/cli.d.ts +1 -0
- package/dist/data/api/cli.js +1 -0
- package/dist/data/api/head.d.ts +16 -0
- package/dist/data/api/head.js +1 -0
- package/dist/data/api/head.spec.d.ts +1 -0
- package/dist/data/api/head.spec.js +1 -0
- package/dist/data/api/index.d.ts +2 -0
- package/dist/data/api/index.js +1 -0
- package/dist/data/api/match.d.ts +69 -0
- package/dist/data/api/match.js +1 -0
- package/dist/data/api/match.spec.d.ts +1 -0
- package/dist/data/api/match.spec.js +1 -0
- package/dist/data/api/server.d.ts +12 -0
- package/dist/data/api/server.js +1 -0
- package/dist/data/projection/cli.d.ts +1 -0
- package/dist/data/projection/cli.js +1 -0
- package/dist/data/projection/edges.d.ts +8 -0
- package/dist/data/projection/edges.js +1 -0
- package/dist/data/projection/edges.spec.d.ts +1 -0
- package/dist/data/projection/edges.spec.js +1 -0
- package/dist/data/projection/facets.d.ts +18 -0
- package/dist/data/projection/facets.js +1 -0
- package/dist/data/projection/facets.spec.d.ts +1 -0
- package/dist/data/projection/facets.spec.js +1 -0
- package/dist/data/projection/facts.d.ts +40 -0
- package/dist/data/projection/facts.js +1 -0
- package/dist/data/projection/index.d.ts +6 -0
- package/dist/data/projection/index.js +1 -0
- package/dist/data/projection/project.d.ts +10 -0
- package/dist/data/projection/project.js +1 -0
- package/dist/data/projection/projection.spec.d.ts +1 -0
- package/dist/data/projection/projection.spec.js +1 -0
- package/dist/data/projection/schema.d.ts +1 -0
- package/dist/data/projection/schema.js +1 -0
- package/dist/data/projection/store.d.ts +49 -0
- package/dist/data/projection/store.js +1 -0
- package/dist/data/projection/types.d.ts +137 -0
- package/dist/data/projection/types.js +1 -0
- package/dist/data/sync/cdc.d.ts +34 -0
- package/dist/data/sync/cdc.js +1 -0
- package/dist/data/sync/cdc.spec.d.ts +1 -0
- package/dist/data/sync/cdc.spec.js +1 -0
- package/dist/data/sync/graphql-source.d.ts +16 -0
- package/dist/data/sync/graphql-source.js +1 -0
- package/dist/data/sync/index.d.ts +5 -0
- package/dist/data/sync/index.js +1 -0
- package/dist/data/sync/reconciler.d.ts +14 -0
- package/dist/data/sync/reconciler.js +1 -0
- package/dist/data/sync/reconciler.spec.d.ts +1 -0
- package/dist/data/sync/reconciler.spec.js +1 -0
- package/dist/data/sync/schema.d.ts +1 -0
- package/dist/data/sync/schema.js +1 -0
- package/dist/data/sync/store.d.ts +19 -0
- package/dist/data/sync/store.js +1 -0
- package/dist/data/sync/sync.spec.d.ts +1 -0
- package/dist/data/sync/sync.spec.js +1 -0
- package/dist/data/sync/synchronizer.d.ts +10 -0
- package/dist/data/sync/synchronizer.js +1 -0
- package/dist/data/sync/types.d.ts +162 -0
- package/dist/data/sync/types.js +1 -0
- package/dist/evaluation/builtins/demand-match.js +1 -1
- package/dist/evaluation/builtins/graph-service.spec.js +1 -1
- package/dist/evaluation/capability.d.ts +1 -0
- package/dist/evaluation/engine.js +1 -1
- package/dist/evaluation/extract.d.ts +7 -1
- package/dist/evaluation/extract.js +1 -1
- package/dist/evaluation/match-policy.d.ts +118 -0
- package/dist/evaluation/match-policy.js +1 -0
- package/dist/evaluation/match-policy.spec.d.ts +1 -0
- package/dist/evaluation/match-policy.spec.js +1 -0
- package/dist/experience/realtime-feedback.js +1 -1
- package/dist/graph/onchain/expand.js +1 -1
- package/dist/graph/onchain/exposure.js +1 -1
- package/dist/knowledge/arbitration-ledger.js +1 -1
- package/dist/knowledge/baselines/rules/plan.json +16 -1
- package/dist/knowledge/builtin-templates.d.ts +1 -1
- package/dist/knowledge/builtin-templates.js +1 -1
- package/dist/knowledge/getting-started.js +1 -1
- package/dist/knowledge/guard-design-patterns.d.ts +1 -1
- package/dist/knowledge/guard-design-patterns.js +1 -1
- package/dist/knowledge/guard-ledger.js +1 -1
- package/dist/knowledge/guard-puzzle.js +1 -1
- package/dist/knowledge/guard-render.js +1 -1
- package/dist/knowledge/guard-risk.js +1 -1
- package/dist/knowledge/guard-templates.js +1 -1
- package/dist/knowledge/guard-translation.js +1 -1
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/jsonrpc-enum.d.ts +26 -10
- package/dist/knowledge/jsonrpc-enum.js +1 -1
- package/dist/knowledge/projection.d.ts +54 -0
- package/dist/knowledge/projection.js +1 -0
- package/dist/knowledge/projection.spec.d.ts +1 -0
- package/dist/knowledge/projection.spec.js +1 -0
- package/dist/knowledge/recipient-constraint.d.ts +1 -1
- package/dist/knowledge/recipient-constraint.js +1 -1
- package/dist/knowledge/service-ledger.d.ts +1 -1
- package/dist/knowledge/service-ledger.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/template-scanner.js +1 -1
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/machine-panorama.js +1 -1
- package/dist/playbooks/service-build/object-panorama.js +1 -1
- package/dist/playbooks/service-build/participation-radar.js +1 -1
- package/dist/playbooks/service-build/relationship-profile.js +1 -1
- package/dist/playbooks/service-build/service-panorama.js +1 -1
- package/dist/playbooks/service-build/service-quote.js +1 -1
- package/dist/playbooks/service-build/service-quote.spec.js +1 -1
- package/dist/review/index.js +1 -1
- package/dist/role/profiles.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/call/allocation.js +1 -1
- package/dist/schema/call/proof.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 +189 -0
- package/dist/schema/evaluation/index.js +1 -1
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/query/bi.d.ts +4 -0
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/evaluation_operation.output.json +384 -2
- package/dist/schemas/evaluation_operation.schema.json +202 -4
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/onchain_operations.schema.json +666 -100
- package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
- package/dist/schemas/onchain_operations_gen_proof.schema.json +1 -1
- package/dist/schemas/onchain_operations_guard.schema.json +660 -94
- package/dist/schemas/onchain_operations_service.schema.json +4 -4
- package/dist/schemas/query_toolkit.output.json +299 -0
- package/dist/tools/handlers/benchmark-migration.d.ts +4 -2
- package/dist/tools/handlers/benchmark-migration.js +1 -1
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/evaluation.js +1 -1
- package/dist/tools/handlers/evaluation.spec.js +1 -1
- package/dist/tools/handlers/onchain.d.ts +1 -0
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/registry/business.js +1 -1
- package/dist/tools/wrap.js +1 -1
- package/package.json +7 -2
|
@@ -670,7 +670,7 @@
|
|
|
670
670
|
]
|
|
671
671
|
},
|
|
672
672
|
"restock": {
|
|
673
|
-
"description": "Refund restocking (permission 305 SERVICE_SALES). op:'flag' opts ONE live product into restock-on-refund; op:'order' puts the units a REFUNDED order purchased back on shelf. The order path is all-or-nothing: every purchased line must be flagged and still live before any unit moves (otherwise the chain aborts 46/32), so half a restock is impossible. Do NOT fake a restock with stock_add when the order carries several lines — use op:'order' so quantities come from the order itself.",
|
|
673
|
+
"description": "Refund restocking (permission 305 SERVICE_SALES). op:'flag' opts ONE live product into restock-on-refund; op:'order' puts the units a REFUNDED order purchased back on shelf. The order path is all-or-nothing: every purchased line must be flagged and still live before any unit moves (otherwise the chain aborts 46/32), so half a restock is impossible. The order path is once-per-order (replay aborts 49) and bound to THIS service (foreign order aborts 26). Do NOT fake a restock with stock_add when the order carries several lines — use op:'order' so quantities come from the order itself.",
|
|
674
674
|
"oneOf": [
|
|
675
675
|
{
|
|
676
676
|
"type": "object",
|
|
@@ -694,7 +694,7 @@
|
|
|
694
694
|
"flagged"
|
|
695
695
|
],
|
|
696
696
|
"additionalProperties": false,
|
|
697
|
-
"description": "Opt ONE live product in/out of restock-on-refund. An unknown sale_name aborts on chain (code 32); delisting the product is the kill switch. Without the flag, the order-level restock op refuses that line (code 46)."
|
|
697
|
+
"description": "Opt ONE live product in/out of restock-on-refund. An unknown sale_name aborts on chain (code 32); delisting the product is the kill switch. Without the flag, the order-level restock op refuses that line (code 46). Flagging a SKU does not itself touch stock — the order-level op below does the restoration, and it is once-per-order per order (code 49) and bound to orders of THIS service (foreign orders abort code 26)."
|
|
698
698
|
},
|
|
699
699
|
{
|
|
700
700
|
"type": "object",
|
|
@@ -706,7 +706,7 @@
|
|
|
706
706
|
"order": {
|
|
707
707
|
"type": "string",
|
|
708
708
|
"minLength": 1,
|
|
709
|
-
"description": "Address or local name of the REFUNDED order whose purchased units go back on shelf."
|
|
709
|
+
"description": "Address or local name of the REFUNDED order whose purchased units go back on shelf. Must be an order of THIS service (a foreign order aborts code 26), and each order can be restocked exactly once — a second call for the same order aborts code 49 (no retry succeeds; the restoration is already complete)."
|
|
710
710
|
}
|
|
711
711
|
},
|
|
712
712
|
"required": [
|
|
@@ -714,7 +714,7 @@
|
|
|
714
714
|
"order"
|
|
715
715
|
],
|
|
716
716
|
"additionalProperties": false,
|
|
717
|
-
"description": "Put back the units one refunded order purchased, read from the order's own purchase lines (the caller cannot add extra units). Two-pass all-or-nothing on chain: every line must be restock-flagged and still live before the first unit moves (unflagged → code 46, delisted → code 32), so a partial restock is impossible. Emits one stock-restocked event per line."
|
|
717
|
+
"description": "Put back the units one refunded order purchased, read from the order's own purchase lines (the caller cannot add extra units). Two-pass all-or-nothing on chain: every line must be restock-flagged and still live before the first unit moves (unflagged → code 46, delisted → code 32), so a partial restock is impossible. Once-per-order (code 49 on replay) and ownership-bound (a foreign order aborts code 26); the applied state is queryable via the restock_applied read. Emits one stock-restocked event per line."
|
|
718
718
|
}
|
|
719
719
|
]
|
|
720
720
|
},
|
|
@@ -16524,6 +16524,20 @@
|
|
|
16524
16524
|
}
|
|
16525
16525
|
]
|
|
16526
16526
|
},
|
|
16527
|
+
"shortfall": {
|
|
16528
|
+
"type": "string",
|
|
16529
|
+
"description": "Raw smallest units the merchant must add via service.compensation_fund_add before THIS basket can be ordered: max(0, required_for_this_basket - fund_balance). 0 when already covered."
|
|
16530
|
+
},
|
|
16531
|
+
"shortfall_display": {
|
|
16532
|
+
"anyOf": [
|
|
16533
|
+
{
|
|
16534
|
+
"type": "string"
|
|
16535
|
+
},
|
|
16536
|
+
{
|
|
16537
|
+
"type": "null"
|
|
16538
|
+
}
|
|
16539
|
+
]
|
|
16540
|
+
},
|
|
16527
16541
|
"covered": {
|
|
16528
16542
|
"type": "boolean",
|
|
16529
16543
|
"description": "True when the fund covers the per-order requirement; false means no fund (a disclosed merchant choice) or an under-funded Service."
|
|
@@ -16539,6 +16553,8 @@
|
|
|
16539
16553
|
"max_coverable_order_display",
|
|
16540
16554
|
"required_for_this_basket",
|
|
16541
16555
|
"required_display",
|
|
16556
|
+
"shortfall",
|
|
16557
|
+
"shortfall_display",
|
|
16542
16558
|
"covered",
|
|
16543
16559
|
"note"
|
|
16544
16560
|
],
|
|
@@ -25909,6 +25925,289 @@
|
|
|
25909
25925
|
"additionalProperties": false,
|
|
25910
25926
|
"description": "Returns U256. Sums the numeric payloads of candidates whose stored value matches the predicate (on-chain checked add, overflow aborts). Non-numeric or mismatching entries contribute 0. Use logic_as_u256_* to compare the sum."
|
|
25911
25927
|
},
|
|
25928
|
+
{
|
|
25929
|
+
"type": "object",
|
|
25930
|
+
"properties": {
|
|
25931
|
+
"type": {
|
|
25932
|
+
"type": "string",
|
|
25933
|
+
"const": "query_repository_data_sum_where_bound"
|
|
25934
|
+
},
|
|
25935
|
+
"object": {
|
|
25936
|
+
"type": "object",
|
|
25937
|
+
"properties": {
|
|
25938
|
+
"identifier": {
|
|
25939
|
+
"type": "integer",
|
|
25940
|
+
"minimum": 0,
|
|
25941
|
+
"maximum": 255,
|
|
25942
|
+
"description": "Identifier (0-255) for data lookup in Guard table. Slot consensus (enforced on-chain at guard table construction): 0-220 = user slots (free for business guards); 221-253 = PROTOCOL-RESERVED (rejected on-chain — reserved so future protocol features get fixed slots without colliding with published guards); 255 = ONCE replay-protection slot on Allocation (byte-keyed, the submitted bytes are the once-key — use for per-period keys like period-<N>); 254 = ONCE-FOR-OBJECT slot on Allocation (chain-derived key = bcs(the Allocation's payment_info.for_object); the submitted bytes are ignored and the submission only arms the slot — use for one-shot per-order rails such as full refunds). SLOT 0 SEMANTICS: slot 0 carries the transacted Order address by convention. As a submission slot it is legal on order/allocation/machine rails (the order exists when those verify), but FORBIDDEN on a Service buy_guard — the order does not exist when the buy-time passport is verified, so the mount is refused (service abort 43)."
|
|
25943
|
+
}
|
|
25944
|
+
},
|
|
25945
|
+
"required": [
|
|
25946
|
+
"identifier"
|
|
25947
|
+
],
|
|
25948
|
+
"additionalProperties": false,
|
|
25949
|
+
"description": "Reference to the Repository object in the Guard table (must be Address type)."
|
|
25950
|
+
},
|
|
25951
|
+
"key": {
|
|
25952
|
+
"type": "object",
|
|
25953
|
+
"properties": {
|
|
25954
|
+
"identifier": {
|
|
25955
|
+
"type": "integer",
|
|
25956
|
+
"minimum": 0,
|
|
25957
|
+
"maximum": 255,
|
|
25958
|
+
"description": "Identifier (0-255) for data lookup in Guard table. Slot consensus (enforced on-chain at guard table construction): 0-220 = user slots (free for business guards); 221-253 = PROTOCOL-RESERVED (rejected on-chain — reserved so future protocol features get fixed slots without colliding with published guards); 255 = ONCE replay-protection slot on Allocation (byte-keyed, the submitted bytes are the once-key — use for per-period keys like period-<N>); 254 = ONCE-FOR-OBJECT slot on Allocation (chain-derived key = bcs(the Allocation's payment_info.for_object); the submitted bytes are ignored and the submission only arms the slot — use for one-shot per-order rails such as full refunds). SLOT 0 SEMANTICS: slot 0 carries the transacted Order address by convention. As a submission slot it is legal on order/allocation/machine rails (the order exists when those verify), but FORBIDDEN on a Service buy_guard — the order does not exist when the buy-time passport is verified, so the mount is refused (service abort 43)."
|
|
25959
|
+
}
|
|
25960
|
+
},
|
|
25961
|
+
"required": [
|
|
25962
|
+
"identifier"
|
|
25963
|
+
],
|
|
25964
|
+
"additionalProperties": false,
|
|
25965
|
+
"description": "Reference to the policy key (String type table entry) whose data table is scanned."
|
|
25966
|
+
},
|
|
25967
|
+
"ids": {
|
|
25968
|
+
"type": "object",
|
|
25969
|
+
"properties": {
|
|
25970
|
+
"identifier": {
|
|
25971
|
+
"type": "integer",
|
|
25972
|
+
"minimum": 0,
|
|
25973
|
+
"maximum": 255,
|
|
25974
|
+
"description": "Identifier (0-255) for data lookup in Guard table. Slot consensus (enforced on-chain at guard table construction): 0-220 = user slots (free for business guards); 221-253 = PROTOCOL-RESERVED (rejected on-chain — reserved so future protocol features get fixed slots without colliding with published guards); 255 = ONCE replay-protection slot on Allocation (byte-keyed, the submitted bytes are the once-key — use for per-period keys like period-<N>); 254 = ONCE-FOR-OBJECT slot on Allocation (chain-derived key = bcs(the Allocation's payment_info.for_object); the submitted bytes are ignored and the submission only arms the slot — use for one-shot per-order rails such as full refunds). SLOT 0 SEMANTICS: slot 0 carries the transacted Order address by convention. As a submission slot it is legal on order/allocation/machine rails (the order exists when those verify), but FORBIDDEN on a Service buy_guard — the order does not exist when the buy-time passport is verified, so the mount is refused (service abort 43)."
|
|
25975
|
+
}
|
|
25976
|
+
},
|
|
25977
|
+
"required": [
|
|
25978
|
+
"identifier"
|
|
25979
|
+
],
|
|
25980
|
+
"additionalProperties": false,
|
|
25981
|
+
"description": "Reference to the candidate ID list (VecAddress type table entry). Each id should be an ORDER address (e.g. order-keyed contribution rows). Duplicates are deduped; max 100 candidates."
|
|
25982
|
+
},
|
|
25983
|
+
"where": {
|
|
25984
|
+
"oneOf": [
|
|
25985
|
+
{
|
|
25986
|
+
"type": "object",
|
|
25987
|
+
"properties": {
|
|
25988
|
+
"kind": {
|
|
25989
|
+
"type": "string",
|
|
25990
|
+
"const": "range"
|
|
25991
|
+
},
|
|
25992
|
+
"valueMin": {
|
|
25993
|
+
"description": "Optional lower bound (inclusive unless minInclusive=false). Plain number string (U256 semantics).",
|
|
25994
|
+
"type": "string"
|
|
25995
|
+
},
|
|
25996
|
+
"valueMax": {
|
|
25997
|
+
"description": "Optional upper bound (inclusive unless maxInclusive=false). Plain number string (U256 semantics).",
|
|
25998
|
+
"type": "string"
|
|
25999
|
+
},
|
|
26000
|
+
"minInclusive": {
|
|
26001
|
+
"description": "Default true. false makes the lower bound exclusive.",
|
|
26002
|
+
"type": "boolean"
|
|
26003
|
+
},
|
|
26004
|
+
"maxInclusive": {
|
|
26005
|
+
"description": "Default true. false makes the upper bound exclusive.",
|
|
26006
|
+
"type": "boolean"
|
|
26007
|
+
}
|
|
26008
|
+
},
|
|
26009
|
+
"required": [
|
|
26010
|
+
"kind"
|
|
26011
|
+
],
|
|
26012
|
+
"additionalProperties": false,
|
|
26013
|
+
"description": "Numeric closed/open range. min=max inclusive is an equality match. At least one bound required."
|
|
26014
|
+
},
|
|
26015
|
+
{
|
|
26016
|
+
"type": "object",
|
|
26017
|
+
"properties": {
|
|
26018
|
+
"kind": {
|
|
26019
|
+
"type": "string",
|
|
26020
|
+
"const": "numEq"
|
|
26021
|
+
},
|
|
26022
|
+
"value": {
|
|
26023
|
+
"type": "string",
|
|
26024
|
+
"description": "Exact numeric match. Plain number string (U256 semantics)."
|
|
26025
|
+
}
|
|
26026
|
+
},
|
|
26027
|
+
"required": [
|
|
26028
|
+
"kind",
|
|
26029
|
+
"value"
|
|
26030
|
+
],
|
|
26031
|
+
"additionalProperties": false
|
|
26032
|
+
},
|
|
26033
|
+
{
|
|
26034
|
+
"type": "object",
|
|
26035
|
+
"properties": {
|
|
26036
|
+
"kind": {
|
|
26037
|
+
"type": "string",
|
|
26038
|
+
"const": "gt"
|
|
26039
|
+
},
|
|
26040
|
+
"value": {
|
|
26041
|
+
"type": "string",
|
|
26042
|
+
"description": "Greater than. Plain number string (U256 semantics)."
|
|
26043
|
+
}
|
|
26044
|
+
},
|
|
26045
|
+
"required": [
|
|
26046
|
+
"kind",
|
|
26047
|
+
"value"
|
|
26048
|
+
],
|
|
26049
|
+
"additionalProperties": false
|
|
26050
|
+
},
|
|
26051
|
+
{
|
|
26052
|
+
"type": "object",
|
|
26053
|
+
"properties": {
|
|
26054
|
+
"kind": {
|
|
26055
|
+
"type": "string",
|
|
26056
|
+
"const": "gte"
|
|
26057
|
+
},
|
|
26058
|
+
"value": {
|
|
26059
|
+
"type": "string",
|
|
26060
|
+
"description": "Greater than or equal. Plain number string (U256 semantics)."
|
|
26061
|
+
}
|
|
26062
|
+
},
|
|
26063
|
+
"required": [
|
|
26064
|
+
"kind",
|
|
26065
|
+
"value"
|
|
26066
|
+
],
|
|
26067
|
+
"additionalProperties": false
|
|
26068
|
+
},
|
|
26069
|
+
{
|
|
26070
|
+
"type": "object",
|
|
26071
|
+
"properties": {
|
|
26072
|
+
"kind": {
|
|
26073
|
+
"type": "string",
|
|
26074
|
+
"const": "lt"
|
|
26075
|
+
},
|
|
26076
|
+
"value": {
|
|
26077
|
+
"type": "string",
|
|
26078
|
+
"description": "Less than. Plain number string (U256 semantics)."
|
|
26079
|
+
}
|
|
26080
|
+
},
|
|
26081
|
+
"required": [
|
|
26082
|
+
"kind",
|
|
26083
|
+
"value"
|
|
26084
|
+
],
|
|
26085
|
+
"additionalProperties": false
|
|
26086
|
+
},
|
|
26087
|
+
{
|
|
26088
|
+
"type": "object",
|
|
26089
|
+
"properties": {
|
|
26090
|
+
"kind": {
|
|
26091
|
+
"type": "string",
|
|
26092
|
+
"const": "lte"
|
|
26093
|
+
},
|
|
26094
|
+
"value": {
|
|
26095
|
+
"type": "string",
|
|
26096
|
+
"description": "Less than or equal. Plain number string (U256 semantics)."
|
|
26097
|
+
}
|
|
26098
|
+
},
|
|
26099
|
+
"required": [
|
|
26100
|
+
"kind",
|
|
26101
|
+
"value"
|
|
26102
|
+
],
|
|
26103
|
+
"additionalProperties": false
|
|
26104
|
+
},
|
|
26105
|
+
{
|
|
26106
|
+
"type": "object",
|
|
26107
|
+
"properties": {
|
|
26108
|
+
"kind": {
|
|
26109
|
+
"type": "string",
|
|
26110
|
+
"const": "addressEq"
|
|
26111
|
+
},
|
|
26112
|
+
"identifier": {
|
|
26113
|
+
"type": "integer",
|
|
26114
|
+
"minimum": 0,
|
|
26115
|
+
"maximum": 255,
|
|
26116
|
+
"description": "Identifier of the Address-type table entry to compare against."
|
|
26117
|
+
}
|
|
26118
|
+
},
|
|
26119
|
+
"required": [
|
|
26120
|
+
"kind",
|
|
26121
|
+
"identifier"
|
|
26122
|
+
],
|
|
26123
|
+
"additionalProperties": false
|
|
26124
|
+
},
|
|
26125
|
+
{
|
|
26126
|
+
"type": "object",
|
|
26127
|
+
"properties": {
|
|
26128
|
+
"kind": {
|
|
26129
|
+
"type": "string",
|
|
26130
|
+
"const": "stringEq"
|
|
26131
|
+
},
|
|
26132
|
+
"value": {
|
|
26133
|
+
"type": "string",
|
|
26134
|
+
"description": "Exact string match (byte equality, UTF-8)."
|
|
26135
|
+
}
|
|
26136
|
+
},
|
|
26137
|
+
"required": [
|
|
26138
|
+
"kind",
|
|
26139
|
+
"value"
|
|
26140
|
+
],
|
|
26141
|
+
"additionalProperties": false
|
|
26142
|
+
},
|
|
26143
|
+
{
|
|
26144
|
+
"type": "object",
|
|
26145
|
+
"properties": {
|
|
26146
|
+
"kind": {
|
|
26147
|
+
"type": "string",
|
|
26148
|
+
"const": "stringContains"
|
|
26149
|
+
},
|
|
26150
|
+
"value": {
|
|
26151
|
+
"type": "string",
|
|
26152
|
+
"description": "Substring match, case-sensitive."
|
|
26153
|
+
}
|
|
26154
|
+
},
|
|
26155
|
+
"required": [
|
|
26156
|
+
"kind",
|
|
26157
|
+
"value"
|
|
26158
|
+
],
|
|
26159
|
+
"additionalProperties": false
|
|
26160
|
+
},
|
|
26161
|
+
{
|
|
26162
|
+
"type": "object",
|
|
26163
|
+
"properties": {
|
|
26164
|
+
"kind": {
|
|
26165
|
+
"type": "string",
|
|
26166
|
+
"const": "stringNoCaseContains"
|
|
26167
|
+
},
|
|
26168
|
+
"value": {
|
|
26169
|
+
"type": "string",
|
|
26170
|
+
"description": "Substring match, case-insensitive."
|
|
26171
|
+
}
|
|
26172
|
+
},
|
|
26173
|
+
"required": [
|
|
26174
|
+
"kind",
|
|
26175
|
+
"value"
|
|
26176
|
+
],
|
|
26177
|
+
"additionalProperties": false
|
|
26178
|
+
},
|
|
26179
|
+
{
|
|
26180
|
+
"type": "object",
|
|
26181
|
+
"properties": {
|
|
26182
|
+
"kind": {
|
|
26183
|
+
"type": "string",
|
|
26184
|
+
"const": "boolEq"
|
|
26185
|
+
},
|
|
26186
|
+
"value": {
|
|
26187
|
+
"type": "boolean",
|
|
26188
|
+
"description": "Boolean equality."
|
|
26189
|
+
}
|
|
26190
|
+
},
|
|
26191
|
+
"required": [
|
|
26192
|
+
"kind",
|
|
26193
|
+
"value"
|
|
26194
|
+
],
|
|
26195
|
+
"additionalProperties": false
|
|
26196
|
+
}
|
|
26197
|
+
],
|
|
26198
|
+
"description": "Predicate filter applied to each candidate's data value."
|
|
26199
|
+
}
|
|
26200
|
+
},
|
|
26201
|
+
"required": [
|
|
26202
|
+
"type",
|
|
26203
|
+
"object",
|
|
26204
|
+
"key",
|
|
26205
|
+
"ids",
|
|
26206
|
+
"where"
|
|
26207
|
+
],
|
|
26208
|
+
"additionalProperties": false,
|
|
26209
|
+
"description": "Returns U256. ESCROW-BOUND sum (query 1179): per-row min(row_value, order.amount of the Order the row id names); a row keyed by anything that is not an Order contributes 0 (fail-closed). Unlike query_repository_data_sum_where (self-reported row values), a record cannot claim more than the Order actually escrowed — the forgery-proof aggregate for threshold gates and Formula pricing. Use logic_as_u256_* to compare the sum."
|
|
26210
|
+
},
|
|
25912
26211
|
{
|
|
25913
26212
|
"type": "object",
|
|
25914
26213
|
"properties": {
|
|
@@ -26,8 +26,9 @@ declare function driftFace(templateId: string): {
|
|
|
26
26
|
detail: string;
|
|
27
27
|
};
|
|
28
28
|
declare function scanSummary(scan: TemplateScanResult, drift?: ReturnType<typeof driftFace>): {
|
|
29
|
+
template_id: string;
|
|
29
30
|
risk_level: import("../../knowledge/template-scanner.js").TemplateRiskLevel;
|
|
30
|
-
|
|
31
|
+
preflight_scan_passed: boolean;
|
|
31
32
|
finding_count: number;
|
|
32
33
|
findings_by_severity: Record<string, number>;
|
|
33
34
|
red_flags: string[];
|
|
@@ -55,9 +56,10 @@ declare function scanSummary(scan: TemplateScanResult, drift?: ReturnType<typeof
|
|
|
55
56
|
detail: string;
|
|
56
57
|
} | undefined;
|
|
57
58
|
};
|
|
58
|
-
export declare function buildVerdict(summary: ReturnType<typeof scanSummary>, plan: Record<string, unknown
|
|
59
|
+
export declare function buildVerdict(summary: ReturnType<typeof scanSummary>, plan: Record<string, unknown>, mirrorGenerateHighGate?: boolean): {
|
|
59
60
|
buildable: boolean;
|
|
60
61
|
blockers: string[];
|
|
62
|
+
status: "READY" | "BLOCKED";
|
|
61
63
|
};
|
|
62
64
|
export declare function planNextAction(plan: Record<string, unknown>, retryAction: string, verdict?: {
|
|
63
65
|
buildable: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{strictParse}from'../../schema/index.js';import{BenchmarkMigrationSchema}from'../../schema/benchmark-migration/index.js';import{getTemplate,listTemplates,validateAllocatorRows,platformShareBps,builtinTemplateDrift}from'../../knowledge/template-loader.js';import{BUILTIN_TEMPLATES,BUILTIN_TEMPLATES_VERSION}from'../../knowledge/builtin-templates.js';import{scanTemplate,buildFeeParamLandingTable}from'../../knowledge/template-scanner.js';import{planMigration}from'../../playbooks/service-build/migration-planner.js';import{handleMerchantGuide}from'../../playbooks/service-build/merchant-guide.js';import{inferArbitration}from'../../playbooks/service-build/intent-analyzer.js';import{getIndustryModeRegistry}from'../../extensions/index.js';import{resolveIndustryName}from'../../knowledge/industry-registry.js';function templateSummary(a){return{'id':a['id'],'industry':a['industry'],'variant':a['variant'],'product_ref':a['product_ref'],'archetype':a['archetype'],'key_risk':a['key_risk'],'node_count':a['machine_shape']['length'],'guard_count':a['guards']['length'],'recommended_role':a['recommended_role']};}function templateGetAids(a){const b=a['machine_shape']['some'](c=>c['name']==='reviewed');return{'claim_anchor':b?'review_node+final':'final_only','claim_anchor_note':b?'machine_shape\x20mounts\x20a\x20\x27reviewed\x27\x20node\x20—\x20the\x20buyer\x27s\x20structured\x20review\x20rides\x20that\x20node\x20alongside\x20the\x20final\x20settlement.':'no\x20\x27reviewed\x27\x20node\x20—\x20sanctioned\x20variant:\x20the\x20buyer\x27s\x20voice\x20rides\x20the\x20claim/arbitration\x20rail\x20only\x20(no\x20separate\x20review\x20stop).','allocator_count_note':'allocator.count\x20=\x20'+a['allocator']['count']+'\x20counts\x20SETTLEMENT-track\x20legs\x20only;\x20refund-track\x20legs\x20(rows[]\x20with\x20track:\x22refund\x22)\x20are\x20additional\x20and\x20NOT\x20included\x20in\x20this\x20count.\x20rows[]\x20carries\x20the\x20complete\x20executable\x20split\x20plan.','onchain_field_notes':['passport.impack\x20—\x20the\x20on-chain\x20field\x20is\x20spelled\x20`impack`\x20(passport.move,\x20packed\x20business\x20objects\x20in\x20the\x20passport\x20verification\x20context).\x20It\x20is\x20the\x20contract\x27s\x20own\x20field\x20name,\x20not\x20a\x20typo;\x20echo\x20it\x20verbatim.']};}function requireTemplate(a,b){if(!a)throw new Error('\x27template_id\x27\x20is\x20required\x20for\x20action=\x27'+b+'\x27');const c=getTemplate(a);if(!c)throw new Error('Unknown\x20template\x20id:\x20'+a+'\x20(use\x20action=\x27template_list\x27\x20to\x20see\x20valid\x20ids)');return c;}function driftFace(a){const b=builtinTemplateDrift()['find'](c=>c['template']===a);if(!b){const c=BUILTIN_TEMPLATES['some'](d=>d['id']===a);return c?{'template':a,'state':'current','catalog_version':BUILTIN_TEMPLATES_VERSION,'blocked':![],'repairable':![],'detail':'disk\x20body\x20matches\x20the\x20shipped\x20catalog\x20(hash-verified\x20sentinel)'}:{'template':a,'state':'untracked','catalog_version':undefined,'blocked':![],'repairable':![],'detail':'user-authored\x20template\x20—\x20no\x20builtin\x20catalog\x20binding\x20to\x20compare\x20against'};}return{'template':b['template'],'state':b['state'],'catalog_version':BUILTIN_TEMPLATES_VERSION,'blocked':!![],'repairable':b['repairable'],'detail':b['detail']};}function scanSummary(a,b){const c={};for(const d of a['findings'])c[d['severity']]=(c[d['severity']]??0x0)+0x1;return{'risk_level':a['risk_level'],'passed':a['red_flags']['length']===0x0,'finding_count':a['findings']['length'],'findings_by_severity':c,'red_flags':a['red_flags'],'findings':a['findings'],'drift':b};}function assertScanPassed(a,b){const c=a['red_flags'];if(a['passed']||c['length']===0x0)return;throw new Error('action=\x27'+b+'\x27\x20blocked:\x20pre-deploy\x20scan\x20of\x20template\x20\x27'+a['template_id']+'\x27\x20found\x20CRITICAL\x20risk\x20—\x20'+c['join'](';\x20')+'.\x20Fix\x20the\x20template\x20(frontmatter\x20or\x20body)\x20and\x20re-run\x20action=\x27template_scan\x27.');}const GENERATE_HIGH_TOLERATED=new Set([]);function assertGenerateScanPassed(a,b){assertScanPassed(a,b);if(b!=='template_generate')return;const c=a['findings']['filter'](d=>d['severity']==='high'&&!(d['rule_id']&&GENERATE_HIGH_TOLERATED['has'](a['template_id']+'/'+d['rule_id'])));if(c['length']===0x0)return;throw new Error('action=\x27'+b+'\x27\x20blocked:\x20pre-deploy\x20scan\x20of\x20template\x20\x27'+a['template_id']+'\x27\x20found\x20'+c['length']+'\x20HIGH\x20finding(s)\x20—\x20'+c['map'](d=>(d['rule_id']??'HIGH')+':\x20'+d['title'])['join'](';\x20')+'.\x20Fix\x20the\x20template\x20(frontmatter\x20or\x20body)\x20and\x20re-run\x20action=\x27template_scan\x27.');}export function buildVerdict(a,b){const c=[];!a['passed']&&c['push']('scan:\x20'+(a['findings_by_severity']['critical']??0x0)+'\x20CRITICAL\x20finding(s)\x20(scan.passed=false)');const d=b['graph_validation'];if(d&&d['valid']===![]){const f=Array['isArray'](d['hard_violations'])?d['hard_violations']['length']:0x0,g=Array['isArray'](d['hard_violations'])?d['hard_violations']['map'](h=>h['id'])['join'](',\x20'):'';c['push']('graph_validation:\x20'+f+'\x20hard\x20violation(s)'+(g?'\x20('+g+')':''));}const e=b['audit'];return e&&e['blocking']===!![]&&c['push']('audit:\x20guide\x20audit\x20flagged\x20blocking\x20issue(s)\x20(plan.audit)'),{'buildable':c['length']===0x0,'blockers':c};}export function planNextAction(a,b,c){const d=a['next_action'];if(typeof d==='string'&&d['startsWith']('Plan\x20ready.'))return d;if(c?.['buildable']){const f=Array['isArray'](a['pending_guard_designs'])?a['pending_guard_designs']['length']:0x0;return'Plan\x20is\x20buildable\x20(verdict.buildable=true).\x20Materialize\x20the\x20objects\x20in\x20plan.steps\x20order'+(f>0x0?',\x20resolving\x20the\x20'+f+'\x20pending\x20guard\x20design(s)\x20in\x20plan.pending_guard_designs\x20via\x20guard_resolutions\x20before\x20the\x20Machine\x20publish':'')+'.';}const e=Array['isArray'](a['pending_guard_designs'])?a['pending_guard_designs']['length']:0x0;return'Plan\x20BLOCKED\x20by\x20the\x20guide\x20audit\x20(see\x20plan.audit\x20/\x20plan.next_action).\x20Do\x20NOT\x20materialize,\x20'+'and\x20do\x20NOT\x20hand-build\x20the\x20objects\x20instead:\x20this\x20plan\x20is\x20the\x20wiring\x20authority\x20(Arbitration\x20+\x20'+'compensation-fund,\x20Contact/um,\x20allocator\x20rows)\x20and\x20hand-built\x20replicas\x20silently\x20drop\x20those\x20wirings.\x20'+(e>0x0?'Resolve\x20the\x20'+e+'\x20pending\x20guard\x20design(s)\x20in\x20plan.pending_guard_designs\x20via\x20guard_resolutions\x20(kind\x20\x27inline\x27\x20with\x20the\x20Guard\x20table+root,\x20kind\x20\x27template\x27\x20with\x20a\x20tpl_*\x20id,\x20or\x20{kind:\x27omit\x27}\x20for\x20advisory\x20designs\x20that\x20do\x20not\x20apply\x20to\x20this\x20shop),\x20':'Adjust\x20fee_overrides,\x20pick\x20another\x20template\x20variant,\x20or\x20fix\x20the\x20template,\x20')+('then\x20re-run\x20action=\x27'+b+'\x27.');}function templateIntent(a,b){if(b&&b['trim']())return b['trim']();return'Adopt\x20the\x20'+a['id']+'\x20industry\x20archetype\x20template\x20('+a['archetype']+')\x20for\x20the\x20'+a['industry']+'\x20industry.\x20'+('Primary\x20risk\x20to\x20mitigate:\x20'+a['key_risk']+'.');}function effectiveFeeParams(a,b){return{...a['fee_params'],...b??{}};}const REWARD_POOL_PATTERNS=[/(?:reward|review|bonus|tip|prize)[\s-]*pools?\s*(?:of|is|at|:|=)?\s*([0-9][0-9_,]*(?:\.[0-9]+)?)/i,/([0-9][0-9_,]*(?:\.[0-9]+)?)\s*(?:reward|review|bonus|tip|prize)[\s-]*pools?\b/i,/(?:奖(?:金|励)?池|打赏池|好评(?:奖励)?池)\s*(?:为|是|:|:|=)?\s*([0-9][0-9_,]*(?:\.[0-9]+)?)/,/([0-9][0-9_,]*(?:\.[0-9]+)?)\s*的?\s*(?:奖(?:金|励)?池|打赏池|好评(?:奖励)?池)/];export function extractRewardPoolCandidate(a){if(!a)return undefined;for(const b of REWARD_POOL_PATTERNS){const c=b['exec'](a);if(!c)continue;const d=Number(c[0x1]['replaceAll'](/[,_]/g,''));if(Number['isFinite'](d)&&d>=0x0)return d;}return undefined;}function rewardPoolPrefill(a,b,c){if(a['fee_params']['review_reward_pool']===undefined)return undefined;if(c?.['review_reward_pool']!==undefined)return undefined;const d=extractRewardPoolCandidate(b);return d===undefined?undefined:{'fee_key':'review_reward_pool','value':d};}function validateFeeParams(a,b){const c=[];let d=0x0;for(const [e,f]of Object['entries'](a)){if(typeof f!=='number'||!Number['isFinite'](f))continue;if(e['endsWith']('_bps')){(!Number['isInteger'](f)||f<0x0||f>0x2710)&&c['push'](e+'='+f+'\x20is\x20not\x20an\x20integer\x20rate\x20in\x20[0,\x2010000]\x20bps');if(e['endsWith']('_share_bps'))d+=Math['max'](0x0,f);}else{if(e['endsWith']('_days')){if(f<=0x0||f>0xe42)c['push'](e+'='+f+'\x20is\x20outside\x20the\x20sane\x20window\x20range\x20(0,\x203650]\x20days');}else{if(e['endsWith']('_hours')){if(f<=0x0||f>0x2238)c['push'](e+'='+f+'\x20is\x20outside\x20the\x20sane\x20window\x20range\x20(0,\x208760]\x20hours');}}}}if(d>0x2710)c['push']('*_share_bps\x20sum\x20'+d+'\x20exceeds\x2010000\x20(a\x20pool\x20splits\x20into\x20at\x20most\x20100%)');if(c['length']>0x0)throw new Error('invalid\x20fee\x20parameters\x20for\x20template\x20\x27'+b+'\x27:\x20'+c['join'](';\x20')+'.\x20'+'Correct\x20the\x20template\x27s\x20fee_params\x20or\x20pass\x20valid\x20\x27fee_overrides\x27.');}export{validateAllocatorRows};export function variantPaymentModel(a){if(a['payment_model'])return a['payment_model'];const b=a['allocator']['rows']??[];if(b['some'](d=>d['track']==='refund'))return'escrow';const c=a['machine_shape']['map'](d=>d['name'])['join']('\x20')['toLowerCase']();if(/\b(milestone|revision|revis|draft|deliverable)\b/['test'](c))return'milestone';if(/\b(charge|renew|subscription|cycle|billing|monthly)\b/['test'](c))return'subscription';return'escrow';}function variantRefundPolicy(a){const b=a['allocator']['description']['toLowerCase']();if(/full[ -]?refund|100% refund|refund .*100/['test'](b))return'full';if(/pro-?rata|prorated/['test'](b))return'milestone_prorated';if(/partial/['test'](b))return'partial';return undefined;}export function variantDeliverables(a,b){const c=a['machine_shape']['filter'](g=>g['semantic_role']==='final'),d=c[c['length']-0x1]??[...a['machine_shape']]['reverse']()['find'](g=>!/refund|cancel|dispute|terminat/i['test'](g['name']+'\x20'+g['role']))??a['machine_shape'][a['machine_shape']['length']-0x1],e=b?.['has_logistics']?'physical':b?.['pure_digital']?'digital':'service_session',f=(a['guards']??[])['filter'](h=>/repository_data_check|required_info_evidence_gate|allocator_order_anchor/['test'](h['template_id']));return[{'name':a['variant']+'\x20fulfillment','type':e,'acceptanceCriteria':'Order\x20reaches\x20the\x20terminal\x20workflow\x20node\x20\x27'+d['name']+'\x27\x20('+d['role']+')','proofOfDelivery':f['length']>0x0?'wip_hash':'manual_confirm'}];}function validateConditionalParams(a,b){for(const d of a['conditional_guards']??[]){const e=b[d['param']];if(e===undefined)continue;if(typeof e!=='string'||!d['values']['includes'](e))throw new Error('invalid\x20\x27'+d['param']+'='+String(e)+'\x27\x20for\x20template\x20\x27'+a['id']+'\x27:\x20must\x20be\x20one\x20of\x20'+d['values']['map'](f=>'\x27'+f+'\x27')['join']('\x20|\x20')+('\x20(the\x20guard\x20variant\x20mounts\x20at\x20\x27'+d['emit_value']+'\x27)'));}}async function runGuide(a,b,c,d,e,f){const g=effectiveFeeParams(a,c),h=rewardPoolPrefill(a,b,c);if(h)g[h['fee_key']]=h['value'];validateFeeParams(g,a['id']),validateConditionalParams(a,g);const i=getIndustryModeRegistry()['getMode'](a['industry']),j=platformShareBps(g),k={'model':variantPaymentModel(a)},l=[],m=(a['allocator']['rows']?.['length']??0x0)>0x0;if(j!==undefined&&j>0x0&&!m&&a['allocator']['mode']==='rate'){const q=Math['round'](j)/0x64;l['push']({'recipient':'merchant','percentage':Math['round']((0x64-q)*0x64)/0x64}),l['push']({'recipient':'platform','percentage':q}),k['allocation']=l;}const n=variantRefundPolicy(a),o={'escrow':!![]};if(n)o['refundPolicy']=n;o['arbitration']=a['arbitration_mode']??o['arbitration']??inferArbitration(templateIntent(a,b));const p=await handleMerchantGuide({'intent':templateIntent(a,b),'guide_confirm':{'industry':a['industry'],'payment':k,'trust':o,'deliverables':variantDeliverables(a,i?.['traits']),...d&&Object['keys'](d)['length']>0x0?{'guard_resolutions':d}:{},...e?.['review_mode']?{'review_mode':e['review_mode']}:{},...e?.['reward_funding']!==undefined?{'reward_funding':e['reward_funding']}:{},...e?.['after_sales_mode']?{'after_sales_mode':e['after_sales_mode']}:{},...e?.['acceptance_mode']?{'acceptance_mode':e['acceptance_mode']}:{},...e?.['installment_mode']?{'installment_mode':e['installment_mode']}:{},...e?.['affiliate_mode']?{'affiliate_mode':e['affiliate_mode']}:{},...e?.['crowdfunding_mode']?{'crowdfunding_mode':e['crowdfunding_mode']}:{},...f?.['length']?{'sales':f}:{}},'template_override':{...a,'fee_params':g},'name_base':a['id']});if(a['allocator']['rows']?.['length'])p['template_allocator_rows']=a['allocator']['rows']['map'](s=>({...s}));p['template']={'id':a['id'],'archetype':a['archetype'],'recommended_role':a['recommended_role'],'fee_params':g},p['template_fee_param_landings']=buildFeeParamLandingTable(a,g);if(c&&Object['keys'](c)['length']>0x0)p['template_fee_overrides']=c;return h&&(p['fee_overrides_prefill']=h,p['next_action']=p['next_action']+'\x20Reward\x20pool\x20prefilled\x20from\x20your\x20request:\x20'+h['value']+'\x20—\x20adjust\x20via\x20fee_overrides.'),p;}export async function handleBenchmarkMigrationOperation(a){const b=strictParse(BenchmarkMigrationSchema,a,'benchmark_migration_operation\x20input'),c=b['industry']?resolveIndustryName(b['industry'])??b['industry']['toLowerCase']():undefined;let d;switch(b['action']){case'template_list':{const {templates:e,errors:f}=listTemplates(),g=c?e['filter'](i=>i['industry']===c):e,h=new Map(builtinTemplateDrift()['map'](i=>[i['template'],i['state']]));d={'action':'template_list','count':g['length'],'templates':g['map'](i=>({...templateSummary(i),'disk_state':h['get'](i['id'])??(BUILTIN_TEMPLATES['some'](j=>j['id']===i['id'])?'current':'untracked')})),'load_errors':f};break;}case'template_get':{const i=requireTemplate(b['template_id'],'template_get');d={'action':'template_get','template':{...i,...templateGetAids(i)}};break;}case'template_generate':{const j=requireTemplate(b['template_id'],'template_generate'),k=b['review_mode']??j['review_mode']??'none';if(k==='review_reward'&&!b['reward_funding'])return{'content':[{'type':'text','text':'template_generate\x20refused\x20—\x20no\x20plan\x20was\x20built.\x20Template\x20\x27'+j['id']+'\x27\x20resolves\x20to\x20review_mode\x20\x27review_reward\x27\x20(input'+(b['review_mode']?'':'\x20via\x20template\x20declaration')+'),\x20which\x20promises\x20buyers\x20a\x20claimable\x20review\x20bounty\x20—\x20an\x20unfunded\x20pool\x20must\x20not\x20ship.\x20Pass\x20reward_funding\x20(smallest-unit\x20string),\x20or\x20drop\x20the\x20mode\x20explicitly\x20(review_mode\x20\x27review\x27\x20keeps\x20the\x20review\x20rail\x20without\x20the\x20bounty;\x20\x27none\x27\x20removes\x20the\x20rail).'}],'structuredContent':{'result':{'type':'error','error':'review_mode\x20\x27'+k+'\x27\x20without\x20reward_funding\x20(INV-4)\x20on\x20template\x20\x27'+j['id']+'\x27.','error_code':'reward_funding_required','retryable':!![],'recovery_hint':'Pass\x20reward_funding\x20=\x20expected\x20orders\x20x\x20per-order\x20reward\x20(fee_param\x20review_reward_pool\x20is\x20the\x20planning\x20benchmark),\x20or\x20re-send\x20with\x20review_mode:\x27review\x27\x20(rail\x20only)\x20/\x20\x27none\x27\x20(no\x20rail).'},'message':'Refused:\x20a\x20review_reward\x20build\x20requires\x20a\x20funded\x20reward\x20pool.\x20See\x20recovery_hint.'}};if(!Array['isArray'](b['sales'])||b['sales']['length']===0x0)return{'content':[{'type':'text','text':'template_generate\x20refused\x20—\x20no\x20plan\x20was\x20built.\x20The\x20sellable\x20catalog\x20(sales)\x20is\x20required:\x20a\x20plan\x20without\x20one\x20publishes\x20a\x20Service\x20frozen\x20with\x20sales:\x20[]\x20and\x20every\x20order_new\x20aborts\x20(PLAN-SALES-01).\x20List\x20at\x20least\x20one\x20SKU:\x20{\x20name,\x20price,\x20quantity?,\x20wip_hash?\x20}\x20—\x20price\x20in\x20smallest\x20units.'}],'structuredContent':{'result':{'type':'error','error':'template_generate\x20without\x20a\x20non-empty\x20sales\x20catalog\x20(PLAN-SALES-01\x20upgraded\x20to\x20an\x20input\x20requirement,\x20amz9\x20A-2).','error_code':'sales_required','retryable':!![],'recovery_hint':'Pass\x20sales:\x20[{\x20name,\x20price,\x20quantity?,\x20wip_hash?\x20}]\x20—\x20one\x20entry\x20per\x20sellable\x20SKU\x20(wip_hash\x20from\x20the\x20wip_file\x20tool\x20upload).\x20migration_apply\x20is\x20unaffected:\x20it\x20confirms\x20an\x20already-reviewed\x20import.'},'message':'Refused:\x20template_generate\x20requires\x20a\x20sellable\x20catalog.\x20See\x20recovery_hint.'}};const l=scanTemplate(j);assertGenerateScanPassed(l,'template_generate');const m=await runGuide(j,b['description'],b['fee_overrides'],b['guard_resolutions'],{'review_mode':b['review_mode'],'reward_funding':b['reward_funding'],'after_sales_mode':b['after_sales_mode'],'acceptance_mode':b['acceptance_mode'],'installment_mode':b['installment_mode'],'affiliate_mode':b['affiliate_mode'],'crowdfunding_mode':b['crowdfunding_mode']},b['sales']);d=((()=>{const n=scanSummary(l,driftFace(j['id'])),o=buildVerdict(n,m);return{'action':'template_generate','template_id':j['id'],'scan':n,'plan':m,'verdict':o,'next_action':planNextAction(m,'template_generate',o)};})());break;}case'template_scan':{const n=requireTemplate(b['template_id'],'template_scan');d={'action':'template_scan','scan':{...scanTemplate(n),'drift':driftFace(n['id'])}};break;}case'migration_import':{if(!b['description']||!b['description']['trim']())throw new Error('\x27description\x27\x20is\x20required\x20for\x20action=\x27migration_import\x27');const o=planMigration({'url':b['url'],'description':b['description'],'industry':c,'network':b['network']});if(!o)throw new Error('No\x20industry\x20template\x20matched\x20the\x20description.\x20Refine\x20the\x20description\x20or\x20pass\x20an\x20explicit\x20\x27industry\x27\x20hint.');d={'action':'migration_import','log':o,'next_action':'MigrationLog\x20ready.\x20Next:\x20call\x20action=\x27migration_review\x27\x20with\x20this\x20log\x20to\x20surface\x20the\x20mapped/unmapped/manual_review\x20items\x20for\x20user\x20confirmation.'};break;}case'migration_review':{if(!b['log'])throw new Error('\x27log\x27\x20is\x20required\x20for\x20action=\x27migration_review\x27');const p=b['log'],q=Array['isArray'](p['mapped'])?p['mapped']:[],r=Array['isArray'](p['unmapped'])?p['unmapped']:[],s=Array['isArray'](p['manual_review'])?p['manual_review']:[],t=p['risk_check']??{},u=p['source']?.['matched_template']??'',v=r['length']===0x0&&s['length']===0x0&&t['passed']===!![];d={'action':'migration_review','log':p,'review_summary':{'mapped_count':q['length'],'unmapped_count':r['length'],'manual_review_count':s['length'],'risk_passed':t['passed']===!![]},'next_action':v?'Review\x20clean.\x20Proceed:\x20call\x20action=\x27migration_apply\x27\x20with\x20template_id=\x27'+u+'\x27\x20to\x20produce\x20the\x20creation\x20plan\x20(network\x20defaults\x20to\x20testnet;\x20mainnet\x20requires\x20explicit\x20user\x20confirmation).':'Surface\x20the\x20'+r['length']+'\x20unmapped\x20and\x20'+s['length']+'\x20manual_review\x20items'+(t['passed']===!![]?'':'\x20plus\x20the\x20risk_check\x20findings')+'\x20to\x20the\x20user\x20for\x20a\x20decision\x20before\x20action=\x27migration_apply\x27\x20(template_id=\x27'+u+'\x27).'};break;}case'migration_apply':{const w=requireTemplate(b['template_id'],'migration_apply'),x=scanTemplate(w);assertScanPassed(x,'migration_apply');const y=b['network']??'testnet',z=await runGuide(w,b['description'],b['fee_overrides'],b['guard_resolutions'],{'review_mode':b['review_mode'],'reward_funding':b['reward_funding'],'after_sales_mode':b['after_sales_mode'],'acceptance_mode':b['acceptance_mode'],'installment_mode':b['installment_mode'],'affiliate_mode':b['affiliate_mode'],'crowdfunding_mode':b['crowdfunding_mode']},b['sales']);d=((()=>{const A=scanSummary(x,driftFace(w['id'])),B=buildVerdict(A,z);return{'action':'migration_apply','template_id':w['id'],'network':y,'scan':A,'plan':z,'verdict':B,'next_action':planNextAction(z,'migration_apply',B)};})());break;}default:throw new Error('Unknown\x20benchmark_migration_operation\x20action:\x20'+String(b['action']));}return{'content':[{'type':'text','text':JSON['stringify']({'result':d})}],'structuredContent':{'result':d}};}
|
|
1
|
+
import{strictParse}from'../../schema/index.js';import{BenchmarkMigrationSchema}from'../../schema/benchmark-migration/index.js';import{getTemplate,listTemplates,validateAllocatorRows,platformShareBps,builtinTemplateDrift}from'../../knowledge/template-loader.js';import{BUILTIN_TEMPLATES,BUILTIN_TEMPLATES_VERSION}from'../../knowledge/builtin-templates.js';import{scanTemplate,buildFeeParamLandingTable}from'../../knowledge/template-scanner.js';import{planMigration}from'../../playbooks/service-build/migration-planner.js';import{handleMerchantGuide}from'../../playbooks/service-build/merchant-guide.js';import{inferArbitration}from'../../playbooks/service-build/intent-analyzer.js';import{getIndustryModeRegistry}from'../../extensions/index.js';import{resolveIndustryName}from'../../knowledge/industry-registry.js';function templateSummary(a){return{'id':a['id'],'industry':a['industry'],'variant':a['variant'],'product_ref':a['product_ref'],'archetype':a['archetype'],'key_risk':a['key_risk'],'node_count':a['machine_shape']['length'],'guard_count':a['guards']['length'],'recommended_role':a['recommended_role']};}function templateGetAids(a){const b=a['machine_shape']['some'](c=>c['name']==='reviewed');return{'claim_anchor':b?'review_node+final':'final_only','claim_anchor_note':b?'machine_shape\x20mounts\x20a\x20\x27reviewed\x27\x20node\x20—\x20the\x20buyer\x27s\x20structured\x20review\x20rides\x20that\x20node\x20alongside\x20the\x20final\x20settlement.':'no\x20\x27reviewed\x27\x20node\x20—\x20sanctioned\x20variant:\x20the\x20buyer\x27s\x20voice\x20rides\x20the\x20claim/arbitration\x20rail\x20only\x20(no\x20separate\x20review\x20stop).','allocator_count_note':'allocator.count\x20=\x20'+a['allocator']['count']+'\x20counts\x20SETTLEMENT-track\x20legs\x20only;\x20refund-track\x20legs\x20(rows[]\x20with\x20track:\x22refund\x22)\x20are\x20additional\x20and\x20NOT\x20included\x20in\x20this\x20count.\x20rows[]\x20carries\x20the\x20complete\x20executable\x20split\x20plan.','onchain_field_notes':['passport.impack\x20—\x20the\x20on-chain\x20field\x20is\x20spelled\x20`impack`\x20(passport.move,\x20packed\x20business\x20objects\x20in\x20the\x20passport\x20verification\x20context).\x20It\x20is\x20the\x20contract\x27s\x20own\x20field\x20name,\x20not\x20a\x20typo;\x20echo\x20it\x20verbatim.']};}function requireTemplate(a,b){if(!a)throw new Error('\x27template_id\x27\x20is\x20required\x20for\x20action=\x27'+b+'\x27');const c=getTemplate(a);if(!c)throw new Error('Unknown\x20template\x20id:\x20'+a+'\x20(use\x20action=\x27template_list\x27\x20to\x20see\x20valid\x20ids)');return c;}function driftFace(a){const b=builtinTemplateDrift()['find'](c=>c['template']===a);if(!b){const c=BUILTIN_TEMPLATES['some'](d=>d['id']===a);return c?{'template':a,'state':'current','catalog_version':BUILTIN_TEMPLATES_VERSION,'blocked':![],'repairable':![],'detail':'disk\x20body\x20matches\x20the\x20shipped\x20catalog\x20(hash-verified\x20sentinel)'}:{'template':a,'state':'untracked','catalog_version':undefined,'blocked':![],'repairable':![],'detail':'user-authored\x20template\x20—\x20no\x20builtin\x20catalog\x20binding\x20to\x20compare\x20against'};}return{'template':b['template'],'state':b['state'],'catalog_version':BUILTIN_TEMPLATES_VERSION,'blocked':!![],'repairable':b['repairable'],'detail':b['detail']};}function scanSummary(a,b){const c={};for(const d of a['findings'])c[d['severity']]=(c[d['severity']]??0x0)+0x1;return{'template_id':a['template_id'],'risk_level':a['risk_level'],'preflight_scan_passed':a['red_flags']['length']===0x0,'finding_count':a['findings']['length'],'findings_by_severity':c,'red_flags':a['red_flags'],'findings':a['findings'],'drift':b};}function assertScanPassed(a,b){const c=a['red_flags'];if(a['passed']||c['length']===0x0)return;throw new Error('action=\x27'+b+'\x27\x20blocked:\x20pre-deploy\x20scan\x20of\x20template\x20\x27'+a['template_id']+'\x27\x20found\x20CRITICAL\x20risk\x20—\x20'+c['join'](';\x20')+'.\x20Fix\x20the\x20template\x20(frontmatter\x20or\x20body)\x20and\x20re-run\x20action=\x27template_scan\x27.');}const GENERATE_HIGH_TOLERATED=new Set([]);function assertGenerateScanPassed(a,b){assertScanPassed(a,b);if(b!=='template_generate')return;const c=generateHighBlockers(a['template_id'],a['findings']);if(c['length']===0x0)return;throw new Error('action=\x27'+b+'\x27\x20blocked:\x20pre-deploy\x20scan\x20of\x20template\x20\x27'+a['template_id']+'\x27\x20found\x20'+c['length']+'\x20HIGH\x20finding(s)\x20—\x20'+c['map'](d=>(d['rule_id']??'HIGH')+':\x20'+d['title'])['join'](';\x20')+'.\x20Fix\x20the\x20template\x20(frontmatter\x20or\x20body)\x20and\x20re-run\x20action=\x27template_scan\x27.');}function generateHighBlockers(a,b){return b['filter'](c=>c['severity']==='high'&&!(c['rule_id']&&GENERATE_HIGH_TOLERATED['has'](a+'/'+c['rule_id'])));}export function buildVerdict(a,b,c){const d=[];!a['preflight_scan_passed']&&d['push']('scan:\x20'+(a['findings_by_severity']['critical']??0x0)+'\x20CRITICAL\x20finding(s)\x20(preflight\x20scan\x20failed)');if(c){const h=generateHighBlockers(a['template_id'],a['findings']??[]);h['length']>0x0&&d['push']('scan:\x20'+h['length']+'\x20HIGH\x20finding(s)\x20—\x20template_generate\x20would\x20refuse\x20(N-21):\x20'+h['map'](i=>((i['rule_id']??'HIGH')+':\x20'+(i['title']??''))['trim']())['join'](';\x20'));}const e=b['graph_validation'];if(e&&e['valid']===![]){const i=Array['isArray'](e['hard_violations'])?e['hard_violations']['length']:0x0,j=Array['isArray'](e['hard_violations'])?e['hard_violations']['map'](k=>k['id'])['join'](',\x20'):'';d['push']('graph_validation:\x20'+i+'\x20hard\x20violation(s)'+(j?'\x20('+j+')':''));}const f=b['audit'];if(f&&f['blocking']===!![]){const k=(f['findings']??[])['filter'](l=>l['level']==='critical'||l['level']==='high');d['push'](k['length']===0x0?'audit:\x20guide\x20audit\x20flagged\x20blocking\x20issue(s)\x20(plan.audit)':'audit:\x20'+k['length']+'\x20blocking\x20finding(s)\x20—\x20'+k['slice'](0x0,0x5)['map'](l=>((l['rule_id']??'?')+':\x20'+(l['title']??''))['trim']())['join'](';\x20')+(k['length']>0x5?'\x20(+'+(k['length']-0x5)+'\x20more\x20in\x20plan.audit.findings)':''));}const g=d['length']===0x0;return{'buildable':g,'blockers':d,'status':g?'READY':'BLOCKED'};}async function templateScanDryRun(a){const b=[{'name':'scan-probe','price':'1000000000','quantity':0x1}],c=a['review_mode']==='review_reward'?{'review_mode':'review_reward','reward_funding':'20000000'}:undefined;try{const d=await runGuide(a,undefined,undefined,undefined,c,b),f=buildVerdict(scanSummary(scanTemplate(a)),d,!![]);return{'status':f['buildable']?'ready':'blocked','buildable':f['buildable'],'blockers':f['blockers'],'note':'Compile\x20dry-run\x20on\x20synthetic\x20probe\x20inputs\x20(single\x20probe\x20SKU,\x20benchmark\x20reward\x20funding),\x20mirrored\x20to\x20the\x20template_generate\x20gate\x20(CRITICAL\x20+\x20N-21\x20HIGH\x20+\x20graph\x20+\x20audit).\x20Structural\x20blockers\x20are\x20REAL\x20—\x20the\x20generate\x20face\x20refuses\x20for\x20the\x20same\x20reason.\x20Blockers\x20naming\x20caller\x20inputs\x20(fee_overrides\x20/\x20guard_resolutions\x20/\x20catalog)\x20may\x20clear\x20with\x20real\x20values.'};}catch(g){return{'status':'unavailable','note':'Compile\x20dry-run\x20could\x20not\x20run\x20on\x20synthetic\x20probe\x20inputs\x20('+(g instanceof Error?g['message']:String(g))+').\x20This\x20is\x20a\x20probe\x20limitation,\x20NOT\x20a\x20template\x20verdict\x20—\x20run\x20template_generate\x20for\x20the\x20authoritative\x20buildability.'};}}export function planNextAction(a,b,c){const d=a['next_action'];if(typeof d==='string'&&d['startsWith']('Plan\x20ready.'))return d;if(c?.['buildable']){const f=Array['isArray'](a['pending_guard_designs'])?a['pending_guard_designs']['length']:0x0;return'Plan\x20is\x20buildable\x20(verdict.buildable=true).\x20Materialize\x20the\x20objects\x20in\x20plan.steps\x20order'+(f>0x0?',\x20resolving\x20the\x20'+f+'\x20pending\x20guard\x20design(s)\x20in\x20plan.pending_guard_designs\x20via\x20guard_resolutions\x20before\x20the\x20Machine\x20publish':'')+'.';}const e=Array['isArray'](a['pending_guard_designs'])?a['pending_guard_designs']['length']:0x0;return'Plan\x20BLOCKED\x20by\x20the\x20guide\x20audit\x20(see\x20plan.audit\x20/\x20plan.next_action).\x20Do\x20NOT\x20materialize,\x20'+'and\x20do\x20NOT\x20hand-build\x20the\x20objects\x20instead:\x20this\x20plan\x20is\x20the\x20wiring\x20authority\x20(Arbitration\x20+\x20'+'compensation-fund,\x20Contact/um,\x20allocator\x20rows)\x20and\x20hand-built\x20replicas\x20silently\x20drop\x20those\x20wirings.\x20'+(e>0x0?'Resolve\x20the\x20'+e+'\x20pending\x20guard\x20design(s)\x20in\x20plan.pending_guard_designs\x20via\x20guard_resolutions\x20(kind\x20\x27inline\x27\x20with\x20the\x20Guard\x20table+root,\x20kind\x20\x27template\x27\x20with\x20a\x20tpl_*\x20id,\x20or\x20{kind:\x27omit\x27}\x20for\x20advisory\x20designs\x20that\x20do\x20not\x20apply\x20to\x20this\x20shop),\x20':'Adjust\x20fee_overrides,\x20pick\x20another\x20template\x20variant,\x20or\x20fix\x20the\x20template,\x20')+('then\x20re-run\x20action=\x27'+b+'\x27.');}function templateIntent(a,b){if(b&&b['trim']())return b['trim']();return'Adopt\x20the\x20'+a['id']+'\x20industry\x20archetype\x20template\x20('+a['archetype']+')\x20for\x20the\x20'+a['industry']+'\x20industry.\x20'+('Primary\x20risk\x20to\x20mitigate:\x20'+a['key_risk']+'.');}function effectiveFeeParams(a,b){return{...a['fee_params'],...b??{}};}const REWARD_POOL_PATTERNS=[/(?:reward|review|bonus|tip|prize)[\s-]*pools?\s*(?:of|is|at|:|=)?\s*([0-9][0-9_,]*(?:\.[0-9]+)?)/i,/([0-9][0-9_,]*(?:\.[0-9]+)?)\s*(?:reward|review|bonus|tip|prize)[\s-]*pools?\b/i,/(?:奖(?:金|励)?池|打赏池|好评(?:奖励)?池)\s*(?:为|是|:|:|=)?\s*([0-9][0-9_,]*(?:\.[0-9]+)?)/,/([0-9][0-9_,]*(?:\.[0-9]+)?)\s*的?\s*(?:奖(?:金|励)?池|打赏池|好评(?:奖励)?池)/];export function extractRewardPoolCandidate(a){if(!a)return undefined;for(const b of REWARD_POOL_PATTERNS){const c=b['exec'](a);if(!c)continue;const d=Number(c[0x1]['replaceAll'](/[,_]/g,''));if(Number['isFinite'](d)&&d>=0x0)return d;}return undefined;}function rewardPoolPrefill(a,b,c){if(a['fee_params']['review_reward_pool']===undefined)return undefined;if(c?.['review_reward_pool']!==undefined)return undefined;const d=extractRewardPoolCandidate(b);return d===undefined?undefined:{'fee_key':'review_reward_pool','value':d};}function validateFeeParams(a,b){const c=[];let d=0x0;for(const [e,f]of Object['entries'](a)){if(typeof f!=='number'||!Number['isFinite'](f))continue;if(e['endsWith']('_bps')){(!Number['isInteger'](f)||f<0x0||f>0x2710)&&c['push'](e+'='+f+'\x20is\x20not\x20an\x20integer\x20rate\x20in\x20[0,\x2010000]\x20bps');if(e['endsWith']('_share_bps'))d+=Math['max'](0x0,f);}else{if(e['endsWith']('_days')){if(f<=0x0||f>0xe42)c['push'](e+'='+f+'\x20is\x20outside\x20the\x20sane\x20window\x20range\x20(0,\x203650]\x20days');}else{if(e['endsWith']('_hours')){if(f<=0x0||f>0x2238)c['push'](e+'='+f+'\x20is\x20outside\x20the\x20sane\x20window\x20range\x20(0,\x208760]\x20hours');}}}}if(d>0x2710)c['push']('*_share_bps\x20sum\x20'+d+'\x20exceeds\x2010000\x20(a\x20pool\x20splits\x20into\x20at\x20most\x20100%)');if(c['length']>0x0)throw new Error('invalid\x20fee\x20parameters\x20for\x20template\x20\x27'+b+'\x27:\x20'+c['join'](';\x20')+'.\x20'+'Correct\x20the\x20template\x27s\x20fee_params\x20or\x20pass\x20valid\x20\x27fee_overrides\x27.');}export{validateAllocatorRows};export function variantPaymentModel(a){if(a['payment_model'])return a['payment_model'];const b=a['allocator']['rows']??[];if(b['some'](d=>d['track']==='refund'))return'escrow';const c=a['machine_shape']['map'](d=>d['name'])['join']('\x20')['toLowerCase']();if(/\b(milestone|revision|revis|draft|deliverable)\b/['test'](c))return'milestone';if(/\b(charge|renew|subscription|cycle|billing|monthly)\b/['test'](c))return'subscription';return'escrow';}function variantRefundPolicy(a){const b=a['allocator']['description']['toLowerCase']();if(/full[ -]?refund|100% refund|refund .*100/['test'](b))return'full';if(/pro-?rata|prorated/['test'](b))return'milestone_prorated';if(/partial/['test'](b))return'partial';return undefined;}export function variantDeliverables(a,b){const c=a['machine_shape']['filter'](g=>g['semantic_role']==='final'),d=c[c['length']-0x1]??[...a['machine_shape']]['reverse']()['find'](g=>!/refund|cancel|dispute|terminat/i['test'](g['name']+'\x20'+g['role']))??a['machine_shape'][a['machine_shape']['length']-0x1],e=b?.['has_logistics']?'physical':b?.['pure_digital']?'digital':'service_session',f=(a['guards']??[])['filter'](h=>/repository_data_check|required_info_evidence_gate|allocator_order_anchor/['test'](h['template_id']));return[{'name':a['variant']+'\x20fulfillment','type':e,'acceptanceCriteria':'Order\x20reaches\x20the\x20terminal\x20workflow\x20node\x20\x27'+d['name']+'\x27\x20('+d['role']+')','proofOfDelivery':f['length']>0x0?'wip_hash':'manual_confirm'}];}function validateConditionalParams(a,b){for(const d of a['conditional_guards']??[]){const e=b[d['param']];if(e===undefined)continue;if(typeof e!=='string'||!d['values']['includes'](e))throw new Error('invalid\x20\x27'+d['param']+'='+String(e)+'\x27\x20for\x20template\x20\x27'+a['id']+'\x27:\x20must\x20be\x20one\x20of\x20'+d['values']['map'](f=>'\x27'+f+'\x27')['join']('\x20|\x20')+('\x20(the\x20guard\x20variant\x20mounts\x20at\x20\x27'+d['emit_value']+'\x27)'));}}async function runGuide(a,b,c,d,e,f){const g=effectiveFeeParams(a,c),h=rewardPoolPrefill(a,b,c);if(h)g[h['fee_key']]=h['value'];validateFeeParams(g,a['id']),validateConditionalParams(a,g);const i=getIndustryModeRegistry()['getMode'](a['industry']),j=platformShareBps(g),k={'model':variantPaymentModel(a)},l=[],m=(a['allocator']['rows']?.['length']??0x0)>0x0;if(j!==undefined&&j>0x0&&!m&&a['allocator']['mode']==='rate'){const q=Math['round'](j)/0x64;l['push']({'recipient':'merchant','percentage':Math['round']((0x64-q)*0x64)/0x64}),l['push']({'recipient':'platform','percentage':q}),k['allocation']=l;}const n=variantRefundPolicy(a),o={'escrow':!![]};if(n)o['refundPolicy']=n;o['arbitration']=a['arbitration_mode']??o['arbitration']??inferArbitration(templateIntent(a,b));const p=await handleMerchantGuide({'intent':templateIntent(a,b),'guide_confirm':{'industry':a['industry'],'payment':k,'trust':o,'deliverables':variantDeliverables(a,i?.['traits']),...d&&Object['keys'](d)['length']>0x0?{'guard_resolutions':d}:{},...e?.['review_mode']?{'review_mode':e['review_mode']}:{},...e?.['reward_funding']!==undefined?{'reward_funding':e['reward_funding']}:{},...e?.['after_sales_mode']?{'after_sales_mode':e['after_sales_mode']}:{},...e?.['acceptance_mode']?{'acceptance_mode':e['acceptance_mode']}:{},...e?.['installment_mode']?{'installment_mode':e['installment_mode']}:{},...e?.['affiliate_mode']?{'affiliate_mode':e['affiliate_mode']}:{},...e?.['crowdfunding_mode']?{'crowdfunding_mode':e['crowdfunding_mode']}:{},...f?.['length']?{'sales':f}:{}},'template_override':{...a,'fee_params':g},'name_base':a['id']});if(a['allocator']['rows']?.['length'])p['template_allocator_rows']=a['allocator']['rows']['map'](s=>({...s}));p['template']={'id':a['id'],'archetype':a['archetype'],'recommended_role':a['recommended_role'],'fee_params':g},p['template_fee_param_landings']=buildFeeParamLandingTable(a,g);if(c&&Object['keys'](c)['length']>0x0)p['template_fee_overrides']=c;return h&&(p['fee_overrides_prefill']=h,p['next_action']=p['next_action']+'\x20Reward\x20pool\x20prefilled\x20from\x20your\x20request:\x20'+h['value']+'\x20—\x20adjust\x20via\x20fee_overrides.'),p;}export async function handleBenchmarkMigrationOperation(a){const b=strictParse(BenchmarkMigrationSchema,a,'benchmark_migration_operation\x20input'),c=b['industry']?resolveIndustryName(b['industry'])??b['industry']['toLowerCase']():undefined;let d;switch(b['action']){case'template_list':{const {templates:e,errors:f}=listTemplates(),g=c?e['filter'](i=>i['industry']===c):e,h=new Map(builtinTemplateDrift()['map'](i=>[i['template'],i['state']]));d={'action':'template_list','count':g['length'],'templates':g['map'](i=>({...templateSummary(i),'disk_state':h['get'](i['id'])??(BUILTIN_TEMPLATES['some'](j=>j['id']===i['id'])?'current':'untracked')})),'load_errors':f};break;}case'template_get':{const i=requireTemplate(b['template_id'],'template_get');d={'action':'template_get','template':{...i,...templateGetAids(i)}};break;}case'template_generate':{const j=requireTemplate(b['template_id'],'template_generate'),k=b['review_mode']??j['review_mode']??'none';if(k==='review_reward'&&!b['reward_funding'])return{'content':[{'type':'text','text':'template_generate\x20refused\x20—\x20no\x20plan\x20was\x20built.\x20Template\x20\x27'+j['id']+'\x27\x20resolves\x20to\x20review_mode\x20\x27review_reward\x27\x20(input'+(b['review_mode']?'':'\x20via\x20template\x20declaration')+'),\x20which\x20promises\x20buyers\x20a\x20claimable\x20review\x20bounty\x20—\x20an\x20unfunded\x20pool\x20must\x20not\x20ship.\x20Pass\x20reward_funding\x20(smallest-unit\x20string),\x20or\x20drop\x20the\x20mode\x20explicitly\x20(review_mode\x20\x27review\x27\x20keeps\x20the\x20review\x20rail\x20without\x20the\x20bounty;\x20\x27none\x27\x20removes\x20the\x20rail).'}],'structuredContent':{'result':{'type':'error','error':'review_mode\x20\x27'+k+'\x27\x20without\x20reward_funding\x20(INV-4)\x20on\x20template\x20\x27'+j['id']+'\x27.','error_code':'reward_funding_required','retryable':!![],'recovery_hint':'Pass\x20reward_funding\x20=\x20expected\x20orders\x20x\x20per-order\x20reward\x20(fee_param\x20review_reward_pool\x20is\x20the\x20planning\x20benchmark),\x20or\x20re-send\x20with\x20review_mode:\x27review\x27\x20(rail\x20only)\x20/\x20\x27none\x27\x20(no\x20rail).'},'message':'Refused:\x20a\x20review_reward\x20build\x20requires\x20a\x20funded\x20reward\x20pool.\x20See\x20recovery_hint.'}};if(!Array['isArray'](b['sales'])||b['sales']['length']===0x0)return{'content':[{'type':'text','text':'template_generate\x20refused\x20—\x20no\x20plan\x20was\x20built.\x20The\x20sellable\x20catalog\x20(sales)\x20is\x20required:\x20a\x20plan\x20without\x20one\x20publishes\x20a\x20Service\x20frozen\x20with\x20sales:\x20[]\x20and\x20every\x20order_new\x20aborts\x20(PLAN-SALES-01).\x20List\x20at\x20least\x20one\x20SKU:\x20{\x20name,\x20price,\x20quantity?,\x20wip_hash?\x20}\x20—\x20price\x20in\x20smallest\x20units.'}],'structuredContent':{'result':{'type':'error','error':'template_generate\x20without\x20a\x20non-empty\x20sales\x20catalog\x20(PLAN-SALES-01\x20upgraded\x20to\x20an\x20input\x20requirement,\x20amz9\x20A-2).','error_code':'sales_required','retryable':!![],'recovery_hint':'Pass\x20sales:\x20[{\x20name,\x20price,\x20quantity?,\x20wip_hash?\x20}]\x20—\x20one\x20entry\x20per\x20sellable\x20SKU\x20(wip_hash\x20from\x20the\x20wip_file\x20tool\x20upload).\x20migration_apply\x20is\x20unaffected:\x20it\x20confirms\x20an\x20already-reviewed\x20import.'},'message':'Refused:\x20template_generate\x20requires\x20a\x20sellable\x20catalog.\x20See\x20recovery_hint.'}};const l=scanTemplate(j);assertGenerateScanPassed(l,'template_generate');const m=await runGuide(j,b['description'],b['fee_overrides'],b['guard_resolutions'],{'review_mode':b['review_mode'],'reward_funding':b['reward_funding'],'after_sales_mode':b['after_sales_mode'],'acceptance_mode':b['acceptance_mode'],'installment_mode':b['installment_mode'],'affiliate_mode':b['affiliate_mode'],'crowdfunding_mode':b['crowdfunding_mode']},b['sales']);d=((()=>{const n=scanSummary(l,driftFace(j['id'])),o=buildVerdict(n,m);return{'action':'template_generate','template_id':j['id'],'scan':n,'plan':m,'verdict':o,'next_action':planNextAction(m,'template_generate',o)};})());break;}case'template_scan':{const n=requireTemplate(b['template_id'],'template_scan'),o=await templateScanDryRun(n);d={'action':'template_scan','scan':{...scanTemplate(n),'drift':driftFace(n['id']),'compile_dry_run':o}};break;}case'migration_import':{if(!b['description']||!b['description']['trim']())throw new Error('\x27description\x27\x20is\x20required\x20for\x20action=\x27migration_import\x27');const p=planMigration({'url':b['url'],'description':b['description'],'industry':c,'network':b['network']});if(!p)throw new Error('No\x20industry\x20template\x20matched\x20the\x20description.\x20Refine\x20the\x20description\x20or\x20pass\x20an\x20explicit\x20\x27industry\x27\x20hint.');d={'action':'migration_import','log':p,'next_action':'MigrationLog\x20ready.\x20Next:\x20call\x20action=\x27migration_review\x27\x20with\x20this\x20log\x20to\x20surface\x20the\x20mapped/unmapped/manual_review\x20items\x20for\x20user\x20confirmation.'};break;}case'migration_review':{if(!b['log'])throw new Error('\x27log\x27\x20is\x20required\x20for\x20action=\x27migration_review\x27');const q=b['log'],r=Array['isArray'](q['mapped'])?q['mapped']:[],s=Array['isArray'](q['unmapped'])?q['unmapped']:[],t=Array['isArray'](q['manual_review'])?q['manual_review']:[],u=q['risk_check']??{},v=q['source']?.['matched_template']??'',w=s['length']===0x0&&t['length']===0x0&&u['passed']===!![];d={'action':'migration_review','log':q,'review_summary':{'mapped_count':r['length'],'unmapped_count':s['length'],'manual_review_count':t['length'],'risk_passed':u['passed']===!![]},'next_action':w?'Review\x20clean.\x20Proceed:\x20call\x20action=\x27migration_apply\x27\x20with\x20template_id=\x27'+v+'\x27\x20to\x20produce\x20the\x20creation\x20plan\x20(network\x20defaults\x20to\x20testnet;\x20mainnet\x20requires\x20explicit\x20user\x20confirmation).':'Surface\x20the\x20'+s['length']+'\x20unmapped\x20and\x20'+t['length']+'\x20manual_review\x20items'+(u['passed']===!![]?'':'\x20plus\x20the\x20risk_check\x20findings')+'\x20to\x20the\x20user\x20for\x20a\x20decision\x20before\x20action=\x27migration_apply\x27\x20(template_id=\x27'+v+'\x27).'};break;}case'migration_apply':{const x=requireTemplate(b['template_id'],'migration_apply'),y=scanTemplate(x);assertScanPassed(y,'migration_apply');const z=b['network']??'testnet',A=await runGuide(x,b['description'],b['fee_overrides'],b['guard_resolutions'],{'review_mode':b['review_mode'],'reward_funding':b['reward_funding'],'after_sales_mode':b['after_sales_mode'],'acceptance_mode':b['acceptance_mode'],'installment_mode':b['installment_mode'],'affiliate_mode':b['affiliate_mode'],'crowdfunding_mode':b['crowdfunding_mode']},b['sales']);d=((()=>{const B=scanSummary(y,driftFace(x['id'])),C=buildVerdict(B,A);return{'action':'migration_apply','template_id':x['id'],'network':z,'scan':B,'plan':A,'verdict':C,'next_action':planNextAction(A,'migration_apply',C)};})());break;}default:throw new Error('Unknown\x20benchmark_migration_operation\x20action:\x20'+String(b['action']));}return{'content':[{'type':'text','text':JSON['stringify']({'result':d})}],'structuredContent':{'result':d}};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{listServices,getServiceInfo,toggle as
|
|
1
|
+
import{listServices,getServiceInfo,toggle as a496a,setEnabled as a496b,reset as a496c}from'../../config/index.js';import{judgmentStatus,setJudgmentOverride,clearJudgmentOverride,clearJudgmentOverrides,patchUserJudgmentDoc,readUserJudgmentDocView}from'../../config/judgment.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,path:e,value:f}=b;let g;switch(c){case'list':g={'action':'list','services':listServices()};break;case'toggle':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20toggle');const h=d,i=getServiceInfo(h);if(!i)throw new Error('Unknown\x20service:\x20'+h+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');if(h==='confirm_gate'&&i['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 j=a496a(h);g={'action':'toggle','service':h,'enabled':j,'reminder':i['reminder']};break;}case'disable':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20disable');const k=d,l=getServiceInfo(k);if(!l)throw new Error('Unknown\x20service:\x20'+k+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');if(k==='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.');a496b(k,![]),g={'action':'disable','service':k,'enabled':![],'reminder':l['reminder']};break;}case'enable':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20enable');const m=d,n=getServiceInfo(m);if(!n)throw new Error('Unknown\x20service:\x20'+m+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');a496b(m,!![]),g={'action':'enable','service':m,'enabled':!![],'reminder':n['reminder']};break;}case'reset':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20reset');const o=d,p=getServiceInfo(o);if(!p)throw new Error('Unknown\x20service:\x20'+o+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');a496c(o),g={'action':'reset','service':o,'enabled':getServiceInfo(o)?.['enabled'],'reminder':p['reminder'],'reset':!![]};break;}case'info':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20info');const q=d,r=getServiceInfo(q);if(!r)throw new Error('Unknown\x20service:\x20'+q+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');g={'action':'info',...r};break;}case'judgment_list':g={'action':'judgment_list',...judgmentStatus()};break;case'judgment_set':{if(!e)throw new Error('\x27path\x27\x20param\x20is\x20required\x20for\x20judgment_set\x20(dotted,\x20e.g.\x20\x27evaluation.weights.trust_reviews\x27)');if(!('value'in b))throw new Error('\x27value\x27\x20param\x20is\x20required\x20for\x20judgment_set');const s=setJudgmentOverride(e,f);if(!s['ok'])throw new Error(s['error']);g={'action':'judgment_set','path':e,'value':f,'applied':!![]};break;}case'judgment_reset':{const t=e?clearJudgmentOverride(e)?0x1:0x0:clearJudgmentOverrides();g={'action':'judgment_reset',...e?{'path':e}:{},'cleared':t};break;}case'judgment_doc_read':{g={'action':'judgment_doc_read',...readUserJudgmentDocView()};break;}case'judgment_doc_patch':{if(!b['patch']||typeof b['patch']!=='object'||Array['isArray'](b['patch']))throw new Error('\x27patch\x27\x20param\x20is\x20required\x20for\x20judgment_doc_patch\x20(a\x20partial\x20judgment\x20document\x20object,\x20e.g.\x20{\x22evaluation\x22:\x20{\x22weights\x22:\x20{…}}})');g={'action':'judgment_doc_patch',...patchUserJudgmentDoc(b['patch'])};break;}default:throw new Error('Unknown\x20config_operation\x20action:\x20'+String(c));}return{'content':[{'type':'text','text':JSON['stringify']({'result':g})}],'structuredContent':{'result':g}};}
|