@wowok/agent-mcp 3.3.2 → 3.3.5

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 (232) hide show
  1. package/dist/chain-semantics/field-capability.js +1 -1
  2. package/dist/chain-semantics/freeze-map.js +1 -1
  3. package/dist/chain-semantics/fund-flow.js +1 -1
  4. package/dist/chain-semantics/object-graph.js +1 -1
  5. package/dist/composition/audit.js +1 -1
  6. package/dist/composition/compile.d.ts +5 -2
  7. package/dist/composition/compile.js +1 -1
  8. package/dist/composition/inflight.d.ts +27 -3
  9. package/dist/composition/inflight.js +1 -1
  10. package/dist/config/judgment.d.ts +111 -1
  11. package/dist/config/judgment.js +1 -1
  12. package/dist/evaluation/arbitration-game.d.ts +4 -0
  13. package/dist/evaluation/arbitration-game.js +1 -1
  14. package/dist/evaluation/builtins/graph-service.js +1 -1
  15. package/dist/evaluation/builtins/graph-service.spec.js +1 -1
  16. package/dist/evaluation/game-strategy.d.ts +6 -0
  17. package/dist/evaluation/game-strategy.js +1 -1
  18. package/dist/evaluation/node-game.d.ts +7 -0
  19. package/dist/evaluation/node-game.js +1 -1
  20. package/dist/evaluation/value-risk.d.ts +8 -0
  21. package/dist/evaluation/value-risk.js +1 -0
  22. package/dist/experience/realtime-feedback.js +1 -1
  23. package/dist/extensions/business-modules.js +1 -1
  24. package/dist/extensions/industry-pack.js +1 -1
  25. package/dist/graph/onchain/analyze.js +1 -1
  26. package/dist/graph/onchain/analyze.spec.js +1 -1
  27. package/dist/graph/onchain/expand.js +1 -1
  28. package/dist/graph/onchain/exposure.js +1 -1
  29. package/dist/graph/onchain/facet-projection.js +1 -1
  30. package/dist/graph/onchain/facet-projection.spec.js +1 -1
  31. package/dist/graph/onchain/facts.d.ts +20 -0
  32. package/dist/graph/onchain/facts.js +1 -1
  33. package/dist/graph/onchain/facts.spec.js +1 -1
  34. package/dist/graph/onchain/object-held-receipts.d.ts +20 -0
  35. package/dist/graph/onchain/object-held-receipts.js +1 -0
  36. package/dist/graph/onchain/object-held-receipts.spec.d.ts +1 -0
  37. package/dist/graph/onchain/object-held-receipts.spec.js +1 -0
  38. package/dist/graph/onchain/sdk-batch.d.ts +1 -0
  39. package/dist/graph/onchain/sdk-batch.js +1 -1
  40. package/dist/harness/index.d.ts +1 -0
  41. package/dist/harness/recover.d.ts +2 -1
  42. package/dist/harness/recover.js +1 -1
  43. package/dist/knowledge/allocation-ledger.d.ts +0 -1
  44. package/dist/knowledge/allocation-ledger.js +1 -1
  45. package/dist/knowledge/allocation-puzzle.js +1 -1
  46. package/dist/knowledge/allocation-risk.js +1 -1
  47. package/dist/knowledge/arb-fund-facts.d.ts +7 -0
  48. package/dist/knowledge/arb-fund-facts.js +1 -1
  49. package/dist/knowledge/audit-rules.js +1 -1
  50. package/dist/knowledge/baselines/judgment-baselines.json +502 -81
  51. package/dist/knowledge/baselines/rules/allocation.json +0 -14
  52. package/dist/knowledge/baselines/rules/graph.json +4 -4
  53. package/dist/knowledge/baselines/rules/plan.json +33 -3
  54. package/dist/knowledge/builtin-templates.d.ts +1 -1
  55. package/dist/knowledge/builtin-templates.js +1 -1
  56. package/dist/knowledge/discount-threshold.js +1 -1
  57. package/dist/knowledge/event-semantics.js +1 -1
  58. package/dist/knowledge/game-scenarios.d.ts +21 -0
  59. package/dist/knowledge/game-scenarios.js +1 -0
  60. package/dist/knowledge/getting-started.js +1 -1
  61. package/dist/knowledge/guard-bindings.js +1 -1
  62. package/dist/knowledge/guard-design-patterns.d.ts +1 -1
  63. package/dist/knowledge/guard-design-patterns.js +1 -1
  64. package/dist/knowledge/guard-field-cognition.js +1 -1
  65. package/dist/knowledge/guard-leg-map.d.ts +5 -0
  66. package/dist/knowledge/guard-leg-map.js +1 -0
  67. package/dist/knowledge/guard-puzzle.js +1 -1
  68. package/dist/knowledge/guard-render.js +1 -1
  69. package/dist/knowledge/guard-risk.js +1 -1
  70. package/dist/knowledge/guard-submission-prompt.js +1 -1
  71. package/dist/knowledge/guard-templates.d.ts +1 -1
  72. package/dist/knowledge/guard-templates.js +1 -1
  73. package/dist/knowledge/guard-translation.js +1 -1
  74. package/dist/knowledge/index.js +1 -1
  75. package/dist/knowledge/industry-registry.js +1 -1
  76. package/dist/knowledge/industry-strategy.js +1 -1
  77. package/dist/knowledge/jsonrpc-enum.js +1 -1
  78. package/dist/knowledge/onchain-constants.d.ts +4 -2
  79. package/dist/knowledge/onchain-constants.js +1 -1
  80. package/dist/knowledge/order-ledger.d.ts +1 -1
  81. package/dist/knowledge/order-ledger.js +1 -1
  82. package/dist/knowledge/order-puzzle.d.ts +3 -0
  83. package/dist/knowledge/order-risk.d.ts +1 -1
  84. package/dist/knowledge/passport-ledger.d.ts +12 -0
  85. package/dist/knowledge/passport-ledger.js +1 -1
  86. package/dist/knowledge/payment-tracker.js +1 -1
  87. package/dist/knowledge/protocol-facts.d.ts +1 -0
  88. package/dist/knowledge/protocol-facts.js +1 -1
  89. package/dist/knowledge/recipient-constraint.d.ts +9 -0
  90. package/dist/knowledge/recipient-constraint.js +1 -1
  91. package/dist/knowledge/repository-write-semantics.d.ts +1 -1
  92. package/dist/knowledge/repository-write-semantics.js +1 -1
  93. package/dist/knowledge/scenario-modes.d.ts +1 -0
  94. package/dist/knowledge/scenario-modes.js +1 -1
  95. package/dist/knowledge/service-ledger.d.ts +14 -0
  96. package/dist/knowledge/service-ledger.js +1 -1
  97. package/dist/knowledge/strategy-manuals.js +1 -1
  98. package/dist/knowledge/template-loader.d.ts +1 -0
  99. package/dist/knowledge/template-loader.js +1 -1
  100. package/dist/knowledge/template-registry.js +1 -1
  101. package/dist/knowledge/template-scanner.d.ts +4 -0
  102. package/dist/knowledge/template-scanner.js +1 -1
  103. package/dist/knowledge/workflow-guidance.d.ts +2 -0
  104. package/dist/knowledge/workflow-guidance.js +1 -1
  105. package/dist/monitor/MonitorLoop.js +1 -1
  106. package/dist/participation/allocation-advice.d.ts +8 -1
  107. package/dist/participation/allocation-advice.js +1 -1
  108. package/dist/participation/game-context.d.ts +25 -0
  109. package/dist/participation/game-context.js +1 -0
  110. package/dist/participation/node-action-advisor.d.ts +64 -0
  111. package/dist/participation/node-action-advisor.js +1 -0
  112. package/dist/participation/radar-core.js +1 -1
  113. package/dist/playbooks/service-build/business-puzzle.js +1 -1
  114. package/dist/playbooks/service-build/machine-panorama.js +1 -1
  115. package/dist/playbooks/service-build/merchant-guide.d.ts +1 -0
  116. package/dist/playbooks/service-build/merchant-guide.js +1 -1
  117. package/dist/playbooks/service-build/migration-planner.d.ts +2 -2
  118. package/dist/playbooks/service-build/migration-planner.js +1 -1
  119. package/dist/playbooks/service-build/object-panorama.d.ts +13 -1
  120. package/dist/playbooks/service-build/object-panorama.js +1 -1
  121. package/dist/playbooks/service-build/participation-radar.js +1 -1
  122. package/dist/playbooks/service-build/relationship-profile.js +1 -1
  123. package/dist/playbooks/service-build/service-panorama.d.ts +8 -0
  124. package/dist/playbooks/service-build/service-panorama.js +1 -1
  125. package/dist/playbooks/service-build/service-quote.js +1 -1
  126. package/dist/playbooks/service-build/service-quote.spec.js +1 -1
  127. package/dist/review/index.js +1 -1
  128. package/dist/review/repository.js +1 -1
  129. package/dist/role/intent.d.ts +23 -0
  130. package/dist/role/intent.js +1 -0
  131. package/dist/safety/confirm-gate.js +1 -1
  132. package/dist/schema/benchmark-migration/index.d.ts +4 -0
  133. package/dist/schema/benchmark-migration/index.js +1 -1
  134. package/dist/schema/call/allocation.d.ts +3 -0
  135. package/dist/schema/call/allocation.js +1 -1
  136. package/dist/schema/call/arbitration.js +1 -1
  137. package/dist/schema/call/base.d.ts +77 -0
  138. package/dist/schema/call/base.js +1 -1
  139. package/dist/schema/call/bridge.d.ts +4 -0
  140. package/dist/schema/call/error-codes.d.ts +1 -1
  141. package/dist/schema/call/error-codes.js +1 -1
  142. package/dist/schema/call/guard.js +1 -1
  143. package/dist/schema/call/handler.js +1 -1
  144. package/dist/schema/call/machine.d.ts +10 -0
  145. package/dist/schema/call/machine.js +1 -1
  146. package/dist/schema/call/order.d.ts +14 -0
  147. package/dist/schema/call/order.js +1 -1
  148. package/dist/schema/call/progress.js +1 -1
  149. package/dist/schema/call/repository.d.ts +4 -0
  150. package/dist/schema/call/semantic.d.ts +6 -0
  151. package/dist/schema/call/semantic.js +1 -1
  152. package/dist/schema/call/service.d.ts +34 -0
  153. package/dist/schema/call/service.js +1 -1
  154. package/dist/schema/common/index.js +1 -1
  155. package/dist/schema/keeper/index.d.ts +2 -0
  156. package/dist/schema/local/index.d.ts +43 -0
  157. package/dist/schema/local/index.js +1 -1
  158. package/dist/schema/messenger/index.d.ts +2 -0
  159. package/dist/schema/operations.d.ts +30 -0
  160. package/dist/schema/operations.js +1 -1
  161. package/dist/schema/persona/index.d.ts +484 -0
  162. package/dist/schema/query/bi.d.ts +6 -0
  163. package/dist/schema/query/bi.js +1 -1
  164. package/dist/schema/query/index.d.ts +207 -48
  165. package/dist/schema/query/index.js +1 -1
  166. package/dist/schema/schema-version.js +1 -1
  167. package/dist/schema-query-impl/index.js +1 -1
  168. package/dist/schemas/account_operation.output.json +15 -8
  169. package/dist/schemas/account_operation.schema.json +1 -1
  170. package/dist/schemas/benchmark_migration_operation.output.json +8 -5
  171. package/dist/schemas/benchmark_migration_operation.schema.json +5 -4
  172. package/dist/schemas/bridge_operation.output.json +15 -8
  173. package/dist/schemas/index.json +1 -1
  174. package/dist/schemas/keeper_operation.output.json +13 -8
  175. package/dist/schemas/local_cache_operation.output.json +36 -8
  176. package/dist/schemas/local_cache_operation.schema.json +16 -1
  177. package/dist/schemas/local_history_operation.output.json +15 -8
  178. package/dist/schemas/local_info_operation.output.json +15 -8
  179. package/dist/schemas/local_info_operation.schema.json +5 -1
  180. package/dist/schemas/local_mark_operation.output.json +15 -8
  181. package/dist/schemas/messenger_operation.output.json +13 -8
  182. package/dist/schemas/monitor_events.output.json +13 -8
  183. package/dist/schemas/monitor_subscription.output.json +13 -8
  184. package/dist/schemas/onchain_events.output.json +68 -19
  185. package/dist/schemas/onchain_events.schema.json +4 -0
  186. package/dist/schemas/onchain_operations.output.json +116 -28
  187. package/dist/schemas/onchain_operations.schema.json +246 -113
  188. package/dist/schemas/onchain_operations_allocation.schema.json +9 -5
  189. package/dist/schemas/onchain_operations_arbitration.schema.json +3 -3
  190. package/dist/schemas/onchain_operations_contact.schema.json +1 -1
  191. package/dist/schemas/onchain_operations_demand.schema.json +3 -3
  192. package/dist/schemas/onchain_operations_gen_passport.schema.json +1 -1
  193. package/dist/schemas/onchain_operations_guard.schema.json +99 -63
  194. package/dist/schemas/onchain_operations_machine.schema.json +10 -1
  195. package/dist/schemas/onchain_operations_order.schema.json +25 -3
  196. package/dist/schemas/onchain_operations_progress.schema.json +4 -4
  197. package/dist/schemas/onchain_operations_proof.schema.json +1 -1
  198. package/dist/schemas/onchain_operations_repository.schema.json +5 -1
  199. package/dist/schemas/onchain_operations_reward.schema.json +4 -4
  200. package/dist/schemas/onchain_operations_service.schema.json +74 -16
  201. package/dist/schemas/onchain_operations_treasury.schema.json +7 -7
  202. package/dist/schemas/onchain_table_data.output.json +18 -9
  203. package/dist/schemas/persona_operation.output.json +1387 -0
  204. package/dist/schemas/persona_operation.schema.json +219 -0
  205. package/dist/schemas/query_toolkit.output.json +113 -60
  206. package/dist/schemas/query_toolkit.schema.json +9 -1
  207. package/dist/schemas/workflow_operation.schema.json +1 -1
  208. package/dist/schemas/wowok_buildin_info.output.json +259 -0
  209. package/dist/schemas/wowok_buildin_info.schema.json +121 -0
  210. package/dist/tools/build-fingerprint.d.ts +28 -0
  211. package/dist/tools/build-fingerprint.js +1 -0
  212. package/dist/tools/handlers/benchmark-migration.js +1 -1
  213. package/dist/tools/handlers/bridge.js +1 -1
  214. package/dist/tools/handlers/config.js +1 -1
  215. package/dist/tools/handlers/dispatch-expectations.js +1 -1
  216. package/dist/tools/handlers/local.js +1 -1
  217. package/dist/tools/handlers/messenger.js +1 -1
  218. package/dist/tools/handlers/onchain-name-registration.d.ts +11 -0
  219. package/dist/tools/handlers/onchain-name-registration.js +1 -1
  220. package/dist/tools/handlers/onchain.d.ts +10 -0
  221. package/dist/tools/handlers/onchain.js +1 -1
  222. package/dist/tools/handlers/query.js +1 -1
  223. package/dist/tools/handlers/review-chain.d.ts +9 -13
  224. package/dist/tools/handlers/review-chain.js +1 -1
  225. package/dist/tools/move-fn-index.gen.js +1 -1
  226. package/dist/tools/registry/local.js +1 -1
  227. package/dist/tools/registry/onchain.js +1 -1
  228. package/dist/tools/registry/query.js +1 -1
  229. package/dist/tools/upgrade-check.d.ts +1 -0
  230. package/dist/tools/upgrade-check.js +1 -1
  231. package/dist/tools/wrap.js +1 -1
  232. package/package.json +3 -3
@@ -199,6 +199,10 @@
199
199
  }
200
200
  },
201
201
  "additionalProperties": false
202
+ },
203
+ "account": {
204
+ "description": "Account partition to query (name or address). Local info is isolated per account; omit for the default account's partition.",
205
+ "type": "string"
202
206
  }
203
207
  },
204
208
  "required": [
@@ -1092,6 +1096,10 @@
1092
1096
  "localnet"
1093
1097
  ],
1094
1098
  "description": "Network for the query — THIS field is `context_network` (the query tools accept no separate `network` key). Defaults to the user's CURRENT network (client UI selection / authority config) when omitted. 'localnet' is for internal test use against a local fullnode."
1099
+ },
1100
+ "no_cache": {
1101
+ "description": "A-5 freshness control (amz9-ln-261023). DEFAULT TRUE: the panorama primary read bypasses the object cache and reads the chain state fresh — a post-write panorama (confirm, forward, claim, refund) must never show pre-write cache (the F-L02/F-L10 stale-after-confirm failure made agents re-confirm and misread terminal states). Pass false to opt back into the cached read for high-frequency polling where a few seconds of staleness is acceptable.",
1102
+ "type": "boolean"
1095
1103
  }
1096
1104
  },
1097
1105
  "required": [
@@ -1247,7 +1255,7 @@
1247
1255
  "type": "boolean"
1248
1256
  },
1249
1257
  "radar_review_summary": {
1250
- "description": "Merchant-side review coverage summary (REVIEW-COMPONENT-PLAN batch 4): completed orders vs orders with a structured review record. Review rows live in a caller-named Repository — gather both counts via onchain_table_data (repository rows under the 'review' key, id_from=Signer → one row per buyer) and pass them in; the radar derives the merchant-side review-rate hint (high missing rate with a reward attached → reward lapsed or window too short). Omit when no review repository is bound.",
1258
+ "description": "Merchant-side review coverage summary (REVIEW-COMPONENT-PLAN batch 4): completed orders vs orders with a structured review record. Review rows live in a caller-named Repository — gather both counts via onchain_table_data (repository rows under the 'review' key, order-keyed → one row per order, F09) and pass them in; the radar derives the merchant-side review-rate hint (high missing rate with a reward attached → reward lapsed or window too short). Omit when no review repository is bound.",
1251
1259
  "type": "object",
1252
1260
  "properties": {
1253
1261
  "orders_completed": {
@@ -143,7 +143,7 @@
143
143
  "type": "integer",
144
144
  "minimum": 0,
145
145
  "maximum": 255,
146
- "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 (protocol 154): 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)."
146
+ "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)."
147
147
  },
148
148
  "b_submission": {
149
149
  "type": "boolean",
@@ -2206,6 +2206,265 @@
2206
2206
  "result"
2207
2207
  ],
2208
2208
  "additionalProperties": false
2209
+ },
2210
+ {
2211
+ "type": "object",
2212
+ "properties": {
2213
+ "info": {
2214
+ "type": "string",
2215
+ "const": "build_fingerprint"
2216
+ },
2217
+ "result": {
2218
+ "anyOf": [
2219
+ {
2220
+ "type": "object",
2221
+ "properties": {
2222
+ "fingerprint": {
2223
+ "type": "object",
2224
+ "properties": {
2225
+ "builtin_templates_version": {
2226
+ "type": "number",
2227
+ "description": "Builtin industry template catalog version compiled into this build — the primary identity key"
2228
+ },
2229
+ "git": {
2230
+ "type": "object",
2231
+ "properties": {
2232
+ "describe": {
2233
+ "anyOf": [
2234
+ {
2235
+ "type": "string"
2236
+ },
2237
+ {
2238
+ "type": "null"
2239
+ }
2240
+ ],
2241
+ "description": "git describe --tags --always --dirty of the workspace the build was produced from (null outside a repo / no git)"
2242
+ },
2243
+ "branch": {
2244
+ "anyOf": [
2245
+ {
2246
+ "type": "string"
2247
+ },
2248
+ {
2249
+ "type": "null"
2250
+ }
2251
+ ],
2252
+ "description": "Short branch name (null when detached/absent)"
2253
+ },
2254
+ "dirty": {
2255
+ "anyOf": [
2256
+ {
2257
+ "type": "boolean"
2258
+ },
2259
+ {
2260
+ "type": "null"
2261
+ }
2262
+ ],
2263
+ "description": "Uncommitted changes present (null = undeterminable)"
2264
+ }
2265
+ },
2266
+ "required": [
2267
+ "describe",
2268
+ "branch",
2269
+ "dirty"
2270
+ ],
2271
+ "additionalProperties": false,
2272
+ "description": "Git identity of the build workspace (best-effort, never throws)"
2273
+ },
2274
+ "mcp_dist_stale": {
2275
+ "anyOf": [
2276
+ {
2277
+ "type": "object",
2278
+ "properties": {
2279
+ "stale": {
2280
+ "type": "boolean"
2281
+ },
2282
+ "lag_minutes": {
2283
+ "type": "number"
2284
+ }
2285
+ },
2286
+ "required": [
2287
+ "stale",
2288
+ "lag_minutes"
2289
+ ],
2290
+ "additionalProperties": false
2291
+ },
2292
+ {
2293
+ "type": "null"
2294
+ }
2295
+ ],
2296
+ "description": "MCP workspace src newer than its dist (null = installed build, no src tree); runtime STATE, not identity — a rebuild between capture and compare is expected and never a skew"
2297
+ },
2298
+ "sdk_dist_stale": {
2299
+ "anyOf": [
2300
+ {
2301
+ "type": "object",
2302
+ "properties": {
2303
+ "stale": {
2304
+ "type": "boolean"
2305
+ },
2306
+ "lag_minutes": {
2307
+ "type": "number"
2308
+ }
2309
+ },
2310
+ "required": [
2311
+ "stale",
2312
+ "lag_minutes"
2313
+ ],
2314
+ "additionalProperties": false
2315
+ },
2316
+ {
2317
+ "type": "null"
2318
+ }
2319
+ ],
2320
+ "description": "SDK workspace src newer than its dist, same semantics (null = installed build)"
2321
+ },
2322
+ "captured_at": {
2323
+ "type": "string",
2324
+ "description": "ISO timestamp of the capture"
2325
+ }
2326
+ },
2327
+ "required": [
2328
+ "builtin_templates_version",
2329
+ "git",
2330
+ "mcp_dist_stale",
2331
+ "sdk_dist_stale",
2332
+ "captured_at"
2333
+ ],
2334
+ "additionalProperties": false,
2335
+ "description": "Current build identity — record verbatim in the test-report header"
2336
+ },
2337
+ "chain_stamp": {
2338
+ "type": "object",
2339
+ "properties": {
2340
+ "network": {
2341
+ "anyOf": [
2342
+ {
2343
+ "type": "string"
2344
+ },
2345
+ {
2346
+ "type": "null"
2347
+ }
2348
+ ]
2349
+ },
2350
+ "protocol_version": {
2351
+ "anyOf": [
2352
+ {
2353
+ "type": "string"
2354
+ },
2355
+ {
2356
+ "type": "null"
2357
+ }
2358
+ ],
2359
+ "description": "Chain protocol version observed on the current network (null when the chain was unreachable)"
2360
+ },
2361
+ "system_state_version": {
2362
+ "anyOf": [
2363
+ {
2364
+ "type": "string"
2365
+ },
2366
+ {
2367
+ "type": "null"
2368
+ }
2369
+ ],
2370
+ "description": "System state data-structure version observed (null when unreachable)"
2371
+ },
2372
+ "epoch": {
2373
+ "anyOf": [
2374
+ {
2375
+ "type": "string"
2376
+ },
2377
+ {
2378
+ "type": "null"
2379
+ }
2380
+ ],
2381
+ "description": "Current epoch observed (null when unreachable)"
2382
+ },
2383
+ "fetched": {
2384
+ "type": "boolean",
2385
+ "description": "false when the chain was unreachable — the null fields then carry no meaning and must not be quoted"
2386
+ },
2387
+ "fetched_at": {
2388
+ "anyOf": [
2389
+ {
2390
+ "type": "string"
2391
+ },
2392
+ {
2393
+ "type": "null"
2394
+ }
2395
+ ]
2396
+ }
2397
+ },
2398
+ "required": [
2399
+ "network",
2400
+ "protocol_version",
2401
+ "system_state_version",
2402
+ "epoch",
2403
+ "fetched",
2404
+ "fetched_at"
2405
+ ],
2406
+ "additionalProperties": false,
2407
+ "description": "Chain attribution observed during capture (fetched:false when unreachable) — record alongside the fingerprint"
2408
+ }
2409
+ },
2410
+ "required": [
2411
+ "fingerprint",
2412
+ "chain_stamp"
2413
+ ],
2414
+ "additionalProperties": false,
2415
+ "description": "CAPTURE result"
2416
+ },
2417
+ {
2418
+ "type": "object",
2419
+ "properties": {
2420
+ "comparison": {
2421
+ "type": "object",
2422
+ "properties": {
2423
+ "verdict": {
2424
+ "type": "string",
2425
+ "enum": [
2426
+ "current",
2427
+ "stale",
2428
+ "incomparable"
2429
+ ],
2430
+ "description": "current: every comparable identity key matches; stale: at least one identity key differs from the current build; incomparable: the report recorded no fingerprint at all"
2431
+ },
2432
+ "downgrades_findings": {
2433
+ "type": "boolean",
2434
+ "description": "true when verdict is stale or incomparable — the report's findings must be marked \"pending retest\" instead of triaged against current code"
2435
+ },
2436
+ "skews": {
2437
+ "type": "array",
2438
+ "items": {
2439
+ "type": "string"
2440
+ },
2441
+ "description": "Human-readable diffs per mismatched identity key (empty when current)"
2442
+ }
2443
+ },
2444
+ "required": [
2445
+ "verdict",
2446
+ "downgrades_findings",
2447
+ "skews"
2448
+ ],
2449
+ "additionalProperties": false,
2450
+ "description": "Report-vs-current verdict; downgrades_findings=true marks the report's findings \"pending retest\""
2451
+ }
2452
+ },
2453
+ "required": [
2454
+ "comparison"
2455
+ ],
2456
+ "additionalProperties": false,
2457
+ "description": "COMPARE result"
2458
+ }
2459
+ ],
2460
+ "description": "Build fingerprint result — capture (fingerprint + chain stamp) or compare (verdict)"
2461
+ }
2462
+ },
2463
+ "required": [
2464
+ "info",
2465
+ "result"
2466
+ ],
2467
+ "additionalProperties": false
2209
2468
  }
2210
2469
  ],
2211
2470
  "description": "Protocol info result"
@@ -632,6 +632,127 @@
632
632
  ],
633
633
  "additionalProperties": false,
634
634
  "description": "Getting-started orientation for a freshly connected agent - what the companion WoWok Skills are, install/doctor/repair commands, best-effort local detection of installed skills, the ~20s cold-start window, and which sub-tools matter for common goals. Call this at conversation start when no skill guidance is loaded."
635
+ },
636
+ {
637
+ "type": "object",
638
+ "properties": {
639
+ "info": {
640
+ "type": "string",
641
+ "const": "build_fingerprint"
642
+ },
643
+ "compare": {
644
+ "type": "object",
645
+ "properties": {
646
+ "builtin_templates_version": {
647
+ "description": "Templates version the report recorded (from its capture)",
648
+ "type": "number"
649
+ },
650
+ "git": {
651
+ "description": "Git state the report recorded",
652
+ "anyOf": [
653
+ {
654
+ "type": "object",
655
+ "properties": {
656
+ "describe": {
657
+ "description": "git describe the report recorded",
658
+ "anyOf": [
659
+ {
660
+ "type": "string"
661
+ },
662
+ {
663
+ "type": "null"
664
+ }
665
+ ]
666
+ }
667
+ },
668
+ "additionalProperties": false
669
+ },
670
+ {
671
+ "type": "null"
672
+ }
673
+ ]
674
+ },
675
+ "chain_stamp": {
676
+ "description": "Chain stamp the report quoted (from upgrade_check)",
677
+ "anyOf": [
678
+ {
679
+ "type": "object",
680
+ "properties": {
681
+ "network": {
682
+ "anyOf": [
683
+ {
684
+ "type": "string"
685
+ },
686
+ {
687
+ "type": "null"
688
+ }
689
+ ]
690
+ },
691
+ "protocol_version": {
692
+ "anyOf": [
693
+ {
694
+ "type": "string"
695
+ },
696
+ {
697
+ "type": "null"
698
+ }
699
+ ],
700
+ "description": "Chain protocol version observed on the current network (null when the chain was unreachable)"
701
+ },
702
+ "system_state_version": {
703
+ "anyOf": [
704
+ {
705
+ "type": "string"
706
+ },
707
+ {
708
+ "type": "null"
709
+ }
710
+ ],
711
+ "description": "System state data-structure version observed (null when unreachable)"
712
+ },
713
+ "epoch": {
714
+ "anyOf": [
715
+ {
716
+ "type": "string"
717
+ },
718
+ {
719
+ "type": "null"
720
+ }
721
+ ],
722
+ "description": "Current epoch observed (null when unreachable)"
723
+ },
724
+ "fetched": {
725
+ "type": "boolean",
726
+ "description": "false when the chain was unreachable — the null fields then carry no meaning and must not be quoted"
727
+ },
728
+ "fetched_at": {
729
+ "anyOf": [
730
+ {
731
+ "type": "string"
732
+ },
733
+ {
734
+ "type": "null"
735
+ }
736
+ ]
737
+ }
738
+ },
739
+ "additionalProperties": false
740
+ },
741
+ {
742
+ "type": "null"
743
+ }
744
+ ]
745
+ }
746
+ },
747
+ "additionalProperties": false,
748
+ "description": "The fingerprint a test report recorded — supply it to COMPARE that report against the current build"
749
+ }
750
+ },
751
+ "required": [
752
+ "info"
753
+ ],
754
+ "additionalProperties": false,
755
+ "description": "Build fingerprint - CAPTURE (no compare): returns the current build identity (templates version + git state + src/dist staleness + chain stamp) to record verbatim in a test-report header, one call, no LLM. COMPARE (with compare): diffs a report's recorded fingerprint against the current build - verdict stale or incomparable sets downgrades_findings=true, meaning the report's findings must be marked \"pending retest\" instead of triaged against current code (deployment-skew gate, yfd ruling 2026-10-24). Call CAPTURE at the start of a test round and COMPARE before triaging an AI test report."
635
756
  }
636
757
  ]
637
758
  }
@@ -0,0 +1,28 @@
1
+ import { type WorkspaceStaleness, type ChainStamp } from "./upgrade-check.js";
2
+ export interface GitState {
3
+ describe: string | null;
4
+ branch: string | null;
5
+ dirty: boolean | null;
6
+ }
7
+ export interface BuildFingerprint {
8
+ builtin_templates_version: number;
9
+ git: GitState;
10
+ mcp_dist_stale: WorkspaceStaleness | null;
11
+ sdk_dist_stale: WorkspaceStaleness | null;
12
+ captured_at: string;
13
+ }
14
+ export declare function captureGitState(): GitState;
15
+ export declare function currentBuildFingerprint(): BuildFingerprint;
16
+ export interface FingerprintComparison {
17
+ verdict: "current" | "stale" | "incomparable";
18
+ downgrades_findings: boolean;
19
+ skews: string[];
20
+ }
21
+ export type ReportedFingerprint = {
22
+ builtin_templates_version?: number;
23
+ git?: Partial<GitState> | null;
24
+ chain_stamp?: Pick<ChainStamp, "epoch" | "protocol_version" | "network"> | null;
25
+ };
26
+ export declare function compareReportFingerprint(report: ReportedFingerprint): FingerprintComparison;
27
+ export declare let currentChainEpoch: string | null;
28
+ export declare function setComparisonChainEpoch(epoch: string | null): void;
@@ -0,0 +1 @@
1
+ import{execSync}from'child_process';import{join}from'path';import{fileURLToPath}from'url';import{dirname}from'path';import{BUILTIN_TEMPLATES_VERSION}from'../knowledge/builtin-templates.js';import{computeSrcDistStaleness,findSdkPackageDir}from'./upgrade-check.js';const __dirname=dirname(fileURLToPath(import.meta.url)),GIT_TIMEOUT_MS=0xbb8;function git(a){try{const b=execSync('git\x20'+a,{'timeout':GIT_TIMEOUT_MS,'stdio':['ignore','pipe','ignore']}),c=String(b)['trim']();return c['length']>0x0?c:null;}catch{return null;}}export function captureGitState(){const a=git('describe\x20--tags\x20--always\x20--dirty');if(a==null)return{'describe':null,'branch':null,'dirty':null};const b=a['endsWith']('-dirty')?!![]:git('status\x20--porcelain')!=null?![]:null;return{'describe':a,'branch':git('rev-parse\x20--abbrev-ref\x20HEAD'),'dirty':b};}export function currentBuildFingerprint(){return{'builtin_templates_version':BUILTIN_TEMPLATES_VERSION,'git':captureGitState(),'mcp_dist_stale':computeSrcDistStaleness(join(__dirname,'..','..','src'),join(__dirname,'..','..','dist'),{'srcExt':'.ts','distExt':'.js'}),'sdk_dist_stale':((()=>{const a=findSdkPackageDir();return a?computeSrcDistStaleness(join(a,'src'),join(a,'dist')):null;})()),'captured_at':new Date()['toISOString']()};}export function compareReportFingerprint(a){const b=[],c=currentBuildFingerprint();a['builtin_templates_version']!=null&&a['builtin_templates_version']!==BUILTIN_TEMPLATES_VERSION&&b['push']('templates\x20version:\x20report\x20'+a['builtin_templates_version']+'\x20vs\x20current\x20'+BUILTIN_TEMPLATES_VERSION+(a['builtin_templates_version']<BUILTIN_TEMPLATES_VERSION?'\x20(report\x20ran\x20on\x20an\x20older\x20template\x20set\x20—\x20fixed\x20defects\x20may\x20be\x20re-reported)':'\x20(current\x20code\x20is\x20BEHIND\x20the\x20report\x20—\x20checkout/rebuild\x20drift)'));const d=a['git']?.['describe']??null;d!=null&&d!==c['git']['describe']&&b['push']('git\x20state:\x20report\x20\x27'+d+'\x27\x20vs\x20current\x20\x27'+(c['git']['describe']??'(not\x20a\x20repo)')+'\x27');const e=a['chain_stamp']?.['epoch']??null;if(e!=null&&currentChainEpoch==null){}e!=null&&currentChainEpoch!=null&&e!==currentChainEpoch&&b['push']('chain\x20epoch:\x20report\x20'+e+'\x20vs\x20current\x20'+currentChainEpoch+'\x20(rolling\x20update\x20/\x20re-genesis\x20between\x20capture\x20and\x20review)');const f=a['builtin_templates_version']!=null||d!=null||e!=null;if(!f)return{'verdict':'incomparable','downgrades_findings':!![],'skews':['the\x20report\x20recorded\x20no\x20build\x20fingerprint\x20—\x20per\x20the\x20build_stamp\x20rule\x20it\x20cannot\x20claim\x20to\x20describe\x20the\x20current\x20code']};return{'verdict':b['length']>0x0?'stale':'current','downgrades_findings':b['length']>0x0,'skews':b};}export let currentChainEpoch=null;export function setComparisonChainEpoch(a){currentChainEpoch=a;}
@@ -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 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,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}};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'],'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 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'],'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 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
+ 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}};}