@wowok/agent-mcp 3.2.9 → 3.3.0

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.
Files changed (200) hide show
  1. package/README.md +2 -2
  2. package/dist/chain-semantics/field-capability.js +1 -1
  3. package/dist/chain-semantics/freeze-map.js +1 -1
  4. package/dist/chain-semantics/fund-flow.js +1 -1
  5. package/dist/chain-semantics/object-graph.js +1 -1
  6. package/dist/composition/audit.js +1 -1
  7. package/dist/composition/compile.d.ts +10 -1
  8. package/dist/composition/compile.js +1 -1
  9. package/dist/composition/inflight.js +1 -1
  10. package/dist/extensions/capability-manifest.js +1 -1
  11. package/dist/extensions/industry-audit.spec.js +1 -1
  12. package/dist/extensions/industry-pack.js +1 -1
  13. package/dist/graph/onchain/facts.spec.js +1 -1
  14. package/dist/graph/onchain/field-manifest.js +1 -1
  15. package/dist/harness/recover.js +1 -1
  16. package/dist/intent/types.d.ts +1 -1
  17. package/dist/intent/types.js +1 -1
  18. package/dist/keeper/KeeperScan.d.ts +2 -1
  19. package/dist/keeper/KeeperScan.js +1 -1
  20. package/dist/keeper/keeper.spec.js +1 -1
  21. package/dist/keeper/types.d.ts +3 -0
  22. package/dist/keeper/types.js +1 -1
  23. package/dist/knowledge/allocator-rail-verifier.d.ts +34 -0
  24. package/dist/knowledge/allocator-rail-verifier.js +1 -0
  25. package/dist/knowledge/arbitration-ledger.js +1 -1
  26. package/dist/knowledge/arbitration-templates.js +1 -1
  27. package/dist/knowledge/arbitration-venue-order.js +1 -1
  28. package/dist/knowledge/audit-rules.d.ts +19 -1
  29. package/dist/knowledge/audit-rules.js +1 -1
  30. package/dist/knowledge/baselines/rules/alloc_audit.json +1 -1
  31. package/dist/knowledge/baselines/rules/arb.json +1 -1
  32. package/dist/knowledge/baselines/rules/guard.json +15 -5
  33. package/dist/knowledge/baselines/rules/machine.json +9 -6
  34. package/dist/knowledge/baselines/rules/plan.json +12 -12
  35. package/dist/knowledge/baselines/semantic-facts.js +1 -1
  36. package/dist/knowledge/builtin-templates.d.ts +1 -1
  37. package/dist/knowledge/builtin-templates.js +1 -1
  38. package/dist/knowledge/contract-invariants.js +1 -1
  39. package/dist/knowledge/event-semantics.js +1 -1
  40. package/dist/knowledge/fund-layer.js +1 -1
  41. package/dist/knowledge/getting-started.js +1 -1
  42. package/dist/knowledge/guard-anchor-reach.d.ts +1 -1
  43. package/dist/knowledge/guard-anchor-reach.js +1 -1
  44. package/dist/knowledge/guard-bindings.js +1 -1
  45. package/dist/knowledge/guard-design-patterns.d.ts +1 -1
  46. package/dist/knowledge/guard-design-patterns.js +1 -1
  47. package/dist/knowledge/guard-field-cognition.js +1 -1
  48. package/dist/knowledge/guard-render.js +1 -1
  49. package/dist/knowledge/guard-risk.js +1 -1
  50. package/dist/knowledge/guard-templates.d.ts +1 -1
  51. package/dist/knowledge/guard-templates.js +1 -1
  52. package/dist/knowledge/index.js +1 -1
  53. package/dist/knowledge/industry-registry.js +1 -1
  54. package/dist/knowledge/industry-strategy.js +1 -1
  55. package/dist/knowledge/jsonrpc-enum.js +1 -1
  56. package/dist/knowledge/machine-ledger.js +1 -1
  57. package/dist/knowledge/machine-puzzle.d.ts +1 -1
  58. package/dist/knowledge/machine-puzzle.js +1 -1
  59. package/dist/knowledge/machine-risk.js +1 -1
  60. package/dist/knowledge/machine-templates.js +1 -1
  61. package/dist/knowledge/machine-topology.d.ts +8 -0
  62. package/dist/knowledge/machine-topology.js +1 -1
  63. package/dist/knowledge/machine-translation.js +1 -1
  64. package/dist/knowledge/permission-ledger.js +1 -1
  65. package/dist/knowledge/protocol-facts.d.ts +16 -0
  66. package/dist/knowledge/protocol-facts.js +1 -0
  67. package/dist/knowledge/recipient-constraint.js +1 -1
  68. package/dist/knowledge/reward-ledger.d.ts +2 -1
  69. package/dist/knowledge/reward-ledger.js +1 -1
  70. package/dist/knowledge/reward-templates.js +1 -1
  71. package/dist/knowledge/safety-rules.d.ts +0 -2
  72. package/dist/knowledge/safety-rules.js +1 -1
  73. package/dist/knowledge/scenario-modes.d.ts +7 -0
  74. package/dist/knowledge/scenario-modes.js +1 -1
  75. package/dist/knowledge/strategy-manuals.js +1 -1
  76. package/dist/knowledge/template-loader.d.ts +13 -1
  77. package/dist/knowledge/template-loader.js +1 -1
  78. package/dist/knowledge/template-registry.js +1 -1
  79. package/dist/knowledge/template-scanner.js +1 -1
  80. package/dist/knowledge/tool-constraints.js +1 -1
  81. package/dist/knowledge/tools-reference.js +1 -1
  82. package/dist/monitor/MonitorLoop.js +1 -1
  83. package/dist/monitor/normalize.d.ts +1 -1
  84. package/dist/monitor/normalize.js +1 -1
  85. package/dist/monitor/types.d.ts +1 -1
  86. package/dist/monitor/types.js +1 -1
  87. package/dist/playbooks/service-build/business-puzzle.js +1 -1
  88. package/dist/playbooks/service-build/game-theory.d.ts +1 -0
  89. package/dist/playbooks/service-build/game-theory.js +1 -1
  90. package/dist/playbooks/service-build/intent-analyzer.js +1 -1
  91. package/dist/playbooks/service-build/machine-panorama.js +1 -1
  92. package/dist/playbooks/service-build/merchant-guide.js +1 -1
  93. package/dist/playbooks/service-build/object-panorama.js +1 -1
  94. package/dist/playbooks/service-build/participation-radar.js +1 -1
  95. package/dist/playbooks/service-build/relationship-profile.js +1 -1
  96. package/dist/playbooks/service-build/service-panorama.js +1 -1
  97. package/dist/playbooks/service-build/service-quote.js +1 -1
  98. package/dist/playbooks/service-build/service-quote.spec.js +1 -1
  99. package/dist/relationship/registry.js +1 -1
  100. package/dist/review/index.js +1 -1
  101. package/dist/role/profiles.js +1 -1
  102. package/dist/safety/confirm-gate.js +1 -1
  103. package/dist/schema/benchmark-migration/index.d.ts +5 -1
  104. package/dist/schema/benchmark-migration/index.js +1 -1
  105. package/dist/schema/call/arbitration.d.ts +4 -4
  106. package/dist/schema/call/arbitration.js +1 -1
  107. package/dist/schema/call/base.d.ts +39 -0
  108. package/dist/schema/call/base.js +1 -1
  109. package/dist/schema/call/bridge.d.ts +1 -0
  110. package/dist/schema/call/contact.d.ts +4 -4
  111. package/dist/schema/call/demand.d.ts +4 -4
  112. package/dist/schema/call/error-codes.d.ts +1 -1
  113. package/dist/schema/call/error-codes.js +1 -1
  114. package/dist/schema/call/handler.js +1 -1
  115. package/dist/schema/call/machine.d.ts +12 -4
  116. package/dist/schema/call/order.d.ts +4 -4
  117. package/dist/schema/call/permission.d.ts +4 -4
  118. package/dist/schema/call/progress.d.ts +4 -4
  119. package/dist/schema/call/receipt.d.ts +8 -0
  120. package/dist/schema/call/receipt.js +1 -1
  121. package/dist/schema/call/repository.d.ts +4 -4
  122. package/dist/schema/call/reward.d.ts +24 -4
  123. package/dist/schema/call/reward.js +1 -1
  124. package/dist/schema/call/semantic.js +1 -1
  125. package/dist/schema/call/service.d.ts +6 -4
  126. package/dist/schema/call/service.js +1 -1
  127. package/dist/schema/call/treasury.d.ts +4 -4
  128. package/dist/schema/common/index.d.ts +2 -2
  129. package/dist/schema/common/index.js +1 -1
  130. package/dist/schema/goal/index.d.ts +5 -1
  131. package/dist/schema/goal/planning.d.ts +10 -2
  132. package/dist/schema/goal/planning.js +1 -1
  133. package/dist/schema/industry-pack/index.d.ts +3 -0
  134. package/dist/schema/industry-pack/index.js +1 -1
  135. package/dist/schema/intent-radar/index.d.ts +9 -0
  136. package/dist/schema/intent-radar/index.js +1 -1
  137. package/dist/schema/local/index.d.ts +10 -0
  138. package/dist/schema/local/index.js +1 -1
  139. package/dist/schema/operations.d.ts +35 -22
  140. package/dist/schema/operations.js +1 -1
  141. package/dist/schema/query/bi.d.ts +16 -0
  142. package/dist/schema/query/bi.js +1 -1
  143. package/dist/schema/query/index.d.ts +52 -48
  144. package/dist/schema/query/index.js +1 -1
  145. package/dist/schema/schema-query/index.d.ts +1 -0
  146. package/dist/schema/schema-query/index.js +1 -1
  147. package/dist/schema/schema-version.js +1 -1
  148. package/dist/schema-query-impl/index.d.ts +1 -1
  149. package/dist/schema-query-impl/index.js +1 -1
  150. package/dist/schemas/account_operation.output.json +1 -0
  151. package/dist/schemas/account_operation.schema.json +1 -1
  152. package/dist/schemas/benchmark_migration_operation.schema.json +27 -3
  153. package/dist/schemas/bridge_operation.output.json +1 -0
  154. package/dist/schemas/goal_operation.schema.json +26 -2
  155. package/dist/schemas/index.json +1 -1
  156. package/dist/schemas/industry_pack_operation.output.json +8 -0
  157. package/dist/schemas/industry_pack_operation.schema.json +9 -0
  158. package/dist/schemas/intent_radar.output.json +8 -2
  159. package/dist/schemas/intent_radar.schema.json +4 -1
  160. package/dist/schemas/local_cache_operation.output.json +1 -0
  161. package/dist/schemas/local_history_operation.output.json +1 -0
  162. package/dist/schemas/local_info_operation.output.json +1 -0
  163. package/dist/schemas/local_mark_operation.output.json +1 -0
  164. package/dist/schemas/monitor_events.schema.json +3 -1
  165. package/dist/schemas/onchain_events.output.json +275 -11
  166. package/dist/schemas/onchain_events.schema.json +25 -1
  167. package/dist/schemas/onchain_operations.output.json +40 -0
  168. package/dist/schemas/onchain_operations.schema.json +573 -104
  169. package/dist/schemas/onchain_operations_allocation.schema.json +2 -2
  170. package/dist/schemas/onchain_operations_arbitration.schema.json +11 -7
  171. package/dist/schemas/onchain_operations_contact.schema.json +9 -5
  172. package/dist/schemas/onchain_operations_demand.schema.json +9 -5
  173. package/dist/schemas/onchain_operations_guard.schema.json +342 -4
  174. package/dist/schemas/onchain_operations_machine.schema.json +17 -5
  175. package/dist/schemas/onchain_operations_order.schema.json +9 -5
  176. package/dist/schemas/onchain_operations_permission.schema.json +9 -5
  177. package/dist/schemas/onchain_operations_progress.schema.json +9 -5
  178. package/dist/schemas/onchain_operations_repository.schema.json +9 -5
  179. package/dist/schemas/onchain_operations_reward.schema.json +89 -9
  180. package/dist/schemas/onchain_operations_service.schema.json +18 -11
  181. package/dist/schemas/onchain_operations_treasury.schema.json +9 -5
  182. package/dist/schemas/query_toolkit.output.json +237 -14
  183. package/dist/schemas/schema_query.schema.json +3 -2
  184. package/dist/tools/handlers/benchmark-migration.d.ts +45 -1
  185. package/dist/tools/handlers/benchmark-migration.js +1 -1
  186. package/dist/tools/handlers/config.js +1 -1
  187. package/dist/tools/handlers/industry-pack.js +1 -1
  188. package/dist/tools/handlers/intent-radar.js +1 -1
  189. package/dist/tools/handlers/keeper.d.ts +1 -1
  190. package/dist/tools/handlers/onchain.d.ts +12 -0
  191. package/dist/tools/handlers/onchain.js +1 -1
  192. package/dist/tools/handlers/schema-query.js +1 -1
  193. package/dist/tools/handlers/workflow.js +1 -1
  194. package/dist/tools/index.js +1 -1
  195. package/dist/tools/registry/agent.js +1 -1
  196. package/dist/tools/registry/business.js +1 -1
  197. package/dist/tools/registry/query.js +1 -1
  198. package/dist/tools/rules-hook.js +1 -1
  199. package/dist/tools/wrap.js +1 -1
  200. package/package.json +2 -2
@@ -2546,7 +2546,7 @@
2546
2546
  "GuardIdentifier"
2547
2547
  ],
2548
2548
  "additionalProperties": false,
2549
- "description": "Guard verified recipient ID. Get recipient ID from specified data index in Guard table. The ID must be of address type."
2549
+ "description": "Guard verified recipient ID. Get recipient ID from specified data index in Guard table. The ID must be of address type. ALLOCATION rails only — the REWARD claim rail requires recipient == the transaction sender (abort 14), so a GuardIdentifier recipient on reward.guard_add resolves to the submitted Order and is structurally unpayable; the tool gate rejects it (crs-mn-261015 F-12)."
2550
2550
  },
2551
2551
  {
2552
2552
  "type": "object",
@@ -2585,7 +2585,7 @@
2585
2585
  "Signer"
2586
2586
  ],
2587
2587
  "additionalProperties": false,
2588
- "description": "Current transaction signer (tx_context::sender) at the time of the alloc() call. For refunds, the Order owner must call alloc_by_guard themselves to receive the funds."
2588
+ "description": "Current transaction signer (tx_context::sender) at the time of the alloc() call. For refunds, the Order owner must call alloc_by_guard themselves to receive the funds. On the REWARD claim rail this is the CANONICAL recipient (the claim entry requires recipient == the tx sender)."
2589
2589
  }
2590
2590
  ],
2591
2591
  "description": "Recipient of this allocation. Three forms — each resolves the address at a DIFFERENT time:\n• { GuardIdentifier: u8 } — DYNAMIC address resolved from Passport at alloc() time (from the passport's submission record). Use 0 for Order owner in Service-integrated mode (Customer who created the Order). The identifier must match a Guard table entry with b_submission=true. If Passport has no matching submission, contract aborts with E_VERIFY_FAILED. Use when the recipient address is not known at config time and must be supplied via Guard submission data.\n• { Entity: { name_or_address: '...' } } — FIXED address resolved via LocalMark at SDK build time (passed to contract as a literal address). Use for known recipients (e.g., 'turo_host', or a Treasury object address). Use when the recipient is a stable, known address (e.g., operator receives rent, platform fee to treasury).\n• 'Signer' — the transaction sender at the time of the alloc() call (tx_context::sender). RESOLVED AT EXECUTION TIME, not at config time. For refunds: the customer (Order owner) must call alloc_by_guard THEMSELVES so that tx_context::sender resolves to THEIR address — if the operator calls alloc_by_guard, the operator becomes the recipient (Signer = operator), NOT the customer. Use when the recipient is whoever submits the allocation transaction (e.g., customer receives refund)."
@@ -4821,7 +4821,7 @@
4821
4821
  "GuardIdentifier"
4822
4822
  ],
4823
4823
  "additionalProperties": false,
4824
- "description": "Guard verified recipient ID. Get recipient ID from specified data index in Guard table. The ID must be of address type."
4824
+ "description": "Guard verified recipient ID. Get recipient ID from specified data index in Guard table. The ID must be of address type. ALLOCATION rails only — the REWARD claim rail requires recipient == the transaction sender (abort 14), so a GuardIdentifier recipient on reward.guard_add resolves to the submitted Order and is structurally unpayable; the tool gate rejects it (crs-mn-261015 F-12)."
4825
4825
  },
4826
4826
  {
4827
4827
  "type": "object",
@@ -4860,7 +4860,7 @@
4860
4860
  "Signer"
4861
4861
  ],
4862
4862
  "additionalProperties": false,
4863
- "description": "Current transaction signer (tx_context::sender) at the time of the alloc() call. For refunds, the Order owner must call alloc_by_guard themselves to receive the funds."
4863
+ "description": "Current transaction signer (tx_context::sender) at the time of the alloc() call. For refunds, the Order owner must call alloc_by_guard themselves to receive the funds. On the REWARD claim rail this is the CANONICAL recipient (the claim entry requires recipient == the tx sender)."
4864
4864
  }
4865
4865
  ],
4866
4866
  "description": "Recipient of this allocation. Three forms — each resolves the address at a DIFFERENT time:\n• { GuardIdentifier: u8 } — DYNAMIC address resolved from Passport at alloc() time (from the passport's submission record). Use 0 for Order owner in Service-integrated mode (Customer who created the Order). The identifier must match a Guard table entry with b_submission=true. If Passport has no matching submission, contract aborts with E_VERIFY_FAILED. Use when the recipient address is not known at config time and must be supplied via Guard submission data.\n• { Entity: { name_or_address: '...' } } — FIXED address resolved via LocalMark at SDK build time (passed to contract as a literal address). Use for known recipients (e.g., 'turo_host', or a Treasury object address). Use when the recipient is a stable, known address (e.g., operator receives rent, platform fee to treasury).\n• 'Signer' — the transaction sender at the time of the alloc() call (tx_context::sender). RESOLVED AT EXECUTION TIME, not at config time. For refunds: the customer (Order owner) must call alloc_by_guard THEMSELVES so that tx_context::sender resolves to THEIR address — if the operator calls alloc_by_guard, the operator becomes the recipient (Signer = operator), NOT the customer. Use when the recipient is whoever submits the allocation transaction (e.g., customer receives refund)."
@@ -5259,7 +5259,7 @@
5259
5259
  "GuardIdentifier"
5260
5260
  ],
5261
5261
  "additionalProperties": false,
5262
- "description": "Guard verified recipient ID. Get recipient ID from specified data index in Guard table. The ID must be of address type."
5262
+ "description": "Guard verified recipient ID. Get recipient ID from specified data index in Guard table. The ID must be of address type. ALLOCATION rails only — the REWARD claim rail requires recipient == the transaction sender (abort 14), so a GuardIdentifier recipient on reward.guard_add resolves to the submitted Order and is structurally unpayable; the tool gate rejects it (crs-mn-261015 F-12)."
5263
5263
  },
5264
5264
  {
5265
5265
  "type": "object",
@@ -5298,10 +5298,10 @@
5298
5298
  "Signer"
5299
5299
  ],
5300
5300
  "additionalProperties": false,
5301
- "description": "Current transaction signer (tx_context::sender) at the time of the alloc() call. For refunds, the Order owner must call alloc_by_guard themselves to receive the funds."
5301
+ "description": "Current transaction signer (tx_context::sender) at the time of the alloc() call. For refunds, the Order owner must call alloc_by_guard themselves to receive the funds. On the REWARD claim rail this is the CANONICAL recipient (the claim entry requires recipient == the tx sender)."
5302
5302
  }
5303
5303
  ],
5304
- "description": "Recipient ID. Three forms:\n - {GuardIdentifier: u8} — DYNAMIC address resolved from Passport at alloc() time\n - {Entity: {name_or_address: 'mark_name'}} — FIXED static address via LocalMark (recommended)\n - {Signer: 'signer'} — transaction sender at alloc() time (e.g. self-refund; customer must call alloc_by_guard themselves)"
5304
+ "description": "Recipient ID. Three forms:\n - {GuardIdentifier: u8} — DYNAMIC address resolved from Passport at alloc() time (Allocation rails only; structurally unpayable on reward.guard_add — abort 14)\n - {Entity: {name_or_address: 'mark_name'}} — FIXED static address via LocalMark (recommended)\n - {Signer: 'signer'} — transaction sender at alloc() time (e.g. self-refund; customer must call alloc_by_guard themselves; canonical on reward claim rails)"
5305
5305
  },
5306
5306
  "amount": {
5307
5307
  "oneOf": [
@@ -5407,7 +5407,7 @@
5407
5407
  "type": "null"
5408
5408
  }
5409
5409
  ],
5410
- "description": "Used to lock whether new Reward Guards can be added. If not specified, new Reward Guards can be added at any time; if expiration time is specified, new Reward Guards cannot be added before expiration."
5410
+ "description": "Used to lock whether new Reward Guards can be added AND whether the balance can be withdrawn. If not specified, new Reward Guards can be added at any time and the balance can be withdrawn; if expiration time is specified, neither new Reward Guards nor balance withdrawal is possible before expiration."
5411
5411
  },
5412
5412
  "record_count": {
5413
5413
  "type": "number",
@@ -7076,7 +7076,7 @@
7076
7076
  "GuardIdentifier"
7077
7077
  ],
7078
7078
  "additionalProperties": false,
7079
- "description": "Guard verified recipient ID. Get recipient ID from specified data index in Guard table. The ID must be of address type."
7079
+ "description": "Guard verified recipient ID. Get recipient ID from specified data index in Guard table. The ID must be of address type. ALLOCATION rails only — the REWARD claim rail requires recipient == the transaction sender (abort 14), so a GuardIdentifier recipient on reward.guard_add resolves to the submitted Order and is structurally unpayable; the tool gate rejects it (crs-mn-261015 F-12)."
7080
7080
  },
7081
7081
  {
7082
7082
  "type": "object",
@@ -7115,10 +7115,10 @@
7115
7115
  "Signer"
7116
7116
  ],
7117
7117
  "additionalProperties": false,
7118
- "description": "Current transaction signer (tx_context::sender) at the time of the alloc() call. For refunds, the Order owner must call alloc_by_guard themselves to receive the funds."
7118
+ "description": "Current transaction signer (tx_context::sender) at the time of the alloc() call. For refunds, the Order owner must call alloc_by_guard themselves to receive the funds. On the REWARD claim rail this is the CANONICAL recipient (the claim entry requires recipient == the tx sender)."
7119
7119
  }
7120
7120
  ],
7121
- "description": "Recipient ID. Three forms:\n - {GuardIdentifier: u8} — DYNAMIC address resolved from Passport at alloc() time\n - {Entity: {name_or_address: 'mark_name'}} — FIXED static address via LocalMark (recommended)\n - {Signer: 'signer'} — transaction sender at alloc() time (e.g. self-refund; customer must call alloc_by_guard themselves)"
7121
+ "description": "Recipient ID. Three forms:\n - {GuardIdentifier: u8} — DYNAMIC address resolved from Passport at alloc() time (Allocation rails only; structurally unpayable on reward.guard_add — abort 14)\n - {Entity: {name_or_address: 'mark_name'}} — FIXED static address via LocalMark (recommended)\n - {Signer: 'signer'} — transaction sender at alloc() time (e.g. self-refund; customer must call alloc_by_guard themselves; canonical on reward claim rails)"
7122
7122
  },
7123
7123
  "amount": {
7124
7124
  "anyOf": [
@@ -16471,6 +16471,63 @@
16471
16471
  ],
16472
16472
  "description": "FIRST allocator's sharing rows — the normal payout path. null when no allocators are configured."
16473
16473
  },
16474
+ "compensation_fund_coverage": {
16475
+ "anyOf": [
16476
+ {
16477
+ "type": "object",
16478
+ "properties": {
16479
+ "fund_balance": {
16480
+ "type": "string",
16481
+ "description": "Raw smallest units currently in the Service's compensation fund."
16482
+ },
16483
+ "fund_balance_display": {
16484
+ "anyOf": [
16485
+ {
16486
+ "type": "string"
16487
+ },
16488
+ {
16489
+ "type": "null"
16490
+ }
16491
+ ]
16492
+ },
16493
+ "required_for_this_basket": {
16494
+ "type": "string",
16495
+ "description": "Raw smallest units: 3 x total_pay — the per-order payout requirement this basket must meet at order creation."
16496
+ },
16497
+ "required_display": {
16498
+ "anyOf": [
16499
+ {
16500
+ "type": "string"
16501
+ },
16502
+ {
16503
+ "type": "null"
16504
+ }
16505
+ ]
16506
+ },
16507
+ "covered": {
16508
+ "type": "boolean",
16509
+ "description": "True when the fund covers the per-order requirement; false means no fund (a disclosed merchant choice) or an under-funded Service."
16510
+ },
16511
+ "note": {
16512
+ "type": "string"
16513
+ }
16514
+ },
16515
+ "required": [
16516
+ "fund_balance",
16517
+ "fund_balance_display",
16518
+ "required_for_this_basket",
16519
+ "required_display",
16520
+ "covered",
16521
+ "note"
16522
+ ],
16523
+ "additionalProperties": false
16524
+ },
16525
+ {
16526
+ "type": "null"
16527
+ }
16528
+ ],
16529
+ "description": "Per-order compensation-fund coverage for THIS basket (b6-11): the enforcement moved off the publish gate to the buy path — a fund-carrying Service below 3x the ORDER amount blocks order creation (compensation_fund_below_order_ceiling, no money moves), so the quote surfaces the same arithmetic BEFORE ordering. fund = 0 is a disclosed no-protection choice, never blocked. The chain-side claim-time abort (code 27, claim NOT consumed) remains the backstop."
16530
+ },
16474
16531
  "reward_terms": {
16475
16532
  "anyOf": [
16476
16533
  {
@@ -16642,10 +16699,11 @@
16642
16699
  "total_pay",
16643
16700
  "discount",
16644
16701
  "allocation_preview",
16702
+ "compensation_fund_coverage",
16645
16703
  "reward_terms"
16646
16704
  ],
16647
16705
  "additionalProperties": false,
16648
- "description": "ServiceQuote (basket prices, total_pay, the allocator fee-split preview and reward terms)."
16706
+ "description": "ServiceQuote (basket prices, total_pay, the allocator fee-split preview, per-order compensation-fund coverage and reward terms)."
16649
16707
  }
16650
16708
  },
16651
16709
  "required": [
@@ -23077,7 +23135,7 @@
23077
23135
  "type": "string"
23078
23136
  }
23079
23137
  ],
23080
- "description": "ID or name of the wowok object data query instruction. Can be a numeric ID (e.g., 1001) or a name string (e.g., 'permission.description'). Name matching is case-insensitive."
23138
+ "description": "ID or name of the wowok object data query instruction. Can be a numeric ID (e.g., 1001) or a name string (e.g., 'permission.description'). Name matching is case-insensitive. STRONGLY PREFER the NAME form: a numeric ID is resolved VERBATIM at runtime, so a wrong-but-existing ID silently checks a DIFFERENT field and only fails at Guard trigger time (abort 7, no leg named) — a wrong name fails loudly at validation here instead (rndb58d8d 04-ROOTCAUSE-A A2). If you only know the field, list the catalog first via schema_query action='get_guard_queries'."
23081
23139
  },
23082
23140
  "object": {
23083
23141
  "type": "object",
@@ -24702,13 +24760,26 @@
24702
24760
  "minimum": 0,
24703
24761
  "maximum": 255,
24704
24762
  "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)."
24763
+ },
24764
+ "convert_witness": {
24765
+ "description": "Optional witness to derive the Progress object from the submitted Order (e.g. 'OrderProgress'): the table object is the ORDER address and the chain resolves its per-order Progress — one Guard serves every order. Omit when the table object is a concrete Progress address.",
24766
+ "anyOf": [
24767
+ {
24768
+ "type": "integer",
24769
+ "minimum": -9007199254740991,
24770
+ "maximum": 9007199254740991
24771
+ },
24772
+ {
24773
+ "type": "string"
24774
+ }
24775
+ ]
24705
24776
  }
24706
24777
  },
24707
24778
  "required": [
24708
24779
  "identifier"
24709
24780
  ],
24710
24781
  "additionalProperties": false,
24711
- "description": "Reference to the Progress object in the Guard table (must be Address type)."
24782
+ "description": "Reference to the queried object in the Guard table: a Progress address, or an Order address when convert_witness is set."
24712
24783
  },
24713
24784
  "where": {
24714
24785
  "type": "object",
@@ -24759,6 +24830,91 @@
24759
24830
  "additionalProperties": false,
24760
24831
  "description": "Returns U64. Finds the index of the first or last history entry matching the filter conditions. Returns the history index (U64) if found. Throws error if no matching entry is found (Guard validation fails)."
24761
24832
  },
24833
+ {
24834
+ "type": "object",
24835
+ "properties": {
24836
+ "type": {
24837
+ "type": "string",
24838
+ "const": "query_progress_history_time"
24839
+ },
24840
+ "object": {
24841
+ "type": "object",
24842
+ "properties": {
24843
+ "identifier": {
24844
+ "type": "integer",
24845
+ "minimum": 0,
24846
+ "maximum": 255,
24847
+ "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)."
24848
+ },
24849
+ "convert_witness": {
24850
+ "description": "Optional witness to derive the Progress object from the submitted Order (e.g. 'OrderProgress'): the table object is the ORDER address and the chain resolves its per-order Progress — one Guard serves every order. Omit when the table object is a concrete Progress address.",
24851
+ "anyOf": [
24852
+ {
24853
+ "type": "integer",
24854
+ "minimum": -9007199254740991,
24855
+ "maximum": 9007199254740991
24856
+ },
24857
+ {
24858
+ "type": "string"
24859
+ }
24860
+ ]
24861
+ }
24862
+ },
24863
+ "required": [
24864
+ "identifier"
24865
+ ],
24866
+ "additionalProperties": false,
24867
+ "description": "Reference to the queried object in the Guard table: a Progress address, or an Order address when convert_witness is set."
24868
+ },
24869
+ "where": {
24870
+ "type": "object",
24871
+ "properties": {
24872
+ "node": {
24873
+ "description": "Optional filter: node name string to match.",
24874
+ "type": "string"
24875
+ },
24876
+ "nextNode": {
24877
+ "description": "Optional filter: next node name string to match — the canonical time anchor is where:{nextNode:'<node>'}, find:'last', which returns the IMMUTABLE moment that node was entered (1280 history.time is written once on entry and never rewritten, unlike the 1272 current-time read which refreshes on re-entry). An empty where {} with find:'last' returns the entry time of the CURRENT node — safe for node-SET gates.",
24878
+ "type": "string"
24879
+ },
24880
+ "timeMin": {
24881
+ "description": "Optional filter: minimum timestamp (inclusive) for history entry time. Use string to represent U64 value.",
24882
+ "type": "string"
24883
+ },
24884
+ "timeMax": {
24885
+ "description": "Optional filter: maximum timestamp (inclusive) for history entry time. Use string to represent U64 value.",
24886
+ "type": "string"
24887
+ },
24888
+ "indexMin": {
24889
+ "description": "Optional filter: minimum history index (inclusive) to search within. Use string to represent U64 value.",
24890
+ "type": "string"
24891
+ },
24892
+ "indexMax": {
24893
+ "description": "Optional filter: maximum history index (inclusive) to search within. Use string to represent U64 value.",
24894
+ "type": "string"
24895
+ }
24896
+ },
24897
+ "additionalProperties": false,
24898
+ "description": "Filter conditions for the progress history time query."
24899
+ },
24900
+ "find": {
24901
+ "type": "string",
24902
+ "enum": [
24903
+ "first",
24904
+ "last"
24905
+ ],
24906
+ "description": "'first' finds the earliest matching history entry, 'last' finds the most recent matching history entry."
24907
+ }
24908
+ },
24909
+ "required": [
24910
+ "type",
24911
+ "object",
24912
+ "where",
24913
+ "find"
24914
+ ],
24915
+ "additionalProperties": false,
24916
+ "description": "Returns U64. Returns the TIMESTAMP (ms) of the first or last history entry matching the filter conditions — the immutable entry moment of a node (query 1280 progress.history.time). Preferred over query 1272 progress.current_time for time anchors: 1272 reads the node's CURRENT time and refreshes on re-entry (drift-prone), while 1280 is written once on entering next_node and never rewritten. Throws error if no matching entry is found (Guard validation fails)."
24917
+ },
24762
24918
  {
24763
24919
  "type": "object",
24764
24920
  "properties": {
@@ -25053,6 +25209,73 @@
25053
25209
  "additionalProperties": false,
25054
25210
  "description": "Returns U64. Counts the number of retained submissions within the specified forward operation."
25055
25211
  },
25212
+ {
25213
+ "type": "object",
25214
+ "properties": {
25215
+ "type": {
25216
+ "type": "string",
25217
+ "const": "query_progress_history_session_forward_retained_submission_value"
25218
+ },
25219
+ "object": {
25220
+ "type": "object",
25221
+ "properties": {
25222
+ "identifier": {
25223
+ "type": "integer",
25224
+ "minimum": 0,
25225
+ "maximum": 255,
25226
+ "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)."
25227
+ }
25228
+ },
25229
+ "required": [
25230
+ "identifier"
25231
+ ],
25232
+ "additionalProperties": false,
25233
+ "description": "Reference to the Progress object in the Guard table (must be Address type)."
25234
+ },
25235
+ "historyIdx": {
25236
+ "description": "GuardNode that returns the history index (U64 type). Typically an 'identifier' node referencing a U64 value from the Guard table.",
25237
+ "allOf": [
25238
+ {
25239
+ "$ref": "#/definitions/__schema1"
25240
+ }
25241
+ ]
25242
+ },
25243
+ "sessionIdx": {
25244
+ "description": "GuardNode that returns the session index (U64 type) within the history entry. Typically an 'identifier' node referencing a U64 value from the Guard table.",
25245
+ "allOf": [
25246
+ {
25247
+ "$ref": "#/definitions/__schema1"
25248
+ }
25249
+ ]
25250
+ },
25251
+ "forwardIdx": {
25252
+ "description": "GuardNode that returns the forward operation index (U64 type) within the session. Typically an 'identifier' node referencing a U64 value from the Guard table.",
25253
+ "allOf": [
25254
+ {
25255
+ "$ref": "#/definitions/__schema1"
25256
+ }
25257
+ ]
25258
+ },
25259
+ "identifier": {
25260
+ "description": "GuardNode that returns the submission identifier (U8 type) — which retained submission of the forward to read. Typically an 'identifier' node referencing a U8 value from the Guard table.",
25261
+ "allOf": [
25262
+ {
25263
+ "$ref": "#/definitions/__schema1"
25264
+ }
25265
+ ]
25266
+ }
25267
+ },
25268
+ "required": [
25269
+ "type",
25270
+ "object",
25271
+ "historyIdx",
25272
+ "sessionIdx",
25273
+ "forwardIdx",
25274
+ "identifier"
25275
+ ],
25276
+ "additionalProperties": false,
25277
+ "description": "Returns VecU8 (the ONLY history query that does not return U64). Value of the specified retained submission of a HISTORY record (query 1281) — the history-side counterpart of the ACTIVE-SESSION-ONLY 1268 read, which goes blind once the session migrates into history. Use 1274/1275 to discover the history/session/forward indexes first. Throws error when the record carries no submission for the identifier (Guard validation fails)."
25278
+ },
25056
25279
  {
25057
25280
  "type": "object",
25058
25281
  "properties": {
@@ -19,9 +19,10 @@
19
19
  "get_guard_design_patterns",
20
20
  "get_safety_rules",
21
21
  "get_templates",
22
- "analyze_guard_semantics"
22
+ "analyze_guard_semantics",
23
+ "get_guard_queries"
23
24
  ],
24
- "description": "Action to perform: 'list' (all schemas), 'get' (specific input schema), 'get_output' (tool output schema), 'get_field' (field-path query e.g. field_path='data.node'), 'search' (by keyword), 'list_operations' (on-chain operations), 'get_guard_templates' (Guard creation templates + best practices), 'get_tool_reference' (MCP tool usage reference: summaries, actions, prerequisites, notes — sunk from wowok-tools skill), 'get_guard_design_patterns' (curated Guard design pattern catalog: business requirement → logic tree template — sunk from wowok-guard skill), 'get_safety_rules' (object reuse/immutability/operation-classification/naming rules — sunk from wowok-safety skill), 'get_templates' (unified template registry: ~90 parameterized templates across 11 object types — guard/machine/service/order/progress/arbitration/treasury/permission/passport/allocation/reward; omit 'template' to list metadata, provide 'template' for full detail, provide 'template' + 'params' to instantiate into executable JSON), 'analyze_guard_semantics' (parse + evaluate any Guard JSON: rendered logic tree, lint diagnostics, risk assessment, and a party-perspective reading — who can trigger, under what conditions, with what evidence. Both transacting parties should run this BEFORE relying on a Guard)."
25
+ "description": "Action to perform: 'list' (all schemas), 'get' (specific input schema), 'get_output' (tool output schema), 'get_field' (field-path query e.g. field_path='data.node'), 'search' (by keyword), 'list_operations' (on-chain operations), 'get_guard_templates' (Guard creation templates + best practices), 'get_tool_reference' (MCP tool usage reference: summaries, actions, prerequisites, notes — sunk from wowok-tools skill), 'get_guard_design_patterns' (curated Guard design pattern catalog: business requirement → logic tree template — sunk from wowok-guard skill), 'get_safety_rules' (object reuse/immutability/operation-classification/naming rules — sunk from wowok-safety skill), 'get_templates' (unified template registry: ~90 parameterized templates across 11 object types — guard/machine/service/order/progress/arbitration/treasury/permission/passport/allocation/reward; omit 'template' to list metadata, provide 'template' for full detail, provide 'template' + 'params' to instantiate into executable JSON), 'analyze_guard_semantics' (parse + evaluate any Guard JSON: rendered logic tree, lint diagnostics, risk assessment, and a party-perspective reading — who can trigger, under what conditions, with what evidence. Both transacting parties should run this BEFORE relying on a Guard), 'get_guard_queries' (the GUARDQUERY catalog — every Guard query instruction as data: {id, name, objectType, returnType}; optional query='<keyword>' for full entries with descriptions, output_file to dump all details. Use this to build the field→query→semantics map BEFORE writing Guard trees — and prefer NAME references: a numeric id is resolved verbatim, so a wrong-but-existing id silently checks a different field)."
25
26
  },
26
27
  "name": {
27
28
  "description": "Schema/tool name for 'get'/'get_output'/'get_field'/'get_tool_reference' action (e.g., 'onchain_operations', 'onchain_operations_machine'), or pattern id for 'get_guard_design_patterns' (e.g., 'pattern.identity_check_allowlist').",
@@ -3,13 +3,57 @@ import { type TemplateScanResult } from "../../knowledge/template-scanner.js";
3
3
  import type { DeliverableDefinition } from "../../playbooks/service-build/intent-analyzer.js";
4
4
  import type { IndustryMode } from "../../extensions/index.js";
5
5
  import type { ToolDispatchResult } from "../types.js";
6
- declare function scanSummary(scan: TemplateScanResult): {
6
+ declare function driftFace(templateId: string): {
7
+ template: string;
8
+ state: "current";
9
+ catalog_version: number;
10
+ blocked: boolean;
11
+ repairable: boolean;
12
+ detail: string;
13
+ } | {
14
+ template: string;
15
+ state: "untracked";
16
+ catalog_version: number;
17
+ blocked: boolean;
18
+ repairable: boolean;
19
+ detail: string;
20
+ } | {
21
+ template: string;
22
+ state: "modified" | "missing";
23
+ catalog_version: number;
24
+ blocked: boolean;
25
+ repairable: boolean;
26
+ detail: string;
27
+ };
28
+ declare function scanSummary(scan: TemplateScanResult, drift?: ReturnType<typeof driftFace>): {
7
29
  risk_level: import("../../knowledge/template-scanner.js").TemplateRiskLevel;
8
30
  passed: boolean;
9
31
  finding_count: number;
10
32
  findings_by_severity: Record<string, number>;
11
33
  red_flags: string[];
12
34
  findings: import("../../knowledge/template-scanner.js").TemplateScanFinding[];
35
+ drift: {
36
+ template: string;
37
+ state: "current";
38
+ catalog_version: number;
39
+ blocked: boolean;
40
+ repairable: boolean;
41
+ detail: string;
42
+ } | {
43
+ template: string;
44
+ state: "untracked";
45
+ catalog_version: number;
46
+ blocked: boolean;
47
+ repairable: boolean;
48
+ detail: string;
49
+ } | {
50
+ template: string;
51
+ state: "modified" | "missing";
52
+ catalog_version: number;
53
+ blocked: boolean;
54
+ repairable: boolean;
55
+ detail: string;
56
+ } | undefined;
13
57
  };
14
58
  export declare function buildVerdict(summary: ReturnType<typeof scanSummary>, plan: Record<string, unknown>): {
15
59
  buildable: boolean;
@@ -1 +1 @@
1
- import{strictParse}from'../../schema/index.js';import{BenchmarkMigrationSchema}from'../../schema/benchmark-migration/index.js';import{getTemplate,listTemplates,validateAllocatorRows,platformShareBps}from'../../knowledge/template-loader.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 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 scanSummary(a){const b={};for(const c of a['findings'])b[c['severity']]=(b[c['severity']]??0x0)+0x1;return{'risk_level':a['risk_level'],'passed':a['passed'],'finding_count':a['findings']['length'],'findings_by_severity':b,'red_flags':a['red_flags'],'findings':a['findings']};}function assertScanPassed(a,b){if(a['passed'])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'+a['red_flags']['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,\x20or\x20kind\x20\x27template\x27\x20with\x20a\x20tpl_*\x20id),\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){const f=effectiveFeeParams(a,c),g=rewardPoolPrefill(a,b,c);if(g)f[g['fee_key']]=g['value'];validateFeeParams(f,a['id']),validateConditionalParams(a,f);const h=getIndustryModeRegistry()['getMode'](a['industry']),i=platformShareBps(f),j={'model':variantPaymentModel(a)},k=[],l=(a['allocator']['rows']?.['length']??0x0)>0x0;if(i!==undefined&&i>0x0&&!l&&a['allocator']['mode']==='rate'){const p=Math['round'](i)/0x64;k['push']({'recipient':'merchant','percentage':Math['round']((0x64-p)*0x64)/0x64}),k['push']({'recipient':'platform','percentage':p}),j['allocation']=k;}const m=variantRefundPolicy(a),n={'escrow':!![]};if(m)n['refundPolicy']=m;n['arbitration']=a['arbitration_mode']??n['arbitration']??inferArbitration(templateIntent(a,b));const o=await handleMerchantGuide({'intent':templateIntent(a,b),'guide_confirm':{'industry':a['industry'],'payment':j,'trust':n,'deliverables':variantDeliverables(a,h?.['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']}:{}},'template_override':{...a,'fee_params':f},'name_base':a['id']});if(a['allocator']['rows']?.['length'])o['template_allocator_rows']=a['allocator']['rows']['map'](q=>({...q}));o['template']={'id':a['id'],'archetype':a['archetype'],'recommended_role':a['recommended_role'],'fee_params':f},o['template_fee_param_landings']=buildFeeParamLandingTable(a,f);if(c&&Object['keys'](c)['length']>0x0)o['template_fee_overrides']=c;return g&&(o['fee_overrides_prefill']=g,o['next_action']=o['next_action']+'\x20Reward\x20pool\x20prefilled\x20from\x20your\x20request:\x20'+g['value']+'\x20—\x20adjust\x20via\x20fee_overrides.'),o;}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'](h=>h['industry']===c):e;d={'action':'template_list','count':g['length'],'templates':g['map'](templateSummary),'load_errors':f};break;}case'template_get':{const h=requireTemplate(b['template_id'],'template_get');d={'action':'template_get','template':{...h}};break;}case'template_generate':{const i=requireTemplate(b['template_id'],'template_generate'),j=scanTemplate(i);assertScanPassed(j,'template_generate');const k=await runGuide(i,b['description'],b['fee_overrides'],b['guard_resolutions'],{'review_mode':b['review_mode'],'reward_funding':b['reward_funding']});d=((()=>{const l=scanSummary(j),m=buildVerdict(l,k);return{'action':'template_generate','template_id':i['id'],'scan':l,'plan':k,'verdict':m,'next_action':planNextAction(k,'template_generate',m)};})());break;}case'template_scan':{const l=requireTemplate(b['template_id'],'template_scan');d={'action':'template_scan','scan':scanTemplate(l)};break;}case'migration_import':{if(!b['description']||!b['description']['trim']())throw new Error('\x27description\x27\x20is\x20required\x20for\x20action=\x27migration_import\x27');const m=planMigration({'url':b['url'],'description':b['description'],'industry':c,'network':b['network']});if(!m)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':m,'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 n=b['log'],o=Array['isArray'](n['mapped'])?n['mapped']:[],p=Array['isArray'](n['unmapped'])?n['unmapped']:[],q=Array['isArray'](n['manual_review'])?n['manual_review']:[],r=n['risk_check']??{},s=n['source']?.['matched_template']??'',t=p['length']===0x0&&q['length']===0x0&&r['passed']===!![];d={'action':'migration_review','log':n,'review_summary':{'mapped_count':o['length'],'unmapped_count':p['length'],'manual_review_count':q['length'],'risk_passed':r['passed']===!![]},'next_action':t?'Review\x20clean.\x20Proceed:\x20call\x20action=\x27migration_apply\x27\x20with\x20template_id=\x27'+s+'\x27\x20to\x20produce\x20the\x20creation\x20plan\x20(network\x20defaults\x20to\x20testnet;\x20mainnet\x20requires\x20explicit\x20user\x20confirmation).':'Surface\x20the\x20'+p['length']+'\x20unmapped\x20and\x20'+q['length']+'\x20manual_review\x20items'+(r['passed']===!![]?'':'\x20plus\x20the\x20risk_check\x20findings')+'\x20to\x20the\x20user\x20for\x20a\x20decision\x20before\x20action=\x27migration_apply\x27\x20(template_id=\x27'+s+'\x27).'};break;}case'migration_apply':{const u=requireTemplate(b['template_id'],'migration_apply'),v=scanTemplate(u);assertScanPassed(v,'migration_apply');const w=b['network']??'testnet',x=await runGuide(u,b['description'],b['fee_overrides'],b['guard_resolutions'],{'review_mode':b['review_mode'],'reward_funding':b['reward_funding']});d=((()=>{const y=scanSummary(v),z=buildVerdict(y,x);return{'action':'migration_apply','template_id':u['id'],'network':w,'scan':y,'plan':x,'verdict':z,'next_action':planNextAction(x,'migration_apply',z)};})());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 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['passed'],'finding_count':a['findings']['length'],'findings_by_severity':c,'red_flags':a['red_flags'],'findings':a['findings'],'drift':b};}function assertScanPassed(a,b){if(a['passed'])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'+a['red_flags']['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){const f=effectiveFeeParams(a,c),g=rewardPoolPrefill(a,b,c);if(g)f[g['fee_key']]=g['value'];validateFeeParams(f,a['id']),validateConditionalParams(a,f);const h=getIndustryModeRegistry()['getMode'](a['industry']),i=platformShareBps(f),j={'model':variantPaymentModel(a)},k=[],l=(a['allocator']['rows']?.['length']??0x0)>0x0;if(i!==undefined&&i>0x0&&!l&&a['allocator']['mode']==='rate'){const p=Math['round'](i)/0x64;k['push']({'recipient':'merchant','percentage':Math['round']((0x64-p)*0x64)/0x64}),k['push']({'recipient':'platform','percentage':p}),j['allocation']=k;}const m=variantRefundPolicy(a),n={'escrow':!![]};if(m)n['refundPolicy']=m;n['arbitration']=a['arbitration_mode']??n['arbitration']??inferArbitration(templateIntent(a,b));const o=await handleMerchantGuide({'intent':templateIntent(a,b),'guide_confirm':{'industry':a['industry'],'payment':j,'trust':n,'deliverables':variantDeliverables(a,h?.['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']}:{}},'template_override':{...a,'fee_params':f},'name_base':a['id']});if(a['allocator']['rows']?.['length'])o['template_allocator_rows']=a['allocator']['rows']['map'](q=>({...q}));o['template']={'id':a['id'],'archetype':a['archetype'],'recommended_role':a['recommended_role'],'fee_params':f},o['template_fee_param_landings']=buildFeeParamLandingTable(a,f);if(c&&Object['keys'](c)['length']>0x0)o['template_fee_overrides']=c;return g&&(o['fee_overrides_prefill']=g,o['next_action']=o['next_action']+'\x20Reward\x20pool\x20prefilled\x20from\x20your\x20request:\x20'+g['value']+'\x20—\x20adjust\x20via\x20fee_overrides.'),o;}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}};break;}case'template_generate':{const j=requireTemplate(b['template_id'],'template_generate'),k=scanTemplate(j);assertScanPassed(k,'template_generate');const l=await runGuide(j,b['description'],b['fee_overrides'],b['guard_resolutions'],{'review_mode':b['review_mode'],'reward_funding':b['reward_funding']});d=((()=>{const m=scanSummary(k,driftFace(j['id'])),n=buildVerdict(m,l);return{'action':'template_generate','template_id':j['id'],'scan':m,'plan':l,'verdict':n,'next_action':planNextAction(l,'template_generate',n)};})());break;}case'template_scan':{const m=requireTemplate(b['template_id'],'template_scan');d={'action':'template_scan','scan':{...scanTemplate(m),'drift':driftFace(m['id'])}};break;}case'migration_import':{if(!b['description']||!b['description']['trim']())throw new Error('\x27description\x27\x20is\x20required\x20for\x20action=\x27migration_import\x27');const n=planMigration({'url':b['url'],'description':b['description'],'industry':c,'network':b['network']});if(!n)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':n,'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 o=b['log'],p=Array['isArray'](o['mapped'])?o['mapped']:[],q=Array['isArray'](o['unmapped'])?o['unmapped']:[],r=Array['isArray'](o['manual_review'])?o['manual_review']:[],s=o['risk_check']??{},t=o['source']?.['matched_template']??'',u=q['length']===0x0&&r['length']===0x0&&s['passed']===!![];d={'action':'migration_review','log':o,'review_summary':{'mapped_count':p['length'],'unmapped_count':q['length'],'manual_review_count':r['length'],'risk_passed':s['passed']===!![]},'next_action':u?'Review\x20clean.\x20Proceed:\x20call\x20action=\x27migration_apply\x27\x20with\x20template_id=\x27'+t+'\x27\x20to\x20produce\x20the\x20creation\x20plan\x20(network\x20defaults\x20to\x20testnet;\x20mainnet\x20requires\x20explicit\x20user\x20confirmation).':'Surface\x20the\x20'+q['length']+'\x20unmapped\x20and\x20'+r['length']+'\x20manual_review\x20items'+(s['passed']===!![]?'':'\x20plus\x20the\x20risk_check\x20findings')+'\x20to\x20the\x20user\x20for\x20a\x20decision\x20before\x20action=\x27migration_apply\x27\x20(template_id=\x27'+t+'\x27).'};break;}case'migration_apply':{const v=requireTemplate(b['template_id'],'migration_apply'),w=scanTemplate(v);assertScanPassed(w,'migration_apply');const x=b['network']??'testnet',y=await runGuide(v,b['description'],b['fee_overrides'],b['guard_resolutions'],{'review_mode':b['review_mode'],'reward_funding':b['reward_funding']});d=((()=>{const z=scanSummary(w,driftFace(v['id'])),A=buildVerdict(z,y);return{'action':'migration_apply','template_id':v['id'],'network':x,'scan':z,'plan':y,'verdict':A,'next_action':planNextAction(y,'migration_apply',A)};})());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 a448a,setEnabled as a448b,reset as a448c}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=a448a(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.');a448b(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.');a448b(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.');a448c(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}};}
1
+ import{listServices,getServiceInfo,toggle as a450a,setEnabled as a450b,reset as a450c}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=a450a(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.');a450b(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.');a450b(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.');a450c(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}};}