@wowok/agent-mcp 3.1.6 → 3.2.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 (235) hide show
  1. package/dist/config/exposure.d.ts +10 -10
  2. package/dist/config/judgment.d.ts +25 -25
  3. package/dist/config/rule-engine.d.ts +25 -25
  4. package/dist/customer/user-preferences.d.ts +2 -2
  5. package/dist/evaluation/arbitration-game.js +1 -1
  6. package/dist/evaluation/capability.d.ts +1 -1
  7. package/dist/evaluation/extract.js +1 -1
  8. package/dist/evaluation/match-operation.js +1 -1
  9. package/dist/extensions/industry-pack.d.ts +3 -2
  10. package/dist/extensions/industry-pack.js +1 -1
  11. package/dist/extensions/modes.js +1 -1
  12. package/dist/extensions/registry.js +1 -1
  13. package/dist/extensions/types.d.ts +1 -0
  14. package/dist/graph/onchain/analyze.js +1 -1
  15. package/dist/graph/onchain/analyze.spec.js +1 -1
  16. package/dist/graph/onchain/edge-schema.js +1 -1
  17. package/dist/graph/onchain/extract.js +1 -1
  18. package/dist/graph/onchain/field-manifest.js +1 -1
  19. package/dist/graph/onchain/project-relationship.js +1 -1
  20. package/dist/graph/onchain/types.d.ts +1 -1
  21. package/dist/harness/recover.js +1 -1
  22. package/dist/keeper/KeeperScan.d.ts +2 -1
  23. package/dist/keeper/KeeperScan.js +1 -1
  24. package/dist/keeper/detectors.d.ts +9 -0
  25. package/dist/keeper/detectors.js +1 -1
  26. package/dist/keeper/keeper.spec.js +1 -1
  27. package/dist/keeper/types.d.ts +1 -1
  28. package/dist/keeper/types.js +1 -1
  29. package/dist/knowledge/allocation-ledger.d.ts +4 -1
  30. package/dist/knowledge/allocation-ledger.js +1 -1
  31. package/dist/knowledge/allocation-puzzle.d.ts +2 -0
  32. package/dist/knowledge/allocation-puzzle.js +1 -1
  33. package/dist/knowledge/allocation-risk.d.ts +1 -1
  34. package/dist/knowledge/allocation-risk.js +1 -1
  35. package/dist/knowledge/arb-risk.d.ts +3 -1
  36. package/dist/knowledge/arb-risk.js +1 -1
  37. package/dist/knowledge/arbitration-ledger.js +1 -1
  38. package/dist/knowledge/arbitration-risk.js +1 -1
  39. package/dist/knowledge/arbitration-templates.d.ts +1 -0
  40. package/dist/knowledge/arbitration-templates.js +1 -1
  41. package/dist/knowledge/audit-rules.d.ts +13 -2
  42. package/dist/knowledge/audit-rules.js +1 -1
  43. package/dist/knowledge/baselines/rules/allocation.json +50 -1
  44. package/dist/knowledge/baselines/rules/arb.json +20 -1
  45. package/dist/knowledge/baselines/rules/arbitration.json +27 -0
  46. package/dist/knowledge/baselines/rules/guard.json +75 -2
  47. package/dist/knowledge/baselines/rules/machine.json +38 -13
  48. package/dist/knowledge/baselines/rules/order.json +2 -2
  49. package/dist/knowledge/builtin-templates.d.ts +3 -1
  50. package/dist/knowledge/builtin-templates.js +1 -1
  51. package/dist/knowledge/event-semantics.js +1 -1
  52. package/dist/knowledge/fund-layer.js +1 -1
  53. package/dist/knowledge/getting-started.js +1 -1
  54. package/dist/knowledge/guard-anchor-reach.d.ts +19 -0
  55. package/dist/knowledge/guard-anchor-reach.js +1 -0
  56. package/dist/knowledge/guard-bindings.js +1 -1
  57. package/dist/knowledge/guard-design-patterns.d.ts +1 -1
  58. package/dist/knowledge/guard-design-patterns.js +1 -1
  59. package/dist/knowledge/guard-ledger.js +1 -1
  60. package/dist/knowledge/guard-lint.js +1 -1
  61. package/dist/knowledge/guard-render.d.ts +6 -0
  62. package/dist/knowledge/guard-render.js +1 -1
  63. package/dist/knowledge/guard-risk.js +1 -1
  64. package/dist/knowledge/guard-submission-prompt.d.ts +6 -0
  65. package/dist/knowledge/guard-submission-prompt.js +1 -1
  66. package/dist/knowledge/guard-templates.d.ts +1 -1
  67. package/dist/knowledge/guard-templates.js +1 -1
  68. package/dist/knowledge/index.d.ts +4 -4
  69. package/dist/knowledge/index.js +1 -1
  70. package/dist/knowledge/industry-generalizer.js +1 -1
  71. package/dist/knowledge/industry-registry.d.ts +1 -1
  72. package/dist/knowledge/industry-registry.js +1 -1
  73. package/dist/knowledge/jsonrpc-enum.js +1 -1
  74. package/dist/knowledge/machine-ledger.js +1 -1
  75. package/dist/knowledge/machine-risk.js +1 -1
  76. package/dist/knowledge/machine-templates.js +1 -1
  77. package/dist/knowledge/order-ledger.js +1 -1
  78. package/dist/knowledge/order-templates.js +1 -1
  79. package/dist/knowledge/permission-ledger.js +1 -1
  80. package/dist/knowledge/release-sentinel.d.ts +12 -0
  81. package/dist/knowledge/release-sentinel.js +1 -0
  82. package/dist/knowledge/repository-write-semantics.d.ts +27 -0
  83. package/dist/knowledge/repository-write-semantics.js +1 -0
  84. package/dist/knowledge/rule-node-analyzers.d.ts +6 -0
  85. package/dist/knowledge/rule-node-analyzers.js +1 -1
  86. package/dist/knowledge/safety-rules.d.ts +5 -1
  87. package/dist/knowledge/safety-rules.js +1 -1
  88. package/dist/knowledge/scenario-modes.d.ts +10 -1
  89. package/dist/knowledge/scenario-modes.js +1 -1
  90. package/dist/knowledge/service-allocation-semantics.d.ts +36 -0
  91. package/dist/knowledge/service-allocation-semantics.js +1 -0
  92. package/dist/knowledge/strategy-manuals.d.ts +3 -5
  93. package/dist/knowledge/strategy-manuals.js +1 -1
  94. package/dist/knowledge/template-loader.d.ts +28 -12
  95. package/dist/knowledge/template-loader.js +1 -1
  96. package/dist/knowledge/template-registry.js +1 -1
  97. package/dist/knowledge/template-scanner.js +1 -1
  98. package/dist/knowledge/tools-reference.js +1 -1
  99. package/dist/knowledge/workflow-guidance.d.ts +26 -0
  100. package/dist/knowledge/workflow-guidance.js +1 -1
  101. package/dist/monitor/MonitorLoop.js +1 -1
  102. package/dist/participation/allocation-advice.d.ts +38 -0
  103. package/dist/participation/allocation-advice.js +1 -0
  104. package/dist/participation/radar-core.d.ts +2 -0
  105. package/dist/persona/types.d.ts +3 -2
  106. package/dist/persona/types.js +1 -1
  107. package/dist/playbooks/service-build/business-puzzle.js +1 -1
  108. package/dist/playbooks/service-build/intent-analyzer.js +1 -1
  109. package/dist/playbooks/service-build/merchant-guide.d.ts +70 -63
  110. package/dist/playbooks/service-build/merchant-guide.js +1 -1
  111. package/dist/playbooks/service-build/migration-planner.js +1 -1
  112. package/dist/playbooks/service-build/mode-actions.d.ts +5 -0
  113. package/dist/playbooks/service-build/mode-actions.js +1 -1
  114. package/dist/playbooks/service-build/participation-radar.js +1 -1
  115. package/dist/playbooks/service-build/semantic-graph.d.ts +1 -0
  116. package/dist/playbooks/service-build/semantic-graph.js +1 -1
  117. package/dist/playbooks/service-build/service-quote.d.ts +2 -0
  118. package/dist/playbooks/service-build/service-quote.js +1 -0
  119. package/dist/relationship/derivation.d.ts +1 -1
  120. package/dist/safety/confirm-gate.js +1 -1
  121. package/dist/schema/benchmark-migration/index.d.ts +30 -8
  122. package/dist/schema/benchmark-migration/index.js +1 -1
  123. package/dist/schema/call/allocation.d.ts +6 -3
  124. package/dist/schema/call/arbitration.js +1 -1
  125. package/dist/schema/call/base.d.ts +4 -0
  126. package/dist/schema/call/base.js +1 -1
  127. package/dist/schema/call/bridge.d.ts +1 -0
  128. package/dist/schema/call/error-codes.d.ts +1 -1
  129. package/dist/schema/call/error-codes.js +1 -1
  130. package/dist/schema/call/guard.d.ts +8 -8
  131. package/dist/schema/call/machine.d.ts +56 -0
  132. package/dist/schema/call/machine.js +1 -1
  133. package/dist/schema/call/order.js +1 -1
  134. package/dist/schema/call/payment.js +1 -1
  135. package/dist/schema/call/semantic.js +1 -1
  136. package/dist/schema/call/service.d.ts +84 -22
  137. package/dist/schema/call/service.js +1 -1
  138. package/dist/schema/common/index.js +1 -1
  139. package/dist/schema/common/tokentype-short-probe.spec.js +1 -0
  140. package/dist/schema/evaluation/index.d.ts +8 -80
  141. package/dist/schema/evaluation/index.js +1 -1
  142. package/dist/schema/goal/index.d.ts +9 -42
  143. package/dist/schema/goal/planning.d.ts +25 -60
  144. package/dist/schema/goal/planning.js +1 -1
  145. package/dist/schema/intent-radar/index.d.ts +2 -20
  146. package/dist/schema/intent-radar/index.js +1 -1
  147. package/dist/schema/interaction/index.d.ts +1 -1
  148. package/dist/schema/keeper/index.d.ts +3 -0
  149. package/dist/schema/keeper/index.js +1 -1
  150. package/dist/schema/local/index.d.ts +8 -0
  151. package/dist/schema/local/index.js +1 -1
  152. package/dist/schema/local/wip.d.ts +73 -0
  153. package/dist/schema/local/wip.js +1 -1
  154. package/dist/schema/operations.d.ts +92 -14
  155. package/dist/schema/operations.js +1 -1
  156. package/dist/schema/persona/index.d.ts +279 -384
  157. package/dist/schema/persona/index.js +1 -1
  158. package/dist/schema/query/bi.d.ts +149 -10
  159. package/dist/schema/query/bi.js +1 -1
  160. package/dist/schema/query/index.d.ts +38 -19
  161. package/dist/schema/query/index.js +1 -1
  162. package/dist/schema/schema-query/index.d.ts +4 -4
  163. package/dist/schema/schema-version.js +1 -1
  164. package/dist/schema/watch/index.d.ts +2 -2
  165. package/dist/schema-query-impl/index.d.ts +1 -0
  166. package/dist/schema-query-impl/index.js +1 -1
  167. package/dist/schemas/account_operation.output.json +3 -2
  168. package/dist/schemas/benchmark_migration_operation.output.json +116 -2
  169. package/dist/schemas/benchmark_migration_operation.schema.json +2 -10
  170. package/dist/schemas/bridge_operation.output.json +3 -2
  171. package/dist/schemas/evaluation_operation.schema.json +7 -70
  172. package/dist/schemas/goal_operation.schema.json +6 -39
  173. package/dist/schemas/index.json +1 -1
  174. package/dist/schemas/intent_radar.output.json +4 -20
  175. package/dist/schemas/keeper_operation.output.json +2 -2
  176. package/dist/schemas/keeper_operation.schema.json +9 -4
  177. package/dist/schemas/local_history_operation.output.json +3 -2
  178. package/dist/schemas/local_info_operation.output.json +3 -2
  179. package/dist/schemas/local_mark_operation.output.json +3 -2
  180. package/dist/schemas/messenger_operation.output.json +2 -2
  181. package/dist/schemas/monitor_events.output.json +2 -2
  182. package/dist/schemas/monitor_subscription.output.json +2 -2
  183. package/dist/schemas/onchain_events.output.json +2 -2
  184. package/dist/schemas/onchain_operations.output.json +7 -6
  185. package/dist/schemas/onchain_operations.schema.json +227 -54
  186. package/dist/schemas/onchain_operations_allocation.schema.json +11 -10
  187. package/dist/schemas/onchain_operations_arbitration.schema.json +13 -13
  188. package/dist/schemas/onchain_operations_machine.schema.json +27 -5
  189. package/dist/schemas/onchain_operations_order.schema.json +1 -1
  190. package/dist/schemas/onchain_operations_payment.schema.json +2 -2
  191. package/dist/schemas/onchain_operations_reward.schema.json +1 -1
  192. package/dist/schemas/onchain_operations_service.schema.json +171 -21
  193. package/dist/schemas/onchain_operations_treasury.schema.json +1 -1
  194. package/dist/schemas/onchain_table_data.output.json +57 -4
  195. package/dist/schemas/persona_operation.output.json +11 -88
  196. package/dist/schemas/persona_operation.schema.json +4 -32
  197. package/dist/schemas/query_toolkit.output.json +320 -22
  198. package/dist/schemas/query_toolkit.schema.json +53 -0
  199. package/dist/schemas/wip_file.output.json +221 -0
  200. package/dist/schemas/wip_file.schema.json +125 -0
  201. package/dist/tools/handlers/benchmark-migration.js +1 -1
  202. package/dist/tools/handlers/config.js +1 -1
  203. package/dist/tools/handlers/dispatch-expectations.spec.js +1 -1
  204. package/dist/tools/handlers/keeper.d.ts +1 -1
  205. package/dist/tools/handlers/onchain.js +1 -1
  206. package/dist/tools/handlers/query.js +1 -1
  207. package/dist/tools/handlers/schema-query.js +1 -1
  208. package/dist/tools/handlers/wip-upload.d.ts +22 -0
  209. package/dist/tools/handlers/wip-upload.js +1 -0
  210. package/dist/tools/handlers/wip.js +1 -1
  211. package/dist/tools/index.js +1 -1
  212. package/dist/tools/move-fn-index.gen.js +1 -1
  213. package/dist/tools/registry/business.js +1 -1
  214. package/dist/tools/registry/files.js +1 -1
  215. package/dist/tools/wip-deploy-assist.js +1 -1
  216. package/dist/tools/wrap.js +1 -1
  217. package/package.json +2 -2
  218. package/dist/knowledge/alloc-audit-policy.spec.js +0 -1
  219. package/dist/knowledge/event-semantics.spec.d.ts +0 -1
  220. package/dist/knowledge/event-semantics.spec.js +0 -1
  221. package/dist/knowledge/facts-sync.spec.d.ts +0 -1
  222. package/dist/knowledge/facts-sync.spec.js +0 -1
  223. package/dist/knowledge/guard-design-patterns.spec.d.ts +0 -1
  224. package/dist/knowledge/guard-design-patterns.spec.js +0 -1
  225. package/dist/knowledge/guard-eval.spec.d.ts +0 -1
  226. package/dist/knowledge/guard-eval.spec.js +0 -1
  227. package/dist/knowledge/rule-node-analyzers.spec.d.ts +0 -1
  228. package/dist/knowledge/rule-node-analyzers.spec.js +0 -1
  229. package/dist/knowledge/safety-rules.extract-amount.spec.d.ts +0 -1
  230. package/dist/knowledge/safety-rules.extract-amount.spec.js +0 -1
  231. package/dist/knowledge/template-loader.spec.d.ts +0 -1
  232. package/dist/knowledge/template-loader.spec.js +0 -1
  233. package/dist/knowledge/template-scanner.spec.d.ts +0 -1
  234. package/dist/knowledge/template-scanner.spec.js +0 -1
  235. /package/dist/{knowledge/alloc-audit-policy.spec.d.ts → schema/common/tokentype-short-probe.spec.d.ts} +0 -0
@@ -1 +1 @@
1
- import{z}from'zod';import{handleWipOperations}from'../handlers/wip.js';import{handleGuard2File,handleMachineNode2File}from'../handlers/file-export.js';import{strictStatusErrorShape}from'../wrap.js';import{createToolMeta,WipOperationsSchema,WipOperationOutputSchema,Guard2File_InputSchema,Guard2File_OutputWrappedSchema,MachineNode2File_InputSchema,MachineNode2File_OutputWrappedSchema}from'../../schema/index.js';export const FILE_TOOLS=[{'name':'wip_file','handler':handleWipOperations,'config':{'title':'🤝\x20Witness\x20Immutable\x20Promise\x20File\x20Operations','summary':'WIP\x20promise\x20file\x20operations:\x20generate,\x20verify,\x20sign,\x20wip2html.','description':'generate\x20(create\x20WIP\x20files\x20from\x20markdown\x20and\x20images),\x20verify\x20(integrity\x20check),\x20sign\x20(add\x20signatures),\x20or\x20wip2html\x20(convert\x20to\x20HTML).\x0a\x0a⚠️\x20IMPORTANT\x20—\x20On-chain\x20WIP\x20URL\x20requirement:\x20When\x20using\x20a\x20WIP\x20file\x20URL\x20in\x20`service.sales[].wip`\x20(stored\x20on-chain),\x20the\x20URL\x20MUST\x20be\x20publicly\x20reachable.\x20Local\x20file\x20paths\x20(e.g.,\x20\x27C:\x5c\x5cpath\x5c\x5cfile.wip\x27\x20or\x20\x27/home/user/file.wip\x27)\x20are\x20NOT\x20acceptable\x20on-chain\x20—\x20they\x20only\x20work\x20locally\x20and\x20will\x20fail\x20verification\x20for\x20buyers.\x0a\x0aDeployment\x20options\x20for\x20the\x20.wip\x20file:\x0a\x20\x20•\x20GitHub\x20Pages:\x20https://raw.githubusercontent.com/<user>/<repo>/<branch>/<file>.wip\x0a\x20\x20•\x20IPFS:\x20https://ipfs.io/ipfs/<CID>\x20or\x20https://cloudflare-ipfs.com/ipfs/<CID>\x20(upload\x20via\x20pinata.cloud)\x0a\x20\x20•\x20User\x27s\x20own\x20static\x20website\x20URL\x0a\x0aUse\x20type=\x27generate\x27\x20to\x20create\x20the\x20WIP\x20file\x20first,\x20upload\x20it\x20to\x20any\x20of\x20the\x20above,\x20then\x20use\x20the\x20resulting\x20URL\x20in\x20service.sales[].wip.\x0a\x0a💡\x20Schema\x20hint:\x20Use\x20schema_query\x20with\x20action=\x27get\x27\x20and\x20name=\x27wip_file\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema\x20before\x20calling.','inputSchema':WipOperationsSchema,'outputSchema':z['object']({'result':WipOperationOutputSchema}),'annotations':{'readOnlyHint':![],'destructiveHint':![],'idempotentHint':![],'openWorldHint':![]},'_meta':createToolMeta('operation',['wip','promise','file-generation','verification','signature','local'])}},{'name':'guard2file','handler':handleGuard2File,'config':{'title':'📄\x20Guard\x20to\x20File\x20-\x20Export\x20Guard\x20Definition','summary':'Export\x20guard\x20rules\x20to\x20a\x20local\x20JSON/Markdown\x20file.','description':'Export\x20a\x20Guard\x20object\x27s\x20definition\x20from\x20the\x20blockchain\x20to\x20a\x20local\x20JSON\x20or\x20Markdown\x20file\x20for\x20editing\x20and\x20creating\x20new\x20Guard\x20objects.\x20Note:\x20To\x20query\x20on-chain\x20object\x20information,\x20use\x20the\x20\x27query_toolkit\x27\x20tool\x20instead.\x0a\x0a💡\x20Schema\x20hint:\x20Use\x20schema_query\x20with\x20action=\x27get\x27\x20and\x20name=\x27guard2file\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema\x20before\x20calling.','inputSchema':Guard2File_InputSchema,'outputSchema':Guard2File_OutputWrappedSchema,'annotations':{'readOnlyHint':!![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':!![]},'_meta':createToolMeta('generate\x20file',['guard','export','file','json','markdown','on-chain'])},'errorShapeBuilder':strictStatusErrorShape},{'name':'machineNode2file','handler':handleMachineNode2File,'config':{'title':'⚙️\x20Machine\x20Node\x20to\x20File\x20-\x20Export\x20Machine\x20Node\x20Definition','summary':'Export\x20machine\x20nodes\x20to\x20a\x20local\x20JSON/Markdown\x20file.','description':'Export\x20a\x20Machine\x20object\x27s\x20node\x20definition\x20from\x20the\x20blockchain\x20to\x20a\x20local\x20JSON\x20or\x20Markdown\x20file\x20for\x20editing\x20and\x20creating\x20new\x20Machine\x20objects.\x20Note:\x20To\x20query\x20on-chain\x20object\x20information,\x20use\x20the\x20\x27query_toolkit\x27\x20tool\x20instead.\x0a\x0a💡\x20Schema\x20hint:\x20Use\x20schema_query\x20with\x20action=\x27get\x27\x20and\x20name=\x27machineNode2file\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema\x20before\x20calling.','inputSchema':MachineNode2File_InputSchema,'outputSchema':MachineNode2File_OutputWrappedSchema,'annotations':{'readOnlyHint':!![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':!![]},'_meta':createToolMeta('generate\x20file',['machine','export','file','json','markdown','on-chain','workflow'])},'errorShapeBuilder':strictStatusErrorShape}];
1
+ import{z}from'zod';import{handleWipOperations}from'../handlers/wip.js';import{handleGuard2File,handleMachineNode2File}from'../handlers/file-export.js';import{strictStatusErrorShape}from'../wrap.js';import{createToolMeta,WipOperationsSchema,WipOperationOutputSchema,Guard2File_InputSchema,Guard2File_OutputWrappedSchema,MachineNode2File_InputSchema,MachineNode2File_OutputWrappedSchema}from'../../schema/index.js';export const FILE_TOOLS=[{'name':'wip_file','handler':handleWipOperations,'config':{'title':'🤝\x20Witness\x20Immutable\x20Promise\x20File\x20Operations','summary':'WIP\x20promise\x20file\x20operations:\x20generate,\x20verify,\x20sign,\x20wip2html,\x20upload/list/delete\x20on\x20wip\x20storage.','description':'generate\x20(create\x20WIP\x20files\x20from\x20markdown\x20and\x20images),\x20verify\x20(integrity\x20check),\x20sign\x20(add\x20signatures),\x20wip2html\x20(convert\x20to\x20HTML),\x20or\x20storage\x20operations:\x20upload\x20/\x20storage_list\x20/\x20storage_delete.\x0a\x0aStorage\x20options\x20for\x20type=\x27upload\x27:\x0a\x20\x20•\x20storage=\x27store\x27\x20(default):\x20official\x20FREE\x20store\x20wip.store.wowok.net\x20—\x20zero\x20setup,\x20files\x20get\x20a\x20public\x20hash-addressed\x20URL\x20(https://wip.store.wowok.net/f/{hash}).\x20Free\x20tier\x20limited\x20to\x2010\x20files\x20per\x20account;\x20when\x20the\x20quota\x20is\x20hit\x20the\x20error\x20returns\x20the\x20stored\x20file\x20list\x20for\x20deletion\x20(use\x20storage_delete).\x20Declaration:\x20files\x20are\x20retained\x20for\x206\x20months\x20(180\x20days);\x20free\x20best-effort\x20service\x20—\x20availability\x20and\x20data\x20survival\x20are\x20not\x20guaranteed\x20(force\x20majeure\x20excepted);\x20expired\x20files\x20are\x20NEVER\x20deleted\x20automatically\x20(manual\x20administrator\x20purge\x20only).\x0a\x20\x20•\x20storage=\x27custom\x27\x20(recommended):\x20your\x20own\x20or\x20any\x20third-party\x20wip-storage-compatible\x20service\x20via\x20customBaseUrl\x20—\x20no\x20store\x20quota,\x20full\x20control,\x20permanent\x20self-managed\x20hosting.\x0a\x0a🌐\x20Network\x20independence:\x20WIP\x20files\x20are\x20OFF-CHAIN\x20—\x20the\x20same\x20public\x20URL\x20and\x20the\x20same\x20stored\x20files\x20work\x20on\x20BOTH\x20testnet\x20and\x20mainnet;\x20storage_list/storage_delete\x20authenticate\x20with\x20the\x20account\x20key\x20and\x20never\x20touch\x20the\x20chain.\x0a\x0a⚠️\x20Large\x20WIP\x20files\x20(multi-MB,\x20image-heavy)\x20are\x20sensitive\x20to\x20network\x20conditions:\x20keep\x20files\x20small\x20(compress\x20images\x20before\x20generate;\x20each\x20image\x20≤\x202MB,\x20total\x20≤\x2010MB),\x20expect\x20longer\x20upload\x20times,\x20retry\x20on\x20transient\x20network\x20failures,\x20and\x20confirm\x20reachability\x20afterwards\x20with\x20type=\x27verify\x27\x20on\x20the\x20returned\x20public\x20URL.\x0a\x0a⚠️\x20IMPORTANT\x20—\x20On-chain\x20WIP\x20URL\x20requirement:\x20When\x20using\x20a\x20WIP\x20file\x20URL\x20in\x20`service.sales[].wip`\x20(stored\x20on-chain),\x20the\x20URL\x20MUST\x20be\x20publicly\x20reachable.\x20Local\x20file\x20paths\x20(e.g.,\x20\x27C:\x5c\x5cpath\x5c\x5cfile.wip\x27\x20or\x20\x27/home/user/file.wip\x27)\x20are\x20NOT\x20acceptable\x20on-chain\x20—\x20they\x20only\x20work\x20locally\x20and\x20will\x20fail\x20verification\x20for\x20buyers.\x0a\x0aDeployment\x20options\x20for\x20the\x20.wip\x20file:\x0a\x20\x20•\x20wip\x20storage\x20service\x20(type=\x27upload\x27)\x20—\x20preferred,\x20gives\x20a\x20stable\x20public\x20URL\x0a\x20\x20•\x20GitHub\x20Pages:\x20https://raw.githubusercontent.com/<user>/<repo>/<branch>/<file>.wip\x0a\x20\x20•\x20IPFS:\x20https://ipfs.io/ipfs/<CID>\x20or\x20https://cloudflare-ipfs.com/ipfs/<CID>\x20(upload\x20via\x20pinata.cloud)\x0a\x20\x20•\x20User\x27s\x20own\x20static\x20website\x20URL\x0a\x0aUse\x20type=\x27generate\x27\x20to\x20create\x20the\x20WIP\x20file,\x20sign\x20it\x20with\x20type=\x27sign\x27,\x20upload\x20with\x20type=\x27upload\x27,\x20then\x20use\x20the\x20resulting\x20URL\x20in\x20service.sales[].wip.\x0a\x0a💡\x20Schema\x20hint:\x20Use\x20schema_query\x20with\x20action=\x27get\x27\x20and\x20name=\x27wip_file\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema\x20before\x20calling.','inputSchema':WipOperationsSchema,'outputSchema':z['object']({'result':WipOperationOutputSchema}),'annotations':{'readOnlyHint':![],'destructiveHint':![],'idempotentHint':![],'openWorldHint':!![]},'_meta':createToolMeta('operation',['wip','promise','file-generation','verification','signature','upload','storage','wip.store.wowok.net'])}},{'name':'guard2file','handler':handleGuard2File,'config':{'title':'📄\x20Guard\x20to\x20File\x20-\x20Export\x20Guard\x20Definition','summary':'Export\x20guard\x20rules\x20to\x20a\x20local\x20JSON/Markdown\x20file.','description':'Export\x20a\x20Guard\x20object\x27s\x20definition\x20from\x20the\x20blockchain\x20to\x20a\x20local\x20JSON\x20or\x20Markdown\x20file\x20for\x20editing\x20and\x20creating\x20new\x20Guard\x20objects.\x20Note:\x20To\x20query\x20on-chain\x20object\x20information,\x20use\x20the\x20\x27query_toolkit\x27\x20tool\x20instead.\x0a\x0a💡\x20Schema\x20hint:\x20Use\x20schema_query\x20with\x20action=\x27get\x27\x20and\x20name=\x27guard2file\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema\x20before\x20calling.','inputSchema':Guard2File_InputSchema,'outputSchema':Guard2File_OutputWrappedSchema,'annotations':{'readOnlyHint':!![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':!![]},'_meta':createToolMeta('generate\x20file',['guard','export','file','json','markdown','on-chain'])},'errorShapeBuilder':strictStatusErrorShape},{'name':'machineNode2file','handler':handleMachineNode2File,'config':{'title':'⚙️\x20Machine\x20Node\x20to\x20File\x20-\x20Export\x20Machine\x20Node\x20Definition','summary':'Export\x20machine\x20nodes\x20to\x20a\x20local\x20JSON/Markdown\x20file.','description':'Export\x20a\x20Machine\x20object\x27s\x20node\x20definition\x20from\x20the\x20blockchain\x20to\x20a\x20local\x20JSON\x20or\x20Markdown\x20file\x20for\x20editing\x20and\x20creating\x20new\x20Machine\x20objects.\x20Note:\x20To\x20query\x20on-chain\x20object\x20information,\x20use\x20the\x20\x27query_toolkit\x27\x20tool\x20instead.\x0a\x0a💡\x20Schema\x20hint:\x20Use\x20schema_query\x20with\x20action=\x27get\x27\x20and\x20name=\x27machineNode2file\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema\x20before\x20calling.','inputSchema':MachineNode2File_InputSchema,'outputSchema':MachineNode2File_OutputWrappedSchema,'annotations':{'readOnlyHint':!![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':!![]},'_meta':createToolMeta('generate\x20file',['machine','export','file','json','markdown','on-chain','workflow'])},'errorShapeBuilder':strictStatusErrorShape}];
@@ -1 +1 @@
1
- export function classifyWipPath(a){if(!a||typeof a!=='string')return{'type':'unknown','is_local':![],'is_network':![],'description':'Empty\x20or\x20invalid\x20path'};if(a['startsWith']('data:'))return{'type':'data_url','is_local':![],'is_network':!![],'description':'Data\x20URL\x20—\x20embedded\x20content,\x20globally\x20reachable'};if(a['startsWith']('ipfs://'))return{'type':'ipfs','is_local':![],'is_network':!![],'description':'IPFS\x20URI\x20—\x20resolve\x20via\x20any\x20public\x20gateway'};const b=[/^https?:\/\/ipfs\.io\//i,/^https?:\/\/cloudflare-ipfs\.com\//i,/^https?:\/\/gateway\.pinata\.cloud\//i,/^https?:\/\/dweb\.link\//i,/^https?:\/\/[^/]*pinata\.cloud\//i];if(b['some'](d=>d['test'](a)))return{'type':'ipfs','is_local':![],'is_network':!![],'description':'IPFS\x20HTTP\x20gateway\x20URL\x20—\x20globally\x20reachable'};if(/^https?:\/\/(localhost|127\.0\.0\.1|\[::1\]|0\.0\.0\.0)([:/]|$)/i['test'](a))return{'type':'local_http','is_local':!![],'is_network':![],'description':'Local\x20HTTP\x20URL\x20(localhost/loopback)\x20—\x20reachable\x20only\x20on\x20this\x20machine,\x20NOT\x20by\x20customers'};const c=/^https?:\/\/(10\.\d{1,3}\.\d{1,3}\.\d{1,3}|172\.(1[6-9]|2\d|3[01])\.\d{1,3}\.\d{1,3}|192\.168\.\d{1,3}\.\d{1,3})([:/]|$)/i;if(c['test'](a))return{'type':'local_http','is_local':!![],'is_network':![],'description':'LAN\x20HTTP\x20URL\x20(private\x20IP)\x20—\x20reachable\x20only\x20on\x20the\x20local\x20network,\x20NOT\x20by\x20customers'};if(/^https?:\/\//i['test'](a))return{'type':'http_url','is_local':![],'is_network':!![],'description':'HTTP(S)\x20URL\x20—\x20globally\x20reachable\x20if\x20server\x20returns\x20200'};if(/^[A-Za-z]:[\\/]/['test'](a))return{'type':'local_windows','is_local':!![],'is_network':![],'description':'Windows\x20local\x20path\x20—\x20NOT\x20reachable\x20by\x20customers/AI'};if(a['startsWith']('/'))return{'type':'local_unix','is_local':!![],'is_network':![],'description':'Unix\x20local\x20path\x20—\x20NOT\x20reachable\x20by\x20customers/AI'};if(a['startsWith']('./')||a['startsWith']('../')||a==='.'||a==='..')return{'type':'local_relative','is_local':!![],'is_network':![],'description':'Relative\x20local\x20path\x20—\x20NOT\x20reachable\x20by\x20customers/AI'};if(!a['includes']('://')&&!a['startsWith']('data:'))return{'type':'local_relative','is_local':!![],'is_network':![],'description':'Local\x20file\x20path\x20(no\x20scheme)\x20—\x20NOT\x20reachable\x20by\x20customers/AI'};return{'type':'unknown','is_local':![],'is_network':![],'description':'Unrecognized\x20path\x20format'};}export function getDeployOptions(a){const b=a['replace'](/'/g,'\x27\x5c\x27\x27'),c=a['split'](/[\\/]/)['pop']()||'file.wip';return[{'name':'GitHub\x20Pages\x20(Recommended)','description':'Upload\x20the\x20.wip\x20file\x20to\x20a\x20GitHub\x20repository\x20and\x20serve\x20it\x20via\x20GitHub\x20Pages.\x20'+'Free,\x20stable,\x20HTTPS-enabled,\x20no\x20expiration.','difficulty':'easy','free':!![],'result_url_pattern':'https://<your-username>.github.io/<repo>/<file>.wip','steps':['//\x201.\x20Create\x20a\x20new\x20GitHub\x20repository\x20(e.g.,\x20\x27wowok-wip\x27)\x20via\x20https://github.com/new','//\x202.\x20Make\x20it\x20PUBLIC\x20so\x20the\x20file\x20is\x20world-readable.','//\x203.\x20Copy\x20your\x20local\x20WIP\x20file\x20into\x20the\x20repo:','git\x20clone\x20https://github.com/<your-username>/wowok-wip.git','cp\x20\x27'+b+'\x27\x20wowok-wip/'+c,'cd\x20wowok-wip','git\x20add\x20'+c,'git\x20commit\x20-m\x20\x22Add\x20WIP\x20file\x22','git\x20push\x20origin\x20main','//\x204.\x20Enable\x20GitHub\x20Pages:\x20repo\x20→\x20Settings\x20→\x20Pages\x20→\x20Source\x20→\x20\x27main\x27\x20branch\x20→\x20/(root)\x20→\x20Save','//\x205.\x20Wait\x2030-60\x20seconds\x20for\x20deployment,\x20then\x20verify\x20the\x20URL\x20is\x20reachable:','curl\x20-I\x20https://<your-username>.github.io/wowok-wip/'+c,'//\x206.\x20Update\x20your\x20Service\x20on-chain\x20with\x20the\x20new\x20public\x20URL:','//\x20\x20\x20\x20Call\x20onchain_operations\x20{\x20operation_type:\x20\x27service\x27,\x20data:\x20{\x20object:\x20\x27<service-id>\x27,\x20sales:\x20{\x20op:\x20\x27set\x27,\x20sales:\x20[{\x20...,\x20wip_url:\x20\x27https://...\x27,\x20wip_hash:\x20\x27<hash>\x27\x20}]\x20}\x20}\x20}'],'notes':['If\x20the\x20repo\x20already\x20has\x20Pages\x20enabled\x20on\x20the\x20main\x20branch,\x20step\x204\x20can\x20be\x20skipped.','GitHub\x20Pages\x20serves\x20files\x20up\x20to\x2025\x20MB\x20—\x20well\x20above\x20typical\x20WIP\x20sizes\x20(<\x201\x20MB).','URL\x20is\x20case-sensitive;\x20ensure\x20the\x20filename\x20in\x20the\x20URL\x20matches\x20exactly.']},{'name':'IPFS\x20via\x20Pinata\x20(Free\x20gateway)','description':'Upload\x20the\x20.wip\x20file\x20to\x20IPFS\x20through\x20Pinata\x27s\x20free\x20gateway.\x20'+'Content-addressed\x20—\x20the\x20CID\x20hash\x20also\x20serves\x20as\x20an\x20integrity\x20check.','difficulty':'medium','free':!![],'result_url_pattern':'https://gateway.pinata.cloud/ipfs/<CID>\x20\x20(or\x20\x20https://ipfs.io/ipfs/<CID>)','steps':['//\x201.\x20Sign\x20up\x20for\x20a\x20free\x20Pinata\x20account\x20at\x20https://app.pinata.cloud/\x20(1\x20GB\x20free\x20storage).','//\x202.\x20Get\x20your\x20API\x20key\x20from\x20https://app.pinata.cloud/keys\x20(generate\x20a\x20new\x20key\x20with\x20\x27pinFileToIPFS\x27\x20scope).','//\x203.\x20Upload\x20your\x20local\x20WIP\x20file\x20via\x20curl:','curl\x20-X\x20POST\x20https://api.pinata.cloud/pinning/pinFileToIPFS\x20\x5c','\x20\x20-H\x20\x22Authorization:\x20Bearer\x20<YOUR_PINATA_API_KEY>\x22\x20\x5c','\x20\x20-F\x20\x22file=@\x27'+b+'\x27\x22','//\x204.\x20Pinata\x20returns\x20JSON\x20with\x20\x27IpfsHash\x27\x20(the\x20CID).\x20Extract\x20it:','//\x20\x20\x20\x20Example\x20response:\x20{\x20\x22IpfsHash\x22:\x20\x22QmXYZ...\x22,\x20\x22PinSize\x22:\x2012345,\x20\x22Timestamp\x22:\x20\x22...\x22\x20}','//\x205.\x20Verify\x20the\x20file\x20is\x20reachable\x20via\x20the\x20public\x20gateway:','curl\x20-I\x20https://gateway.pinata.cloud/ipfs/<CID>','//\x206.\x20(Optional)\x20Use\x20ipfs://<CID>\x20as\x20the\x20wip_url\x20—\x20the\x20SDK\x20resolves\x20it.','//\x207.\x20Update\x20your\x20Service\x20on-chain\x20with\x20the\x20IPFS\x20URL\x20or\x20CID:','//\x20\x20\x20\x20Call\x20onchain_operations\x20{\x20operation_type:\x20\x27service\x27,\x20data:\x20{\x20object:\x20\x27<service-id>\x27,\x20sales:\x20{\x20op:\x20\x27set\x27,\x20sales:\x20[{\x20...,\x20wip_url:\x20\x27https://gateway.pinata.cloud/ipfs/<CID>\x27,\x20wip_hash:\x20\x27<hash>\x27\x20}]\x20}\x20}\x20}'],'notes':['Pinata\x20free\x20tier:\x201\x20GB\x20storage,\x20100\x20uploads/day\x20—\x20sufficient\x20for\x20WIP\x20files.','For\x20long-term\x20durability,\x20also\x20pin\x20via\x20another\x20gateway\x20(e.g.,\x20nft.storage).','IPFS\x20CIDs\x20are\x20content-addressed\x20—\x20if\x20the\x20file\x20changes,\x20the\x20CID\x20changes.\x20This\x20is\x20a\x20feature,\x20not\x20a\x20bug.']},{'name':'User\x27s\x20own\x20website\x20/\x20static\x20host','description':'If\x20you\x20already\x20operate\x20a\x20website\x20or\x20static\x20host\x20(e.g.,\x20nginx,\x20Vercel,\x20Netlify,\x20Cloudflare\x20Pages),\x20'+'upload\x20the\x20.wip\x20file\x20there\x20and\x20use\x20its\x20public\x20URL.','difficulty':'medium','free':!![],'result_url_pattern':'https://<your-domain>/<path>/<file>.wip','steps':['//\x201.\x20Copy\x20your\x20local\x20WIP\x20file\x20to\x20your\x20web\x20server\x27s\x20static\x20directory:','scp\x20\x27'+b+'\x27\x20user@your-server:/var/www/html/wowok/'+c,'//\x202.\x20Ensure\x20the\x20server\x20sets\x20Content-Type:\x20application/json\x20(or\x20application/octet-stream)\x20for\x20.wip\x20files.','//\x20\x20\x20\x20For\x20nginx,\x20add\x20to\x20your\x20server\x20block:','//\x20\x20\x20\x20\x20\x20\x20\x20location\x20~\x20\x5c.wip$\x20{\x20default_type\x20application/json;\x20}','//\x203.\x20Verify\x20the\x20file\x20is\x20reachable:','curl\x20-I\x20https://<your-domain>/wowok/'+c,'//\x204.\x20Update\x20your\x20Service\x20on-chain\x20with\x20the\x20new\x20public\x20URL:','//\x20\x20\x20\x20Call\x20onchain_operations\x20{\x20operation_type:\x20\x27service\x27,\x20data:\x20{\x20object:\x20\x27<service-id>\x27,\x20sales:\x20{\x20op:\x20\x27set\x27,\x20sales:\x20[{\x20...,\x20wip_url:\x20\x27https://<your-domain>/wowok/<file>.wip\x27,\x20wip_hash:\x20\x27<hash>\x27\x20}]\x20}\x20}\x20}'],'notes':['Make\x20sure\x20CORS\x20is\x20permissive\x20if\x20the\x20verifier\x20fetches\x20via\x20browser\x20(Access-Control-Allow-Origin:\x20*).','Ensure\x20HTTPS\x20is\x20enabled\x20—\x20most\x20verifiers\x20reject\x20plain\x20HTTP.']},{'name':'Data\x20URL\x20embedding\x20(small\x20files\x20only)','description':'Embed\x20the\x20entire\x20WIP\x20file\x20as\x20a\x20base64\x20data\x20URL\x20directly\x20in\x20the\x20wip_url\x20field.\x20'+'No\x20external\x20hosting\x20required,\x20but\x20on-chain\x20storage\x20cost\x20grows\x20with\x20file\x20size.','difficulty':'easy','free':!![],'result_url_pattern':'data:application/json;base64,<base64-encoded-content>','steps':['//\x201.\x20Encode\x20your\x20local\x20WIP\x20file\x20as\x20a\x20base64\x20data\x20URL:','//\x20\x20\x20\x20On\x20Linux/macOS:','echo\x20\x22data:application/json;base64,$(base64\x20-w0\x20\x27'+b+'\x27)\x22','//\x20\x20\x20\x20On\x20Windows\x20(PowerShell):','$bytes\x20=\x20[System.IO.File]::ReadAllBytes(\x27'+a+'\x27);\x20$b64\x20=\x20[System.Convert]::ToBase64String($bytes);\x20Write-Output\x20\x22data:application/json;base64,$b64\x22','//\x202.\x20Use\x20the\x20resulting\x20data\x20URL\x20as\x20the\x20wip_url\x20field\x20when\x20updating\x20the\x20Service.','//\x203.\x20Note:\x20data\x20URLs\x20are\x20NOT\x20recommended\x20for\x20files\x20>\x2050\x20KB\x20due\x20to\x20on-chain\x20storage\x20cost.'],'notes':['Only\x20suitable\x20for\x20very\x20small\x20WIP\x20files\x20(typically\x20<\x2010\x20KB).','Data\x20URLs\x20cannot\x20be\x20updated\x20without\x20an\x20on-chain\x20transaction\x20—\x20content\x20is\x20literally\x20embedded.','Prefer\x20GitHub\x20Pages\x20or\x20IPFS\x20for\x20files\x20>\x2010\x20KB.']}];}export function analyzeWipDeployment(a){const b=classifyWipPath(a),c=b['is_local'];let d,e=[];if(c)b['type']==='local_http'?d='The\x20WIP\x20URL\x20\x27'+a+'\x27\x20is\x20a\x20'+b['description']+'.\x20'+'It\x20is\x20reachable\x20only\x20from\x20the\x20merchant\x27s\x20own\x20machine/LAN\x20—\x20customers\x20and\x20'+'on-chain\x20verifiers\x20on\x20other\x20machines\x20CANNOT\x20fetch\x20it.\x20Storing\x20it\x20on-chain\x20'+'makes\x20every\x20customer\x20order\x20fail.\x20'+'Deploy\x20the\x20.wip\x20file\x20to\x20a\x20public\x20host\x20(GitHub\x20Pages,\x20IPFS,\x20or\x20your\x20own\x20website)\x20'+'and\x20update\x20the\x20Service\x27s\x20wip_url\x20with\x20the\x20public\x20URL.':d='The\x20WIP\x20path\x20\x27'+a+'\x27\x20is\x20a\x20LOCAL\x20'+b['type']+'\x20path.\x20'+'Local\x20paths\x20stored\x20on-chain\x20are\x20unreachable\x20by\x20customers\x20and\x20verifiers.\x20'+'Deploy\x20the\x20.wip\x20file\x20to\x20a\x20public\x20host\x20(GitHub\x20Pages,\x20IPFS,\x20or\x20your\x20own\x20website)\x20'+'and\x20update\x20the\x20Service\x27s\x20wip_url\x20with\x20the\x20public\x20URL.',e=getDeployOptions(a);else{if(b['type']==='http_url')d='The\x20WIP\x20path\x20is\x20an\x20HTTP(S)\x20URL\x20—\x20verify\x20the\x20server\x20returns\x20200.\x20'+'If\x20the\x20URL\x20returns\x20404/403,\x20the\x20file\x20may\x20have\x20been\x20moved\x20or\x20deleted.',e=[];else{if(b['type']==='ipfs')d='The\x20WIP\x20path\x20is\x20an\x20IPFS\x20URL\x20—\x20verify\x20the\x20gateway\x20is\x20responsive.\x20'+'If\x20the\x20CID\x20is\x20unreachable,\x20the\x20file\x20may\x20have\x20been\x20unpinned.',e=[];else b['type']==='data_url'?(d='The\x20WIP\x20path\x20is\x20a\x20data\x20URL\x20—\x20content\x20is\x20embedded,\x20no\x20deployment\x20needed.',e=[]):(d='Unrecognized\x20WIP\x20path\x20format:\x20\x27'+a+'\x27',e=[]);}}return{'path':a,'classification':b,'needs_deployment':c,'reason':d,'options':e,'remind_update_hash':c};}export function formatDeployHints(a){if(!a['needs_deployment']&&a['options']['length']===0x0)return'';const b=[];b['push']('===\x20WIP\x20Deployment\x20Assistance\x20==='),b['push'](''),b['push']('Path:\x20'+a['path']),b['push']('Type:\x20'+a['classification']['description']),b['push']('Reason:\x20'+a['reason']),b['push']('');if(a['options']['length']>0x0){b['push']('Recommended\x20deployment\x20options:'),b['push']('');for(const c of a['options']){b['push']('▶\x20'+c['name']+'\x20(difficulty:\x20'+c['difficulty']+',\x20free:\x20'+c['free']+')'),b['push']('\x20\x20'+c['description']),b['push']('\x20\x20Resulting\x20URL\x20pattern:\x20'+c['result_url_pattern']),b['push']('\x20\x20Steps:');for(const d of c['steps']){b['push']('\x20\x20\x20\x20'+d);}if(c['notes']&&c['notes']['length']>0x0){b['push']('\x20\x20Notes:');for(const e of c['notes']){b['push']('\x20\x20\x20\x20-\x20'+e);}}b['push']('');}}return a['remind_update_hash']&&(b['push']('⚠️\x20After\x20deploying,\x20compute\x20the\x20new\x20WIP\x20hash\x20and\x20update\x20the\x20Service:'),b['push']('\x20\x201.\x20Re-run\x20wip_file\x20{\x20type:\x20\x27verify\x27,\x20wipFilePath:\x20\x27<new-public-url>\x27\x20}\x20to\x20confirm\x20the\x20file\x20is\x20reachable.'),b['push']('\x20\x202.\x20Extract\x20the\x20meta.hash\x20from\x20the\x20WIP\x20file\x20(or\x20use\x20wip_file\x20{\x20type:\x20\x27verify\x27\x20}\x20result).'),b['push']('\x20\x203.\x20Update\x20the\x20Service\x20on-chain:\x20onchain_operations\x20{\x20operation_type:\x20\x27service\x27,\x20data:\x20{\x20object:\x20\x27<service-id>\x27,\x20sales:\x20{\x20op:\x20\x27set\x27,\x20sales:\x20[{\x20...,\x20wip_url:\x20\x27<new-public-url>\x27,\x20wip_hash:\x20\x27<hash>\x27\x20}]\x20}\x20}\x20}'),b['push']('')),b['push']('==============================='),b['join']('\x0a');}
1
+ export function classifyWipPath(a){if(!a||typeof a!=='string')return{'type':'unknown','is_local':![],'is_network':![],'description':'Empty\x20or\x20invalid\x20path'};if(a['startsWith']('data:'))return{'type':'data_url','is_local':![],'is_network':!![],'description':'Data\x20URL\x20—\x20embedded\x20content,\x20globally\x20reachable'};if(a['startsWith']('ipfs://'))return{'type':'ipfs','is_local':![],'is_network':!![],'description':'IPFS\x20URI\x20—\x20resolve\x20via\x20any\x20public\x20gateway'};const b=[/^https?:\/\/ipfs\.io\//i,/^https?:\/\/cloudflare-ipfs\.com\//i,/^https?:\/\/gateway\.pinata\.cloud\//i,/^https?:\/\/dweb\.link\//i,/^https?:\/\/[^/]*pinata\.cloud\//i];if(b['some'](d=>d['test'](a)))return{'type':'ipfs','is_local':![],'is_network':!![],'description':'IPFS\x20HTTP\x20gateway\x20URL\x20—\x20globally\x20reachable'};if(/^https?:\/\/(localhost|127\.0\.0\.1|\[::1\]|0\.0\.0\.0)([:/]|$)/i['test'](a))return{'type':'local_http','is_local':!![],'is_network':![],'description':'Local\x20HTTP\x20URL\x20(localhost/loopback)\x20—\x20reachable\x20only\x20on\x20this\x20machine,\x20NOT\x20by\x20customers'};const c=/^https?:\/\/(10\.\d{1,3}\.\d{1,3}\.\d{1,3}|172\.(1[6-9]|2\d|3[01])\.\d{1,3}\.\d{1,3}|192\.168\.\d{1,3}\.\d{1,3})([:/]|$)/i;if(c['test'](a))return{'type':'local_http','is_local':!![],'is_network':![],'description':'LAN\x20HTTP\x20URL\x20(private\x20IP)\x20—\x20reachable\x20only\x20on\x20the\x20local\x20network,\x20NOT\x20by\x20customers'};if(/^https?:\/\//i['test'](a))return{'type':'http_url','is_local':![],'is_network':!![],'description':'HTTP(S)\x20URL\x20—\x20globally\x20reachable\x20if\x20server\x20returns\x20200'};if(/^[A-Za-z]:[\\/]/['test'](a))return{'type':'local_windows','is_local':!![],'is_network':![],'description':'Windows\x20local\x20path\x20—\x20NOT\x20reachable\x20by\x20customers/AI'};if(a['startsWith']('/'))return{'type':'local_unix','is_local':!![],'is_network':![],'description':'Unix\x20local\x20path\x20—\x20NOT\x20reachable\x20by\x20customers/AI'};if(a['startsWith']('./')||a['startsWith']('../')||a==='.'||a==='..')return{'type':'local_relative','is_local':!![],'is_network':![],'description':'Relative\x20local\x20path\x20—\x20NOT\x20reachable\x20by\x20customers/AI'};if(!a['includes']('://')&&!a['startsWith']('data:'))return{'type':'local_relative','is_local':!![],'is_network':![],'description':'Local\x20file\x20path\x20(no\x20scheme)\x20—\x20NOT\x20reachable\x20by\x20customers/AI'};return{'type':'unknown','is_local':![],'is_network':![],'description':'Unrecognized\x20path\x20format'};}export function getDeployOptions(a){const b=a['replace'](/'/g,'\x27\x5c\x27\x27'),c=a['split'](/[\\/]/)['pop']()||'file.wip';return[{'name':'Wowok\x20WIP\x20storage\x20service\x20(Recommended)','description':'Upload\x20the\x20.wip\x20file\x20directly\x20from\x20the\x20MCP\x20with\x20wip_file\x20type=\x27upload\x27.\x20'+'Default\x20is\x20the\x20official\x20FREE\x20store\x20wip.store.wowok.net\x20(limited\x20to\x2010\x20files\x20per\x20account);\x20'+'with\x20storage=\x27custom\x27\x20any\x20self-hosted\x20or\x20third-party\x20wip\x20storage\x20service\x20works\x20(no\x20store\x20quota,\x20full\x20control).','difficulty':'easy','free':!![],'result_url_pattern':'https://wip.store.wowok.net/f/{hash}\x20\x20\x20(or\x20your\x20custom\x20service\x20base\x20URL\x20+\x20/f/{hash})','steps':['//\x201.\x20Generate\x20the\x20WIP\x20file:\x20wip_file\x20{\x20type:\x20\x27generate\x27,\x20options:\x20{\x20markdown_text:\x20\x27...\x27\x20}\x20}','//\x202.\x20Sign\x20it\x20with\x20your\x20account:\x20wip_file\x20{\x20type:\x20\x27sign\x27,\x20wipFilePath:\x20\x27<file>\x27,\x20account:\x20\x27<account>\x27\x20}','//\x203.\x20Upload\x20to\x20the\x20official\x20free\x20store:\x20wip_file\x20{\x20type:\x20\x27upload\x27,\x20wipFilePath:\x20\x27<file>\x27,\x20account:\x20\x27<account>\x27\x20}','//\x20\x20\x20\x20Or\x20use\x20your\x20own\x20/\x20a\x20third-party\x20service:\x20wip_file\x20{\x20type:\x20\x27upload\x27,\x20wipFilePath:\x20\x27<file>\x27,\x20storage:\x20\x27custom\x27,\x20customBaseUrl:\x20\x27https://your-wip-service.example.com\x27\x20}','//\x204.\x20Use\x20the\x20returned\x20URL\x20(base_url\x20+\x20/f/{hash})\x20as\x20the\x20Service\x27s\x20wip_url:','//\x20\x20\x20\x20onchain_operations\x20{\x20operation_type:\x20\x27service\x27,\x20data:\x20{\x20object:\x20\x27<service-id>\x27,\x20sales:\x20{\x20op:\x20\x27set\x27,\x20sales:\x20[{\x20...,\x20wip_url:\x20\x27<public-url>\x27,\x20wip_hash:\x20\x27<hash>\x27\x20}]\x20}\x20}\x20}','//\x205.\x20Confirm\x20reachability:\x20wip_file\x20{\x20type:\x20\x27verify\x27,\x20wipFilePath:\x20\x27<public-url>\x27\x20}'],'notes':['Official\x20free\x20store\x20is\x20limited\x20to\x2010\x20files\x20per\x20account\x20—\x20free\x20up\x20space\x20with\x20wip_file\x20type=\x27storage_delete\x27\x20when\x20the\x20quota\x20is\x20hit.','Official\x20free\x20store\x20declaration:\x20files\x20are\x20retained\x20for\x206\x20months\x20(180\x20days);\x20free\x20best-effort\x20service\x20—\x20force\x20majeure\x20excepted;\x20expired\x20files\x20are\x20NEVER\x20deleted\x20automatically\x20(manual\x20admin\x20purge\x20only).\x20For\x20permanent\x20hosting\x20use\x20storage=\x27custom\x27.','The\x20public\x20WIP\x20URL\x20is\x20network-independent:\x20the\x20same\x20file\x20serves\x20buyers\x20on\x20both\x20testnet\x20and\x20mainnet.','Large\x20WIP\x20files\x20(multi-MB,\x20image-heavy)\x20are\x20network-sensitive:\x20compress\x20images\x20before\x20generate\x20and\x20retry\x20transient\x20upload\x20failures.']},{'name':'GitHub\x20Pages','description':'Upload\x20the\x20.wip\x20file\x20to\x20a\x20GitHub\x20repository\x20and\x20serve\x20it\x20via\x20GitHub\x20Pages.\x20'+'Free,\x20stable,\x20HTTPS-enabled,\x20no\x20expiration.','difficulty':'easy','free':!![],'result_url_pattern':'https://<your-username>.github.io/<repo>/<file>.wip','steps':['//\x201.\x20Create\x20a\x20new\x20GitHub\x20repository\x20(e.g.,\x20\x27wowok-wip\x27)\x20via\x20https://github.com/new','//\x202.\x20Make\x20it\x20PUBLIC\x20so\x20the\x20file\x20is\x20world-readable.','//\x203.\x20Copy\x20your\x20local\x20WIP\x20file\x20into\x20the\x20repo:','git\x20clone\x20https://github.com/<your-username>/wowok-wip.git','cp\x20\x27'+b+'\x27\x20wowok-wip/'+c,'cd\x20wowok-wip','git\x20add\x20'+c,'git\x20commit\x20-m\x20\x22Add\x20WIP\x20file\x22','git\x20push\x20origin\x20main','//\x204.\x20Enable\x20GitHub\x20Pages:\x20repo\x20→\x20Settings\x20→\x20Pages\x20→\x20Source\x20→\x20\x27main\x27\x20branch\x20→\x20/(root)\x20→\x20Save','//\x205.\x20Wait\x2030-60\x20seconds\x20for\x20deployment,\x20then\x20verify\x20the\x20URL\x20is\x20reachable:','curl\x20-I\x20https://<your-username>.github.io/wowok-wip/'+c,'//\x206.\x20Update\x20your\x20Service\x20on-chain\x20with\x20the\x20new\x20public\x20URL:','//\x20\x20\x20\x20Call\x20onchain_operations\x20{\x20operation_type:\x20\x27service\x27,\x20data:\x20{\x20object:\x20\x27<service-id>\x27,\x20sales:\x20{\x20op:\x20\x27set\x27,\x20sales:\x20[{\x20...,\x20wip_url:\x20\x27https://...\x27,\x20wip_hash:\x20\x27<hash>\x27\x20}]\x20}\x20}\x20}'],'notes':['If\x20the\x20repo\x20already\x20has\x20Pages\x20enabled\x20on\x20the\x20main\x20branch,\x20step\x204\x20can\x20be\x20skipped.','GitHub\x20Pages\x20serves\x20files\x20up\x20to\x2025\x20MB\x20—\x20well\x20above\x20typical\x20WIP\x20sizes\x20(<\x201\x20MB).','URL\x20is\x20case-sensitive;\x20ensure\x20the\x20filename\x20in\x20the\x20URL\x20matches\x20exactly.']},{'name':'IPFS\x20via\x20Pinata\x20(Free\x20gateway)','description':'Upload\x20the\x20.wip\x20file\x20to\x20IPFS\x20through\x20Pinata\x27s\x20free\x20gateway.\x20'+'Content-addressed\x20—\x20the\x20CID\x20hash\x20also\x20serves\x20as\x20an\x20integrity\x20check.','difficulty':'medium','free':!![],'result_url_pattern':'https://gateway.pinata.cloud/ipfs/<CID>\x20\x20(or\x20\x20https://ipfs.io/ipfs/<CID>)','steps':['//\x201.\x20Sign\x20up\x20for\x20a\x20free\x20Pinata\x20account\x20at\x20https://app.pinata.cloud/\x20(1\x20GB\x20free\x20storage).','//\x202.\x20Get\x20your\x20API\x20key\x20from\x20https://app.pinata.cloud/keys\x20(generate\x20a\x20new\x20key\x20with\x20\x27pinFileToIPFS\x27\x20scope).','//\x203.\x20Upload\x20your\x20local\x20WIP\x20file\x20via\x20curl:','curl\x20-X\x20POST\x20https://api.pinata.cloud/pinning/pinFileToIPFS\x20\x5c','\x20\x20-H\x20\x22Authorization:\x20Bearer\x20<YOUR_PINATA_API_KEY>\x22\x20\x5c','\x20\x20-F\x20\x22file=@\x27'+b+'\x27\x22','//\x204.\x20Pinata\x20returns\x20JSON\x20with\x20\x27IpfsHash\x27\x20(the\x20CID).\x20Extract\x20it:','//\x20\x20\x20\x20Example\x20response:\x20{\x20\x22IpfsHash\x22:\x20\x22QmXYZ...\x22,\x20\x22PinSize\x22:\x2012345,\x20\x22Timestamp\x22:\x20\x22...\x22\x20}','//\x205.\x20Verify\x20the\x20file\x20is\x20reachable\x20via\x20the\x20public\x20gateway:','curl\x20-I\x20https://gateway.pinata.cloud/ipfs/<CID>','//\x206.\x20(Optional)\x20Use\x20ipfs://<CID>\x20as\x20the\x20wip_url\x20—\x20the\x20SDK\x20resolves\x20it.','//\x207.\x20Update\x20your\x20Service\x20on-chain\x20with\x20the\x20IPFS\x20URL\x20or\x20CID:','//\x20\x20\x20\x20Call\x20onchain_operations\x20{\x20operation_type:\x20\x27service\x27,\x20data:\x20{\x20object:\x20\x27<service-id>\x27,\x20sales:\x20{\x20op:\x20\x27set\x27,\x20sales:\x20[{\x20...,\x20wip_url:\x20\x27https://gateway.pinata.cloud/ipfs/<CID>\x27,\x20wip_hash:\x20\x27<hash>\x27\x20}]\x20}\x20}\x20}'],'notes':['Pinata\x20free\x20tier:\x201\x20GB\x20storage,\x20100\x20uploads/day\x20—\x20sufficient\x20for\x20WIP\x20files.','For\x20long-term\x20durability,\x20also\x20pin\x20via\x20another\x20gateway\x20(e.g.,\x20nft.storage).','IPFS\x20CIDs\x20are\x20content-addressed\x20—\x20if\x20the\x20file\x20changes,\x20the\x20CID\x20changes.\x20This\x20is\x20a\x20feature,\x20not\x20a\x20bug.']},{'name':'User\x27s\x20own\x20website\x20/\x20static\x20host','description':'If\x20you\x20already\x20operate\x20a\x20website\x20or\x20static\x20host\x20(e.g.,\x20nginx,\x20Vercel,\x20Netlify,\x20Cloudflare\x20Pages),\x20'+'upload\x20the\x20.wip\x20file\x20there\x20and\x20use\x20its\x20public\x20URL.','difficulty':'medium','free':!![],'result_url_pattern':'https://<your-domain>/<path>/<file>.wip','steps':['//\x201.\x20Copy\x20your\x20local\x20WIP\x20file\x20to\x20your\x20web\x20server\x27s\x20static\x20directory:','scp\x20\x27'+b+'\x27\x20user@your-server:/var/www/html/wowok/'+c,'//\x202.\x20Ensure\x20the\x20server\x20sets\x20Content-Type:\x20application/json\x20(or\x20application/octet-stream)\x20for\x20.wip\x20files.','//\x20\x20\x20\x20For\x20nginx,\x20add\x20to\x20your\x20server\x20block:','//\x20\x20\x20\x20\x20\x20\x20\x20location\x20~\x20\x5c.wip$\x20{\x20default_type\x20application/json;\x20}','//\x203.\x20Verify\x20the\x20file\x20is\x20reachable:','curl\x20-I\x20https://<your-domain>/wowok/'+c,'//\x204.\x20Update\x20your\x20Service\x20on-chain\x20with\x20the\x20new\x20public\x20URL:','//\x20\x20\x20\x20Call\x20onchain_operations\x20{\x20operation_type:\x20\x27service\x27,\x20data:\x20{\x20object:\x20\x27<service-id>\x27,\x20sales:\x20{\x20op:\x20\x27set\x27,\x20sales:\x20[{\x20...,\x20wip_url:\x20\x27https://<your-domain>/wowok/<file>.wip\x27,\x20wip_hash:\x20\x27<hash>\x27\x20}]\x20}\x20}\x20}'],'notes':['Make\x20sure\x20CORS\x20is\x20permissive\x20if\x20the\x20verifier\x20fetches\x20via\x20browser\x20(Access-Control-Allow-Origin:\x20*).','Ensure\x20HTTPS\x20is\x20enabled\x20—\x20most\x20verifiers\x20reject\x20plain\x20HTTP.']},{'name':'Data\x20URL\x20embedding\x20(small\x20files\x20only)','description':'Embed\x20the\x20entire\x20WIP\x20file\x20as\x20a\x20base64\x20data\x20URL\x20directly\x20in\x20the\x20wip_url\x20field.\x20'+'No\x20external\x20hosting\x20required,\x20but\x20on-chain\x20storage\x20cost\x20grows\x20with\x20file\x20size.','difficulty':'easy','free':!![],'result_url_pattern':'data:application/json;base64,<base64-encoded-content>','steps':['//\x201.\x20Encode\x20your\x20local\x20WIP\x20file\x20as\x20a\x20base64\x20data\x20URL:','//\x20\x20\x20\x20On\x20Linux/macOS:','echo\x20\x22data:application/json;base64,$(base64\x20-w0\x20\x27'+b+'\x27)\x22','//\x20\x20\x20\x20On\x20Windows\x20(PowerShell):','$bytes\x20=\x20[System.IO.File]::ReadAllBytes(\x27'+a+'\x27);\x20$b64\x20=\x20[System.Convert]::ToBase64String($bytes);\x20Write-Output\x20\x22data:application/json;base64,$b64\x22','//\x202.\x20Use\x20the\x20resulting\x20data\x20URL\x20as\x20the\x20wip_url\x20field\x20when\x20updating\x20the\x20Service.','//\x203.\x20Note:\x20data\x20URLs\x20are\x20NOT\x20recommended\x20for\x20files\x20>\x2050\x20KB\x20due\x20to\x20on-chain\x20storage\x20cost.'],'notes':['Only\x20suitable\x20for\x20very\x20small\x20WIP\x20files\x20(typically\x20<\x2010\x20KB).','Data\x20URLs\x20cannot\x20be\x20updated\x20without\x20an\x20on-chain\x20transaction\x20—\x20content\x20is\x20literally\x20embedded.','Prefer\x20GitHub\x20Pages\x20or\x20IPFS\x20for\x20files\x20>\x2010\x20KB.']}];}export function analyzeWipDeployment(a){const b=classifyWipPath(a),c=b['is_local'];let d,e=[];if(c)b['type']==='local_http'?d='The\x20WIP\x20URL\x20\x27'+a+'\x27\x20is\x20a\x20'+b['description']+'.\x20'+'It\x20is\x20reachable\x20only\x20from\x20the\x20merchant\x27s\x20own\x20machine/LAN\x20—\x20customers\x20and\x20'+'on-chain\x20verifiers\x20on\x20other\x20machines\x20CANNOT\x20fetch\x20it.\x20Storing\x20it\x20on-chain\x20'+'makes\x20every\x20customer\x20order\x20fail.\x20'+'Deploy\x20the\x20.wip\x20file\x20to\x20a\x20public\x20host\x20(GitHub\x20Pages,\x20IPFS,\x20or\x20your\x20own\x20website)\x20'+'and\x20update\x20the\x20Service\x27s\x20wip_url\x20with\x20the\x20public\x20URL.':d='The\x20WIP\x20path\x20\x27'+a+'\x27\x20is\x20a\x20LOCAL\x20'+b['type']+'\x20path.\x20'+'Local\x20paths\x20stored\x20on-chain\x20are\x20unreachable\x20by\x20customers\x20and\x20verifiers.\x20'+'Deploy\x20the\x20.wip\x20file\x20to\x20a\x20public\x20host\x20(GitHub\x20Pages,\x20IPFS,\x20or\x20your\x20own\x20website)\x20'+'and\x20update\x20the\x20Service\x27s\x20wip_url\x20with\x20the\x20public\x20URL.',e=getDeployOptions(a);else{if(b['type']==='http_url')d='The\x20WIP\x20path\x20is\x20an\x20HTTP(S)\x20URL\x20—\x20verify\x20the\x20server\x20returns\x20200.\x20'+'If\x20the\x20URL\x20returns\x20404/403,\x20the\x20file\x20may\x20have\x20been\x20moved\x20or\x20deleted.',e=[];else{if(b['type']==='ipfs')d='The\x20WIP\x20path\x20is\x20an\x20IPFS\x20URL\x20—\x20verify\x20the\x20gateway\x20is\x20responsive.\x20'+'If\x20the\x20CID\x20is\x20unreachable,\x20the\x20file\x20may\x20have\x20been\x20unpinned.',e=[];else b['type']==='data_url'?(d='The\x20WIP\x20path\x20is\x20a\x20data\x20URL\x20—\x20content\x20is\x20embedded,\x20no\x20deployment\x20needed.',e=[]):(d='Unrecognized\x20WIP\x20path\x20format:\x20\x27'+a+'\x27',e=[]);}}return{'path':a,'classification':b,'needs_deployment':c,'reason':d,'options':e,'remind_update_hash':c};}export function formatDeployHints(a){if(!a['needs_deployment']&&a['options']['length']===0x0)return'';const b=[];b['push']('===\x20WIP\x20Deployment\x20Assistance\x20==='),b['push'](''),b['push']('Path:\x20'+a['path']),b['push']('Type:\x20'+a['classification']['description']),b['push']('Reason:\x20'+a['reason']),b['push']('');if(a['options']['length']>0x0){b['push']('Recommended\x20deployment\x20options:'),b['push']('');for(const c of a['options']){b['push']('▶\x20'+c['name']+'\x20(difficulty:\x20'+c['difficulty']+',\x20free:\x20'+c['free']+')'),b['push']('\x20\x20'+c['description']),b['push']('\x20\x20Resulting\x20URL\x20pattern:\x20'+c['result_url_pattern']),b['push']('\x20\x20Steps:');for(const d of c['steps']){b['push']('\x20\x20\x20\x20'+d);}if(c['notes']&&c['notes']['length']>0x0){b['push']('\x20\x20Notes:');for(const e of c['notes']){b['push']('\x20\x20\x20\x20-\x20'+e);}}b['push']('');}}return a['remind_update_hash']&&(b['push']('⚠️\x20After\x20deploying,\x20compute\x20the\x20new\x20WIP\x20hash\x20and\x20update\x20the\x20Service:'),b['push']('\x20\x201.\x20Re-run\x20wip_file\x20{\x20type:\x20\x27verify\x27,\x20wipFilePath:\x20\x27<new-public-url>\x27\x20}\x20to\x20confirm\x20the\x20file\x20is\x20reachable.'),b['push']('\x20\x202.\x20Extract\x20the\x20meta.hash\x20from\x20the\x20WIP\x20file\x20(or\x20use\x20wip_file\x20{\x20type:\x20\x27verify\x27\x20}\x20result).'),b['push']('\x20\x203.\x20Update\x20the\x20Service\x20on-chain:\x20onchain_operations\x20{\x20operation_type:\x20\x27service\x27,\x20data:\x20{\x20object:\x20\x27<service-id>\x27,\x20sales:\x20{\x20op:\x20\x27set\x27,\x20sales:\x20[{\x20...,\x20wip_url:\x20\x27<new-public-url>\x27,\x20wip_hash:\x20\x27<hash>\x27\x20}]\x20}\x20}\x20}'),b['push']('')),b['push']('==============================='),b['join']('\x0a');}
@@ -1 +1 @@
1
- import{classifyError,buildDataSemantic}from'../schema/call/semantic.js';import{buildClassifiedErrorResult}from'./shared.js';import{shouldRunLightHooks,shouldRunHeavyHooks,recordOperationFailure,recordCriticalRisk,recordCriticalOperation,recordSubstepFailure}from'../harness/auto-escalation.js';import{getHarnessTier,setHarnessTier,isEnabled}from'../config/runtime.js';import{getHarness}from'../harness/index.js';import{recover}from'../harness/recover.js';import{recordOperationOutcome}from'../experience/index.js';import{recordIndustrySignal}from'../knowledge/flywheel-loop.js';import{getStageCache}from'../playbooks/service-build/index.js';import{SERVICE_BUILD_STAGES}from'../playbooks/service-build/process.js';import{extractAmount,getAmountThreshold,formatAmount}from'../knowledge/safety-rules.js';function stageIndexOf(a){const b=SERVICE_BUILD_STAGES['indexOf'](a);return b>=0x0?b:0x0;}export function withTimeout(a,b=0x7530,c='operation'){let d;return Promise['race']([a['finally'](()=>{if(d)clearTimeout(d);}),new Promise((e,f)=>{d=setTimeout(()=>{let g='';if(c['includes']('messenger'))g='\x20This\x20is\x20a\x20messenger\x20network\x20operation.\x20Possible\x20causes:\x20'+'(1)\x20messenger\x20server\x20(https://messenger.wowok.net)\x20unreachable,\x20'+'(2)\x20no\x20messenger-enabled\x20account\x20configured\x20(use\x20account_operation\x20to\x20set\x20messenger\x20name),\x20'+'(3)\x20network\x20connectivity\x20issue.\x20'+'Ensure\x20you\x20have\x20a\x20messenger-enabled\x20account\x20and\x20the\x20server\x20is\x20reachable.';else(c['includes']('onchain')||c['includes']('account_operation')||c['includes']('bridge')||c['includes']('workflow')||c['includes']('keeper')||c['includes']('wowok'))&&(g='\x20This\x20tool\x20may\x20submit\x20an\x20ON-CHAIN\x20transaction.\x20The\x20transaction\x20was\x20NOT\x20cancelled\x20'+'by\x20this\x20timeout\x20—\x20it\x20may\x20already\x20be\x20submitted\x20and\x20still\x20finalize\x20on-chain.\x20'+'DO\x20NOT\x20blindly\x20retry\x20(risk\x20of\x20duplicate\x20operations).\x20First\x20verify:\x20'+'(1)\x20if\x20the\x20error\x20above\x20carries\x20a\x20tx\x20digest,\x20check\x20it\x20via\x20query_toolkit\x20'+'(query_type=\x27onchain_transaction\x27);\x20(2)\x20otherwise\x20verify\x20via\x20query_toolkit\x20'+'onchain_events\x20(or\x20the\x20account\x27s\x20recent\x20transactions).\x20Do\x20NOT\x20rely\x20on\x20an\x20'+'onchain_objects\x20read\x20alone:\x20it\x20may\x20serve\x20a\x20pre-transaction\x20cached\x20snapshot,\x20'+'so\x20an\x20unchanged\x20object\x20must\x20never\x20on\x20its\x20own\x20justify\x20a\x20retry.');f(new Error('Operation\x20\x27'+c+'\x27\x20timed\x20out\x20after\x20'+b+'ms.'+g));},b);})]);}export function wrapHandlerWithErrorShape(a,b,c,d){return async(e,f)=>{try{return await withTimeout(a(e,f),b,c);}catch(g){if(d){const h=g instanceof Error?g['message']:String(g),i=classifyError(h),j={'operation_type':c,'data':e},k=d(h,i,j);return{'content':[{'type':'text','text':'Error:\x20'+h}],'structuredContent':k};}throw g;}};}export const statusErrorShape=(a,b,c)=>({'result':buildClassifiedErrorResult({'status':'error'},a,b),'semantic':buildDataSemantic(undefined,c,!![],a)});export const operationErrorShape=(a,b,c)=>({'result':buildClassifiedErrorResult({'operation':'error'},a,b),'semantic':buildDataSemantic(undefined,c,!![],a)});export const strictStatusErrorShape=(a,b,c)=>({'result':{'status':'error','error':a}});function checkProjectStage(a,b,c){const d={'analyze_intent':'puzzle','aggregate_risks':'risk','trace_substeps':'substeps'},e=d[a];if(!e)return null;const f=getStageCache(b,c);if(!f){if(a==='analyze_intent')return null;return'project_stage:\x20calling\x20\x27'+a+'\x27\x20before\x20\x27analyze_intent\x27\x20—\x20recommend\x20calling\x20analyze_intent\x20first\x20for\x20project\x20\x27'+b+':'+c+'\x27';}if(stageIndexOf(f['stage'])<stageIndexOf(e)-0x1)return'project_stage:\x20calling\x20\x27'+a+'\x27\x20(stage\x20\x27'+e+'\x27)\x20but\x20project\x20is\x20at\x20stage\x20\x27'+f['stage']+'\x27\x20—\x20recommend\x20completing\x20prior\x20stages\x20first\x20for\x20\x27'+b+':'+c+'\x27';return null;}export function dispatchWithHarness(a,b){return async(d,f)=>{const g=[],h=getHarness(),i=shouldRunLightHooks(),j=shouldRunHeavyHooks(),k=isPublishOperation(b,d),l=isSignOperation(b,d),m=getHarnessTier();if(b==='goal_operation'&&i)try{const o=d,p=o?.['action'],q=o?.['project'],r=o?.['version'];if(p&&q&&r){const s=checkProjectStage(p,q,r);s&&g['push'](s);}}catch{}k&&m==='lightweight'&&(setHarnessTier('full'),g['push']('pre_publish:\x20tier\x20forced\x20to\x20full\x20for\x20publish-class\x20operation\x20(GLM5-21\x20§3.3)'));if(k&&m!=='off')try{const t=runPrePublishChecks(b,d);g['push'](...t['warnings']);if(t['critical']['length']>0x0){for(const u of t['critical']){const v=recordCriticalRisk(u);if(v)g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+v['reason']);}return buildHarnessBlockResult('pre_publish','Publish\x20BLOCKED\x20by\x20Harness\x20pre-publish\x20gate\x20(GLM5-21\x20V6):\x20'+(t['critical']['length']+'\x20CRITICAL\x20risk(s)\x20must\x20be\x20resolved\x20before\x20publish.'),t['critical'],t['warnings'],'immutable_violation','Fix\x20the\x20CRITICAL\x20risks\x20listed\x20in\x20the\x20message\x20(e.g.\x20rename\x20dispute/refund\x20nodes\x20per\x20R-M1-11,\x20add\x20the\x20entry\x20pair\x20prev_node=\x22\x22),\x20then\x20retry\x20publish.\x20Nodes/pairs/forwards\x20are\x20immutable\x20after\x20publish\x20—\x20verify\x20via\x20machineNode2file\x20first.');}}catch(x){g['push']('pre_publish\x20hook\x20failed:\x20'+(x instanceof Error?x['message']:String(x)));}if(l&&j)try{const y=extractData(d),z=y?extractAmount(y):null;if(z!==null){const A=getAmountThreshold();let B=null;try{B=BigInt(z);}catch{B=null;}if(B!==null&&B>A)return buildHarnessBlockResult('pre_sign','Sign\x20BLOCKED\x20by\x20Harness\x20pre-sign\x20gate\x20(GLM5-21\x20V7):\x20amount\x20'+formatAmount(B)+'\x20WOW\x20exceeds\x20the\x20full-tier\x20threshold\x20'+formatAmount(A)+'\x20WOW.',['amount\x20'+z+'\x20(smallest\x20unit)\x20>\x20threshold\x20'+A['toString']()+'\x20(smallest\x20unit)'],[],'invalid_parameter','Raise\x20WOWOK_AMOUNT_THRESHOLD\x20to\x20match\x20the\x20intended\x20amount,\x20split\x20the\x20transaction,\x20or\x20reset\x20the\x20harness\x20tier\x20to\x20lightweight\x20(config_operation)\x20after\x20explicit\x20user\x20confirmation.');}}catch(C){g['push']('pre_sign\x20hook\x20failed:\x20'+(C instanceof Error?C['message']:String(C)));}let n;try{n=await a(d,f);}catch(D){const E=D instanceof Error?D['message']:String(D),F=recordOperationFailure(b,E);F&&g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+F['reason']);if(b==='onchain_operations')try{const G=classifyError(E,D);if(!G['retryable']&&G['error_code']!=='unknown'){const H=recordCriticalOperation(b,G['error_code']);if(H)g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+H['reason']);}}catch{}throw D;}if(b==='onchain_operations')try{if(classifyOutcome(n)==='failed'){const I=extractErrorCode(n)??'',J=classifyError(I);if(!J['retryable']&&J['error_code']!=='unknown'){const K=recordCriticalOperation(b,J['error_code']);if(K)g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+K['reason']);}}}catch{}if(i&&!isOutcomeDiscriminated(n)){const L=extractIntent(b,d)??b;try{const M=classifyOutcome(n);if(M==='failed'){const N=extractErrorCode(n)??'',O=classifyError(N),P=h['recover'](O['error_code'],L,{'operation_type':b,'data':extractData(d)});g['push']('Harness\x20recover:\x20strategy='+P['strategy']+('\x20(attempt\x20'+P['current_attempt']+'/'+P['max_attempts']+')')+(P['should_retry']?'\x20—\x20retryable':'\x20—\x20do\x20NOT\x20retry\x20blindly')+(P['user_prompt']?'\x20—\x20'+P['user_prompt']:'\x20—\x20'+P['detail']));}else M==='success'&&h['resetRecovery'](L);}catch(Q){g['push']('recover\x20hook\x20failed:\x20'+(Q instanceof Error?Q['message']:String(Q)));}}if(b==='goal_operation')try{const R=d?.['action'];if(R==='trace_substeps'){const S=extractCriticalFindingCount(n);if(S>0x0){const T=recordSubstepFailure(String(R)+':\x20'+S+'\x20critical\x20finding(s)');if(T)g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+T['reason']);}}}catch{}if(isWriteClassTool(b)&&!SEMANTIC_RECORDED_TOOLS['has'](b))try{const U=extractOperationType(b,d)??b,V=extractIntent(b,d)??b,W=extractData(d)??d,X=classifyOutcome(n),Y=extractErrorCode(n),Z=isEnabled('experience_layer');if(Z)recordOperationOutcome(U,W,V,X,Y);else{const a0=extractIndustry(d);a0&&isEnabled('industry_evolution')&&recordIndustrySignal(a0,{'type':U},{'success':X==='success','error_code':Y});}}catch(a1){g['push']('signal\x20collection\x20failed:\x20'+(a1 instanceof Error?a1['message']:String(a1)));}if(g['length']>0x0){if(n?.['structuredContent']){const a2=n['structuredContent'],a3=a2['semantic'];if(a3){const a4=Array['isArray'](a3['warnings'])?a3['warnings']:[];a3['warnings']=[...a4,...g];}else for(const a5 of g){console['warn']('[harness]\x20'+a5);}}else for(const a6 of g){console['warn']('[harness]\x20'+a6);}}return n;};}function isPublishOperation(a,b){if(a!=='onchain_operations')return![];const c=extractOperationType(a,b);if(c!=='service'&&c!=='machine')return![];const d=extractData(b);return d?.['publish']===!![]||d?.['bPublished']===!![];}function isSignOperation(a,b){if(a==='wip_file'){const c=b?.['operation_type'];return c==='sign';}return a==='onchain_operations';}function extractOperationType(a,b){if(!b||typeof b!=='object')return undefined;const c=b;if(a==='onchain_operations')return typeof c['operation_type']==='string'?c['operation_type']:undefined;if(a==='goal_operation'||a==='industry_pack_operation'||a==='strategy_review_operation')return typeof c['action']==='string'?c['action']:undefined;return typeof c['operation_type']==='string'?c['operation_type']:undefined;}function extractIntent(a,b){if(!b||typeof b!=='object')return undefined;const c=b;if((a==='goal_operation'||a==='industry_pack_operation'||a==='strategy_review_operation')&&typeof c['action']==='string')return a+':'+c['action'];const d=c['operation_type'];if(typeof d==='string')return a+':'+d;return a;}function extractData(a){if(!a||typeof a!=='object')return undefined;const b=a,c=b['data'];return c&&typeof c==='object'?c:undefined;}const WRITE_CLASS_TOOLS=new Set(['onchain_operations','goal_operation','industry_pack_operation','strategy_review_operation','wip_file','messenger_operation','bridge_operation']),SEMANTIC_RECORDED_TOOLS=new Set(['onchain_operations','bridge_operation']);function isWriteClassTool(a){return WRITE_CLASS_TOOLS['has'](a);}function classifyOutcome(a){if(!a?.['structuredContent'])return'failed';const b=a['structuredContent'];if(b['outcome']==='failed')return'failed';if(b['outcome']==='executed')return'success';if(b['outcome']==='pending_input')return'partial';const c=typeof b['status']==='string'?b['status']:typeof b['result_type']==='string'?b['result_type']:'';if(c==='error'||c==='failed')return'failed';if(c==='partial')return'partial';return'success';}function isOutcomeDiscriminated(a){const b=a?.['structuredContent'];return!!b&&typeof b==='object'&&'outcome'in b;}function extractErrorCode(a){if(!a?.['structuredContent'])return undefined;const b=a['structuredContent'];if(typeof b['error_code']==='string')return b['error_code'];const c=b['error'];if(typeof c==='string')return c;if(c&&typeof c==='object'){const d=c['code'];if(typeof d==='string')return d;}return undefined;}function extractIndustry(a){if(!a||typeof a!=='object')return undefined;const b=a;if(typeof b['industry']==='string')return b['industry'];const c=b['data'];if(c&&typeof c==='object'){const e=c;if(typeof e['industry']==='string')return e['industry'];}return undefined;}const ANTI_PATTERN_NODE_REGEX=/(^|_)(disputed?|refund(?:ed)?|arbitration|arb)(_|$)/i;function runPrePublishChecks(a,b){const c=[],d=[],e=extractOperationType(a,b),g=extractData(b)??{};if(e==='machine'){const h=g['node'],i=Array['isArray'](h)?h:Array['isArray'](h?.['nodes'])?h['nodes']:[];if(i['length']>0x0){for(const l of i){const m=typeof l?.['name']==='string'?l['name']:'';m&&ANTI_PATTERN_NODE_REGEX['test'](m)&&c['push']('R-M1-11:\x20machine\x20node\x20\x22'+m+'\x22\x20models\x20dispute/refund\x20flow\x20—\x20'+'refunds\x20must\x20route\x20via\x20an\x20Allocator\x20triggered\x20by\x20business\x20states,\x20'+'disputes\x20via\x20the\x20separate\x20Arbitration\x20object\x20(off-Machine)');}const j=new Set();for(const o of i){const q=typeof o?.['name']==='string'?o['name']:'';if(!q)continue;j['has'](q)&&c['push']('MC-C-04:\x20duplicate\x20machine\x20node\x20name\x20\x22'+q+'\x22\x20—\x20on-chain\x20will\x20reject\x20the\x20publish\x20transaction'),j['add'](q);}const k=i['some'](r=>Array['isArray'](r?.['pairs'])&&r['pairs']['some'](s=>s?.['prev_node']===''));!k&&c['push']('Machine\x20has\x20no\x20entry\x20pair\x20(prev_node=\x22\x22)\x20—\x20Progress\x20can\x20never\x20advance\x20'+'from\x20the\x20initial\x20state;\x20orders\x20are\x20permanently\x20stuck');for(const r of i){const s=typeof r?.['name']==='string'?r['name']:'?';for(const t of r?.['pairs']??[]){for(const u of t?.['forwards']??[]){const v=u?.['namedOperator']!==undefined&&u?.['namedOperator']!==null,w=u?.['permissionIndex']!==undefined&&u?.['permissionIndex']!==null;!v&&!w&&d['push']('pre_publish:\x20node\x20\x22'+s+'\x22\x20forward\x20\x22'+String(u?.['name']??'?')+'\x22\x20has\x20neither\x20namedOperator\x20nor\x20permissionIndex\x20—\x20no\x20one\x20can\x20advance\x20it');}}}}else d['push']('pre_publish:\x20publishing\x20machine\x20without\x20inline\x20node\x20data\x20—\x20topology\x20not\x20verifiable\x20in\x20this\x20call;\x20'+'verify\x20nodes/pairs/forwards\x20via\x20machineNode2file\x20BEFORE\x20publish\x20(immutable\x20after\x20publish,\x20IMMUT-001)');d['push']('pre_publish:\x20machine\x20nodes/pairs/forwards\x20become\x20immutable\x20after\x20publish\x20(IMMUT-001)');}return e==='service'&&(d['push']('pre_publish:\x20service\x20machine/order_allocators/arbitrations\x20become\x20immutable\x20after\x20publish\x20(IMMUT-002);\x20sales\x20remains\x20modifiable'),g['machine']===undefined&&d['push']('pre_publish:\x20\x27machine\x27\x20not\x20set\x20in\x20this\x20call\x20—\x20if\x20the\x20service\x20was\x20never\x20bound\x20to\x20a\x20published\x20machine,\x20'+'it\x20cannot\x20process\x20orders\x20and\x20CANNOT\x20be\x20fixed\x20after\x20publish'),g['order_allocators']===undefined&&d['push']('pre_publish:\x20\x27order_allocators\x27\x20not\x20set\x20in\x20this\x20call\x20—\x20immutable\x20after\x20publish;\x20'+'orders\x20will\x20have\x20no\x20fund\x20distribution\x20if\x20never\x20configured')),{'critical':c,'warnings':d};}function buildHarnessBlockResult(a,b,c,d,e,f){const g=[...c['map'](i=>'CRITICAL:\x20'+i),...d['map'](i=>'WARN:\x20'+i)]['join']('\x0a'),h='Error:\x20'+b+(g?'\x0a'+g:'')+'\x0aRecovery:\x20'+f;return{'content':[{'type':'text','text':h}],'structuredContent':{'outcome':'failed','result':{'type':'error','error':b+'\x20[gate='+a+']','error_code':e,'retryable':![],'recovery_hint':f},'message':h,'recovery':recover(e,'harness:'+a)}};}function extractCriticalFindingCount(a){const b=a?.['structuredContent'];if(!b)return 0x0;const c=b['semantic'],d=c?.['summary'];if(typeof d?.['critical_count']==='number'&&d['critical_count']>0x0)return d['critical_count'];const e=b['findings']??c?.['findings'];if(Array['isArray'](e))return e['filter'](h=>h?.['severity']==='error')['length'];const f=a?.['content']?.['map'](h=>'text'in h?h['text']:'')['join']('\x0a')??'',g=f['match'](/\[AUDIT ERROR\]/g);return g?g['length']:0x0;}
1
+ import{classifyError,buildDataSemantic}from'../schema/call/semantic.js';import{buildClassifiedErrorResult}from'./shared.js';import{shouldRunLightHooks,shouldRunHeavyHooks,recordOperationFailure,recordCriticalRisk,recordCriticalOperation,recordSubstepFailure}from'../harness/auto-escalation.js';import{getHarnessTier,setHarnessTier,isEnabled}from'../config/runtime.js';import{getHarness}from'../harness/index.js';import{recover}from'../harness/recover.js';import{recordOperationOutcome}from'../experience/index.js';import{recordIndustrySignal}from'../knowledge/flywheel-loop.js';import{getStageCache}from'../playbooks/service-build/index.js';import{SERVICE_BUILD_STAGES}from'../playbooks/service-build/process.js';import{extractAmount,getAmountThreshold,getFundCoverageMin,formatAmount}from'../knowledge/safety-rules.js';import{auditMachineNodes}from'../knowledge/audit-rules.js';import{fetchMachineNodes}from'../graph/onchain/sdk-batch.js';function stageIndexOf(a){const b=SERVICE_BUILD_STAGES['indexOf'](a);return b>=0x0?b:0x0;}export function withTimeout(a,b=0x7530,c='operation'){let d;return Promise['race']([a['finally'](()=>{if(d)clearTimeout(d);}),new Promise((e,f)=>{d=setTimeout(()=>{let g='';if(c['includes']('messenger'))g='\x20This\x20is\x20a\x20messenger\x20network\x20operation.\x20Possible\x20causes:\x20'+'(1)\x20messenger\x20server\x20(https://messenger.wowok.net)\x20unreachable,\x20'+'(2)\x20no\x20messenger-enabled\x20account\x20configured\x20(use\x20account_operation\x20to\x20set\x20messenger\x20name),\x20'+'(3)\x20network\x20connectivity\x20issue.\x20'+'Ensure\x20you\x20have\x20a\x20messenger-enabled\x20account\x20and\x20the\x20server\x20is\x20reachable.';else(c['includes']('onchain')||c['includes']('account_operation')||c['includes']('bridge')||c['includes']('workflow')||c['includes']('keeper')||c['includes']('wowok'))&&(g='\x20This\x20tool\x20may\x20submit\x20an\x20ON-CHAIN\x20transaction.\x20The\x20transaction\x20was\x20NOT\x20cancelled\x20'+'by\x20this\x20timeout\x20—\x20it\x20may\x20already\x20be\x20submitted\x20and\x20still\x20finalize\x20on-chain.\x20'+'DO\x20NOT\x20blindly\x20retry\x20(risk\x20of\x20duplicate\x20operations).\x20First\x20verify:\x20'+'(1)\x20if\x20the\x20error\x20above\x20carries\x20a\x20tx\x20digest,\x20check\x20it\x20via\x20query_toolkit\x20'+'(query_type=\x27onchain_transaction\x27);\x20(2)\x20otherwise\x20verify\x20via\x20query_toolkit\x20'+'onchain_events\x20(or\x20the\x20account\x27s\x20recent\x20transactions).\x20Do\x20NOT\x20rely\x20on\x20an\x20'+'onchain_objects\x20read\x20alone:\x20it\x20may\x20serve\x20a\x20pre-transaction\x20cached\x20snapshot,\x20'+'so\x20an\x20unchanged\x20object\x20must\x20never\x20on\x20its\x20own\x20justify\x20a\x20retry.');f(new Error('Operation\x20\x27'+c+'\x27\x20timed\x20out\x20after\x20'+b+'ms.'+g));},b);})]);}export function wrapHandlerWithErrorShape(a,b,c,d){return async(e,f)=>{try{return await withTimeout(a(e,f),b,c);}catch(g){if(d){const h=g instanceof Error?g['message']:String(g),i=classifyError(h),j={'operation_type':c,'data':e},k=d(h,i,j);return{'content':[{'type':'text','text':'Error:\x20'+h}],'structuredContent':k};}throw g;}};}export const statusErrorShape=(a,b,c)=>({'result':buildClassifiedErrorResult({'status':'error'},a,b),'semantic':buildDataSemantic(undefined,c,!![],a)});export const operationErrorShape=(a,b,c)=>({'result':buildClassifiedErrorResult({'operation':'error'},a,b),'semantic':buildDataSemantic(undefined,c,!![],a)});export const strictStatusErrorShape=(a,b,c)=>({'result':{'status':'error','error':a}});function checkProjectStage(a,b,c){const d={'analyze_intent':'puzzle','aggregate_risks':'risk','trace_substeps':'substeps'},e=d[a];if(!e)return null;const f=getStageCache(b,c);if(!f){if(a==='analyze_intent')return null;return'project_stage:\x20calling\x20\x27'+a+'\x27\x20before\x20\x27analyze_intent\x27\x20—\x20recommend\x20calling\x20analyze_intent\x20first\x20for\x20project\x20\x27'+b+':'+c+'\x27';}if(stageIndexOf(f['stage'])<stageIndexOf(e)-0x1)return'project_stage:\x20calling\x20\x27'+a+'\x27\x20(stage\x20\x27'+e+'\x27)\x20but\x20project\x20is\x20at\x20stage\x20\x27'+f['stage']+'\x27\x20—\x20recommend\x20completing\x20prior\x20stages\x20first\x20for\x20\x27'+b+':'+c+'\x27';return null;}export function dispatchWithHarness(a,b){return async(d,f)=>{const g=[],h=getHarness(),i=shouldRunLightHooks(),j=shouldRunHeavyHooks(),k=isPublishOperation(b,d),l=isSignOperation(b,d),m=getHarnessTier();if(b==='goal_operation'&&i)try{const o=d,p=o?.['action'],q=o?.['project'],r=o?.['version'];if(p&&q&&r){const s=checkProjectStage(p,q,r);s&&g['push'](s);}}catch{}k&&m==='lightweight'&&(setHarnessTier('full'),g['push']('pre_publish:\x20tier\x20forced\x20to\x20full\x20for\x20publish-class\x20operation\x20(GLM5-21\x20§3.3)'));if(k&&m!=='off')try{const t=await runPrePublishChecks(b,d);g['push'](...t['warnings']);if(t['critical']['length']>0x0){for(const u of t['critical']){const v=recordCriticalRisk(u);if(v)g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+v['reason']);}return buildHarnessBlockResult('pre_publish','Publish\x20BLOCKED\x20by\x20Harness\x20pre-publish\x20gate\x20(GLM5-21\x20V6):\x20'+(t['critical']['length']+'\x20CRITICAL\x20risk(s)\x20must\x20be\x20resolved\x20before\x20publish.'),t['critical'],t['warnings'],'immutable_violation','Fix\x20the\x20CRITICAL\x20risks\x20listed\x20in\x20the\x20message\x20(e.g.\x20rename\x20dispute/refund\x20nodes\x20per\x20R-M1-11,\x20add\x20the\x20entry\x20pair\x20prev_node=\x22\x22),\x20then\x20retry\x20publish.\x20Nodes/pairs/forwards\x20are\x20immutable\x20after\x20publish\x20—\x20verify\x20via\x20machineNode2file\x20first.');}}catch(x){g['push']('pre_publish\x20hook\x20failed:\x20'+(x instanceof Error?x['message']:String(x)));}if(l&&j)try{const y=extractData(d),z=y?extractAmount(y,{'excludeConfigAmounts':!![]}):null;if(z!==null){const A=getAmountThreshold();let B=null;try{B=BigInt(z);}catch{B=null;}if(B!==null&&B>A)return buildHarnessBlockResult('pre_sign','Sign\x20BLOCKED\x20by\x20Harness\x20pre-sign\x20gate\x20(GLM5-21\x20V7):\x20amount\x20'+formatAmount(B)+'\x20WOW\x20exceeds\x20the\x20full-tier\x20threshold\x20'+formatAmount(A)+'\x20WOW.',['amount\x20'+z+'\x20(smallest\x20unit)\x20>\x20threshold\x20'+A['toString']()+'\x20(smallest\x20unit)'],[],'invalid_parameter','Raise\x20WOWOK_AMOUNT_THRESHOLD\x20to\x20match\x20the\x20intended\x20amount,\x20split\x20the\x20transaction,\x20or\x20reset\x20the\x20harness\x20tier\x20to\x20lightweight\x20(config_operation)\x20after\x20explicit\x20user\x20confirmation.');}}catch(C){g['push']('pre_sign\x20hook\x20failed:\x20'+(C instanceof Error?C['message']:String(C)));}let n;try{n=await a(d,f);}catch(D){const E=D instanceof Error?D['message']:String(D),F=recordOperationFailure(b,E);F&&g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+F['reason']);if(b==='onchain_operations')try{const G=classifyError(E,D);if(!G['retryable']&&G['error_code']!=='unknown'){const H=recordCriticalOperation(b,G['error_code']);if(H)g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+H['reason']);}}catch{}throw D;}if(b==='onchain_operations')try{if(classifyOutcome(n)==='failed'){const I=extractErrorCode(n)??'',J=classifyError(I);if(!J['retryable']&&J['error_code']!=='unknown'){const K=recordCriticalOperation(b,J['error_code']);if(K)g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+K['reason']);}}}catch{}if(i&&!isOutcomeDiscriminated(n)){const L=extractIntent(b,d)??b;try{const M=classifyOutcome(n);if(M==='failed'){const N=extractErrorCode(n)??'',O=classifyError(N),P=h['recover'](O['error_code'],L,{'operation_type':b,'data':extractData(d)});g['push']('Harness\x20recover:\x20strategy='+P['strategy']+('\x20(attempt\x20'+P['current_attempt']+'/'+P['max_attempts']+')')+(P['should_retry']?'\x20—\x20retryable':'\x20—\x20do\x20NOT\x20retry\x20blindly')+(P['user_prompt']?'\x20—\x20'+P['user_prompt']:'\x20—\x20'+P['detail']));}else M==='success'&&h['resetRecovery'](L);}catch(Q){g['push']('recover\x20hook\x20failed:\x20'+(Q instanceof Error?Q['message']:String(Q)));}}if(b==='goal_operation')try{const R=d?.['action'];if(R==='trace_substeps'){const S=extractCriticalFindingCount(n);if(S>0x0){const T=recordSubstepFailure(String(R)+':\x20'+S+'\x20critical\x20finding(s)');if(T)g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+T['reason']);}}}catch{}if(isWriteClassTool(b)&&!SEMANTIC_RECORDED_TOOLS['has'](b))try{const U=extractOperationType(b,d)??b,V=extractIntent(b,d)??b,W=extractData(d)??d,X=classifyOutcome(n),Y=extractErrorCode(n),Z=isEnabled('experience_layer');if(Z)recordOperationOutcome(U,W,V,X,Y);else{const a0=extractIndustry(d);a0&&isEnabled('industry_evolution')&&recordIndustrySignal(a0,{'type':U},{'success':X==='success','error_code':Y});}}catch(a1){g['push']('signal\x20collection\x20failed:\x20'+(a1 instanceof Error?a1['message']:String(a1)));}if(g['length']>0x0){if(n?.['structuredContent']){const a2=n['structuredContent'],a3=a2['semantic'];if(a3){const a4=Array['isArray'](a3['warnings'])?a3['warnings']:[];a3['warnings']=[...a4,...g];}else for(const a5 of g){console['warn']('[harness]\x20'+a5);}}else for(const a6 of g){console['warn']('[harness]\x20'+a6);}}return n;};}function isPublishOperation(a,b){if(a!=='onchain_operations')return![];const c=extractOperationType(a,b);if(c!=='service'&&c!=='machine')return![];const d=extractData(b);return d?.['publish']===!![]||d?.['bPublished']===!![];}function isSignOperation(a,b){if(a==='wip_file'){const c=b?.['operation_type'];return c==='sign';}return a==='onchain_operations';}function extractOperationType(a,b){if(!b||typeof b!=='object')return undefined;const c=b;if(a==='onchain_operations')return typeof c['operation_type']==='string'?c['operation_type']:undefined;if(a==='goal_operation'||a==='industry_pack_operation'||a==='strategy_review_operation')return typeof c['action']==='string'?c['action']:undefined;return typeof c['operation_type']==='string'?c['operation_type']:undefined;}function extractIntent(a,b){if(!b||typeof b!=='object')return undefined;const c=b;if((a==='goal_operation'||a==='industry_pack_operation'||a==='strategy_review_operation')&&typeof c['action']==='string')return a+':'+c['action'];const d=c['operation_type'];if(typeof d==='string')return a+':'+d;return a;}function extractData(a){if(!a||typeof a!=='object')return undefined;const b=a,c=b['data'];return c&&typeof c==='object'?c:undefined;}const WRITE_CLASS_TOOLS=new Set(['onchain_operations','goal_operation','industry_pack_operation','strategy_review_operation','wip_file','messenger_operation','bridge_operation']),SEMANTIC_RECORDED_TOOLS=new Set(['onchain_operations','bridge_operation']);function isWriteClassTool(a){return WRITE_CLASS_TOOLS['has'](a);}function classifyOutcome(a){if(!a?.['structuredContent'])return'failed';const b=a['structuredContent'];if(b['outcome']==='failed')return'failed';if(b['outcome']==='executed')return'success';if(b['outcome']==='pending_input')return'partial';const c=typeof b['status']==='string'?b['status']:typeof b['result_type']==='string'?b['result_type']:'';if(c==='error'||c==='failed')return'failed';if(c==='partial')return'partial';return'success';}function isOutcomeDiscriminated(a){const b=a?.['structuredContent'];return!!b&&typeof b==='object'&&'outcome'in b;}function extractErrorCode(a){if(!a?.['structuredContent'])return undefined;const b=a['structuredContent'];if(typeof b['error_code']==='string')return b['error_code'];const c=b['error'];if(typeof c==='string')return c;if(c&&typeof c==='object'){const d=c['code'];if(typeof d==='string')return d;}return undefined;}function extractIndustry(a){if(!a||typeof a!=='object')return undefined;const b=a;if(typeof b['industry']==='string')return b['industry'];const c=b['data'];if(c&&typeof c==='object'){const e=c;if(typeof e['industry']==='string')return e['industry'];}return undefined;}function numericBalance(a){if(typeof a==='number'&&Number['isFinite'](a))return a;if(typeof a==='string'&&a['trim']()!==''&&Number['isFinite'](Number(a)))return Number(a);return undefined;}async function runPrePublishChecks(a,b){const c=[],d=[],f=extractOperationType(a,b),g=extractData(b)??{};if(f==='machine'){const h=g['node'];let i=Array['isArray'](h)?h:Array['isArray'](h?.['nodes'])?h['nodes']:[];if(i['length']===0x0&&typeof g['object']==='string'){const j=g['object'],k=b?.['env']?.['network'];try{const l=await fetchMachineNodes(j,k,!![]);l['length']>0x0&&(i=l,d['push']('pre_publish:\x20machine\x20\x22'+j+'\x22\x20published\x20by\x20reference\x20—\x20audited\x20against\x20its\x20'+(l['length']+'\x20on-chain\x20node(s)\x20(effective-state\x20gate)')));}catch(m){d['push']('pre_publish:\x20could\x20not\x20fetch\x20on-chain\x20nodes\x20for\x20machine\x20\x22'+j+'\x22\x20'+('('+(m instanceof Error?m['message']:String(m))+')\x20—\x20topology\x20not\x20verifiable\x20in\x20this\x20call;\x20')+'verify\x20via\x20machineNode2file\x20BEFORE\x20publish\x20(immutable\x20after\x20publish,\x20IMMUT-001)');}}if(i['length']>0x0){const n=auditMachineNodes(i);c['push'](...n['critical']),d['push'](...n['warnings']);}else typeof g['object']!=='string'&&d['push']('pre_publish:\x20publishing\x20machine\x20without\x20inline\x20node\x20data\x20—\x20topology\x20not\x20verifiable\x20in\x20this\x20call;\x20'+'verify\x20nodes/pairs/forwards\x20via\x20machineNode2file\x20BEFORE\x20publish\x20(immutable\x20after\x20publish,\x20IMMUT-001)');d['push']('pre_publish:\x20machine\x20nodes/pairs/forwards\x20become\x20immutable\x20after\x20publish\x20(IMMUT-001)');}if(f==='service'){d['push']('pre_publish:\x20service\x20machine/order_allocators/arbitrations\x20become\x20immutable\x20after\x20publish\x20(IMMUT-002);\x20sales\x20remains\x20modifiable');g['machine']===undefined&&d['push']('pre_publish:\x20\x27machine\x27\x20not\x20set\x20in\x20this\x20call\x20—\x20if\x20the\x20service\x20was\x20never\x20bound\x20to\x20a\x20published\x20machine,\x20'+'it\x20cannot\x20process\x20orders\x20and\x20CANNOT\x20be\x20fixed\x20after\x20publish');g['order_allocators']===undefined&&d['push']('pre_publish:\x20\x27order_allocators\x27\x20not\x20set\x20in\x20this\x20call\x20—\x20immutable\x20after\x20publish;\x20'+'orders\x20will\x20have\x20no\x20fund\x20distribution\x20if\x20never\x20configured');const o=g,p=numericBalance(o['compensation_fund_add']?.['balance']);if(p!==undefined&&p>0x0){const q=o['sales'],r=(Array['isArray'](q?.['sales'])?q['sales']:[])['map'](s=>numericBalance(s?.['price']?.['balance']))['filter'](s=>s!==undefined);if(r['length']>0x0){const s=r['reduce']((u,v)=>u+v,0x0),t=s*0x3;if(t>0x0){const u=p/t,v=getFundCoverageMin(),w='fund='+p+',\x20max\x20single\x20order=Σ(price×1)='+s+'\x20(quantity\x20set\x20at\x20buy\x20time),\x20'+('award\x20cap=3×order='+t+'\x20(MAX_INDEMNITY_MULTIPLE),\x20coverage='+u['toFixed'](0x2));if(v>0x0&&u<v)d['push']('pre_publish:\x20G7\x20advisory\x20—\x20compensation-fund\x20coverage\x20below\x20the\x20configured\x20minimum\x20—\x20'+w+'\x20<\x20'+v+'.\x20'+'Awards\x20beyond\x20the\x20fund\x20draw\x20from\x20the\x20merchant\x20wallet.\x20'+'Consider\x20adding\x20funds\x20(compensation_fund_add),\x20or\x20set\x20WOWOK_FUND_COVERAGE_MIN\x20'+'(0\x20silences\x20this\x20advisory).\x20Informational\x20—\x20does\x20not\x20block\x20publish');else u<0x1&&d['push']('pre_publish:\x20compensation-fund\x20coverage\x20below\x20the\x20award\x20ceiling\x20—\x20'+w+'\x20<\x201\x20—\x20'+'awards\x20beyond\x20the\x20fund\x20draw\x20from\x20the\x20merchant\x20wallet.\x20Informational');}}else d['push']('pre_publish:\x20compensation_fund_add\x20present\x20but\x20sales\x20not\x20set\x20in\x20this\x20call\x20—\x20verify\x20coverage\x20manually:\x20'+'the\x20fund\x20must\x20cover\x203×\x20the\x20maximum\x20single-order\x20amount\x20(MAX_INDEMNITY_MULTIPLE=3)');}}return{'critical':c,'warnings':d};}function buildHarnessBlockResult(a,b,c,d,e,f){const g=[...c['map'](i=>'CRITICAL:\x20'+i),...d['map'](i=>'WARN:\x20'+i)]['join']('\x0a'),h='Error:\x20'+b+(g?'\x0a'+g:'')+'\x0aRecovery:\x20'+f;return{'content':[{'type':'text','text':h}],'structuredContent':{'outcome':'failed','result':{'type':'error','error':b+'\x20[gate='+a+']','error_code':e,'retryable':![],'recovery_hint':f},'message':h,'recovery':recover(e,'harness:'+a)}};}function extractCriticalFindingCount(a){const b=a?.['structuredContent'];if(!b)return 0x0;const c=b['semantic'],d=c?.['summary'];if(typeof d?.['critical_count']==='number'&&d['critical_count']>0x0)return d['critical_count'];const e=b['findings']??c?.['findings'];if(Array['isArray'](e))return e['filter'](h=>h?.['severity']==='error')['length'];const f=a?.['content']?.['map'](h=>'text'in h?h['text']:'')['join']('\x0a')??'',g=f['match'](/\[AUDIT ERROR\]/g);return g?g['length']:0x0;}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wowok/agent-mcp",
3
- "version": "3.1.6",
3
+ "version": "3.2.0",
4
4
  "description": "Making It Easy for AI Agents to Communicate, Collaborate, Trade, and Trust.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -54,7 +54,7 @@
54
54
  "license": "Apache-2.0",
55
55
  "dependencies": {
56
56
  "@modelcontextprotocol/server": "^2.0.0",
57
- "@wowok/wowok": "3.1.6",
57
+ "@wowok/wowok": "3.2.0",
58
58
  "lodash": "^4.18.1",
59
59
  "zod": "^4.2.0"
60
60
  },
@@ -1 +0,0 @@
1
- import{mkdtempSync,writeFileSync}from'node:fs';import{tmpdir}from'node:os';import{join}from'node:path';import{afterAll,beforeAll,describe,expect,it}from'vitest';import{beginPolicyRun,endPolicyRun,factoryRulePack,getJudgmentDoc,judgmentStatus}from'../config/judgment.js';import{evaluateRuleBook}from'../config/rule-engine.js';import{serviceAllocatorAuditNodeAnalyzer}from'./service-allocator-audit-node.js';const CONFIG_DIR=mkdtempSync(join(tmpdir(),'wowok-alloc-audit-'));process['env']['WOWOK_CONFIG_DIR']=CONFIG_DIR;const PACK_IDS=['RC-FIND-01','RC-FIND-02','RC-FIND-03','RC-FIND-04','RC-FIND-05','RC-FIND-06','RC-FIND-07','RC-FIND-08','RC-FIND-09','RC-GAP','RC-SUMMARY'];function rule(a,b){const c=factoryRulePack('alloc_audit');if(!c)throw new Error('alloc_audit\x20factory\x20pack\x20missing');const d=c['rules']['find'](e=>e['rule_id']===a);if(!d)throw new Error('rule\x20'+a+'\x20missing');return evaluateRuleBook([d],b)['findings'][0x0];}const BASE={'host_service':'0xsvc','code':'RC-FIND-01','base_level':'high','evidence_paths':'(root)','evidence_count':0x0};function resnapshot(){endPolicyRun(),beginPolicyRun();}beforeAll(()=>{beginPolicyRun();}),afterAll(()=>{endPolicyRun();}),describe('alloc_audit\x20factory\x20parity\x20—\x20per-finding\x20rules',()=>{it('the\x20pack\x20carries\x20exactly\x20the\x20canonical\x20emission\x20ids',()=>{const a=factoryRulePack('alloc_audit');expect(a)['not']['toBeNull'](),expect(a['rules']['map'](b=>b['rule_id'])['sort']())['toEqual']([...PACK_IDS]['sort']());}),it('fact:base_level\x20passes\x20the\x20kernel\x20severity\x20through\x20unchanged',()=>{for(const a of['high','medium','low']){expect(rule('RC-FIND-01',{...BASE,'base_level':a})?.['level'])['toBe'](a);}}),it('copy\x20is\x20pack-owned\x20and\x20interpolates\x20the\x20kernel\x20facts',()=>{const a=rule('RC-FIND-01',{...BASE,'evidence_paths':'root.and(0)'});expect(a?.['title'])['toBe']('Fund\x20theft\x20risk:\x20Signer\x20recipient\x20without\x20caller\x20identity\x20constraint'),expect(a?.['description'])['toContain']('service\x200xsvc'),expect(a?.['description'])['toContain']('rule\x20RC-FIND-01,\x20evidence\x20paths\x20root.and(0)'),expect(a?.['mitigation'])['toContain']('do\x20NOT\x20pay\x20this\x20service\x20before\x20the\x20fix');}),it('fixed\x20levels\x20hold\x20where\x20the\x20kernel\x20hardcoded\x20them',()=>{expect(rule('RC-FIND-05',{...BASE,'code':'RC-FIND-05','base_level':'high'})?.['level'])['toBe']('medium'),expect(rule('RC-FIND-06',{...BASE,'code':'RC-FIND-06','base_level':'high'})?.['level'])['toBe']('low'),expect(rule('RC-FIND-07',{...BASE,'code':'RC-FIND-07','base_level':'high'})?.['level'])['toBe']('medium');}),it('shortfall\x20findings\x20(05/07)\x20carry\x20loss\x20parties\x20only\x20and\x20are\x20never\x20downgraded',()=>{for(const a of['RC-FIND-05','RC-FIND-07']){const b=rule(a,{...BASE,'code':a});expect(b?.['exposure']?.['gainPaths'])['toHaveLength'](0x0),expect(b?.['exposure']?.['lossParties']['length'])['toBeGreaterThan'](0x0),expect(b?.['exposure']?.['verdict'])['toBe']('confirmed'),expect(b?.['level'])['not']['toBe']('info');}expect(rule('RC-FIND-05',{...BASE,'code':'RC-FIND-05'})?.['exposure']?.['lossParties']['map'](c=>c['role']))['toEqual'](['supplier','buyer']);}),it('RC-FIND-08\x20keeps\x20its\x20level\x20as\x20pending-disclosure\x20(undecided\x20predicate)',()=>{const a=rule('RC-FIND-08',{...BASE,'code':'RC-FIND-08','base_level':'medium','evidence_count':0x2});expect(a?.['level'])['toBe']('medium'),expect(a?.['description'])['toContain']('composes\x202\x20sub-guard(s)'),expect(a?.['exposure']?.['verdict'])['toBe']('pending-disclosure'),expect(a?.['exposure']?.['gainPaths'][0x0]?.['viability'])['toBe']('unverifiable');}),it('RC-FIND-09\x20stays\x20low\x20(visibility\x20hint\x20—\x20omission\x20is\x20often\x20intended,\x20not\x20theft)',()=>{const a=rule('RC-FIND-09',{...BASE,'code':'RC-FIND-09','base_level':'low'});expect(a?.['level'])['toBe']('low'),expect(a?.['mitigation'])['toContain']('anchor\x20row'),expect(a?.['description'])['toContain']('confirm\x20it\x20is');}),it('an\x20unknown\x20canonical\x20code\x20fires\x20no\x20case\x20(kernel\x20fallback\x20stays\x20in\x20charge)',()=>{const a=factoryRulePack('alloc_audit'),b=a['rules']['find'](d=>d['rule_id']==='RC-FIND-01'),{findings:c}=evaluateRuleBook([b],{...BASE,'code':'RC-FIND-99'});expect(c)['toHaveLength'](0x0);});}),describe('alloc_audit\x20factory\x20parity\x20—\x20gap\x20and\x20verdict',()=>{it('RC-GAP\x20emits\x20info\x20with\x20the\x20unfetched\x20evidence\x20interpolated',()=>{const a=rule('RC-GAP',{'host_service':'0xsvc','unfetched_count':0x2,'unfetched_list':'0xa,\x200xb\x20(guard.relies)'});expect(a?.['level'])['toBe']('info'),expect(a?.['title'])['toContain']('evidence\x20gap'),expect(a?.['description'])['toContain']('references\x202\x20guard(s)'),expect(a?.['description'])['toContain']('0xa,\x200xb\x20(guard.relies)'),expect(a?.['exposure']?.['gainPaths'])['toHaveLength'](0x0),expect(a?.['exposure']?.['verdict'])['toBe']('confirmed');}),it('RC-SUMMARY\x20—\x20unsafe\x20wins\x20at\x20high,\x20with\x20and\x20without\x20the\x20residual\x20suffix',()=>{const a=rule('RC-SUMMARY',summaryFacts({'dest_unsafe':!![],'resolution_required':![]}));expect(a?.['level'])['toBe']('high'),expect(a?.['title'])['toBe']('Fund\x20destination\x20and\x20condition\x20integrity:\x20stealable\x20destination\x20exists'),expect(a?.['description'])['toContain']('WARNING:\x20an\x20unbound\x20Signer\x20direct-pay\x20path\x20exists'),expect(a?.['exposure']?.['gainPaths'][0x0]?.['viability'])['toBe']('viable'),expect(a?.['exposure']?.['verdict'])['toBe']('confirmed');const b=rule('RC-SUMMARY',summaryFacts({'dest_unsafe':!![],'resolution_required':!![]}));expect(b?.['level'])['toBe']('high'),expect(b?.['title'])['toBe']('Fund\x20destination\x20and\x20condition\x20integrity:\x20stealable\x20destination\x20exists\x20(residual\x20requires\x20explicit\x20decision)');}),it('RC-SUMMARY\x20—\x20safe\x20+\x20residual\x20is\x20medium\x20conditional\x20with\x20the\x20destinations\x20interpolated',()=>{const a=rule('RC-SUMMARY',summaryFacts({'dest_unsafe':![],'resolution_required':!![]}));expect(a?.['level'])['toBe']('medium'),expect(a?.['title'])['toBe']('Fund\x20destination\x20and\x20condition\x20integrity:\x20destination\x20safe\x20(residual\x20requires\x20explicit\x20decision)'),expect(a?.['exposure']?.['gainPaths'][0x0]?.['viability'])['toBe']('conditional'),expect(a?.['exposure']?.['lossParties'][0x0]?.['basis'])['toContain']('0xmerchant'),expect(a?.['exposure']?.['verdict'])['toBe']('confirmed');}),it('RC-SUMMARY\x20—\x20fully\x20safe\x20downgrades\x20to\x20info\x20(redirect\x20provably\x20blocked)',()=>{const a=rule('RC-SUMMARY',summaryFacts({'dest_unsafe':![],'resolution_required':![]}));expect(a?.['level'])['toBe']('info'),expect(a?.['title'])['toBe']('Fund\x20destination\x20and\x20condition\x20integrity:\x20destination\x20safe'),expect(a?.['exposure']?.['gainPaths'][0x0]?.['viability'])['toBe']('blocked'),expect(a?.['exposure']?.['verdict'])['toBe']('downgraded'),expect(a?.['exposure']?.['baseSeverity'])['toBe']('info');});});function summaryFacts(a){return{'host_service':'0xsvc','allocator_count':0x1,'guard_count':0x1,'destinations_text':'0xmerchant','dest_unsafe':a['dest_unsafe'],'resolution_required':a['resolution_required'],'audit_summary':'Analyzed\x201\x20allocator(s):\x201\x20actionable,\x200\x20unavoidable.'};}const GUARD='0xguard0000000000000000000000000000000000000000000000000000000001';function serviceNode(){return{'id':'0xsvc','kind':'object','state':'fetched','origins':[],'depth':0x0,'raw':{'data':{'order_allocators':{'allocators':[{'guard':GUARD,'sharing':[{'who':{'Signer':!![]},'sharing':'10000','mode':'Rate'}]}]}}}};}function guardNode(){return{'id':GUARD,'kind':'object','state':'fetched','origins':[],'depth':0x1,'raw':{'data':{'table':[],'root':{'type':'value','value':!![]}}}};}function viewport(){return{'visibleEdges':[{'id':'service.order_allocator_guard|0xsvc→'+GUARD,'schema':'service.order_allocator_guard','family':'F','from':'0xsvc','to':GUARD,'retention':'complete','observedAt':0x0}],'graph':{'nodes':new Map([[GUARD,guardNode()]])}};}function scopedGuardNode(a){return{'id':GUARD,'kind':'object','state':'fetched','origins':[],'depth':0x1,'raw':{'data':{'table':[{'identifier':0x0,'b_submission':!![],'value_type':a,'value':undefined,'name':'order_slot'},{'identifier':0x2,'b_submission':![],'value_type':'Address','value':'0xsvc','name':'svc'}],'root':{'type':'logic_and','nodes':[{'type':'logic_equal','nodes':[{'type':'query','query':'order.service','object':{'identifier':0x0}},{'type':'identifier','identifier':0x2}]}]}}}};}function scopedServiceNode(){return{'id':'0xsvc','kind':'object','state':'fetched','origins':[],'depth':0x0,'raw':{'data':{'order_allocators':{'allocators':[{'guard':GUARD,'sharing':[{'who':{'GuardIdentifier':0x0},'sharing':'10000','mode':'Rate'}]}]}}}};}function scopedViewport(a){return{'visibleEdges':[{'id':'service.order_allocator_guard|0xsvc→'+GUARD,'schema':'service.order_allocator_guard','family':'F','from':'0xsvc','to':GUARD,'retention':'complete','observedAt':0x0}],'graph':{'nodes':new Map([[GUARD,scopedGuardNode(a)]])}};}describe('alloc_audit\x20binding\x20—\x20identifier-constant\x20scope\x20binding\x20(docs#44-b)',()=>{it('does\x20NOT\x20fire\x20RC-FIND-02\x20when\x20the\x20table\x20constant\x20is\x20a\x20chain-serialized\x20type\x20name',()=>{const a=serviceAllocatorAuditNodeAnalyzer['run'](scopedServiceNode(),scopedViewport('Address'));expect(a['map'](c=>c['title'])['some'](c=>c['includes']('no\x20scope\x20binding')))['toBe'](![]);const b=a['find'](c=>c['title']['startsWith']('Fund\x20destination\x20and\x20condition\x20integrity'));expect(b?.['title'])['toContain']('destination\x20safe');}),it('does\x20NOT\x20fire\x20RC-FIND-02\x20when\x20the\x20table\x20constant\x20is\x20a\x20numeric\x20value_type\x20enum',()=>{const a=serviceAllocatorAuditNodeAnalyzer['run'](scopedServiceNode(),scopedViewport(0x1));expect(a['map'](c=>c['title'])['some'](c=>c['includes']('no\x20scope\x20binding')))['toBe'](![]);const b=a['find'](c=>c['title']['startsWith']('Fund\x20destination\x20and\x20condition\x20integrity'));expect(b?.['title'])['toContain']('destination\x20safe');});}),describe('alloc_audit\x20binding\x20—\x20end\x20to\x20end',()=>{it('a\x20signer-recipient\x20service\x20yields\x20the\x20pack-driven\x20theft\x20finding\x20+\x20unsafe\x20verdict',()=>{const a=serviceAllocatorAuditNodeAnalyzer['run'](serviceNode(),viewport());expect(a)['toHaveLength'](0x4);const [b,c,d,e]=a;expect(b['id'])['toBe']('ALC1:0xsvc#0'),expect(b['title'])['toBe']('Fund\x20theft\x20risk:\x20Signer\x20recipient\x20without\x20caller\x20identity\x20constraint'),expect(b['severity'])['toBe']('high'),expect(b['exposure']?.['verdict'])['toBe']('confirmed'),expect(b['exposure']?.['gainPaths'][0x0]?.['viability'])['toBe']('viable'),expect(b['detail'])['toContain']('service\x200xsvc'),expect(c['id'])['toBe']('ALC1:0xsvc#1'),expect(c['title'])['toBe']('Allocator\x20Guard\x20has\x20no\x20GuardIdentifier\x20sharing\x20row\x20—\x20bound\x20to\x20no\x20particular\x20order'),expect(c['severity'])['toBe']('low'),expect(d['id'])['toBe']('ALC1:0xsvc#2'),expect(d['title'])['toBe']('Permissionless\x20alloc\x20—\x20settlement\x20timing\x20can\x20be\x20front-run'),expect(d['severity'])['toBe']('low'),expect(d['exposure']?.['verdict'])['toBe']('confirmed'),expect(e['id'])['toBe']('ALC1:0xsvc#3'),expect(e['title'])['toBe']('Fund\x20destination\x20and\x20condition\x20integrity:\x20stealable\x20destination\x20exists'),expect(e['severity'])['toBe']('high'),expect(e['detail'])['toContain']('1\x20allocator(s)\x20/\x201\x20resolved\x20guard(s)');}),it('a\x20user\x20disable\x20suppresses\x20the\x20theft\x20finding;\x20the\x20verdict\x20stays',()=>{writeFileSync(join(CONFIG_DIR,'judgment.json'),JSON['stringify']({'version':0x1,'rules':{'domains':{'alloc_audit':{'rules':[{'rule_id':'RC-FIND-01','enabled':![]}]}}}}),'utf-8'),resnapshot();const a=serviceAllocatorAuditNodeAnalyzer['run'](serviceNode(),viewport());expect(a['map'](c=>c['title']))['toEqual'](['Allocator\x20Guard\x20has\x20no\x20GuardIdentifier\x20sharing\x20row\x20—\x20bound\x20to\x20no\x20particular\x20order','Permissionless\x20alloc\x20—\x20settlement\x20timing\x20can\x20be\x20front-run','Fund\x20destination\x20and\x20condition\x20integrity:\x20stealable\x20destination\x20exists']);const b=judgmentStatus();expect(b['user_doc_loaded'])['toBe'](!![]);}),it('a\x20fact:\x20reference\x20outside\x20the\x20factory\x20vocabulary\x20is\x20rejected\x20loudly;\x20the\x20factory\x20keeps\x20serving',()=>{writeFileSync(join(CONFIG_DIR,'judgment.json'),JSON['stringify']({'version':0x1,'rules':{'domains':{'alloc_audit':{'rules':[{'rule_id':'RC-FIND-01','cases':[{'when':{'field':'code','op':'eq','value':'RC-FIND-01'},'level':'fact:not_a_kernel_fact','title':'t','description':'d'}]}]}}}}),'utf-8'),void getJudgmentDoc(),resnapshot();const a=judgmentStatus();expect(a['last_reload_error'])['toContain']('fact:not_a_kernel_fact'),expect(a['last_reload_error'])['toContain']('RC-FIND-01');const b=serviceAllocatorAuditNodeAnalyzer['run'](serviceNode(),viewport());expect(b['map'](c=>c['title']))['toEqual'](['Allocator\x20Guard\x20has\x20no\x20GuardIdentifier\x20sharing\x20row\x20—\x20bound\x20to\x20no\x20particular\x20order','Permissionless\x20alloc\x20—\x20settlement\x20timing\x20can\x20be\x20front-run','Fund\x20destination\x20and\x20condition\x20integrity:\x20stealable\x20destination\x20exists']);});});
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- import{describe,expect,it}from'vitest';import{EVENT_SEMANTIC_REGISTRY}from'./event-semantics.js';const EXPECTED_EVENTS=['NewOrderEvent','ArbEvent','ArbitrationEvent','VoteEvent','FeedbackEvent','DemandPresentEvent','DemandFeedbackEvent','DemandChangedEvent','ProgressEvent','NewEntityEvent','ServiceEvent','AllocationEvent','TreasuryEvent','RewardClaimEvent','RewardFundEvent','NewPaymentEvent'];describe('event\x20semantics\x20channel\x20ownership\x20(N-3)',()=>{it('registry\x20covers\x20all\x2016\x20framework\x20events',()=>{expect(EVENT_SEMANTIC_REGISTRY['map'](a=>a['name'])['sort']())['toEqual']([...EXPECTED_EVENTS]['sort']());}),it('every\x20entry\x20declares\x20at\x20least\x20one\x20consumer\x20channel',()=>{for(const a of EVENT_SEMANTIC_REGISTRY){expect(a['consumers']['length'],a['name']+'\x20has\x20no\x20consumer\x20channel')['toBeGreaterThan'](0x0);}}),it('an\x20entry\x20without\x20any\x20push\x20consumer\x20must\x20document\x20why\x20(channel_note)',()=>{const a=['suggestion_bridge','problem_bridge'];for(const b of EVENT_SEMANTIC_REGISTRY){const c=b['consumers']['some'](d=>a['includes'](d));!c&&expect(b['channel_note'],b['name']+'\x20lacks\x20push\x20consumers\x20but\x20has\x20no\x20channel_note')['toBeTruthy']();}}),it('the\x20deliberate\x20non-bridge\x20events\x20carry\x20their\x20documented\x20ownership',()=>{const a=new Map(EVENT_SEMANTIC_REGISTRY['map'](b=>[b['name'],b]));for(const b of['VoteEvent','DemandChangedEvent','NewEntityEvent','ArbitrationEvent']){expect(a['get'](b)?.['consumers'])['toEqual'](['intent_radar']);}expect(a['get']('NewPaymentEvent')?.['consumers'])['toEqual'](['keeper','intent_radar']);});});
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- import{afterEach,beforeEach,describe,expect,it}from'vitest';import{existsSync,mkdtempSync,rmSync}from'node:fs';import{tmpdir}from'node:os';import{join}from'node:path';import{getJudgmentDoc}from'../config/judgment.js';const DOMAINS=['allocation','arb','arbitration','bridge','contact','demand','guard','machine','order','payment','permission','personal','proof','progress','registrar','repository','resource','reward','service','treasury','util'];import*as a163a from'./allocation-risk.js';import*as a163b from'./arb-risk.js';import*as a163c from'./arbitration-risk.js';import*as a163d from'./bridge-risk.js';import*as a163e from'./contact-risk.js';import*as a163f from'./demand-risk.js';import*as a163g from'./guard-risk.js';import*as a163h from'./machine-risk.js';import*as a163i from'./order-risk.js';import*as a163j from'./payment-risk.js';import*as a163k from'./permission-risk.js';import*as a163l from'./personal-risk.js';import*as a163m from'./proof-risk.js';import*as a163n from'./progress-risk.js';import*as a163o from'./registrar-risk.js';import*as a163p from'./repository-risk.js';import*as a163q from'./resource-risk.js';import*as a163r from'./reward-risk.js';import*as a163s from'./service-risk.js';import*as a163t from'./treasury-risk.js';import*as a163u from'./util-risk.js';const EXTRACTORS={'allocation':a163a,'arb':a163b,'arbitration':a163c,'bridge':a163d,'contact':a163e,'demand':a163f,'guard':a163g,'machine':a163h,'order':a163i,'payment':a163j,'permission':a163k,'personal':a163l,'proof':a163m,'progress':a163n,'registrar':a163o,'repository':a163p,'resource':a163q,'reward':a163r,'service':a163s,'treasury':a163t,'util':a163u};let configDir;beforeEach(()=>{configDir=mkdtempSync(join(tmpdir(),'wowok-facts-sync-')),process['env']['WOWOK_CONFIG_DIR']=configDir;}),afterEach(()=>{delete process['env']['WOWOK_CONFIG_DIR'];if(existsSync(configDir))rmSync(configDir,{'recursive':!![],'force':!![]});});function leafRoots(a,b){if('all'in a)a['all']['forEach'](d=>leafRoots(d,b));else{if('any'in a)a['any']['forEach'](d=>leafRoots(d,b));else'not'in a?leafRoots(a['not'],b):b['add'](a['field']['split']('.')[0x0]);}}function interpolationRoots(a,b,d){const e=a['rules']['find'](f=>f['rule_id']===b);if(!e)return;for(const f of e['cases']){for(const g of[f['title'],f['description'],f['mitigation'],f['evidence'],f['scenario']]){if(!g)continue;for(const h of g['matchAll'](/\$\{([^}]+)\}/g)){d['add'](h[0x1]['split']('.')[0x0]);}}}}function domainPack(a,b){const c=a['rules']['domains'][b];return expect(c,'factory\x20rule\x20pack\x20\x27'+b+'\x27\x20missing')['toBeTruthy'](),c;}const PROBE_PARTIAL_EXTRACTORS=new Set(['guard','machine','reward']),PROBE_ARGS={'machine':[{'pairs':[],'nodes':[]},{}]};describe('fact\x20vocabulary\x20↔\x20kernel\x20extractor\x20sync\x20(Q9)',()=>{it('pack-declared\x20facts\x20match\x20the\x20extractor\x20output\x20vocabulary\x20exactly',()=>{const a=getJudgmentDoc();for(const b of DOMAINS){const c=domainPack(a,b),d=EXTRACTORS[b];expect(d,'extractor\x20module\x20for\x20\x27'+b+'\x27\x20not\x20registered')['toBeTruthy']();const e=d[b+'RiskFacts'];expect(e,'extractor\x20\x27'+b+'RiskFacts\x27\x20missing\x20in\x20knowledge/'+b+'-risk.js')['toBeTypeOf']('function');const f=Object['keys'](e(...PROBE_ARGS[b]??[{},{}])),g=Object['keys'](c['facts']??{});expect(g,b+':\x20pack\x20facts\x20record\x20missing')['not']['toHaveLength'](0x0);const h=f['filter'](i=>!g['includes'](i));expect(h,b+':\x20emitted\x20facts\x20not\x20documented\x20in\x20the\x20pack')['toEqual']([]);if(!PROBE_PARTIAL_EXTRACTORS['has'](b)){const i=g['filter'](j=>!f['includes'](j));expect(i,b+':\x20documented\x20facts\x20no\x20longer\x20emitted')['toEqual']([]);}}}),it('every\x20fact\x20a\x20rule\x20references\x20exists\x20in\x20the\x20extractor\x20vocabulary',()=>{const a=getJudgmentDoc();for(const b of DOMAINS){const d=domainPack(a,b),e=EXTRACTORS[b][b+'RiskFacts'],f=new Set(Object['keys'](e(...PROBE_ARGS[b]??[{},{}]))),g=PROBE_PARTIAL_EXTRACTORS['has'](b);for(const h of d['rules']){if(h['enabled']===![])continue;const i=new Set();for(const j of h['cases'])leafRoots(j['when'],i);interpolationRoots(d,h['rule_id'],i);for(const k of i){const l=g?new Set(Object['keys'](d['facts']??{})):f;expect(l['has'](k),b+'/'+h['rule_id']+':\x20references\x20unknown\x20fact\x20\x27'+k+'\x27\x20(dead\x20condition\x20or\x20stale\x20text)')['toBe'](!![]);}}}});});
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- import{describe,it,expect}from'vitest';import{GUARD_DESIGN_PATTERNS,GUARD_SCHEMA_NOTES}from'./guard-design-patterns.js';import{SCHEMA_TO_SEMANTIC_RULES}from'./guard-translation.js';const NODE_TOKEN_RE=/\b((?:logic|calc|vec|convert|query)_[a-z0-9_]+)\s*[\[(]/g,ALIAS_RE=/\blogic_as_u256_(gt|lt|eq|ge|le)\b/,nodeTypeNames=new Set(SCHEMA_TO_SEMANTIC_RULES['filter'](a=>a['element_type']==='node')['map'](a=>a['type_name'])),witnessTypeNames=new Set(SCHEMA_TO_SEMANTIC_RULES['filter'](a=>a['element_type']==='witness')['map'](a=>a['type_name']));function extractTokens(...a){const b=new Set();for(const c of a){if(!c)continue;for(const d of c['matchAll'](NODE_TOKEN_RE))b['add'](d[0x1]);}return[...b];}describe('guard\x20design\x20patterns\x20vs\x20schema\x20(docs#43-a\x20CI\x20check)',()=>{it('every\x20node\x20token\x20in\x20logic_summary/notes\x20exists\x20in\x20the\x20schema',()=>{const a=[];for(const b of GUARD_DESIGN_PATTERNS){for(const c of extractTokens(b['logic_summary'],...b['notes']??[])){!nodeTypeNames['has'](c)&&a['push'](b['id']+':\x20\x27'+c+'\x27\x20is\x20not\x20a\x20schema\x20node\x20type');}}expect(a)['toEqual']([]);}),it('every\x20witness_types\x20entry\x20maps\x20to\x20a\x20schema\x20witness\x20type\x20(Type*\x20prefix)',()=>{const a=[];for(const b of GUARD_DESIGN_PATTERNS){for(const c of b['witness_types']??[]){!witnessTypeNames['has']('Type'+c)&&a['push'](b['id']+':\x20witness\x20\x27'+c+'\x27\x20has\x20no\x20Type'+c+'\x20in\x20the\x20schema');}}expect(a)['toEqual']([]);}),it('no\x20abbreviated\x20comparator\x20aliases\x20in\x20logic_summary\x20or\x20notes',()=>{const a=GUARD_DESIGN_PATTERNS['filter'](b=>ALIAS_RE['test'](b['logic_summary'])||(b['notes']??[])['some'](c=>ALIAS_RE['test'](c)))['map'](b=>b['id']);expect(a)['toEqual']([]);}),it('GUARD_SCHEMA_NOTES\x20covers\x20the\x20known\x20gotchas\x20(where\x20required,\x20child\x20cap,\x20no\x20aliases)',()=>{expect(GUARD_SCHEMA_NOTES['length'])['toBeGreaterThanOrEqual'](0x3);const a=GUARD_SCHEMA_NOTES['join']('\x20');expect(a)['toContain']('where:\x20{}'),expect(a)['toContain']('MAX_MULTI_OPERANDS'),expect(a)['toContain']('logic_as_u256_greater_or_equal');});});
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- import{describe,expect,it}from'vitest';import{evaluateGuardDraft}from'./guard-eval.js';import{findScene}from'./guard-ledger.js';const TRIGGER={'table':[{'identifier':0x0,'b_submission':![],'value_type':'Address','value':'0xabc','name':'selector'}],'root':{'type':'identifier','identifier':0x0},'scene':findScene('Service','order_allocators')};describe('guard\x20draft\x20evaluation\x20—\x20unified\x20registry\x20bridge\x20(T27)',()=>{it('runs\x20rules\x20through\x20the\x20registry\x20with\x20GD1\x20native\x20risks\x20carried\x20on\x20findings',()=>{const {findings:a}=evaluateGuardDraft(TRIGGER);expect(a['length'],'trigger\x20draft\x20fired\x20nothing')['toBeGreaterThan'](0x0);for(const b of a){expect(b['path'][0x0])['toBe']('proposal::guard'),expect(b['source'])['toBe']('proposal'),expect(b['ruleId'],'rule\x20id\x20carried')['toBeTruthy'](),expect(b['nativeRisk'],'native\x20risk\x20carried\x20(carryNative)')['toBeDefined']();const c=b['nativeRisk'];expect(c['id'])['toBe'](b['ruleId']),expect(c['level'])['toBe'](b['severity']);}}),it('rebuilds\x20the\x20GuardRiskAssessment\x20contract\x201:1\x20from\x20the\x20findings',()=>{const {findings:a,assessment:b}=evaluateGuardDraft(TRIGGER);expect(b['risks']['length'])['toBe'](a['length']);for(let c=0x0;c<a['length'];c++){expect(b['risks'][c]['id'])['toBe'](a[c]['ruleId']),expect(b['risks'][c])['toBe'](a[c]['nativeRisk']);}expect(typeof b['overall_risk'])['toBe']('string'),expect(b['overall_risk']['length'])['toBeGreaterThan'](0x0),expect(typeof b['needs_human_review'])['toBe']('boolean'),expect(b['scene']?.['id'])['toBe']('service_order_allocators_guard'),expect(b['guard_summary']['length'])['toBeGreaterThan'](0x0),expect(b['stakeholder_advice'])['toBeDefined']();}),it('informs\x20a\x20scene-free\x20sparse\x20draft\x20honestly\x20(stubs\x20stay\x20silent)',()=>{const {findings:a,assessment:b}=evaluateGuardDraft({'table':[],'root':undefined});expect(b['risks']['length'])['toBe'](a['length']);for(let c=0x0;c<a['length'];c++){expect(b['risks'][c]['id'])['toBe'](a[c]['ruleId']);}});});
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- import{describe,expect,it}from'vitest';import{readFileSync}from'node:fs';import{fileURLToPath}from'node:url';import{dirname,join}from'node:path';import{ENTRYPOINT}from'@wowok/wowok';import{FakeDataPlane}from'../graph/onchain/dataplane.js';import{expandTopology}from'../graph/onchain/expand.js';import{buildProposalGraph,buildViewport,runNodeAnalyzers}from'../graph/onchain/index.js';import{RISK_CASES}from'./baselines/risk-cases.js';import{RULE_NODE_ANALYZERS}from'./rule-node-analyzers.js';import{recipientAuditRisks}from'./rule-outcome.js';const REGISTRY_PACKS=new Set(['service','machine','guard','permission','allocation','treasury','arbitration','arb','reward','progress','order','contact','repository','demand','payment','proof','resource','personal','util','registrar','bridge']),CASES=RISK_CASES['filter'](a=>REGISTRY_PACKS['has'](a['pack'])),here=dirname(fileURLToPath(import.meta.url)),SNAPSHOT=JSON['parse'](readFileSync(join(here,'baselines','risk-baselines.json'),'utf-8'));function keysOf(a){return a['map'](b=>b['id']+':'+b['level']['toUpperCase']())['sort']();}async function migratedKeys(a,b){const d={[a['objectType']]:{'puzzle':b,'completeness':{},'missing_dimensions':[]}},e=await buildProposalGraph(d,{'network':ENTRYPOINT['Testnet']}),f=buildViewport(e,e['seed'],'neutral'),h=runNodeAnalyzers(f,RULE_NODE_ANALYZERS);return h['filter'](i=>i['ruleId']!=null)['map'](i=>i['ruleId']+':'+i['severity']['toUpperCase']())['sort']();}describe('rule-pack\x20node\x20analyzers\x20—\x20batch\x20A+B+C\x20parity\x20(T23/T24/T25)',()=>{it['each'](CASES['map'](a=>[a['pack'],a]))('TR-23.1/TR-24.1/TR-25.1\x20%s:\x20empty\x20round\x20reproduces\x20the\x20Task\x202\x20baseline',async(a,b)=>{const d=SNAPSHOT[a];expect(d)['toBeDefined'](),expect(await migratedKeys(b,b['empty']))['toEqual'](keysOf(d['empty']));}),it['each'](CASES['map'](a=>[a['pack'],a]))('TR-23.1/TR-24.1/TR-25.1\x20%s:\x20trigger\x20round\x20reproduces\x20the\x20Task\x202\x20baseline',async(a,b)=>{const d=SNAPSHOT[a];expect(d)['toBeDefined']();const e=await migratedKeys(b,b['trigger']);if(a==='allocation'){const f=e['filter'](h=>h['startsWith']('R-A-'));expect(f)['toEqual'](keysOf(d['trigger']));const g=e['filter'](h=>h['startsWith']('RC-FIND-'));expect(g['length'])['toBeGreaterThan'](0x0),expect(g)['toEqual'](recipientAuditRisks(b['trigger'])['map'](h=>{const i=h??{};return String(i['id'])+':'+String(i['level'])['toUpperCase']();})['sort']());return;}expect(e)['toEqual'](keysOf(d['trigger']));});}),describe('rule-pack\x20exposure\x20attribution\x20passthrough\x20(Phase\x202)',()=>{const a=CASES['find'](d=>d['pack']==='treasury')['run'];function b(c,d=a){const e=d(c),f=Array['isArray'](e)?e:e?.['risks']??e?.['detected_risks'];return f??[];}it('R-T-3-03:\x20delegated\x20withdraw-guard\x20management\x20carries\x20the\x20gated\x20viable\x20gain\x20path',()=>{const c=b({'current_permission_indexes_granted':[0x100]})['find'](d=>d['id']==='R-T-3-03');expect(c)['toBeDefined'](),expect(c['exposure'])['toBeDefined'](),expect(c['exposure']['lossParties'][0x0]['role'])['toBe']('merchant'),expect(c['exposure']['gainPaths'][0x0]['viability'])['toBe']('viable'),expect(c['exposure']['verdict'])['toBe']('confirmed');}),it('R-T-5-02:\x20missing\x20receive\x20permission\x20is\x20a\x20shortfall\x20defect\x20(no\x20gainer,\x20never\x20downgraded)',()=>{const c=b({'current_permission_indexes_granted':[0xfa],'shared_with_allocator':!![]})['find'](d=>d['id']==='R-T-5-02');expect(c)['toBeDefined'](),expect(c['exposure'])['toBeDefined'](),expect(c['exposure']['lossParties'][0x0]['role'])['toBe']('merchant'),expect(c['exposure']['gainPaths'])['toEqual']([]),expect(c['exposure']['verdict'])['toBe']('confirmed');}),it('notice-class\x20rules\x20stay\x20unattributed\x20(R-T-1-01\x20description\x20over\x20limit)',()=>{const c=b({'description':'x'['repeat'](0xfa1)})['find'](d=>d['id']==='R-T-1-01');expect(c)['toBeDefined'](),expect(c['exposure'])['toBeUndefined']();}),it('R-A-1-01:\x20empty\x20allocators\x20is\x20a\x20shortfall\x20defect\x20(buyer+merchant\x20loss,\x20no\x20gainer)',()=>{const c=CASES['find'](g=>g['pack']==='allocation')['run'],d=c({'allocators_config':{'allocators':[]}}),e=Array['isArray'](d)?d:d?.['risks']??d?.['detected_risks'],f=(e??[])['find'](g=>g['id']==='R-A-1-01');expect(f)['toBeDefined'](),expect(f['exposure'])['toBeDefined'](),expect(f['exposure']['lossParties']['map'](g=>g['role'])['sort']())['toEqual'](['buyer','merchant']),expect(f['exposure']['gainPaths'])['toEqual']([]),expect(f['exposure']['verdict'])['toBe']('confirmed');}),it('R-S-2-01:\x20unpinned\x20WIP\x20content\x20—\x20buyer\x20loses,\x20merchant\x20substitution\x20rides\x20the\x20viable\x20payment\x20flow',()=>{const c=CASES['find'](e=>e['pack']==='service')['run'],d=b({'sales':{'op':'add','sales':[{'name':'sku','wip':'https://example.com/a.wip','wip_hash':''}]}},c)['find'](e=>e['id']==='R-S-2-01');expect(d)['toBeDefined'](),expect(d['exposure'])['toBeDefined'](),expect(d['exposure']['lossParties'][0x0]['role'])['toBe']('buyer'),expect(d['exposure']['gainPaths'][0x0]['role'])['toBe']('merchant'),expect(d['exposure']['gainPaths'][0x0]['viability'])['toBe']('viable'),expect(d['exposure']['verdict'])['toBe']('confirmed');}),it('R-S-5-05:\x20funded\x20without\x20arbitration\x20is\x20a\x20shortfall\x20defect\x20(buyer\x20loss,\x20no\x20gainer)',()=>{const c=CASES['find'](e=>e['pack']==='service')['run'],d=b({'current_compensation_fund_balance':'100','current_arbitrations_count':0x0},c)['find'](e=>e['id']==='R-S-5-05');expect(d)['toBeDefined'](),expect(d['exposure'])['toBeDefined'](),expect(d['exposure']['lossParties'][0x0]['role'])['toBe']('buyer'),expect(d['exposure']['gainPaths'])['toEqual']([]),expect(d['exposure']['verdict'])['toBe']('confirmed');}),it('R-R-2-05:\x20unconstrained\x20GuardIdentifier\x20recipient\x20slot\x20—\x20conditional\x20pool-drain\x20path',()=>{const c=CASES['find'](e=>e['pack']==='reward')['run'],d=b({'guard_add':[{'guard':'0xg1','recipient':{'GuardIdentifier':0x7},'amount':{'type':'Fixed','value':'100'}}]},c)['find'](e=>e['id']==='R-R-2-05');expect(d)['toBeDefined'](),expect(d['exposure'])['toBeDefined'](),expect(d['exposure']['lossParties'][0x0]['role'])['toBe']('merchant'),expect(d['exposure']['gainPaths'][0x0]['role'])['toBe']('neutral'),expect(d['exposure']['gainPaths'][0x0]['viability'])['toBe']('conditional'),expect(d['exposure']['verdict'])['toBe']('confirmed');}),it('R-R-7-01:\x20no\x20owner\x20escape\x20guard\x20is\x20a\x20shortfall\x20defect\x20(merchant\x20budget\x20locked,\x20no\x20gainer)',()=>{const c=CASES['find'](e=>e['pack']==='reward')['run'],d=b({'coin_add':{'amount':'100','coin_type':'0x2::sui::SUI'}},c)['find'](e=>e['id']==='R-R-7-01');expect(d)['toBeDefined'](),expect(d['exposure'])['toBeDefined'](),expect(d['exposure']['lossParties'][0x0]['role'])['toBe']('merchant'),expect(d['exposure']['gainPaths'])['toEqual']([]),expect(d['exposure']['verdict'])['toBe']('confirmed');}),it('R-M1-02:\x20no\x20terminal\x20node\x20is\x20a\x20topology\x20freeze\x20(buyer+merchant\x20loss,\x20no\x20gainer)',()=>{const c=CASES['find'](e=>e['pack']==='machine')['run'],d=b({'pairs':[],'nodes':[]},c)['find'](e=>e['rule_id']==='R-M1-02');expect(d)['toBeDefined'](),expect(d['exposure'])['toBeDefined'](),expect(d['exposure']['lossParties']['map'](e=>e['role'])['sort']())['toEqual'](['buyer','merchant']),expect(d['exposure']['gainPaths'])['toEqual']([]),expect(d['exposure']['verdict'])['toBe']('confirmed');}),it('R-X1-07:\x20overstuffed\x20usage_guard\x20is\x20a\x20dispute-access\x20shortfall\x20(buyer\x20loss,\x20no\x20gainer)',()=>{const c=CASES['find'](e=>e['pack']==='guard')['run'],d=b({'table':[],'root':{'type':'logic_and','nodes':[{'type':'logic_and','nodes':[{'type':'identifier','value':0x0},{'type':'identifier','value':0x0}]},{'type':'logic_and','nodes':[{'type':'identifier','value':0x0},{'type':'identifier','value':0x0}]},{'type':'identifier','value':0x0}]},'scene':{'id':'arbitration_usage_guard','host_object':'Arbitration','binding_field':'usage_guard'}},c)['find'](e=>e['id']==='R-X1-07');expect(d)['toBeDefined'](),expect(d['exposure'])['toBeDefined'](),expect(d['exposure']['lossParties'][0x0]['role'])['toBe']('buyer'),expect(d['exposure']['gainPaths'])['toEqual']([]),expect(d['exposure']['verdict'])['toBe']('confirmed');}),it('R-O-3-03:\x20arb_claim_compensation\x20is\x20a\x20recourse-exhaustion\x20shortfall\x20(buyer\x20loss,\x20no\x20gainer)',()=>{const c=CASES['find'](e=>e['pack']==='order')['run'],d=b({'operation':'arb_claim_compensation'},c)['find'](e=>e['id']==='R-O-3-03');expect(d)['toBeDefined'](),expect(d['exposure'])['toBeDefined'](),expect(d['exposure']['lossParties']['map'](e=>e['role']))['toEqual'](['buyer']),expect(d['exposure']['gainPaths'])['toEqual']([]),expect(d['exposure']['verdict'])['toBe']('confirmed');}),it('R-PAYMENT-01:\x20unchecked\x20unwrap\x20is\x20an\x20unblockable\x20mismatched-release\x20path\x20(neutral\x20viable\x20gainer)',()=>{const c=CASES['find'](e=>e['pack']==='payment')['run'],d=b({'uses_unsafe_unwrap':!![]},c)['find'](e=>e['id']==='R-PAYMENT-01');expect(d)['toBeDefined'](),expect(d['exposure'])['toBeDefined'](),expect(d['exposure']['lossParties']['map'](e=>e['role'])['sort']())['toEqual'](['buyer','merchant']),expect(d['exposure']['gainPaths'][0x0]['role'])['toBe']('neutral'),expect(d['exposure']['gainPaths'][0x0]['viability'])['toBe']('viable'),expect(d['exposure']['verdict'])['toBe']('confirmed');}),it('R-AB-3-01:\x20dominant\x20vote\x20weight\x20is\x20a\x20capture-conditional\x20payout-steering\x20path',()=>{const c=CASES['find'](e=>e['pack']==='arbitration')['run'],d=b({'voting_guard':{'op':'add','guards':[{'guard':'0xg1','vote_weight':{'FixedValue':0x3c}},{'guard':'0xg2','vote_weight':{'FixedValue':0x28}}]}},c)['find'](e=>e['id']==='R-AB-3-01');expect(d)['toBeDefined'](),expect(d['exposure'])['toBeDefined'](),expect(d['exposure']['lossParties'][0x0]['role'])['toBe']('buyer'),expect(d['exposure']['gainPaths'][0x0]['role'])['toBe']('neutral'),expect(d['exposure']['gainPaths'][0x0]['viability'])['toBe']('conditional'),expect(d['exposure']['verdict'])['toBe']('confirmed');});}),describe('rule-pack\x20node\x20analyzers\x20—\x20on-chain\x20fixtures\x20(T23/T24/T25)',()=>{it('TR-23.2\x20SR1\x20state\x20rules\x20fire\x20on\x20a\x20fetched\x20on-chain\x20Service\x20through\x20the\x20unified\x20list',async()=>{const a='0x'+'14'+'cd'['repeat'](0x1f),b=new FakeDataPlane({'objects':new Map([[a['toLowerCase'](),{'object':a,'type':'Service','data':{'bPublished':!![],'bPaused':!![],'compensation_fund':'9','arbitrations':[]}}]]),'keyedFields':new Map(),'tables':new Map()}),c=await expandTopology(b,{'network':ENTRYPOINT['Mainnet'],'seed':a,'edges':{'tableEdges':['machine.node']}}),d=buildViewport(c,a['toLowerCase'](),'neutral'),e=runNodeAnalyzers(d,RULE_NODE_ANALYZERS),f=e['filter'](h=>h['id']['startsWith']('SR1:'));expect(f)['toHaveLength'](0x2),expect(f['every'](h=>h['detail']['includes']('R-S-4-05')||h['detail']['includes']('R-S-5-05')))['toBe'](!![]),expect(f['every'](h=>h['ruleId']===undefined))['toBe'](!![]),expect(f['every'](h=>h['source']===undefined))['toBe'](!![]),expect(e['filter'](h=>h['id']['startsWith']('MK1:')||h['id']['startsWith']('GD1:')||h['id']['startsWith']('PM1:')||h['id']['startsWith']('AL1:')||h['id']['startsWith']('TR1:')||h['id']['startsWith']('AR1:')||h['id']['startsWith']('AR3:')||h['id']['startsWith']('RW1:')||h['id']['startsWith']('PR1:')||h['id']['startsWith']('OR1:')||h['id']['startsWith']('CT1:')||h['id']['startsWith']('RP1:')||h['id']['startsWith']('DM1:')||h['id']['startsWith']('PY1:')||h['id']['startsWith']('PF1:')||h['id']['startsWith']('RS1:')||h['id']['startsWith']('PS1:')||h['id']['startsWith']('UT1:')||h['id']['startsWith']('RG1:')||h['id']['startsWith']('BR1:')))['toEqual']([]);}),it['each']([['Machine','15',{'pairs':[]}],['Guard','19',{'description':'chain\x20guard'}],['Permission','10',{'description':'chain\x20permission'}],['Allocation','18',{'description':'chain\x20allocation'}],['Treasury','1c',{'description':'chain\x20treasury'}],['Arb','11',{'description':'chain\x20arb'}],['Reward','12',{'description':'chain\x20reward'}],['Progress','13',{'description':'chain\x20progress'}],['Order','14',{'description':'chain\x20order'}],['Contact','1d',{'description':'chain\x20contact'}],['Repository','1e',{'description':'chain\x20repository'}],['Demand','1f',{'description':'chain\x20demand'}],['Payment','16',{'description':'chain\x20payment'}],['Resource','17',{'description':'chain\x20resource'}],['Proof','1a',{'description':'chain\x20proof'}],['EntityRegistrar','1b',{'description':'chain\x20registrar'}]])('TR-23.2\x20on-chain\x20%s:\x20packs\x20without\x20an\x20on-chain\x20projection\x20run\x20zero\x20rules\x20(honest\x20zero)',async(a,b,c)=>{const d='0x'+b+'ef'['repeat'](0x1f),e={'object':d,'type':a,'data':c},f=new FakeDataPlane({'objects':new Map([[d['toLowerCase'](),e]]),'keyedFields':new Map(),'tables':new Map()}),h=await expandTopology(f,{'network':ENTRYPOINT['Mainnet'],'seed':d,'edges':{'tableEdges':['machine.node']}});expect(h['nodes']['get'](d['toLowerCase']())?.['state'])['toBe']('fetched');const i=buildViewport(h,d['toLowerCase'](),'neutral');expect(runNodeAnalyzers(i,RULE_NODE_ANALYZERS))['toEqual']([]);});}),describe('rule-pack\x20node\x20analyzers\x20—\x20external\x20fact\x20nodes\x20(TR-25.1)',()=>{const a=CASES['find'](d=>d['pack']==='bridge'),b=CASES['find'](d=>d['pack']==='payment');it('TR-25.1\x20bridge\x20synthesizes\x20a\x20Bridge-typed\x20EXTERNAL\x20fact\x20node;\x20findings\x20stamp\x20source\x20external',async()=>{const c=await buildProposalGraph({'bridge':{'puzzle':a['trigger'],'completeness':{},'missing_dimensions':[]}},{'network':ENTRYPOINT['Testnet']}),d=c['nodes']['get']('proposal::bridge');expect(d?.['kind'])['toBe']('object'),expect(d?.['objectType'])['toBe']('Bridge'),expect(d?.['proposal']?.['provenance'])['toBe']('external');const e=buildViewport(c,'proposal::bridge','neutral'),f=runNodeAnalyzers(e,RULE_NODE_ANALYZERS)['filter'](h=>h['id']['startsWith']('BR1:'));expect(f['length'])['toBeGreaterThan'](0x0),expect(f['every'](h=>h['source']==='external'))['toBe'](!![]);}),it('TR-25.1\x20default\x20proposal\x20nodes\x20stay\x20intent\x20nodes\x20stamped\x20source\x20proposal',async()=>{const c=await buildProposalGraph({'payment':{'puzzle':b['trigger'],'completeness':{},'missing_dimensions':[]}},{'network':ENTRYPOINT['Testnet']}),d=c['nodes']['get']('proposal::payment');expect(d?.['objectType'])['toBe']('Payment'),expect(d?.['proposal']?.['provenance'])['toBeUndefined']();const e=buildViewport(c,'proposal::payment','neutral'),f=runNodeAnalyzers(e,RULE_NODE_ANALYZERS)['filter'](h=>h['id']['startsWith']('PY1:'));expect(f['length'])['toBeGreaterThan'](0x0),expect(f['every'](h=>h['source']==='proposal'))['toBe'](!![]);});});
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- import{describe,expect,it}from'vitest';import{extractAmount}from'./safety-rules.js';describe('extractAmount\x20—\x20docs#48-2\x20zero\x20suppression',()=>{it('returns\x20null\x20for\x20a\x20call\x20with\x20no\x20amount\x20concept\x20at\x20all',()=>{expect(extractAmount({'object':'0xsvc','description':'plain\x20draft\x20edit'}))['toBeNull']();}),it('does\x20not\x20raise\x20Amount:\x200\x20for\x20Rate-mode\x20allocators\x20with\x20default\x20threshold\x200',()=>{const a={'order_allocators':{'threshold':'0','allocators':[{'who':{'GuardIdentifier':0x0},'sharing':[{'mode':'Rate','sharing':'10000'}],'mode':'Rate'}]}};expect(extractAmount(a))['toBeNull']();}),it('does\x20not\x20raise\x20Amount:\x200\x20when\x20every\x20candidate\x20is\x20zero',()=>{expect(extractAmount({'amount':'0','fee':0x0}))['toBeNull']();});}),describe('extractAmount\x20—\x20docs#48-2\x20enumeration\x20sums',()=>{it('sums\x20ALL\x20revenue\x20rows\x20instead\x20of\x20reporting\x20only\x20the\x20first',()=>{const a={'revenue':[{'recipient':'0xa','amount':{'balance':'1000'}},{'recipient':'0xb','amount':{'balance':'2000'}}]};expect(extractAmount(a))['toBe']('3000');}),it('sums\x20Amount-mode\x20allocator\x20shares\x20across\x20every\x20allocator',()=>{const a={'allocators':{'threshold':'0','allocators':[{'who':{'Address':'0xa'},'sharing':[{'mode':'Amount','sharing':'500'}],'mode':'Amount'},{'who':{'Address':'0xb'},'sharing':[{'mode':'Amount','sharing':'700'}],'mode':'Amount'}]}};expect(extractAmount(a))['toBe']('1200');}),it('keeps\x20single-value\x20behavior\x20for\x20direct\x20amount\x20fields',()=>{expect(extractAmount({'amount':'2500000000'}))['toBe']('2500000000'),expect(extractAmount({'fee':0x64}))['toBe']('100'),expect(extractAmount({'deposit':{'coin':{'balance':'7000'}}}))['toBe']('7000');}),it('falls\x20back\x20to\x20the\x20first\x20value\x20when\x20display\x20strings\x20cannot\x20be\x20summed',()=>{const a={'amount':'2.5WOW','fee':'1WOW'};expect(extractAmount(a))['toBe']('2.5WOW');}),it('skips\x20zero\x20entries\x20mixed\x20with\x20real\x20values',()=>{expect(extractAmount({'amount':'0','fee':0x1f4}))['toBe']('500');});});
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- import{afterEach,beforeEach,describe,expect,it}from'vitest';import{existsSync,mkdirSync,mkdtempSync,readFileSync,rmSync,utimesSync,writeFileSync}from'node:fs';import{tmpdir}from'node:os';import{join}from'node:path';import{getTemplate,getTemplatesByIndustry,INDUSTRY_VALUES,listTemplates,loadAndValidate,parseTemplateFile,reloadTemplates,resolveTemplatesDir,seedBuiltinTemplates,TEMPLATES_SUBDIR}from'./template-loader.js';import{BUILTIN_TEMPLATES}from'./builtin-templates.js';const COMPETITOR_NAMES=['amazon','etsy','upwork','contra','airbnb','ziroom','coursera','yuanfudao','booking.com','klook','patreon','onlyfans','fiverr','turo','getaround','byju','outschool','thomas\x20cook','apple\x20iap']['map'](a=>new RegExp('\x5cb'+a['replace'](/[.*+?^${}()|[\]\\]/g,'\x5c$&')+'\x5cb','i'));describe('template-loader\x20—\x20builtin\x20catalog',()=>{let a,b,c,d;beforeEach(()=>{c=process['env']['WOWOK_TEMPLATES_DIR'],d=process['env']['WOWOK_LEGACY_TEMPLATES_DIR'],a=mkdtempSync(join(tmpdir(),'wowok-templates-')),b=mkdtempSync(join(tmpdir(),'wowok-templates-legacy-')),process['env']['WOWOK_TEMPLATES_DIR']=a,process['env']['WOWOK_LEGACY_TEMPLATES_DIR']=b,reloadTemplates();}),afterEach(()=>{if(c===undefined)delete process['env']['WOWOK_TEMPLATES_DIR'];else process['env']['WOWOK_TEMPLATES_DIR']=c;if(d===undefined)delete process['env']['WOWOK_LEGACY_TEMPLATES_DIR'];else process['env']['WOWOK_LEGACY_TEMPLATES_DIR']=d;reloadTemplates(),rmSync(a,{'recursive':!![],'force':!![]}),rmSync(b,{'recursive':!![],'force':!![]});}),it('seeds\x20exactly\x2012\x20templates:\x206\x20industries\x20x\x202\x20variants',()=>{const {templates:e,errors:f}=listTemplates();expect(f)['toEqual']([]),expect(e)['toHaveLength'](0xc);const g=new Map();for(const h of e){g['set'](h['industry'],(g['get'](h['industry'])??0x0)+0x1);}for(const i of INDUSTRY_VALUES){expect(g['get'](i),'industry\x20'+i)['toBe'](0x2);}}),it('every\x20industry\x20has\x20one\x20leader\x20and\x20one\x20challenger',()=>{const {templates:e}=listTemplates();for(const f of INDUSTRY_VALUES){const g=e['filter'](h=>h['industry']===f)['map'](h=>h['archetype'])['sort']();expect(g,'industry\x20'+f)['toEqual'](['challenger','leader']);}}),it('ids\x20follow\x20\x27<industry>/<variant>\x27\x20and\x20match\x20the\x20builtin\x20catalog',()=>{const {templates:e}=listTemplates(),f=e['map'](g=>g['id'])['sort']();expect(f)['toEqual'](BUILTIN_TEMPLATES['map'](g=>g['id'])['sort']());for(const g of e){expect(g['id'])['toBe'](g['industry']+'/'+g['variant']);}}),it('seeded\x20files\x20are\x20sanitized\x20—\x20no\x20competitor\x20company\x20names',()=>{seedBuiltinTemplates();const e=[];for(const f of BUILTIN_TEMPLATES){e['push'](join(a,f['industry'],TEMPLATES_SUBDIR,f['variant']+'.md'));}for(const g of e){expect(existsSync(g),g)['toBe'](!![]);const h=readFileSync(g,'utf-8');for(const i of COMPETITOR_NAMES){expect(i['test'](h),g+'\x20matches\x20'+i)['toBe'](![]);}}}),it('seeding\x20is\x20idempotent\x20—\x20existing\x20files\x20are\x20never\x20overwritten',()=>{seedBuiltinTemplates();const e=join(a,'retail',TEMPLATES_SUBDIR,'scale-marketplace.md'),f=readFileSync(e,'utf-8')+'\x0a<!--\x20user\x20edit\x20-->\x0a';writeFileSync(e,f,'utf-8'),seedBuiltinTemplates(),expect(readFileSync(e,'utf-8'))['toBe'](f);}),it('migrates\x20legacy\x20flat-root\x20templates\x20into\x20the\x20industry\x20tree',()=>{const e=join(b,'retail','custom-legacy.md');mkdirSync(join(b,'retail'),{'recursive':!![]}),writeFileSync(e,['---','id:\x20retail/custom-legacy','industry:\x20retail','variant:\x20custom-legacy','archetype:\x20challenger','phase:\x201','recommended_role:\x20merchant','role_rationale:\x20legacy\x20test','key_risk:\x20legacy\x20test','machine_shape:\x20[{\x22name\x22:\x20\x22paid\x22,\x20\x22role\x22:\x20\x22entry\x22}]','guards:\x20[]','allocator:\x20{\x22recipient\x22:\x20\x22signer\x22,\x20\x22count\x22:\x201,\x20\x22mode\x22:\x20\x22rate\x22,\x20\x22description\x22:\x20\x22legacy\x22}','fee_params:\x20{}','trust_mechanisms:\x20[]','keeper_dependencies:\x20[]','differences:\x20[]','user_inputs:\x20[]','build_notes:\x20[]','---','legacy\x20body']['join']('\x0a'),'utf-8'),seedBuiltinTemplates();const f=join(a,'retail',TEMPLATES_SUBDIR,'custom-legacy.md');expect(existsSync(f))['toBe'](!![]),expect(existsSync(e))['toBe'](![]),expect(getTemplate('retail/custom-legacy'))['toBeDefined'](),expect(listTemplates()['templates'])['toHaveLength'](0xd);}),it('legacy\x20migration\x20never\x20overwrites\x20an\x20existing\x20target',()=>{seedBuiltinTemplates();const e=join(a,'retail',TEMPLATES_SUBDIR,'scale-marketplace.md'),f=readFileSync(e,'utf-8');mkdirSync(join(b,'retail'),{'recursive':!![]}),writeFileSync(join(b,'retail','scale-marketplace.md'),'---\x0aid:\x20retail/scale-marketplace\x0a---\x0aLEGACY\x20CONTENT','utf-8'),reloadTemplates(),seedBuiltinTemplates(),expect(readFileSync(e,'utf-8'))['toBe'](f);}),it('getTemplate\x20/\x20getTemplatesByIndustry\x20resolve\x20by\x20id\x20and\x20industry',()=>{expect(getTemplate('retail/scale-marketplace')?.['archetype'])['toBe']('leader'),expect(getTemplate('nope/nope'))['toBeUndefined']();const e=getTemplatesByIndustry('rental');expect(e)['toHaveLength'](0x2),expect(e['every'](f=>f['industry']==='rental'))['toBe'](!![]);});}),describe('template-loader\x20—\x20parsing\x20and\x20validation',()=>{it('parseTemplateFile\x20splits\x20frontmatter\x20from\x20body',()=>{const a=['---','id:\x20retail/scale-marketplace','phase:\x201','fee_params:\x20{\x22commission_rate_bps\x22:\x201500}','machine_shape:\x20[{\x22name\x22:\x20\x22paid\x22,\x20\x22role\x22:\x20\x22entry\x22}]','---','#\x20Body','','Free-form\x20guidance.']['join']('\x0a'),{frontmatter:b,body:c}=parseTemplateFile(a);expect(b['id'])['toBe']('retail/scale-marketplace'),expect(b['phase'])['toBe'](0x1),expect(b['fee_params'])['toEqual']({'commission_rate_bps':0x5dc}),expect(b['machine_shape'])['toEqual']([{'name':'paid','role':'entry'}]),expect(c)['toContain']('#\x20Body');}),it('rejects\x20files\x20without\x20a\x20frontmatter\x20block',()=>{expect(()=>parseTemplateFile('#\x20no\x20frontmatter'))['toThrow'](/frontmatter/);}),it('rejects\x20unterminated\x20frontmatter',()=>{expect(()=>parseTemplateFile('---\x0aid:\x20a/b\x0ano\x20closing'))['toThrow'](/unterminated/i);}),it('loadAndValidate\x20throws\x20with\x20the\x20file\x20path\x20and\x20issues\x20for\x20invalid\x20frontmatter',()=>{const a=mkdtempSync(join(tmpdir(),'wowok-tpl-bad-')),b=join(a,'bad.md');writeFileSync(b,'---\x0aid:\x20BAD\x20ID\x0aindustry:\x20retail\x0a---\x0abody','utf-8');try{expect(()=>loadAndValidate(b))['toThrow'](new RegExp(b['replace'](/\\/g,'\x5c\x5c')));}finally{rmSync(a,{'recursive':!![],'force':!![]});}});}),describe('template-loader\x20—\x20hot\x20reload',()=>{let a,b,c,d;beforeEach(()=>{c=process['env']['WOWOK_TEMPLATES_DIR'],d=process['env']['WOWOK_LEGACY_TEMPLATES_DIR'],a=mkdtempSync(join(tmpdir(),'wowok-templates-hot-')),b=mkdtempSync(join(tmpdir(),'wowok-templates-hot-legacy-')),process['env']['WOWOK_TEMPLATES_DIR']=a,process['env']['WOWOK_LEGACY_TEMPLATES_DIR']=b,reloadTemplates();}),afterEach(()=>{if(c===undefined)delete process['env']['WOWOK_TEMPLATES_DIR'];else process['env']['WOWOK_TEMPLATES_DIR']=c;if(d===undefined)delete process['env']['WOWOK_LEGACY_TEMPLATES_DIR'];else process['env']['WOWOK_LEGACY_TEMPLATES_DIR']=d;reloadTemplates(),rmSync(a,{'recursive':!![],'force':!![]}),rmSync(b,{'recursive':!![],'force':!![]});}),it('re-reads\x20a\x20file\x20whose\x20mtime\x20changed',()=>{const {templates:e}=listTemplates();expect(e)['toHaveLength'](0xc);const f=join(a,'retail',TEMPLATES_SUBDIR,'scale-marketplace.md'),g=readFileSync(f,'utf-8'),h=g['replace']('key_risk:\x20','key_risk:\x20MUTATED\x20');writeFileSync(f,h,'utf-8');const i=new Date(Date['now']()+0x1388);utimesSync(f,i,i);const j=getTemplate('retail/scale-marketplace');expect(j?.['key_risk']['startsWith']('MUTATED'))['toBe'](!![]);}),it('drops\x20cache\x20entries\x20whose\x20files\x20vanished',()=>{expect(listTemplates()['templates'])['toHaveLength'](0xc),rmSync(join(a,'retail',TEMPLATES_SUBDIR,'scale-marketplace.md')),expect(listTemplates()['templates'])['toHaveLength'](0xb),expect(getTemplate('retail/scale-marketplace'))['toBeUndefined']();}),it('reports\x20invalid\x20files\x20in\x20errors\x20without\x20breaking\x20the\x20rest',()=>{listTemplates();const e=join(a,'retail',TEMPLATES_SUBDIR,'broken.md');writeFileSync(e,'---\x0aid:\x20retail/broken\x0a---\x0abody','utf-8');const {templates:f,errors:g}=listTemplates();expect(f)['toHaveLength'](0xc),expect(g['length'])['toBe'](0x1),expect(g[0x0])['toContain']('broken.md');}),it('reloadTemplates\x20forces\x20a\x20full\x20re-read',()=>{expect(listTemplates()['templates'])['toHaveLength'](0xc);const e=join(a,'retail',TEMPLATES_SUBDIR,'custom.md');writeFileSync(e,readFileSync(join(a,'retail',TEMPLATES_SUBDIR,'scale-marketplace.md'),'utf-8')['replace']('id:\x20retail/scale-marketplace','id:\x20retail/custom'),'utf-8'),reloadTemplates(),expect(listTemplates()['templates'])['toHaveLength'](0xd),expect(getTemplate('retail/custom'))['toBeDefined']();}),it('resolveTemplatesDir\x20honours\x20the\x20env\x20override',()=>{expect(resolveTemplatesDir())['toBe'](a);});});
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- import{describe,expect,it}from'vitest';import{scanTemplate}from'./template-scanner.js';import{BUILTIN_TEMPLATES,getBuiltinTemplate}from'./builtin-templates.js';function asLoaded(a,b={}){return{...a,'body':'','source_path':'<builtin:'+a['id']+'>',...b};}const base=()=>getBuiltinTemplate('retail/scale-marketplace');describe('scanTemplate\x20—\x20builtin\x20catalog\x20passes',()=>{it('all\x2012\x20built-in\x20templates\x20pass\x20(no\x20CRITICAL\x20findings)',()=>{for(const a of BUILTIN_TEMPLATES){const b=scanTemplate(asLoaded(a));expect(b['template_id'])['toBe'](a['id']),expect(b['passed'],a['id']+'\x20blocked:\x20'+b['red_flags']['join'](';\x20')+'\x20/\x20'+b['findings']['map'](c=>(c['rule_id']??'?')+':'+c['title'])['join'](';\x20'))['toBe'](!![]),expect(b['red_flags'])['toEqual']([]),expect(b['findings']['every'](c=>c['severity']!=='critical'))['toBe'](!![]);}}),it('the\x20synthetic\x20draft\x20machine\x20trips\x20no\x20machine/allocation\x20rule\x20false\x20positives',()=>{for(const a of BUILTIN_TEMPLATES){const b=scanTemplate(asLoaded(a)),c=b['findings']['filter'](d=>d['rule_id']?.['startsWith']('R-M')||d['rule_id']?.['startsWith']('R-A'));expect(c,a['id']+':\x20'+c['map'](d=>d['rule_id'])['join'](','))['toEqual']([]);}});}),describe('scanTemplate\x20—\x20static\x20checks\x20fire\x20on\x20mutations',()=>{const a=()=>getBuiltinTemplate('retail/scale-marketplace');it('R-M1-11:\x20a\x20dispute/refund\x20Machine\x20node\x20is\x20CRITICAL\x20and\x20blocks',()=>{const b=asLoaded(a(),{'machine_shape':[...a()['machine_shape'],{'name':'disputed','role':'Dispute\x20handled\x20inside\x20the\x20Machine'}]}),c=scanTemplate(b);expect(c['passed'])['toBe'](![]),expect(c['risk_level'])['toBe']('critical');const d=c['findings']['find'](e=>e['rule_id']==='R-M1-11');expect(d)['toBeDefined'](),expect(d['severity'])['toBe']('critical'),expect(c['red_flags']['some'](e=>e['includes']('R-M1-11')))['toBe'](!![]);}),it('R-M1-01:\x20an\x20empty\x20machine_shape\x20is\x20CRITICAL\x20and\x20blocks',()=>{const b=scanTemplate(asLoaded(a(),{'machine_shape':[]}));expect(b['passed'])['toBe'](![]),expect(b['findings']['some'](c=>c['rule_id']==='R-M1-01'&&c['severity']==='critical'))['toBe'](!![]);}),it('R1:\x20missing\x20refund\x20path\x20raises\x20a\x20high\x20finding\x20(but\x20does\x20not\x20block)',()=>{const b=a(),c=asLoaded(b,{'guards':b['guards']['filter'](f=>!f['template_id']['includes']('refund')&&!f['template_id']['includes']('cancel')),'allocator':{...b['allocator'],'description':'Settlement\x20split\x20among\x20participants\x20at\x20the\x20release\x20point'}}),d=scanTemplate(c),e=d['findings']['find'](g=>g['rule_id']==='R1');expect(e)['toBeDefined'](),expect(e['severity'])['toBe']('high'),expect(d['passed'])['toBe'](!![]),expect(d['risk_level'])['toBe']('high');}),it('R2:\x20missing\x20independent\x20Arbitration\x20reference\x20raises\x20a\x20high\x20finding',()=>{const b=a(),c=asLoaded(b,{'guards':b['guards']['filter'](e=>e['host']!=='arbitration'),'trust_mechanisms':b['trust_mechanisms']['filter'](e=>!e['startsWith']('R2'))}),d=scanTemplate(c);expect(d['findings']['some'](e=>e['rule_id']==='R2'&&e['severity']==='high'))['toBe'](!![]);}),it('R9:\x20no\x20keeper\x20declarations\x20raises\x20a\x20medium\x20finding',()=>{const b=scanTemplate(asLoaded(a(),{'keeper_dependencies':[]})),c=b['findings']['find'](d=>d['rule_id']==='R9');expect(c)['toBeDefined'](),expect(c['severity'])['toBe']('medium');});}),describe('scanTemplate\x20—\x20result\x20shape',()=>{it('findings\x20are\x20sorted\x20by\x20severity\x20descending;\x20risk_level\x20is\x20the\x20highest',()=>{const a=base(),b=asLoaded(a,{'machine_shape':[...a['machine_shape'],{'name':'refunded','role':'Refund\x20node'}],'keeper_dependencies':[]}),c=scanTemplate(b),d={'low':0x0,'medium':0x1,'high':0x2,'critical':0x3};for(let e=0x1;e<c['findings']['length'];e++){expect(d[c['findings'][e]['severity']])['toBeLessThanOrEqual'](d[c['findings'][e-0x1]['severity']]);}expect(c['risk_level'])['toBe'](c['findings'][0x0]['severity']);}),it('a\x20clean\x20scan\x20reports\x20risk_level\x20from\x20its\x20highest\x20non-critical\x20finding',()=>{const a=scanTemplate(asLoaded(getBuiltinTemplate('freelance/enterprise-talent-market')));expect(a['passed'])['toBe'](!![]),expect(['low','medium','high'])['toContain'](a['risk_level']);});});