@wowok/agent-mcp 2.7.7 → 2.7.8

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 (239) hide show
  1. package/dist/customer/index.d.ts +3 -4
  2. package/dist/customer/index.js +1 -1
  3. package/dist/customer/info-puzzle.js +1 -1
  4. package/dist/customer/order-monitor.d.ts +0 -9
  5. package/dist/customer/order-monitor.js +1 -1
  6. package/dist/customer/order-strategy.d.ts +0 -19
  7. package/dist/customer/order-strategy.js +1 -1
  8. package/dist/customer/reminder-system.d.ts +0 -5
  9. package/dist/customer/reminder-system.js +1 -1
  10. package/dist/evaluation/game-strategy.js +1 -1
  11. package/dist/evaluation/injection.d.ts +6 -0
  12. package/dist/evaluation/injection.js +1 -0
  13. package/dist/evaluation/node-game.js +1 -1
  14. package/dist/examples/machine-multisig-threshold.json +1 -0
  15. package/dist/harness/recover.js +1 -1
  16. package/dist/harness/types.d.ts +1 -1
  17. package/dist/harness/verify.js +1 -1
  18. package/dist/intent/enrich.js +1 -1
  19. package/dist/intent/matcher.js +1 -1
  20. package/dist/intent/types.d.ts +1 -1
  21. package/dist/intent/types.js +1 -1
  22. package/dist/knowledge/arbitration-ledger.js +1 -1
  23. package/dist/knowledge/contract-invariants.d.ts +53 -0
  24. package/dist/knowledge/contract-invariants.js +1 -0
  25. package/dist/knowledge/deployment-scanner.js +1 -1
  26. package/dist/knowledge/dynamic-pricing.d.ts +0 -2
  27. package/dist/knowledge/dynamic-pricing.js +1 -1
  28. package/dist/knowledge/event-semantics.d.ts +20 -0
  29. package/dist/knowledge/event-semantics.js +1 -0
  30. package/dist/knowledge/examples-scanner-cli.js +1 -1
  31. package/dist/knowledge/examples-scanner.js +1 -1
  32. package/dist/knowledge/glossary.js +1 -1
  33. package/dist/knowledge/guard-submission-prompt.js +1 -1
  34. package/dist/knowledge/immutability.d.ts +11 -0
  35. package/dist/knowledge/immutability.js +1 -0
  36. package/dist/knowledge/index.d.ts +12 -6
  37. package/dist/knowledge/index.js +1 -1
  38. package/dist/knowledge/industry-registry.js +1 -1
  39. package/dist/knowledge/intent-metrics.d.ts +1 -1
  40. package/dist/knowledge/jsonrpc-enum.d.ts +37 -0
  41. package/dist/knowledge/jsonrpc-enum.js +1 -0
  42. package/dist/knowledge/machine-confirm.js +1 -1
  43. package/dist/knowledge/machine-risk.js +1 -1
  44. package/dist/knowledge/machine-topology.d.ts +11 -0
  45. package/dist/knowledge/machine-topology.js +1 -1
  46. package/dist/knowledge/machine-translation.js +1 -1
  47. package/dist/knowledge/market-metrics.d.ts +11 -0
  48. package/dist/knowledge/market-metrics.js +1 -1
  49. package/dist/knowledge/mcp-schema-audit-cli.js +1 -1
  50. package/dist/knowledge/mcp-schema-audit.d.ts +1 -0
  51. package/dist/knowledge/mcp-schema-audit.js +1 -1
  52. package/dist/knowledge/messenger-guard-guidance.d.ts +17 -0
  53. package/dist/knowledge/messenger-guard-guidance.js +1 -0
  54. package/dist/knowledge/operation-dictionary.d.ts +18 -0
  55. package/dist/knowledge/operation-dictionary.js +1 -0
  56. package/dist/knowledge/service-ledger.js +1 -1
  57. package/dist/knowledge/service-risk.js +1 -1
  58. package/dist/knowledge/service-translation.js +1 -1
  59. package/dist/knowledge/supply-chain.d.ts +24 -0
  60. package/dist/knowledge/supply-chain.js +1 -0
  61. package/dist/knowledge/template-registry.js +1 -1
  62. package/dist/knowledge/tools-reference.js +1 -1
  63. package/dist/knowledge/trust-metrics.d.ts +27 -2
  64. package/dist/knowledge/trust-metrics.js +1 -1
  65. package/dist/knowledge/workflow-guidance.d.ts +22 -1
  66. package/dist/knowledge/workflow-guidance.js +1 -1
  67. package/dist/monitor/EventStore.d.ts +78 -0
  68. package/dist/monitor/EventStore.js +1 -0
  69. package/dist/participation/radar-core.d.ts +0 -1
  70. package/dist/participation/radar-core.js +1 -1
  71. package/dist/persona/address-format.d.ts +6 -0
  72. package/dist/persona/address-format.js +1 -0
  73. package/dist/persona/analyzer.js +1 -1
  74. package/dist/persona/index.d.ts +3 -0
  75. package/dist/persona/index.js +1 -1
  76. package/dist/persona/types.d.ts +1 -1
  77. package/dist/persona/types.js +1 -1
  78. package/dist/project/business-puzzle.js +1 -1
  79. package/dist/project/edit-planner.js +1 -1
  80. package/dist/project/evaluation.js +1 -1
  81. package/dist/project/graph-builder.js +1 -1
  82. package/dist/project/handlers.d.ts +2 -18
  83. package/dist/project/handlers.js +1 -1
  84. package/dist/project/index.js +1 -1
  85. package/dist/project/machine-nodes.d.ts +23 -0
  86. package/dist/project/machine-nodes.js +1 -1
  87. package/dist/project/machine-panorama.d.ts +41 -0
  88. package/dist/project/machine-panorama.js +1 -0
  89. package/dist/project/object-panorama.d.ts +179 -0
  90. package/dist/project/object-panorama.js +1 -0
  91. package/dist/project/object-type.d.ts +1 -0
  92. package/dist/project/object-type.js +1 -0
  93. package/dist/project/participation-radar.js +1 -1
  94. package/dist/project/semantic-assembler.js +1 -1
  95. package/dist/project/service-panorama.d.ts +180 -0
  96. package/dist/project/service-panorama.js +1 -0
  97. package/dist/project/stage-gate.d.ts +0 -1
  98. package/dist/project/stage-gate.js +1 -1
  99. package/dist/project/task-tracker.d.ts +4 -0
  100. package/dist/project/task-tracker.js +1 -1
  101. package/dist/role/derivation.d.ts +19 -2
  102. package/dist/role/derivation.js +1 -1
  103. package/dist/role/index.d.ts +2 -2
  104. package/dist/role/index.js +1 -1
  105. package/dist/role/model.js +1 -1
  106. package/dist/role/resolution.d.ts +16 -0
  107. package/dist/role/resolution.js +1 -1
  108. package/dist/role/types.d.ts +1 -1
  109. package/dist/role/types.js +1 -1
  110. package/dist/safety/confirm-gate.js +1 -1
  111. package/dist/schema/call/allocation.d.ts +1 -0
  112. package/dist/schema/call/arbitration.d.ts +4 -3
  113. package/dist/schema/call/arbitration.js +1 -1
  114. package/dist/schema/call/base.d.ts +16 -0
  115. package/dist/schema/call/base.js +1 -1
  116. package/dist/schema/call/bridge.d.ts +7 -0
  117. package/dist/schema/call/contact.d.ts +1 -0
  118. package/dist/schema/call/demand.d.ts +1 -0
  119. package/dist/schema/call/guard.d.ts +3 -0
  120. package/dist/schema/call/handler.js +1 -1
  121. package/dist/schema/call/machine.d.ts +2 -0
  122. package/dist/schema/call/machine.js +1 -1
  123. package/dist/schema/call/order.d.ts +1 -0
  124. package/dist/schema/call/payment.d.ts +1 -0
  125. package/dist/schema/call/permission.d.ts +1 -0
  126. package/dist/schema/call/personal.d.ts +38 -0
  127. package/dist/schema/call/personal.js +1 -1
  128. package/dist/schema/call/progress.d.ts +1 -0
  129. package/dist/schema/call/proof.d.ts +2 -0
  130. package/dist/schema/call/repository.d.ts +5 -4
  131. package/dist/schema/call/reward.d.ts +1 -12
  132. package/dist/schema/call/reward.js +1 -1
  133. package/dist/schema/call/semantic.d.ts +3 -2
  134. package/dist/schema/call/semantic.js +1 -1
  135. package/dist/schema/call/service.d.ts +1 -0
  136. package/dist/schema/call/service.js +1 -1
  137. package/dist/schema/call/treasury.d.ts +1 -0
  138. package/dist/schema/common/index.js +1 -1
  139. package/dist/schema/evaluation/index.d.ts +146 -0
  140. package/dist/schema/evaluation/index.js +1 -1
  141. package/dist/schema/index.d.ts +1 -0
  142. package/dist/schema/index.js +1 -1
  143. package/dist/schema/intent-radar/index.d.ts +30 -3
  144. package/dist/schema/intent-radar/index.js +1 -1
  145. package/dist/schema/local/index.d.ts +9 -0
  146. package/dist/schema/local/index.js +1 -1
  147. package/dist/schema/messenger/index.d.ts +54 -0
  148. package/dist/schema/messenger/index.js +1 -1
  149. package/dist/schema/operations.d.ts +864 -8
  150. package/dist/schema/operations.js +1 -1
  151. package/dist/schema/permission/index.d.ts +17 -0
  152. package/dist/schema/permission/index.js +1 -1
  153. package/dist/schema/project/index.d.ts +6 -0
  154. package/dist/schema/project/index.js +1 -1
  155. package/dist/schema/query/index.d.ts +658 -56
  156. package/dist/schema/query/index.js +1 -1
  157. package/dist/schema/schema-version.js +1 -1
  158. package/dist/schema/trust/index.d.ts +17 -0
  159. package/dist/schema/trust/index.js +1 -1
  160. package/dist/schema/watch/index.d.ts +204 -0
  161. package/dist/schema/watch/index.js +1 -0
  162. package/dist/schema/workflow/index.d.ts +301 -0
  163. package/dist/schema/workflow/index.js +1 -1
  164. package/dist/schema-query-impl/index.js +1 -1
  165. package/dist/schemas/account_operation.output.json +5 -2
  166. package/dist/schemas/bridge_operation.output.json +5 -2
  167. package/dist/schemas/bridge_operation.schema.json +25 -9
  168. package/dist/schemas/evaluation_operation.output.json +276 -1
  169. package/dist/schemas/evaluation_operation.schema.json +307 -0
  170. package/dist/schemas/guard2file.schema.json +6 -2
  171. package/dist/schemas/index.json +13 -1
  172. package/dist/schemas/intent_radar.output.json +20 -2
  173. package/dist/schemas/intent_radar.schema.json +10 -1
  174. package/dist/schemas/local_info_operation.output.json +5 -2
  175. package/dist/schemas/local_mark_operation.output.json +5 -2
  176. package/dist/schemas/machineNode2file.schema.json +6 -2
  177. package/dist/schemas/messenger_operation.output.json +105 -2
  178. package/dist/schemas/messenger_operation.schema.json +98 -0
  179. package/dist/schemas/monitor_events.output.json +1360 -0
  180. package/dist/schemas/monitor_events.schema.json +62 -0
  181. package/dist/schemas/onchain_events.output.json +237 -14
  182. package/dist/schemas/onchain_events.schema.json +20 -0
  183. package/dist/schemas/onchain_operations.output.json +10 -5
  184. package/dist/schemas/onchain_operations.schema.json +511 -419
  185. package/dist/schemas/onchain_operations_allocation.schema.json +11 -7
  186. package/dist/schemas/onchain_operations_arbitration.schema.json +14 -9
  187. package/dist/schemas/onchain_operations_contact.schema.json +9 -5
  188. package/dist/schemas/onchain_operations_demand.schema.json +9 -5
  189. package/dist/schemas/onchain_operations_gen_passport.schema.json +6 -2
  190. package/dist/schemas/onchain_operations_gen_proof.schema.json +6 -2
  191. package/dist/schemas/onchain_operations_guard.schema.json +6 -2
  192. package/dist/schemas/onchain_operations_machine.schema.json +14 -10
  193. package/dist/schemas/onchain_operations_order.schema.json +9 -5
  194. package/dist/schemas/onchain_operations_payment.schema.json +7 -3
  195. package/dist/schemas/onchain_operations_permission.schema.json +9 -5
  196. package/dist/schemas/onchain_operations_personal.schema.json +44 -2
  197. package/dist/schemas/onchain_operations_progress.schema.json +9 -5
  198. package/dist/schemas/onchain_operations_proof.schema.json +6 -2
  199. package/dist/schemas/onchain_operations_repository.schema.json +290 -305
  200. package/dist/schemas/onchain_operations_reward.schema.json +14 -10
  201. package/dist/schemas/onchain_operations_service.schema.json +17 -13
  202. package/dist/schemas/onchain_operations_treasury.schema.json +14 -10
  203. package/dist/schemas/onchain_table_data.output.json +3750 -208
  204. package/dist/schemas/onchain_table_data.schema.json +311 -0
  205. package/dist/schemas/permission_operation.output.json +32 -0
  206. package/dist/schemas/project_operation.schema.json +14 -8
  207. package/dist/schemas/query_toolkit.output.json +405 -320
  208. package/dist/schemas/query_toolkit.schema.json +139 -1
  209. package/dist/schemas/trust_score.output.json +38 -0
  210. package/dist/schemas/trust_score.schema.json +32 -0
  211. package/dist/schemas/watch_operation.output.json +827 -0
  212. package/dist/schemas/watch_operation.schema.json +145 -0
  213. package/dist/schemas/workflow_operation.output.json +263 -5
  214. package/dist/schemas/workflow_operation.schema.json +597 -2
  215. package/dist/tools/handlers/config.js +1 -1
  216. package/dist/tools/handlers/evaluation.js +1 -1
  217. package/dist/tools/handlers/intent-radar.js +1 -1
  218. package/dist/tools/handlers/messenger.js +1 -1
  219. package/dist/tools/handlers/monitor.d.ts +2 -0
  220. package/dist/tools/handlers/monitor.js +1 -0
  221. package/dist/tools/handlers/onchain.js +1 -1
  222. package/dist/tools/handlers/permission.js +1 -1
  223. package/dist/tools/handlers/project.js +1 -1
  224. package/dist/tools/handlers/query.js +1 -1
  225. package/dist/tools/handlers/trust.d.ts +14 -0
  226. package/dist/tools/handlers/trust.js +1 -1
  227. package/dist/tools/handlers/watch.d.ts +2 -0
  228. package/dist/tools/handlers/watch.js +1 -0
  229. package/dist/tools/handlers/workflow.js +1 -1
  230. package/dist/tools/index.d.ts +2 -0
  231. package/dist/tools/index.js +1 -1
  232. package/dist/tools/shared.js +1 -1
  233. package/package.json +2 -2
  234. package/dist/customer/post-purchase.d.ts +0 -44
  235. package/dist/customer/post-purchase.js +0 -1
  236. package/dist/project/migration.d.ts +0 -22
  237. package/dist/project/migration.js +0 -1
  238. package/dist/project/rollback-policy.d.ts +0 -45
  239. package/dist/project/rollback-policy.js +0 -1
@@ -1 +1 @@
1
- import*as a137a from'fs';import*as a137b from'path';import{CONCEPT_GLOSSARY}from'./glossary.js';export const TRAE_MCPS_ROOT='c:\x5cUsers\x5czhou\x5c.trae-cn\x5cmcps';export const GENERATED_SCHEMAS_DIR='d:\x5cwowok\x5cagent\x5cmcp\x5cdist\x5cschemas';export const MCP_SRC_SCHEMA_DIR='d:\x5cwowok\x5cagent\x5cmcp\x5csrc\x5cschema';export const MCP_SRC_TOOLS_DIR='d:\x5cwowok\x5cagent\x5cmcp\x5csrc\x5ctools';export const GENERATION_SCRIPT='d:\x5cwowok\x5cagent\x5cmcp\x5cscripts\x5cgenerate-json-schemas.ts';export const TOOLS_INDEX_FILE='d:\x5cwowok\x5cagent\x5cmcp\x5csrc\x5ctools\x5cindex.ts';export const MCP_SCHEMA_AUDIT_VERSION='2.1.0';export const ALL_TOOLS=[{'name':'onchain_operations','input_schema_export':'OnchainOperationsSchema','output_schema_export':'CallOutputSchema'},{'name':'account_operation','input_schema_export':'AccountOperationSchema','output_schema_export':'AccountOperationOutputWrappedSchema'},{'name':'local_mark_operation','input_schema_export':'LocalMarkOperationSchema','output_schema_export':'LocalMarkOperationOutputWrappedSchema'},{'name':'local_info_operation','input_schema_export':'LocalInfoOperationSchema','output_schema_export':'LocalInfoOperationOutputWrappedSchema'},{'name':'wip_file','input_schema_export':'WipOperationsSchema','output_schema_export':'WipOperationOutputSchema'},{'name':'messenger_operation','input_schema_export':'MessengerOperationInputSchema','output_schema_export':'MessengerOperationOutputSchema'},{'name':'guard2file','input_schema_export':'Guard2File_InputSchema','output_schema_export':'Guard2File_OutputWrappedSchema'},{'name':'machineNode2file','input_schema_export':'MachineNode2File_InputSchema','output_schema_export':'MachineNode2File_OutputWrappedSchema'},{'name':'query_toolkit','input_schema_export':'WatchQueryOperationsSchema','output_schema_export':'WatchQueryOperationsResultSchema'},{'name':'onchain_table_data','input_schema_export':'OnchainTableDataSchema','output_schema_export':'OnchainTableDataResultSchema'},{'name':'onchain_events','input_schema_export':'OnchainEventsInputSchema','output_schema_export':'OnchainEventsResultSchema'},{'name':'wowok_buildin_info','input_schema_export':'ProtocolInfoQuerySchema','output_schema_export':'ProtocolInfoResultSchema'},{'name':'schema_query','input_schema_export':'SchemaQueryInputSchema','output_schema_export':'SchemaQueryOutputSchema'},{'name':'bridge_operation','input_schema_export':'BridgeOperationsSchema','output_schema_export':'BridgeCallOutputSchema'},{'name':'project_operation','input_schema_export':'ProjectOperationInputSchema','output_schema_export':'ProjectOperationOutputSchema'},{'name':'config_operation','input_schema_export':'ConfigOperationInputSchema','output_schema_export':'ConfigOperationOutputSchema'},{'name':'trust_score','input_schema_export':'TrustScoreInputSchema','output_schema_export':'TrustScoreOutputSchema'},{'name':'query_task_status','input_schema_export':'QueryTaskStatusInputSchema','output_schema_export':'QueryTaskStatusOutputSchema'},{'name':'evaluation_operation','input_schema_export':'EvaluationOperationInputSchema','output_schema_export':'EvaluationOperationOutputSchema'},{'name':'persona_operation','input_schema_export':'PersonaOperationInputSchema','output_schema_export':'PersonaOperationOutputSchema'},{'name':'intent_radar','input_schema_export':'IntentRadarInputSchema','output_schema_export':'IntentRadarOutputSchema'},{'name':'employee_operation','input_schema_export':'EmployeeOperationInputSchema','output_schema_export':'EmployeeOperationOutputSchema'},{'name':'industry_pack_operation','input_schema_export':'IndustryPackOperationInputSchema','output_schema_export':'IndustryPackOperationOutputSchema'},{'name':'workspace_operation','input_schema_export':'WorkspaceOperationInputSchema','output_schema_export':'WorkspaceOperationOutputSchema'}];export function discoverDeployedGatewayMounts(){const a=[];if(!a137a['existsSync'](TRAE_MCPS_ROOT))return[];for(const b of a137a['readdirSync'](TRAE_MCPS_ROOT,{'withFileTypes':!![]})){if(!b['isDirectory']())continue;const c=a137b['join'](TRAE_MCPS_ROOT,b['name'],'solo_agent','mcp_wagent','tools','wowok.json');try{const d=a137a['statSync'](c);if(d['isFile']())a['push']({'file':c,'mtime':d['mtimeMs']});}catch{}}return a['sort']((e,f)=>f['mtime']-e['mtime']),a['map'](e=>e['file']);}const GATEWAY_MISSING={'gateway_file':a137b['join'](TRAE_MCPS_ROOT,'<none>','solo_agent','mcp_wagent','tools','wowok.json'),'file_exists':![],'gateway_name':null,'has_definitions':![],'definitions_count':0x0,'has_tool_field':![],'has_data_field':![],'is_strict':![],'has_schema_hint':![],'size_bytes':0x0,'all_mounts':[]};export function loadLayer4Gateway(){const a=discoverDeployedGatewayMounts();if(a['length']===0x0)return GATEWAY_MISSING;const b=a[0x0];try{const c=a137a['readFileSync'](b,'utf-8'),d=JSON['parse'](c),e=d['arguments']??{},f=e['definitions']??{},g=Object['keys'](f)['length'];let h=e;const i=e['$ref'];if(i&&i['startsWith']('#/definitions/')){const l=i['slice']('#/definitions/'['length']),m=f[l];if(m&&typeof m==='object')h=m;}const j=h['properties']??{},k=d['description']??'';return{'gateway_file':b,'file_exists':!![],'gateway_name':d['name']??null,'has_definitions':g>0x0,'definitions_count':g,'has_tool_field':'tool'in j,'has_data_field':'data'in j,'is_strict':h['additionalProperties']===![],'has_schema_hint':k['includes']('schema_query'),'size_bytes':Buffer['byteLength'](c,'utf-8'),'all_mounts':a};}catch{return{...GATEWAY_MISSING,'gateway_file':b,'all_mounts':a};}}export function loadLayer3Generated(a){const b=a137b['join'](GENERATED_SCHEMAS_DIR,a+'.schema.json'),c=a137b['join'](GENERATED_SCHEMAS_DIR,a+'.output.json'),d=a137a['existsSync'](b),e=a137a['existsSync'](c),f=d?a137a['statSync'](b)['size']:0x0,g=e?a137a['statSync'](c)['size']:0x0;return{'input_schema_file':b,'output_schema_file':c,'input_exists':d,'output_exists':e,'input_size_bytes':f,'output_size_bytes':g};}export function analyzeLayerCensus(){const a=[];for(const b of ALL_TOOLS){a['push']({'name':b['name'],'layer2_zod':{'input_schema_export':b['input_schema_export'],'output_schema_export':b['output_schema_export'],'schema_dir':MCP_SRC_SCHEMA_DIR},'layer3_generated':loadLayer3Generated(b['name'])});}return a;}export function analyzeGatewayDeployment(a){const b=[],c='(gateway)';if(!a['file_exists'])return b['push']({'rule_id':'MCP-GATEWAY-001','severity':'critical','category':'gateway_deployment','tool_name':c,'description':'No\x20deployed\x20wowok.json\x20gateway\x20descriptor\x20found\x20under\x20any\x20Trae\x20mount\x20in\x20'+TRAE_MCPS_ROOT+'.\x20The\x20MCP\x20server\x20is\x20not\x20loaded\x20by\x20any\x20Trae\x20session,\x20or\x20tools/list\x20failed.','fix':'Load\x20the\x20WoWok\x20MCP\x20server\x20in\x20a\x20Trae\x20session\x20and\x20verify\x20tools/list\x20returns\x20the\x20single\x20\x27wowok\x27\x20tool.'}),b;return a['gateway_name']!=='wowok'&&b['push']({'rule_id':'MCP-GATEWAY-002','severity':'high','category':'gateway_deployment','tool_name':c,'description':'Deployed\x20gateway\x20descriptor\x20name\x20is\x20\x27'+a['gateway_name']+'\x27\x20—\x20expected\x20\x27wowok\x27\x20(the\x20single\x20unified\x20tool\x20registered\x20by\x20the\x20server).','location':a['gateway_file'],'fix':'Restart\x20the\x20Trae\x20session\x20so\x20Trae\x20regenerates\x20wowok.json\x20from\x20the\x20server\x27s\x20tools/list.'}),!a['has_definitions']&&a['definitions_count']===0x0&&b['push']({'rule_id':'MCP-GATEWAY-003','severity':'high','category':'gateway_deployment','tool_name':c,'description':'Deployed\x20gateway\x20descriptor\x20carries\x20no\x20argument\x20schema\x20(no\x20definitions,\x20no\x20properties)\x20—\x20the\x20LLM\x20has\x20no\x20parameter\x20structure\x20at\x20all.','location':a['gateway_file'],'fix':'Ensure\x20listTools()\x20advertises\x20WowokToolDisplaySchema\x20and\x20restart\x20the\x20Trae\x20session.'}),!a['has_schema_hint']&&b['push']({'rule_id':'MCP-GATEWAY-004','severity':'medium','category':'gateway_deployment','tool_name':c,'description':'Gateway\x20descriptor\x20description\x20does\x20not\x20mention\x20schema_query\x20—\x20the\x20LLM\x20is\x20not\x20told\x20about\x20the\x20schema\x20self-correction\x20path\x20(sub-tool\x20schemas\x20are\x20returned\x20on\x20validation\x20mismatch).','location':a['gateway_file'],'fix':'Keep\x20the\x20schema_query\x20mention\x20in\x20WOWOK_TOOL_DESCRIPTION\x20(src/tools/index.ts).'}),b;}export function analyzeGatewayDispatchContract(a){const b=[],c='(gateway)';if(!a['file_exists'])return b;const d=[];if(!a['has_tool_field'])d['push']('tool');if(!a['has_data_field'])d['push']('data');return d['length']>0x0&&b['push']({'rule_id':'MCP-PARITY-001','severity':'high','category':'layer_parity','tool_name':c,'description':'Deployed\x20gateway\x20argument\x20schema\x20is\x20missing\x20dispatch\x20field(s):\x20'+d['join'](',\x20')+'.\x20Calls\x20of\x20the\x20form\x20wowok({\x20tool,\x20data\x20})\x20cannot\x20be\x20validated.','location':a['gateway_file'],'fix':'Ensure\x20WowokToolDisplaySchema\x20exposes\x20tool/data\x20properties\x20and\x20restart\x20the\x20Trae\x20session.'}),!a['is_strict']&&b['push']({'rule_id':'MCP-PARITY-002','severity':'medium','category':'layer_parity','tool_name':c,'description':'Deployed\x20gateway\x20root\x20schema\x20is\x20not\x20strict\x20(additionalProperties\x20!==\x20false)\x20—\x20unknown\x20keys\x20silently\x20pass\x20the\x20client-side\x20check.','location':a['gateway_file'],'fix':'Keep\x20additionalProperties:false\x20on\x20WowokToolDisplaySchema\x20(aliases\x20are\x20explicit\x20properties).'}),b;}export function analyzeAnyUnknownCensus(){const a=[],b=[MCP_SRC_SCHEMA_DIR,MCP_SRC_TOOLS_DIR];for(const c of b){const d=listTypeScriptFiles(c);for(const e of d){const f=a137a['readFileSync'](e,'utf-8')['split']('\x0a');for(let g=0x0;g<f['length'];g++){const h=f[g],j=h['trim']();if(j['startsWith']('//')||j['startsWith']('*'))continue;const k=[{'regex':/z\.any\(\)/g,'pattern':'z.any()'},{'regex':/z\.unknown\(\)/g,'pattern':'z.unknown()'},{'regex':/args\s*:\s*any\b/g,'pattern':'args:\x20any'},{'regex':/Promise\s*<\s*any\s*>/g,'pattern':'Promise<any>'},{'regex':/Record\s*<\s*string\s*,\s*any\s*>/g,'pattern':'Record<string,\x20any>'},{'regex':/\bas\s+any\b/g,'pattern':'as\x20any'}];for(const {regex:l,pattern:n}of k){l['lastIndex']=0x0;let o;while((o=l['exec'](h))!==null){const p=categorizeAnyInstance(e,g+0x1,h,n);a['push']({'file':e,'line':g+0x1,'code':j['length']>0x78?j['slice'](0x0,0x75)+'...':j,'pattern':n,'category':p['category'],'reason':p['reason'],'fix_suggestion':p['fix']});}}}}}return a;}function listTypeScriptFiles(a){const b=[];if(!a137a['existsSync'](a))return b;const c=a137a['readdirSync'](a,{'withFileTypes':!![]});for(const d of c){const e=a137b['join'](a,d['name']);if(d['isDirectory']()){if(d['name']==='__tests__'||d['name']==='node_modules')continue;b['push'](...listTypeScriptFiles(e));}else d['isFile']()&&d['name']['endsWith']('.ts')&&b['push'](e);}return b;}function categorizeAnyInstance(a,b,c,d){const e=a137b['basename'](a),f=c['trim']();if(d==='z.any()'&&/SemanticSummarySchema\s*=\s*z\.any\(\)/['test'](f))return{'category':'fixable','reason':'Circular-dependency\x20workaround\x20for\x20SemanticSummarySchema\x20—\x20can\x20use\x20z.lazy()\x20or\x20refactor\x20to\x20break\x20the\x20cycle.','fix':'Define\x20SemanticSummarySchema\x20with\x20z.lazy(()\x20=>\x20SemanticSummarySchemaReal)\x20or\x20restructure\x20imports\x20to\x20break\x20the\x20cycle.'};if(d==='z.any()'&&/result\s*:\s*z\.any\(\)/['test'](f)&&/[\\/]config[\\/]|[\\/]project[\\/]/['test'](a))return{'category':'fixable','reason':'Result\x20shape\x20depends\x20on\x20action\x20—\x20can\x20use\x20z.discriminatedUnion(\x27action\x27,\x20[...])\x20to\x20type\x20each\x20action\x27s\x20result.','fix':'Define\x20discriminated\x20union:\x20z.discriminatedUnion(\x27action\x27,\x20[z.object({action:\x20z.literal(\x27list\x27),\x20result:\x20...}),\x20...]).'};if(d==='z.unknown()'&&/result\s*:\s*z\.unknown\(\)/['test'](f)&&/index\.ts/['test'](e))return{'category':'fixable','reason':'query_toolkit\x20output\x20result\x20depends\x20on\x20query_type\x20—\x20can\x20use\x20z.discriminatedUnion(\x27query_type\x27,\x20[...]).','fix':'Define\x20discriminated\x20union:\x20z.discriminatedUnion(\x27query_type\x27,\x20[z.object({query_type:\x20z.literal(\x27local_mark_list\x27),\x20result:\x20z.array(MarkDataSchema)}),\x20...]).'};if(d==='z.any()'&&/data\s*:\s*z\.any\(\)/['test'](f)&&/[\\/]schema-query[\\/]/['test'](a))return{'category':'fixable','reason':'SchemaQuery\x20output\x20data\x20depends\x20on\x20action\x20—\x20can\x20use\x20discriminated\x20union\x20by\x20action.','fix':'Define\x20discriminated\x20union:\x20action=\x27get\x27\x20returns\x20JSON\x20Schema,\x20action=\x27list\x27\x20returns\x20array\x20of\x20items.'};if(d==='args:\x20any'&&/handlers[\\/]/['test'](a))return{'category':'fixable','reason':'Handler\x20args\x20can\x20use\x20`unknown`\x20(forces\x20runtime\x20validation)\x20or\x20a\x20typed\x20input\x20schema.','fix':'Replace\x20`args:\x20any`\x20with\x20`args:\x20unknown`\x20and\x20use\x20strictParse(schema,\x20args)\x20at\x20the\x20top\x20of\x20the\x20handler.'};if(d==='args:\x20any'&&/tools[\\/]index\.ts/['test'](a))return{'category':'fixable','reason':'dispatchToolCall\x20args\x20is\x20`any`\x20—\x20can\x20be\x20`unknown`\x20since\x20each\x20tool\x20parses\x20with\x20its\x20own\x20schema.','fix':'Change\x20`args:\x20any`\x20to\x20`args:\x20unknown`\x20in\x20dispatchToolCall\x20signature.'};if(d==='args:\x20any'&&/types\.ts/['test'](e)&&/handler/['test'](f))return{'category':'fixable','reason':'ToolEntry.handler\x20args\x20is\x20`any`\x20—\x20can\x20be\x20`unknown`\x20(each\x20handler\x20parses\x20with\x20its\x20own\x20schema).','fix':'Change\x20`handler:\x20(args:\x20any)\x20=>\x20...`\x20to\x20`handler:\x20(args:\x20unknown)\x20=>\x20...`.'};if(d==='z.any()'&&/claimReceipt|ethReceipt|wowReceipt/['test'](f))return{'category':'legitimate','reason':'EVM\x20transaction\x20receipts\x20have\x20an\x20externally-defined\x20shape\x20from\x20viem/ethers\x20—\x20z.any()\x20is\x20acceptable\x20(receipt\x20is\x20informational,\x20not\x20validated).'};if(d==='z.any()'&&/content_raw/['test'](f))return{'category':'legitimate','reason':'content_raw\x20holds\x20raw\x20content\x20for\x20unknown\x20object\x20types\x20—\x20by\x20definition\x20untyped.\x20z.any()\x20is\x20acceptable\x20here.'};if((d==='z.unknown()'||d==='z.any()')&&/parsedJson/['test'](f))return{'category':'legitimate','reason':'Event\x20parsedJson\x20is\x20arbitrary\x20on-chain\x20event\x20data\x20—\x20z.record(z.string(),\x20z.unknown())\x20is\x20appropriate.'};if(d==='z.any()'&&/key_value/['test'](f))return{'category':'fixable','reason':'Repository\x20key_value\x20depends\x20on\x20key_type\x20—\x20could\x20use\x20discriminated\x20union\x20by\x20key_type\x20(string→z.string(),\x20u64→z.bigint()/number,\x20etc.).','fix':'Define\x20z.discriminatedUnion(\x27key_type\x27,\x20[...])\x20with\x20each\x20variant\x20typed.'};if(d==='z.unknown()'&&/data\s*:\s*z\.unknown\(\)/['test'](f)&&/[\\/]bridge/['test'](a))return{'category':'legitimate','reason':'Bridge\x20operation\x20result\x20data\x20varies\x20by\x20operation_type\x20—\x20currently\x209\x20different\x20shapes.\x20Discriminated\x20union\x20would\x20be\x20ideal\x20but\x20high\x20refactor\x20cost.'};if(d==='z.unknown()'&&/adjusted_params/['test'](f))return{'category':'legitimate','reason':'adjusted_params\x20are\x20free-form\x20key-value\x20pairs\x20suggested\x20by\x20AI\x20—\x20z.record(z.string(),\x20z.unknown())\x20is\x20appropriate.'};if(d==='z.any()'&&/object\s*:\s*z\.union.*z\.record\(z\.any\(\)/['test'](f))return{'category':'fixable','reason':'Creation\x20vs\x20reference\x20object\x20union\x20—\x20z.record(z.any())\x20should\x20be\x20replaced\x20with\x20NamedObjectSchema\x20(structured\x20creation\x20input).','fix':'Replace\x20z.record(z.any())\x20with\x20NamedObjectSchema\x20(already\x20defined\x20in\x20base.ts).'};if(d==='z.any()'&&/result\s*:\s*z\.any\(\)\.optional\(\)/['test'](f)&&/[\\/]bridge/['test'](a))return{'category':'legitimate','reason':'Bridge\x20result\x20is\x20operation-specific\x20(manage_evm_rpc\x20has\x20different\x20result\x20per\x20operation)\x20—\x20z.any().optional()\x20is\x20acceptable\x20here.'};if(d==='Promise<any>'&&/[\\/](wrap|shared)\.ts/['test'](a))return{'category':'fixable','reason':'Generic\x20wrappers\x20in\x20wrap.ts/shared.ts\x20use\x20Promise<any>\x20—\x20could\x20be\x20made\x20generic\x20<T>.','fix':'Replace\x20`Promise<any>`\x20with\x20`Promise<ToolDispatchResult>`\x20(the\x20actual\x20return\x20shape).'};if(d==='Record<string,\x20any>'&&/types\.ts/['test'](e)&&/_meta|structuredContent/['test'](f))return{'category':'fixable','reason':'ToolConfig._meta\x20and\x20ToolDispatchResult.structuredContent\x20could\x20use\x20structured\x20types.','fix':'Define\x20ToolMeta\x20interface\x20(category,\x20tags)\x20and\x20replace\x20structuredContent:\x20any\x20with\x20structured\x20type.'};if(d==='as\x20any')return{'category':'legitimate','reason':'`as\x20any`\x20cast\x20—\x20usually\x20for\x20third-party\x20type\x20mismatches\x20(MCP\x20SDK).\x20Acceptable\x20if\x20isolated.'};return{'category':'legitimate','reason':'Unclassified\x20any/unknown\x20usage\x20—\x20review\x20manually.\x20Defaulting\x20to\x20legitimate\x20(no\x20auto-fix).'};}export function analyzeHandlerTypeSafety(a){const b=[];for(const c of a){if(c['pattern']!=='args:\x20any')continue;if(!/tools[\\/]/['test'](c['file']))continue;b['push']({'rule_id':'MCP-HANDLER-001','severity':'medium','category':'handler_types','tool_name':a137b['basename'](c['file'],'.ts'),'description':'Handler\x20uses\x20`args:\x20any`\x20—\x20bypasses\x20TypeScript\x20type\x20checking.\x20'+c['reason'],'location':c['file']+':'+c['line'],'fix':c['fix_suggestion']});}return b;}export function analyzeOutputSchemaCoverage(a){const b=[];for(const d of a){!d['layer3_generated']['output_exists']&&d['name']!=='onchain_operations'&&b['push']({'rule_id':'MCP-OUTPUT-001','severity':'high','category':'output_coverage','tool_name':d['name'],'description':'Layer\x203\x20output\x20schema\x20file\x20does\x20not\x20exist:\x20'+d['layer3_generated']['output_schema_file'],'fix':'Add\x20outputSchema\x20to\x20'+d['name']+'\x27s\x20tool\x20definition\x20and\x20regenerate\x20schemas.'}),d['layer2_zod']['output_schema_export']===null&&b['push']({'rule_id':'MCP-OUTPUT-002','severity':'medium','category':'output_coverage','tool_name':d['name'],'description':'Layer\x202\x20outputSchema\x20is\x20defined\x20inline\x20(not\x20exported\x20with\x20a\x20stable\x20name).\x20This\x20makes\x20it\x20harder\x20to\x20reference\x20from\x20tests.','fix':'Export\x20the\x20outputSchema\x20with\x20a\x20stable\x20name\x20(e.g.,\x20'+d['name']+'OutputSchema).'});}return b;}export function analyzeGenerationScriptSync(){const a=[];if(!a137a['existsSync'](GENERATION_SCRIPT))return a['push']({'rule_id':'MCP-GENSYNC-001','severity':'critical','category':'generation_sync','tool_name':'(all)','description':'Generation\x20script\x20not\x20found:\x20'+GENERATION_SCRIPT}),a;const b=a137a['readFileSync'](GENERATION_SCRIPT,'utf-8'),c=/name:\s*["']([^"']+)["']/g,d=new Set();let e;while((e=c['exec'](b))!==null){ALL_TOOLS['some'](f=>f['name']===e[0x1])&&d['add'](e[0x1]);}for(const f of ALL_TOOLS){!d['has'](f['name'])&&a['push']({'rule_id':'MCP-GENSYNC-002','severity':'high','category':'generation_sync','tool_name':f['name'],'description':'Tool\x20\x22'+f['name']+'\x22\x20is\x20in\x20TOOL_REGISTRY\x20but\x20missing\x20from\x20generate-json-schemas.ts.\x20Layer\x203\x20schemas\x20will\x20not\x20be\x20generated.','location':GENERATION_SCRIPT,'fix':'Add\x20a\x20get'+toPascalCase(f['name'])+'Tool()\x20function\x20and\x20add\x20it\x20to\x20the\x20tools\x20array.'});}return a;}function toPascalCase(a){return a['split']('_')['map'](b=>b['charAt'](0x0)['toUpperCase']()+b['slice'](0x1)['toLowerCase']())['join']('');}export function analyzeSchemaQueryReflection(a){const b=[];for(const e of a){!e['layer3_generated']['input_exists']&&b['push']({'rule_id':'MCP-REFLECT-001','severity':'high','category':'reflection','tool_name':e['name'],'description':'schema_query(action=\x27get\x27,\x20name=\x27'+e['name']+'\x27)\x20would\x20fail\x20—\x20Layer\x203\x20input\x20schema\x20missing.','fix':'Run\x20pnpm\x20generate:schemas.'}),!e['layer3_generated']['output_exists']&&e['name']!=='onchain_operations'&&b['push']({'rule_id':'MCP-REFLECT-002','severity':'medium','category':'reflection','tool_name':e['name'],'description':'schema_query(action=\x27get_output\x27,\x20name=\x27'+e['name']+'\x27)\x20would\x20fail\x20—\x20Layer\x203\x20output\x20schema\x20missing.','fix':'Run\x20pnpm\x20generate:schemas.'});}const d=['permission','service','machine','progress','guard','arbitration','repository','contact','treasury','reward','allocation','personal','payment','demand','order','gen_passport','proof','gen_proof'];for(const f of d){const g=a137b['join'](GENERATED_SCHEMAS_DIR,'onchain_operations_'+f+'.schema.json');!a137a['existsSync'](g)&&b['push']({'rule_id':'MCP-REFLECT-003','severity':'medium','category':'reflection','tool_name':'onchain_operations_'+f,'description':'Individual\x20operation\x20schema\x20missing:\x20'+g+'.\x20schema_query(action=\x27get\x27,\x20name=\x27onchain_operations_'+f+'\x27)\x20would\x20fail.','fix':'Run\x20pnpm\x20generate:schemas.'});}return b;}function normalizeGlossaryTerm(a){return a['toLowerCase']()['replace'](/[-_\s]/g,'');}const GLOSSARY_ALIAS_INDEX=((()=>{const a=new Set(CONCEPT_GLOSSARY['map'](c=>normalizeGlossaryTerm(c['term']))),b=new Map();for(const c of CONCEPT_GLOSSARY){for(const d of c['aliases']){const e=normalizeGlossaryTerm(d);if(a['has'](e))continue;if(!b['has'](e))b['set'](e,c['term']);}}return b;})());function collectSchemaProperties(a,b,c){if(!a||typeof a!=='object')return;const d=a;if(d['properties']&&typeof d['properties']==='object')for(const e of Object['keys'](d['properties'])){c['push']({'file':b,'property':e}),collectSchemaProperties(d['properties'][e],b,c);}if(d['definitions']&&typeof d['definitions']==='object')for(const f of Object['keys'](d['definitions'])){collectSchemaProperties(d['definitions'][f],b,c);}if(d['items'])collectSchemaProperties(d['items'],b,c);if(Array['isArray'](d['anyOf']))d['anyOf']['forEach'](g=>collectSchemaProperties(g,b,c));if(Array['isArray'](d['oneOf']))d['oneOf']['forEach'](g=>collectSchemaProperties(g,b,c));d['additionalProperties']&&typeof d['additionalProperties']==='object'&&collectSchemaProperties(d['additionalProperties'],b,c);}export function analyzeGlossaryAlignment(){const a=[];if(!a137a['existsSync'](GENERATED_SCHEMAS_DIR))return a;const b=a137a['readdirSync'](GENERATED_SCHEMAS_DIR)['filter'](d=>d['endsWith']('.schema.json')||d['endsWith']('.output.json')),c=new Set();for(const d of b){const e=a137b['join'](GENERATED_SCHEMAS_DIR,d);let f;try{f=JSON['parse'](a137a['readFileSync'](e,'utf-8'));}catch{continue;}const g=[];collectSchemaProperties(f,d,g);for(const h of g){const i=normalizeGlossaryTerm(h['property']),j=GLOSSARY_ALIAS_INDEX['get'](i);if(!j)continue;const k=h['file']+'::'+h['property'];if(c['has'](k))continue;c['add'](k),a['push']({'rule_id':'MCP-GLOSSARY-001','severity':'medium','category':'glossary_alignment','tool_name':d['replace'](/\.(schema|output)\.json$/,''),'description':'Schema\x20field\x20\x27'+h['property']+'\x27\x20uses\x20a\x20deprecated\x20glossary\x20alias\x20—\x20the\x20canonical\x20term\x20is\x20\x27'+j+'\x27.','location':e,'fix':'Rename\x20the\x20field\x20to\x20the\x20canonical\x20term\x20(camelCase/snake_case\x20of\x20\x27'+j+'\x27).'});}}return a;}export function scanAllMcpSchemas(){const a=analyzeLayerCensus(),b=loadLayer4Gateway(),c=analyzeAnyUnknownCensus(),d=[...analyzeGatewayDeployment(b),...analyzeGatewayDispatchContract(b),...analyzeHandlerTypeSafety(c),...analyzeOutputSchemaCoverage(a),...analyzeGenerationScriptSync(),...analyzeSchemaQueryReflection(a),...analyzeGlossaryAlignment()],e=new Map(),g=new Map();for(const k of d){if(!e['has'](k['severity']))e['set'](k['severity'],[]);e['get'](k['severity'])['push'](k);if(!g['has'](k['category']))g['set'](k['category'],[]);g['get'](k['category'])['push'](k);}const h=c['filter'](l=>l['category']==='fixable')['length'],i=c['filter'](l=>l['category']==='legitimate')['length'],j=c['filter'](l=>l['category']==='external')['length'];return{'census':a,'gateway':b,'findings':d,'any_unknown_instances':c,'findings_by_severity':e,'findings_by_category':g,'total_findings':d['length'],'fixable_any_count':h,'legitimate_any_count':i,'external_any_count':j};}export function formatAuditReport(a){const b=[];b['push']('#\x20MCP\x20Schema\x20Audit\x20Report\x20—\x20'+a['census']['length']+'\x20WoWok\x20Sub-Tools\x20+\x20Unified\x20Gateway'),b['push'](''),b['push']('>\x20Auto-generated\x20by\x20`mcp-schema-audit.ts`\x20v'+MCP_SCHEMA_AUDIT_VERSION+'\x20—\x20comprehensive'),b['push']('>\x204-layer\x20audit\x20of\x20schema\x20consistency,\x20any/unknown\x20usage,\x20and\x20I/O\x20coverage.'),b['push'](''),b['push']('##\x20Summary'),b['push'](''),b['push']('-\x20**Tools\x20audited**:\x20'+a['census']['length']),b['push']('-\x20**Total\x20findings**:\x20'+a['total_findings']),b['push']('-\x20**Gateway\x20deployed**:\x20'+(a['gateway']['file_exists']?'yes\x20('+a['gateway']['all_mounts']['length']+'\x20Trae\x20mount(s))':'NO')),b['push']('-\x20**any/unknown\x20instances**:\x20'+a['any_unknown_instances']['length']+'\x20total'),b['push']('\x20\x20-\x20Fixable:\x20'+a['fixable_any_count']),b['push']('\x20\x20-\x20Legitimate:\x20'+a['legitimate_any_count']),b['push']('\x20\x20-\x20External:\x20'+a['external_any_count']),b['push']('-\x20**Glossary\x20alignment**:\x20'+(a['findings_by_category']['get']('glossary_alignment')??[])['length']+'\x20deprecated-alias\x20schema\x20field(s)'),b['push'](''),b['push']('###\x20Findings\x20by\x20Severity'),b['push'](''),b['push']('|\x20Severity\x20|\x20Count\x20|'),b['push']('|----------|-------|');for(const h of['critical','high','medium','low','info']){const i=a['findings_by_severity']['get'](h)??[];b['push']('|\x20'+h+'\x20|\x20'+i['length']+'\x20|');}b['push'](''),b['push']('###\x20Findings\x20by\x20Category'),b['push'](''),b['push']('|\x20Category\x20|\x20Count\x20|'),b['push']('|----------|-------|');for(const j of['gateway_deployment','layer_parity','handler_types','output_coverage','generation_sync','reflection','glossary_alignment']){const k=a['findings_by_category']['get'](j)??[];b['push']('|\x20'+j+'\x20|\x20'+k['length']+'\x20|');}b['push'](''),b['push']('##\x20Layer\x204\x20—\x20Deployed\x20Gateway'),b['push']('');a['gateway']['file_exists']?(b['push']('-\x20**Descriptor**:\x20`'+a['gateway']['gateway_file']+'`\x20('+(a['gateway']['size_bytes']/0x400)['toFixed'](0x1)+'KB)'),b['push']('-\x20**Name**:\x20'+a['gateway']['gateway_name']),b['push']('-\x20**Dispatch\x20contract**:\x20tool='+(a['gateway']['has_tool_field']?'✓':'✗')+'\x20data='+(a['gateway']['has_data_field']?'✓':'✗')+'\x20strict='+(a['gateway']['is_strict']?'✓':'✗')),b['push']('-\x20**Definitions**:\x20'+a['gateway']['definitions_count']),b['push']('-\x20**schema_query\x20hint**:\x20'+(a['gateway']['has_schema_hint']?'✓':'✗')),b['push']('-\x20**Trae\x20mounts**:\x20'+a['gateway']['all_mounts']['length'])):b['push']('-\x20✗\x20No\x20wowok.json\x20found\x20under\x20any\x20Trae\x20mount\x20in\x20'+TRAE_MCPS_ROOT);b['push'](''),b['push']('##\x20Layer\x20Census\x20—\x20All\x20'+a['census']['length']+'\x20Sub-Tools\x20(dispatched\x20via\x20the\x20wowok\x20gateway)'),b['push'](''),b['push']('|\x20Tool\x20|\x20L3\x20Input\x20|\x20L3\x20Output\x20|'),b['push']('|------|----------|-----------|');for(const l of a['census']){const m=l['layer3_generated']['input_exists']?'✓\x20'+(l['layer3_generated']['input_size_bytes']/0x400)['toFixed'](0x1)+'KB':'✗\x20MISSING',n=l['layer3_generated']['output_exists']?'✓\x20'+(l['layer3_generated']['output_size_bytes']/0x400)['toFixed'](0x1)+'KB':'✗\x20MISSING';b['push']('|\x20'+l['name']+'\x20|\x20'+m+'\x20|\x20'+n+'\x20|');}b['push'](''),b['push']('##\x20Findings\x20Detail'),b['push']('');const d=['critical','high','medium','low','info'];for(const o of d){const p=a['findings_by_severity']['get'](o)??[];if(p['length']===0x0)continue;const q=o['toUpperCase']();b['push']('###\x20'+q+'\x20('+p['length']+')'),b['push']('');for(const r of p){b['push']('-\x20**['+r['rule_id']+']\x20'+r['description']);if(r['location'])b['push']('\x20\x20-\x20Location:\x20`'+r['location']+'`');if(r['fix'])b['push']('\x20\x20-\x20Fix:\x20'+r['fix']);b['push']('');}}b['push']('##\x20any/unknown\x20Census\x20Detail'),b['push'](''),b['push']('Total\x20instances:\x20'+a['any_unknown_instances']['length']),b['push'](''),b['push']('###\x20By\x20Pattern'),b['push'](''),b['push']('|\x20Pattern\x20|\x20Total\x20|\x20Fixable\x20|\x20Legitimate\x20|\x20External\x20|'),b['push']('|---------|-------|---------|------------|----------|');const e=new Map();for(const s of a['any_unknown_instances']){if(!e['has'](s['pattern']))e['set'](s['pattern'],[]);e['get'](s['pattern'])['push'](s);}for(const [t,u]of[...e['entries']()]['sort']((v,w)=>w[0x1]['length']-v[0x1]['length'])){const v=u['filter'](y=>y['category']==='fixable')['length'],w=u['filter'](y=>y['category']==='legitimate')['length'],x=u['filter'](y=>y['category']==='external')['length'];b['push']('|\x20`'+t+'`\x20|\x20'+u['length']+'\x20|\x20'+v+'\x20|\x20'+w+'\x20|\x20'+x+'\x20|');}b['push']('');const g=a['any_unknown_instances']['filter'](y=>y['category']==='fixable');if(g['length']>0x0){b['push']('###\x20Fixable\x20Instances\x20(Priority\x20List)'),b['push']('');for(const y of g){b['push']('-\x20**'+a137b['basename'](y['file'])+':'+y['line']+'**\x20[`'+y['pattern']+'`]'),b['push']('\x20\x20-\x20Code:\x20`'+y['code']+'`'),b['push']('\x20\x20-\x20Reason:\x20'+y['reason']);if(y['fix_suggestion'])b['push']('\x20\x20-\x20Fix:\x20'+y['fix_suggestion']);b['push']('');}}return b['push']('##\x20Recommended\x20Action\x20Plan'),b['push'](''),b['push']('###\x20Phase\x201:\x20Keep\x20the\x20Layer\x203\x20schema\x20set\x20regenerable'),b['push'](''),b['push']('Layer\x204\x20(the\x20deployed\x20wowok.json\x20gateway)\x20is\x20CLIENT-generated\x20from\x20our\x20tools/list\x20—\x20keep\x20Layer\x203\x20in\x20sync\x20so\x20schema_query\x20reflection\x20always\x20serves\x20fresh\x20schemas:'),b['push'](''),b['push']('```bash'),b['push']('cd\x20d:/wowok/agent/mcp\x20&&\x20pnpm\x20generate:schemas'),b['push']('```'),b['push'](''),b['push']('###\x20Phase\x202:\x20Type\x20the\x20'+a['fixable_any_count']+'\x20fixable\x20any/unknown\x20instances'),b['push'](''),b['push']('Priority\x20order:'),b['push'](''),b['push']('1.\x20**SemanticSummarySchema**\x20(src/schema/local/index.ts:6)\x20—\x20use\x20`z.lazy()`'),b['push']('2.\x20**ConfigOperationOutputSchema.result**\x20(src/schema/config/index.ts:17)\x20—\x20discriminated\x20union\x20by\x20action'),b['push']('3.\x20**ProjectOperationOutputSchema.result**\x20(src/schema/project/index.ts:34)\x20—\x20discriminated\x20union\x20by\x20action'),b['push']('4.\x20**query_toolkit\x20output\x20result**\x20(src/tools/index.ts:250)\x20—\x20discriminated\x20union\x20by\x20query_type'),b['push']('5.\x20**SchemaQueryOutputSchema.data**\x20(src/schema/schema-query/index.ts:34)\x20—\x20discriminated\x20union\x20by\x20action'),b['push']('6.\x20**RepositoryKeyValueSchema.key_value**\x20(src/schema/operations.ts:331)\x20—\x20discriminated\x20union\x20by\x20key_type'),b['push']('7.\x20**Handler\x20args:\x20any**\x20—\x20replace\x20with\x20`unknown`\x20(forces\x20strictParse\x20at\x20top\x20of\x20handler)'),b['push']('8.\x20**dispatchToolCall(name,\x20args:\x20any)**\x20—\x20replace\x20with\x20`unknown`'),b['push'](''),b['push']('###\x20Phase\x203:\x20Verify\x20I/O\x20Schema\x20Match'),b['push'](''),b['push']('For\x20each\x20tool,\x20write\x20a\x20parity\x20test\x20that:'),b['push']('1.\x20Calls\x20the\x20handler\x20with\x20a\x20minimal\x20valid\x20input'),b['push']('2.\x20Captures\x20the\x20structuredContent'),b['push']('3.\x20Validates\x20structuredContent\x20against\x20outputSchema'),b['push']('4.\x20Reports\x20any\x20mismatch'),b['push'](''),b['join']('\x0a');}
1
+ import*as a141a from'fs';import*as a141b from'path';import{CONCEPT_GLOSSARY}from'./glossary.js';export const TRAE_MCPS_ROOT='c:\x5cUsers\x5czhou\x5c.trae-cn\x5cmcps';export const GENERATED_SCHEMAS_DIR='d:\x5cwowok\x5cagent\x5cmcp\x5cdist\x5cschemas';export const MCP_SRC_SCHEMA_DIR='d:\x5cwowok\x5cagent\x5cmcp\x5csrc\x5cschema';export const MCP_SRC_TOOLS_DIR='d:\x5cwowok\x5cagent\x5cmcp\x5csrc\x5ctools';export const GENERATION_SCRIPT='d:\x5cwowok\x5cagent\x5cmcp\x5cscripts\x5cgenerate-json-schemas.ts';export const TOOLS_INDEX_FILE='d:\x5cwowok\x5cagent\x5cmcp\x5csrc\x5ctools\x5cindex.ts';export const MCP_SCHEMA_AUDIT_VERSION='2.1.0';export const ALL_TOOLS=[{'name':'onchain_operations','input_schema_export':'OnchainOperationsSchema','output_schema_export':'CallOutputSchema'},{'name':'account_operation','input_schema_export':'AccountOperationSchema','output_schema_export':'AccountOperationOutputWrappedSchema'},{'name':'local_mark_operation','input_schema_export':'LocalMarkOperationSchema','output_schema_export':'LocalMarkOperationOutputWrappedSchema'},{'name':'local_info_operation','input_schema_export':'LocalInfoOperationSchema','output_schema_export':'LocalInfoOperationOutputWrappedSchema'},{'name':'wip_file','input_schema_export':'WipOperationsSchema','output_schema_export':'WipOperationOutputSchema'},{'name':'messenger_operation','input_schema_export':'MessengerOperationInputSchema','output_schema_export':'MessengerOperationOutputSchema'},{'name':'guard2file','input_schema_export':'Guard2File_InputSchema','output_schema_export':'Guard2File_OutputWrappedSchema'},{'name':'machineNode2file','input_schema_export':'MachineNode2File_InputSchema','output_schema_export':'MachineNode2File_OutputWrappedSchema'},{'name':'query_toolkit','input_schema_export':'WatchQueryOperationsSchema','output_schema_export':'WatchQueryOperationsResultSchema'},{'name':'onchain_table_data','input_schema_export':'OnchainTableDataSchema','output_schema_export':'OnchainTableDataResultSchema'},{'name':'onchain_events','input_schema_export':'OnchainEventsInputSchema','output_schema_export':'OnchainEventsResultSchema'},{'name':'wowok_buildin_info','input_schema_export':'ProtocolInfoQuerySchema','output_schema_export':'ProtocolInfoResultSchema'},{'name':'schema_query','input_schema_export':'SchemaQueryInputSchema','output_schema_export':'SchemaQueryOutputSchema'},{'name':'bridge_operation','input_schema_export':'BridgeOperationsSchema','output_schema_export':'BridgeCallOutputSchema'},{'name':'project_operation','input_schema_export':'ProjectOperationInputSchema','output_schema_export':'ProjectOperationOutputSchema'},{'name':'config_operation','input_schema_export':'ConfigOperationInputSchema','output_schema_export':'ConfigOperationOutputSchema'},{'name':'trust_score','input_schema_export':'TrustScoreInputSchema','output_schema_export':'TrustScoreOutputSchema'},{'name':'query_task_status','input_schema_export':'QueryTaskStatusInputSchema','output_schema_export':'QueryTaskStatusOutputSchema'},{'name':'evaluation_operation','input_schema_export':'EvaluationOperationInputSchema','output_schema_export':'EvaluationOperationOutputSchema'},{'name':'persona_operation','input_schema_export':'PersonaOperationInputSchema','output_schema_export':'PersonaOperationOutputSchema'},{'name':'intent_radar','input_schema_export':'IntentRadarInputSchema','output_schema_export':'IntentRadarOutputSchema'},{'name':'employee_operation','input_schema_export':'EmployeeOperationInputSchema','output_schema_export':'EmployeeOperationOutputSchema'},{'name':'industry_pack_operation','input_schema_export':'IndustryPackOperationInputSchema','output_schema_export':'IndustryPackOperationOutputSchema'},{'name':'workspace_operation','input_schema_export':'WorkspaceOperationInputSchema','output_schema_export':'WorkspaceOperationOutputSchema'}];export function discoverDeployedGatewayMounts(){const a=[];if(!a141a['existsSync'](TRAE_MCPS_ROOT))return[];for(const b of a141a['readdirSync'](TRAE_MCPS_ROOT,{'withFileTypes':!![]})){if(!b['isDirectory']())continue;const c=a141b['join'](TRAE_MCPS_ROOT,b['name'],'solo_agent','mcp_wagent','tools','wowok.json');try{const d=a141a['statSync'](c);if(d['isFile']())a['push']({'file':c,'mtime':d['mtimeMs']});}catch{}}return a['sort']((e,f)=>f['mtime']-e['mtime']),a['map'](e=>e['file']);}const GATEWAY_MISSING={'gateway_file':a141b['join'](TRAE_MCPS_ROOT,'<none>','solo_agent','mcp_wagent','tools','wowok.json'),'file_exists':![],'gateway_name':null,'has_definitions':![],'definitions_count':0x0,'has_properties':![],'has_tool_field':![],'has_data_field':![],'is_strict':![],'has_schema_hint':![],'size_bytes':0x0,'all_mounts':[]};export function loadLayer4Gateway(){const a=discoverDeployedGatewayMounts();if(a['length']===0x0)return GATEWAY_MISSING;const b=a[0x0];try{const c=a141a['readFileSync'](b,'utf-8'),d=JSON['parse'](c),e=d['arguments']??{},f=e['definitions']??{},g=Object['keys'](f)['length'];let h=e;const i=e['$ref'];if(i&&i['startsWith']('#/definitions/')){const l=i['slice']('#/definitions/'['length']),m=f[l];if(m&&typeof m==='object')h=m;}const j=h['properties']??{},k=d['description']??'';return{'gateway_file':b,'file_exists':!![],'gateway_name':d['name']??null,'has_definitions':g>0x0,'definitions_count':g,'has_properties':Object['keys'](j)['length']>0x0,'has_tool_field':'tool'in j,'has_data_field':'data'in j,'is_strict':h['additionalProperties']===![],'has_schema_hint':k['includes']('schema_query'),'size_bytes':Buffer['byteLength'](c,'utf-8'),'all_mounts':a};}catch{return{...GATEWAY_MISSING,'gateway_file':b,'all_mounts':a};}}export function loadLayer3Generated(a){const b=a141b['join'](GENERATED_SCHEMAS_DIR,a+'.schema.json'),c=a141b['join'](GENERATED_SCHEMAS_DIR,a+'.output.json'),d=a141a['existsSync'](b),e=a141a['existsSync'](c),f=d?a141a['statSync'](b)['size']:0x0,g=e?a141a['statSync'](c)['size']:0x0;return{'input_schema_file':b,'output_schema_file':c,'input_exists':d,'output_exists':e,'input_size_bytes':f,'output_size_bytes':g};}export function analyzeLayerCensus(){const a=[];for(const b of ALL_TOOLS){a['push']({'name':b['name'],'layer2_zod':{'input_schema_export':b['input_schema_export'],'output_schema_export':b['output_schema_export'],'schema_dir':MCP_SRC_SCHEMA_DIR},'layer3_generated':loadLayer3Generated(b['name'])});}return a;}export function analyzeGatewayDeployment(a){const b=[],c='(gateway)';if(!a['file_exists'])return b['push']({'rule_id':'MCP-GATEWAY-001','severity':'critical','category':'gateway_deployment','tool_name':c,'description':'No\x20deployed\x20wowok.json\x20gateway\x20descriptor\x20found\x20under\x20any\x20Trae\x20mount\x20in\x20'+TRAE_MCPS_ROOT+'.\x20The\x20MCP\x20server\x20is\x20not\x20loaded\x20by\x20any\x20Trae\x20session,\x20or\x20tools/list\x20failed.','fix':'Load\x20the\x20WoWok\x20MCP\x20server\x20in\x20a\x20Trae\x20session\x20and\x20verify\x20tools/list\x20returns\x20the\x20single\x20\x27wowok\x27\x20tool.'}),b;return a['gateway_name']!=='wowok'&&b['push']({'rule_id':'MCP-GATEWAY-002','severity':'high','category':'gateway_deployment','tool_name':c,'description':'Deployed\x20gateway\x20descriptor\x20name\x20is\x20\x27'+a['gateway_name']+'\x27\x20—\x20expected\x20\x27wowok\x27\x20(the\x20single\x20unified\x20tool\x20registered\x20by\x20the\x20server).','location':a['gateway_file'],'fix':'Restart\x20the\x20Trae\x20session\x20so\x20Trae\x20regenerates\x20wowok.json\x20from\x20the\x20server\x27s\x20tools/list.'}),!a['has_definitions']&&a['definitions_count']===0x0&&!a['has_properties']&&b['push']({'rule_id':'MCP-GATEWAY-003','severity':'high','category':'gateway_deployment','tool_name':c,'description':'Deployed\x20gateway\x20descriptor\x20carries\x20no\x20argument\x20schema\x20(no\x20definitions\x20and\x20no\x20properties)\x20—\x20the\x20LLM\x20has\x20no\x20parameter\x20structure\x20at\x20all.','location':a['gateway_file'],'fix':'Ensure\x20listTools()\x20advertises\x20WowokToolDisplaySchema\x20and\x20restart\x20the\x20Trae\x20session.'}),!a['has_schema_hint']&&b['push']({'rule_id':'MCP-GATEWAY-004','severity':'medium','category':'gateway_deployment','tool_name':c,'description':'Gateway\x20descriptor\x20description\x20does\x20not\x20mention\x20schema_query\x20—\x20the\x20LLM\x20is\x20not\x20told\x20about\x20the\x20schema\x20self-correction\x20path\x20(sub-tool\x20schemas\x20are\x20returned\x20on\x20validation\x20mismatch).','location':a['gateway_file'],'fix':'Keep\x20the\x20schema_query\x20mention\x20in\x20WOWOK_TOOL_DESCRIPTION\x20(src/tools/index.ts).'}),b;}export function analyzeGatewayDispatchContract(a){const b=[],c='(gateway)';if(!a['file_exists'])return b;const d=[];if(!a['has_tool_field'])d['push']('tool');if(!a['has_data_field'])d['push']('data');return d['length']>0x0&&b['push']({'rule_id':'MCP-PARITY-001','severity':'high','category':'layer_parity','tool_name':c,'description':'Deployed\x20gateway\x20argument\x20schema\x20is\x20missing\x20dispatch\x20field(s):\x20'+d['join'](',\x20')+'.\x20Calls\x20of\x20the\x20form\x20wowok({\x20tool,\x20data\x20})\x20cannot\x20be\x20validated.','location':a['gateway_file'],'fix':'Ensure\x20WowokToolDisplaySchema\x20exposes\x20tool/data\x20properties\x20and\x20restart\x20the\x20Trae\x20session.'}),!a['is_strict']&&b['push']({'rule_id':'MCP-PARITY-002','severity':'medium','category':'layer_parity','tool_name':c,'description':'Deployed\x20gateway\x20root\x20schema\x20is\x20not\x20strict\x20(additionalProperties\x20!==\x20false)\x20—\x20unknown\x20keys\x20silently\x20pass\x20the\x20client-side\x20check.','location':a['gateway_file'],'fix':'Keep\x20additionalProperties:false\x20on\x20WowokToolDisplaySchema\x20(aliases\x20are\x20explicit\x20properties).'}),b;}export function analyzeAnyUnknownCensus(){const a=[],b=[MCP_SRC_SCHEMA_DIR,MCP_SRC_TOOLS_DIR];for(const c of b){const d=listTypeScriptFiles(c);for(const e of d){const f=a141a['readFileSync'](e,'utf-8')['split']('\x0a');for(let g=0x0;g<f['length'];g++){const h=f[g],j=h['trim']();if(j['startsWith']('//')||j['startsWith']('*'))continue;const k=[{'regex':/z\.any\(\)/g,'pattern':'z.any()'},{'regex':/z\.unknown\(\)/g,'pattern':'z.unknown()'},{'regex':/args\s*:\s*any\b/g,'pattern':'args:\x20any'},{'regex':/Promise\s*<\s*any\s*>/g,'pattern':'Promise<any>'},{'regex':/Record\s*<\s*string\s*,\s*any\s*>/g,'pattern':'Record<string,\x20any>'},{'regex':/\bas\s+any\b/g,'pattern':'as\x20any'}];for(const {regex:l,pattern:n}of k){l['lastIndex']=0x0;let o;while((o=l['exec'](h))!==null){const p=categorizeAnyInstance(e,g+0x1,h,n);a['push']({'file':e,'line':g+0x1,'code':j['length']>0x78?j['slice'](0x0,0x75)+'...':j,'pattern':n,'category':p['category'],'reason':p['reason'],'fix_suggestion':p['fix']});}}}}}return a;}function listTypeScriptFiles(a){const b=[];if(!a141a['existsSync'](a))return b;const c=a141a['readdirSync'](a,{'withFileTypes':!![]});for(const d of c){const e=a141b['join'](a,d['name']);if(d['isDirectory']()){if(d['name']==='__tests__'||d['name']==='node_modules')continue;b['push'](...listTypeScriptFiles(e));}else d['isFile']()&&d['name']['endsWith']('.ts')&&b['push'](e);}return b;}function categorizeAnyInstance(a,b,c,d){const e=a141b['basename'](a),f=c['trim']();if(d==='z.any()'&&/SemanticSummarySchema\s*=\s*z\.any\(\)/['test'](f))return{'category':'fixable','reason':'Circular-dependency\x20workaround\x20for\x20SemanticSummarySchema\x20—\x20can\x20use\x20z.lazy()\x20or\x20refactor\x20to\x20break\x20the\x20cycle.','fix':'Define\x20SemanticSummarySchema\x20with\x20z.lazy(()\x20=>\x20SemanticSummarySchemaReal)\x20or\x20restructure\x20imports\x20to\x20break\x20the\x20cycle.'};if(d==='z.any()'&&/result\s*:\s*z\.any\(\)/['test'](f)&&/[\\/]config[\\/]|[\\/]project[\\/]/['test'](a))return{'category':'fixable','reason':'Result\x20shape\x20depends\x20on\x20action\x20—\x20can\x20use\x20z.discriminatedUnion(\x27action\x27,\x20[...])\x20to\x20type\x20each\x20action\x27s\x20result.','fix':'Define\x20discriminated\x20union:\x20z.discriminatedUnion(\x27action\x27,\x20[z.object({action:\x20z.literal(\x27list\x27),\x20result:\x20...}),\x20...]).'};if(d==='z.unknown()'&&/result\s*:\s*z\.unknown\(\)/['test'](f)&&/index\.ts/['test'](e))return{'category':'fixable','reason':'query_toolkit\x20output\x20result\x20depends\x20on\x20query_type\x20—\x20can\x20use\x20z.discriminatedUnion(\x27query_type\x27,\x20[...]).','fix':'Define\x20discriminated\x20union:\x20z.discriminatedUnion(\x27query_type\x27,\x20[z.object({query_type:\x20z.literal(\x27local_mark_list\x27),\x20result:\x20z.array(MarkDataSchema)}),\x20...]).'};if(d==='z.any()'&&/data\s*:\s*z\.any\(\)/['test'](f)&&/[\\/]schema-query[\\/]/['test'](a))return{'category':'fixable','reason':'SchemaQuery\x20output\x20data\x20depends\x20on\x20action\x20—\x20can\x20use\x20discriminated\x20union\x20by\x20action.','fix':'Define\x20discriminated\x20union:\x20action=\x27get\x27\x20returns\x20JSON\x20Schema,\x20action=\x27list\x27\x20returns\x20array\x20of\x20items.'};if(d==='args:\x20any'&&/handlers[\\/]/['test'](a))return{'category':'fixable','reason':'Handler\x20args\x20can\x20use\x20`unknown`\x20(forces\x20runtime\x20validation)\x20or\x20a\x20typed\x20input\x20schema.','fix':'Replace\x20`args:\x20any`\x20with\x20`args:\x20unknown`\x20and\x20use\x20strictParse(schema,\x20args)\x20at\x20the\x20top\x20of\x20the\x20handler.'};if(d==='args:\x20any'&&/tools[\\/]index\.ts/['test'](a))return{'category':'fixable','reason':'dispatchToolCall\x20args\x20is\x20`any`\x20—\x20can\x20be\x20`unknown`\x20since\x20each\x20tool\x20parses\x20with\x20its\x20own\x20schema.','fix':'Change\x20`args:\x20any`\x20to\x20`args:\x20unknown`\x20in\x20dispatchToolCall\x20signature.'};if(d==='args:\x20any'&&/types\.ts/['test'](e)&&/handler/['test'](f))return{'category':'fixable','reason':'ToolEntry.handler\x20args\x20is\x20`any`\x20—\x20can\x20be\x20`unknown`\x20(each\x20handler\x20parses\x20with\x20its\x20own\x20schema).','fix':'Change\x20`handler:\x20(args:\x20any)\x20=>\x20...`\x20to\x20`handler:\x20(args:\x20unknown)\x20=>\x20...`.'};if(d==='z.any()'&&/claimReceipt|ethReceipt|wowReceipt/['test'](f))return{'category':'legitimate','reason':'EVM\x20transaction\x20receipts\x20have\x20an\x20externally-defined\x20shape\x20from\x20viem/ethers\x20—\x20z.any()\x20is\x20acceptable\x20(receipt\x20is\x20informational,\x20not\x20validated).'};if(d==='z.any()'&&/content_raw/['test'](f))return{'category':'legitimate','reason':'content_raw\x20holds\x20raw\x20content\x20for\x20unknown\x20object\x20types\x20—\x20by\x20definition\x20untyped.\x20z.any()\x20is\x20acceptable\x20here.'};if((d==='z.unknown()'||d==='z.any()')&&/parsedJson/['test'](f))return{'category':'legitimate','reason':'Event\x20parsedJson\x20is\x20arbitrary\x20on-chain\x20event\x20data\x20—\x20z.record(z.string(),\x20z.unknown())\x20is\x20appropriate.'};if(d==='z.any()'&&/key_value/['test'](f))return{'category':'fixable','reason':'Repository\x20key_value\x20depends\x20on\x20key_type\x20—\x20could\x20use\x20discriminated\x20union\x20by\x20key_type\x20(string→z.string(),\x20u64→z.bigint()/number,\x20etc.).','fix':'Define\x20z.discriminatedUnion(\x27key_type\x27,\x20[...])\x20with\x20each\x20variant\x20typed.'};if(d==='z.unknown()'&&/data\s*:\s*z\.unknown\(\)/['test'](f)&&/[\\/]bridge/['test'](a))return{'category':'legitimate','reason':'Bridge\x20operation\x20result\x20data\x20varies\x20by\x20operation_type\x20—\x20currently\x209\x20different\x20shapes.\x20Discriminated\x20union\x20would\x20be\x20ideal\x20but\x20high\x20refactor\x20cost.'};if(d==='z.unknown()'&&/adjusted_params/['test'](f))return{'category':'legitimate','reason':'adjusted_params\x20are\x20free-form\x20key-value\x20pairs\x20suggested\x20by\x20AI\x20—\x20z.record(z.string(),\x20z.unknown())\x20is\x20appropriate.'};if(d==='z.any()'&&/object\s*:\s*z\.union.*z\.record\(z\.any\(\)/['test'](f))return{'category':'fixable','reason':'Creation\x20vs\x20reference\x20object\x20union\x20—\x20z.record(z.any())\x20should\x20be\x20replaced\x20with\x20NamedObjectSchema\x20(structured\x20creation\x20input).','fix':'Replace\x20z.record(z.any())\x20with\x20NamedObjectSchema\x20(already\x20defined\x20in\x20base.ts).'};if(d==='z.any()'&&/result\s*:\s*z\.any\(\)\.optional\(\)/['test'](f)&&/[\\/]bridge/['test'](a))return{'category':'legitimate','reason':'Bridge\x20result\x20is\x20operation-specific\x20(manage_evm_rpc\x20has\x20different\x20result\x20per\x20operation)\x20—\x20z.any().optional()\x20is\x20acceptable\x20here.'};if(d==='Promise<any>'&&/[\\/](wrap|shared)\.ts/['test'](a))return{'category':'fixable','reason':'Generic\x20wrappers\x20in\x20wrap.ts/shared.ts\x20use\x20Promise<any>\x20—\x20could\x20be\x20made\x20generic\x20<T>.','fix':'Replace\x20`Promise<any>`\x20with\x20`Promise<ToolDispatchResult>`\x20(the\x20actual\x20return\x20shape).'};if(d==='Record<string,\x20any>'&&/types\.ts/['test'](e)&&/_meta|structuredContent/['test'](f))return{'category':'fixable','reason':'ToolConfig._meta\x20and\x20ToolDispatchResult.structuredContent\x20could\x20use\x20structured\x20types.','fix':'Define\x20ToolMeta\x20interface\x20(category,\x20tags)\x20and\x20replace\x20structuredContent:\x20any\x20with\x20structured\x20type.'};if(d==='as\x20any')return{'category':'legitimate','reason':'`as\x20any`\x20cast\x20—\x20usually\x20for\x20third-party\x20type\x20mismatches\x20(MCP\x20SDK).\x20Acceptable\x20if\x20isolated.'};return{'category':'legitimate','reason':'Unclassified\x20any/unknown\x20usage\x20—\x20review\x20manually.\x20Defaulting\x20to\x20legitimate\x20(no\x20auto-fix).'};}export function analyzeHandlerTypeSafety(a){const b=[];for(const c of a){if(c['pattern']!=='args:\x20any')continue;if(!/tools[\\/]/['test'](c['file']))continue;b['push']({'rule_id':'MCP-HANDLER-001','severity':'medium','category':'handler_types','tool_name':a141b['basename'](c['file'],'.ts'),'description':'Handler\x20uses\x20`args:\x20any`\x20—\x20bypasses\x20TypeScript\x20type\x20checking.\x20'+c['reason'],'location':c['file']+':'+c['line'],'fix':c['fix_suggestion']});}return b;}export function analyzeOutputSchemaCoverage(a){const b=[];for(const d of a){!d['layer3_generated']['output_exists']&&d['name']!=='onchain_operations'&&b['push']({'rule_id':'MCP-OUTPUT-001','severity':'high','category':'output_coverage','tool_name':d['name'],'description':'Layer\x203\x20output\x20schema\x20file\x20does\x20not\x20exist:\x20'+d['layer3_generated']['output_schema_file'],'fix':'Add\x20outputSchema\x20to\x20'+d['name']+'\x27s\x20tool\x20definition\x20and\x20regenerate\x20schemas.'}),d['layer2_zod']['output_schema_export']===null&&b['push']({'rule_id':'MCP-OUTPUT-002','severity':'medium','category':'output_coverage','tool_name':d['name'],'description':'Layer\x202\x20outputSchema\x20is\x20defined\x20inline\x20(not\x20exported\x20with\x20a\x20stable\x20name).\x20This\x20makes\x20it\x20harder\x20to\x20reference\x20from\x20tests.','fix':'Export\x20the\x20outputSchema\x20with\x20a\x20stable\x20name\x20(e.g.,\x20'+d['name']+'OutputSchema).'});}return b;}export function analyzeGenerationScriptSync(){const a=[];if(!a141a['existsSync'](GENERATION_SCRIPT))return a['push']({'rule_id':'MCP-GENSYNC-001','severity':'critical','category':'generation_sync','tool_name':'(all)','description':'Generation\x20script\x20not\x20found:\x20'+GENERATION_SCRIPT}),a;const b=a141a['readFileSync'](GENERATION_SCRIPT,'utf-8'),c=/name:\s*["']([^"']+)["']/g,d=new Set();let e;while((e=c['exec'](b))!==null){ALL_TOOLS['some'](f=>f['name']===e[0x1])&&d['add'](e[0x1]);}for(const f of ALL_TOOLS){!d['has'](f['name'])&&a['push']({'rule_id':'MCP-GENSYNC-002','severity':'high','category':'generation_sync','tool_name':f['name'],'description':'Tool\x20\x22'+f['name']+'\x22\x20is\x20in\x20TOOL_REGISTRY\x20but\x20missing\x20from\x20generate-json-schemas.ts.\x20Layer\x203\x20schemas\x20will\x20not\x20be\x20generated.','location':GENERATION_SCRIPT,'fix':'Add\x20a\x20get'+toPascalCase(f['name'])+'Tool()\x20function\x20and\x20add\x20it\x20to\x20the\x20tools\x20array.'});}return a;}function toPascalCase(a){return a['split']('_')['map'](b=>b['charAt'](0x0)['toUpperCase']()+b['slice'](0x1)['toLowerCase']())['join']('');}export function analyzeSchemaQueryReflection(a){const b=[];for(const e of a){!e['layer3_generated']['input_exists']&&b['push']({'rule_id':'MCP-REFLECT-001','severity':'high','category':'reflection','tool_name':e['name'],'description':'schema_query(action=\x27get\x27,\x20name=\x27'+e['name']+'\x27)\x20would\x20fail\x20—\x20Layer\x203\x20input\x20schema\x20missing.','fix':'Run\x20pnpm\x20generate:schemas.'}),!e['layer3_generated']['output_exists']&&e['name']!=='onchain_operations'&&b['push']({'rule_id':'MCP-REFLECT-002','severity':'medium','category':'reflection','tool_name':e['name'],'description':'schema_query(action=\x27get_output\x27,\x20name=\x27'+e['name']+'\x27)\x20would\x20fail\x20—\x20Layer\x203\x20output\x20schema\x20missing.','fix':'Run\x20pnpm\x20generate:schemas.'});}const d=['permission','service','machine','progress','guard','arbitration','repository','contact','treasury','reward','allocation','personal','payment','demand','order','gen_passport','proof','gen_proof'];for(const f of d){const g=a141b['join'](GENERATED_SCHEMAS_DIR,'onchain_operations_'+f+'.schema.json');!a141a['existsSync'](g)&&b['push']({'rule_id':'MCP-REFLECT-003','severity':'medium','category':'reflection','tool_name':'onchain_operations_'+f,'description':'Individual\x20operation\x20schema\x20missing:\x20'+g+'.\x20schema_query(action=\x27get\x27,\x20name=\x27onchain_operations_'+f+'\x27)\x20would\x20fail.','fix':'Run\x20pnpm\x20generate:schemas.'});}return b;}function normalizeGlossaryTerm(a){return a['toLowerCase']()['replace'](/[-_\s]/g,'');}const GLOSSARY_ALIAS_INDEX=((()=>{const a=new Set(CONCEPT_GLOSSARY['map'](c=>normalizeGlossaryTerm(c['term']))),b=new Map();for(const c of CONCEPT_GLOSSARY){for(const d of c['aliases']){const e=normalizeGlossaryTerm(d);if(a['has'](e))continue;if(!b['has'](e))b['set'](e,c['term']);}}return b;})());function collectSchemaProperties(a,b,c){if(!a||typeof a!=='object')return;const d=a;if(d['properties']&&typeof d['properties']==='object')for(const e of Object['keys'](d['properties'])){c['push']({'file':b,'property':e}),collectSchemaProperties(d['properties'][e],b,c);}if(d['definitions']&&typeof d['definitions']==='object')for(const f of Object['keys'](d['definitions'])){collectSchemaProperties(d['definitions'][f],b,c);}if(d['items'])collectSchemaProperties(d['items'],b,c);if(Array['isArray'](d['anyOf']))d['anyOf']['forEach'](g=>collectSchemaProperties(g,b,c));if(Array['isArray'](d['oneOf']))d['oneOf']['forEach'](g=>collectSchemaProperties(g,b,c));d['additionalProperties']&&typeof d['additionalProperties']==='object'&&collectSchemaProperties(d['additionalProperties'],b,c);}export function analyzeGlossaryAlignment(){const a=[];if(!a141a['existsSync'](GENERATED_SCHEMAS_DIR))return a;const b=a141a['readdirSync'](GENERATED_SCHEMAS_DIR)['filter'](d=>d['endsWith']('.schema.json')||d['endsWith']('.output.json')),c=new Set();for(const d of b){const e=a141b['join'](GENERATED_SCHEMAS_DIR,d);let f;try{f=JSON['parse'](a141a['readFileSync'](e,'utf-8'));}catch{continue;}const g=[];collectSchemaProperties(f,d,g);for(const h of g){const i=normalizeGlossaryTerm(h['property']),j=GLOSSARY_ALIAS_INDEX['get'](i);if(!j)continue;const k=h['file']+'::'+h['property'];if(c['has'](k))continue;c['add'](k),a['push']({'rule_id':'MCP-GLOSSARY-001','severity':'medium','category':'glossary_alignment','tool_name':d['replace'](/\.(schema|output)\.json$/,''),'description':'Schema\x20field\x20\x27'+h['property']+'\x27\x20uses\x20a\x20deprecated\x20glossary\x20alias\x20—\x20the\x20canonical\x20term\x20is\x20\x27'+j+'\x27.','location':e,'fix':'Rename\x20the\x20field\x20to\x20the\x20canonical\x20term\x20(camelCase/snake_case\x20of\x20\x27'+j+'\x27).'});}}return a;}export function scanAllMcpSchemas(){const a=analyzeLayerCensus(),b=loadLayer4Gateway(),c=analyzeAnyUnknownCensus(),d=[...analyzeGatewayDeployment(b),...analyzeGatewayDispatchContract(b),...analyzeHandlerTypeSafety(c),...analyzeOutputSchemaCoverage(a),...analyzeGenerationScriptSync(),...analyzeSchemaQueryReflection(a),...analyzeGlossaryAlignment()],e=new Map(),g=new Map();for(const k of d){if(!e['has'](k['severity']))e['set'](k['severity'],[]);e['get'](k['severity'])['push'](k);if(!g['has'](k['category']))g['set'](k['category'],[]);g['get'](k['category'])['push'](k);}const h=c['filter'](l=>l['category']==='fixable')['length'],i=c['filter'](l=>l['category']==='legitimate')['length'],j=c['filter'](l=>l['category']==='external')['length'];return{'census':a,'gateway':b,'findings':d,'any_unknown_instances':c,'findings_by_severity':e,'findings_by_category':g,'total_findings':d['length'],'fixable_any_count':h,'legitimate_any_count':i,'external_any_count':j};}export function formatAuditReport(a){const b=[];b['push']('#\x20MCP\x20Schema\x20Audit\x20Report\x20—\x20'+a['census']['length']+'\x20WoWok\x20Sub-Tools\x20+\x20Unified\x20Gateway'),b['push'](''),b['push']('>\x20Auto-generated\x20by\x20`mcp-schema-audit.ts`\x20v'+MCP_SCHEMA_AUDIT_VERSION+'\x20—\x20comprehensive'),b['push']('>\x204-layer\x20audit\x20of\x20schema\x20consistency,\x20any/unknown\x20usage,\x20and\x20I/O\x20coverage.'),b['push'](''),b['push']('##\x20Summary'),b['push'](''),b['push']('-\x20**Tools\x20audited**:\x20'+a['census']['length']),b['push']('-\x20**Total\x20findings**:\x20'+a['total_findings']),b['push']('-\x20**Gateway\x20deployed**:\x20'+(a['gateway']['file_exists']?'yes\x20('+a['gateway']['all_mounts']['length']+'\x20Trae\x20mount(s))':'NO')),b['push']('-\x20**any/unknown\x20instances**:\x20'+a['any_unknown_instances']['length']+'\x20total'),b['push']('\x20\x20-\x20Fixable:\x20'+a['fixable_any_count']),b['push']('\x20\x20-\x20Legitimate:\x20'+a['legitimate_any_count']),b['push']('\x20\x20-\x20External:\x20'+a['external_any_count']),b['push']('-\x20**Glossary\x20alignment**:\x20'+(a['findings_by_category']['get']('glossary_alignment')??[])['length']+'\x20deprecated-alias\x20schema\x20field(s)'),b['push'](''),b['push']('###\x20Findings\x20by\x20Severity'),b['push'](''),b['push']('|\x20Severity\x20|\x20Count\x20|'),b['push']('|----------|-------|');for(const h of['critical','high','medium','low','info']){const i=a['findings_by_severity']['get'](h)??[];b['push']('|\x20'+h+'\x20|\x20'+i['length']+'\x20|');}b['push'](''),b['push']('###\x20Findings\x20by\x20Category'),b['push'](''),b['push']('|\x20Category\x20|\x20Count\x20|'),b['push']('|----------|-------|');for(const j of['gateway_deployment','layer_parity','handler_types','output_coverage','generation_sync','reflection','glossary_alignment']){const k=a['findings_by_category']['get'](j)??[];b['push']('|\x20'+j+'\x20|\x20'+k['length']+'\x20|');}b['push'](''),b['push']('##\x20Layer\x204\x20—\x20Deployed\x20Gateway'),b['push']('');a['gateway']['file_exists']?(b['push']('-\x20**Descriptor**:\x20`'+a['gateway']['gateway_file']+'`\x20('+(a['gateway']['size_bytes']/0x400)['toFixed'](0x1)+'KB)'),b['push']('-\x20**Name**:\x20'+a['gateway']['gateway_name']),b['push']('-\x20**Dispatch\x20contract**:\x20tool='+(a['gateway']['has_tool_field']?'✓':'✗')+'\x20data='+(a['gateway']['has_data_field']?'✓':'✗')+'\x20strict='+(a['gateway']['is_strict']?'✓':'✗')),b['push']('-\x20**Definitions**:\x20'+a['gateway']['definitions_count']),b['push']('-\x20**schema_query\x20hint**:\x20'+(a['gateway']['has_schema_hint']?'✓':'✗')),b['push']('-\x20**Trae\x20mounts**:\x20'+a['gateway']['all_mounts']['length'])):b['push']('-\x20✗\x20No\x20wowok.json\x20found\x20under\x20any\x20Trae\x20mount\x20in\x20'+TRAE_MCPS_ROOT);b['push'](''),b['push']('##\x20Layer\x20Census\x20—\x20All\x20'+a['census']['length']+'\x20Sub-Tools\x20(dispatched\x20via\x20the\x20wowok\x20gateway)'),b['push'](''),b['push']('|\x20Tool\x20|\x20L3\x20Input\x20|\x20L3\x20Output\x20|'),b['push']('|------|----------|-----------|');for(const l of a['census']){const m=l['layer3_generated']['input_exists']?'✓\x20'+(l['layer3_generated']['input_size_bytes']/0x400)['toFixed'](0x1)+'KB':'✗\x20MISSING',n=l['layer3_generated']['output_exists']?'✓\x20'+(l['layer3_generated']['output_size_bytes']/0x400)['toFixed'](0x1)+'KB':'✗\x20MISSING';b['push']('|\x20'+l['name']+'\x20|\x20'+m+'\x20|\x20'+n+'\x20|');}b['push'](''),b['push']('##\x20Findings\x20Detail'),b['push']('');const d=['critical','high','medium','low','info'];for(const o of d){const p=a['findings_by_severity']['get'](o)??[];if(p['length']===0x0)continue;const q=o['toUpperCase']();b['push']('###\x20'+q+'\x20('+p['length']+')'),b['push']('');for(const r of p){b['push']('-\x20**['+r['rule_id']+']\x20'+r['description']);if(r['location'])b['push']('\x20\x20-\x20Location:\x20`'+r['location']+'`');if(r['fix'])b['push']('\x20\x20-\x20Fix:\x20'+r['fix']);b['push']('');}}b['push']('##\x20any/unknown\x20Census\x20Detail'),b['push'](''),b['push']('Total\x20instances:\x20'+a['any_unknown_instances']['length']),b['push'](''),b['push']('###\x20By\x20Pattern'),b['push'](''),b['push']('|\x20Pattern\x20|\x20Total\x20|\x20Fixable\x20|\x20Legitimate\x20|\x20External\x20|'),b['push']('|---------|-------|---------|------------|----------|');const e=new Map();for(const s of a['any_unknown_instances']){if(!e['has'](s['pattern']))e['set'](s['pattern'],[]);e['get'](s['pattern'])['push'](s);}for(const [t,u]of[...e['entries']()]['sort']((v,w)=>w[0x1]['length']-v[0x1]['length'])){const v=u['filter'](y=>y['category']==='fixable')['length'],w=u['filter'](y=>y['category']==='legitimate')['length'],x=u['filter'](y=>y['category']==='external')['length'];b['push']('|\x20`'+t+'`\x20|\x20'+u['length']+'\x20|\x20'+v+'\x20|\x20'+w+'\x20|\x20'+x+'\x20|');}b['push']('');const g=a['any_unknown_instances']['filter'](y=>y['category']==='fixable');if(g['length']>0x0){b['push']('###\x20Fixable\x20Instances\x20(Priority\x20List)'),b['push']('');for(const y of g){b['push']('-\x20**'+a141b['basename'](y['file'])+':'+y['line']+'**\x20[`'+y['pattern']+'`]'),b['push']('\x20\x20-\x20Code:\x20`'+y['code']+'`'),b['push']('\x20\x20-\x20Reason:\x20'+y['reason']);if(y['fix_suggestion'])b['push']('\x20\x20-\x20Fix:\x20'+y['fix_suggestion']);b['push']('');}}return b['push']('##\x20Recommended\x20Action\x20Plan'),b['push'](''),b['push']('###\x20Phase\x201:\x20Keep\x20the\x20Layer\x203\x20schema\x20set\x20regenerable'),b['push'](''),b['push']('Layer\x204\x20(the\x20deployed\x20wowok.json\x20gateway)\x20is\x20CLIENT-generated\x20from\x20our\x20tools/list\x20—\x20keep\x20Layer\x203\x20in\x20sync\x20so\x20schema_query\x20reflection\x20always\x20serves\x20fresh\x20schemas:'),b['push'](''),b['push']('```bash'),b['push']('cd\x20d:/wowok/agent/mcp\x20&&\x20pnpm\x20generate:schemas'),b['push']('```'),b['push'](''),b['push']('###\x20Phase\x202:\x20Type\x20the\x20'+a['fixable_any_count']+'\x20fixable\x20any/unknown\x20instances'),b['push'](''),b['push']('Priority\x20order:'),b['push'](''),b['push']('1.\x20**SemanticSummarySchema**\x20(src/schema/local/index.ts:6)\x20—\x20use\x20`z.lazy()`'),b['push']('2.\x20**ConfigOperationOutputSchema.result**\x20(src/schema/config/index.ts:17)\x20—\x20discriminated\x20union\x20by\x20action'),b['push']('3.\x20**ProjectOperationOutputSchema.result**\x20(src/schema/project/index.ts:34)\x20—\x20discriminated\x20union\x20by\x20action'),b['push']('4.\x20**query_toolkit\x20output\x20result**\x20(src/tools/index.ts:250)\x20—\x20discriminated\x20union\x20by\x20query_type'),b['push']('5.\x20**SchemaQueryOutputSchema.data**\x20(src/schema/schema-query/index.ts:34)\x20—\x20discriminated\x20union\x20by\x20action'),b['push']('6.\x20**RepositoryKeyValueSchema.key_value**\x20(src/schema/operations.ts:331)\x20—\x20discriminated\x20union\x20by\x20key_type'),b['push']('7.\x20**Handler\x20args:\x20any**\x20—\x20replace\x20with\x20`unknown`\x20(forces\x20strictParse\x20at\x20top\x20of\x20handler)'),b['push']('8.\x20**dispatchToolCall(name,\x20args:\x20any)**\x20—\x20replace\x20with\x20`unknown`'),b['push'](''),b['push']('###\x20Phase\x203:\x20Verify\x20I/O\x20Schema\x20Match'),b['push'](''),b['push']('For\x20each\x20tool,\x20write\x20a\x20parity\x20test\x20that:'),b['push']('1.\x20Calls\x20the\x20handler\x20with\x20a\x20minimal\x20valid\x20input'),b['push']('2.\x20Captures\x20the\x20structuredContent'),b['push']('3.\x20Validates\x20structuredContent\x20against\x20outputSchema'),b['push']('4.\x20Reports\x20any\x20mismatch'),b['push'](''),b['join']('\x0a');}
@@ -0,0 +1,17 @@
1
+ export interface MessengerGuardSuggestion {
2
+ intent: string;
3
+ recognized: boolean;
4
+ best_semantic?: {
5
+ id: string;
6
+ pattern_name: string;
7
+ semantic_intent: string;
8
+ };
9
+ best_design?: {
10
+ id: string;
11
+ business_requirement: string;
12
+ data_source: string;
13
+ };
14
+ alternatives: string[];
15
+ guidance: string;
16
+ }
17
+ export declare function suggestGuardForMessenger(intent: string): MessengerGuardSuggestion;
@@ -0,0 +1 @@
1
+ import{matchSemanticPattern}from'./guard-translation.js';import{suggestPatternForRequirement}from'./guard-design-patterns.js';export function suggestGuardForMessenger(a){const b=matchSemanticPattern(a),c=suggestPatternForRequirement(a),d=b['length']>0x0,e=b[0x0];return{'intent':a,'recognized':d,'best_semantic':e?{'id':e['id'],'pattern_name':e['pattern_name'],'semantic_intent':e['semantic_intent']}:undefined,'best_design':c['best']?{'id':c['best']['id'],'business_requirement':c['best']['business_requirement'],'data_source':c['best']['data_source']}:undefined,'alternatives':c['alternatives']['map'](f=>f['business_requirement']),'guidance':d?'Recommend\x20guard\x20\x22'+e['pattern_name']+'\x22\x20('+e['id']+')\x20for:\x20\x22'+a+'\x22.\x20'+'Add\x20it\x20to\x20the\x20recipient\x27s\x20guard\x20list\x20(messenger_operation\x20guardlist\x20add)\x20'+'with\x20a\x20passportValiditySeconds\x20matching\x20the\x20underlying\x20data\x20volatility.':'No\x20exact\x20semantic\x20pattern\x20matched\x20\x22'+a+'\x22.\x20Closest\x20design:\x20'+(c['best']['business_requirement']+'.\x20Review\x20guard-design-patterns\x20before\x20configuring.')};}
@@ -0,0 +1,18 @@
1
+ import type { PermissionContext } from "./workflow-guidance.js";
2
+ export type OperationCategory = "permission_index" | "guard" | "special";
3
+ export type ComplexityLevel = "L0" | "L1" | "L2" | "L3";
4
+ export interface OperationComplexity {
5
+ level: ComplexityLevel;
6
+ reads: number;
7
+ note?: string;
8
+ }
9
+ export interface WatchOperationDraft {
10
+ operation: string;
11
+ can_execute: boolean;
12
+ path: string;
13
+ note?: string;
14
+ }
15
+ export declare function operationCategoryOf(type: string): OperationCategory;
16
+ export declare function operationComplexityOf(type: string): OperationComplexity;
17
+ export declare function isPermissionIndexType(type: string): boolean;
18
+ export declare function enumerateObjectOperations(type: string, data: Record<string, unknown>, account: string, permCtx: PermissionContext | undefined, clockNow?: number | null): WatchOperationDraft[];
@@ -0,0 +1 @@
1
+ import{fieldMutabilityOf}from'./contract-invariants.js';import{REPOSITORY_PERMISSIONS,REWARD_PERMISSIONS,MACHINE_PERMISSIONS,PROGRESS_PERMISSIONS,TREASURY_PERMISSIONS,SERVICE_PERMISSIONS,ARBITRATION_PERMISSIONS,DEMAND_PERMISSIONS,CONTACT_PERMISSIONS}from'./permission-ledger.js';const BUILTIN_PERMISSIONS_BY_TYPE={'Repository':REPOSITORY_PERMISSIONS,'Reward':REWARD_PERMISSIONS,'Machine':MACHINE_PERMISSIONS,'Progress':PROGRESS_PERMISSIONS,'Treasury':TREASURY_PERMISSIONS,'Service':SERVICE_PERMISSIONS,'Arbitration':ARBITRATION_PERMISSIONS,'Demand':DEMAND_PERMISSIONS,'Contact':CONTACT_PERMISSIONS},CATEGORY={'Service':'permission_index','Machine':'permission_index','Treasury':'permission_index','Reward':'permission_index','Repository':'permission_index','Arbitration':'permission_index','Demand':'permission_index','Contact':'permission_index','Progress':'permission_index','Order':'guard','Allocation':'guard','Permission':'special','Guard':'special','Payment':'special','Proof':'special','Personal':'special','GenPassport':'special','GenProof':'special'},COMPLEXITY={'Service':{'level':'L1','reads':0x2,'note':'target\x20+\x20Permission\x20(admin/table)'},'Machine':{'level':'L1','reads':0x2,'note':'target\x20+\x20Permission\x20(admin/table)'},'Treasury':{'level':'L1','reads':0x2,'note':'target\x20+\x20Permission\x20(admin/table)'},'Reward':{'level':'L1','reads':0x2,'note':'target\x20+\x20Permission\x20(admin/table)'},'Repository':{'level':'L1','reads':0x2,'note':'target\x20+\x20Permission\x20(admin/table)'},'Arbitration':{'level':'L1','reads':0x2,'note':'target\x20+\x20Permission\x20(admin/table)'},'Demand':{'level':'L1','reads':0x2,'note':'target\x20+\x20Permission\x20(admin/table)'},'Contact':{'level':'L1','reads':0x2,'note':'target\x20+\x20Permission\x20(admin/table)'},'Progress':{'level':'L3','reads':0x8,'note':'machine\x20nodes\x20+\x20order\x20+\x20machine\x20Permission\x20+\x20named\x20operators'},'Order':{'level':'L0','reads':0x1,'note':'order\x20builder/agent\x20fields\x20suffice'},'Allocation':{'level':'L2','reads':0x5,'note':'allocation\x20+\x20guard\x20+\x20payment\x20+\x20recipient'},'Permission':{'level':'L0','reads':0x1,'note':'owner/admin\x20fields\x20suffice'},'Guard':{'level':'L1','reads':0x2,'note':'guard\x20table\x20+\x20dependency\x20state'},'Payment':{'level':'L0','reads':0x1,'note':'payment\x20signer\x20field\x20suffices'},'Proof':{'level':'L0','reads':0x1,'note':'proof\x20creator\x20field\x20suffices'},'Personal':{'level':'L0','reads':0x1,'note':'signer-owned\x20local\x20data'},'GenPassport':{'level':'L0','reads':0x1,'note':'signer-generated\x20credential'},'GenProof':{'level':'L0','reads':0x1,'note':'signer-generated\x20proof'}};function isCreateEntry(a){return a['name']['endsWith']('_NEW');}function addrOf(a){return typeof a==='string'&&a['length']>0x0?a['toLowerCase']():undefined;}function listHas(a,b){if(!Array['isArray'](a))return![];return a['some'](c=>String(c)['toLowerCase']()===b);}function enumeratePermissionIndexOps(a,b,c){const d=BUILTIN_PERMISSIONS_BY_TYPE[a];if(!d)return[];const f=c?.['admin']['has'](b)??![],g=c?.['table']['get'](b),h=[];for(const i of d){if(isCreateEntry(i))continue;const j=g?.['has'](i['index'])??![],k=f||j,l=f?i['name']+'\x20—\x20admin\x20(full\x20rights)':k?i['name']+'\x20—\x20holds\x20permission\x20'+i['index']:i['name']+'\x20—\x20requires\x20permission\x20'+i['index']+'\x20(not\x20held)';h['push']({'operation':i['governed_operation'],'can_execute':k,'path':'permission_index','note':l});}return h;}function orderOperations(a,b){const c=addrOf(a['builder']??a['owner']),d=c===b||listHas(a['agent'],b),e='order_holder',f=d?'account\x20is\x20the\x20order\x20holder\x20(builder)\x20or\x20an\x20agent':'not\x20the\x20order\x20holder';return[{'operation':'order::required_info_update','can_execute':d,'path':e,'note':f},{'operation':'order::agent_set','can_execute':c===b,'path':e,'note':c===b?'holder\x20may\x20manage\x20agents':'only\x20the\x20holder\x20(builder)\x20may\x20manage\x20agents'},{'operation':'order::owner_change','can_execute':c===b,'path':e,'note':c===b?'holder\x20may\x20transfer\x20the\x20order':'only\x20the\x20holder\x20(builder)\x20may\x20transfer\x20the\x20order'},{'operation':'order::owner_receive','can_execute':d,'path':e,'note':f}];}function permissionOperations(a,b){const c=addrOf(a['builder']??a['owner']),d=c===b,e=listHas(a['admin'],b),f=d?'permission\x20owner':'only\x20the\x20permission\x20owner',g=e?'permission\x20admin':d?'owner\x20(owner\x20may\x20not\x20admin-gate\x20without\x20admin)':'requires\x20admin';return[{'operation':'permission::admin_add','can_execute':d,'path':'owner','note':f},{'operation':'permission::admin_remove','can_execute':d,'path':'owner','note':f},{'operation':'permission::admin_set','can_execute':d,'path':'owner','note':f},{'operation':'permission::transfer','can_execute':d,'path':'owner','note':d?'irreversible\x20ownership\x20transfer':'only\x20the\x20owner'},{'operation':'permission::um_set','can_execute':d,'path':'owner','note':f},{'operation':'permission::description_set','can_execute':e,'path':'admin','note':g},{'operation':'permission::perm_add','can_execute':e,'path':'admin','note':g},{'operation':'permission::perm_remove','can_execute':e,'path':'admin','note':g},{'operation':'permission::perm_set','can_execute':e,'path':'admin','note':g},{'operation':'permission::entity_set','can_execute':e,'path':'admin','note':g},{'operation':'permission::entity_del','can_execute':e,'path':'admin','note':g},{'operation':'permission::remark_set','can_execute':e,'path':'admin','note':g}];}function specialOperations(a,b,c){const d=addrOf(b['builder']??b['owner']??b['signer']),e=d===c;switch(a){case'Guard':return[{'operation':'guard::relies_add','can_execute':![],'path':'signer','note':'guard\x20dependency\x20management\x20—\x20runtime-validated\x20against\x20guard\x20state'},{'operation':'guard::relies_logic_and','can_execute':![],'path':'signer','note':'guard\x20dependency\x20logic\x20—\x20runtime-validated\x20against\x20guard\x20state'}];case'Payment':return[{'operation':'payment::unwrap','can_execute':e,'path':'signer','note':e?'recipient\x20may\x20unwrap\x20the\x20CoinWrapper':'only\x20the\x20payment\x20recipient\x20(signer)'}];case'Proof':return[{'operation':'proof::create_wowok_proof','can_execute':e,'path':'signer','note':e?'creator\x20may\x20issue\x20the\x20proof':'only\x20the\x20proof\x20creator'}];case'Allocation':return[{'operation':'allocation::alloc','can_execute':![],'path':'guard_submission','note':'requires\x20Guard\x20+\x20Passport\x20verification\x20at\x20runtime'},{'operation':'allocation::receive','can_execute':e,'path':'signer','note':e?'recipient\x20may\x20receive\x20the\x20CoinWrapper':'only\x20the\x20allocation\x20recipient'}];default:return[{'operation':a['toLowerCase']()+'_operation','can_execute':e,'path':'signer','note':e?'signer-owned\x20object':'no\x20on-chain\x20mutative\x20operation\x20for\x20this\x20account'}];}}export function operationCategoryOf(a){return CATEGORY[a]??'special';}export function operationComplexityOf(a){return COMPLEXITY[a]??{'level':'L1','reads':0x2,'note':'unknown\x20type\x20—\x20assume\x20target\x20+\x20Permission'};}export function isPermissionIndexType(a){return BUILTIN_PERMISSIONS_BY_TYPE[a]!==undefined;}export function enumerateObjectOperations(a,b,c,d,e){const f=operationCategoryOf(a);if(f==='permission_index')return applyContractInvariants(a,b,enumeratePermissionIndexOps(a,c,d),e);if(a==='Order')return orderOperations(b,c);if(a==='Permission')return permissionOperations(b,c);return specialOperations(a,b,c);}function applyContractInvariants(a,b,c,d){const e=b['bPublished']===!![];if(!e)return c;return c['map'](f=>{const g=fieldFromGovernedOperation(f['operation']);if(!g)return f;const h=fieldMutabilityOf(a,g);if(!h||h['frozen_when']===null)return f;if(h['unfreeze']===null)return{...f,'can_execute':![],'note':((f['note']??'')+'\x20—\x20frozen:\x20forbidden\x20after\x20'+h['frozen_when']+'\x20('+h['move_anchor']+')')['trim']()};if(d!=null){const i=toNumberOrNull(b['paused_time']),j=toNumberOrNull(b['setting_lock_duration']),k=i!==null&&j!==null&&i+j<=d;if(k)return{...f,'note':((f['note']??'')+'\x20—\x20lock\x20elapsed\x20(paused_time\x20+\x20setting_lock_duration\x20<=\x20clock)')['trim']()};return{...f,'can_execute':![],'note':((f['note']??'')+'\x20—\x20locked:\x20needs\x20pause\x20and\x20paused_time\x20+\x20setting_lock_duration\x20<=\x20clock\x20before\x20remove/clear')['trim']()};}return{...f,'note':((f['note']??'')+'\x20—\x20after\x20'+h['frozen_when']+'\x20remove/clear\x20needs\x20'+h['unfreeze']+'\x20(add\x20still\x20allowed)')['trim']()};});}function toNumberOrNull(a){if(a===null||a===undefined)return null;const b=Number(a);return Number['isFinite'](b)?b:null;}function fieldFromGovernedOperation(a){const b=a['toLowerCase']();if(b['includes']('arbitration'))return'arbitrations';if(b['includes']('reward'))return'rewards';if(b['includes']('repository'))return'repositories';if(b['includes']('buy_guard'))return'buy_guard';if(b['includes']('machine'))return'machine';if(b['includes']('sales'))return'sales';if(b['includes']('order_allocator'))return'order_allocators';return undefined;}
@@ -1 +1 @@
1
- export const SERVICE_PERMISSIONS=[{'index':0x12c,'name':'SERVICE_NEW','description':'Create\x20new\x20Service','governed_operation':'service::new','post_publish_mutability':'na'},{'index':0x12d,'name':'SERVICE_DESCRIPTION','description':'Modify\x20Service\x20description','governed_operation':'service::description_set','post_publish_mutability':'mutable'},{'index':0x12f,'name':'SERVICE_LOCATION','description':'Set\x20Service\x20location/URL','governed_operation':'service::location_set','post_publish_mutability':'mutable'},{'index':0x130,'name':'SERVICE_REPOSITORY','description':'Add/remove\x20Repository\x20references','governed_operation':'service::repository_add/remove/clear','post_publish_mutability':'mutable'},{'index':0x131,'name':'SERVICE_SALES','description':'Add/set/remove/clear\x20sales\x20items','governed_operation':'service::sales_add/set/remove/clear','post_publish_mutability':'mutable'},{'index':0x132,'name':'SERVICE_MACHINE','description':'Bind/unbind\x20Machine\x20workflow\x20template','governed_operation':'service::machine_set/machine_none','post_publish_mutability':'immutable'},{'index':0x133,'name':'SERVICE_BUY_GUARD','description':'Set/clear\x20buy\x20Guard\x20(post-publish\x20mutable)','governed_operation':'service::buy_guard_set/buy_guard_none','post_publish_mutability':'mutable'},{'index':0x134,'name':'SERVICE_ARBITRATION','description':'Add/remove\x20Arbitration\x20references','governed_operation':'service::arbitration_add/remove/clear','post_publish_mutability':'immutable'},{'index':0x135,'name':'SERVICE_CUSTOMER_INFO_REQUIRED','description':'Set\x20customer\x20required\x20info\x20fields','governed_operation':'service::customer_required_set','post_publish_mutability':'mutable'},{'index':0x136,'name':'SERVICE_PAUSE','description':'Pause/resume\x20Service\x20(block\x20new\x20orders)','governed_operation':'service::pause','post_publish_mutability':'mutable'},{'index':0x137,'name':'SERVICE_PUBLISH','description':'Publish\x20Service\x20(IRREVERSIBLE)','governed_operation':'service::publish','post_publish_mutability':'one_shot'},{'index':0x138,'name':'SERVICE_DISCOUNT','description':'Issue/discount_destroy\x20discount\x20coupons','governed_operation':'service::discount','post_publish_mutability':'mutable'},{'index':0x139,'name':'SERVICE_ORDER_ALLOCATOR','description':'Set\x20order\x20allocator\x20strategy','governed_operation':'service::order_allocators_set','post_publish_mutability':'immutable'},{'index':0x13a,'name':'SERVICE_COMPENSATION_FUND_WITHDRAW','description':'Withdraw\x20compensation\x20fund\x20(lock_duration)','governed_operation':'service::compensation_fund_withdraw','post_publish_mutability':'locked_by_duration'},{'index':0x13b,'name':'SERVICE_COMPENSATION_FUND_DEPOSIT','description':'Deposit\x20to\x20compensation\x20fund','governed_operation':'service::compensation_fund_add','post_publish_mutability':'mutable'},{'index':0x13c,'name':'SERVICE_COMPENSATION_FUND_RECEIVE','description':'Receive\x20compensation\x20fund\x20(lock_duration)','governed_operation':'service::compensation_fund_receive','post_publish_mutability':'locked_by_duration'},{'index':0x13d,'name':'SERVICE_COMPENSATION_LOCK_DURATION_ADD','description':'Extend\x20setting_lock_duration\x20(only-increase)','governed_operation':'service::setting_lock_duration_add','post_publish_mutability':'mutable'},{'index':0x13e,'name':'SERVICE_REWARD','description':'Add/remove\x20Reward\x20references\x20(locked)','governed_operation':'service::reward_add/remove/clear','post_publish_mutability':'locked_by_duration'},{'index':0x13f,'name':'SERVICE_OWNER_RECEIVE','description':'Receive\x20Payment/objects\x20to\x20owner','governed_operation':'service::owner_receive','post_publish_mutability':'mutable'},{'index':0x140,'name':'SERVICE_UM','description':'Bind/unbind\x20Contact\x20as\x20UM','governed_operation':'service::um_set/um_none','post_publish_mutability':'mutable'}];export const SERVICE_ORDER_FLOW_STAGES=[{'stage':0x1,'name':'pre_check','preconditions':['Service.bPublished\x20==\x20true\x20(else\x20E_SERVICE_NOT_PUBLISHED)','Service.bPaused\x20==\x20false\x20(else\x20E_SERVICE_PAUSED)','buy_guard\x20(if\x20set)\x20added\x20to\x20guards[]\x20list\x20for\x20verification'],'side_effects':[],'always_executed':!![]},{'stage':0x2,'name':'wip_verify','preconditions':['buy.items\x20non-empty','Each\x20item.name\x20matches\x20a\x20sale\x20in\x20Service.sales\x20(else\x20E_SALE_NOT_FOUND)','sale.suspension\x20==\x20false\x20(else\x20E_SALE_SUSPENDED)'],'side_effects':['If\x20buyer\x20passes\x20empty\x20wip_hash,\x20SDK\x20auto-fills\x20with\x20sale.wip_hash','verifiedWipUrls\x20Set\x20avoids\x20re-verifying\x20same\x20WIP\x20URL\x20across\x20items','verify_wip()\x20fetches\x20WIP\x20file\x20and\x20compares\x20hash\x20(else\x20E_WIP_HASH_NOT_MATCH)'],'always_executed':!![]},{'stage':0x3,'name':'quote','preconditions':['All\x20items\x20have\x20valid\x20sale\x20+\x20wip_hash\x20match','stock\x20>=\x20purchase\x20quantity\x20(else\x20E_STOCK_INSUFFICIENT)','discount\x20object\x20(if\x20used)\x20is\x20valid\x20and\x20unexpired'],'side_effects':['quote_imp()\x20computes\x20total\x20price\x20(with\x20discount\x20if\x20applicable)','⚠️\x20Stock\x20is\x20deducted\x20(split)\x20—\x20side\x20effect\x20is\x20NOT\x20auto-rolled-back\x20on\x20later\x20failure','service::quote\x20or\x20service::quote_with_discount\x20MoveCall'],'always_executed':!![]},{'stage':0x4,'name':'create_order','preconditions':['Quote\x20object\x20from\x20stage\x203','Registrar\x20+\x20Clock\x20objects\x20available'],'side_effects':['service::buy\x20or\x20service::buy_with_passport\x20MoveCall','Order\x20object\x20created\x20(builder=customer,\x20service=Service.id)','Order.id\x20recorded\x20for\x20stages\x205-7'],'always_executed':!![]},{'stage':0x5,'name':'create_allocation','preconditions':['Service.order_allocators\x20is\x20Some\x20(configured)','Order\x20from\x20stage\x204','CoinParam\x20for\x20total_pay\x20matches\x20Service<T>\x20type'],'side_effects':['service::order_allocation\x20MoveCall','Allocation\x20object\x20created\x20(first-match-wins\x20fund\x20distribution)','Order.allocation\x20=\x20Allocation\x20address'],'always_executed':!![]},{'stage':0x6,'name':'create_progress','preconditions':['Service.machine\x20is\x20Some\x20(machine\x20bound)','Order\x20from\x20stage\x204','Machine\x20from\x20Service.machine'],'side_effects':['service::order_progress\x20MoveCall','Progress\x20object\x20created\x20(Progress.machine\x20=\x20Service.machine,\x20Progress.task\x20=\x20Order.id)'],'always_executed':![]},{'stage':0x7,'name':'post_actions','preconditions':['Order/Allocation/Progress\x20objects\x20from\x20stages\x204-6'],'side_effects':['agent_set\x20(if\x20order_new.agents\x20provided)','order_required_info_update\x20(if\x20order_required_info\x20provided)','owner_change\x20(if\x20transfer\x20provided\x20—\x20sets\x20new\x20Order\x20owner)','namedNewOrder\x20/\x20namedNewAllocation\x20/\x20namedNewProgress\x20(local\x20naming)'],'always_executed':![]},{'stage':0x8,'name':'return_result','preconditions':['All\x20preceding\x20stages\x20succeeded'],'side_effects':['Returns\x20BuyResult\x20{\x20order,\x20allocation?,\x20progress?\x20}','Caller\x20proceeds\x20to\x20sign\x20+\x20submit\x20transaction'],'always_executed':!![]}];export const SERVICE_CROSS_OBJECT_BINDINGS=[{'object':'Machine','field':'machine','required':![],'locked_after_publish':!![],'notes':'Workflow\x20template;\x20post-publish\x20immutable\x20(F-S-20).\x20Progress.machine\x20inherits\x20this\x20value.'},{'object':'Guard','field':'buy_guard','required':![],'locked_after_publish':![],'notes':'Buyer\x20eligibility\x20guard;\x20post-publish\x20STILL\x20MUTABLE\x20(unusual\x20—\x20see\x20F-S-26)'},{'object':'Allocation','field':'order_allocators','required':!![],'locked_after_publish':!![],'notes':'Order\x20fund\x20distribution\x20strategy;\x20publish\x20prerequisite\x20(F-S-18).\x20Post-publish\x20immutable\x20(F-S-22).'},{'object':'Arbitration','field':'arbitrations','required':![],'locked_after_publish':!![],'notes':'Dispute\x20handlers;\x20required\x20if\x20compensation_fund\x20>\x200\x20(F-S-19).\x20Post-publish\x20immutable\x20(F-S-21).'},{'object':'Repository','field':'repositories','required':![],'locked_after_publish':![],'notes':'Shared\x20data\x20stores;\x20mutable\x20post-publish'},{'object':'Reward','field':'rewards','required':![],'locked_after_publish':![],'notes':'Marketing\x20incentives;\x20mutable\x20but\x20locked\x20by\x20setting_lock_duration\x20(F-S-24)'},{'object':'Contact','field':'um','required':![],'locked_after_publish':![],'notes':'User\x20Manager\x20(Contact\x20object);\x20mutable\x20post-publish'},{'object':'Treasury','field':'(indirect\x20via\x20order_allocators.sharing.who=Entity)','required':![],'locked_after_publish':![],'notes':'Treasury\x20is\x20referenced\x20by\x20Allocation.sharing.who,\x20not\x20by\x20Service\x20directly'}];export const SERVICE_SCENES=[{'id':'service_retail','name':'Retail\x20e-commerce\x20Service','category':'retail','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set','location_set','customer_required_set'],'permission_index_operations':['service::publish\x20(311)','service::pause\x20(310)','service::sales_add/set/remove/clear\x20(305)','service::order_allocators_set\x20(313)','service::buy_guard_set\x20(307)','service::discount\x20(312)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set\x20(F-S-18,\x20E_NO_ALLOCATOR)','If\x20compensation_fund\x20>\x200,\x20arbitrations\x20must\x20be\x20non-empty\x20(F-S-19)'],'common_patterns':['Multi-tier\x20pricing\x20via\x20sales[]\x20(Standard/Premium/Enterprise)','WIP\x20hash\x20per\x20sale\x20item\x20for\x20tamper-proof\x20product\x20info','buy_guard\x20for\x20KYC\x20whitelist\x20during\x20pre-sale,\x20then\x20null\x20for\x20public\x20sale','compensation_fund\x20deposited\x20before\x20publish\x20+\x20arbitrations\x20configured'],'recommended_templates':['T-S-01','T-S-06']},{'id':'service_rental','name':'Rental\x20Service\x20(short/long-term)','category':'rental','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set','location_set'],'permission_index_operations':['service::publish\x20(311)','service::sales_add/set\x20(305)','service::machine_set\x20(306)\x20—\x20for\x20rental\x20workflow','service::arbitration_add\x20(308)\x20—\x20for\x20deposit\x20disputes'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set','machine\x20recommended\x20(rental\x20workflow\x20with\x20deposit/return\x20stages)','arbitrations\x20recommended\x20(deposit\x20refund\x20disputes)'],'common_patterns':['Machine\x20workflow\x20with\x20\x27Deposit\x20→\x20Use\x20→\x20Return\x20→\x20Refund\x27\x20nodes','compensation_fund\x20holds\x20deposit\x20guarantees','buy_guard\x20verifies\x20renter\x20identity/KYC','stock=1\x20per\x20rental\x20item\x20(unique\x20items)'],'recommended_templates':['T-S-02','T-S-04']},{'id':'service_subscription','name':'Subscription\x20Service\x20(recurring)','category':'subscription','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set','location_set'],'permission_index_operations':['service::publish\x20(311)','service::sales_add/set\x20(305)','service::discount\x20(312)\x20—\x20promotional\x20rates','service::reward_add\x20(318)\x20—\x20loyalty\x20rewards'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Tiered\x20plans\x20(Free/Pro/Enterprise)\x20as\x20sales[]','Discount\x20coupons\x20for\x20trial\x20periods','Rewards\x20for\x20long-term\x20subscribers','Renewal\x20handled\x20by\x20repeat\x20orders\x20(no\x20native\x20recurring\x20billing)'],'recommended_templates':['T-S-03']},{'id':'service_workflow','name':'Workflow-bound\x20Service\x20(machine-bound)','category':'workflow','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set','location_set'],'permission_index_operations':['service::machine_set\x20(306)\x20—\x20bind\x20workflow','service::publish\x20(311)','service::order_allocators_set\x20(313)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set','machine\x20must\x20be\x20published\x20before\x20binding','machine\x20recommended\x20for\x20any\x20multi-stage\x20service\x20delivery'],'common_patterns':['Machine\x20defines\x20Pay\x20→\x20Confirm\x20→\x20Deliver\x20→\x20Sign-off\x20nodes','Progress\x20created\x20per\x20order\x20(stage\x206\x20of\x20buy\x20flow)','Named\x20operators\x20assigned\x20per\x20Forward\x20in\x20Machine','Service.paused\x20does\x20NOT\x20affect\x20already-created\x20Progress\x20(existing\x20orders\x20continue)'],'recommended_templates':['T-S-04']},{'id':'service_arbitration','name':'Arbitration-bound\x20Service\x20(dispute-ready)','category':'arbitration','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::arbitration_add\x20(308)','service::compensation_fund_add\x20(315)','service::setting_lock_duration_add\x20(317)','service::publish\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['If\x20compensation_fund\x20>\x200,\x20arbitrations\x20must\x20be\x20non-empty\x20(F-S-19)','Arbitration\x20objects\x20must\x20be\x20created\x20before\x20binding','compensation_fund_add\x20before\x20publish\x20recommended\x20(else\x20post-publish\x20deposit\x20still\x20possible)'],'common_patterns':['2-3\x20Arbitration\x20objects\x20(different\x20arb\x20committees\x20for\x20different\x20dispute\x20types)','compensation_fund\x20deposited\x20as\x20%\x20of\x20expected\x20order\x20volume','setting_lock_duration\x20extended\x20by\x20owner\x20to\x20build\x20customer\x20trust','compensation_claim\x20triggered\x20by\x20arbitration\x20result\x20(not\x20by\x20Service\x20directly)'],'recommended_templates':['T-S-05','T-S-06']},{'id':'service_compensation_fund','name':'Compensation\x20Fund\x20Service\x20(embedded\x20balance)','category':'compensation_fund','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::compensation_fund_add\x20(315)\x20—\x20deposit','service::compensation_fund_withdraw\x20(314)\x20—\x20withdraw\x20(locked)','service::compensation_fund_receive\x20(316)\x20—\x20receive\x20(locked)','service::setting_lock_duration_add\x20(317)\x20—\x20extend\x20lock'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['compensation_fund\x20>\x200\x20→\x20arbitrations\x20non-empty\x20(F-S-19)','compensation_fund\x20coin\x20type\x20must\x20match\x20Service<T>\x20type\x20parameter'],'common_patterns':['Fund\x20inflow:\x20compensation_fund_add\x20(315)\x20—\x20always\x20mutable','Fund\x20outflow:\x20compensation_fund_withdraw\x20(314)\x20—\x20requires\x20bPaused\x20+\x20lock_duration\x20expired','Fund\x20receive:\x20compensation_fund_receive\x20(316)\x20—\x20locked\x20by\x20duration','Fund\x20consumer:\x20arbitration::compensation_claim\x20(driven\x20by\x20arb\x20result)','Distinct\x20from\x20Treasury:\x20Service-internal,\x20arbitration-bound,\x20lock-protected'],'recommended_templates':['T-S-06']},{'id':'service_reward','name':'Reward-attached\x20Service\x20(marketing)','category':'reward','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::reward_add/remove/clear\x20(318)\x20—\x20locked\x20by\x20duration','service::discount\x20(312)','service::publish\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Rewards\x20added\x20post-publish\x20(still\x20allowed,\x20but\x20locked\x20by\x20duration)','Reward\x20objects\x20must\x20exist\x20before\x20binding\x20(queryObjectsWithType\x20validation)','MAX_REWARD_COUNT\x20=\x2020\x20per\x20Service','Reward\x20removal\x20also\x20locked\x20by\x20duration\x20(protects\x20customer\x20expectations)'],'recommended_templates':['T-S-08']},{'id':'service_arbitration_binding','name':'Arbitration\x20Binding\x20Service\x20(post-publish\x20immutable)','category':'arbitration','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::arbitration_add\x20(308)\x20—\x20pre-publish\x20only','service::arbitration_remove\x20(308)\x20—\x20pre-publish\x20only','service::arbitration_clear\x20(308)\x20—\x20pre-publish\x20only','service::publish\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['MAX_ARBITRATION_COUNT\x20=\x2020\x20per\x20Service\x20(F-S-04)','Each\x20Arbitration\x20object\x20must\x20be\x20valid\x20(queryObjectsWithType\x20validation)','Arbitration\x20bound\x20=\x20locked\x20post-publish\x20(F-S-21).\x20To\x20change:\x20create\x20new\x20Service.'],'common_patterns':['Pre-publish:\x20set\x201-3\x20Arbitration\x20objects\x20for\x20different\x20dispute\x20scopes','Post-publish:\x20immutable\x20—\x20clone\x20Service\x20if\x20change\x20needed','⚠️\x20Data\x20inconsistency:\x20dynamic-pricing.ts\x20marks\x20arbitrations\x20as\x20mutable,\x20but\x20SDK\x20blocks\x20it\x20(F-S-21)'],'recommended_templates':['T-S-05']},{'id':'service_buy_guard','name':'Buy\x20Guard\x20Service\x20(post-publish\x20mutable\x20guard)','category':'buy_guard','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::buy_guard_set\x20(307)\x20—\x20bind\x20guard','service::buy_guard_none\x20(307)\x20—\x20clear\x20guard','service::publish\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Pre-sale\x20phase:\x20buy_guard\x20=\x20whitelist\x20Guard\x20(KYC\x20verified\x20buyers\x20only)','Public\x20sale:\x20buy_guard\x20=\x20null\x20(anyone\x20can\x20buy)','Restricted\x20phase:\x20buy_guard\x20=\x20KYC\x20Guard\x20(compliance)','⚠️\x20buy_guard\x20is\x20the\x20ONLY\x20publish-locked-field\x20exception\x20—\x20still\x20mutable\x20post-publish','buy_guard\x20verification\x20happens\x20at\x20Stage\x201\x20of\x20buy\x20flow\x20(pre_check)'],'recommended_templates':['T-S-01']},{'id':'service_order_allocator','name':'Order\x20Allocator\x20Service\x20(fund\x20distribution\x20config)','category':'order_allocator','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::order_allocators_set\x20(313)\x20—\x20pre-publish\x20only','service::publish\x20(311)\x20—\x20requires\x20order_allocators\x20(F-S-18)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20MUST\x20be\x20set\x20(F-S-18,\x20E_NO_ALLOCATOR)','Allocators.sharing.who\x20can\x20reference\x20Treasury\x20addresses\x20(indirect\x20Treasury\x20binding)','MAX_SHARING_COUNT\x20=\x20100\x20per\x20allocator'],'common_patterns':['Multi-party\x20split:\x20merchant\x2080%\x20/\x20platform\x2010%\x20/\x20logistics\x2010%','Threshold-based:\x20different\x20allocators\x20for\x20different\x20order\x20sizes','Guard-bound\x20allocator:\x20allocation\x20execution\x20requires\x20Guard\x20verification','Post-publish\x20immutable\x20—\x20clone\x20Service\x20to\x20change\x20allocation\x20strategy'],'recommended_templates':['T-S-08']},{'id':'service_dynamic_pricing','name':'Dynamic\x20Pricing\x20Service\x20(discount-driven)','category':'dynamic_pricing','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::discount\x20(312)\x20—\x20issue\x20coupons','service::sales_add/set\x20(305)\x20—\x20adjust\x20base\x20prices','service::sales_remove\x20(305)\x20—\x20remove\x20deprecated\x20SKUs'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Discount\x20types:\x200=rates\x20(basis\x20points,\x20per\x2010000),\x201=minus\x20(direct\x20deduction)','MAX_DISCOUNT_COUNT_ONCE\x20=\x201000\x20per\x20issue\x20call','MAX_DISCOUNT_RECEIVER_ONCE\x20=\x201000\x20receivers\x20per\x20call','MAX_DISCOUNT_TOTAL_COUNT\x20=\x2020000\x20total\x20coupons','discount_destroy:\x20holder-only\x20(no\x20SERVICE_DISCOUNT\x20permission\x20needed)'],'recommended_templates':['T-S-07']},{'id':'service_multi_allocator','name':'Multi-Allocator\x20Service\x20(tiered\x20fund\x20distribution)','category':'multi_allocator','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::order_allocators_set\x20(313)\x20—\x20pre-publish\x20only','service::publish\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20MUST\x20be\x20set','Each\x20allocator\x20has\x20its\x20own\x20Guard\x20+\x20sharing\x20+\x20threshold','First-match-wins:\x20first\x20allocator\x20whose\x20threshold\x20is\x20met\x20handles\x20the\x20order'],'common_patterns':['Tier\x201\x20(small\x20orders):\x20single-recipient\x20allocator\x20(low\x20fee)','Tier\x202\x20(medium\x20orders):\x20two-recipient\x20split\x20(merchant\x20+\x20platform)','Tier\x203\x20(large\x20orders):\x20three-recipient\x20split\x20(merchant\x20+\x20platform\x20+\x20logistics)','Each\x20tier\x20can\x20have\x20its\x20own\x20Guard\x20for\x20execution\x20authorization'],'recommended_templates':['T-S-08']}];export const SERVICE_LEDGER_VERSION='1.0.0';export function getScenesByCategory(a){return SERVICE_SCENES['filter'](b=>b['category']===a);}export function findSceneById(a){return SERVICE_SCENES['find'](b=>b['id']===a);}export function getServicePermissionByIndex(a){return SERVICE_PERMISSIONS['find'](b=>b['index']===a);}export function isServicePermission(a){return getServicePermissionByIndex(a)!==undefined;}export function getPermissionsByMutability(a){return SERVICE_PERMISSIONS['filter'](b=>b['post_publish_mutability']===a);}export function getImmutablePostPublishPermissions(){return SERVICE_PERMISSIONS['filter'](a=>a['post_publish_mutability']==='immutable'||a['post_publish_mutability']==='one_shot');}export function getLockedByDurationPermissions(){return SERVICE_PERMISSIONS['filter'](a=>a['post_publish_mutability']==='locked_by_duration');}export function inferSceneFromIntent(a){const b=a['toLowerCase'](),c=[['retail','retail'],['ecommerce','retail'],['rental','rental'],['rent','rental'],['short-term\x20rental','rental'],['long-term\x20rental','rental'],['subscription','subscription'],['subscribe','subscription'],['workflow','workflow'],['machine-bound','workflow'],['arbitration','arbitration'],['dispute','arbitration'],['compensation','compensation_fund'],['compensation_fund','compensation_fund'],['reward','reward'],['marketing','reward'],['buy_guard','buy_guard'],['kyc','buy_guard'],['whitelist','buy_guard'],['allocator','order_allocator'],['discount','dynamic_pricing'],['coupon','dynamic_pricing'],['multi-allocator','multi_allocator'],['tiered','multi_allocator']];for(const [d,e]of c){if(b['includes'](d)){const f=getScenesByCategory(e);if(f['length']>0x0)return f[0x0];}}if(b['includes']('service'))return findSceneById('service_retail');return undefined;}export function getAllServiceScenes(){return[...SERVICE_SCENES];}export function getServiceScenesCount(){return SERVICE_SCENES['length'];}export function getServicePermissionsCount(){return SERVICE_PERMISSIONS['length'];}export function getOrderFlowStage(a){return SERVICE_ORDER_FLOW_STAGES['find'](b=>b['stage']===a);}export function getCrossObjectBindings(){return[...SERVICE_CROSS_OBJECT_BINDINGS];}
1
+ export const SERVICE_PERMISSIONS=[{'index':0x12c,'name':'SERVICE_NEW','description':'Create\x20new\x20Service','governed_operation':'service::new','post_publish_mutability':'na'},{'index':0x12d,'name':'SERVICE_DESCRIPTION','description':'Modify\x20Service\x20description','governed_operation':'service::description_set','post_publish_mutability':'mutable'},{'index':0x12f,'name':'SERVICE_LOCATION','description':'Set\x20Service\x20location/URL','governed_operation':'service::location_set','post_publish_mutability':'mutable'},{'index':0x130,'name':'SERVICE_REPOSITORY','description':'Add/remove\x20Repository\x20references','governed_operation':'service::repository_add/remove/clear','post_publish_mutability':'mutable'},{'index':0x131,'name':'SERVICE_SALES','description':'Add/set/remove/clear\x20sales\x20items','governed_operation':'service::sales_add/set/remove/clear','post_publish_mutability':'mutable'},{'index':0x132,'name':'SERVICE_MACHINE','description':'Bind/unbind\x20Machine\x20workflow\x20template','governed_operation':'service::machine_set/machine_none','post_publish_mutability':'immutable'},{'index':0x133,'name':'SERVICE_BUY_GUARD','description':'Set/clear\x20buy\x20Guard\x20(post-publish\x20mutable)','governed_operation':'service::buy_guard_set/buy_guard_none','post_publish_mutability':'mutable'},{'index':0x134,'name':'SERVICE_ARBITRATION','description':'Add/remove\x20Arbitration\x20references','governed_operation':'service::arbitration_add/remove/clear','post_publish_mutability':'immutable'},{'index':0x135,'name':'SERVICE_CUSTOMER_INFO_REQUIRED','description':'Set\x20customer\x20required\x20info\x20fields','governed_operation':'service::customer_required_set','post_publish_mutability':'mutable'},{'index':0x136,'name':'SERVICE_PAUSE','description':'Pause/resume\x20Service\x20(block\x20new\x20orders)','governed_operation':'service::pause','post_publish_mutability':'mutable'},{'index':0x137,'name':'SERVICE_PUBLISH','description':'Publish\x20Service\x20(IRREVERSIBLE)','governed_operation':'service::publish','post_publish_mutability':'one_shot'},{'index':0x138,'name':'SERVICE_DISCOUNT','description':'Issue/discount_destroy\x20discount\x20coupons','governed_operation':'service::discount','post_publish_mutability':'mutable'},{'index':0x139,'name':'SERVICE_ORDER_ALLOCATOR','description':'Set\x20order\x20allocator\x20strategy','governed_operation':'service::order_allocators_set','post_publish_mutability':'immutable'},{'index':0x13a,'name':'SERVICE_COMPENSATION_FUND_WITHDRAW','description':'Withdraw\x20compensation\x20fund\x20(time-locked)','governed_operation':'service::compensation_fund_withdraw','post_publish_mutability':'locked_by_duration'},{'index':0x13b,'name':'SERVICE_COMPENSATION_FUND_DEPOSIT','description':'Deposit\x20to\x20compensation\x20fund','governed_operation':'service::compensation_fund_add','post_publish_mutability':'mutable'},{'index':0x13c,'name':'SERVICE_COMPENSATION_FUND_RECEIVE','description':'Receive\x20compensation\x20fund\x20(arbitration\x20payout)','governed_operation':'service::compensation_fund_receive','post_publish_mutability':'mutable'},{'index':0x13d,'name':'SERVICE_COMPENSATION_LOCK_DURATION_ADD','description':'Extend\x20setting_lock_duration\x20(only-increase)','governed_operation':'service::setting_lock_duration_add','post_publish_mutability':'mutable'},{'index':0x13e,'name':'SERVICE_REWARD','description':'Add/remove\x20Reward\x20references\x20(remove/clear\x20time-locked)','governed_operation':'service::reward_add/remove/clear','post_publish_mutability':'locked_by_duration'},{'index':0x13f,'name':'SERVICE_OWNER_RECEIVE','description':'Receive\x20Payment/objects\x20to\x20owner','governed_operation':'service::owner_receive','post_publish_mutability':'mutable'},{'index':0x140,'name':'SERVICE_UM','description':'Bind/unbind\x20Contact\x20as\x20UM','governed_operation':'service::um_set/um_none','post_publish_mutability':'mutable'}];export const SERVICE_ORDER_FLOW_STAGES=[{'stage':0x1,'name':'pre_check','preconditions':['Service.bPublished\x20==\x20true\x20(else\x20E_SERVICE_NOT_PUBLISHED)','Service.bPaused\x20==\x20false\x20(else\x20E_SERVICE_PAUSED)','buy_guard\x20(if\x20set)\x20added\x20to\x20guards[]\x20list\x20for\x20verification'],'side_effects':[],'always_executed':!![]},{'stage':0x2,'name':'wip_verify','preconditions':['buy.items\x20non-empty','Each\x20item.name\x20matches\x20a\x20sale\x20in\x20Service.sales\x20(else\x20E_SALE_NOT_FOUND)','sale.suspension\x20==\x20false\x20(else\x20E_SALE_SUSPENDED)'],'side_effects':['If\x20buyer\x20passes\x20empty\x20wip_hash,\x20SDK\x20auto-fills\x20with\x20sale.wip_hash','verifiedWipUrls\x20Set\x20avoids\x20re-verifying\x20same\x20WIP\x20URL\x20across\x20items','verify_wip()\x20fetches\x20WIP\x20file\x20and\x20compares\x20hash\x20(else\x20E_WIP_HASH_NOT_MATCH)'],'always_executed':!![]},{'stage':0x3,'name':'quote','preconditions':['All\x20items\x20have\x20valid\x20sale\x20+\x20wip_hash\x20match','stock\x20>=\x20purchase\x20quantity\x20(else\x20E_STOCK_INSUFFICIENT)','discount\x20object\x20(if\x20used)\x20is\x20valid\x20and\x20unexpired'],'side_effects':['quote_imp()\x20computes\x20total\x20price\x20(with\x20discount\x20if\x20applicable)','⚠️\x20Stock\x20is\x20deducted\x20(split)\x20—\x20side\x20effect\x20is\x20NOT\x20auto-rolled-back\x20on\x20later\x20failure','service::quote\x20or\x20service::quote_with_discount\x20MoveCall'],'always_executed':!![]},{'stage':0x4,'name':'create_order','preconditions':['Quote\x20object\x20from\x20stage\x203','Registrar\x20+\x20Clock\x20objects\x20available'],'side_effects':['service::buy\x20or\x20service::buy_with_passport\x20MoveCall','Order\x20object\x20created\x20(builder=customer,\x20service=Service.id)','Order.id\x20recorded\x20for\x20stages\x205-7'],'always_executed':!![]},{'stage':0x5,'name':'create_allocation','preconditions':['Service.order_allocators\x20is\x20Some\x20(configured)','Order\x20from\x20stage\x204','CoinParam\x20for\x20total_pay\x20matches\x20Service<T>\x20type'],'side_effects':['service::order_allocation\x20MoveCall','Allocation\x20object\x20created\x20(first-match-wins\x20fund\x20distribution)','Order.allocation\x20=\x20Allocation\x20address'],'always_executed':!![]},{'stage':0x6,'name':'create_progress','preconditions':['Service.machine\x20is\x20Some\x20(machine\x20bound)','Order\x20from\x20stage\x204','Machine\x20from\x20Service.machine'],'side_effects':['service::order_progress\x20MoveCall','Progress\x20object\x20created\x20(Progress.machine\x20=\x20Service.machine,\x20Progress.task\x20=\x20Order.id)'],'always_executed':![]},{'stage':0x7,'name':'post_actions','preconditions':['Order/Allocation/Progress\x20objects\x20from\x20stages\x204-6'],'side_effects':['agent_set\x20(if\x20order_new.agents\x20provided)','order_required_info_update\x20(if\x20order_required_info\x20provided)','owner_change\x20(if\x20transfer\x20provided\x20—\x20sets\x20new\x20Order\x20owner)','namedNewOrder\x20/\x20namedNewAllocation\x20/\x20namedNewProgress\x20(local\x20naming)'],'always_executed':![]},{'stage':0x8,'name':'return_result','preconditions':['All\x20preceding\x20stages\x20succeeded'],'side_effects':['Returns\x20BuyResult\x20{\x20order,\x20allocation?,\x20progress?\x20}','Caller\x20proceeds\x20to\x20sign\x20+\x20submit\x20transaction'],'always_executed':!![]}];export const SERVICE_CROSS_OBJECT_BINDINGS=[{'object':'Machine','field':'machine','required':![],'locked_after_publish':!![],'notes':'Workflow\x20template;\x20post-publish\x20immutable\x20(F-S-20).\x20Progress.machine\x20inherits\x20this\x20value.'},{'object':'Guard','field':'buy_guard','required':![],'locked_after_publish':![],'notes':'Buyer\x20eligibility\x20guard;\x20post-publish\x20STILL\x20MUTABLE\x20(unusual\x20—\x20see\x20F-S-26)'},{'object':'Allocation','field':'order_allocators','required':!![],'locked_after_publish':!![],'notes':'Order\x20fund\x20distribution\x20strategy;\x20publish\x20prerequisite\x20(F-S-18).\x20Post-publish\x20immutable\x20(F-S-22).'},{'object':'Arbitration','field':'arbitrations','required':![],'locked_after_publish':![],'notes':'Dispute\x20handlers;\x20required\x20if\x20compensation_fund\x20>\x200\x20(F-S-19).\x20add\x20always\x20mutable;\x20remove/clear\x20time-locked\x20after\x20publish\x20(F-S-21).'},{'object':'Repository','field':'repositories','required':![],'locked_after_publish':![],'notes':'Shared\x20data\x20stores;\x20mutable\x20post-publish'},{'object':'Reward','field':'rewards','required':![],'locked_after_publish':![],'notes':'Marketing\x20incentives;\x20add\x20always\x20mutable;\x20remove/clear\x20time-locked\x20after\x20publish\x20(F-S-24)'},{'object':'Contact','field':'um','required':![],'locked_after_publish':![],'notes':'User\x20Manager\x20(Contact\x20object);\x20mutable\x20post-publish'},{'object':'Treasury','field':'(indirect\x20via\x20order_allocators.sharing.who=Entity)','required':![],'locked_after_publish':![],'notes':'Treasury\x20is\x20referenced\x20by\x20Allocation.sharing.who,\x20not\x20by\x20Service\x20directly'}];export const SERVICE_SCENES=[{'id':'service_retail','name':'Retail\x20e-commerce\x20Service','category':'retail','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set','location_set','customer_required_set'],'permission_index_operations':['service::publish\x20(311)','service::pause\x20(310)','service::sales_add/set/remove/clear\x20(305)','service::order_allocators_set\x20(313)','service::buy_guard_set\x20(307)','service::discount\x20(312)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set\x20(F-S-18,\x20E_NO_ALLOCATOR)','If\x20compensation_fund\x20>\x200,\x20arbitrations\x20must\x20be\x20non-empty\x20(F-S-19)'],'common_patterns':['Multi-tier\x20pricing\x20via\x20sales[]\x20(Standard/Premium/Enterprise)','WIP\x20hash\x20per\x20sale\x20item\x20for\x20tamper-proof\x20product\x20info','buy_guard\x20for\x20KYC\x20whitelist\x20during\x20pre-sale,\x20then\x20null\x20for\x20public\x20sale','compensation_fund\x20deposited\x20before\x20publish\x20+\x20arbitrations\x20configured'],'recommended_templates':['T-S-01','T-S-06']},{'id':'service_rental','name':'Rental\x20Service\x20(short/long-term)','category':'rental','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set','location_set'],'permission_index_operations':['service::publish\x20(311)','service::sales_add/set\x20(305)','service::machine_set\x20(306)\x20—\x20for\x20rental\x20workflow','service::arbitration_add\x20(308)\x20—\x20for\x20deposit\x20disputes'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set','machine\x20recommended\x20(rental\x20workflow\x20with\x20deposit/return\x20stages)','arbitrations\x20recommended\x20(deposit\x20refund\x20disputes)'],'common_patterns':['Machine\x20workflow\x20with\x20\x27Deposit\x20→\x20Use\x20→\x20Return\x20→\x20Refund\x27\x20nodes','compensation_fund\x20holds\x20deposit\x20guarantees','buy_guard\x20verifies\x20renter\x20identity/KYC','stock=1\x20per\x20rental\x20item\x20(unique\x20items)'],'recommended_templates':['T-S-02','T-S-04']},{'id':'service_subscription','name':'Subscription\x20Service\x20(recurring)','category':'subscription','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set','location_set'],'permission_index_operations':['service::publish\x20(311)','service::sales_add/set\x20(305)','service::discount\x20(312)\x20—\x20promotional\x20rates','service::reward_add\x20(318)\x20—\x20loyalty\x20rewards'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Tiered\x20plans\x20(Free/Pro/Enterprise)\x20as\x20sales[]','Discount\x20coupons\x20for\x20trial\x20periods','Rewards\x20for\x20long-term\x20subscribers','Renewal\x20handled\x20by\x20repeat\x20orders\x20(no\x20native\x20recurring\x20billing)'],'recommended_templates':['T-S-03']},{'id':'service_workflow','name':'Workflow-bound\x20Service\x20(machine-bound)','category':'workflow','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set','location_set'],'permission_index_operations':['service::machine_set\x20(306)\x20—\x20bind\x20workflow','service::publish\x20(311)','service::order_allocators_set\x20(313)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set','machine\x20must\x20be\x20published\x20before\x20binding','machine\x20recommended\x20for\x20any\x20multi-stage\x20service\x20delivery'],'common_patterns':['Machine\x20defines\x20Pay\x20→\x20Confirm\x20→\x20Deliver\x20→\x20Sign-off\x20nodes','Progress\x20created\x20per\x20order\x20(stage\x206\x20of\x20buy\x20flow)','Named\x20operators\x20assigned\x20per\x20Forward\x20in\x20Machine','Service.paused\x20does\x20NOT\x20affect\x20already-created\x20Progress\x20(existing\x20orders\x20continue)'],'recommended_templates':['T-S-04']},{'id':'service_arbitration','name':'Arbitration-bound\x20Service\x20(dispute-ready)','category':'arbitration','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::arbitration_add\x20(308)','service::compensation_fund_add\x20(315)','service::setting_lock_duration_add\x20(317)','service::publish\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['If\x20compensation_fund\x20>\x200,\x20arbitrations\x20must\x20be\x20non-empty\x20(F-S-19)','Arbitration\x20objects\x20must\x20be\x20created\x20before\x20binding','compensation_fund_add\x20before\x20publish\x20recommended\x20(else\x20post-publish\x20deposit\x20still\x20possible)'],'common_patterns':['2-3\x20Arbitration\x20objects\x20(different\x20arb\x20committees\x20for\x20different\x20dispute\x20types)','compensation_fund\x20deposited\x20as\x20%\x20of\x20expected\x20order\x20volume','setting_lock_duration\x20extended\x20by\x20owner\x20to\x20build\x20customer\x20trust','compensation_claim\x20triggered\x20by\x20arbitration\x20result\x20(not\x20by\x20Service\x20directly)'],'recommended_templates':['T-S-05','T-S-06']},{'id':'service_compensation_fund','name':'Compensation\x20Fund\x20Service\x20(embedded\x20balance)','category':'compensation_fund','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::compensation_fund_add\x20(315)\x20—\x20deposit','service::compensation_fund_withdraw\x20(314)\x20—\x20withdraw\x20(time-locked\x20after\x20publish)','service::compensation_fund_receive\x20(316)\x20—\x20receive\x20arbitration\x20payout\x20(always\x20mutable)','service::setting_lock_duration_add\x20(317)\x20—\x20extend\x20lock'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['compensation_fund\x20>\x200\x20→\x20arbitrations\x20non-empty\x20(F-S-19)','compensation_fund\x20coin\x20type\x20must\x20match\x20Service<T>\x20type\x20parameter'],'common_patterns':['Fund\x20inflow:\x20compensation_fund_add\x20(315)\x20—\x20always\x20mutable','Fund\x20outflow:\x20compensation_fund_withdraw\x20(314)\x20—\x20requires\x20bPaused\x20+\x20lock_duration\x20expired','Fund\x20receive:\x20compensation_fund_receive\x20(316)\x20—\x20arbitration\x20payout,\x20always\x20mutable','Fund\x20consumer:\x20arbitration::compensation_claim\x20(driven\x20by\x20arb\x20result)','Distinct\x20from\x20Treasury:\x20Service-internal,\x20arbitration-bound,\x20lock-protected'],'recommended_templates':['T-S-06']},{'id':'service_reward','name':'Reward-attached\x20Service\x20(marketing)','category':'reward','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::reward_add/remove/clear\x20(318)\x20—\x20add\x20always\x20mutable;\x20remove/clear\x20time-locked\x20after\x20publish','service::discount\x20(312)','service::publish\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Rewards\x20added\x20post-publish\x20(always\x20allowed;\x20remove/clear\x20is\x20time-locked\x20after\x20publish)','Reward\x20objects\x20must\x20exist\x20before\x20binding\x20(queryObjectsWithType\x20validation)','MAX_REWARD_COUNT\x20=\x2020\x20per\x20Service','Reward\x20remove/clear\x20requires\x20Service\x20paused\x20+\x20setting_lock_duration\x20elapsed\x20(protects\x20customer\x20expectations)'],'recommended_templates':['T-S-08']},{'id':'service_arbitration_binding','name':'Arbitration\x20Binding\x20Service\x20(post-publish\x20immutable)','category':'arbitration','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::arbitration_add\x20(308)\x20—\x20pre-publish\x20only','service::arbitration_remove\x20(308)\x20—\x20pre-publish\x20only','service::arbitration_clear\x20(308)\x20—\x20pre-publish\x20only','service::publish\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['MAX_ARBITRATION_COUNT\x20=\x2020\x20per\x20Service\x20(F-S-04)','Each\x20Arbitration\x20object\x20must\x20be\x20valid\x20(queryObjectsWithType\x20validation)','Arbitration\x20bound\x20=\x20locked\x20post-publish\x20(F-S-21).\x20To\x20change:\x20create\x20new\x20Service.'],'common_patterns':['Pre-publish:\x20set\x201-3\x20Arbitration\x20objects\x20for\x20different\x20dispute\x20scopes','Post-publish:\x20immutable\x20—\x20clone\x20Service\x20if\x20change\x20needed','⚠️\x20Data\x20inconsistency:\x20dynamic-pricing.ts\x20marks\x20arbitrations\x20as\x20mutable,\x20but\x20SDK\x20blocks\x20it\x20(F-S-21)'],'recommended_templates':['T-S-05']},{'id':'service_buy_guard','name':'Buy\x20Guard\x20Service\x20(post-publish\x20mutable\x20guard)','category':'buy_guard','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::buy_guard_set\x20(307)\x20—\x20bind\x20guard','service::buy_guard_none\x20(307)\x20—\x20clear\x20guard','service::publish\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Pre-sale\x20phase:\x20buy_guard\x20=\x20whitelist\x20Guard\x20(KYC\x20verified\x20buyers\x20only)','Public\x20sale:\x20buy_guard\x20=\x20null\x20(anyone\x20can\x20buy)','Restricted\x20phase:\x20buy_guard\x20=\x20KYC\x20Guard\x20(compliance)','⚠️\x20buy_guard\x20is\x20the\x20ONLY\x20publish-locked-field\x20exception\x20—\x20still\x20mutable\x20post-publish','buy_guard\x20verification\x20happens\x20at\x20Stage\x201\x20of\x20buy\x20flow\x20(pre_check)'],'recommended_templates':['T-S-01']},{'id':'service_order_allocator','name':'Order\x20Allocator\x20Service\x20(fund\x20distribution\x20config)','category':'order_allocator','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::order_allocators_set\x20(313)\x20—\x20pre-publish\x20only','service::publish\x20(311)\x20—\x20requires\x20order_allocators\x20(F-S-18)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20MUST\x20be\x20set\x20(F-S-18,\x20E_NO_ALLOCATOR)','Allocators.sharing.who\x20can\x20reference\x20Treasury\x20addresses\x20(indirect\x20Treasury\x20binding)','MAX_SHARING_COUNT\x20=\x20100\x20per\x20allocator'],'common_patterns':['Multi-party\x20split:\x20merchant\x2080%\x20/\x20platform\x2010%\x20/\x20logistics\x2010%','Threshold-based:\x20different\x20allocators\x20for\x20different\x20order\x20sizes','Guard-bound\x20allocator:\x20allocation\x20execution\x20requires\x20Guard\x20verification','Post-publish\x20immutable\x20—\x20clone\x20Service\x20to\x20change\x20allocation\x20strategy'],'recommended_templates':['T-S-08']},{'id':'service_dynamic_pricing','name':'Dynamic\x20Pricing\x20Service\x20(discount-driven)','category':'dynamic_pricing','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::discount\x20(312)\x20—\x20issue\x20coupons','service::sales_add/set\x20(305)\x20—\x20adjust\x20base\x20prices','service::sales_remove\x20(305)\x20—\x20remove\x20deprecated\x20SKUs'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Discount\x20types:\x200=rates\x20(basis\x20points,\x20per\x2010000),\x201=minus\x20(direct\x20deduction)','MAX_DISCOUNT_COUNT_ONCE\x20=\x201000\x20per\x20issue\x20call','MAX_DISCOUNT_RECEIVER_ONCE\x20=\x201000\x20receivers\x20per\x20call','MAX_DISCOUNT_TOTAL_COUNT\x20=\x2020000\x20total\x20coupons','discount_destroy:\x20holder-only\x20(no\x20SERVICE_DISCOUNT\x20permission\x20needed)'],'recommended_templates':['T-S-07']},{'id':'service_multi_allocator','name':'Multi-Allocator\x20Service\x20(tiered\x20fund\x20distribution)','category':'multi_allocator','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::order_allocators_set\x20(313)\x20—\x20pre-publish\x20only','service::publish\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20MUST\x20be\x20set','Each\x20allocator\x20has\x20its\x20own\x20Guard\x20+\x20sharing\x20+\x20threshold','First-match-wins:\x20first\x20allocator\x20whose\x20threshold\x20is\x20met\x20handles\x20the\x20order'],'common_patterns':['Tier\x201\x20(small\x20orders):\x20single-recipient\x20allocator\x20(low\x20fee)','Tier\x202\x20(medium\x20orders):\x20two-recipient\x20split\x20(merchant\x20+\x20platform)','Tier\x203\x20(large\x20orders):\x20three-recipient\x20split\x20(merchant\x20+\x20platform\x20+\x20logistics)','Each\x20tier\x20can\x20have\x20its\x20own\x20Guard\x20for\x20execution\x20authorization'],'recommended_templates':['T-S-08']}];export const SERVICE_LEDGER_VERSION='1.0.0';export function getScenesByCategory(a){return SERVICE_SCENES['filter'](b=>b['category']===a);}export function findSceneById(a){return SERVICE_SCENES['find'](b=>b['id']===a);}export function getServicePermissionByIndex(a){return SERVICE_PERMISSIONS['find'](b=>b['index']===a);}export function isServicePermission(a){return getServicePermissionByIndex(a)!==undefined;}export function getPermissionsByMutability(a){return SERVICE_PERMISSIONS['filter'](b=>b['post_publish_mutability']===a);}export function getImmutablePostPublishPermissions(){return SERVICE_PERMISSIONS['filter'](a=>a['post_publish_mutability']==='immutable'||a['post_publish_mutability']==='one_shot');}export function getLockedByDurationPermissions(){return SERVICE_PERMISSIONS['filter'](a=>a['post_publish_mutability']==='locked_by_duration');}export function inferSceneFromIntent(a){const b=a['toLowerCase'](),c=[['retail','retail'],['ecommerce','retail'],['rental','rental'],['rent','rental'],['short-term\x20rental','rental'],['long-term\x20rental','rental'],['subscription','subscription'],['subscribe','subscription'],['workflow','workflow'],['machine-bound','workflow'],['arbitration','arbitration'],['dispute','arbitration'],['compensation','compensation_fund'],['compensation_fund','compensation_fund'],['reward','reward'],['marketing','reward'],['buy_guard','buy_guard'],['kyc','buy_guard'],['whitelist','buy_guard'],['allocator','order_allocator'],['discount','dynamic_pricing'],['coupon','dynamic_pricing'],['multi-allocator','multi_allocator'],['tiered','multi_allocator']];for(const [d,e]of c){if(b['includes'](d)){const f=getScenesByCategory(e);if(f['length']>0x0)return f[0x0];}}if(b['includes']('service'))return findSceneById('service_retail');return undefined;}export function getAllServiceScenes(){return[...SERVICE_SCENES];}export function getServiceScenesCount(){return SERVICE_SCENES['length'];}export function getServicePermissionsCount(){return SERVICE_PERMISSIONS['length'];}export function getOrderFlowStage(a){return SERVICE_ORDER_FLOW_STAGES['find'](b=>b['stage']===a);}export function getCrossObjectBindings(){return[...SERVICE_CROSS_OBJECT_BINDINGS];}