@wowok/agent-mcp 3.2.7 → 3.2.9

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 (185) hide show
  1. package/dist/chain-semantics/field-capability.js +1 -1
  2. package/dist/chain-semantics/fund-flow.js +1 -1
  3. package/dist/chain-semantics/guard-verbs.js +1 -1
  4. package/dist/chain-semantics/object-graph.js +1 -1
  5. package/dist/composition/audit.js +1 -1
  6. package/dist/composition/compile.js +1 -1
  7. package/dist/composition/inflight.d.ts +10 -0
  8. package/dist/composition/inflight.js +1 -1
  9. package/dist/extensions/business-modules.d.ts +1 -1
  10. package/dist/extensions/business-modules.js +1 -1
  11. package/dist/graph/onchain/edge-schema.js +1 -1
  12. package/dist/harness/index.d.ts +1 -0
  13. package/dist/harness/index.js +1 -1
  14. package/dist/harness/operation-id.d.ts +1 -0
  15. package/dist/harness/operation-id.js +1 -0
  16. package/dist/harness/recover.js +1 -1
  17. package/dist/index.js +1 -1
  18. package/dist/knowledge/arbitration-ledger.js +1 -1
  19. package/dist/knowledge/audit-rules.js +1 -1
  20. package/dist/knowledge/baselines/rules/guard.json +96 -1
  21. package/dist/knowledge/baselines/rules/plan.json +30 -7
  22. package/dist/knowledge/baselines/semantic-facts.js +1 -1
  23. package/dist/knowledge/builtin-templates.d.ts +1 -1
  24. package/dist/knowledge/builtin-templates.js +1 -1
  25. package/dist/knowledge/discount-threshold.d.ts +11 -0
  26. package/dist/knowledge/discount-threshold.js +1 -1
  27. package/dist/knowledge/fund-layer.js +1 -1
  28. package/dist/knowledge/getting-started.js +1 -1
  29. package/dist/knowledge/guard-design-patterns.d.ts +1 -1
  30. package/dist/knowledge/guard-design-patterns.js +1 -1
  31. package/dist/knowledge/guard-field-cognition.js +1 -1
  32. package/dist/knowledge/guard-ledger.js +1 -1
  33. package/dist/knowledge/guard-lint.js +1 -1
  34. package/dist/knowledge/guard-render.js +1 -1
  35. package/dist/knowledge/guard-risk.d.ts +1 -0
  36. package/dist/knowledge/guard-risk.js +1 -1
  37. package/dist/knowledge/guard-submission-brief.d.ts +6 -0
  38. package/dist/knowledge/guard-submission-brief.js +1 -1
  39. package/dist/knowledge/guard-templates.d.ts +2 -2
  40. package/dist/knowledge/guard-templates.js +1 -1
  41. package/dist/knowledge/index.js +1 -1
  42. package/dist/knowledge/industry-registry.js +1 -1
  43. package/dist/knowledge/jsonrpc-enum.js +1 -1
  44. package/dist/knowledge/order-ledger.js +1 -1
  45. package/dist/knowledge/reward-ledger.js +1 -1
  46. package/dist/knowledge/safety-rules.js +1 -1
  47. package/dist/knowledge/template-loader.js +1 -1
  48. package/dist/knowledge/template-registry.js +1 -1
  49. package/dist/knowledge/template-scanner.d.ts +2 -0
  50. package/dist/knowledge/template-scanner.js +1 -1
  51. package/dist/knowledge/tool-constraints.js +1 -1
  52. package/dist/knowledge/workflow-guidance.d.ts +7 -3
  53. package/dist/knowledge/workflow-guidance.js +1 -1
  54. package/dist/monitor/MonitorLoop.js +1 -1
  55. package/dist/participation/radar-core.d.ts +1 -1
  56. package/dist/playbooks/service-build/business-puzzle.js +1 -1
  57. package/dist/playbooks/service-build/machine-panorama.js +1 -1
  58. package/dist/playbooks/service-build/merchant-guide.d.ts +8 -0
  59. package/dist/playbooks/service-build/merchant-guide.js +1 -1
  60. package/dist/playbooks/service-build/object-panorama.d.ts +28 -1
  61. package/dist/playbooks/service-build/object-panorama.js +1 -1
  62. package/dist/playbooks/service-build/participation-radar.d.ts +2 -0
  63. package/dist/playbooks/service-build/participation-radar.js +1 -1
  64. package/dist/playbooks/service-build/relationship-profile.js +1 -1
  65. package/dist/playbooks/service-build/reverse-mapping-nk4.spec.js +1 -1
  66. package/dist/playbooks/service-build/reverse-mapping.js +1 -1
  67. package/dist/playbooks/service-build/service-panorama.js +1 -1
  68. package/dist/playbooks/service-build/service-quote.js +1 -1
  69. package/dist/playbooks/service-build/service-quote.spec.js +1 -1
  70. package/dist/review/index.js +1 -1
  71. package/dist/safety/confirm-gate.js +1 -1
  72. package/dist/safety/preview.d.ts +1 -0
  73. package/dist/safety/preview.js +1 -1
  74. package/dist/schema/benchmark-migration/index.d.ts +14 -0
  75. package/dist/schema/benchmark-migration/index.js +1 -1
  76. package/dist/schema/call/allocation.d.ts +1 -1
  77. package/dist/schema/call/arbitration.d.ts +4 -4
  78. package/dist/schema/call/arbitration.js +1 -1
  79. package/dist/schema/call/base.d.ts +13 -5
  80. package/dist/schema/call/base.js +1 -1
  81. package/dist/schema/call/bridge.d.ts +2 -0
  82. package/dist/schema/call/contact.d.ts +1 -1
  83. package/dist/schema/call/demand.d.ts +1 -1
  84. package/dist/schema/call/error-codes.d.ts +1 -1
  85. package/dist/schema/call/error-codes.js +1 -1
  86. package/dist/schema/call/guard.d.ts +3 -3
  87. package/dist/schema/call/guard.js +1 -1
  88. package/dist/schema/call/handler.js +1 -1
  89. package/dist/schema/call/machine.d.ts +1 -1
  90. package/dist/schema/call/machine.js +1 -1
  91. package/dist/schema/call/order.d.ts +1 -1
  92. package/dist/schema/call/order.js +1 -1
  93. package/dist/schema/call/permission.d.ts +1 -1
  94. package/dist/schema/call/personal.d.ts +4 -4
  95. package/dist/schema/call/progress.d.ts +1 -1
  96. package/dist/schema/call/progress.js +1 -1
  97. package/dist/schema/call/proof.js +1 -1
  98. package/dist/schema/call/repository.d.ts +5 -5
  99. package/dist/schema/call/repository.js +1 -1
  100. package/dist/schema/call/reward.d.ts +1 -1
  101. package/dist/schema/call/reward.js +1 -1
  102. package/dist/schema/call/semantic.js +1 -1
  103. package/dist/schema/call/service.d.ts +4 -1
  104. package/dist/schema/call/service.js +1 -1
  105. package/dist/schema/call/treasury.d.ts +1 -1
  106. package/dist/schema/common/index.d.ts +4 -4
  107. package/dist/schema/common/index.js +1 -1
  108. package/dist/schema/goal/index.d.ts +12 -0
  109. package/dist/schema/goal/planning.d.ts +18 -0
  110. package/dist/schema/goal/planning.js +1 -1
  111. package/dist/schema/local/index.d.ts +21 -0
  112. package/dist/schema/local/index.js +1 -1
  113. package/dist/schema/messenger/index.js +1 -1
  114. package/dist/schema/operations.d.ts +22 -21
  115. package/dist/schema/query/bi.d.ts +6 -6
  116. package/dist/schema/query/bi.js +1 -1
  117. package/dist/schema/query/index.d.ts +112 -54
  118. package/dist/schema/query/index.js +1 -1
  119. package/dist/schema/schema-query/index.d.ts +1 -0
  120. package/dist/schema/schema-query/index.js +1 -1
  121. package/dist/schema/schema-version.js +1 -1
  122. package/dist/schema/utils/permission-machine-check.d.ts +2 -0
  123. package/dist/schema/utils/permission-machine-check.js +1 -1
  124. package/dist/schema/workflow/index.d.ts +1 -1
  125. package/dist/schema-query-impl/index.js +1 -1
  126. package/dist/schemas/account_operation.output.json +2 -0
  127. package/dist/schemas/account_operation.schema.json +3 -3
  128. package/dist/schemas/benchmark_migration_operation.output.json +42 -0
  129. package/dist/schemas/benchmark_migration_operation.schema.json +13 -0
  130. package/dist/schemas/bridge_operation.output.json +2 -0
  131. package/dist/schemas/goal_operation.schema.json +26 -0
  132. package/dist/schemas/index.json +1 -1
  133. package/dist/schemas/local_cache_operation.output.json +2 -0
  134. package/dist/schemas/local_history_operation.output.json +2 -0
  135. package/dist/schemas/local_info_operation.output.json +2 -0
  136. package/dist/schemas/local_mark_operation.output.json +2 -0
  137. package/dist/schemas/messenger_operation.schema.json +4 -4
  138. package/dist/schemas/onchain_operations.output.json +7 -5
  139. package/dist/schemas/onchain_operations.schema.json +108 -92
  140. package/dist/schemas/onchain_operations_allocation.schema.json +5 -5
  141. package/dist/schemas/onchain_operations_arbitration.schema.json +10 -8
  142. package/dist/schemas/onchain_operations_contact.schema.json +6 -5
  143. package/dist/schemas/onchain_operations_demand.schema.json +6 -5
  144. package/dist/schemas/onchain_operations_gen_passport.schema.json +5 -5
  145. package/dist/schemas/onchain_operations_gen_proof.schema.json +1 -1
  146. package/dist/schemas/onchain_operations_guard.schema.json +4 -4
  147. package/dist/schemas/onchain_operations_machine.schema.json +7 -6
  148. package/dist/schemas/onchain_operations_order.schema.json +8 -7
  149. package/dist/schemas/onchain_operations_permission.schema.json +1 -0
  150. package/dist/schemas/onchain_operations_personal.schema.json +2 -2
  151. package/dist/schemas/onchain_operations_progress.schema.json +8 -7
  152. package/dist/schemas/onchain_operations_proof.schema.json +6 -6
  153. package/dist/schemas/onchain_operations_repository.schema.json +10 -9
  154. package/dist/schemas/onchain_operations_reward.schema.json +8 -7
  155. package/dist/schemas/onchain_operations_service.schema.json +16 -11
  156. package/dist/schemas/onchain_operations_treasury.schema.json +6 -5
  157. package/dist/schemas/onchain_table_data.output.json +7 -7
  158. package/dist/schemas/query_toolkit.output.json +31 -30
  159. package/dist/schemas/query_toolkit.schema.json +1 -1
  160. package/dist/schemas/schema_query.schema.json +4 -0
  161. package/dist/schemas/workflow_operation.schema.json +5 -5
  162. package/dist/schemas/wowok_buildin_info.output.json +140 -3
  163. package/dist/schemas/wowok_buildin_info.schema.json +2 -2
  164. package/dist/tools/handlers/benchmark-migration.d.ts +22 -1
  165. package/dist/tools/handlers/benchmark-migration.js +1 -1
  166. package/dist/tools/handlers/config.js +1 -1
  167. package/dist/tools/handlers/dispatch-expectations.d.ts +0 -1
  168. package/dist/tools/handlers/dispatch-expectations.js +1 -1
  169. package/dist/tools/handlers/local.js +1 -1
  170. package/dist/tools/handlers/onchain.js +1 -1
  171. package/dist/tools/handlers/query.d.ts +1 -0
  172. package/dist/tools/handlers/query.js +1 -1
  173. package/dist/tools/handlers/review-chain.js +1 -1
  174. package/dist/tools/handlers/schema-query.js +1 -1
  175. package/dist/tools/index.js +1 -1
  176. package/dist/tools/move-fn-index.gen.js +1 -1
  177. package/dist/tools/registry/files.js +1 -1
  178. package/dist/tools/registry/query.js +1 -1
  179. package/dist/tools/rules-hook.js +1 -1
  180. package/dist/tools/upgrade-check.d.ts +23 -0
  181. package/dist/tools/upgrade-check.js +1 -1
  182. package/dist/tools/wip-deploy-assist.d.ts +6 -0
  183. package/dist/tools/wip-deploy-assist.js +1 -1
  184. package/dist/tools/wrap.js +1 -1
  185. package/package.json +2 -2
@@ -1 +1 @@
1
- function fld(a,b){return a?.[b]??a?.['data']?.[b];}function detectType(a){const b=fld(a,'type')??fld(a,'type_raw');if(typeof b!=='string'||b['length']===0x0)return'';const c=b['split']('::')['pop']()??b;return c;}function objectsOfType(a,b){return a['filter'](c=>detectType(c)===b);}function identity(a){const b=fld(a,'name');if(typeof b==='string'&&b['trim']())return b['trim']();const c=fld(a,'object')??fld(a,'id');if(typeof c==='string'&&c['trim']())return c['trim']();return'unknown';}function balanceStr(a){if(a==null)return undefined;if(typeof a==='object'&&'balance'in a)return String(a['balance']);return String(a);}function extractService(a){const b=objectsOfType(a,'Service')[0x0];if(!b)return{'found':![],'name':'unavailable','description':'No\x20Service\x20object\x20found','published':![],'paused':![],'salesCount':0x0,'arbitrations':[],'hasBuyGuard':![],'hasUm':![],'rewardsCount':0x0};return{'found':!![],'name':identity(b),'description':fld(b,'description')??'Service\x20(no\x20description)','published':fld(b,'bPublished')??![],'paused':fld(b,'bPaused')??![],'salesCount':Array['isArray'](fld(b,'sales'))?fld(b,'sales')['length']:0x0,'arbitrations':(fld(b,'arbitrations')??[])['filter'](c=>!!c),'compensationFund':balanceStr(fld(b,'compensation_fund')),'hasBuyGuard':fld(b,'buy_guard')!=null,'hasUm':fld(b,'um')!=null,'rewardsCount':(fld(b,'rewards')??[])['length']};}const REFUND_TERMS=['refund','refunded','return','returned','cancel','cancelled','canceled','reverse','reversal','chargeback','reimburse','compensat','expir','expired','void','voided','reject','rejected','fail','failed','abort','aborted','walk','dispute'],TERMINAL_SUFFIXES=['complete','completed','done','finish','finished','delivered','accepted',...REFUND_TERMS],matchesAny=(a,b)=>{const c=a['toLowerCase']();return b['some'](d=>c['includes'](d));},MACHINE_START_NODE='';function extractMachine(a,b,c){const d=objectsOfType(a,'Machine')[0x0];if(!d)return{'found':![],'nodeCount':0x0,'published':![],'paused':![],'entryNodes':[],'terminalNodeNames':[],'terminalSource':'names','refundNodeNames':[],'refundReachable':[],'reachabilityKnown':![]};const f=(b??[])['map'](j=>j['name'])['filter'](j=>typeof j==='string'),g=f['filter'](j=>matchesAny(j,REFUND_TERMS)),h=(c??[])['filter'](j=>!!j&&typeof j['from']==='string'&&typeof j['to']==='string');if(h['length']>0x0){const j=new Map();for(const p of h){const q=j['get'](p['from'])??[];q['push'](p['to']),j['set'](p['from'],q);}const k=new Set(f);for(const r of h){if(r['from'])k['add'](r['from']);if(r['to'])k['add'](r['to']);}k['delete'](MACHINE_START_NODE);const l=[...k]['filter'](s=>(j['get'](s)?.['length']??0x0)===0x0)['sort'](),n=new Set();if(j['has'](MACHINE_START_NODE)){n['add'](MACHINE_START_NODE);const s=[MACHINE_START_NODE];while(s['length']>0x0){const t=s['shift']();for(const u of j['get'](t)??[]){!n['has'](u)&&(n['add'](u),s['push'](u));}}}const o=j['has'](MACHINE_START_NODE);return{'found':!![],'nodeCount':f['length']>0x0?f['length']:(fld(d,'node_count')??0x0)+0x1,'published':fld(d,'bPublished')??![],'paused':fld(d,'bPaused')??![],'entryNodes':[],'terminalNodeNames':l,'terminalSource':'topology','refundNodeNames':g,'refundReachable':o?g['filter'](v=>n['has'](v)):[],'reachabilityKnown':o};}const i=f['filter'](v=>matchesAny(v,TERMINAL_SUFFIXES));return{'found':!![],'nodeCount':f['length']>0x0?f['length']:(fld(d,'node_count')??0x0)+0x1,'published':fld(d,'bPublished')??![],'paused':fld(d,'bPaused')??![],'entryNodes':[],'terminalNodeNames':i,'terminalSource':'names','refundNodeNames':g,'refundReachable':[],'reachabilityKnown':![]};}function detectAllocationRefundSlot(a){const b=objectsOfType(a,'Service')[0x0],c=fld(b,'order_allocators'),d=Array['isArray'](c)?c:Array['isArray'](c?.['allocators'])?c['allocators']:[];for(const e of d){for(const f of e?.['sharing']??[]){const g=f?.['who'];if(g==null)continue;if(typeof g==='object'){if('GuardIdentifier'in g)return!![];if('Signer'in g)return!![];continue;}if(typeof g==='string'){const h=g['toLowerCase']();if(h['includes']('guard\x20identifier')||h==='signer')return!![];}}}return![];}export const PENDING_STALE_HOURS_DEFAULT=0xa8;function computeOrderHealth(a,b,c){if(!a||a['length']===0x0)return undefined;const d=a['filter'](h=>h&&h['claimed_by']==null),e=typeof b==='number'&&Number['isFinite'](b)&&b>0x0;let f=0x0,g=null;for(const h of d){const i=Number(h?.['created_at_ms']??0x0);if(!e||!Number['isFinite'](i)||i<=0x0)continue;const j=b-i;if(j>c*0x36ee80)f++;if(g==null||j>g)g=j;}return{'observed':a['length'],'pending':d['length'],'agingKnown':e,'overdue':e?f:0x0,'oldestPendingAgeDays':e&&g!=null?Math['floor'](g/0x5265c00):null,'staleHours':c};}export function generateBusinessReport(a){const b=a['objects']??[],c=extractService(b),d=extractMachine(b,a['machine_nodes'],a['machine_edges']),e=detectAllocationRefundSlot(b),f=d['refundNodeNames']['length']>0x0,g=d['refundReachable']['length']>0x0,h=d['reachabilityKnown']?g||e:f||e,i=d['reachabilityKnown']&&f&&!g,j=a['pending_stale_hours']??PENDING_STALE_HOURS_DEFAULT,k=computeOrderHealth(a['orders'],a['now_ms'],j),l=k?.['agingKnown']?k['overdue']:0x0,m=k?.['pending']??0x0,n=c['arbitrations']['length']>0x0,o=c['compensationFund'],p=o==null||o==='0',q=!c['found']?'unavailable':c['published']?c['paused']?'published\x20but\x20PAUSED':'published\x20and\x20active':'not\x20yet\x20published',r=!c['found']?'No\x20Service\x20object\x20available\x20to\x20describe.':c['description']+'\x20('+q+(c['salesCount']>0x0?',\x20'+c['salesCount']+'\x20sale\x20option(s)':'')+').',s=!d['found']?'Workflow\x20(Machine)\x20unavailable\x20—\x20cannot\x20describe\x20the\x20process.':d['nodeCount']>0x0?d['nodeCount']+'-node\x20workflow\x20('+(d['published']?'published':'draft')+(d['paused']?',\x20paused':'')+').'+(d['terminalNodeNames']['length']>0x0?d['terminalSource']==='topology'?'\x20Stop\x20nodes\x20(derived\x20from\x20workflow\x20edges):\x20'+d['terminalNodeNames']['join'](',\x20')+'.':'\x20Stop/refund\x20nodes\x20detected\x20(name\x20convention\x20only\x20—\x20no\x20edge\x20table\x20to\x20verify):\x20'+d['terminalNodeNames']['join'](',\x20')+'.':d['terminalSource']==='topology'?'\x20No\x20stop\x20node\x20in\x20the\x20workflow\x20graph.':'\x20No\x20explicit\x20stop\x20node\x20detected\x20from\x20names.'):'Workflow\x20node\x20details\x20unavailable\x20(node_count\x20not\x20resolved).',t=!f?'':d['reachabilityKnown']?g?'\x20Workflow\x20edges\x20verify\x20the\x20reversal\x20rail\x20is\x20reachable:\x20node(s)\x20'+d['refundReachable']['join'](',\x20')+'.':'\x20WARNING:\x20the\x20named\x20refund\x20node(s)\x20'+d['refundNodeNames']['join'](',\x20')+'\x20are\x20UNREACHABLE\x20from\x20the\x20workflow\x20entry\x20—\x20that\x20rail\x20cannot\x20fire.':'\x20Reversal\x20rail:\x20workflow\x20node(s)\x20'+d['refundNodeNames']['join'](',\x20')+'.',u=h?['A\x20refund\x20path\x20is\x20present.',t,e?'\x20Escrow\x20can\x20be\x20routed\x20back\x20to\x20the\x20payer\x20or\x20to\x20the\x20order\x20by\x20an\x20allocation\x20slot.':'']['filter'](Boolean)['join'](''):'NO\x20refund\x20path\x20detected\x20—\x20funds\x20may\x20be\x20unrecoverable\x20once\x20the\x20workflow\x20advances\x20to\x20completion.'+(i?t:''),v=n?c['arbitrations']['length']+'\x20arbitration\x20service(s)\x20bound\x20—\x20disputes\x20have\x20a\x20resolution\x20path.':'NO\x20arbitration\x20bound\x20—\x20disputes\x20have\x20no\x20neutral\x20resolution\x20path.',w=[];if(!h)w['push']('No\x20refund\x20path\x20—\x20escrowed\x20funds\x20may\x20be\x20unrecoverable.');i&&h&&w['push']('The\x20named\x20refund\x20node(s)\x20'+d['refundNodeNames']['join'](',\x20')+'\x20are\x20unreachable\x20from\x20the\x20workflow\x20entry\x20—\x20'+'that\x20rail\x20is\x20dead;\x20only\x20the\x20allocation\x20slot\x20can\x20still\x20return\x20funds.');if(!n)w['push']('No\x20arbitration\x20bound\x20—\x20no\x20dispute\x20recourse.');if(p)w['push']('Compensation\x20fund\x20is\x20empty\x20—\x20arbitration\x20indemnity\x20would\x20be\x20unenforceable.');l>0x0&&w['push'](l+'\x20pending\x20order(s)\x20exceed\x20the\x20'+j+'h\x20settlement\x20window'+(k?.['oldestPendingAgeDays']!=null?'\x20(oldest:\x20'+k['oldestPendingAgeDays']+'d)':'')+'\x20—\x20funds\x20held\x20in\x20escrow\x20with\x20no\x20settlement\x20progress.');const x=[];if(c['published']&&!c['paused'])x['push']('Service\x20is\x20published\x20and\x20active.');h&&x['push'](d['reachabilityKnown']&&g&&e?'Refund\x20path\x20VERIFIED\x20—\x20reachable\x20rail\x20plus\x20an\x20order-routed\x20allocation\x20slot.':d['reachabilityKnown']&&g?'Refund\x20path\x20reachable\x20via\x20workflow\x20edges\x20(no\x20order-routed\x20allocation\x20slot\x20found).':'Refund\x20path\x20present.');if(n)x['push']('Arbitration\x20bound\x20(neutral\x20dispute\x20resolution).');if(!p)x['push']('Compensation\x20fund\x20funded\x20('+o+'\x20raw\x20units)\x20—\x20indemnity\x20enforceable.');if(c['hasBuyGuard'])x['push']('Buy\x20guard\x20present\x20(purchase\x20is\x20validated\x20by\x20on-chain\x20rules).');const y=[];if(!h)y['push']('Refund\x20path');if(!n)y['push']('Arbitration');if(p)y['push']('Compensation\x20fund');let z='low';if(!h&&!n)z='critical';else{if(!h||!n)z='high';else p&&(z='medium');}if(l>=0x3&&(z==='low'||z==='medium'))z='high';else{if(l>=0x1&&z==='low')z='medium';}const A=[];if(c['found']&&c['paused'])A['push']('Service\x20is\x20currently\x20PAUSED\x20—\x20purchases\x20are\x20rejected\x20until\x20the\x20merchant\x20resumes\x20it.\x20This\x20is\x20a\x20merchant-side\x20availability\x20state,\x20not\x20a\x20trust\x20signal:\x20do\x20not\x20purchase\x20while\x20paused.');else c['found']&&!c['published']&&A['push']('Service\x20is\x20not\x20yet\x20published\x20—\x20purchases\x20are\x20not\x20possible\x20until\x20the\x20merchant\x20publishes\x20it.\x20This\x20is\x20a\x20launch\x20state,\x20not\x20a\x20trust\x20signal.');c['found']&&!c['hasUm']&&A['push']('No\x20contact\x20channel\x20(um)\x20configured\x20—\x20Messenger\x20pre-order\x20negotiation\x20with\x20the\x20merchant\x20is\x20unavailable.');m>0x0&&l===0x0&&A['push'](m+'\x20order(s)\x20in\x20the\x20recent\x20window\x20are\x20pending\x20(not\x20yet\x20settled).');const B=[];B['push']('Escrowed\x20settlement:\x20funds\x20release\x20only\x20when\x20the\x20workflow\x20advances\x20—\x20the\x20merchant\x20is\x20incentivized\x20to\x20deliver.'),B['push']('On-chain\x20reputation\x20(Registrar\x20like/dislike\x20+\x20dispute\x20rate)\x20is\x20a\x20public\x20trust\x20signal\x20for\x20future\x20buyers.');if(c['rewardsCount']>0x0)B['push'](c['rewardsCount']+'\x20reward(s)\x20configured\x20—\x20repeat-buyer\x20incentives\x20lower\x20acquisition\x20cost.');const C=[];C['push']('Escrow\x20safety:\x20money\x20is\x20locked\x20on-chain\x20until\x20completion,\x20not\x20held\x20by\x20the\x20merchant.');if(h)C['push']('Refund\x20path\x20exists\x20—\x20a\x20verified\x20refund\x20returns\x20the\x20escrow.');if(n)C['push']('Arbitration\x20recourse\x20—\x20a\x20neutral\x20third\x20party\x20can\x20rule\x20on\x20disputes.');if(!p)C['push']('Compensation\x20fund\x20backs\x20arbitration\x20indemnity.');const D=[];D['push']('Merchant\x20wants\x20settlement\x20released\x20early;\x20user\x20wants\x20to\x20verify\x20the\x20deliverable\x20first\x20—\x20the\x20workflow\x27s\x20confirm\x20step\x20is\x20the\x20contention\x20point.'),D['push']('Merchant\x20controls\x20the\x20Machine/Guards;\x20user\x20is\x20limited\x20to\x20the\x20confirm/refund\x20forwards\x20the\x20merchant\x20designed.');if(!n)D['push']('No\x20arbitration:\x20a\x20deadlock\x20has\x20no\x20neutral\x20tie-breaker.');const E=[];E['push']('Escrow\x20alignment:\x20funds\x20stay\x20locked\x20until\x20both\x20sides\x20advance\x20the\x20workflow\x20—\x20neither\x20can\x20unilaterally\x20take\x20the\x20money.');if(h)E['push']('Allocation\x20alignment:\x20a\x20refund\x20slot\x20routes\x20the\x20escrow\x20back\x20to\x20the\x20buyer\x20on\x20the\x20refund\x20path.');if(n)E['push']('Arbitration\x20alignment:\x20an\x20independent\x20Permission\x20+\x20public\x20voters\x20provide\x20a\x20neutral\x20dispute\x20authority.');E['push']('Reputation\x20alignment:\x20Registrar\x20like/dislike\x20is\x20framework-enforced\x20and\x20unforgeable\x20—\x20both\x20sides\x20are\x20accountable\x20to\x20public\x20history.');const F=z['toUpperCase'](),G=a['order_amount']!=null?'\x20'+a['order_amount']+'\x20raw\x20units\x20are\x20escrowed.':'',H=c['found']&&c['paused']?'\x20NOTE:\x20the\x20service\x20is\x20PAUSED\x20—\x20purchases\x20are\x20rejected\x20until\x20the\x20merchant\x20resumes\x20it.':c['found']&&!c['published']?'\x20NOTE:\x20the\x20service\x20is\x20not\x20yet\x20published\x20—\x20purchases\x20are\x20not\x20possible.':'',I=!c['found']?'No\x20Service\x20object\x20found\x20—\x20reverse\x20mapping\x20produced\x20a\x20minimal\x20report.':'\x22'+c['name']+'\x22\x20is\x20'+q+'.'+G+'\x20'+('Risk\x20level:\x20'+F+'.\x20'+(h?'Refund\x20path\x20present.':'NO\x20refund\x20path.')+'\x20')+(''+(n?'Arbitration\x20bound.':'NO\x20arbitration.'))+(H+'\x20')+'This\x20report\x20is\x20generated\x20deterministically\x20from\x20on-chain\x20facts\x20—\x20the\x20buyer\x20decides.';return{'summary':I,'merchantProfile':{'serviceDescription':r,'workflowDescription':s,'refundPolicy':u,'arbitrationPolicy':v},'userRiskAssessment':{'riskLevel':z,'keyRisks':w,'protections':x,'missingProtections':y,'notices':A},'gameTheoryAnalysis':{'merchantIncentives':B,'userIncentives':C,'potentialConflicts':D,'wowAlignments':E},'orderHealth':k};}export function classifyObjectType(a){return detectType(a);}export function extractObjectFields(a){if(!a||typeof a!=='object')return{};const b=a['data']??a;if(!b||typeof b!=='object')return{};return{...b};}
1
+ function fld(a,b){return a?.[b]??a?.['data']?.[b];}function detectType(a){const b=fld(a,'type')??fld(a,'type_raw');if(typeof b!=='string'||b['length']===0x0)return'';const c=b['split']('::')['pop']()??b;return c;}function objectsOfType(a,b){return a['filter'](c=>detectType(c)===b);}function identity(a){const b=fld(a,'name');if(typeof b==='string'&&b['trim']())return b['trim']();const c=fld(a,'object')??fld(a,'id');if(typeof c==='string'&&c['trim']())return c['trim']();return'unknown';}function balanceStr(a){if(a==null)return undefined;if(typeof a==='object'&&'balance'in a)return String(a['balance']);return String(a);}function extractService(a){const b=objectsOfType(a,'Service')[0x0];if(!b)return{'found':![],'name':'unavailable','description':'No\x20Service\x20object\x20found','published':![],'paused':![],'salesCount':0x0,'arbitrations':[],'hasBuyGuard':![],'hasUm':![],'rewardsCount':0x0};return{'found':!![],'name':identity(b),'description':fld(b,'description')??'Service\x20(no\x20description)','published':fld(b,'bPublished')??![],'paused':fld(b,'bPaused')??![],'salesCount':Array['isArray'](fld(b,'sales'))?fld(b,'sales')['length']:0x0,'arbitrations':(fld(b,'arbitrations')??[])['filter'](c=>!!c),'compensationFund':balanceStr(fld(b,'compensation_fund')),'hasBuyGuard':fld(b,'buy_guard')!=null,'hasUm':fld(b,'um')!=null,'rewardsCount':(fld(b,'rewards')??[])['length']};}const REFUND_TERMS=['refund','refunded','return','returned','cancel','cancelled','canceled','reverse','reversal','chargeback','reimburse','compensat','expir','expired','void','voided','reject','rejected','fail','failed','abort','aborted','walk','dispute'],TERMINAL_SUFFIXES=['complete','completed','done','finish','finished','delivered','accepted',...REFUND_TERMS],matchesAny=(a,b)=>{const c=a['toLowerCase']();return b['some'](d=>c['includes'](d));},MACHINE_START_NODE='';function extractMachine(a,b,c){const d=objectsOfType(a,'Machine')[0x0];if(!d)return{'found':![],'nodeCount':0x0,'published':![],'paused':![],'entryNodes':[],'terminalNodeNames':[],'terminalSource':'names','refundNodeNames':[],'refundReachable':[],'reachabilityKnown':![]};const f=(b??[])['map'](j=>j['name'])['filter'](j=>typeof j==='string'),g=f['filter'](j=>matchesAny(j,REFUND_TERMS)),h=(c??[])['filter'](j=>!!j&&typeof j['from']==='string'&&typeof j['to']==='string');if(h['length']>0x0){const j=new Map();for(const p of h){const q=j['get'](p['from'])??[];q['push'](p['to']),j['set'](p['from'],q);}const k=new Set(f);for(const r of h){if(r['from'])k['add'](r['from']);if(r['to'])k['add'](r['to']);}k['delete'](MACHINE_START_NODE);const l=[...k]['filter'](s=>(j['get'](s)?.['length']??0x0)===0x0)['sort'](),n=new Set();if(j['has'](MACHINE_START_NODE)){n['add'](MACHINE_START_NODE);const s=[MACHINE_START_NODE];while(s['length']>0x0){const t=s['shift']();for(const u of j['get'](t)??[]){!n['has'](u)&&(n['add'](u),s['push'](u));}}}const o=j['has'](MACHINE_START_NODE);return{'found':!![],'nodeCount':f['length']>0x0?f['length']:(fld(d,'node_count')??0x0)+0x1,'published':fld(d,'bPublished')??![],'paused':fld(d,'bPaused')??![],'entryNodes':[],'terminalNodeNames':l,'terminalSource':'topology','refundNodeNames':g,'refundReachable':o?g['filter'](v=>n['has'](v)):[],'reachabilityKnown':o};}const i=f['filter'](v=>matchesAny(v,TERMINAL_SUFFIXES));return{'found':!![],'nodeCount':f['length']>0x0?f['length']:(fld(d,'node_count')??0x0)+0x1,'published':fld(d,'bPublished')??![],'paused':fld(d,'bPaused')??![],'entryNodes':[],'terminalNodeNames':i,'terminalSource':'names','refundNodeNames':g,'refundReachable':[],'reachabilityKnown':![]};}function detectAllocationRefundSlot(a){const b=objectsOfType(a,'Service')[0x0],c=fld(b,'order_allocators'),d=Array['isArray'](c)?c:Array['isArray'](c?.['allocators'])?c['allocators']:[];for(const e of d){for(const f of e?.['sharing']??[]){const g=f?.['who'];if(g==null)continue;if(typeof g==='object'){if('GuardIdentifier'in g)return!![];if('Signer'in g)return!![];continue;}if(typeof g==='string'){const h=g['toLowerCase']();if(h['includes']('guard\x20identifier')||h==='signer')return!![];}}}return![];}export const PENDING_STALE_HOURS_DEFAULT=0xa8;function computeOrderHealth(a,b,c){if(!a||a['length']===0x0)return undefined;const d=a['filter'](h=>h&&h['claimed_by']==null),e=typeof b==='number'&&Number['isFinite'](b)&&b>0x0;let f=0x0,g=null;for(const h of d){const i=Number(h?.['created_at_ms']??0x0);if(!e||!Number['isFinite'](i)||i<=0x0)continue;const j=b-i;if(j>c*0x36ee80)f++;if(g==null||j>g)g=j;}return{'observed':a['length'],'pending':d['length'],'agingKnown':e,'overdue':e?f:0x0,'oldestPendingAgeDays':e&&g!=null?Math['floor'](g/0x5265c00):null,'staleHours':c};}export function generateBusinessReport(a){const b=a['objects']??[],c=extractService(b),d=extractMachine(b,a['machine_nodes'],a['machine_edges']),e=detectAllocationRefundSlot(b),f=d['refundNodeNames']['length']>0x0,g=d['refundReachable']['length']>0x0,h=d['reachabilityKnown']?g||e:f||e,i=d['reachabilityKnown']&&f&&!g,j=a['pending_stale_hours']??PENDING_STALE_HOURS_DEFAULT,k=computeOrderHealth(a['orders'],a['now_ms'],j),l=k?.['agingKnown']?k['overdue']:0x0,m=k?.['pending']??0x0,n=c['arbitrations']['length']>0x0,o=c['compensationFund'],p=o==null||o==='0',q=!c['found']?'unavailable':c['published']?c['paused']?'published\x20but\x20PAUSED':'published\x20and\x20active':'not\x20yet\x20published',r=!c['found']?'No\x20Service\x20object\x20available\x20to\x20describe.':c['description']+'\x20('+q+(c['salesCount']>0x0?',\x20'+c['salesCount']+'\x20sale\x20option(s)':'')+').',s=!d['found']?'Workflow\x20(Machine)\x20unavailable\x20—\x20cannot\x20describe\x20the\x20process.':d['nodeCount']>0x0?d['nodeCount']+'-node\x20workflow\x20('+(d['published']?'published':'draft')+(d['paused']?',\x20paused':'')+').'+(d['terminalNodeNames']['length']>0x0?d['terminalSource']==='topology'?'\x20Stop\x20nodes\x20(derived\x20from\x20workflow\x20edges):\x20'+d['terminalNodeNames']['join'](',\x20')+'.':'\x20Stop/refund\x20nodes\x20detected\x20(name\x20convention\x20only\x20—\x20no\x20edge\x20table\x20to\x20verify):\x20'+d['terminalNodeNames']['join'](',\x20')+'.':d['terminalSource']==='topology'?'\x20No\x20stop\x20node\x20in\x20the\x20workflow\x20graph.':'\x20No\x20explicit\x20stop\x20node\x20detected\x20from\x20names.'):'Workflow\x20node\x20details\x20unavailable\x20(node_count\x20not\x20resolved).',t=!f?'':d['reachabilityKnown']?g?'\x20Workflow\x20edges\x20verify\x20the\x20reversal\x20rail\x20is\x20reachable:\x20node(s)\x20'+d['refundReachable']['join'](',\x20')+'.':'\x20WARNING:\x20the\x20named\x20refund\x20node(s)\x20'+d['refundNodeNames']['join'](',\x20')+'\x20are\x20UNREACHABLE\x20from\x20the\x20workflow\x20entry\x20—\x20that\x20rail\x20cannot\x20fire.':'\x20Reversal\x20rail:\x20workflow\x20node(s)\x20'+d['refundNodeNames']['join'](',\x20')+'.',u=h?['A\x20refund\x20path\x20is\x20present.',t,e?'\x20Escrow\x20can\x20be\x20routed\x20back\x20to\x20the\x20payer\x20or\x20to\x20the\x20order\x20by\x20an\x20allocation\x20slot.':'']['filter'](Boolean)['join'](''):'NO\x20refund\x20path\x20detected\x20—\x20funds\x20may\x20be\x20unrecoverable\x20once\x20the\x20workflow\x20advances\x20to\x20completion.'+(i?t:''),v=n?c['arbitrations']['length']+'\x20arbitration\x20service(s)\x20bound\x20—\x20disputes\x20have\x20a\x20resolution\x20path.':'NO\x20arbitration\x20bound\x20—\x20disputes\x20have\x20no\x20neutral\x20resolution\x20path.',w=[];if(!h)w['push']('No\x20refund\x20path\x20—\x20escrowed\x20funds\x20may\x20be\x20unrecoverable.');i&&h&&w['push']('The\x20named\x20refund\x20node(s)\x20'+d['refundNodeNames']['join'](',\x20')+'\x20are\x20unreachable\x20from\x20the\x20workflow\x20entry\x20—\x20'+'that\x20rail\x20is\x20dead;\x20only\x20the\x20allocation\x20slot\x20can\x20still\x20return\x20funds.');if(!n)w['push']('No\x20arbitration\x20bound\x20—\x20no\x20dispute\x20recourse.');if(p)w['push']('Compensation\x20fund\x20is\x20empty\x20—\x20arbitration\x20indemnity\x20would\x20be\x20unenforceable.');l>0x0&&w['push'](l+'\x20pending\x20order(s)\x20exceed\x20the\x20'+j+'h\x20settlement\x20window'+(k?.['oldestPendingAgeDays']!=null?'\x20(oldest:\x20'+k['oldestPendingAgeDays']+'d)':'')+'\x20—\x20funds\x20held\x20in\x20escrow\x20with\x20no\x20settlement\x20progress.');const x=[];if(c['published']&&!c['paused'])x['push']('Service\x20is\x20published\x20and\x20active.');h&&x['push'](d['reachabilityKnown']&&g&&e?'Refund\x20path\x20statically\x20reachable\x20—\x20workflow\x20edges\x20reach\x20the\x20rail\x20and\x20an\x20order-routed\x20allocation\x20slot\x20exists\x20(static\x20graph\x20check\x20only;\x20leg\x20executability\x20is\x20audited\x20by\x20the\x20allocator\x20guard\x20lint,\x20not\x20here).':d['reachabilityKnown']&&g?'Refund\x20path\x20statically\x20reachable\x20via\x20workflow\x20edges\x20(no\x20order-routed\x20allocation\x20slot\x20found).':'Refund\x20path\x20present.');if(n)x['push']('Arbitration\x20bound\x20(neutral\x20dispute\x20resolution).');if(!p)x['push']('Compensation\x20fund\x20funded\x20('+o+'\x20raw\x20units)\x20—\x20indemnity\x20enforceable.');if(c['hasBuyGuard'])x['push']('Buy\x20guard\x20present\x20(purchase\x20is\x20validated\x20by\x20on-chain\x20rules).');const y=[];if(!h)y['push']('Refund\x20path');if(!n)y['push']('Arbitration');if(p)y['push']('Compensation\x20fund');let z='low';if(!h&&!n)z='critical';else{if(!h||!n)z='high';else p&&(z='medium');}if(l>=0x3&&(z==='low'||z==='medium'))z='high';else{if(l>=0x1&&z==='low')z='medium';}const A=[];if(c['found']&&c['paused'])A['push']('Service\x20is\x20currently\x20PAUSED\x20—\x20purchases\x20are\x20rejected\x20until\x20the\x20merchant\x20resumes\x20it.\x20This\x20is\x20a\x20merchant-side\x20availability\x20state,\x20not\x20a\x20trust\x20signal:\x20do\x20not\x20purchase\x20while\x20paused.');else c['found']&&!c['published']&&A['push']('Service\x20is\x20not\x20yet\x20published\x20—\x20purchases\x20are\x20not\x20possible\x20until\x20the\x20merchant\x20publishes\x20it.\x20This\x20is\x20a\x20launch\x20state,\x20not\x20a\x20trust\x20signal.');c['found']&&!c['hasUm']&&A['push']('No\x20contact\x20channel\x20(um)\x20configured\x20—\x20Messenger\x20pre-order\x20negotiation\x20with\x20the\x20merchant\x20is\x20unavailable.');m>0x0&&l===0x0&&A['push'](m+'\x20order(s)\x20in\x20the\x20recent\x20window\x20are\x20pending\x20(not\x20yet\x20settled).');const B=[];B['push']('Escrowed\x20settlement:\x20funds\x20release\x20only\x20when\x20the\x20workflow\x20advances\x20—\x20the\x20merchant\x20is\x20incentivized\x20to\x20deliver.'),B['push']('On-chain\x20reputation\x20(Registrar\x20like/dislike\x20+\x20dispute\x20rate)\x20is\x20a\x20public\x20trust\x20signal\x20for\x20future\x20buyers.');if(c['rewardsCount']>0x0)B['push'](c['rewardsCount']+'\x20reward(s)\x20configured\x20—\x20repeat-buyer\x20incentives\x20lower\x20acquisition\x20cost.');const C=[];C['push']('Escrow\x20safety:\x20money\x20is\x20locked\x20on-chain\x20until\x20completion,\x20not\x20held\x20by\x20the\x20merchant.');if(h)C['push']('Refund\x20path\x20exists\x20—\x20a\x20verified\x20refund\x20returns\x20the\x20escrow.');if(n)C['push']('Arbitration\x20recourse\x20—\x20a\x20neutral\x20third\x20party\x20can\x20rule\x20on\x20disputes.');if(!p)C['push']('Compensation\x20fund\x20backs\x20arbitration\x20indemnity.');const D=[];D['push']('Merchant\x20wants\x20settlement\x20released\x20early;\x20user\x20wants\x20to\x20verify\x20the\x20deliverable\x20first\x20—\x20the\x20workflow\x27s\x20confirm\x20step\x20is\x20the\x20contention\x20point.'),D['push']('Merchant\x20controls\x20the\x20Machine/Guards;\x20user\x20is\x20limited\x20to\x20the\x20confirm/refund\x20forwards\x20the\x20merchant\x20designed.');if(!n)D['push']('No\x20arbitration:\x20a\x20deadlock\x20has\x20no\x20neutral\x20tie-breaker.');const E=[];E['push']('Escrow\x20alignment:\x20funds\x20stay\x20locked\x20until\x20both\x20sides\x20advance\x20the\x20workflow\x20—\x20neither\x20can\x20unilaterally\x20take\x20the\x20money.');if(h)E['push']('Allocation\x20alignment:\x20a\x20refund\x20slot\x20routes\x20the\x20escrow\x20back\x20to\x20the\x20buyer\x20on\x20the\x20refund\x20path.');if(n)E['push']('Arbitration\x20alignment:\x20an\x20independent\x20Permission\x20+\x20public\x20voters\x20provide\x20a\x20neutral\x20dispute\x20authority.');E['push']('Reputation\x20alignment:\x20Registrar\x20like/dislike\x20is\x20framework-enforced\x20and\x20unforgeable\x20—\x20both\x20sides\x20are\x20accountable\x20to\x20public\x20history.');const F=z['toUpperCase'](),G=a['order_amount']!=null?'\x20'+a['order_amount']+'\x20raw\x20units\x20are\x20escrowed.':'',H=c['found']&&c['paused']?'\x20NOTE:\x20the\x20service\x20is\x20PAUSED\x20—\x20purchases\x20are\x20rejected\x20until\x20the\x20merchant\x20resumes\x20it.':c['found']&&!c['published']?'\x20NOTE:\x20the\x20service\x20is\x20not\x20yet\x20published\x20—\x20purchases\x20are\x20not\x20possible.':'',I=!c['found']?'No\x20Service\x20object\x20found\x20—\x20reverse\x20mapping\x20produced\x20a\x20minimal\x20report.':'\x22'+c['name']+'\x22\x20is\x20'+q+'.'+G+'\x20'+('Risk\x20level:\x20'+F+'.\x20'+(h?'Refund\x20path\x20present.':'NO\x20refund\x20path.')+'\x20')+(''+(n?'Arbitration\x20bound.':'NO\x20arbitration.'))+(H+'\x20')+'This\x20report\x20is\x20generated\x20deterministically\x20from\x20on-chain\x20facts\x20—\x20the\x20buyer\x20decides.';return{'summary':I,'merchantProfile':{'serviceDescription':r,'workflowDescription':s,'refundPolicy':u,'arbitrationPolicy':v},'userRiskAssessment':{'riskLevel':z,'keyRisks':w,'protections':x,'missingProtections':y,'notices':A},'gameTheoryAnalysis':{'merchantIncentives':B,'userIncentives':C,'potentialConflicts':D,'wowAlignments':E},'orderHealth':k};}export function classifyObjectType(a){return detectType(a);}export function extractObjectFields(a){if(!a||typeof a!=='object')return{};const b=a['data']??a;if(!b||typeof b!=='object')return{};return{...b};}
@@ -1 +1 @@
1
- import{Config,LocalMark,query_serviceContext,query_object_last_updated,query_affiliations,objectTypeFromAddress,ObjectType}from'@wowok/wowok';import{resolveAddress as a340a}from'../../tools/handlers/name-resolution.js';import{generateBusinessReport}from'./reverse-mapping.js';import{resolveSupplyChainGraph}from'../../knowledge/supply-chain.js';import{batchQueryObjectsByIds,fetchServiceOrders,ringWindowSaturated}from'../../graph/onchain/sdk-batch.js';import{projectExploration}from'../../graph/onchain/exploration.js';import{buildMachineGraph}from'./machine-nodes.js';import{formatMoneyAnnotation}from'./facet-money.js';function balanceStr(a){if(a===null||a===undefined)return null;if(typeof a==='bigint')return a['toString']();return String(a);}function ownerAddr(a){if(typeof a==='string')return a;const b=a;if(b&&typeof b==='object'){if(typeof b['AddressOwner']==='string')return b['AddressOwner'];if(typeof b['ObjectOwner']==='string')return b['ObjectOwner'];}return null;}function requireField(a,b){if(a===undefined||a===null)throw new Error('\x27'+b+'\x27\x20is\x20required\x20for\x20this\x20action');return a;}function summarizeGuard(a){if(!a)return null;const b=a,c=Array['isArray'](b['table'])?b['table']:[],d=c['filter'](e=>e?.['b_submission']===!![])['length'];return{'address':b['object']??'','description':b['description']??null,'rep':typeof b['rep']==='boolean'?b['rep']:null,'table_entry_count':c['length'],'submission_slot_count':d,'relies':Array['isArray'](b['relies'])?b['relies']['filter'](e=>typeof e==='string'):[],'relies_logic_and':typeof b['relies_logic_and']==='boolean'?b['relies_logic_and']:null};}function summarizePermission(a,b){if(!a)return null;const c=a,d=Array['isArray'](c['admin'])?c['admin']:[],e=d[0x0],f=typeof e==='string'?e:typeof e?.['account']==='string'?e['account']:c['builder']??null;return{'address':c['object']??'','description':c['description']??null,'builder':c['builder']??null,'owner':f,'owner_name':b?.['name']??null,'admin_count':d['length'],'entity_count':typeof c['entity_count']==='number'?c['entity_count']:null,'perm_remark':Array['isArray'](c['perm_remark'])?c['perm_remark']['map'](g=>({'index':String(g?.['index']??''),'remark':typeof g?.['remark']==='string'?g['remark']:''})):[],'um':c['um']??null,'tags':b?.['tags']??[],'updated_timestamp_ms':b?.['updated_at_ms']!=null?String(b['updated_at_ms']):null};}async function markOf(a){if(!a)return{'name':null,'tags':[],'updated_at_ms':null};try{const b=await LocalMark['Instance']()['get'](a);if(b)return{'name':b['name']??null,'tags':Array['isArray'](b['tags'])?b['tags']:[],'updated_at_ms':typeof b['updatedAt']==='number'?b['updatedAt']:null};}catch{}try{const c=await LocalMark['Instance']()['list']({'address':a}),d=c?.[0x0];if(d)return{'name':d['name']??null,'tags':Array['isArray'](d['tags'])?d['tags']:[],'updated_at_ms':typeof d['updatedAt']==='number'?d['updatedAt']:null};}catch{}return{'name':null,'tags':[],'updated_at_ms':null};}async function markOfMany(a){const b=[...new Set(a['filter'](e=>!!e))],c=await Promise['all'](b['map'](e=>markOf(e))),d=new Map();for(let e=0x0;e<b['length'];e++)d['set'](b[e],c[e]);return d;}export async function handleServicePanorama(b){const c=requireField(b['service_address'],'service_address'),d=b['context_network']??undefined;let h=d??await Config['Instance']()['network_get']();const j=[];let k=await a340a(c,'service'),l=await query_serviceContext({'service':k,'include_machine_nodes':!![],'network':h});if(!l?.['service']&&d){const a6=await Config['Instance']()['network_get']();a6&&a6!==h&&(h=a6,l=await query_serviceContext({'service':k,'include_machine_nodes':!![],'network':h}));}const m=l['service'];k=m['object']??k;const q=new Set(),w=a7=>{if(a7)q['add'](a7);};w(k),w(m['machine']),w(m['permission']),w(m['um']);for(const a7 of m['arbitrations']??[])w(a7);for(const a8 of m['rewards']??[])w(a8);for(const a9 of m['repositories']??[])w(a9);const x=l['permission'];if(x){const aa=Array['isArray'](x['admin'])?x['admin']:[];aa[0x0]&&w(typeof aa[0x0]==='string'?aa[0x0]:aa[0x0]?.['account']);if(x['builder'])w(x['builder']);}const y=await markOfMany([...q]),z=y['get'](k)??{'name':null,'tags':[],'updated_at_ms':null},A=z['name'],B=ab=>ab?y['get'](ab)??{'name':null,'tags':[],'updated_at_ms':null}:{'name':null,'tags':[],'updated_at_ms':null};let C=null;const D=l['machine'],E=l['machine_nodes']??[];if(D||E['length']>0x0){const {nodes:ab,edges:ac}=buildMachineGraph(E);C={'address':D?.['object']??m['machine']??'','name':B(D?.['object']??m['machine'])['name'],'description':D?.['description']??null,'published':typeof D?.['bPublished']==='boolean'?D['bPublished']:null,'paused':typeof D?.['bPaused']==='boolean'?D['bPaused']:null,'node_count':typeof D?.['node_count']==='number'?D['node_count']:null,'consensus_repositories':Array['isArray'](D?.['consensus_repositories'])?D['consensus_repositories']:[],'nodes':ab,'edges':ac};}let F=null;try{const ad=await query_object_last_updated({'object':k,'network':h});ad?.['timestamp_ms']&&(F={'timestamp_ms':ad['timestamp_ms'],'digest':ad['digest']??null,'sender':ad['sender']??null});}catch{j['push']('onchain_last_updated:\x20query\x20failed\x20(non-blocking)');}let G=null;try{G=await resolveSupplyChainGraph(k,h);}catch{j['push']('supply_chain:\x20resolution\x20failed\x20(non-blocking)');}let H=null,I=[];const J=m?.['type_raw']??m?.['type']??'',K=J['match'](/<(.+)>$/),L=K?K[0x1]:null,M=(ae,af)=>{const ag=[];return ae?ag['push']('Pricing\x20&\x20settlement\x20coin:\x20'+ae+'\x20—\x20the\x20Service\x27s\x20generic\x20T,\x20FIXED\x20at\x20creation\x20(immutable).\x20Sales\x20prices\x20and\x20order\x20amounts\x20are\x20denominated\x20in\x20this\x20exact\x20token;\x20buyers\x20must\x20hold\x20it\x20to\x20order.'):ag['push']('Pricing\x20&\x20settlement\x20coin:\x20unavailable\x20from\x20the\x20Service\x20type\x20(no\x20generic\x20found)\x20—\x20treat\x20amounts\x20as\x20raw\x20smallest\x20units.'),ag['push']('To\x20price\x20in\x20a\x20different\x20token,\x20publish\x20a\x20NEW\x20Service\x20with\x20type_parameter\x20set\x20to\x20that\x20token\x27s\x20full\x20type\x20—\x20this\x20one\x20keeps\x20settling\x20in\x20its\x20coin.'),/testnet/i['test'](af)?ag['push']('Testnet\x20has\x20ONLY\x20WOW\x20(no\x20stablecoins\x20are\x20bridged)\x20—\x20testnet\x20services\x20stay\x20WOW-denominated;\x20multi-token\x20pricing\x20is\x20a\x20mainnet\x20capability.'):ag['push']('Mainnet\x20accepts\x20bridged\x20tokens\x20(USDT\x20/\x20USDC\x20/\x20ETH\x20/\x20WBTC\x20/\x20WOW):\x20buyers\x20bridge\x20them\x20from\x20Ethereum\x20via\x20the\x20cross-chain\x20bridge.\x20Query\x20wowok_buildin_info\x20info=\x27mainnet\x20bridge\x20tokens\x27\x20for\x20each\x20token\x27s\x20exact\x20type\x20tag\x20(wowTypeTag)\x20to\x20use\x20in\x20type_parameter\x20when\x20publishing.'),ag['join']('\x20');},N=ae=>formatMoneyAnnotation(ae,L,h),O=0x3,P=0x32;let Q=null;try{const ae=await fetchServiceOrders(k,h,!![]),af=Array['isArray'](ae?.['items'])?ae['items']:[],ag=af['slice'](-P),ah=af['slice'](-O),ai=ag['map'](aG=>typeof aG?.['who']==='string'?aG['who']:'')['filter'](aG=>aG!==''),aj=ah['map'](aG=>typeof aG?.['who']==='string'?aG['who']:'')['filter'](aG=>aG!==''),ak=new Map();try{if(ai['length']>0x0){const aG=await batchQueryObjectsByIds(ai,h,!![]);for(const aH of aG){aH&&aH['type']===ObjectType['Order']&&ak['set'](aH['object'],aH);}}}catch{j['push']('recent_orders:\x20order\x20details\x20unavailable\x20(non-blocking)');}const al=new Map();try{const aI=new Set();for(const aJ of ak['values']()){if(aJ?.['allocation'])aI['add'](aJ['allocation']);}if(aI['size']>0x0){const aK=await batchQueryObjectsByIds(Array['from'](aI),h,!![]);for(const aL of aK){if(!aL?.['object'])continue;if(aL['type']===ObjectType['Allocation']){const aM=Number(aL?.['balance']??0x0);al['set'](aL['object'],Number['isFinite'](aM)&&aM===0x0?'allocated':'pending');}}}}catch{j['push']('recent_orders:\x20allocation\x20details\x20unavailable\x20(non-blocking)');}const am=new Map(),an=new Map();try{const aN=new Set();for(const aO of aj){const aP=ak['get'](aO);if(aP?.['progress'])aN['add'](aP['progress']);}if(aN['size']>0x0){const aQ=await batchQueryObjectsByIds(Array['from'](aN),h,!![]);for(const aR of aQ){if(!aR?.['object'])continue;if(aR['type']===ObjectType['Progress']){const aS=aR?.['current'];am['set'](aR['object'],typeof aS==='string'&&aS!==''?aS:null),an['set'](aR['object'],Number(aR?.['current_time'])||null);}}}}catch{j['push']('recent_orders:\x20progress\x20details\x20unavailable\x20(non-blocking)');}I=Array['from'](ak['values']())['map'](aT=>({'id':aT['object'],'created_at_ms':Number(aT['time'])||undefined,'claimed_by':aT['claimed_by']??null,'current_node':aT['progress']?am['get'](aT['progress'])??null:null}));const ao=new Map();try{const aT=aj,aU=await Promise['allSettled'](aT['map'](aV=>query_object_last_updated({'object':aV,'network':h})));for(let aV=0x0;aV<aT['length'];aV++){const aW=aU[aV];ao['set'](aT[aV],aW['status']==='fulfilled'&&aW['value']?.['timestamp_ms']?Number(aW['value']['timestamp_ms'])||null:null);}}catch{j['push']('recent_orders:\x20order\x20updated\x20times\x20unavailable\x20(non-blocking)');}const ap=await Promise['all'](ah['map'](async aX=>{const aY=typeof aX?.['who']==='string'?aX['who']:'',aZ=ak['get'](aY),b0=aZ?.['amount']!==null&&aZ?.['amount']!==undefined?String(aZ['amount']):'',b1=await N(b0);return{'order':aY,'time':typeof aX?.['time']==='number'?aX['time']:0x0,'updated_ms':ao['get'](aY)??null,'amount':b0,'amount_display':b1['display'],'amount_tip':b1['tip'],'progress':aZ?.['progress']??null,'allocation':aZ?.['allocation']??null,'disputes':Array['isArray'](aZ?.['dispute'])?aZ['dispute']:[],'agent':Array['isArray'](aZ?.['agent'])?aZ['agent']:[],'owner':ownerAddr(aZ?.['builder']??aZ?.['owner']),'claimed_by':aZ?.['claimed_by']??null,'required_info':aZ?.['required_info']??null,'progress_next':aZ?.['progress']?am['get'](aZ['progress'])??null:null,'progress_since':aZ?.['progress']?an['get'](aZ['progress'])??null:null,'allocation_state':aZ?.['allocation']?al['get'](aZ['allocation'])??'pending':'none','bought':await Promise['all']((Array['isArray'](aZ?.['items'])?aZ['items']:[])['map'](async b2=>({'name':String(b2?.['name']??''),'price_display':(await N(b2?.['price']!==null&&b2?.['price']!==undefined?String(b2['price']):null))['display'],'quantity':String(b2?.['quantity']??'0'),'wip_hash':String(b2?.['wip_hash']??'')})))};})),aq=ap['filter'](aX=>aX['order']!==''),ar=ai['map'](aX=>ak['get'](aX))['filter'](aX=>!!aX);let as=0x0n,at=0x0,au=0x0,av=0x0,aw=0x0,ax=0x0,ay=null,az=null;for(const aX of ar){const aY=aX?.['amount']!==null&&aX?.['amount']!==undefined?String(aX['amount']):'';/^\d+$/['test'](aY)&&(as+=BigInt(aY),at++);if(Array['isArray'](aX?.['dispute'])&&aX['dispute']['length']>0x0)au++;const aZ=aX?.['allocation']?al['get'](aX['allocation'])??'pending':'none';if(aZ==='pending')av++;else{if(aZ==='allocated')aw++;else ax++;}}for(const b0 of ag){if(typeof b0?.['time']==='number'){if(ay===null||b0['time']<ay)ay=b0['time'];if(az===null||b0['time']>az)az=b0['time'];}}const aA=at>0x0?as['toString']():null,aB=aA!==null?await N(aA):null,aC=af['length'],aD=ae?.['ring_saturated']??ringWindowSaturated(aC),aE=aq['length'],aF='Analyze\x20ALL\x20orders\x20of\x20Service\x20'+k+'\x20('+h+')\x20one\x20by\x20one,\x20newest\x20first.\x20'+('The\x20orders\x20live\x20in\x20the\x20Service\x27s\x20FIFO\x20tx-linker\x20window\x20holding\x20at\x20most\x205200\x20newest\x20entries\x20—\x20the\x20retained\x20count\x20is\x20a\x20lower\x20bound\x20when\x20the\x20window\x20is\x20saturated\x20(currently\x20'+aC+(aD?',\x20saturated':'')+').\x20')+'For\x20each\x20order\x20call\x20object_panorama\x20with\x20the\x20order\x27s\x20FULL\x200x\x20address\x20(collect\x20the\x20addresses\x20from\x20the\x20same\x20reverse-index\x20source;\x20work\x20newest-first)\x20and\x20render\x20ONE\x20table\x20row\x20per\x20order:\x20'+'order\x20address\x20chip\x20(first\x20column)\x20|\x20created\x20+\x20last-updated\x20(local\x20dates)\x20|\x20amount\x20(the\x20display\x20value\x20with\x20its\x20token\x20symbol\x20—\x20never\x20reconvert\x20from\x20raw)\x20|\x20fund\x20state\x20(none\x20/\x20pending\x20/\x20allocated)\x20|\x20current\x20machine\x20node\x20|\x20disputes\x20(each\x20dispute\x20case\x20as\x20its\x20own\x20address\x20chip\x20ON\x20THE\x20SAME\x20ROW\x20—\x20an\x20order\x27s\x20progress,\x20allocation\x20and\x20arb\x20cases\x20are\x20its\x20children\x20and\x20are\x20never\x20split\x20into\x20a\x20separate\x20flat\x20list)\x20|\x20buyer\x20address\x20chip.\x20'+'Close\x20with\x20the\x203\x20most\x20valuable\x20patterns\x20across\x20the\x20rows\x20(amount\x20distribution,\x20stuck\x20or\x20paused\x20orders,\x20dispute\x20rate).\x20Orders\x20only\x20—\x20do\x20not\x20re-analyze\x20the\x20Service\x20itself.';Q={'count':aC,'window_saturated':aD,'preview_truncated':aC>aE,'stats':{'scope_count':ar['length'],'scoped':ar['length']<aC,'amount_sum_raw':aA,'amount_sum_display':aB?.['display']??null,'amount_sum_tip':aB?.['tip']??null,'amount_known_count':at,'disputed_order_count':au,'allocation_pending_count':av,'allocation_allocated_count':aw,'allocation_none_count':ax,'first_created_ms':ay,'last_created_ms':az},...aC>aE?{'drilldown':{'total_count':aC,'analyzed_count':aE,'stats_scope_count':ar['length'],'prompt':aF}}:{},'items':aq};}catch{j['push']('recent_orders:\x20reverse-index\x20query\x20failed\x20(non-blocking)');}try{const b1=[m,l['machine'],l['buy_guard'],...l['allocator_guards']??[]]['filter'](Boolean);H=generateBusinessReport({'objects':b1,'machine_nodes':E['map'](b2=>({'name':b2['name']})),'machine_edges':C?.['edges']?C['edges']['map'](b2=>({'from':b2['from'],'to':b2['to']})):undefined,'orders':I['length']>0x0?I:undefined,'now_ms':Date['now']()});}catch{j['push']('business_report:\x20generation\x20failed\x20(non-blocking)');}const R=[];try{const b2=await query_affiliations({'address':k,'no_cache':!![],'network':h}),b3=new Set(),b4=new Map();for(const b6 of b2?.['entries']??[]){const b7=typeof b6?.['who']==='string'?b6['who']:'';if(!b7||b3['has'](b7))continue;b3['add'](b7);const b8=objectTypeFromAddress(b7);if(!b8)continue;if(b8===ObjectType['Order'])continue;const b9=String(b8);let ba=b4['get'](b9);!ba&&(ba=[],b4['set'](b9,ba)),ba['push']({'address':b7,'type_label':b9,'name':B(b7)['name'],'time':typeof b6?.['time']==='number'?b6['time']:null,'via':typeof b6?.['table']==='string'?b6['table']:null});}const b5=['Progress','Allocation','Payment','Guard'];for(const bb of b5){const bc=b4['get'](bb);bc&&bc['length']>0x0&&(R['push']({'type_label':bb,'items':bc}),b4['delete'](bb));}for(const [bd,be]of b4){if(be['length']>0x0)R['push']({'type_label':bd,'items':be});}}catch{j['push']('related:\x20global-table\x20lookup\x20failed\x20(non-blocking)');}const S=new Set(),T=bf=>{typeof bf==='string'&&/^0x[0-9a-fA-F]{40,64}$/['test'](bf)&&S['add'](bf['toLowerCase']());};T(m['buy_guard']);for(const bf of E){for(const bg of bf?.['pairs']??[]){for(const bh of bg?.['forwards']??[])T(bh?.['guard']);}}for(const bi of m['order_allocators']?.['allocators']??[])T(bi?.['guard']);for(const bj of l['allocator_guards']??[])T(bj?.['object']);for(const bk of Object['values'](l['referenced']??{})){const bl=bk;if(!bl||typeof bl!=='object')continue;if(bl['type']===ObjectType['Reward']){for(const bm of bl['guards']??[])T(bm?.['guard']);}if(bl['type']===ObjectType['Treasury']){for(const bn of bl['external_withdraw_guard']??[])T(bn?.['guard']);for(const bo of bl['external_deposit_guard']??[])T(bo?.['guard']);}(bl['type']===ObjectType['Arbitration']||bl['type']===ObjectType['Arb'])&&T(bl['voting_guard']);}const U=R['find'](bp=>bp['type_label']===String(ObjectType['Guard']));if(U){U['items']=U['items']['filter'](bp=>!S['has'](bp['address']['toLowerCase']()));if(U['items']['length']===0x0)R['splice'](R['indexOf'](U),0x1);else{const bp=U['items'];try{const bq=await batchQueryObjectsByIds(bp['map'](bs=>bs['address']),h,!![]),br=new Map();for(const bs of bq){if(bs?.['object'])br['set'](String(bs['object'])['toLowerCase'](),bs);}for(const bt of bp){const bu=br['get'](bt['address']['toLowerCase']());if(!bu){bt['explanation']=null;continue;}const bv=Array['isArray'](bu['table'])?bu['table']:[],bw=[];let bx=0x0;for(const bz of bv){if(bz?.['b_submission']===!![]){bx++;continue;}bz?.['value_type']==='Address'&&typeof bz?.['value']==='string'&&bz['value']['startsWith']('0x')&&bw['push'](bz['value']);}const by=bw['some'](bA=>bA['toLowerCase']()===k['toLowerCase']());bt['explanation']={'description':typeof bu['description']==='string'?bu['description']:null,'table_refs':bw,'references_this_service':by,'submission_slots':bx,'note':by?'One-off\x20verification\x20guard:\x20NOT\x20mounted\x20on\x20any\x20host\x20field;\x20its\x20table\x20carries\x20this\x20Service\x20as\x20an\x20on-chain\x20constant\x20(the\x20affiliation\x20is\x20written\x20at\x20creation).\x20It\x20acts\x20only\x20when\x20submitted\x20inside\x20a\x20passport\x20at\x20runtime.':'Guard\x20surfaced\x20by\x20the\x20affiliation\x20window\x20only;\x20not\x20mounted\x20on\x20any\x20host\x20field\x20reachable\x20from\x20this\x20panorama.\x20It\x20acts\x20only\x20when\x20referenced\x20at\x20runtime\x20(passport\x20submission\x20or\x20a\x20host\x20outside\x20this\x20view).'};}}catch{j['push']('related:\x20unbound-guard\x20explanation\x20unavailable\x20(non-blocking)');}}}const V=new Map();for(const bA of l['allocator_guards']??[]){const bB=bA;if(bB?.['object'])V['set'](String(bB['object'])['toLowerCase'](),bB);}const W=[];for(const bC of Array['isArray'](m['sales'])?m['sales']:[]){const bD=balanceStr(bC?.['price']),bE=await N(bD);W['push']({'name':typeof bC?.['name']==='string'?bC['name']:'','price':bD,'price_display':bE['display'],'price_tip':bE['tip'],'stock':balanceStr(bC?.['stock']),'suspension':bC?.['suspension']===!![],'wip':typeof bC?.['wip']==='string'?bC['wip']:'','wip_hash':typeof bC?.['wip_hash']==='string'?bC['wip_hash']:''});}const X=bF=>bF===0x0?'amount':bF===0x2?'surplus':'rate',Y=bF=>{const bG=bF?.['who'];if(bG&&typeof bG==='object'&&'Entity'in bG){const bH=bG['Entity'],bI=typeof bH==='string'?bH:typeof bH?.['name_or_address']==='string'?bH['name_or_address']:null;return{'who':bI?'Entity\x20'+bI:'Entity','entity':bI&&/^0x[0-9a-fA-F]{6,64}$/['test'](bI)?bI:null,'mode':X(bF?.['mode']),'value':balanceStr(bF?.['sharing'])};}if(bG&&typeof bG==='object'&&'GuardIdentifier'in bG)return{'who':'Guard\x20identifier\x20#'+bG['GuardIdentifier'],'entity':null,'mode':X(bF?.['mode']),'value':balanceStr(bF?.['sharing'])};return{'who':'Signer','entity':null,'mode':X(bF?.['mode']),'value':balanceStr(bF?.['sharing'])};},Z=m['order_allocators']?{'description':m['order_allocators']['description']??'','threshold':balanceStr(m['order_allocators']['threshold']),'allocators':(m['order_allocators']['allocators']??[])['map'](bF=>({'guard':bF['guard'],'sharing_count':Array['isArray'](bF['sharing'])?bF['sharing']['length']:0x0,'sharing':(Array['isArray'](bF['sharing'])?bF['sharing']:[])['map'](Y),'max':balanceStr(bF['max']??null),'guard_summary':summarizeGuard(V['get'](String(bF['guard']??'')['toLowerCase']()))}))}:null,a0=[];{const bF=new Map();for(const bG of m['order_allocators']?.['allocators']??[]){for(const bH of Array['isArray'](bG['sharing'])?bG['sharing']:[]){const bI=Y(bH);if(bI['entity']){const bJ=bI['entity']['toLowerCase'](),bK=bF['get'](bJ)??{'raw':bI['entity'],'guards':[]};bK['guards']['push'](bG['guard']??''),bF['set'](bJ,bK);}}}if(bF['size']>0x0)try{const bL=await batchQueryObjectsByIds([...bF['keys']()],h,!![]),bM=new Map();for(const bN of bL){if(bN?.['object'])bM['set'](String(bN['object'])['toLowerCase'](),bN);}for(const [bO,bP]of bF){const bQ=bM['get'](bO),bR='order_allocators\x20sharing\x20of\x20allocator\x20guard\x20'+bP['guards'][0x0];if(bQ&&bQ['permission']!==undefined){const bS=balanceStr(bQ['balance']),bT=await N(bS);a0['push']({'address':String(bQ['object']),'kind':'treasury','description':typeof bQ['description']==='string'?bQ['description']:null,'permission':typeof bQ['permission']==='string'?bQ['permission']:null,'balance':bS,'balance_display':bT['display'],'balance_tip':bT['tip'],'external_deposit_guard_count':Array['isArray'](bQ['external_deposit_guard'])?bQ['external_deposit_guard']['length']:null,'external_withdraw_guard_count':Array['isArray'](bQ['external_withdraw_guard'])?bQ['external_withdraw_guard']['length']:null,'via':bR});}else a0['push']({'address':bP['raw'],'kind':'account','description':null,'permission':null,'balance':null,'balance_display':null,'balance_tip':null,'external_deposit_guard_count':null,'external_withdraw_guard_count':null,'via':bR});}}catch{j['push']('income_recipients:\x20Sharing\x20entity\x20read\x20failed\x20(non-blocking)');}}const a1=summarizePermission(l['permission'],B(m['permission'])),a2=a1?.['owner']??F?.['sender']??null,a3=a2?await markOf(a2):null,a4=await N(balanceStr(m['compensation_fund'])),a5=projectExploration([],{'truncations':[],'budgetExhausted':{},'dataGaps':j});return{'action':'service_panorama','network':h,'service':{'address':k,'name':A,'description':m['description']??'','location':m['location']??'','published':m['bPublished']===!![],'paused':m['bPaused']===!![],'paused_time':typeof m['paused_time']==='number'?m['paused_time']:typeof m['paused_time']==='string'&&/^\d+$/['test'](m['paused_time'])?Number(m['paused_time']):null,'setting_lock_duration':balanceStr(m['setting_lock_duration']),'customer_required':Array['isArray'](m['customer_required'])?m['customer_required']:[],'compensation_fund':balanceStr(m['compensation_fund']),'compensation_fund_display':a4['display'],'compensation_fund_tip':a4['tip'],'sales':W,'machine':m['machine']??null,'buy_guard':m['buy_guard']??null,'permission':m['permission']??'','um':m['um']??null,'arbitrations':Array['isArray'](m['arbitrations'])?m['arbitrations']:[],'rewards':Array['isArray'](m['rewards'])?m['rewards']:[],'repositories':Array['isArray'](m['repositories'])?m['repositories']:[],'order_allocators':Z,'income_recipients':a0,'payment_token':{'coin_type':L,'guidance':M(L,h)},'onchain_last_updated':F,'tags':z['tags']??[],'owner':a2,'owner_name':a3?.['name']??null},'machine_graph':C,'buy_guard':summarizeGuard(l['buy_guard']),'permission':a1,'related':{'groups':R},'supply_chain':G,'business_report':H,'recent_orders':Q,'data_gaps':j,...a5['open_questions']['length']>0x0?{'exploration':a5}:{}};}
1
+ import{Config,LocalMark,query_serviceContext,query_object_last_updated,query_affiliations,objectTypeFromAddress,ObjectType}from'@wowok/wowok';import{resolveAddress as a341a}from'../../tools/handlers/name-resolution.js';import{generateBusinessReport}from'./reverse-mapping.js';import{resolveSupplyChainGraph}from'../../knowledge/supply-chain.js';import{batchQueryObjectsByIds,fetchServiceOrders,ringWindowSaturated}from'../../graph/onchain/sdk-batch.js';import{projectExploration}from'../../graph/onchain/exploration.js';import{buildMachineGraph}from'./machine-nodes.js';import{formatMoneyAnnotation}from'./facet-money.js';function balanceStr(a){if(a===null||a===undefined)return null;if(typeof a==='bigint')return a['toString']();return String(a);}function ownerAddr(a){if(typeof a==='string')return a;const b=a;if(b&&typeof b==='object'){if(typeof b['AddressOwner']==='string')return b['AddressOwner'];if(typeof b['ObjectOwner']==='string')return b['ObjectOwner'];}return null;}function requireField(a,b){if(a===undefined||a===null)throw new Error('\x27'+b+'\x27\x20is\x20required\x20for\x20this\x20action');return a;}function summarizeGuard(a){if(!a)return null;const b=a,c=Array['isArray'](b['table'])?b['table']:[],d=c['filter'](e=>e?.['b_submission']===!![])['length'];return{'address':b['object']??'','description':b['description']??null,'rep':typeof b['rep']==='boolean'?b['rep']:null,'table_entry_count':c['length'],'submission_slot_count':d,'relies':Array['isArray'](b['relies'])?b['relies']['filter'](e=>typeof e==='string'):[],'relies_logic_and':typeof b['relies_logic_and']==='boolean'?b['relies_logic_and']:null};}function summarizePermission(a,b){if(!a)return null;const c=a,d=Array['isArray'](c['admin'])?c['admin']:[],e=d[0x0],f=typeof e==='string'?e:typeof e?.['account']==='string'?e['account']:c['builder']??null;return{'address':c['object']??'','description':c['description']??null,'builder':c['builder']??null,'owner':f,'owner_name':b?.['name']??null,'admin_count':d['length'],'entity_count':typeof c['entity_count']==='number'?c['entity_count']:null,'perm_remark':Array['isArray'](c['perm_remark'])?c['perm_remark']['map'](g=>({'index':String(g?.['index']??''),'remark':typeof g?.['remark']==='string'?g['remark']:''})):[],'um':c['um']??null,'tags':b?.['tags']??[],'updated_timestamp_ms':b?.['updated_at_ms']!=null?String(b['updated_at_ms']):null};}async function markOf(a){if(!a)return{'name':null,'tags':[],'updated_at_ms':null};try{const b=await LocalMark['Instance']()['get'](a);if(b)return{'name':b['name']??null,'tags':Array['isArray'](b['tags'])?b['tags']:[],'updated_at_ms':typeof b['updatedAt']==='number'?b['updatedAt']:null};}catch{}try{const c=await LocalMark['Instance']()['list']({'address':a}),d=c?.[0x0];if(d)return{'name':d['name']??null,'tags':Array['isArray'](d['tags'])?d['tags']:[],'updated_at_ms':typeof d['updatedAt']==='number'?d['updatedAt']:null};}catch{}return{'name':null,'tags':[],'updated_at_ms':null};}async function markOfMany(a){const b=[...new Set(a['filter'](e=>!!e))],c=await Promise['all'](b['map'](e=>markOf(e))),d=new Map();for(let e=0x0;e<b['length'];e++)d['set'](b[e],c[e]);return d;}export async function handleServicePanorama(b){const c=requireField(b['service_address'],'service_address'),d=b['context_network']??undefined;let h=d??await Config['Instance']()['network_get']();const j=[];let k=await a341a(c,'service'),l=await query_serviceContext({'service':k,'include_machine_nodes':!![],'network':h});if(!l?.['service']&&d){const a6=await Config['Instance']()['network_get']();a6&&a6!==h&&(h=a6,l=await query_serviceContext({'service':k,'include_machine_nodes':!![],'network':h}));}const m=l['service'];k=m['object']??k;const q=new Set(),w=a7=>{if(a7)q['add'](a7);};w(k),w(m['machine']),w(m['permission']),w(m['um']);for(const a7 of m['arbitrations']??[])w(a7);for(const a8 of m['rewards']??[])w(a8);for(const a9 of m['repositories']??[])w(a9);const x=l['permission'];if(x){const aa=Array['isArray'](x['admin'])?x['admin']:[];aa[0x0]&&w(typeof aa[0x0]==='string'?aa[0x0]:aa[0x0]?.['account']);if(x['builder'])w(x['builder']);}const y=await markOfMany([...q]),z=y['get'](k)??{'name':null,'tags':[],'updated_at_ms':null},A=z['name'],B=ab=>ab?y['get'](ab)??{'name':null,'tags':[],'updated_at_ms':null}:{'name':null,'tags':[],'updated_at_ms':null};let C=null;const D=l['machine'],E=l['machine_nodes']??[];if(D||E['length']>0x0){const {nodes:ab,edges:ac}=buildMachineGraph(E);C={'address':D?.['object']??m['machine']??'','name':B(D?.['object']??m['machine'])['name'],'description':D?.['description']??null,'published':typeof D?.['bPublished']==='boolean'?D['bPublished']:null,'paused':typeof D?.['bPaused']==='boolean'?D['bPaused']:null,'node_count':typeof D?.['node_count']==='number'?D['node_count']:null,'consensus_repositories':Array['isArray'](D?.['consensus_repositories'])?D['consensus_repositories']:[],'nodes':ab,'edges':ac};}let F=null;try{const ad=await query_object_last_updated({'object':k,'network':h});ad?.['timestamp_ms']&&(F={'timestamp_ms':ad['timestamp_ms'],'digest':ad['digest']??null,'sender':ad['sender']??null});}catch{j['push']('onchain_last_updated:\x20query\x20failed\x20(non-blocking)');}let G=null;try{G=await resolveSupplyChainGraph(k,h);}catch{j['push']('supply_chain:\x20resolution\x20failed\x20(non-blocking)');}let H=null,I=[];const J=m?.['type_raw']??m?.['type']??'',K=J['match'](/<(.+)>$/),L=K?K[0x1]:null,M=(ae,af)=>{const ag=[];return ae?ag['push']('Pricing\x20&\x20settlement\x20coin:\x20'+ae+'\x20—\x20the\x20Service\x27s\x20generic\x20T,\x20FIXED\x20at\x20creation\x20(immutable).\x20Sales\x20prices\x20and\x20order\x20amounts\x20are\x20denominated\x20in\x20this\x20exact\x20token;\x20buyers\x20must\x20hold\x20it\x20to\x20order.'):ag['push']('Pricing\x20&\x20settlement\x20coin:\x20unavailable\x20from\x20the\x20Service\x20type\x20(no\x20generic\x20found)\x20—\x20treat\x20amounts\x20as\x20raw\x20smallest\x20units.'),ag['push']('To\x20price\x20in\x20a\x20different\x20token,\x20publish\x20a\x20NEW\x20Service\x20with\x20type_parameter\x20set\x20to\x20that\x20token\x27s\x20full\x20type\x20—\x20this\x20one\x20keeps\x20settling\x20in\x20its\x20coin.'),/testnet/i['test'](af)?ag['push']('Testnet\x20has\x20ONLY\x20WOW\x20(no\x20stablecoins\x20are\x20bridged)\x20—\x20testnet\x20services\x20stay\x20WOW-denominated;\x20multi-token\x20pricing\x20is\x20a\x20mainnet\x20capability.'):ag['push']('Mainnet\x20accepts\x20bridged\x20tokens\x20(USDT\x20/\x20USDC\x20/\x20ETH\x20/\x20WBTC\x20/\x20WOW):\x20buyers\x20bridge\x20them\x20from\x20Ethereum\x20via\x20the\x20cross-chain\x20bridge.\x20Query\x20wowok_buildin_info\x20info=\x27mainnet\x20bridge\x20tokens\x27\x20for\x20each\x20token\x27s\x20exact\x20type\x20tag\x20(wowTypeTag)\x20to\x20use\x20in\x20type_parameter\x20when\x20publishing.'),ag['join']('\x20');},N=ae=>formatMoneyAnnotation(ae,L,h),O=0x3,P=0x32;let Q=null;try{const ae=await fetchServiceOrders(k,h,!![]),af=Array['isArray'](ae?.['items'])?ae['items']:[],ag=af['slice'](-P),ah=af['slice'](-O),ai=ag['map'](aG=>typeof aG?.['who']==='string'?aG['who']:'')['filter'](aG=>aG!==''),aj=ah['map'](aG=>typeof aG?.['who']==='string'?aG['who']:'')['filter'](aG=>aG!==''),ak=new Map();try{if(ai['length']>0x0){const aG=await batchQueryObjectsByIds(ai,h,!![]);for(const aH of aG){aH&&aH['type']===ObjectType['Order']&&ak['set'](aH['object'],aH);}}}catch{j['push']('recent_orders:\x20order\x20details\x20unavailable\x20(non-blocking)');}const al=new Map();try{const aI=new Set();for(const aJ of ak['values']()){if(aJ?.['allocation'])aI['add'](aJ['allocation']);}if(aI['size']>0x0){const aK=await batchQueryObjectsByIds(Array['from'](aI),h,!![]);for(const aL of aK){if(!aL?.['object'])continue;if(aL['type']===ObjectType['Allocation']){const aM=Number(aL?.['balance']??0x0);al['set'](aL['object'],Number['isFinite'](aM)&&aM===0x0?'allocated':'pending');}}}}catch{j['push']('recent_orders:\x20allocation\x20details\x20unavailable\x20(non-blocking)');}const am=new Map(),an=new Map();try{const aN=new Set();for(const aO of aj){const aP=ak['get'](aO);if(aP?.['progress'])aN['add'](aP['progress']);}if(aN['size']>0x0){const aQ=await batchQueryObjectsByIds(Array['from'](aN),h,!![]);for(const aR of aQ){if(!aR?.['object'])continue;if(aR['type']===ObjectType['Progress']){const aS=aR?.['current'];am['set'](aR['object'],typeof aS==='string'&&aS!==''?aS:null),an['set'](aR['object'],Number(aR?.['current_time'])||null);}}}}catch{j['push']('recent_orders:\x20progress\x20details\x20unavailable\x20(non-blocking)');}I=Array['from'](ak['values']())['map'](aT=>({'id':aT['object'],'created_at_ms':Number(aT['time'])||undefined,'claimed_by':aT['claimed_by']??null,'current_node':aT['progress']?am['get'](aT['progress'])??null:null}));const ao=new Map();try{const aT=aj,aU=await Promise['allSettled'](aT['map'](aV=>query_object_last_updated({'object':aV,'network':h})));for(let aV=0x0;aV<aT['length'];aV++){const aW=aU[aV];ao['set'](aT[aV],aW['status']==='fulfilled'&&aW['value']?.['timestamp_ms']?Number(aW['value']['timestamp_ms'])||null:null);}}catch{j['push']('recent_orders:\x20order\x20updated\x20times\x20unavailable\x20(non-blocking)');}const ap=await Promise['all'](ah['map'](async aX=>{const aY=typeof aX?.['who']==='string'?aX['who']:'',aZ=ak['get'](aY),b0=aZ?.['amount']!==null&&aZ?.['amount']!==undefined?String(aZ['amount']):'',b1=await N(b0);return{'order':aY,'time':typeof aX?.['time']==='number'?aX['time']:0x0,'updated_ms':ao['get'](aY)??null,'amount':b0,'amount_display':b1['display'],'amount_tip':b1['tip'],'progress':aZ?.['progress']??null,'allocation':aZ?.['allocation']??null,'disputes':Array['isArray'](aZ?.['dispute'])?aZ['dispute']:[],'agent':Array['isArray'](aZ?.['agent'])?aZ['agent']:[],'owner':ownerAddr(aZ?.['builder']??aZ?.['owner']),'claimed_by':aZ?.['claimed_by']??null,'required_info':aZ?.['required_info']??null,'progress_next':aZ?.['progress']?am['get'](aZ['progress'])??null:null,'progress_since':aZ?.['progress']?an['get'](aZ['progress'])??null:null,'allocation_state':aZ?.['allocation']?al['get'](aZ['allocation'])??'pending':'none','bought':await Promise['all']((Array['isArray'](aZ?.['items'])?aZ['items']:[])['map'](async b2=>({'name':String(b2?.['name']??''),'price_display':(await N(b2?.['price']!==null&&b2?.['price']!==undefined?String(b2['price']):null))['display'],'quantity':String(b2?.['quantity']??'0'),'wip_hash':String(b2?.['wip_hash']??'')})))};})),aq=ap['filter'](aX=>aX['order']!==''),ar=ai['map'](aX=>ak['get'](aX))['filter'](aX=>!!aX);let as=0x0n,at=0x0,au=0x0,av=0x0,aw=0x0,ax=0x0,ay=null,az=null;for(const aX of ar){const aY=aX?.['amount']!==null&&aX?.['amount']!==undefined?String(aX['amount']):'';/^\d+$/['test'](aY)&&(as+=BigInt(aY),at++);if(Array['isArray'](aX?.['dispute'])&&aX['dispute']['length']>0x0)au++;const aZ=aX?.['allocation']?al['get'](aX['allocation'])??'pending':'none';if(aZ==='pending')av++;else{if(aZ==='allocated')aw++;else ax++;}}for(const b0 of ag){if(typeof b0?.['time']==='number'){if(ay===null||b0['time']<ay)ay=b0['time'];if(az===null||b0['time']>az)az=b0['time'];}}const aA=at>0x0?as['toString']():null,aB=aA!==null?await N(aA):null,aC=af['length'],aD=ae?.['ring_saturated']??ringWindowSaturated(aC),aE=aq['length'],aF='Analyze\x20ALL\x20orders\x20of\x20Service\x20'+k+'\x20('+h+')\x20one\x20by\x20one,\x20newest\x20first.\x20'+('The\x20orders\x20live\x20in\x20the\x20Service\x27s\x20FIFO\x20tx-linker\x20window\x20holding\x20at\x20most\x205200\x20newest\x20entries\x20—\x20the\x20retained\x20count\x20is\x20a\x20lower\x20bound\x20when\x20the\x20window\x20is\x20saturated\x20(currently\x20'+aC+(aD?',\x20saturated':'')+').\x20')+'For\x20each\x20order\x20call\x20object_panorama\x20with\x20the\x20order\x27s\x20FULL\x200x\x20address\x20(collect\x20the\x20addresses\x20from\x20the\x20same\x20reverse-index\x20source;\x20work\x20newest-first)\x20and\x20render\x20ONE\x20table\x20row\x20per\x20order:\x20'+'order\x20address\x20chip\x20(first\x20column)\x20|\x20created\x20+\x20last-updated\x20(local\x20dates)\x20|\x20amount\x20(the\x20display\x20value\x20with\x20its\x20token\x20symbol\x20—\x20never\x20reconvert\x20from\x20raw)\x20|\x20fund\x20state\x20(none\x20/\x20pending\x20/\x20allocated)\x20|\x20current\x20machine\x20node\x20|\x20disputes\x20(each\x20dispute\x20case\x20as\x20its\x20own\x20address\x20chip\x20ON\x20THE\x20SAME\x20ROW\x20—\x20an\x20order\x27s\x20progress,\x20allocation\x20and\x20arb\x20cases\x20are\x20its\x20children\x20and\x20are\x20never\x20split\x20into\x20a\x20separate\x20flat\x20list)\x20|\x20buyer\x20address\x20chip.\x20'+'Close\x20with\x20the\x203\x20most\x20valuable\x20patterns\x20across\x20the\x20rows\x20(amount\x20distribution,\x20stuck\x20or\x20paused\x20orders,\x20dispute\x20rate).\x20Orders\x20only\x20—\x20do\x20not\x20re-analyze\x20the\x20Service\x20itself.';Q={'count':aC,'window_saturated':aD,'preview_truncated':aC>aE,'stats':{'scope_count':ar['length'],'scoped':ar['length']<aC,'amount_sum_raw':aA,'amount_sum_display':aB?.['display']??null,'amount_sum_tip':aB?.['tip']??null,'amount_known_count':at,'disputed_order_count':au,'allocation_pending_count':av,'allocation_allocated_count':aw,'allocation_none_count':ax,'first_created_ms':ay,'last_created_ms':az},...aC>aE?{'drilldown':{'total_count':aC,'analyzed_count':aE,'stats_scope_count':ar['length'],'prompt':aF}}:{},'items':aq};}catch{j['push']('recent_orders:\x20reverse-index\x20query\x20failed\x20(non-blocking)');}try{const b1=[m,l['machine'],l['buy_guard'],...l['allocator_guards']??[]]['filter'](Boolean);H=generateBusinessReport({'objects':b1,'machine_nodes':E['map'](b2=>({'name':b2['name']})),'machine_edges':C?.['edges']?C['edges']['map'](b2=>({'from':b2['from'],'to':b2['to']})):undefined,'orders':I['length']>0x0?I:undefined,'now_ms':Date['now']()});}catch{j['push']('business_report:\x20generation\x20failed\x20(non-blocking)');}const R=[];try{const b2=await query_affiliations({'address':k,'no_cache':!![],'network':h}),b3=new Set(),b4=new Map();for(const b6 of b2?.['entries']??[]){const b7=typeof b6?.['who']==='string'?b6['who']:'';if(!b7||b3['has'](b7))continue;b3['add'](b7);const b8=objectTypeFromAddress(b7);if(!b8)continue;if(b8===ObjectType['Order'])continue;const b9=String(b8);let ba=b4['get'](b9);!ba&&(ba=[],b4['set'](b9,ba)),ba['push']({'address':b7,'type_label':b9,'name':B(b7)['name'],'time':typeof b6?.['time']==='number'?b6['time']:null,'via':typeof b6?.['table']==='string'?b6['table']:null});}const b5=['Progress','Allocation','Payment','Guard'];for(const bb of b5){const bc=b4['get'](bb);bc&&bc['length']>0x0&&(R['push']({'type_label':bb,'items':bc}),b4['delete'](bb));}for(const [bd,be]of b4){if(be['length']>0x0)R['push']({'type_label':bd,'items':be});}}catch{j['push']('related:\x20global-table\x20lookup\x20failed\x20(non-blocking)');}const S=new Set(),T=bf=>{typeof bf==='string'&&/^0x[0-9a-fA-F]{40,64}$/['test'](bf)&&S['add'](bf['toLowerCase']());};T(m['buy_guard']);for(const bf of E){for(const bg of bf?.['pairs']??[]){for(const bh of bg?.['forwards']??[])T(bh?.['guard']);}}for(const bi of m['order_allocators']?.['allocators']??[])T(bi?.['guard']);for(const bj of l['allocator_guards']??[])T(bj?.['object']);for(const bk of Object['values'](l['referenced']??{})){const bl=bk;if(!bl||typeof bl!=='object')continue;if(bl['type']===ObjectType['Reward']){for(const bm of bl['guards']??[])T(bm?.['guard']);}if(bl['type']===ObjectType['Treasury']){for(const bn of bl['external_withdraw_guard']??[])T(bn?.['guard']);for(const bo of bl['external_deposit_guard']??[])T(bo?.['guard']);}(bl['type']===ObjectType['Arbitration']||bl['type']===ObjectType['Arb'])&&T(bl['voting_guard']);}const U=R['find'](bp=>bp['type_label']===String(ObjectType['Guard']));if(U){U['items']=U['items']['filter'](bp=>!S['has'](bp['address']['toLowerCase']()));if(U['items']['length']===0x0)R['splice'](R['indexOf'](U),0x1);else{const bp=U['items'];try{const bq=await batchQueryObjectsByIds(bp['map'](bs=>bs['address']),h,!![]),br=new Map();for(const bs of bq){if(bs?.['object'])br['set'](String(bs['object'])['toLowerCase'](),bs);}for(const bt of bp){const bu=br['get'](bt['address']['toLowerCase']());if(!bu){bt['explanation']=null;continue;}const bv=Array['isArray'](bu['table'])?bu['table']:[],bw=[];let bx=0x0;for(const bz of bv){if(bz?.['b_submission']===!![]){bx++;continue;}bz?.['value_type']==='Address'&&typeof bz?.['value']==='string'&&bz['value']['startsWith']('0x')&&bw['push'](bz['value']);}const by=bw['some'](bA=>bA['toLowerCase']()===k['toLowerCase']());bt['explanation']={'description':typeof bu['description']==='string'?bu['description']:null,'table_refs':bw,'references_this_service':by,'submission_slots':bx,'note':by?'One-off\x20verification\x20guard:\x20NOT\x20mounted\x20on\x20any\x20host\x20field;\x20its\x20table\x20carries\x20this\x20Service\x20as\x20an\x20on-chain\x20constant\x20(the\x20affiliation\x20is\x20written\x20at\x20creation).\x20It\x20acts\x20only\x20when\x20submitted\x20inside\x20a\x20passport\x20at\x20runtime.':'Guard\x20surfaced\x20by\x20the\x20affiliation\x20window\x20only;\x20not\x20mounted\x20on\x20any\x20host\x20field\x20reachable\x20from\x20this\x20panorama.\x20It\x20acts\x20only\x20when\x20referenced\x20at\x20runtime\x20(passport\x20submission\x20or\x20a\x20host\x20outside\x20this\x20view).'};}}catch{j['push']('related:\x20unbound-guard\x20explanation\x20unavailable\x20(non-blocking)');}}}const V=new Map();for(const bA of l['allocator_guards']??[]){const bB=bA;if(bB?.['object'])V['set'](String(bB['object'])['toLowerCase'](),bB);}const W=[];for(const bC of Array['isArray'](m['sales'])?m['sales']:[]){const bD=balanceStr(bC?.['price']),bE=await N(bD);W['push']({'name':typeof bC?.['name']==='string'?bC['name']:'','price':bD,'price_display':bE['display'],'price_tip':bE['tip'],'stock':balanceStr(bC?.['stock']),'suspension':bC?.['suspension']===!![],'wip':typeof bC?.['wip']==='string'?bC['wip']:'','wip_hash':typeof bC?.['wip_hash']==='string'?bC['wip_hash']:''});}const X=bF=>bF===0x0?'amount':bF===0x2?'surplus':'rate',Y=bF=>{const bG=bF?.['who'];if(bG&&typeof bG==='object'&&'Entity'in bG){const bH=bG['Entity'],bI=typeof bH==='string'?bH:typeof bH?.['name_or_address']==='string'?bH['name_or_address']:null;return{'who':bI?'Entity\x20'+bI:'Entity','entity':bI&&/^0x[0-9a-fA-F]{6,64}$/['test'](bI)?bI:null,'mode':X(bF?.['mode']),'value':balanceStr(bF?.['sharing'])};}if(bG&&typeof bG==='object'&&'GuardIdentifier'in bG)return{'who':'Guard\x20identifier\x20#'+bG['GuardIdentifier'],'entity':null,'mode':X(bF?.['mode']),'value':balanceStr(bF?.['sharing'])};return{'who':'Signer','entity':null,'mode':X(bF?.['mode']),'value':balanceStr(bF?.['sharing'])};},Z=m['order_allocators']?{'description':m['order_allocators']['description']??'','threshold':balanceStr(m['order_allocators']['threshold']),'allocators':(m['order_allocators']['allocators']??[])['map'](bF=>({'guard':bF['guard'],'sharing_count':Array['isArray'](bF['sharing'])?bF['sharing']['length']:0x0,'sharing':(Array['isArray'](bF['sharing'])?bF['sharing']:[])['map'](Y),'max':balanceStr(bF['max']??null),'guard_summary':summarizeGuard(V['get'](String(bF['guard']??'')['toLowerCase']()))}))}:null,a0=[];{const bF=new Map();for(const bG of m['order_allocators']?.['allocators']??[]){for(const bH of Array['isArray'](bG['sharing'])?bG['sharing']:[]){const bI=Y(bH);if(bI['entity']){const bJ=bI['entity']['toLowerCase'](),bK=bF['get'](bJ)??{'raw':bI['entity'],'guards':[]};bK['guards']['push'](bG['guard']??''),bF['set'](bJ,bK);}}}if(bF['size']>0x0)try{const bL=await batchQueryObjectsByIds([...bF['keys']()],h,!![]),bM=new Map();for(const bN of bL){if(bN?.['object'])bM['set'](String(bN['object'])['toLowerCase'](),bN);}for(const [bO,bP]of bF){const bQ=bM['get'](bO),bR='order_allocators\x20sharing\x20of\x20allocator\x20guard\x20'+bP['guards'][0x0];if(bQ&&bQ['permission']!==undefined){const bS=balanceStr(bQ['balance']),bT=await N(bS);a0['push']({'address':String(bQ['object']),'kind':'treasury','description':typeof bQ['description']==='string'?bQ['description']:null,'permission':typeof bQ['permission']==='string'?bQ['permission']:null,'balance':bS,'balance_display':bT['display'],'balance_tip':bT['tip'],'external_deposit_guard_count':Array['isArray'](bQ['external_deposit_guard'])?bQ['external_deposit_guard']['length']:null,'external_withdraw_guard_count':Array['isArray'](bQ['external_withdraw_guard'])?bQ['external_withdraw_guard']['length']:null,'via':bR});}else a0['push']({'address':bP['raw'],'kind':'account','description':null,'permission':null,'balance':null,'balance_display':null,'balance_tip':null,'external_deposit_guard_count':null,'external_withdraw_guard_count':null,'via':bR});}}catch{j['push']('income_recipients:\x20Sharing\x20entity\x20read\x20failed\x20(non-blocking)');}}const a1=summarizePermission(l['permission'],B(m['permission'])),a2=a1?.['owner']??F?.['sender']??null,a3=a2?await markOf(a2):null,a4=await N(balanceStr(m['compensation_fund'])),a5=projectExploration([],{'truncations':[],'budgetExhausted':{},'dataGaps':j});return{'action':'service_panorama','network':h,'service':{'address':k,'name':A,'description':m['description']??'','location':m['location']??'','published':m['bPublished']===!![],'paused':m['bPaused']===!![],'paused_time':typeof m['paused_time']==='number'?m['paused_time']:typeof m['paused_time']==='string'&&/^\d+$/['test'](m['paused_time'])?Number(m['paused_time']):null,'setting_lock_duration':balanceStr(m['setting_lock_duration']),'customer_required':Array['isArray'](m['customer_required'])?m['customer_required']:[],'compensation_fund':balanceStr(m['compensation_fund']),'compensation_fund_display':a4['display'],'compensation_fund_tip':a4['tip'],'sales':W,'machine':m['machine']??null,'buy_guard':m['buy_guard']??null,'permission':m['permission']??'','um':m['um']??null,'arbitrations':Array['isArray'](m['arbitrations'])?m['arbitrations']:[],'rewards':Array['isArray'](m['rewards'])?m['rewards']:[],'repositories':Array['isArray'](m['repositories'])?m['repositories']:[],'order_allocators':Z,'income_recipients':a0,'payment_token':{'coin_type':L,'guidance':M(L,h)},'onchain_last_updated':F,'tags':z['tags']??[],'owner':a2,'owner_name':a3?.['name']??null},'machine_graph':C,'buy_guard':summarizeGuard(l['buy_guard']),'permission':a1,'related':{'groups':R},'supply_chain':G,'business_report':H,'recent_orders':Q,'data_gaps':j,...a5['open_questions']['length']>0x0?{'exploration':a5}:{}};}
@@ -1 +1 @@
1
- import{Config,LocalMark,query_objects,query_serviceContext}from'@wowok/wowok';import{resolveAddress as a341a}from'../../tools/handlers/name-resolution.js';import{formatMoneyAnnotation}from'./facet-money.js';const balanceStr=a=>a===null||a===undefined?'0':typeof a==='bigint'?a['toString']():String(a);async function displayOf(a,b,c){try{return(await formatMoneyAnnotation(a,b,c))['display'];}catch{return a;}}function describeRecipient(a){if(typeof a==='string')return a;if(a&&typeof a==='object'){const b=a;if('GuardIdentifier'in b)return'submission\x20slot\x20'+String(b['GuardIdentifier']);if('Entity'in b){const c=b['Entity'],d=c&&typeof c==='object'?c['name_or_address']:c;return d===''?'Entity(\x22\x22)\x20—\x20MCP\x20default\x20local\x20account':'Entity:'+String(d);}return JSON['stringify'](a);}return'unknown';}export async function handleServiceQuote(a){const b=a['context_network']??undefined??await Config['Instance']()['network_get'](),c=await a341a(a['service_address'],'service_address'),d=await query_serviceContext({'service':c,'network':b}),f=d['service'];if(!f)throw new Error('Service\x20\x27'+a['service_address']+'\x27\x20not\x20found\x20on\x20network\x20'+b+'.');const h=f?.['type_raw']??f?.['type']??'',i=h['match'](/<(.+)>$/),j=i?i[0x1]:null,k=Array['isArray'](f['sales'])?f['sales']:[],l=new Map();for(const D of k){if(!D||typeof D['name']!=='string')continue;l['set'](D['name'],{'price':balanceStr(D['price']?.['balance']??D['price']??0x0),'suspended':D['suspension']===!![]});}const m=a['items']??[...l['keys']()]['map'](E=>({'name':E,'quantity':0x1})),n=m['filter'](E=>!l['has'](E['name']));if(n['length']>0x0)throw new Error('Sale(s)\x20not\x20found\x20on\x20this\x20Service:\x20'+n['map'](E=>'\x27'+E['name']+'\x27')['join'](',\x20')+'.\x20'+('Available\x20sales:\x20'+([...l['keys']()]['map'](E=>'\x27'+E+'\x27')['join'](',\x20')||'<none>')+'.'));if(m['length']===0x0)throw new Error('This\x20Service\x20has\x20NO\x20configured\x20sales\x20—\x20nothing\x20to\x20quote.');const o=[];let p=0x0n;for(const E of m){const F=l['get'](E['name']),G=BigInt(F['price']||'0'),H=G*BigInt(E['quantity']);p+=H,o['push']({'name':E['name'],'quantity':E['quantity'],'unit_price':F['price'],'unit_price_display':await displayOf(F['price'],j,b),'line_total':H['toString'](),'suspended':F['suspended']});}let q=p,t=null;if(typeof a['discount']==='string'&&a['discount']['trim']()!==''){const I=await a341a(a['discount'],'discount');let J=null;try{const U=await query_objects({'objects':[I],'network':b});J=U?.['objects']?.[0x0]??null;}catch{J=null;}if(!J)throw new Error('E_DISCOUNT_NOT_FOUND:\x20coupon\x20\x27'+I+'\x27\x20not\x20found\x20—\x20it\x20was\x20already\x20burned\x20on\x20a\x20'+'previous\x20buy\x20(a\x20burned\x20coupon\x20is\x20destroyed\x20on\x20chain\x20and\x20cannot\x20be\x20quoted\x20again)\x20'+'or\x20the\x20address\x20is\x20wrong.\x20Re-quote\x20without\x20the\x20coupon.');const K=String(J['service']??'');if(K['toLowerCase']()!==c['toLowerCase']())throw new Error('E_SERVICE_DISCOUNT_NOT_MATCH:\x20coupon\x20\x27'+I+'\x27\x20is\x20bound\x20to\x20service\x20'+((K||'<unparseable>')+',\x20not\x20to\x20'+c+'.\x20A\x20buy\x20with\x20this\x20coupon\x20aborts.'));const L=V=>{const W=balanceStr(V)['trim']();return/^\d+$/['test'](W)?BigInt(W):0x0n;},M=BigInt(Date['now']()),N=L(J['time_start']),O=L(J['time_end']);if(M<N||M>O)throw new Error('E_DISCOUNT_TIME_INVALID:\x20coupon\x20\x27'+I+'\x27\x20is\x20valid\x20'+(N+'–'+O+'\x20(ms\x20epoch),\x20now\x20is\x20'+M+'.\x20A\x20buy\x20with\x20this\x20coupon\x20aborts.'));const P=Number(J['discount_type'])===0x0,Q=L(J['off']),R=J['benchmark']===null||J['benchmark']===undefined?null:L(J['benchmark']),S=R===null?!![]:p>=R;let T=![];S&&(T=!![],q=P?p-p*Q/0x2710n:p>Q?p-Q:0x0n),t={'coupon':I,'name':typeof J['name']==='string'?J['name']:null,'type':P?'rates':'minus','off':Q['toString'](),'benchmark':R===null?null:R['toString'](),'benchmark_met':S,'applied':T,'list_total':p['toString'](),'final_total':q['toString'](),'final_total_display':await displayOf(q['toString'](),j,b),'note':T?'Discounted\x20total\x20shown\x20—\x20order_new.buy.total_pay.balance\x20must\x20equal\x20final_total.':'⚠\x20Benchmark\x20NOT\x20met\x20(list\x20total\x20'+p+'\x20<\x20'+R+'):\x20the\x20chain\x20REJECTS\x20this\x20buy\x20when\x20the\x20coupon\x20is\x20attached\x20(error\x2038\x20—\x20full\x20rollback,\x20nothing\x20paid,\x20coupon\x20preserved).\x20Raise\x20the\x20basket\x20to\x20>=\x20'+R+',\x20or\x20order\x20without\x20the\x20coupon\x20and\x20keep\x20it.'};}const u=await displayOf(q['toString'](),j,b),w=f['order_allocators'],x=Array['isArray'](w?.['allocators'])?w['allocators']:[],y=x['length']>0x0?x[0x0]:undefined,z=y?{'allocator_index':0x0,'note':'Sharing\x20rows\x20of\x20the\x20FIRST\x20order_allocator\x20(the\x20intended\x20normal\x20payout\x20path).\x20'+'Guards\x20select\x20per-case\x20allocators\x20(refund\x20/\x20damage\x20/\x20late-cancel),\x20so\x20the\x20LIVE\x20'+'split\x20depends\x20on\x20which\x20guard\x20passes\x20—\x20review\x20the\x20full\x20allocator\x20table\x20via\x20'+'service_panorama\x20before\x20ordering.','sharing':(Array['isArray'](y['sharing'])?y['sharing']:[])['map'](V=>({'recipient':describeRecipient(V?.['who']),'mode':typeof V?.['mode']==='string'?V['mode']:null,'value':balanceStr(V?.['sharing']?.['balance']??V?.['sharing']??0x0)}))}:null,A=Array['isArray'](f['rewards'])?f['rewards']['filter'](V=>typeof V==='string'&&V!==''):[];let B=null;if(A['length']>0x0){const V=[],W=[];let X=[];try{const Y=await query_objects({'objects':A,'network':b});X=Array['isArray'](Y?.['objects'])?Y['objects']:[];}catch(Z){V['push']('Reward\x20lookup\x20failed\x20('+(Z instanceof Error?Z['message']:String(Z))+')\x20—\x20reward\x20terms\x20NOT\x20verified;\x20do\x20not\x20rely\x20on\x20them.');}for(const a0 of A){const a1=X['find'](a8=>typeof a8?.['object']==='string'&&a8['object']['toLowerCase']()===a0['toLowerCase']());if(!a1){V['push']('Reward\x20\x27'+a0+'\x27\x20could\x20not\x20be\x20read\x20—\x20its\x20terms\x20are\x20unknown;\x20do\x20not\x20rely\x20on\x20it.');continue;}const a2=balanceStr(a1['balance']??0x0),a3=/^\d+$/['test'](a2)?BigInt(a2):0x0n,a4=[];let a5=0x0n,a6=![];for(const a8 of Array['isArray'](a1['guards'])?a1['guards']:[]){const a9=a8?.['amount'],aa=a9!=null&&(a9['type']===0x1||a9['type']==='Fixed'),ab=a8?.['expiration_time'],ac=ab==null?null:Number(ab),ad=ac!=null&&Number['isFinite'](ac)?ac:null;if(aa){const ae=balanceStr(a9['value']??0x0),af=/^\d+$/['test'](ae)?BigInt(ae):0x0n;if(af>a5)a5=af;a4['push']({'guard':String(a8?.['guard']??''),'amount_type':'fixed','amount':ae,'amount_display':await displayOf(ae,j,b),'expiration_time':ad,'expiration_display':ad!=null?new Date(ad)['toISOString']():null,'expired':ad!=null?Date['now']()>ad:null});}else a6=!![],a4['push']({'guard':String(a8?.['guard']??''),'amount_type':'guard_submission','amount':'submission\x20identifier\x20'+String(a9?.['value']??'?'),'amount_display':null,'expiration_time':ad,'expiration_display':ad!=null?new Date(ad)['toISOString']():null,'expired':ad!=null?Date['now']()>ad:null});}const a7=a3===0x0n?'Pool\x20is\x20EMPTY\x20—\x20any\x20claim\x20aborts\x20on-chain\x20(E_INSUFFICIENT_BALANCE);\x20do\x20not\x20budget\x20on\x20this\x20reward.':a6||a5===0x0n?null:'Pool\x20covers\x20~'+(a3/a5)['toString']()+'\x20further\x20claim(s)\x20at\x20the\x20largest\x20configured\x20per-claim\x20amount.';W['push']({'reward':a0,'description':typeof a1['description']==='string'?a1['description']:null,'pool_balance':a3['toString'](),'pool_balance_display':await displayOf(a3['toString'](),j,b),'record_count':Number['isFinite'](Number(a1['record_count']))?Number(a1['record_count']):0x0,'claims':a4,'coverage':a7});}B={'note':'Pre-order\x20reward\x20terms\x20for\x20every\x20Reward\x20hung\x20on\x20this\x20Service\x20(bound\x20at\x20build\x20time):\x20pool\x20balance,\x20'+'per-claim\x20amount\x20and\x20claim\x20windows.\x20A\x20claim\x20aborts\x20after\x20its\x20window\x20(E_GUARD_EXPIRED)\x20or\x20'+'against\x20an\x20empty\x20pool\x20(E_INSUFFICIENT_BALANCE)\x20—\x20never\x20budget\x20on\x20an\x20expired\x20or\x20empty\x20'+'reward.\x20Claiming\x20requires\x20passing\x20the\x20claim\x20guard\x27s\x20conditions.','rewards':W,'data_gaps':V};}let C=null;try{const ag=await LocalMark['Instance']()['list']({'address':c});C=ag?.[0x0]?.['name']??null;}catch{C=null;}return{'action':'service_quote','network':String(b),'service':{'address':c,'name':C},'payment_token':{'coin_type':j,'display_note':j?'Prices\x20and\x20the\x20order\x20total\x20are\x20denominated\x20in\x20this\x20token\x27s\x20smallest\x20units;\x20displays\x20convert\x20with\x20the\x20token\x27s\x20on-chain\x20precision.':'Payment\x20token\x20could\x20not\x20be\x20parsed\x20from\x20the\x20Service\x20type\x20—\x20raw\x20smallest\x20units\x20only,\x20precision\x20NOT\x20guessed.'},'items':o,'total_pay':{'balance':q['toString'](),'display':u,'note':t?.['applied']?'Discounted\x20total\x20—\x20order_new.buy.total_pay.balance\x20must\x20equal\x20this\x20exactly\x20(the\x20on-chain\x20buy\x20aborts\x20on\x20any\x20drift;\x20the\x20coupon\x20is\x20consumed\x20at\x20buy).':'order_new.buy.total_pay.balance\x20must\x20equal\x20this\x20exactly\x20when\x20passed\x20explicitly\x20—\x20the\x20on-chain\x20buy\x20aborts\x20on\x20any\x20drift.\x20WITHOUT\x20a\x20discount\x20you\x20may\x20also\x20omit\x20total_pay\x20entirely:\x20the\x20buy\x20auto-derives\x20this\x20exact\x20total\x20(M-K17).'},'discount':t,'allocation_preview':z,'reward_terms':B};}
1
+ import{Config,LocalMark,query_objects,query_serviceContext}from'@wowok/wowok';import{resolveAddress as a342a}from'../../tools/handlers/name-resolution.js';import{formatMoneyAnnotation}from'./facet-money.js';const balanceStr=a=>a===null||a===undefined?'0':typeof a==='bigint'?a['toString']():String(a);async function displayOf(a,b,c){try{return(await formatMoneyAnnotation(a,b,c))['display'];}catch{return a;}}function describeRecipient(a){if(typeof a==='string')return a;if(a&&typeof a==='object'){const b=a;if('GuardIdentifier'in b)return'submission\x20slot\x20'+String(b['GuardIdentifier']);if('Entity'in b){const c=b['Entity'],d=c&&typeof c==='object'?c['name_or_address']:c;return d===''?'Entity(\x22\x22)\x20—\x20MCP\x20default\x20local\x20account':'Entity:'+String(d);}return JSON['stringify'](a);}return'unknown';}export async function handleServiceQuote(a){const b=a['context_network']??undefined??await Config['Instance']()['network_get'](),c=await a342a(a['service_address'],'service_address'),d=await query_serviceContext({'service':c,'network':b}),f=d['service'];if(!f)throw new Error('Service\x20\x27'+a['service_address']+'\x27\x20not\x20found\x20on\x20network\x20'+b+'.');const h=f?.['type_raw']??f?.['type']??'',i=h['match'](/<(.+)>$/),j=i?i[0x1]:null,k=Array['isArray'](f['sales'])?f['sales']:[],l=new Map();for(const D of k){if(!D||typeof D['name']!=='string')continue;l['set'](D['name'],{'price':balanceStr(D['price']?.['balance']??D['price']??0x0),'suspended':D['suspension']===!![]});}const m=a['items']??[...l['keys']()]['map'](E=>({'name':E,'quantity':0x1})),n=m['filter'](E=>!l['has'](E['name']));if(n['length']>0x0)throw new Error('Sale(s)\x20not\x20found\x20on\x20this\x20Service:\x20'+n['map'](E=>'\x27'+E['name']+'\x27')['join'](',\x20')+'.\x20'+('Available\x20sales:\x20'+([...l['keys']()]['map'](E=>'\x27'+E+'\x27')['join'](',\x20')||'<none>')+'.'));if(m['length']===0x0)throw new Error('This\x20Service\x20has\x20NO\x20configured\x20sales\x20—\x20nothing\x20to\x20quote.');const o=[];let p=0x0n;for(const E of m){const F=l['get'](E['name']),G=BigInt(F['price']||'0'),H=G*BigInt(E['quantity']);p+=H,o['push']({'name':E['name'],'quantity':E['quantity'],'unit_price':F['price'],'unit_price_display':await displayOf(F['price'],j,b),'line_total':H['toString'](),'suspended':F['suspended']});}let q=p,t=null;if(typeof a['discount']==='string'&&a['discount']['trim']()!==''){const I=await a342a(a['discount'],'discount');let J=null;try{const U=await query_objects({'objects':[I],'network':b});J=U?.['objects']?.[0x0]??null;}catch{J=null;}if(!J)throw new Error('E_DISCOUNT_NOT_FOUND:\x20coupon\x20\x27'+I+'\x27\x20not\x20found\x20—\x20it\x20was\x20already\x20burned\x20on\x20a\x20'+'previous\x20buy\x20(a\x20burned\x20coupon\x20is\x20destroyed\x20on\x20chain\x20and\x20cannot\x20be\x20quoted\x20again)\x20'+'or\x20the\x20address\x20is\x20wrong.\x20Re-quote\x20without\x20the\x20coupon.');const K=String(J['service']??'');if(K['toLowerCase']()!==c['toLowerCase']())throw new Error('E_SERVICE_DISCOUNT_NOT_MATCH:\x20coupon\x20\x27'+I+'\x27\x20is\x20bound\x20to\x20service\x20'+((K||'<unparseable>')+',\x20not\x20to\x20'+c+'.\x20A\x20buy\x20with\x20this\x20coupon\x20aborts.'));const L=V=>{const W=balanceStr(V)['trim']();return/^\d+$/['test'](W)?BigInt(W):0x0n;},M=BigInt(Date['now']()),N=L(J['time_start']),O=L(J['time_end']);if(M<N||M>O)throw new Error('E_DISCOUNT_TIME_INVALID:\x20coupon\x20\x27'+I+'\x27\x20is\x20valid\x20'+(N+'–'+O+'\x20(ms\x20epoch),\x20now\x20is\x20'+M+'.\x20A\x20buy\x20with\x20this\x20coupon\x20aborts.'));const P=Number(J['discount_type'])===0x0,Q=L(J['off']),R=J['benchmark']===null||J['benchmark']===undefined?null:L(J['benchmark']),S=R===null?!![]:p>=R;let T=![];S&&(T=!![],q=P?p-p*Q/0x2710n:p>Q?p-Q:0x0n),t={'coupon':I,'name':typeof J['name']==='string'?J['name']:null,'type':P?'rates':'minus','off':Q['toString'](),'benchmark':R===null?null:R['toString'](),'benchmark_met':S,'applied':T,'list_total':p['toString'](),'final_total':q['toString'](),'final_total_display':await displayOf(q['toString'](),j,b),'note':T?q===0x0n?'ZERO-TOTAL\x20ORDER\x20(BKN-P2):\x20the\x20coupon\x20covers\x20the\x20entire\x20basket\x20—\x20the\x20chain\x20ACCEPTS\x20this\x20buy\x20'+'(final\x20clamp\x20is\x20chain\x20truth),\x20but\x20the\x20escrow\x20holds\x200\x20and\x20reward/incentive\x20rails\x20EXCLUDE\x20zero-total\x20'+'orders,\x20so\x20no\x20bounty\x20can\x20be\x20claimed\x20on\x20it.\x20A\x20deliberate\x20free\x20product\x20must\x20be\x20declared\x20explicitly\x20'+'(coupon\x20issued\x20with\x20allow_zero_total:\x20true);\x20otherwise\x20lower\x20the\x20coupon\x20value\x20so\x20the\x20final\x20total\x20'+'stays\x20>=\x201\x20smallest\x20unit.':'Discounted\x20total\x20shown\x20—\x20order_new.buy.total_pay.balance\x20must\x20equal\x20final_total.':'⚠\x20Benchmark\x20NOT\x20met\x20(list\x20total\x20'+p+'\x20<\x20'+R+'):\x20the\x20chain\x20REJECTS\x20this\x20buy\x20when\x20the\x20coupon\x20is\x20attached\x20(error\x2038\x20—\x20full\x20rollback,\x20nothing\x20paid,\x20coupon\x20preserved).\x20Raise\x20the\x20basket\x20to\x20>=\x20'+R+',\x20or\x20order\x20without\x20the\x20coupon\x20and\x20keep\x20it.'};}const u=await displayOf(q['toString'](),j,b),w=f['order_allocators'],x=Array['isArray'](w?.['allocators'])?w['allocators']:[],y=x['length']>0x0?x[0x0]:undefined,z=y?{'allocator_index':0x0,'note':'Sharing\x20rows\x20of\x20the\x20FIRST\x20order_allocator\x20(the\x20intended\x20normal\x20payout\x20path).\x20'+'Guards\x20select\x20per-case\x20allocators\x20(refund\x20/\x20damage\x20/\x20late-cancel),\x20so\x20the\x20LIVE\x20'+'split\x20depends\x20on\x20which\x20guard\x20passes\x20—\x20review\x20the\x20full\x20allocator\x20table\x20via\x20'+'service_panorama\x20before\x20ordering.','sharing':(Array['isArray'](y['sharing'])?y['sharing']:[])['map'](V=>({'recipient':describeRecipient(V?.['who']),'mode':typeof V?.['mode']==='string'?V['mode']:null,'value':balanceStr(V?.['sharing']?.['balance']??V?.['sharing']??0x0)}))}:null,A=Array['isArray'](f['rewards'])?f['rewards']['filter'](V=>typeof V==='string'&&V!==''):[];let B=null;if(A['length']>0x0){const V=[],W=[];let X=[];try{const Y=await query_objects({'objects':A,'network':b});X=Array['isArray'](Y?.['objects'])?Y['objects']:[];}catch(Z){V['push']('Reward\x20lookup\x20failed\x20('+(Z instanceof Error?Z['message']:String(Z))+')\x20—\x20reward\x20terms\x20NOT\x20verified;\x20do\x20not\x20rely\x20on\x20them.');}for(const a0 of A){const a1=X['find'](a8=>typeof a8?.['object']==='string'&&a8['object']['toLowerCase']()===a0['toLowerCase']());if(!a1){V['push']('Reward\x20\x27'+a0+'\x27\x20could\x20not\x20be\x20read\x20—\x20its\x20terms\x20are\x20unknown;\x20do\x20not\x20rely\x20on\x20it.');continue;}const a2=balanceStr(a1['balance']??0x0),a3=/^\d+$/['test'](a2)?BigInt(a2):0x0n,a4=[];let a5=0x0n,a6=![];for(const a8 of Array['isArray'](a1['guards'])?a1['guards']:[]){const a9=a8?.['amount'],aa=a9!=null&&(a9['type']===0x1||a9['type']==='Fixed'),ab=a8?.['expiration_time'],ac=ab==null?null:Number(ab),ad=ac!=null&&Number['isFinite'](ac)?ac:null;if(aa){const ae=balanceStr(a9['value']??0x0),af=/^\d+$/['test'](ae)?BigInt(ae):0x0n;if(af>a5)a5=af;a4['push']({'guard':String(a8?.['guard']??''),'amount_type':'fixed','amount':ae,'amount_display':await displayOf(ae,j,b),'expiration_time':ad,'expiration_display':ad!=null?new Date(ad)['toISOString']():null,'expired':ad!=null?Date['now']()>ad:null});}else a6=!![],a4['push']({'guard':String(a8?.['guard']??''),'amount_type':'guard_submission','amount':'submission\x20identifier\x20'+String(a9?.['value']??'?'),'amount_display':null,'expiration_time':ad,'expiration_display':ad!=null?new Date(ad)['toISOString']():null,'expired':ad!=null?Date['now']()>ad:null});}const a7=a3===0x0n?'Pool\x20is\x20EMPTY\x20—\x20any\x20claim\x20aborts\x20on-chain\x20(E_INSUFFICIENT_BALANCE);\x20do\x20not\x20budget\x20on\x20this\x20reward.':a6||a5===0x0n?null:'Pool\x20covers\x20~'+(a3/a5)['toString']()+'\x20further\x20claim(s)\x20at\x20the\x20largest\x20configured\x20per-claim\x20amount.';W['push']({'reward':a0,'description':typeof a1['description']==='string'?a1['description']:null,'pool_balance':a3['toString'](),'pool_balance_display':await displayOf(a3['toString'](),j,b),'record_count':Number['isFinite'](Number(a1['record_count']))?Number(a1['record_count']):0x0,'claims':a4,'coverage':a7});}B={'note':'Pre-order\x20reward\x20terms\x20for\x20every\x20Reward\x20hung\x20on\x20this\x20Service\x20(bound\x20at\x20build\x20time):\x20pool\x20balance,\x20'+'per-claim\x20amount\x20and\x20claim\x20windows.\x20A\x20claim\x20aborts\x20after\x20its\x20window\x20(E_GUARD_EXPIRED)\x20or\x20'+'against\x20an\x20empty\x20pool\x20(E_INSUFFICIENT_BALANCE)\x20—\x20never\x20budget\x20on\x20an\x20expired\x20or\x20empty\x20'+'reward.\x20Claiming\x20requires\x20passing\x20the\x20claim\x20guard\x27s\x20conditions.','rewards':W,'data_gaps':V};}let C=null;try{const ag=await LocalMark['Instance']()['list']({'address':c});C=ag?.[0x0]?.['name']??null;}catch{C=null;}return{'action':'service_quote','network':String(b),'service':{'address':c,'name':C},'payment_token':{'coin_type':j,'display_note':j?'Prices\x20and\x20the\x20order\x20total\x20are\x20denominated\x20in\x20this\x20token\x27s\x20smallest\x20units;\x20displays\x20convert\x20with\x20the\x20token\x27s\x20on-chain\x20precision.':'Payment\x20token\x20could\x20not\x20be\x20parsed\x20from\x20the\x20Service\x20type\x20—\x20raw\x20smallest\x20units\x20only,\x20precision\x20NOT\x20guessed.'},'items':o,'total_pay':{'balance':q['toString'](),'display':u,'note':t?.['applied']?'Discounted\x20total\x20—\x20order_new.buy.total_pay.balance\x20must\x20equal\x20this\x20exactly\x20(the\x20on-chain\x20buy\x20aborts\x20on\x20any\x20drift;\x20the\x20coupon\x20is\x20consumed\x20at\x20buy).':'order_new.buy.total_pay.balance\x20must\x20equal\x20this\x20exactly\x20when\x20passed\x20explicitly\x20—\x20the\x20on-chain\x20buy\x20aborts\x20on\x20any\x20drift.\x20WITHOUT\x20a\x20discount\x20you\x20may\x20also\x20omit\x20total_pay\x20entirely:\x20the\x20buy\x20auto-derives\x20this\x20exact\x20total\x20(M-K17).'},'discount':t,'allocation_preview':z,'reward_terms':B};}
@@ -1 +1 @@
1
- import{describe,it,expect,vi,beforeEach}from'vitest';const {sdkMocks}=vi['hoisted'](()=>({'sdkMocks':{'network_get':vi['fn'](),'localMarkList':vi['fn'](),'query_objects':vi['fn'](),'query_serviceContext':vi['fn'](),'resolveAddress':vi['fn']()}}));vi['mock']('@wowok/wowok',async a=>{const b=await a();return{...b,'Config':{'Instance':()=>({'network_get':sdkMocks['network_get']})},'LocalMark':{'Instance':()=>({'list':sdkMocks['localMarkList']})},'query_objects':sdkMocks['query_objects'],'query_serviceContext':sdkMocks['query_serviceContext']};}),vi['mock']('../../tools/handlers/name-resolution.js',()=>({'resolveAddress':sdkMocks['resolveAddress']})),vi['mock']('./facet-money.js',()=>({'formatMoneyAnnotation':async a=>({'display':a})}));import{handleServiceQuote}from'./service-quote.js';const SVC='0x'+'1'['repeat'](0x40),COUPON='0x'+'2'['repeat'](0x40),OTHER_SVC='0x'+'3'['repeat'](0x40),FLEXIBLE='Flexible\x20—\x20canal\x20view\x20double',LIST_TOTAL=0x35a4e900n;function makeCoupon(a={}){const b=Date['now']();return{'object':COUPON,'name':'bk3t-promo15','discount_type':0x0,'off':0x5dc,'benchmark':null,'time_start':b-0x5265c00,'time_end':b+0x5265c00,'service':SVC,'transferable':![],...a};}function quoteInput(a={}){return{'query_type':'service_quote','service_address':'bk3t-canal-stay','items':[{'name':FLEXIBLE,'quantity':0x1}],'context_network':'mainnet',...a};}beforeEach(()=>{vi['clearAllMocks'](),sdkMocks['network_get']['mockResolvedValue']('mainnet'),sdkMocks['localMarkList']['mockResolvedValue']([{'name':'bk3t-canal-stay'}]),sdkMocks['query_serviceContext']['mockResolvedValue']({'service':{'type_raw':'Service<0x2::wow::WOW>','sales':[{'name':FLEXIBLE,'price':{'balance':LIST_TOTAL['toString']()},'suspension':![]}]}}),sdkMocks['resolveAddress']['mockImplementation'](async a=>{if(a==='bk3t-canal-stay')return SVC;if(a==='bk3t-promo15'||a===COUPON)return COUPON;throw new Error('unresolvable:\x20'+a);}),sdkMocks['query_objects']['mockResolvedValue']({'objects':[makeCoupon()]});}),describe('service_quote\x20discount\x20pricing\x20(F-10)',()=>{it('no\x20discount\x20requested\x20→\x20undiscounted\x20total,\x20discount\x20block\x20null\x20(pre-fix\x20behavior\x20preserved)',async()=>{const a=await handleServiceQuote(quoteInput());expect(a['discount'])['toBeNull'](),expect(a['total_pay']['balance'])['toBe'](LIST_TOTAL['toString']());}),it('RATES\x20coupon\x20applies\x20with\x20integer\x20floor\x20division\x20—\x20reproduces\x20the\x20live\x20order\x20C\x20number',async()=>{const a=await handleServiceQuote(quoteInput({'discount':'bk3t-promo15'}));expect(a['discount'])['not']['toBeNull'](),expect(a['discount']['type'])['toBe']('rates'),expect(a['discount']['applied'])['toBe'](!![]),expect(a['discount']['list_total'])['toBe']('900000000'),expect(a['discount']['final_total'])['toBe']('765000000'),expect(a['total_pay']['balance'])['toBe']('765000000'),expect(a['total_pay']['note'])['toContain']('Discounted\x20total');}),it('MINUS\x20coupon\x20subtracts\x20a\x20fixed\x20amount\x20and\x20clamps\x20at\x20zero',async()=>{sdkMocks['query_objects']['mockResolvedValue']({'objects':[makeCoupon({'discount_type':0x1,'off':0x5f5e100})]});const a=await handleServiceQuote(quoteInput({'discount':COUPON}));expect(a['discount']['type'])['toBe']('minus'),expect(a['discount']['final_total'])['toBe']('800000000'),sdkMocks['query_objects']['mockResolvedValue']({'objects':[makeCoupon({'discount_type':0x1,'off':0x77359400})]});const b=await handleServiceQuote(quoteInput({'discount':COUPON}));expect(b['discount']['final_total'])['toBe']('0');}),it('unmet\x20benchmark\x20→\x20applied:false\x20+\x20attach\x20warning,\x20total\x20stays\x20at\x20list\x20price\x20(NOT\x20thrown)',async()=>{sdkMocks['query_objects']['mockResolvedValue']({'objects':[makeCoupon({'benchmark':(LIST_TOTAL+0x1n)['toString']()})]});const a=await handleServiceQuote(quoteInput({'discount':COUPON}));expect(a['discount']['applied'])['toBe'](![]),expect(a['discount']['benchmark_met'])['toBe'](![]),expect(a['total_pay']['balance'])['toBe'](LIST_TOTAL['toString']()),expect(a['discount']['note'])['toContain']('REJECTS'),expect(a['discount']['note'])['toContain']('coupon\x20preserved');}),it('benchmark\x20exactly\x20met\x20→\x20applies\x20(chain\x20uses\x20>=)',async()=>{sdkMocks['query_objects']['mockResolvedValue']({'objects':[makeCoupon({'benchmark':LIST_TOTAL['toString']()})]});const a=await handleServiceQuote(quoteInput({'discount':COUPON}));expect(a['discount']['applied'])['toBe'](!![]),expect(a['discount']['final_total'])['toBe']('765000000');}),it('benchmark\x20None\x20always\x20applies\x20(corrected\x20old\x20docs\x20claim)',async()=>{const a=await handleServiceQuote(quoteInput({'discount':COUPON}));expect(a['discount']['benchmark'])['toBeNull'](),expect(a['discount']['applied'])['toBe'](!![]);}),it('coupon\x20bound\x20to\x20another\x20service\x20→\x20rejected\x20like\x20the\x20chain\x20abort\x20(E_SERVICE_DISCOUNT_NOT_MATCH)',async()=>{sdkMocks['query_objects']['mockResolvedValue']({'objects':[makeCoupon({'service':OTHER_SVC})]}),await expect(handleServiceQuote(quoteInput({'discount':COUPON})))['rejects']['toThrow'](/E_SERVICE_DISCOUNT_NOT_MATCH/);}),it('coupon\x20outside\x20its\x20time\x20window\x20→\x20rejected\x20like\x20the\x20chain\x20abort\x20(E_DISCOUNT_TIME_INVALID)',async()=>{const a=Date['now']();sdkMocks['query_objects']['mockResolvedValue']({'objects':[makeCoupon({'time_start':a+0x3e8,'time_end':a+0x186a0})]}),await expect(handleServiceQuote(quoteInput({'discount':COUPON})))['rejects']['toThrow'](/E_DISCOUNT_TIME_INVALID/);}),it('unknown\x20coupon\x20object\x20→\x20clear\x20rejection,\x20never\x20a\x20silent\x20full-price\x20quote',async()=>{sdkMocks['query_objects']['mockResolvedValue']({'objects':[]}),await expect(handleServiceQuote(quoteInput({'discount':COUPON})))['rejects']['toThrow'](/not found/);});});const REWARD='0x'+'4'['repeat'](0x40),CLAIM_GUARD='0x'+'5'['repeat'](0x40);function makeReward(a={}){return{'object':REWARD,'description':'5-star\x20review\x20reward','balance':'500000000','record_count':0x3,'guards':[{'guard':CLAIM_GUARD,'amount':{'type':0x1,'value':'100000000'},'expiration_time':Date['now']()+0x5265c00}],...a};}function svcWithRewards(...a){sdkMocks['query_serviceContext']['mockResolvedValue']({'service':{'type_raw':'Service<0x2::wow::WOW>','sales':[{'name':FLEXIBLE,'price':{'balance':LIST_TOTAL['toString']()},'suspension':![]}],'rewards':a}});}describe('service_quote\x20reward\x20terms\x20(review\x20component\x20b2-5)',()=>{it('no\x20rewards\x20on\x20the\x20Service\x20→\x20reward_terms\x20null',async()=>{const a=await handleServiceQuote(quoteInput());expect(a['reward_terms'])['toBeNull']();}),it('fixed\x20amount\x20+\x20live\x20window\x20→\x20terms\x20with\x20coverage\x20estimate,\x20expired:false,\x20no\x20gaps',async()=>{svcWithRewards(REWARD),sdkMocks['query_objects']['mockResolvedValue']({'objects':[makeReward()]});const a=await handleServiceQuote(quoteInput());expect(a['reward_terms'])['not']['toBeNull']();const b=a['reward_terms']['rewards'][0x0];expect(b['reward'])['toBe'](REWARD),expect(b['description'])['toBe']('5-star\x20review\x20reward'),expect(b['pool_balance'])['toBe']('500000000'),expect(b['record_count'])['toBe'](0x3),expect(b['claims'][0x0]['guard'])['toBe'](CLAIM_GUARD),expect(b['claims'][0x0]['amount_type'])['toBe']('fixed'),expect(b['claims'][0x0]['amount'])['toBe']('100000000'),expect(b['claims'][0x0]['expired'])['toBe'](![]),expect(b['coverage'])['toMatch'](/~5 further claim/),expect(a['reward_terms']['data_gaps'])['toEqual']([]),expect(a['total_pay']['balance'])['toBe'](LIST_TOTAL['toString']());}),it('empty\x20pool\x20→\x20EMPTY\x20coverage\x20warning;\x20expired\x20window\x20→\x20expired:true',async()=>{svcWithRewards(REWARD),sdkMocks['query_objects']['mockResolvedValue']({'objects':[makeReward({'balance':'0','guards':[{'guard':CLAIM_GUARD,'amount':{'type':0x1,'value':'100000000'},'expiration_time':Date['now']()-0x3e8}]})]});const a=await handleServiceQuote(quoteInput()),b=a['reward_terms']['rewards'][0x0];expect(b['claims'][0x0]['expired'])['toBe'](!![]),expect(b['coverage'])['toContain']('EMPTY'),expect(b['coverage'])['toContain']('E_INSUFFICIENT_BALANCE');}),it('guard_submission\x20amount\x20→\x20coverage\x20null\x20(guard-decided),\x20amount\x20carries\x20the\x20submission\x20identifier',async()=>{svcWithRewards(REWARD),sdkMocks['query_objects']['mockResolvedValue']({'objects':[makeReward({'guards':[{'guard':CLAIM_GUARD,'amount':{'type':0x0,'value':0x7}}]})]});const a=await handleServiceQuote(quoteInput()),b=a['reward_terms']['rewards'][0x0];expect(b['claims'][0x0]['amount_type'])['toBe']('guard_submission'),expect(b['claims'][0x0]['amount'])['toContain']('7'),expect(b['claims'][0x0]['amount_display'])['toBeNull'](),expect(b['coverage'])['toBeNull']();}),it('no\x20window\x20set\x20→\x20expiration\x20null\x20and\x20expired\x20null\x20(claimable\x20until\x20guard\x20removal)',async()=>{svcWithRewards(REWARD),sdkMocks['query_objects']['mockResolvedValue']({'objects':[makeReward({'guards':[{'guard':CLAIM_GUARD,'amount':{'type':0x1,'value':'100000000'}}]})]});const a=await handleServiceQuote(quoteInput()),b=a['reward_terms']['rewards'][0x0]['claims'][0x0];expect(b['expiration_time'])['toBeNull'](),expect(b['expiration_display'])['toBeNull'](),expect(b['expired'])['toBeNull']();}),it('unreadable\x20reward\x20object\x20→\x20data_gaps\x20note,\x20quote\x20still\x20succeeds\x20(fail-soft)',async()=>{svcWithRewards(REWARD),sdkMocks['query_objects']['mockResolvedValue']({'objects':[]});const a=await handleServiceQuote(quoteInput());expect(a['reward_terms'])['not']['toBeNull'](),expect(a['reward_terms']['rewards'])['toEqual']([]),expect(a['reward_terms']['data_gaps'][0x0])['toContain'](REWARD),expect(a['total_pay']['balance'])['toBe'](LIST_TOTAL['toString']());}),it('reward\x20lookup\x20throws\x20→\x20whole\x20lookup\x20degrades\x20to\x20one\x20gap\x20note,\x20never\x20thrown',async()=>{svcWithRewards(REWARD),sdkMocks['query_objects']['mockRejectedValue'](new Error('rpc\x20down'));const a=await handleServiceQuote(quoteInput());expect(a['reward_terms']['rewards'])['toEqual']([]),expect(a['reward_terms']['data_gaps'][0x0])['toContain']('rpc\x20down'),expect(a['total_pay']['balance'])['toBe'](LIST_TOTAL['toString']());});});
1
+ import{describe,it,expect,vi,beforeEach}from'vitest';const {sdkMocks}=vi['hoisted'](()=>({'sdkMocks':{'network_get':vi['fn'](),'localMarkList':vi['fn'](),'query_objects':vi['fn'](),'query_serviceContext':vi['fn'](),'resolveAddress':vi['fn']()}}));vi['mock']('@wowok/wowok',async a=>{const b=await a();return{...b,'Config':{'Instance':()=>({'network_get':sdkMocks['network_get']})},'LocalMark':{'Instance':()=>({'list':sdkMocks['localMarkList']})},'query_objects':sdkMocks['query_objects'],'query_serviceContext':sdkMocks['query_serviceContext']};}),vi['mock']('../../tools/handlers/name-resolution.js',()=>({'resolveAddress':sdkMocks['resolveAddress']})),vi['mock']('./facet-money.js',()=>({'formatMoneyAnnotation':async a=>({'display':a})}));import{handleServiceQuote}from'./service-quote.js';const SVC='0x'+'1'['repeat'](0x40),COUPON='0x'+'2'['repeat'](0x40),OTHER_SVC='0x'+'3'['repeat'](0x40),FLEXIBLE='Flexible\x20—\x20canal\x20view\x20double',LIST_TOTAL=0x35a4e900n;function makeCoupon(a={}){const b=Date['now']();return{'object':COUPON,'name':'bk3t-promo15','discount_type':0x0,'off':0x5dc,'benchmark':null,'time_start':b-0x5265c00,'time_end':b+0x5265c00,'service':SVC,'transferable':![],...a};}function quoteInput(a={}){return{'query_type':'service_quote','service_address':'bk3t-canal-stay','items':[{'name':FLEXIBLE,'quantity':0x1}],'context_network':'mainnet',...a};}beforeEach(()=>{vi['clearAllMocks'](),sdkMocks['network_get']['mockResolvedValue']('mainnet'),sdkMocks['localMarkList']['mockResolvedValue']([{'name':'bk3t-canal-stay'}]),sdkMocks['query_serviceContext']['mockResolvedValue']({'service':{'type_raw':'Service<0x2::wow::WOW>','sales':[{'name':FLEXIBLE,'price':{'balance':LIST_TOTAL['toString']()},'suspension':![]}]}}),sdkMocks['resolveAddress']['mockImplementation'](async a=>{if(a==='bk3t-canal-stay')return SVC;if(a==='bk3t-promo15'||a===COUPON)return COUPON;throw new Error('unresolvable:\x20'+a);}),sdkMocks['query_objects']['mockResolvedValue']({'objects':[makeCoupon()]});}),describe('service_quote\x20discount\x20pricing\x20(F-10)',()=>{it('no\x20discount\x20requested\x20→\x20undiscounted\x20total,\x20discount\x20block\x20null\x20(pre-fix\x20behavior\x20preserved)',async()=>{const a=await handleServiceQuote(quoteInput());expect(a['discount'])['toBeNull'](),expect(a['total_pay']['balance'])['toBe'](LIST_TOTAL['toString']());}),it('RATES\x20coupon\x20applies\x20with\x20integer\x20floor\x20division\x20—\x20reproduces\x20the\x20live\x20order\x20C\x20number',async()=>{const a=await handleServiceQuote(quoteInput({'discount':'bk3t-promo15'}));expect(a['discount'])['not']['toBeNull'](),expect(a['discount']['type'])['toBe']('rates'),expect(a['discount']['applied'])['toBe'](!![]),expect(a['discount']['list_total'])['toBe']('900000000'),expect(a['discount']['final_total'])['toBe']('765000000'),expect(a['total_pay']['balance'])['toBe']('765000000'),expect(a['total_pay']['note'])['toContain']('Discounted\x20total');}),it('MINUS\x20coupon\x20subtracts\x20a\x20fixed\x20amount\x20and\x20clamps\x20at\x20zero',async()=>{sdkMocks['query_objects']['mockResolvedValue']({'objects':[makeCoupon({'discount_type':0x1,'off':0x5f5e100})]});const a=await handleServiceQuote(quoteInput({'discount':COUPON}));expect(a['discount']['type'])['toBe']('minus'),expect(a['discount']['final_total'])['toBe']('800000000'),sdkMocks['query_objects']['mockResolvedValue']({'objects':[makeCoupon({'discount_type':0x1,'off':0x77359400})]});const b=await handleServiceQuote(quoteInput({'discount':COUPON}));expect(b['discount']['final_total'])['toBe']('0'),expect(b['discount']['note'])['toContain']('ZERO-TOTAL\x20ORDER'),expect(b['discount']['note'])['toContain']('allow_zero_total'),expect(b['discount']['note'])['toContain']('EXCLUDE\x20zero-total'),sdkMocks['query_objects']['mockResolvedValue']({'objects':[makeCoupon({'discount_type':0x1,'off':0x5f5e100})]});const c=await handleServiceQuote(quoteInput({'discount':COUPON}));expect(c['discount']['note'])['toBe']('Discounted\x20total\x20shown\x20—\x20order_new.buy.total_pay.balance\x20must\x20equal\x20final_total.');}),it('unmet\x20benchmark\x20→\x20applied:false\x20+\x20attach\x20warning,\x20total\x20stays\x20at\x20list\x20price\x20(NOT\x20thrown)',async()=>{sdkMocks['query_objects']['mockResolvedValue']({'objects':[makeCoupon({'benchmark':(LIST_TOTAL+0x1n)['toString']()})]});const a=await handleServiceQuote(quoteInput({'discount':COUPON}));expect(a['discount']['applied'])['toBe'](![]),expect(a['discount']['benchmark_met'])['toBe'](![]),expect(a['total_pay']['balance'])['toBe'](LIST_TOTAL['toString']()),expect(a['discount']['note'])['toContain']('REJECTS'),expect(a['discount']['note'])['toContain']('coupon\x20preserved');}),it('benchmark\x20exactly\x20met\x20→\x20applies\x20(chain\x20uses\x20>=)',async()=>{sdkMocks['query_objects']['mockResolvedValue']({'objects':[makeCoupon({'benchmark':LIST_TOTAL['toString']()})]});const a=await handleServiceQuote(quoteInput({'discount':COUPON}));expect(a['discount']['applied'])['toBe'](!![]),expect(a['discount']['final_total'])['toBe']('765000000');}),it('benchmark\x20None\x20always\x20applies\x20(corrected\x20old\x20docs\x20claim)',async()=>{const a=await handleServiceQuote(quoteInput({'discount':COUPON}));expect(a['discount']['benchmark'])['toBeNull'](),expect(a['discount']['applied'])['toBe'](!![]);}),it('coupon\x20bound\x20to\x20another\x20service\x20→\x20rejected\x20like\x20the\x20chain\x20abort\x20(E_SERVICE_DISCOUNT_NOT_MATCH)',async()=>{sdkMocks['query_objects']['mockResolvedValue']({'objects':[makeCoupon({'service':OTHER_SVC})]}),await expect(handleServiceQuote(quoteInput({'discount':COUPON})))['rejects']['toThrow'](/E_SERVICE_DISCOUNT_NOT_MATCH/);}),it('coupon\x20outside\x20its\x20time\x20window\x20→\x20rejected\x20like\x20the\x20chain\x20abort\x20(E_DISCOUNT_TIME_INVALID)',async()=>{const a=Date['now']();sdkMocks['query_objects']['mockResolvedValue']({'objects':[makeCoupon({'time_start':a+0x3e8,'time_end':a+0x186a0})]}),await expect(handleServiceQuote(quoteInput({'discount':COUPON})))['rejects']['toThrow'](/E_DISCOUNT_TIME_INVALID/);}),it('unknown\x20coupon\x20object\x20→\x20clear\x20rejection,\x20never\x20a\x20silent\x20full-price\x20quote',async()=>{sdkMocks['query_objects']['mockResolvedValue']({'objects':[]}),await expect(handleServiceQuote(quoteInput({'discount':COUPON})))['rejects']['toThrow'](/not found/);});});const REWARD='0x'+'4'['repeat'](0x40),CLAIM_GUARD='0x'+'5'['repeat'](0x40);function makeReward(a={}){return{'object':REWARD,'description':'5-star\x20review\x20reward','balance':'500000000','record_count':0x3,'guards':[{'guard':CLAIM_GUARD,'amount':{'type':0x1,'value':'100000000'},'expiration_time':Date['now']()+0x5265c00}],...a};}function svcWithRewards(...a){sdkMocks['query_serviceContext']['mockResolvedValue']({'service':{'type_raw':'Service<0x2::wow::WOW>','sales':[{'name':FLEXIBLE,'price':{'balance':LIST_TOTAL['toString']()},'suspension':![]}],'rewards':a}});}describe('service_quote\x20reward\x20terms\x20(review\x20component\x20b2-5)',()=>{it('no\x20rewards\x20on\x20the\x20Service\x20→\x20reward_terms\x20null',async()=>{const a=await handleServiceQuote(quoteInput());expect(a['reward_terms'])['toBeNull']();}),it('fixed\x20amount\x20+\x20live\x20window\x20→\x20terms\x20with\x20coverage\x20estimate,\x20expired:false,\x20no\x20gaps',async()=>{svcWithRewards(REWARD),sdkMocks['query_objects']['mockResolvedValue']({'objects':[makeReward()]});const a=await handleServiceQuote(quoteInput());expect(a['reward_terms'])['not']['toBeNull']();const b=a['reward_terms']['rewards'][0x0];expect(b['reward'])['toBe'](REWARD),expect(b['description'])['toBe']('5-star\x20review\x20reward'),expect(b['pool_balance'])['toBe']('500000000'),expect(b['record_count'])['toBe'](0x3),expect(b['claims'][0x0]['guard'])['toBe'](CLAIM_GUARD),expect(b['claims'][0x0]['amount_type'])['toBe']('fixed'),expect(b['claims'][0x0]['amount'])['toBe']('100000000'),expect(b['claims'][0x0]['expired'])['toBe'](![]),expect(b['coverage'])['toMatch'](/~5 further claim/),expect(a['reward_terms']['data_gaps'])['toEqual']([]),expect(a['total_pay']['balance'])['toBe'](LIST_TOTAL['toString']());}),it('empty\x20pool\x20→\x20EMPTY\x20coverage\x20warning;\x20expired\x20window\x20→\x20expired:true',async()=>{svcWithRewards(REWARD),sdkMocks['query_objects']['mockResolvedValue']({'objects':[makeReward({'balance':'0','guards':[{'guard':CLAIM_GUARD,'amount':{'type':0x1,'value':'100000000'},'expiration_time':Date['now']()-0x3e8}]})]});const a=await handleServiceQuote(quoteInput()),b=a['reward_terms']['rewards'][0x0];expect(b['claims'][0x0]['expired'])['toBe'](!![]),expect(b['coverage'])['toContain']('EMPTY'),expect(b['coverage'])['toContain']('E_INSUFFICIENT_BALANCE');}),it('guard_submission\x20amount\x20→\x20coverage\x20null\x20(guard-decided),\x20amount\x20carries\x20the\x20submission\x20identifier',async()=>{svcWithRewards(REWARD),sdkMocks['query_objects']['mockResolvedValue']({'objects':[makeReward({'guards':[{'guard':CLAIM_GUARD,'amount':{'type':0x0,'value':0x7}}]})]});const a=await handleServiceQuote(quoteInput()),b=a['reward_terms']['rewards'][0x0];expect(b['claims'][0x0]['amount_type'])['toBe']('guard_submission'),expect(b['claims'][0x0]['amount'])['toContain']('7'),expect(b['claims'][0x0]['amount_display'])['toBeNull'](),expect(b['coverage'])['toBeNull']();}),it('no\x20window\x20set\x20→\x20expiration\x20null\x20and\x20expired\x20null\x20(claimable\x20until\x20guard\x20removal)',async()=>{svcWithRewards(REWARD),sdkMocks['query_objects']['mockResolvedValue']({'objects':[makeReward({'guards':[{'guard':CLAIM_GUARD,'amount':{'type':0x1,'value':'100000000'}}]})]});const a=await handleServiceQuote(quoteInput()),b=a['reward_terms']['rewards'][0x0]['claims'][0x0];expect(b['expiration_time'])['toBeNull'](),expect(b['expiration_display'])['toBeNull'](),expect(b['expired'])['toBeNull']();}),it('unreadable\x20reward\x20object\x20→\x20data_gaps\x20note,\x20quote\x20still\x20succeeds\x20(fail-soft)',async()=>{svcWithRewards(REWARD),sdkMocks['query_objects']['mockResolvedValue']({'objects':[]});const a=await handleServiceQuote(quoteInput());expect(a['reward_terms'])['not']['toBeNull'](),expect(a['reward_terms']['rewards'])['toEqual']([]),expect(a['reward_terms']['data_gaps'][0x0])['toContain'](REWARD),expect(a['total_pay']['balance'])['toBe'](LIST_TOTAL['toString']());}),it('reward\x20lookup\x20throws\x20→\x20whole\x20lookup\x20degrades\x20to\x20one\x20gap\x20note,\x20never\x20thrown',async()=>{svcWithRewards(REWARD),sdkMocks['query_objects']['mockRejectedValue'](new Error('rpc\x20down'));const a=await handleServiceQuote(quoteInput());expect(a['reward_terms']['rewards'])['toEqual']([]),expect(a['reward_terms']['data_gaps'][0x0])['toContain']('rpc\x20down'),expect(a['total_pay']['balance'])['toBe'](LIST_TOTAL['toString']());});});
@@ -1 +1 @@
1
- import{objectTypeFromAddress,ObjectType}from'@wowok/wowok';import{resolveAddress as a354a}from'../tools/handlers/name-resolution.js';import{handleObjectPanorama}from'../playbooks/service-build/object-panorama.js';import{handleServicePanorama}from'../playbooks/service-build/service-panorama.js';import{handleMachinePanorama}from'../playbooks/service-build/machine-panorama.js';import{assembleOrderReview}from'./order.js';import{assembleServiceReview}from'./service.js';import{assembleMachineReview}from'./machine.js';import{assembleArbReview}from'./arb.js';import{assembleDemandReview}from'./demand.js';import{assembleRepositoryReview}from'./repository.js';import{assembleProgressReview}from'./progress.js';export const REVIEW_PACK_TYPES=['Order','Service','Arb','Demand','Repository','Progress','Machine'];export async function handleReviewPack(a){const b=a['object_address'];if(!b)throw new Error('\x27object_address\x27\x20is\x20required\x20for\x20review_pack');const c=await a354a(b,'object_address'),d=objectTypeFromAddress(c);if(d===ObjectType['Order']){const g=await handleObjectPanorama(a);if(g['object_type']!=='Order')throw new Error('review_pack:\x20expected\x20an\x20Order,\x20resolved\x20to\x20'+g['object_type']);return assembleOrderReview(g);}if(d===ObjectType['Service']){const h=await handleServicePanorama({...a,'service_address':c});return assembleServiceReview(h);}if(d===ObjectType['Machine']){const i=await handleMachinePanorama({...a,'object_address':c});if(i['machineAddress']?.['toLowerCase']()!==c['toLowerCase']())throw new Error('review_pack:\x20expected\x20a\x20Machine,\x20resolved\x20to\x20'+i['machineAddress']);return assembleMachineReview(i);}const e={[ObjectType['Arb']]:assembleArbReview,[ObjectType['Demand']]:assembleDemandReview,[ObjectType['Repository']]:assembleRepositoryReview,[ObjectType['Progress']]:assembleProgressReview},f=d?e[d]:undefined;if(f){const j=await handleObjectPanorama(a);if(j['object_type']!==d)throw new Error('review_pack:\x20expected\x20a\x20'+d+',\x20resolved\x20to\x20'+j['object_type']);return f(j);}throw new Error('review_pack:\x20unsupported\x20object\x20type\x20\x27'+(d??'unknown')+'\x27\x20—\x20supported:\x20'+REVIEW_PACK_TYPES['join'](',\x20')+'.\x20Other\x20types\x20keep\x20object_panorama\x20/\x20machine_panorama\x20/\x20service_panorama.');}
1
+ import{objectTypeFromAddress,ObjectType}from'@wowok/wowok';import{resolveAddress as a355a}from'../tools/handlers/name-resolution.js';import{handleObjectPanorama}from'../playbooks/service-build/object-panorama.js';import{handleServicePanorama}from'../playbooks/service-build/service-panorama.js';import{handleMachinePanorama}from'../playbooks/service-build/machine-panorama.js';import{assembleOrderReview}from'./order.js';import{assembleServiceReview}from'./service.js';import{assembleMachineReview}from'./machine.js';import{assembleArbReview}from'./arb.js';import{assembleDemandReview}from'./demand.js';import{assembleRepositoryReview}from'./repository.js';import{assembleProgressReview}from'./progress.js';export const REVIEW_PACK_TYPES=['Order','Service','Arb','Demand','Repository','Progress','Machine'];export async function handleReviewPack(a){const b=a['object_address'];if(!b)throw new Error('\x27object_address\x27\x20is\x20required\x20for\x20review_pack');const c=await a355a(b,'object_address'),d=objectTypeFromAddress(c);if(d===ObjectType['Order']){const g=await handleObjectPanorama(a);if(g['object_type']!=='Order')throw new Error('review_pack:\x20expected\x20an\x20Order,\x20resolved\x20to\x20'+g['object_type']);return assembleOrderReview(g);}if(d===ObjectType['Service']){const h=await handleServicePanorama({...a,'service_address':c});return assembleServiceReview(h);}if(d===ObjectType['Machine']){const i=await handleMachinePanorama({...a,'object_address':c});if(i['machineAddress']?.['toLowerCase']()!==c['toLowerCase']())throw new Error('review_pack:\x20expected\x20a\x20Machine,\x20resolved\x20to\x20'+i['machineAddress']);return assembleMachineReview(i);}const e={[ObjectType['Arb']]:assembleArbReview,[ObjectType['Demand']]:assembleDemandReview,[ObjectType['Repository']]:assembleRepositoryReview,[ObjectType['Progress']]:assembleProgressReview},f=d?e[d]:undefined;if(f){const j=await handleObjectPanorama(a);if(j['object_type']!==d)throw new Error('review_pack:\x20expected\x20a\x20'+d+',\x20resolved\x20to\x20'+j['object_type']);return f(j);}throw new Error('review_pack:\x20unsupported\x20object\x20type\x20\x27'+(d??'unknown')+'\x27\x20—\x20supported:\x20'+REVIEW_PACK_TYPES['join'](',\x20')+'.\x20Other\x20types\x20keep\x20object_panorama\x20/\x20machine_panorama\x20/\x20service_panorama.');}
@@ -1 +1 @@
1
- import{CONFIRMATION_RULES,resolveOverrideId}from'../knowledge/safety-rules.js';import{isEnabled as a369a}from'../config/index.js';import{isPlanPreapproved}from'../goal/plan-approval.js';export function isConfirmGateEnabled(){return a369a('confirm_gate');}const internalErrorCounts={};function logInternalError(a,b){const c=a;internalErrorCounts[c]=(internalErrorCounts[c]??0x0)+0x1;const d=internalErrorCounts[c];console['warn']('[ConfirmGate]\x20internal_error\x20context=\x22'+a+'\x22\x20count='+d+'\x20error='+(b instanceof Error?b['message']:String(b)));}export function getFailMode(a){switch(a){case'irreversible':case'publish':case'amount':return'closed';case'standard':case'none':default:return'open';}}function buildInternalErrorResult(a,b,c){const d=b instanceof Error?b['message']:b!==undefined?String(b):undefined;return{'pass':![],'level':'irreversible','preview':{'level':'irreversible','operation':a,'irreversible':!![],'warnings':[...c?['ConfirmGate\x20rule\x20\x27'+c+'\x27\x20matched\x20but\x20its\x20preview\x20could\x20not\x20be\x20generated.']:['An\x20error\x20occurred\x20while\x20matching\x20confirmation\x20rules.'],...d!==undefined?['Reason:\x20'+d]:[],'The\x20operation\x20was\x20NOT\x20executed.\x20Review\x20the\x20parameters\x20for\x20malformed\x20values\x20(e.g.\x20decimal\x20amounts\x20instead\x20of\x20smallest-unit\x20integers)\x20before\x20confirming.']},'rule_id':'internal_error'};}export function confirmGate(a,b,c,d,f,g){if(!isConfirmGateEnabled())return{'pass':!![]};if(c?.['confirmed']===!![])return{'pass':!![]};if(c?.['dry_run']===!![])return{'pass':!![]};let h,i=null;try{h=CONFIRMATION_RULES['find'](n=>{try{return n['when'](a,b,c);}catch(o){logInternalError('rule_when:'+n['id'],o);if(getFailMode(n['level'])==='closed')throw o;return![];}});}catch(n){i=n;}if(i)return logInternalError('rule_search',i),buildInternalErrorResult(a,i);if(!h)return{'pass':!![]};if(getFailMode(h['level'])==='open'&&isPlanPreapproved(c))return{'pass':!![]};const j=resolveOverrideId(h['id'],a),k=j?f?.[j]:undefined;if(k==='auto')return{'pass':!![]};const l=c?.['confirm_mode']==='quiet'||c?.['confirm_mode']==='streamlined'?c['confirm_mode']:'full';if(l!=='full'&&k!=='block'&&getFailMode(h['level'])==='open')return{'pass':!![]};if(k!=='block'&&g?.['intent_bypass']!==![]&&h['bypass_on_explicit_intent']&&d&&d['length']>0x0){const o=d['map'](q=>q['toLowerCase']()),p=h['bypass_on_explicit_intent']['some'](q=>o['some'](r=>r['includes'](q['toLowerCase']())));if(p)return{'pass':!![]};}let m;try{m=h['preview'](a,b,c);}catch(q){logInternalError('rule_preview:'+h['id'],q);if(getFailMode(h['level'])==='closed')return buildInternalErrorResult(a,q,h['id']);return{'pass':!![]};}return{'pass':![],'level':h['level'],'preview':m,'rule_id':h['id']};}export function isExplicitlyConfirmed(a){return a?.['confirmed']===!![];}
1
+ import{CONFIRMATION_RULES,resolveOverrideId}from'../knowledge/safety-rules.js';import{isEnabled as a370a}from'../config/index.js';import{isPlanPreapproved}from'../goal/plan-approval.js';export function isConfirmGateEnabled(){return a370a('confirm_gate');}const internalErrorCounts={};function logInternalError(a,b){const c=a;internalErrorCounts[c]=(internalErrorCounts[c]??0x0)+0x1;const d=internalErrorCounts[c];console['warn']('[ConfirmGate]\x20internal_error\x20context=\x22'+a+'\x22\x20count='+d+'\x20error='+(b instanceof Error?b['message']:String(b)));}export function getFailMode(a){switch(a){case'irreversible':case'publish':case'amount':return'closed';case'standard':case'none':default:return'open';}}function buildInternalErrorResult(a,b,c){const d=b instanceof Error?b['message']:b!==undefined?String(b):undefined;return{'pass':![],'level':'irreversible','preview':{'level':'irreversible','operation':a,'irreversible':!![],'warnings':[...c?['ConfirmGate\x20rule\x20\x27'+c+'\x27\x20matched\x20but\x20its\x20preview\x20could\x20not\x20be\x20generated.']:['An\x20error\x20occurred\x20while\x20matching\x20confirmation\x20rules.'],...d!==undefined?['Reason:\x20'+d]:[],'The\x20operation\x20was\x20NOT\x20executed.\x20Review\x20the\x20parameters\x20for\x20malformed\x20values\x20(e.g.\x20decimal\x20amounts\x20instead\x20of\x20smallest-unit\x20integers)\x20before\x20confirming.']},'rule_id':'internal_error'};}function emitGuardQuietNotice(a,b,c,d,f){try{const g=f['preview'](a,b,c),h=['[ConfirmGate]\x20guard\x20CREATE\x20proceeded\x20WITHOUT\x20interactive\x20confirmation\x20(confirm_mode:\x20'+d+').','\x20\x20Object:\x20'+String(g['object']??'(unnamed)')+'\x20\x20Network:\x20'+String(g['network']??'?'),...(g['warnings']??[])['map'](i=>'\x20\x20-\x20'+i),'\x20\x20Immutable\x20after\x20creation\x20—\x20changes\x20require\x20a\x20NEW\x20guard\x20+\x20rebind.\x20Verify\x20with\x20analyze_guard_semantics\x20after\x20creation.'];console['warn'](h['join']('\x0a'));}catch(i){console['warn']('[ConfirmGate]\x20guard\x20CREATE\x20proceeded\x20in\x20'+d+'\x20mode\x20(manifest\x20unavailable:\x20'+(i instanceof Error?i['message']:String(i))+')');}}export function confirmGate(a,b,c,d,f,g){if(!isConfirmGateEnabled())return{'pass':!![]};if(c?.['confirmed']===!![])return{'pass':!![]};if(c?.['dry_run']===!![])return{'pass':!![]};let h,i=null;try{h=CONFIRMATION_RULES['find'](n=>{try{return n['when'](a,b,c);}catch(o){logInternalError('rule_when:'+n['id'],o);if(getFailMode(n['level'])==='closed')throw o;return![];}});}catch(n){i=n;}if(i)return logInternalError('rule_search',i),buildInternalErrorResult(a,i);if(!h)return{'pass':!![]};if(getFailMode(h['level'])==='open'&&isPlanPreapproved(c))return{'pass':!![]};const j=resolveOverrideId(h['id'],a),k=j?f?.[j]:undefined;if(k==='auto')return{'pass':!![]};const l=c?.['confirm_mode']==='quiet'||c?.['confirm_mode']==='streamlined'?c['confirm_mode']:'full';if(l!=='full'&&k!=='block'&&getFailMode(h['level'])==='open')return{'pass':!![]};if(h['id']==='guard_create_immutable'&&l!=='full'&&k!=='block')return emitGuardQuietNotice(a,b,c,l,h),{'pass':!![]};if(k!=='block'&&g?.['intent_bypass']!==![]&&h['bypass_on_explicit_intent']&&d&&d['length']>0x0){const o=d['map'](q=>q['toLowerCase']()),p=h['bypass_on_explicit_intent']['some'](q=>o['some'](r=>r['includes'](q['toLowerCase']())));if(p)return{'pass':!![]};}let m;try{m=h['preview'](a,b,c);}catch(q){logInternalError('rule_preview:'+h['id'],q);if(getFailMode(h['level'])==='closed')return buildInternalErrorResult(a,q,h['id']);return{'pass':!![]};}return{'pass':![],'level':h['level'],'preview':m,'rule_id':h['id']};}export function isExplicitlyConfirmed(a){return a?.['confirmed']===!![];}
@@ -1,3 +1,4 @@
1
1
  import type { OperationPreview } from "../knowledge/safety-rules.js";
2
+ export declare const CONFIRMATION_REQUIRED_OPERATIONS: string[];
2
3
  export declare function renderPreview(p: OperationPreview): string;
3
4
  export declare function renderPreviewHuman(p: OperationPreview): string;
@@ -1 +1 @@
1
- import{formatShortAddress}from'../persona/address-format.js';const LEVEL_LABEL={'none':'none','standard':'Standard\x20confirmation','amount':'Amount\x20confirmation','publish':'Publish\x20confirmation\x20(irreversible\x20lock)','irreversible':'Irreversible\x20operation\x20confirmation'},CONFIRMATION_REQUIRED_OPERATIONS=['guard\x20(CREATE\x20—\x20immutable,\x20cannot\x20be\x20edited\x20or\x20deleted)','service\x20(publish=true\x20—\x20locks\x20machine/order_allocators)','machine\x20(publish=true\x20—\x20locks\x20nodes/pairs/forwards)','arbitration\x20(verdict\x20—\x20irreversible)','payment\x20(send/receive\x20—\x20irreversible)','treasury\x20(withdraw/external_withdraw/external_deposit\x20—\x20irreversible)','reward\x20coin_add\x20/\x20treasury\x20deposit\x20/\x20allocation\x20funding\x20/\x20arbitration\x20fee\x20/\x20service\x20compensation_fund_add\x20/\x20service\x20order_new\x20payment\x20(amount-sensitive)','progress\x20(node\x20advance\x20—\x20may\x20release\x20funds;\x20owner_receive\x20—\x20fund\x20claim)','gen_passport\x20(gas-consuming\x20test)'];export function renderPreview(a){const b=[];b['push']('⚠️\x20\x20Confirmation\x20required\x20—\x20'+LEVEL_LABEL[a['level']]),b['push']('\x20\x20Operation:\x20'+a['operation']);a['object']&&b['push']('\x20\x20Object:\x20'+(typeof a['object']==='string'?a['object']:JSON['stringify'](a['object'])));if(a['network'])b['push']('\x20\x20Network:\x20'+a['network']);if(a['account']!==undefined)b['push']('\x20\x20Account:\x20'+(a['account']===''?'(default)':a['account']));a['amount']&&b['push']('\x20\x20Amount:\x20'+a['amount']['human_readable']+'\x20('+a['amount']['value']+'\x20smallest\x20unit)'+(a['amount']['recipient']?'\x20→\x20'+a['amount']['recipient']:''));a['immutable_after']&&a['immutable_after']['length']>0x0&&b['push']('\x20\x20Fields\x20becoming\x20immutable:\x20'+a['immutable_after']['join'](',\x20'));if(a['warnings']&&a['warnings']['length']>0x0){b['push']('\x20\x20Warnings:');for(const c of a['warnings'])b['push']('\x20\x20\x20\x20-\x20'+c);}a['irreversible']&&b['push']('\x20\x20⛔\x20This\x20operation\x20is\x20IRREVERSIBLE.\x20It\x20cannot\x20be\x20undone.');b['push'](''),b['push']('Confirm\x20by\x20re-calling\x20with\x20env.confirmed=true,\x20or\x20modify/cancel.'),b['push'](''),b['push']('Operations\x20that\x20require\x20env.confirmed=true:');for(const d of CONFIRMATION_REQUIRED_OPERATIONS){b['push']('\x20\x20-\x20'+d);}return b['push']('Example:\x20{\x22env\x22:\x20{\x22account\x22:\x20\x22...\x22,\x20\x22network\x22:\x20\x22testnet\x22,\x20\x22confirmed\x22:\x20true}}'),b['join']('\x0a');}const OPERATION_MEANINGS={'payment':'Send\x20a\x20payment\x20on-chain.\x20Funds\x20leave\x20your\x20account\x20and\x20are\x20credited\x20to\x20the\x20recipient.','service':'Publish\x20/\x20update\x20this\x20Service.\x20Publishing\x20locks\x20its\x20machine\x20and\x20order-allocator\x20configuration\x20—\x20further\x20changes\x20require\x20a\x20new\x20Service\x20version.','machine':'Publish\x20this\x20Machine\x20workflow.\x20Publishing\x20locks\x20its\x20nodes,\x20pairs\x20and\x20forwards\x20—\x20the\x20flow\x20cannot\x20be\x20redesigned\x20afterwards.','arbitration':'Issue\x20the\x20arbitration\x20verdict.\x20The\x20verdict\x20is\x20final\x20and\x20cannot\x20be\x20changed.','treasury':'Move\x20funds\x20in/out\x20of\x20a\x20Treasury.\x20Withdrawals\x20are\x20on-chain\x20transfers\x20and\x20cannot\x20be\x20undone.','reward':'Distribute\x20rewards\x20from\x20a\x20Service.\x20Funds\x20are\x20transferred\x20on-chain\x20immediately.','guard':'Create\x20a\x20Guard.\x20Guards\x20are\x20CREATE-only\x20and\x20immutable\x20—\x20they\x20can\x20never\x20be\x20edited\x20or\x20deleted;\x20changing\x20one\x20means\x20creating\x20a\x20new\x20Guard\x20and\x20rebinding.','progress':'Advance\x20an\x20order\x20(Progress\x20node).\x20Depending\x20on\x20the\x20node\x20this\x20may\x20release\x20funds\x20to\x20the\x20counterparty.','gen_passport':'Run\x20a\x20Guard\x20test\x20(generate\x20a\x20test\x20Passport).\x20This\x20consumes\x20gas\x20but\x20changes\x20nothing\x20permanent.'};function fallbackMeaning(a){return'Execute\x20the\x20\x22'+a+'\x22\x20operation\x20on-chain.';}function shortish(a){return/^(0x)?[0-9a-fA-F]{8,64}$/['test'](a)?formatShortAddress(a):a;}export function renderPreviewHuman(a){const b=[];b['push']('What\x20this\x20does'),b['push']('\x20\x20'+(OPERATION_MEANINGS[a['operation']]??fallbackMeaning(a['operation']))),b['push'](''),b['push']('How\x20it\x20will\x20run');if(a['object'])b['push']('\x20\x20Object:\x20\x20\x20'+shortish(a['object']));a['account']!==undefined&&b['push']('\x20\x20Account:\x20\x20'+(a['account']===''?'(current\x20account)':shortish(a['account'])));if(a['network'])b['push']('\x20\x20Network:\x20\x20'+a['network']);a['amount']&&b['push']('\x20\x20Amount:\x20\x20\x20'+a['amount']['human_readable']+(a['amount']['recipient']?'\x20\x20→\x20\x20to\x20'+shortish(a['amount']['recipient']):''));b['push'](''),b['push']('What\x20happens\x20after\x20you\x20confirm');a['immutable_after']&&a['immutable_after']['length']>0x0&&b['push']('\x20\x20-\x20These\x20become\x20PERMANENT:\x20'+a['immutable_after']['join'](',\x20'));a['irreversible']&&b['push']('\x20\x20-\x20The\x20operation\x20is\x20IRREVERSIBLE\x20—\x20it\x20cannot\x20be\x20undone\x20or\x20cancelled.');if(a['warnings']&&a['warnings']['length']>0x0){b['push']('\x20\x20Notes:');for(const c of a['warnings'])b['push']('\x20\x20\x20\x20-\x20'+c);}return!(a['immutable_after']&&a['immutable_after']['length']>0x0)&&!a['irreversible']&&!(a['warnings']&&a['warnings']['length']>0x0)&&b['push']('\x20\x20-\x20The\x20operation\x20is\x20submitted\x20to\x20the\x20network\x20immediately.'),b['join']('\x0a');}
1
+ import{formatShortAddress}from'../persona/address-format.js';const LEVEL_LABEL={'none':'none','standard':'Standard\x20confirmation','amount':'Amount\x20confirmation','publish':'Publish\x20confirmation\x20(irreversible\x20lock)','irreversible':'Irreversible\x20operation\x20confirmation'};export const CONFIRMATION_REQUIRED_OPERATIONS=['guard\x20(CREATE\x20—\x20immutable,\x20cannot\x20be\x20edited\x20or\x20deleted)','service\x20(publish=true\x20—\x20locks\x20machine/order_allocators)','machine\x20(publish=true\x20—\x20locks\x20nodes/pairs/forwards)','arbitration\x20(verdict\x20—\x20irreversible)','payment\x20(send/receive\x20—\x20irreversible)','treasury\x20(withdraw/external_withdraw/external_deposit\x20—\x20irreversible)','bridge\x20(cross_chain_wow_to_evm\x20/\x20cross_chain_evm_to_wow\x20/\x20claim_wow_to_evm\x20/\x20resume_transfer\x20/\x20withdraw\x20—\x20irreversible)','reward\x20coin_add\x20/\x20treasury\x20deposit\x20/\x20allocation\x20funding\x20/\x20arbitration\x20fee\x20/\x20service\x20compensation_fund_add\x20/\x20service\x20order_new\x20payment\x20(amount-sensitive)','progress\x20(node\x20advance\x20—\x20may\x20release\x20funds;\x20owner_receive\x20—\x20fund\x20claim)','gen_passport\x20(gas-consuming\x20test)'];export function renderPreview(a){const b=[];b['push']('⚠️\x20\x20Confirmation\x20required\x20—\x20'+LEVEL_LABEL[a['level']]),b['push']('\x20\x20Operation:\x20'+a['operation']);a['object']&&b['push']('\x20\x20Object:\x20'+(typeof a['object']==='string'?a['object']:JSON['stringify'](a['object'])));if(a['network'])b['push']('\x20\x20Network:\x20'+a['network']);if(a['account']!==undefined)b['push']('\x20\x20Account:\x20'+(a['account']===''?'(default)':a['account']));a['amount']&&b['push']('\x20\x20Amount:\x20'+a['amount']['human_readable']+'\x20('+a['amount']['value']+'\x20smallest\x20unit)'+(a['amount']['recipient']?'\x20→\x20'+a['amount']['recipient']:''));a['immutable_after']&&a['immutable_after']['length']>0x0&&b['push']('\x20\x20Fields\x20becoming\x20immutable:\x20'+a['immutable_after']['join'](',\x20'));if(a['warnings']&&a['warnings']['length']>0x0){b['push']('\x20\x20Warnings:');for(const c of a['warnings'])b['push']('\x20\x20\x20\x20-\x20'+c);}a['irreversible']&&b['push']('\x20\x20⛔\x20This\x20operation\x20is\x20IRREVERSIBLE.\x20It\x20cannot\x20be\x20undone.');b['push'](''),b['push']('Confirm\x20by\x20re-calling\x20with\x20env.confirmed=true,\x20or\x20modify/cancel.'),b['push'](''),b['push']('Operations\x20that\x20require\x20env.confirmed=true:');for(const d of CONFIRMATION_REQUIRED_OPERATIONS){b['push']('\x20\x20-\x20'+d);}return b['push']('Example:\x20{\x22env\x22:\x20{\x22account\x22:\x20\x22...\x22,\x20\x22network\x22:\x20\x22testnet\x22,\x20\x22confirmed\x22:\x20true}}'),b['join']('\x0a');}const OPERATION_MEANINGS={'payment':'Send\x20a\x20payment\x20on-chain.\x20Funds\x20leave\x20your\x20account\x20and\x20are\x20credited\x20to\x20the\x20recipient.','service':'Publish\x20/\x20update\x20this\x20Service.\x20Publishing\x20locks\x20its\x20machine\x20and\x20order-allocator\x20configuration\x20—\x20further\x20changes\x20require\x20a\x20new\x20Service\x20version.','machine':'Publish\x20this\x20Machine\x20workflow.\x20Publishing\x20locks\x20its\x20nodes,\x20pairs\x20and\x20forwards\x20—\x20the\x20flow\x20cannot\x20be\x20redesigned\x20afterwards.','arbitration':'Issue\x20the\x20arbitration\x20verdict.\x20The\x20verdict\x20is\x20final\x20and\x20cannot\x20be\x20changed.','treasury':'Move\x20funds\x20in/out\x20of\x20a\x20Treasury.\x20Withdrawals\x20are\x20on-chain\x20transfers\x20and\x20cannot\x20be\x20undone.','reward':'Distribute\x20rewards\x20from\x20a\x20Service.\x20Funds\x20are\x20transferred\x20on-chain\x20immediately.','guard':'Create\x20a\x20Guard.\x20Guards\x20are\x20CREATE-only\x20and\x20immutable\x20—\x20they\x20can\x20never\x20be\x20edited\x20or\x20deleted;\x20changing\x20one\x20means\x20creating\x20a\x20new\x20Guard\x20and\x20rebinding.','progress':'Advance\x20an\x20order\x20(Progress\x20node).\x20Depending\x20on\x20the\x20node\x20this\x20may\x20release\x20funds\x20to\x20the\x20counterparty.','gen_passport':'Run\x20a\x20Guard\x20test\x20(generate\x20a\x20test\x20Passport).\x20This\x20consumes\x20gas\x20but\x20changes\x20nothing\x20permanent.'};function fallbackMeaning(a){return'Execute\x20the\x20\x22'+a+'\x22\x20operation\x20on-chain.';}function shortish(a){return/^(0x)?[0-9a-fA-F]{8,64}$/['test'](a)?formatShortAddress(a):a;}export function renderPreviewHuman(a){const b=[];b['push']('What\x20this\x20does'),b['push']('\x20\x20'+(OPERATION_MEANINGS[a['operation']]??fallbackMeaning(a['operation']))),b['push'](''),b['push']('How\x20it\x20will\x20run');if(a['object'])b['push']('\x20\x20Object:\x20\x20\x20'+shortish(a['object']));a['account']!==undefined&&b['push']('\x20\x20Account:\x20\x20'+(a['account']===''?'(current\x20account)':shortish(a['account'])));if(a['network'])b['push']('\x20\x20Network:\x20\x20'+a['network']);a['amount']&&b['push']('\x20\x20Amount:\x20\x20\x20'+a['amount']['human_readable']+(a['amount']['recipient']?'\x20\x20→\x20\x20to\x20'+shortish(a['amount']['recipient']):''));b['push'](''),b['push']('What\x20happens\x20after\x20you\x20confirm');a['immutable_after']&&a['immutable_after']['length']>0x0&&b['push']('\x20\x20-\x20These\x20become\x20PERMANENT:\x20'+a['immutable_after']['join'](',\x20'));a['irreversible']&&b['push']('\x20\x20-\x20The\x20operation\x20is\x20IRREVERSIBLE\x20—\x20it\x20cannot\x20be\x20undone\x20or\x20cancelled.');if(a['warnings']&&a['warnings']['length']>0x0){b['push']('\x20\x20Notes:');for(const c of a['warnings'])b['push']('\x20\x20\x20\x20-\x20'+c);}return!(a['immutable_after']&&a['immutable_after']['length']>0x0)&&!a['irreversible']&&!(a['warnings']&&a['warnings']['length']>0x0)&&b['push']('\x20\x20-\x20The\x20operation\x20is\x20submitted\x20to\x20the\x20network\x20immediately.'),b['join']('\x0a');}
@@ -24,6 +24,12 @@ export declare const BenchmarkMigrationSchema: z.ZodObject<{
24
24
  table: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
25
25
  root: z.ZodUnknown;
26
26
  }, z.core.$strict>]>>>;
27
+ review_mode: z.ZodOptional<z.ZodEnum<{
28
+ review: "review";
29
+ none: "none";
30
+ review_reward: "review_reward";
31
+ }>>;
32
+ reward_funding: z.ZodOptional<z.ZodString>;
27
33
  log: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
28
34
  network: z.ZodOptional<z.ZodEnum<{
29
35
  testnet: "testnet";
@@ -85,6 +91,10 @@ export declare const BenchmarkMigrationOutputSchema: z.ZodObject<{
85
91
  red_flags: z.ZodArray<z.ZodString>;
86
92
  }, z.core.$strip>;
87
93
  plan: z.ZodRecord<z.ZodString, z.ZodUnknown>;
94
+ verdict: z.ZodObject<{
95
+ buildable: z.ZodBoolean;
96
+ blockers: z.ZodArray<z.ZodString>;
97
+ }, z.core.$strip>;
88
98
  next_action: z.ZodString;
89
99
  }, z.core.$strip>, z.ZodObject<{
90
100
  action: z.ZodLiteral<"template_scan">;
@@ -237,6 +247,10 @@ export declare const BenchmarkMigrationOutputSchema: z.ZodObject<{
237
247
  red_flags: z.ZodArray<z.ZodString>;
238
248
  }, z.core.$strip>;
239
249
  plan: z.ZodRecord<z.ZodString, z.ZodUnknown>;
250
+ verdict: z.ZodObject<{
251
+ buildable: z.ZodBoolean;
252
+ blockers: z.ZodArray<z.ZodString>;
253
+ }, z.core.$strip>;
240
254
  next_action: z.ZodString;
241
255
  }, z.core.$strip>], "action">;
242
256
  }, z.core.$strict>;
@@ -1 +1 @@
1
- import{z}from'zod';import{GuardResolutionInputSchema}from'../goal/planning.js';const TemplateSummarySchema=z['object']({'id':z['string']()['describe']('Template\x20id\x20\x27<industry>/<variant>\x27,\x20e.g.\x20\x27retail/scale-marketplace\x27.'),'industry':z['string']()['describe']('Industry\x20vertical.'),'variant':z['string']()['describe']('Business-model\x20variant\x20slug.'),'product_ref':z['string']()['optional']()['describe']('Benchmark\x20product\x20slug\x20this\x20archetype\x20models\x20(e.g.\x20\x27amazon\x27).\x20The\x20only\x20sanctioned\x20company\x20name;\x20users\x20can\x20pick\x20a\x20template\x20by\x20naming\x20the\x20incumbent\x20product.'),'archetype':z['enum'](['leader','challenger']),'key_risk':z['string']()['describe']('Primary\x20risk\x20this\x20template\x20mitigates.'),'node_count':z['number']()['describe']('Machine\x20node\x20count.'),'guard_count':z['number']()['describe']('Guard\x20template\x20count.'),'recommended_role':z['enum'](['merchant','supplier','both'])})['describe']('Compact\x20template\x20listing\x20row.'),TemplateScanFindingSchema=z['object']({'rule_id':z['string']()['optional']()['describe']('Rule\x20id\x20when\x20known\x20(e.g.\x20\x27R-M3-01\x27,\x20\x27R1\x27).'),'severity':z['enum'](['low','medium','high','critical']),'title':z['string'](),'detail':z['string'](),'suggestion':z['string']()})['describe']('One\x20pre-deploy\x20risk\x20finding.'),MigrationEntrySchema=z['object']({'source_element':z['string']()['describe']('Competitor-side\x20element.'),'target_object':z['string']()['optional']()['describe']('WoWok\x20object/mechanism\x20it\x20maps\x20to.'),'mapping_note':z['string']()['describe']('One-line\x20mapping\x20explanation.'),'reason':z['string']()['optional']()['describe']('Why\x20it\x20cannot\x20be\x20migrated,\x20or\x20why\x20it\x20needs\x20a\x20decision.')})['describe']('One\x20competitor\x20element\x20and\x20its\x20WoWok\x20mapping\x20outcome.'),MigrationLogSchema=z['object']({'source':z['object']({'url':z['string']()['optional'](),'description':z['string'](),'detected_industry':z['string'](),'matched_template':z['string']()['describe']('Matched\x20template\x20id\x20\x27<industry>/<variant>\x27.')})['describe']('Migration\x20source\x20provenance.'),'mapped':z['array'](MigrationEntrySchema)['describe']('Elements\x20that\x20map\x20cleanly\x20to\x20WoWok\x20objects.'),'unmapped':z['array'](MigrationEntrySchema)['describe']('Elements\x20that\x20cannot\x20be\x20migrated,\x20with\x20reasons.'),'manual_review':z['array'](MigrationEntrySchema)['describe']('Elements\x20requiring\x20an\x20explicit\x20user\x20decision.'),'wowok_advantages':z['array'](z['string']())['describe']('WoWok\x20platform\x20advantages\x20surfaced\x20during\x20migration.'),'customizable_modules':z['array'](z['string']())['describe']('Business-module\x20ids\x20the\x20user\x20can\x20customize.'),'role_assessment':z['object']({'recommended':z['string'](),'rationale':z['string'](),'alternatives':z['array'](z['string']())})['describe']('Merchant\x20vs\x20supplier\x20role\x20assessment.'),'risk_check':z['object']({'passed':z['boolean'](),'findings':z['array'](z['string']())})['describe']('Dry-run\x20risk\x20check\x20against\x20the\x20matched\x20template.'),'network':z['enum'](['testnet','mainnet'])['describe']('Target\x20network\x20(default\x20testnet).')})['describe']('Structured\x20competitor-migration\x20log.');export const BenchmarkMigrationSchema=z['object']({'action':z['enum'](['template_list','template_get','template_generate','template_scan','migration_import','migration_review','migration_apply'])['describe']('Action:\x20\x27template_list\x27\x20=\x20list\x20the\x20loaded\x20MD\x20industry\x20templates\x20(optional\x20industry\x20filter);\x20'+'\x27template_get\x27\x20=\x20fetch\x20one\x20template\x20by\x20id\x20(template_id\x20required);\x20'+'\x27template_generate\x27\x20=\x20generate\x20a\x20creation\x20plan\x20from\x20a\x20template\x20via\x20the\x20merchant-guide\x20'+'pipeline\x20(template_id\x20required;\x20scan-first\x20—\x20CRITICAL\x20findings\x20block;\x20never\x20executes\x20on-chain);\x20'+'\x27template_scan\x27\x20=\x20pre-deploy\x20risk\x20scan\x20of\x20one\x20template\x20(template_id\x20required;\x20returns\x20'+'risk_level/findings/red_flags;\x20CRITICAL\x20blocks\x20generation/apply);\x20'+'\x27migration_import\x27\x20=\x20competitor\x20URL/description\x20→\x20migration\x20plan\x20+\x20MigrationLog\x20'+'(description\x20required);\x20'+'\x27migration_review\x27\x20=\x20surface\x20the\x20MigrationLog\x20for\x20user\x20confirmation\x20(log\x20required);\x20'+'\x27migration_apply\x27\x20=\x20run\x20the\x20approved\x20template\x20through\x20the\x20merchant-guide\x20pipeline\x20'+'(template_id\x20required;\x20scan-first\x20—\x20CRITICAL\x20findings\x20block;\x20default\x20network\x20testnet).'),'template_id':z['string']()['optional']()['describe']('Template\x20id\x20\x27<industry>/<variant>\x27\x20(required\x20for\x20template_get\x20/\x20template_generate\x20/\x20template_scan\x20/\x20migration_apply),\x20e.g.\x20\x27retail/scale-marketplace\x27.'),'industry':z['string']()['optional']()['describe']('Industry\x20filter\x20for\x20template_list;\x20industry\x20hint\x20for\x20migration_import.\x20'+'Any\x20registered\x20industry\x20is\x20accepted\x20(builtin:\x20freelance,\x20rental,\x20education,\x20'+'travel,\x20subscription,\x20retail;\x20plus\x20custom\x20industries\x20registered\x20via\x20industry\x20packs).\x20'+'Aliases\x20are\x20resolved\x20(e.g.\x20\x27ecommerce\x27\x20→\x20\x27retail\x27).'),'description':z['string']()['optional']()['describe']('Natural-language\x20business/competitor\x20description\x20(required\x20for\x20migration_import;\x20used\x20by\x20template_generate\x20as\x20the\x20intent\x20text).'),'url':z['string']()['optional']()['describe']('Competitor\x20store/profile\x20URL\x20for\x20migration_import\x20(recorded\x20as\x20provenance\x20only).'),'fee_overrides':z['record'](z['string'](),z['union']([z['number'](),z['string']()]))['optional']()['describe']('Template\x20fee-parameter\x20overrides\x20for\x20template_generate\x20(e.g.\x20commission_rate_bps).'),'guard_resolutions':z['record'](z['string'](),GuardResolutionInputSchema)['optional']()['describe']('Judgment-layer\x20resolutions\x20for\x20pending\x20guard\x20designs\x20(C6-DEEP),\x20keyed\x20by\x20plan.pending_guard_designs[].key.\x20'+'A\x20blocked\x20migration_apply/template_generate\x20lists\x20every\x20unresolved\x20design\x20—\x20resolve\x20each\x20here\x20'+'(kind\x20\x27inline\x27\x20with\x20the\x20Guard\x20table+root,\x20or\x20kind\x20\x27template\x27\x20with\x20a\x20tpl_*\x20id)\x20and\x20re-run\x20the\x20action.\x20'+'The\x20audit\x20freeze\x20gate\x20still\x20decides:\x20resolutions\x20only\x20unblock\x20a\x20plan\x20whose\x20closed\x20audit\x20is\x20clean.'),'log':z['record'](z['string'](),z['unknown']())['optional']()['describe']('A\x20prior\x20MigrationLog\x20(required\x20for\x20migration_review).'),'network':z['enum'](['testnet','mainnet'])['optional']()['describe']('Target\x20network\x20for\x20migration_import\x20/\x20migration_apply\x20(default\x20testnet;\x20mainnet\x20requires\x20explicit\x20user\x20confirmation).')})['strict']();const ScanSummarySchema=z['object']({'risk_level':z['enum'](['low','medium','high','critical']),'passed':z['boolean'](),'finding_count':z['number'](),'findings_by_severity':z['record'](z['string'](),z['number']())['describe']('Finding\x20count\x20keyed\x20by\x20severity.'),'findings':z['array'](TemplateScanFindingSchema)['describe']('Every\x20finding\x20with\x20its\x20rule\x20id,\x20detail\x20and\x20suggestion.'),'red_flags':z['array'](z['string']())})['describe']('Pre-deploy\x20scan\x20summary\x20(generation/apply\x20only\x20runs\x20when\x20passed).');export const BenchmarkMigrationOutputSchema=z['object']({'result':z['discriminatedUnion']('action',[z['object']({'action':z['literal']('template_list'),'count':z['number']()['describe']('Number\x20of\x20templates\x20returned.'),'templates':z['array'](TemplateSummarySchema)['describe']('Template\x20listing\x20rows.'),'load_errors':z['array'](z['string']())['describe']('Template\x20files\x20that\x20failed\x20to\x20load/validate\x20(never\x20silently\x20dropped).')}),z['object']({'action':z['literal']('template_get'),'template':z['record'](z['string'](),z['unknown']())['describe']('Full\x20template\x20object\x20(machine_shape/guards/allocator/fee_params/body/...).')}),z['object']({'action':z['literal']('template_generate'),'template_id':z['string'](),'scan':ScanSummarySchema,'plan':z['record'](z['string'](),z['unknown']())['describe']('Creation\x20plan\x20from\x20the\x20merchant-guide\x20pipeline\x20(never\x20executed\x20on-chain).'),'next_action':z['string']()['describe']('Top-level\x20forwarding\x20of\x20the\x20materialization\x20contract\x20(C6):\x20the\x20guide\x27s\x20\x27Plan\x20ready.\x20Materialize:\x20...\x27\x20text\x20verbatim\x20when\x20the\x20audit\x20is\x20clean;\x20a\x20BLOCKED\x20reroute\x20back\x20to\x20this\x20action\x20otherwise.')}),z['object']({'action':z['literal']('template_scan'),'scan':z['object']({'template_id':z['string'](),'risk_level':z['enum'](['low','medium','high','critical']),'passed':z['boolean'](),'findings':z['array'](TemplateScanFindingSchema),'red_flags':z['array'](z['string']())})['describe']('Full\x20pre-deploy\x20scan\x20result.')}),z['object']({'action':z['literal']('migration_import'),'log':MigrationLogSchema['describe']('The\x20structured\x20migration\x20log.'),'next_action':z['string']()['describe']('Next\x20chain\x20step:\x20run\x20migration_review\x20with\x20this\x20log\x20(C6\x20—\x20the\x20chain\x20is\x20self-describing,\x20no\x20agent\x20re-exploration).')}),z['object']({'action':z['literal']('migration_review'),'log':MigrationLogSchema['describe']('The\x20migration\x20log\x20under\x20review.'),'review_summary':z['object']({'mapped_count':z['number'](),'unmapped_count':z['number'](),'manual_review_count':z['number'](),'risk_passed':z['boolean']()})['describe']('Counts\x20+\x20risk\x20status\x20for\x20the\x20confirmation\x20screen.'),'next_action':z['string']()['describe']('Next\x20chain\x20step:\x20migration_apply\x20with\x20the\x20matched\x20template\x20when\x20the\x20review\x20is\x20clean;\x20surface\x20the\x20unmapped/manual_review\x20items\x20for\x20a\x20user\x20decision\x20otherwise.')}),z['object']({'action':z['literal']('migration_apply'),'template_id':z['string'](),'network':z['enum'](['testnet','mainnet']),'scan':ScanSummarySchema,'plan':z['record'](z['string'](),z['unknown']())['describe']('Creation\x20plan\x20from\x20the\x20merchant-guide\x20pipeline\x20(never\x20executed\x20on-chain).'),'next_action':z['string']()['describe']('Top-level\x20forwarding\x20of\x20the\x20materialization\x20contract\x20(C6):\x20the\x20guide\x27s\x20\x27Plan\x20ready.\x20Materialize:\x20...\x27\x20text\x20verbatim\x20when\x20the\x20audit\x20is\x20clean;\x20a\x20BLOCKED\x20reroute\x20back\x20to\x20this\x20action\x20otherwise.')})])})['strict']();
1
+ import{z}from'zod';import{GuardResolutionInputSchema}from'../goal/planning.js';const TemplateSummarySchema=z['object']({'id':z['string']()['describe']('Template\x20id\x20\x27<industry>/<variant>\x27,\x20e.g.\x20\x27retail/scale-marketplace\x27.'),'industry':z['string']()['describe']('Industry\x20vertical.'),'variant':z['string']()['describe']('Business-model\x20variant\x20slug.'),'product_ref':z['string']()['optional']()['describe']('Benchmark\x20product\x20slug\x20this\x20archetype\x20models\x20(e.g.\x20\x27amazon\x27).\x20The\x20only\x20sanctioned\x20company\x20name;\x20users\x20can\x20pick\x20a\x20template\x20by\x20naming\x20the\x20incumbent\x20product.'),'archetype':z['enum'](['leader','challenger']),'key_risk':z['string']()['describe']('Primary\x20risk\x20this\x20template\x20mitigates.'),'node_count':z['number']()['describe']('Machine\x20node\x20count.'),'guard_count':z['number']()['describe']('Guard\x20template\x20count.'),'recommended_role':z['enum'](['merchant','supplier','both'])})['describe']('Compact\x20template\x20listing\x20row.'),TemplateScanFindingSchema=z['object']({'rule_id':z['string']()['optional']()['describe']('Rule\x20id\x20when\x20known\x20(e.g.\x20\x27R-M3-01\x27,\x20\x27R1\x27).'),'severity':z['enum'](['low','medium','high','critical']),'title':z['string'](),'detail':z['string'](),'suggestion':z['string']()})['describe']('One\x20pre-deploy\x20risk\x20finding.'),MigrationEntrySchema=z['object']({'source_element':z['string']()['describe']('Competitor-side\x20element.'),'target_object':z['string']()['optional']()['describe']('WoWok\x20object/mechanism\x20it\x20maps\x20to.'),'mapping_note':z['string']()['describe']('One-line\x20mapping\x20explanation.'),'reason':z['string']()['optional']()['describe']('Why\x20it\x20cannot\x20be\x20migrated,\x20or\x20why\x20it\x20needs\x20a\x20decision.')})['describe']('One\x20competitor\x20element\x20and\x20its\x20WoWok\x20mapping\x20outcome.'),MigrationLogSchema=z['object']({'source':z['object']({'url':z['string']()['optional'](),'description':z['string'](),'detected_industry':z['string'](),'matched_template':z['string']()['describe']('Matched\x20template\x20id\x20\x27<industry>/<variant>\x27.')})['describe']('Migration\x20source\x20provenance.'),'mapped':z['array'](MigrationEntrySchema)['describe']('Elements\x20that\x20map\x20cleanly\x20to\x20WoWok\x20objects.'),'unmapped':z['array'](MigrationEntrySchema)['describe']('Elements\x20that\x20cannot\x20be\x20migrated,\x20with\x20reasons.'),'manual_review':z['array'](MigrationEntrySchema)['describe']('Elements\x20requiring\x20an\x20explicit\x20user\x20decision.'),'wowok_advantages':z['array'](z['string']())['describe']('WoWok\x20platform\x20advantages\x20surfaced\x20during\x20migration.'),'customizable_modules':z['array'](z['string']())['describe']('Business-module\x20ids\x20the\x20user\x20can\x20customize.'),'role_assessment':z['object']({'recommended':z['string'](),'rationale':z['string'](),'alternatives':z['array'](z['string']())})['describe']('Merchant\x20vs\x20supplier\x20role\x20assessment.'),'risk_check':z['object']({'passed':z['boolean'](),'findings':z['array'](z['string']())})['describe']('Dry-run\x20risk\x20check\x20against\x20the\x20matched\x20template.'),'network':z['enum'](['testnet','mainnet'])['describe']('Target\x20network\x20(default\x20testnet).')})['describe']('Structured\x20competitor-migration\x20log.');export const BenchmarkMigrationSchema=z['object']({'action':z['enum'](['template_list','template_get','template_generate','template_scan','migration_import','migration_review','migration_apply'])['describe']('Action:\x20\x27template_list\x27\x20=\x20list\x20the\x20loaded\x20MD\x20industry\x20templates\x20(optional\x20industry\x20filter);\x20'+'\x27template_get\x27\x20=\x20fetch\x20one\x20template\x20by\x20id\x20(template_id\x20required);\x20'+'\x27template_generate\x27\x20=\x20generate\x20a\x20creation\x20plan\x20from\x20a\x20template\x20via\x20the\x20merchant-guide\x20'+'pipeline\x20(template_id\x20required;\x20scan-first\x20—\x20CRITICAL\x20findings\x20block;\x20never\x20executes\x20on-chain);\x20'+'\x27template_scan\x27\x20=\x20pre-deploy\x20risk\x20scan\x20of\x20one\x20template\x20(template_id\x20required;\x20returns\x20'+'risk_level/findings/red_flags;\x20CRITICAL\x20blocks\x20generation/apply);\x20'+'\x27migration_import\x27\x20=\x20competitor\x20URL/description\x20→\x20migration\x20plan\x20+\x20MigrationLog\x20'+'(description\x20required);\x20'+'\x27migration_review\x27\x20=\x20surface\x20the\x20MigrationLog\x20for\x20user\x20confirmation\x20(log\x20required);\x20'+'\x27migration_apply\x27\x20=\x20run\x20the\x20approved\x20template\x20through\x20the\x20merchant-guide\x20pipeline\x20'+'(template_id\x20required;\x20scan-first\x20—\x20CRITICAL\x20findings\x20block;\x20default\x20network\x20testnet).'),'template_id':z['string']()['optional']()['describe']('Template\x20id\x20\x27<industry>/<variant>\x27\x20(required\x20for\x20template_get\x20/\x20template_generate\x20/\x20template_scan\x20/\x20migration_apply),\x20e.g.\x20\x27retail/scale-marketplace\x27.'),'industry':z['string']()['optional']()['describe']('Industry\x20filter\x20for\x20template_list;\x20industry\x20hint\x20for\x20migration_import.\x20'+'Any\x20registered\x20industry\x20is\x20accepted\x20(builtin:\x20freelance,\x20rental,\x20education,\x20'+'travel,\x20subscription,\x20retail;\x20plus\x20custom\x20industries\x20registered\x20via\x20industry\x20packs).\x20'+'Aliases\x20are\x20resolved\x20(e.g.\x20\x27ecommerce\x27\x20→\x20\x27retail\x27).'),'description':z['string']()['optional']()['describe']('Natural-language\x20business/competitor\x20description\x20(required\x20for\x20migration_import;\x20used\x20by\x20template_generate\x20as\x20the\x20intent\x20text).'),'url':z['string']()['optional']()['describe']('Competitor\x20store/profile\x20URL\x20for\x20migration_import\x20(recorded\x20as\x20provenance\x20only).'),'fee_overrides':z['record'](z['string'](),z['union']([z['number'](),z['string']()]))['optional']()['describe']('Template\x20fee-parameter\x20overrides\x20for\x20template_generate\x20(e.g.\x20commission_rate_bps).'),'guard_resolutions':z['record'](z['string'](),GuardResolutionInputSchema)['optional']()['describe']('Judgment-layer\x20resolutions\x20for\x20pending\x20guard\x20designs\x20(C6-DEEP),\x20keyed\x20by\x20plan.pending_guard_designs[].key.\x20'+'A\x20blocked\x20migration_apply/template_generate\x20lists\x20every\x20unresolved\x20design\x20—\x20resolve\x20each\x20here\x20'+'(kind\x20\x27inline\x27\x20with\x20the\x20Guard\x20table+root,\x20or\x20kind\x20\x27template\x27\x20with\x20a\x20tpl_*\x20id)\x20and\x20re-run\x20the\x20action.\x20'+'The\x20audit\x20freeze\x20gate\x20still\x20decides:\x20resolutions\x20only\x20unblock\x20a\x20plan\x20whose\x20closed\x20audit\x20is\x20clean.'),'review_mode':z['enum'](['review','review_reward','none'])['optional']()['describe']('Per-build\x20review-rail\x20mode\x20(v53\x20templates).\x20Absent\x20=\x20the\x20template\x27s\x20declared\x20review_mode\x20applies.'),'reward_funding':z['string']()['optional']()['describe']('Review\x20reward\x20pool\x20funding,\x20smallest-unit\x20string.\x20Required\x20by\x20template_generate/migration_apply\x20when\x20the\x20effective\x20review\x20mode\x20is\x20review_reward\x20(INV-4:\x20the\x20incentive\x20must\x20be\x20funded\x20at\x20build\x20time).'),'log':z['record'](z['string'](),z['unknown']())['optional']()['describe']('A\x20prior\x20MigrationLog\x20(required\x20for\x20migration_review).'),'network':z['enum'](['testnet','mainnet'])['optional']()['describe']('Target\x20network\x20for\x20migration_import\x20/\x20migration_apply\x20(default\x20testnet;\x20mainnet\x20requires\x20explicit\x20user\x20confirmation).')})['strict']();const ScanSummarySchema=z['object']({'risk_level':z['enum'](['low','medium','high','critical']),'passed':z['boolean'](),'finding_count':z['number'](),'findings_by_severity':z['record'](z['string'](),z['number']())['describe']('Finding\x20count\x20keyed\x20by\x20severity.'),'findings':z['array'](TemplateScanFindingSchema)['describe']('Every\x20finding\x20with\x20its\x20rule\x20id,\x20detail\x20and\x20suggestion.'),'red_flags':z['array'](z['string']())})['describe']('Pre-deploy\x20scan\x20summary\x20(generation/apply\x20only\x20runs\x20when\x20passed).');export const BenchmarkMigrationOutputSchema=z['object']({'result':z['discriminatedUnion']('action',[z['object']({'action':z['literal']('template_list'),'count':z['number']()['describe']('Number\x20of\x20templates\x20returned.'),'templates':z['array'](TemplateSummarySchema)['describe']('Template\x20listing\x20rows.'),'load_errors':z['array'](z['string']())['describe']('Template\x20files\x20that\x20failed\x20to\x20load/validate\x20(never\x20silently\x20dropped).')}),z['object']({'action':z['literal']('template_get'),'template':z['record'](z['string'](),z['unknown']())['describe']('Full\x20template\x20object\x20(machine_shape/guards/allocator/fee_params/body/...).')}),z['object']({'action':z['literal']('template_generate'),'template_id':z['string'](),'scan':ScanSummarySchema,'plan':z['record'](z['string'](),z['unknown']())['describe']('Creation\x20plan\x20from\x20the\x20merchant-guide\x20pipeline\x20(never\x20executed\x20on-chain).'),'verdict':z['object']({'buildable':z['boolean'](),'blockers':z['array'](z['string']())})['describe']('Single\x20aggregate\x20ruling\x20over\x20the\x20three\x20signal\x20faces\x20(scan.passed\x20/\x20plan.graph_validation.valid\x20/\x20plan.audit.blocking)\x20—\x20the\x20authoritative\x20go/no-go\x20(bkmn-261012\x20F-M62);\x20the\x20individual\x20faces\x20stay\x20advisory.'),'next_action':z['string']()['describe']('Top-level\x20forwarding\x20of\x20the\x20materialization\x20contract\x20(C6):\x20the\x20guide\x27s\x20\x27Plan\x20ready.\x20Materialize:\x20...\x27\x20text\x20verbatim\x20when\x20the\x20audit\x20is\x20clean;\x20a\x20BLOCKED\x20reroute\x20back\x20to\x20this\x20action\x20otherwise.')}),z['object']({'action':z['literal']('template_scan'),'scan':z['object']({'template_id':z['string'](),'risk_level':z['enum'](['low','medium','high','critical']),'passed':z['boolean'](),'findings':z['array'](TemplateScanFindingSchema),'red_flags':z['array'](z['string']())})['describe']('Full\x20pre-deploy\x20scan\x20result.')}),z['object']({'action':z['literal']('migration_import'),'log':MigrationLogSchema['describe']('The\x20structured\x20migration\x20log.'),'next_action':z['string']()['describe']('Next\x20chain\x20step:\x20run\x20migration_review\x20with\x20this\x20log\x20(C6\x20—\x20the\x20chain\x20is\x20self-describing,\x20no\x20agent\x20re-exploration).')}),z['object']({'action':z['literal']('migration_review'),'log':MigrationLogSchema['describe']('The\x20migration\x20log\x20under\x20review.'),'review_summary':z['object']({'mapped_count':z['number'](),'unmapped_count':z['number'](),'manual_review_count':z['number'](),'risk_passed':z['boolean']()})['describe']('Counts\x20+\x20risk\x20status\x20for\x20the\x20confirmation\x20screen.'),'next_action':z['string']()['describe']('Next\x20chain\x20step:\x20migration_apply\x20with\x20the\x20matched\x20template\x20when\x20the\x20review\x20is\x20clean;\x20surface\x20the\x20unmapped/manual_review\x20items\x20for\x20a\x20user\x20decision\x20otherwise.')}),z['object']({'action':z['literal']('migration_apply'),'template_id':z['string'](),'network':z['enum'](['testnet','mainnet']),'scan':ScanSummarySchema,'plan':z['record'](z['string'](),z['unknown']())['describe']('Creation\x20plan\x20from\x20the\x20merchant-guide\x20pipeline\x20(never\x20executed\x20on-chain).'),'verdict':z['object']({'buildable':z['boolean'](),'blockers':z['array'](z['string']())})['describe']('Single\x20aggregate\x20ruling\x20over\x20the\x20three\x20signal\x20faces\x20(scan.passed\x20/\x20plan.graph_validation.valid\x20/\x20plan.audit.blocking)\x20—\x20the\x20authoritative\x20go/no-go\x20(bkmn-261012\x20F-M62);\x20the\x20individual\x20faces\x20stay\x20advisory.'),'next_action':z['string']()['describe']('Top-level\x20forwarding\x20of\x20the\x20materialization\x20contract\x20(C6):\x20the\x20guide\x27s\x20\x27Plan\x20ready.\x20Materialize:\x20...\x27\x20text\x20verbatim\x20when\x20the\x20audit\x20is\x20clean;\x20a\x20BLOCKED\x20reroute\x20back\x20to\x20this\x20action\x20otherwise.')})])})['strict']();
@@ -231,7 +231,7 @@ export declare const CallAllocation_InputSchema: z.ZodObject<{
231
231
  submission: z.ZodArray<z.ZodObject<{
232
232
  identifier: z.ZodNumber;
233
233
  b_submission: z.ZodBoolean;
234
- value_type: z.ZodUnion<readonly [z.ZodLiteral<import("@wowok/wowok").ValueType.Bool>, z.ZodLiteral<import("@wowok/wowok").ValueType.Address>, z.ZodLiteral<import("@wowok/wowok").ValueType.String>, z.ZodLiteral<import("@wowok/wowok").ValueType.U8>, z.ZodLiteral<import("@wowok/wowok").ValueType.U16>, z.ZodLiteral<import("@wowok/wowok").ValueType.U32>, z.ZodLiteral<import("@wowok/wowok").ValueType.U64>, z.ZodLiteral<import("@wowok/wowok").ValueType.U128>, z.ZodLiteral<import("@wowok/wowok").ValueType.U256>, z.ZodLiteral<import("@wowok/wowok").ValueType.VecBool>, z.ZodLiteral<import("@wowok/wowok").ValueType.VecAddress>, z.ZodLiteral<import("@wowok/wowok").ValueType.VecString>, z.ZodLiteral<import("@wowok/wowok").ValueType.VecU8>, z.ZodLiteral<import("@wowok/wowok").ValueType.VecU16>, z.ZodLiteral<import("@wowok/wowok").ValueType.VecU32>, z.ZodLiteral<import("@wowok/wowok").ValueType.VecU64>, z.ZodLiteral<import("@wowok/wowok").ValueType.VecU128>, z.ZodLiteral<import("@wowok/wowok").ValueType.VecU256>, z.ZodLiteral<import("@wowok/wowok").ValueType.VecVecU8>, z.ZodLiteral<"Bool">, z.ZodLiteral<"Address">, z.ZodLiteral<"String">, z.ZodLiteral<"U8">, z.ZodLiteral<"U16">, z.ZodLiteral<"U32">, z.ZodLiteral<"U64">, z.ZodLiteral<"U128">, z.ZodLiteral<"U256">, z.ZodLiteral<"VecBool">, z.ZodLiteral<"VecAddress">, z.ZodLiteral<"VecString">, z.ZodLiteral<"VecU8">, z.ZodLiteral<"VecU16">, z.ZodLiteral<"VecU32">, z.ZodLiteral<"VecU64">, z.ZodLiteral<"VecU128">, z.ZodLiteral<"VecU256">, z.ZodLiteral<"VecVecU8">, z.ZodLiteral<"bool">, z.ZodLiteral<"address">, z.ZodLiteral<"string">, z.ZodLiteral<"u8">, z.ZodLiteral<"u16">, z.ZodLiteral<"u32">, z.ZodLiteral<"u64">, z.ZodLiteral<"u128">, z.ZodLiteral<"u256">, z.ZodLiteral<"vecbool">, z.ZodLiteral<"vecaddress">, z.ZodLiteral<"vecstring">, z.ZodLiteral<"vecu8">, z.ZodLiteral<"vecu16">, z.ZodLiteral<"vecu32">, z.ZodLiteral<"vecu64">, z.ZodLiteral<"vecu128">, z.ZodLiteral<"vecu256">, z.ZodLiteral<"vecvecu8">]>;
234
+ value_type: z.ZodPreprocess<z.ZodUnion<readonly [z.ZodLiteral<import("@wowok/wowok").ValueType.Bool>, z.ZodLiteral<import("@wowok/wowok").ValueType.Address>, z.ZodLiteral<import("@wowok/wowok").ValueType.String>, z.ZodLiteral<import("@wowok/wowok").ValueType.U8>, z.ZodLiteral<import("@wowok/wowok").ValueType.U16>, z.ZodLiteral<import("@wowok/wowok").ValueType.U32>, z.ZodLiteral<import("@wowok/wowok").ValueType.U64>, z.ZodLiteral<import("@wowok/wowok").ValueType.U128>, z.ZodLiteral<import("@wowok/wowok").ValueType.U256>, z.ZodLiteral<import("@wowok/wowok").ValueType.VecBool>, z.ZodLiteral<import("@wowok/wowok").ValueType.VecAddress>, z.ZodLiteral<import("@wowok/wowok").ValueType.VecString>, z.ZodLiteral<import("@wowok/wowok").ValueType.VecU8>, z.ZodLiteral<import("@wowok/wowok").ValueType.VecU16>, z.ZodLiteral<import("@wowok/wowok").ValueType.VecU32>, z.ZodLiteral<import("@wowok/wowok").ValueType.VecU64>, z.ZodLiteral<import("@wowok/wowok").ValueType.VecU128>, z.ZodLiteral<import("@wowok/wowok").ValueType.VecU256>, z.ZodLiteral<import("@wowok/wowok").ValueType.VecVecU8>, z.ZodLiteral<"Bool">, z.ZodLiteral<"Address">, z.ZodLiteral<"String">, z.ZodLiteral<"U8">, z.ZodLiteral<"U16">, z.ZodLiteral<"U32">, z.ZodLiteral<"U64">, z.ZodLiteral<"U128">, z.ZodLiteral<"U256">, z.ZodLiteral<"VecBool">, z.ZodLiteral<"VecAddress">, z.ZodLiteral<"VecString">, z.ZodLiteral<"VecU8">, z.ZodLiteral<"VecU16">, z.ZodLiteral<"VecU32">, z.ZodLiteral<"VecU64">, z.ZodLiteral<"VecU128">, z.ZodLiteral<"VecU256">, z.ZodLiteral<"VecVecU8">, z.ZodLiteral<"bool">, z.ZodLiteral<"address">, z.ZodLiteral<"string">, z.ZodLiteral<"u8">, z.ZodLiteral<"u16">, z.ZodLiteral<"u32">, z.ZodLiteral<"u64">, z.ZodLiteral<"u128">, z.ZodLiteral<"u256">, z.ZodLiteral<"vecbool">, z.ZodLiteral<"vecaddress">, z.ZodLiteral<"vecstring">, z.ZodLiteral<"vecu8">, z.ZodLiteral<"vecu16">, z.ZodLiteral<"vecu32">, z.ZodLiteral<"vecu64">, z.ZodLiteral<"vecu128">, z.ZodLiteral<"vecu256">, z.ZodLiteral<"vecvecu8">]>>;
235
235
  value: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodUnion<readonly [z.ZodObject<{
236
236
  name_or_address: z.ZodOptional<z.ZodString>;
237
237
  local_mark_first: z.ZodOptional<z.ZodBoolean>;