@wowok/agent-mcp 3.3.6 → 3.3.7
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.
- package/dist/chain-semantics/eval-order.js +1 -1
- package/dist/chain-semantics/field-capability.js +1 -1
- package/dist/chain-semantics/fund-flow.js +1 -1
- package/dist/chain-semantics/guard-verbs.js +1 -1
- package/dist/chain-semantics/object-graph.js +1 -1
- package/dist/composition/audit.js +1 -1
- package/dist/composition/compile.d.ts +2 -1
- package/dist/composition/compile.js +1 -1
- package/dist/composition/materialize.js +1 -1
- package/dist/data/projection/facets.spec.js +1 -1
- package/dist/evaluation/match-policy.d.ts +30 -6
- package/dist/evaluation/match-policy.js +1 -1
- package/dist/evaluation/match-policy.spec.js +1 -1
- package/dist/extensions/business-modules.js +1 -1
- package/dist/harness/recover.js +1 -1
- package/dist/intent/types.d.ts +1 -1
- package/dist/intent/types.js +1 -1
- package/dist/keeper/detectors.d.ts +3 -0
- package/dist/keeper/detectors.js +1 -1
- package/dist/keeper/keeper.spec.js +1 -1
- package/dist/knowledge/allocator-rail-verifier.js +1 -1
- package/dist/knowledge/audit-rules.js +1 -1
- package/dist/knowledge/baselines/rules/plan.json +97 -2
- package/dist/knowledge/builtin-templates.d.ts +6 -1
- package/dist/knowledge/builtin-templates.js +1 -1
- package/dist/knowledge/event-semantics.js +1 -1
- package/dist/knowledge/guard-design-patterns.js +1 -1
- package/dist/knowledge/guard-templates.d.ts +1 -1
- package/dist/knowledge/guard-templates.js +1 -1
- package/dist/knowledge/industry-generalizer.d.ts +4 -0
- package/dist/knowledge/industry-generalizer.js +1 -1
- package/dist/knowledge/semantic-ir.d.ts +113 -0
- package/dist/knowledge/semantic-ir.js +1 -0
- package/dist/knowledge/strategy-manuals.js +1 -1
- package/dist/knowledge/template-loader.d.ts +34 -0
- package/dist/knowledge/template-loader.js +1 -1
- package/dist/knowledge/template-prose.d.ts +50 -0
- package/dist/knowledge/template-prose.js +1 -0
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/template-scanner.d.ts +1 -1
- package/dist/knowledge/template-scanner.js +1 -1
- package/dist/knowledge/tools-reference.js +1 -1
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/monitor/normalize.d.ts +1 -1
- package/dist/monitor/normalize.js +1 -1
- package/dist/monitor/types.js +1 -1
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/machine-panorama.js +1 -1
- package/dist/playbooks/service-build/merchant-guide.d.ts +4 -0
- package/dist/playbooks/service-build/merchant-guide.js +1 -1
- package/dist/playbooks/service-build/migration-planner.d.ts +2 -1
- package/dist/playbooks/service-build/migration-planner.js +1 -1
- package/dist/playbooks/service-build/mode-actions.d.ts +7 -0
- package/dist/playbooks/service-build/mode-actions.js +1 -1
- package/dist/playbooks/service-build/object-panorama.d.ts +22 -1
- package/dist/playbooks/service-build/object-panorama.js +1 -1
- package/dist/playbooks/service-build/participation-radar.js +1 -1
- package/dist/playbooks/service-build/relationship-profile.js +1 -1
- package/dist/playbooks/service-build/reverse-mapping-nk4.spec.js +1 -1
- package/dist/playbooks/service-build/reverse-mapping.d.ts +1 -0
- package/dist/playbooks/service-build/reverse-mapping.js +1 -1
- package/dist/playbooks/service-build/service-panorama.js +1 -1
- package/dist/playbooks/service-build/service-quote.js +1 -1
- package/dist/review/index.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/benchmark-migration/index.d.ts +64 -10
- package/dist/schema/benchmark-migration/index.js +1 -1
- package/dist/schema/call/arbitration.js +1 -1
- package/dist/schema/call/base.d.ts +8 -0
- package/dist/schema/call/bridge.d.ts +2 -0
- package/dist/schema/call/error-codes.d.ts +1 -1
- package/dist/schema/call/error-codes.js +1 -1
- package/dist/schema/call/reward.d.ts +10 -0
- package/dist/schema/call/reward.js +1 -1
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.js +1 -1
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/evaluation/index.d.ts +152 -0
- package/dist/schema/evaluation/index.js +1 -1
- package/dist/schema/goal/index.d.ts +2 -0
- package/dist/schema/goal/planning.d.ts +3 -0
- package/dist/schema/goal/planning.js +1 -1
- package/dist/schema/industry-pack/index.d.ts +62 -0
- package/dist/schema/industry-pack/modes.d.ts +62 -0
- package/dist/schema/industry-pack/modes.js +1 -1
- package/dist/schema/intent-radar/index.d.ts +3 -0
- package/dist/schema/intent-radar/index.js +1 -1
- package/dist/schema/local/index.d.ts +20 -0
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/operations.d.ts +5 -0
- package/dist/schema/query/index.d.ts +145 -47
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +2 -0
- package/dist/schemas/benchmark_migration_operation.output.json +42 -0
- package/dist/schemas/benchmark_migration_operation.schema.json +208 -5
- package/dist/schemas/bridge_operation.output.json +2 -0
- package/dist/schemas/evaluation_operation.output.json +240 -0
- package/dist/schemas/evaluation_operation.schema.json +397 -1
- package/dist/schemas/goal_operation.schema.json +18 -10
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/industry_pack_operation.output.json +86 -2
- package/dist/schemas/industry_pack_operation.schema.json +199 -0
- package/dist/schemas/intent_radar.output.json +2 -0
- package/dist/schemas/intent_radar.schema.json +1 -0
- package/dist/schemas/local_cache_operation.output.json +2 -0
- package/dist/schemas/local_history_operation.output.json +2 -0
- package/dist/schemas/local_info_operation.output.json +2 -0
- package/dist/schemas/local_mark_operation.output.json +2 -0
- package/dist/schemas/onchain_events.output.json +281 -11
- package/dist/schemas/onchain_events.schema.json +5 -1
- package/dist/schemas/onchain_operations.output.json +2 -0
- package/dist/schemas/onchain_operations.schema.json +37 -3
- package/dist/schemas/onchain_operations_arbitration.schema.json +1 -1
- package/dist/schemas/onchain_operations_reward.schema.json +35 -1
- package/dist/schemas/onchain_operations_service.schema.json +1 -1
- package/dist/schemas/query_toolkit.output.json +34 -0
- package/dist/tools/handlers/benchmark-migration.d.ts +1 -0
- package/dist/tools/handlers/benchmark-migration.js +1 -1
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/evaluation.js +1 -1
- package/dist/tools/handlers/evaluation.spec.js +1 -1
- package/dist/tools/handlers/intent-radar.js +1 -1
- package/dist/tools/handlers/messenger.d.ts +1 -0
- package/dist/tools/handlers/messenger.js +1 -1
- package/dist/tools/handlers/onchain.d.ts +1 -0
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/handlers/wip.js +1 -1
- package/dist/tools/registry/agent.js +1 -1
- package/dist/tools/registry/query.js +1 -1
- package/dist/tools/wip-verify-ledger.d.ts +14 -0
- package/dist/tools/wip-verify-ledger.js +1 -0
- package/dist/tools/wrap.d.ts +4 -0
- package/dist/tools/wrap.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Config,LocalMark,query_serviceContext,query_object_last_updated,query_affiliations,objectTypeFromAddress,ObjectType}from'@wowok/wowok';import{resolveAddress as a387a}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{computeFundListingWall}from'../../graph/onchain/facts.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 a387a(c,'service'),l=await query_serviceContext({'service':k,'include_machine_nodes':!![],'network':h});if(!l?.['service']&&d){const ac=await Config['Instance']()['network_get']();ac&&ac!==h&&(h=ac,l=await query_serviceContext({'service':k,'include_machine_nodes':!![],'network':h}));}const m=l['service'];k=m['object']??k;const q=new Set(),w=ad=>{if(ad)q['add'](ad);};w(k),w(m['machine']),w(m['permission']),w(m['um']);for(const ad of m['arbitrations']??[])w(ad);for(const ae of m['rewards']??[])w(ae);for(const af of m['repositories']??[])w(af);const x=l['permission'];if(x){const ag=Array['isArray'](x['admin'])?x['admin']:[];ag[0x0]&&w(typeof ag[0x0]==='string'?ag[0x0]:ag[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=ah=>ah?y['get'](ah)??{'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:ah,edges:ai}=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':ah,'edges':ai};}let F=null;try{const aj=await query_object_last_updated({'object':k,'network':h});aj?.['timestamp_ms']&&(F={'timestamp_ms':aj['timestamp_ms'],'digest':aj['digest']??null,'sender':aj['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=(ak,al)=>{const am=[];return ak?am['push']('Pricing\x20&\x20settlement\x20coin:\x20'+ak+'\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.'):am['push']('Pricing\x20&\x20settlement\x20coin:\x20unavailable\x20from\x20the\x20Service\x20type\x20(no\x20generic\x20found)\x20—\x20treat\x20amounts\x20as\x20raw\x20smallest\x20units.'),am['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'](al)?am['push']('Testnet\x20has\x20ONLY\x20WOW\x20(no\x20stablecoins\x20are\x20bridged)\x20—\x20testnet\x20services\x20stay\x20WOW-denominated;\x20multi-token\x20pricing\x20is\x20a\x20mainnet\x20capability.'):am['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.'),am['join']('\x20');},N=ak=>formatMoneyAnnotation(ak,L,h),O=0x3,P=0x32;let Q=null;try{const ak=await fetchServiceOrders(k,h,!![]),al=Array['isArray'](ak?.['items'])?ak['items']:[],am=al['slice'](-P),an=al['slice'](-O),ao=am['map'](aM=>typeof aM?.['who']==='string'?aM['who']:'')['filter'](aM=>aM!==''),ap=an['map'](aM=>typeof aM?.['who']==='string'?aM['who']:'')['filter'](aM=>aM!==''),aq=new Map();try{if(ao['length']>0x0){const aM=await batchQueryObjectsByIds(ao,h,!![]);for(const aN of aM){aN&&aN['type']===ObjectType['Order']&&aq['set'](aN['object'],aN);}}}catch{j['push']('recent_orders:\x20order\x20details\x20unavailable\x20(non-blocking)');}const ar=new Map();try{const aO=new Set();for(const aP of aq['values']()){if(aP?.['allocation'])aO['add'](aP['allocation']);}if(aO['size']>0x0){const aQ=await batchQueryObjectsByIds(Array['from'](aO),h,!![]);for(const aR of aQ){if(!aR?.['object'])continue;if(aR['type']===ObjectType['Allocation']){const aS=Number(aR?.['balance']??0x0);ar['set'](aR['object'],Number['isFinite'](aS)&&aS===0x0?'allocated':'pending');}}}}catch{j['push']('recent_orders:\x20allocation\x20details\x20unavailable\x20(non-blocking)');}const as=new Map(),at=new Map();try{const aT=new Set();for(const aU of ap){const aV=aq['get'](aU);if(aV?.['progress'])aT['add'](aV['progress']);}if(aT['size']>0x0){const aW=await batchQueryObjectsByIds(Array['from'](aT),h,!![]);for(const aX of aW){if(!aX?.['object'])continue;if(aX['type']===ObjectType['Progress']){const aY=aX?.['current'];as['set'](aX['object'],typeof aY==='string'&&aY!==''?aY:null),at['set'](aX['object'],Number(aX?.['current_time'])||null);}}}}catch{j['push']('recent_orders:\x20progress\x20details\x20unavailable\x20(non-blocking)');}I=Array['from'](aq['values']())['map'](aZ=>({'id':aZ['object'],'created_at_ms':Number(aZ['time'])||undefined,'claimed_by':aZ['claimed_by']??null,'current_node':aZ['progress']?as['get'](aZ['progress'])??null:null}));const au=new Map();try{const aZ=ap,b0=await Promise['allSettled'](aZ['map'](b1=>query_object_last_updated({'object':b1,'network':h})));for(let b1=0x0;b1<aZ['length'];b1++){const b2=b0[b1];au['set'](aZ[b1],b2['status']==='fulfilled'&&b2['value']?.['timestamp_ms']?Number(b2['value']['timestamp_ms'])||null:null);}}catch{j['push']('recent_orders:\x20order\x20updated\x20times\x20unavailable\x20(non-blocking)');}const av=await Promise['all'](an['map'](async b3=>{const b4=typeof b3?.['who']==='string'?b3['who']:'',b5=aq['get'](b4),b6=b5?.['amount']!==null&&b5?.['amount']!==undefined?String(b5['amount']):'',b7=await N(b6);return{'order':b4,'time':typeof b3?.['time']==='number'?b3['time']:0x0,'updated_ms':au['get'](b4)??null,'amount':b6,'amount_display':b7['display'],'amount_tip':b7['tip'],'progress':b5?.['progress']??null,'allocation':b5?.['allocation']??null,'disputes':Array['isArray'](b5?.['dispute'])?b5['dispute']:[],'agent':Array['isArray'](b5?.['agent'])?b5['agent']:[],'owner':ownerAddr(b5?.['builder']??b5?.['owner']),'claimed_by':b5?.['claimed_by']??null,'required_info':b5?.['required_info']??null,'progress_next':b5?.['progress']?as['get'](b5['progress'])??null:null,'progress_since':b5?.['progress']?at['get'](b5['progress'])??null:null,'allocation_state':b5?.['allocation']?ar['get'](b5['allocation'])??'pending':'none','bought':await Promise['all']((Array['isArray'](b5?.['items'])?b5['items']:[])['map'](async b8=>({'name':String(b8?.['name']??''),'price_display':(await N(b8?.['price']!==null&&b8?.['price']!==undefined?String(b8['price']):null))['display'],'quantity':String(b8?.['quantity']??'0'),'wip_hash':String(b8?.['wip_hash']??'')})))};})),aw=av['filter'](b3=>b3['order']!==''),ax=ao['map'](b3=>aq['get'](b3))['filter'](b3=>!!b3);let ay=0x0n,az=0x0,aA=0x0,aB=0x0,aC=0x0,aD=0x0,aE=null,aF=null;for(const b3 of ax){const b4=b3?.['amount']!==null&&b3?.['amount']!==undefined?String(b3['amount']):'';/^\d+$/['test'](b4)&&(ay+=BigInt(b4),az++);if(Array['isArray'](b3?.['dispute'])&&b3['dispute']['length']>0x0)aA++;const b5=b3?.['allocation']?ar['get'](b3['allocation'])??'pending':'none';if(b5==='pending')aB++;else{if(b5==='allocated')aC++;else aD++;}}for(const b6 of am){if(typeof b6?.['time']==='number'){if(aE===null||b6['time']<aE)aE=b6['time'];if(aF===null||b6['time']>aF)aF=b6['time'];}}const aG=az>0x0?ay['toString']():null,aH=aG!==null?await N(aG):null,aI=al['length'],aJ=ak?.['ring_saturated']??ringWindowSaturated(aI),aK=aw['length'],aL='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'+aI+(aJ?',\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':aI,'window_saturated':aJ,'preview_truncated':aI>aK,'stats':{'scope_count':ax['length'],'scoped':ax['length']<aI,'amount_sum_raw':aG,'amount_sum_display':aH?.['display']??null,'amount_sum_tip':aH?.['tip']??null,'amount_known_count':az,'disputed_order_count':aA,'allocation_pending_count':aB,'allocation_allocated_count':aC,'allocation_none_count':aD,'first_created_ms':aE,'last_created_ms':aF},...aI>aK?{'drilldown':{'total_count':aI,'analyzed_count':aK,'stats_scope_count':ax['length'],'prompt':aL},'order_addresses':ax['map'](b7=>b7['object'])}:{},'items':aw};}catch{j['push']('recent_orders:\x20reverse-index\x20query\x20failed\x20(non-blocking)');}try{const b7=[m,l['machine'],l['buy_guard'],...l['allocator_guards']??[]]['filter'](Boolean);H=generateBusinessReport({'objects':b7,'machine_nodes':E['map'](b8=>({'name':b8['name']})),'machine_edges':C?.['edges']?C['edges']['map'](b8=>({'from':b8['from'],'to':b8['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 b8=await query_affiliations({'address':k,'no_cache':!![],'network':h}),b9=new Set(),ba=new Map();for(const bc of b8?.['entries']??[]){const bd=typeof bc?.['who']==='string'?bc['who']:'';if(!bd||b9['has'](bd))continue;b9['add'](bd);const be=objectTypeFromAddress(bd);if(!be)continue;if(be===ObjectType['Order'])continue;const bf=String(be);let bg=ba['get'](bf);!bg&&(bg=[],ba['set'](bf,bg)),bg['push']({'address':bd,'type_label':bf,'name':B(bd)['name'],'time':typeof bc?.['time']==='number'?bc['time']:null,'via':typeof bc?.['table']==='string'?bc['table']:null});}const bb=['Progress','Allocation','Payment','Guard'];for(const bh of bb){const bi=ba['get'](bh);bi&&bi['length']>0x0&&(R['push']({'type_label':bh,'items':bi}),ba['delete'](bh));}for(const [bj,bk]of ba){if(bk['length']>0x0)R['push']({'type_label':bj,'items':bk});}}catch{j['push']('related:\x20global-table\x20lookup\x20failed\x20(non-blocking)');}const S=new Set(),T=bl=>{typeof bl==='string'&&/^0x[0-9a-fA-F]{40,64}$/['test'](bl)&&S['add'](bl['toLowerCase']());};T(m['buy_guard']);for(const bl of E){for(const bm of bl?.['pairs']??[]){for(const bn of bm?.['forwards']??[])T(bn?.['guard']);}}for(const bo of m['order_allocators']?.['allocators']??[])T(bo?.['guard']);for(const bp of l['allocator_guards']??[])T(bp?.['object']);for(const bq of Object['values'](l['referenced']??{})){const br=bq;if(!br||typeof br!=='object')continue;if(br['type']===ObjectType['Reward']){for(const bs of br['guards']??[])T(bs?.['guard']);}if(br['type']===ObjectType['Treasury']){for(const bt of br['external_withdraw_guard']??[])T(bt?.['guard']);for(const bu of br['external_deposit_guard']??[])T(bu?.['guard']);}(br['type']===ObjectType['Arbitration']||br['type']===ObjectType['Arb'])&&T(br['voting_guard']);}const U=R['find'](bv=>bv['type_label']===String(ObjectType['Guard']));if(U){U['items']=U['items']['filter'](bv=>!S['has'](bv['address']['toLowerCase']()));if(U['items']['length']===0x0)R['splice'](R['indexOf'](U),0x1);else{const bv=U['items'];try{const bw=await batchQueryObjectsByIds(bv['map'](by=>by['address']),h,!![]),bx=new Map();for(const by of bw){if(by?.['object'])bx['set'](String(by['object'])['toLowerCase'](),by);}for(const bz of bv){const bA=bx['get'](bz['address']['toLowerCase']());if(!bA){bz['explanation']=null;continue;}const bB=Array['isArray'](bA['table'])?bA['table']:[],bC=[];let bD=0x0;for(const bF of bB){if(bF?.['b_submission']===!![]){bD++;continue;}bF?.['value_type']==='Address'&&typeof bF?.['value']==='string'&&bF['value']['startsWith']('0x')&&bC['push'](bF['value']);}const bE=bC['some'](bG=>bG['toLowerCase']()===k['toLowerCase']());bz['explanation']={'description':typeof bA['description']==='string'?bA['description']:null,'table_refs':bC,'references_this_service':bE,'submission_slots':bD,'note':bE?'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 bG of l['allocator_guards']??[]){const bH=bG;if(bH?.['object'])V['set'](String(bH['object'])['toLowerCase'](),bH);}const W=[];for(const bI of Array['isArray'](m['sales'])?m['sales']:[]){const bJ=balanceStr(bI?.['price']),bK=await N(bJ);W['push']({'name':typeof bI?.['name']==='string'?bI['name']:'','price':bJ,'price_display':bK['display'],'price_tip':bK['tip'],'stock':balanceStr(bI?.['stock']),'suspension':bI?.['suspension']===!![],'wip':typeof bI?.['wip']==='string'?bI['wip']:'','wip_hash':typeof bI?.['wip_hash']==='string'?bI['wip_hash']:''});}const X=bL=>bL===0x0?'amount':bL===0x2?'surplus':'rate',Y=bL=>{const bM=bL?.['who'];if(bM&&typeof bM==='object'&&'Entity'in bM){const bN=bM['Entity'],bO=typeof bN==='string'?bN:typeof bN?.['name_or_address']==='string'?bN['name_or_address']:null;return{'who':bO?'Entity\x20'+bO:'Entity','entity':bO&&/^0x[0-9a-fA-F]{6,64}$/['test'](bO)?bO:null,'mode':X(bL?.['mode']),'value':balanceStr(bL?.['sharing'])};}if(bM&&typeof bM==='object'&&'GuardIdentifier'in bM)return{'who':'Guard\x20identifier\x20#'+bM['GuardIdentifier'],'entity':null,'mode':X(bL?.['mode']),'value':balanceStr(bL?.['sharing'])};return{'who':'Signer','entity':null,'mode':X(bL?.['mode']),'value':balanceStr(bL?.['sharing'])};},Z=m['order_allocators']?{'description':m['order_allocators']['description']??'','threshold':balanceStr(m['order_allocators']['threshold']),'allocators':(m['order_allocators']['allocators']??[])['map'](bL=>({'guard':bL['guard'],'sharing_count':Array['isArray'](bL['sharing'])?bL['sharing']['length']:0x0,'sharing':(Array['isArray'](bL['sharing'])?bL['sharing']:[])['map'](Y),'max':balanceStr(bL['max']??null),'guard_summary':summarizeGuard(V['get'](String(bL['guard']??'')['toLowerCase']()))}))}:null,a0=[];{const bL=new Map();for(const bM of m['order_allocators']?.['allocators']??[]){for(const bN of Array['isArray'](bM['sharing'])?bM['sharing']:[]){const bO=Y(bN);if(bO['entity']){const bP=bO['entity']['toLowerCase'](),bQ=bL['get'](bP)??{'raw':bO['entity'],'guards':[]};bQ['guards']['push'](bM['guard']??''),bL['set'](bP,bQ);}}}if(bL['size']>0x0)try{const bR=await batchQueryObjectsByIds([...bL['keys']()],h,!![]),bS=new Map();for(const bT of bR){if(bT?.['object'])bS['set'](String(bT['object'])['toLowerCase'](),bT);}for(const [bU,bV]of bL){const bW=bS['get'](bU),bX='order_allocators\x20sharing\x20of\x20allocator\x20guard\x20'+bV['guards'][0x0];if(bW&&bW['permission']!==undefined){const bY=balanceStr(bW['balance']),bZ=await N(bY);a0['push']({'address':String(bW['object']),'kind':'treasury','description':typeof bW['description']==='string'?bW['description']:null,'permission':typeof bW['permission']==='string'?bW['permission']:null,'balance':bY,'balance_display':bZ['display'],'balance_tip':bZ['tip'],'external_deposit_guard_count':Array['isArray'](bW['external_deposit_guard'])?bW['external_deposit_guard']['length']:null,'external_withdraw_guard_count':Array['isArray'](bW['external_withdraw_guard'])?bW['external_withdraw_guard']['length']:null,'via':bX});}else a0['push']({'address':bV['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':bX});}}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=balanceStr(m['compensation_fund']),a6=/^\d+$/['test'](a5?.['trim']()??'')?BigInt(a5['trim']()):null,a7=a6===null?null:(a6/0x3n)['toString'](),a8=a7===null?null:await N(a7),a9=a6===null?null:a6===0x0n?'No\x20compensation\x20fund:\x20this\x20Service\x20carries\x20NO\x20payout\x20protection\x20—\x20a\x20won\x20arbitration\x20award\x20cannot\x20be\x20paid\x20(the\x20claim\x20aborts,\x20code\x2027).\x20Running\x20without\x20a\x20fund\x20is\x20a\x20legitimate\x20merchant\x20choice,\x20but\x20it\x20is\x20one\x20a\x20buyer\x20should\x20see\x20before\x20ordering.':'Orders\x20at\x20or\x20under\x20this\x20cap\x20are\x20fully\x20protected\x20(award\x20ceiling\x203x\x20order).\x20Above\x20the\x20cap\x20there\x20is\x20NO\x20partial\x20payout\x20—\x20settlement\x20is\x20all-or-nothing\x20and\x20the\x20claim\x20aborts\x20(code\x2027)\x20until\x20the\x20fund\x20covers\x20the\x20award;\x20the\x20order\x20itself\x20is\x20unaffected.';let aa=null;if(a6!==null&&a6>0x0n){const c0=W['filter'](c4=>!c4['suspension']&&/^\d+$/['test'](c4['price']?.['trim']()??''))['map'](c4=>({'name':c4['name'],'price':BigInt(c4['price']['trim']())})),c1=computeFundListingWall(a6,c0),c2=await Promise['all'](c1['blocked']['map'](async c4=>({'name':c4['name'],'price':c4['price']['toString'](),'price_display':(await N(c4['price']['toString']()))['display']}))),c3=c2['length']===0x0?null:'The\x20fund\x20currently\x20backs\x20orders\x20up\x20to\x20'+(a8?.['display']??a7)+'.\x20'+((c2['length']===0x1?'1\x20listing\x20is':c2['length']+'\x20listings\x20are')+'\x20priced\x20above\x20that\x20and\x20cannot\x20be\x20checked\x20out\x20—\x20the\x20buy\x20gate\x20refuses\x20the\x20order\x20(no\x20money\x20moves)\x20because\x20the\x20fund\x20cannot\x20back\x20its\x20maximum\x20award.\x20')+'The\x20highest-priced\x20listing\x20is\x20blocked\x20first;\x20top\x20the\x20fund\x20above\x203x\x20a\x20listing\x27s\x20price\x20(service.compensation_fund_add)\x20or\x20cut\x20the\x20price\x20to\x20restore\x20it.\x20'+'This\x20recomputes\x20on\x20every\x20read:\x20after\x20every\x20award\x20that\x20spends\x20the\x20fund,\x20re-check\x20your\x20top\x20listing.';aa={'blocked':c2,'note':c3};}const ab=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'],'compensation_fund_cover_cap':a7,'compensation_fund_cover_cap_display':a8?.['display']??null,'compensation_fund_cover_cap_note':a9,'compensation_fund_listing_wall':aa,'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,...ab['open_questions']['length']>0x0?{'exploration':ab}:{}};}
|
|
1
|
+
import{Config,LocalMark,query_serviceContext,query_object_last_updated,query_affiliations,objectTypeFromAddress,ObjectType}from'@wowok/wowok';import{resolveAddress as a389a}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{computeFundListingWall}from'../../graph/onchain/facts.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 a389a(c,'service'),l=await query_serviceContext({'service':k,'include_machine_nodes':!![],'network':h});if(!l?.['service']&&d){const ac=await Config['Instance']()['network_get']();ac&&ac!==h&&(h=ac,l=await query_serviceContext({'service':k,'include_machine_nodes':!![],'network':h}));}const m=l['service'];k=m['object']??k;const q=new Set(),w=ad=>{if(ad)q['add'](ad);};w(k),w(m['machine']),w(m['permission']),w(m['um']);for(const ad of m['arbitrations']??[])w(ad);for(const ae of m['rewards']??[])w(ae);for(const af of m['repositories']??[])w(af);const x=l['permission'];if(x){const ag=Array['isArray'](x['admin'])?x['admin']:[];ag[0x0]&&w(typeof ag[0x0]==='string'?ag[0x0]:ag[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=ah=>ah?y['get'](ah)??{'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:ah,edges:ai}=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':ah,'edges':ai};}let F=null;try{const aj=await query_object_last_updated({'object':k,'network':h});aj?.['timestamp_ms']&&(F={'timestamp_ms':aj['timestamp_ms'],'digest':aj['digest']??null,'sender':aj['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=(ak,al)=>{const am=[];return ak?am['push']('Pricing\x20&\x20settlement\x20coin:\x20'+ak+'\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.'):am['push']('Pricing\x20&\x20settlement\x20coin:\x20unavailable\x20from\x20the\x20Service\x20type\x20(no\x20generic\x20found)\x20—\x20treat\x20amounts\x20as\x20raw\x20smallest\x20units.'),am['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'](al)?am['push']('Testnet\x20has\x20ONLY\x20WOW\x20(no\x20stablecoins\x20are\x20bridged)\x20—\x20testnet\x20services\x20stay\x20WOW-denominated;\x20multi-token\x20pricing\x20is\x20a\x20mainnet\x20capability.'):am['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.'),am['join']('\x20');},N=ak=>formatMoneyAnnotation(ak,L,h),O=0x3,P=0x32;let Q=null;try{const ak=await fetchServiceOrders(k,h,!![]),al=Array['isArray'](ak?.['items'])?ak['items']:[],am=al['slice'](-P),an=al['slice'](-O),ao=am['map'](aM=>typeof aM?.['who']==='string'?aM['who']:'')['filter'](aM=>aM!==''),ap=an['map'](aM=>typeof aM?.['who']==='string'?aM['who']:'')['filter'](aM=>aM!==''),aq=new Map();try{if(ao['length']>0x0){const aM=await batchQueryObjectsByIds(ao,h,!![]);for(const aN of aM){aN&&aN['type']===ObjectType['Order']&&aq['set'](aN['object'],aN);}}}catch{j['push']('recent_orders:\x20order\x20details\x20unavailable\x20(non-blocking)');}const ar=new Map();try{const aO=new Set();for(const aP of aq['values']()){if(aP?.['allocation'])aO['add'](aP['allocation']);}if(aO['size']>0x0){const aQ=await batchQueryObjectsByIds(Array['from'](aO),h,!![]);for(const aR of aQ){if(!aR?.['object'])continue;if(aR['type']===ObjectType['Allocation']){const aS=Number(aR?.['balance']??0x0);ar['set'](aR['object'],Number['isFinite'](aS)&&aS===0x0?'allocated':'pending');}}}}catch{j['push']('recent_orders:\x20allocation\x20details\x20unavailable\x20(non-blocking)');}const as=new Map(),at=new Map();try{const aT=new Set();for(const aU of ap){const aV=aq['get'](aU);if(aV?.['progress'])aT['add'](aV['progress']);}if(aT['size']>0x0){const aW=await batchQueryObjectsByIds(Array['from'](aT),h,!![]);for(const aX of aW){if(!aX?.['object'])continue;if(aX['type']===ObjectType['Progress']){const aY=aX?.['current'];as['set'](aX['object'],typeof aY==='string'&&aY!==''?aY:null),at['set'](aX['object'],Number(aX?.['current_time'])||null);}}}}catch{j['push']('recent_orders:\x20progress\x20details\x20unavailable\x20(non-blocking)');}I=Array['from'](aq['values']())['map'](aZ=>({'id':aZ['object'],'created_at_ms':Number(aZ['time'])||undefined,'claimed_by':aZ['claimed_by']??null,'current_node':aZ['progress']?as['get'](aZ['progress'])??null:null}));const au=new Map();try{const aZ=ap,b0=await Promise['allSettled'](aZ['map'](b1=>query_object_last_updated({'object':b1,'network':h})));for(let b1=0x0;b1<aZ['length'];b1++){const b2=b0[b1];au['set'](aZ[b1],b2['status']==='fulfilled'&&b2['value']?.['timestamp_ms']?Number(b2['value']['timestamp_ms'])||null:null);}}catch{j['push']('recent_orders:\x20order\x20updated\x20times\x20unavailable\x20(non-blocking)');}const av=await Promise['all'](an['map'](async b3=>{const b4=typeof b3?.['who']==='string'?b3['who']:'',b5=aq['get'](b4),b6=b5?.['amount']!==null&&b5?.['amount']!==undefined?String(b5['amount']):'',b7=await N(b6);return{'order':b4,'time':typeof b3?.['time']==='number'?b3['time']:0x0,'updated_ms':au['get'](b4)??null,'amount':b6,'amount_display':b7['display'],'amount_tip':b7['tip'],'progress':b5?.['progress']??null,'allocation':b5?.['allocation']??null,'disputes':Array['isArray'](b5?.['dispute'])?b5['dispute']:[],'agent':Array['isArray'](b5?.['agent'])?b5['agent']:[],'owner':ownerAddr(b5?.['builder']??b5?.['owner']),'claimed_by':b5?.['claimed_by']??null,'required_info':b5?.['required_info']??null,'progress_next':b5?.['progress']?as['get'](b5['progress'])??null:null,'progress_since':b5?.['progress']?at['get'](b5['progress'])??null:null,'allocation_state':b5?.['allocation']?ar['get'](b5['allocation'])??'pending':'none','bought':await Promise['all']((Array['isArray'](b5?.['items'])?b5['items']:[])['map'](async b8=>({'name':String(b8?.['name']??''),'price_display':(await N(b8?.['price']!==null&&b8?.['price']!==undefined?String(b8['price']):null))['display'],'quantity':String(b8?.['quantity']??'0'),'wip_hash':String(b8?.['wip_hash']??'')})))};})),aw=av['filter'](b3=>b3['order']!==''),ax=ao['map'](b3=>aq['get'](b3))['filter'](b3=>!!b3);let ay=0x0n,az=0x0,aA=0x0,aB=0x0,aC=0x0,aD=0x0,aE=null,aF=null;for(const b3 of ax){const b4=b3?.['amount']!==null&&b3?.['amount']!==undefined?String(b3['amount']):'';/^\d+$/['test'](b4)&&(ay+=BigInt(b4),az++);if(Array['isArray'](b3?.['dispute'])&&b3['dispute']['length']>0x0)aA++;const b5=b3?.['allocation']?ar['get'](b3['allocation'])??'pending':'none';if(b5==='pending')aB++;else{if(b5==='allocated')aC++;else aD++;}}for(const b6 of am){if(typeof b6?.['time']==='number'){if(aE===null||b6['time']<aE)aE=b6['time'];if(aF===null||b6['time']>aF)aF=b6['time'];}}const aG=az>0x0?ay['toString']():null,aH=aG!==null?await N(aG):null,aI=al['length'],aJ=ak?.['ring_saturated']??ringWindowSaturated(aI),aK=aw['length'],aL='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'+aI+(aJ?',\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':aI,'window_saturated':aJ,'preview_truncated':aI>aK,'stats':{'scope_count':ax['length'],'scoped':ax['length']<aI,'amount_sum_raw':aG,'amount_sum_display':aH?.['display']??null,'amount_sum_tip':aH?.['tip']??null,'amount_known_count':az,'disputed_order_count':aA,'allocation_pending_count':aB,'allocation_allocated_count':aC,'allocation_none_count':aD,'first_created_ms':aE,'last_created_ms':aF},...aI>aK?{'drilldown':{'total_count':aI,'analyzed_count':aK,'stats_scope_count':ax['length'],'prompt':aL},'order_addresses':ax['map'](b7=>b7['object'])}:{},'items':aw};}catch{j['push']('recent_orders:\x20reverse-index\x20query\x20failed\x20(non-blocking)');}try{const b7=[m,l['machine'],l['buy_guard'],...l['allocator_guards']??[]]['filter'](Boolean);H=generateBusinessReport({'objects':b7,'machine_nodes':E['map'](b8=>({'name':b8['name']})),'machine_edges':C?.['edges']?C['edges']['map'](b8=>({'from':b8['from'],'to':b8['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 b8=await query_affiliations({'address':k,'no_cache':!![],'network':h}),b9=new Set(),ba=new Map();for(const bc of b8?.['entries']??[]){const bd=typeof bc?.['who']==='string'?bc['who']:'';if(!bd||b9['has'](bd))continue;b9['add'](bd);const be=objectTypeFromAddress(bd);if(!be)continue;if(be===ObjectType['Order'])continue;const bf=String(be);let bg=ba['get'](bf);!bg&&(bg=[],ba['set'](bf,bg)),bg['push']({'address':bd,'type_label':bf,'name':B(bd)['name'],'time':typeof bc?.['time']==='number'?bc['time']:null,'via':typeof bc?.['table']==='string'?bc['table']:null});}const bb=['Progress','Allocation','Payment','Guard'];for(const bh of bb){const bi=ba['get'](bh);bi&&bi['length']>0x0&&(R['push']({'type_label':bh,'items':bi}),ba['delete'](bh));}for(const [bj,bk]of ba){if(bk['length']>0x0)R['push']({'type_label':bj,'items':bk});}}catch{j['push']('related:\x20global-table\x20lookup\x20failed\x20(non-blocking)');}const S=new Set(),T=bl=>{typeof bl==='string'&&/^0x[0-9a-fA-F]{40,64}$/['test'](bl)&&S['add'](bl['toLowerCase']());};T(m['buy_guard']);for(const bl of E){for(const bm of bl?.['pairs']??[]){for(const bn of bm?.['forwards']??[])T(bn?.['guard']);}}for(const bo of m['order_allocators']?.['allocators']??[])T(bo?.['guard']);for(const bp of l['allocator_guards']??[])T(bp?.['object']);for(const bq of Object['values'](l['referenced']??{})){const br=bq;if(!br||typeof br!=='object')continue;if(br['type']===ObjectType['Reward']){for(const bs of br['guards']??[])T(bs?.['guard']);}if(br['type']===ObjectType['Treasury']){for(const bt of br['external_withdraw_guard']??[])T(bt?.['guard']);for(const bu of br['external_deposit_guard']??[])T(bu?.['guard']);}(br['type']===ObjectType['Arbitration']||br['type']===ObjectType['Arb'])&&T(br['voting_guard']);}const U=R['find'](bv=>bv['type_label']===String(ObjectType['Guard']));if(U){U['items']=U['items']['filter'](bv=>!S['has'](bv['address']['toLowerCase']()));if(U['items']['length']===0x0)R['splice'](R['indexOf'](U),0x1);else{const bv=U['items'];try{const bw=await batchQueryObjectsByIds(bv['map'](by=>by['address']),h,!![]),bx=new Map();for(const by of bw){if(by?.['object'])bx['set'](String(by['object'])['toLowerCase'](),by);}for(const bz of bv){const bA=bx['get'](bz['address']['toLowerCase']());if(!bA){bz['explanation']=null;continue;}const bB=Array['isArray'](bA['table'])?bA['table']:[],bC=[];let bD=0x0;for(const bF of bB){if(bF?.['b_submission']===!![]){bD++;continue;}bF?.['value_type']==='Address'&&typeof bF?.['value']==='string'&&bF['value']['startsWith']('0x')&&bC['push'](bF['value']);}const bE=bC['some'](bG=>bG['toLowerCase']()===k['toLowerCase']());bz['explanation']={'description':typeof bA['description']==='string'?bA['description']:null,'table_refs':bC,'references_this_service':bE,'submission_slots':bD,'note':bE?'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 bG of l['allocator_guards']??[]){const bH=bG;if(bH?.['object'])V['set'](String(bH['object'])['toLowerCase'](),bH);}const W=[];for(const bI of Array['isArray'](m['sales'])?m['sales']:[]){const bJ=balanceStr(bI?.['price']),bK=await N(bJ);W['push']({'name':typeof bI?.['name']==='string'?bI['name']:'','price':bJ,'price_display':bK['display'],'price_tip':bK['tip'],'stock':balanceStr(bI?.['stock']),'suspension':bI?.['suspension']===!![],'wip':typeof bI?.['wip']==='string'?bI['wip']:'','wip_hash':typeof bI?.['wip_hash']==='string'?bI['wip_hash']:''});}const X=bL=>bL===0x0?'amount':bL===0x2?'surplus':'rate',Y=bL=>{const bM=bL?.['who'];if(bM&&typeof bM==='object'&&'Entity'in bM){const bN=bM['Entity'],bO=typeof bN==='string'?bN:typeof bN?.['name_or_address']==='string'?bN['name_or_address']:null;return{'who':bO?'Entity\x20'+bO:'Entity','entity':bO&&/^0x[0-9a-fA-F]{6,64}$/['test'](bO)?bO:null,'mode':X(bL?.['mode']),'value':balanceStr(bL?.['sharing'])};}if(bM&&typeof bM==='object'&&'GuardIdentifier'in bM)return{'who':'Guard\x20identifier\x20#'+bM['GuardIdentifier'],'entity':null,'mode':X(bL?.['mode']),'value':balanceStr(bL?.['sharing'])};return{'who':'Signer','entity':null,'mode':X(bL?.['mode']),'value':balanceStr(bL?.['sharing'])};},Z=m['order_allocators']?{'description':m['order_allocators']['description']??'','threshold':balanceStr(m['order_allocators']['threshold']),'allocators':(m['order_allocators']['allocators']??[])['map'](bL=>({'guard':bL['guard'],'sharing_count':Array['isArray'](bL['sharing'])?bL['sharing']['length']:0x0,'sharing':(Array['isArray'](bL['sharing'])?bL['sharing']:[])['map'](Y),'max':balanceStr(bL['max']??null),'guard_summary':summarizeGuard(V['get'](String(bL['guard']??'')['toLowerCase']()))}))}:null,a0=[];{const bL=new Map();for(const bM of m['order_allocators']?.['allocators']??[]){for(const bN of Array['isArray'](bM['sharing'])?bM['sharing']:[]){const bO=Y(bN);if(bO['entity']){const bP=bO['entity']['toLowerCase'](),bQ=bL['get'](bP)??{'raw':bO['entity'],'guards':[]};bQ['guards']['push'](bM['guard']??''),bL['set'](bP,bQ);}}}if(bL['size']>0x0)try{const bR=await batchQueryObjectsByIds([...bL['keys']()],h,!![]),bS=new Map();for(const bT of bR){if(bT?.['object'])bS['set'](String(bT['object'])['toLowerCase'](),bT);}for(const [bU,bV]of bL){const bW=bS['get'](bU),bX='order_allocators\x20sharing\x20of\x20allocator\x20guard\x20'+bV['guards'][0x0];if(bW&&bW['permission']!==undefined){const bY=balanceStr(bW['balance']),bZ=await N(bY);a0['push']({'address':String(bW['object']),'kind':'treasury','description':typeof bW['description']==='string'?bW['description']:null,'permission':typeof bW['permission']==='string'?bW['permission']:null,'balance':bY,'balance_display':bZ['display'],'balance_tip':bZ['tip'],'external_deposit_guard_count':Array['isArray'](bW['external_deposit_guard'])?bW['external_deposit_guard']['length']:null,'external_withdraw_guard_count':Array['isArray'](bW['external_withdraw_guard'])?bW['external_withdraw_guard']['length']:null,'via':bX});}else a0['push']({'address':bV['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':bX});}}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=balanceStr(m['compensation_fund']),a6=/^\d+$/['test'](a5?.['trim']()??'')?BigInt(a5['trim']()):null,a7=a6===null?null:(a6/0x3n)['toString'](),a8=a7===null?null:await N(a7),a9=a6===null?null:a6===0x0n?'No\x20compensation\x20fund:\x20this\x20Service\x20carries\x20NO\x20payout\x20protection\x20—\x20a\x20won\x20arbitration\x20award\x20cannot\x20be\x20paid\x20(the\x20claim\x20aborts,\x20code\x2027).\x20Running\x20without\x20a\x20fund\x20is\x20a\x20legitimate\x20merchant\x20choice,\x20but\x20it\x20is\x20one\x20a\x20buyer\x20should\x20see\x20before\x20ordering.':'Orders\x20at\x20or\x20under\x20this\x20cap\x20are\x20fully\x20protected\x20(award\x20ceiling\x203x\x20order).\x20Above\x20the\x20cap\x20there\x20is\x20NO\x20partial\x20payout\x20—\x20settlement\x20is\x20all-or-nothing\x20and\x20the\x20claim\x20aborts\x20(code\x2027)\x20until\x20the\x20fund\x20covers\x20the\x20award;\x20the\x20order\x20itself\x20is\x20unaffected.';let aa=null;if(a6!==null&&a6>0x0n){const c0=W['filter'](c4=>!c4['suspension']&&/^\d+$/['test'](c4['price']?.['trim']()??''))['map'](c4=>({'name':c4['name'],'price':BigInt(c4['price']['trim']())})),c1=computeFundListingWall(a6,c0),c2=await Promise['all'](c1['blocked']['map'](async c4=>({'name':c4['name'],'price':c4['price']['toString'](),'price_display':(await N(c4['price']['toString']()))['display']}))),c3=c2['length']===0x0?null:'The\x20fund\x20currently\x20backs\x20orders\x20up\x20to\x20'+(a8?.['display']??a7)+'.\x20'+((c2['length']===0x1?'1\x20listing\x20is':c2['length']+'\x20listings\x20are')+'\x20priced\x20above\x20that\x20and\x20cannot\x20be\x20checked\x20out\x20—\x20the\x20buy\x20gate\x20refuses\x20the\x20order\x20(no\x20money\x20moves)\x20because\x20the\x20fund\x20cannot\x20back\x20its\x20maximum\x20award.\x20')+'The\x20highest-priced\x20listing\x20is\x20blocked\x20first;\x20top\x20the\x20fund\x20above\x203x\x20a\x20listing\x27s\x20price\x20(service.compensation_fund_add)\x20or\x20cut\x20the\x20price\x20to\x20restore\x20it.\x20'+'This\x20recomputes\x20on\x20every\x20read:\x20after\x20every\x20award\x20that\x20spends\x20the\x20fund,\x20re-check\x20your\x20top\x20listing.';aa={'blocked':c2,'note':c3};}const ab=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'],'compensation_fund_cover_cap':a7,'compensation_fund_cover_cap_display':a8?.['display']??null,'compensation_fund_cover_cap_note':a9,'compensation_fund_listing_wall':aa,'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,...ab['open_questions']['length']>0x0?{'exploration':ab}:{}};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Config,LocalMark,query_objects,query_serviceContext}from'@wowok/wowok';import{resolveAddress as a388a}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'](),d=await a388a(a['service_address'],'service_address'),f=await query_serviceContext({'service':d,'network':b}),h=f['service'];if(!h)throw new Error('Service\x20\x27'+a['service_address']+'\x27\x20not\x20found\x20on\x20network\x20'+b+'.');const i=h?.['type_raw']??h?.['type']??'',j=i['match'](/<(.+)>$/),k=j?j[0x1]:null,l=Array['isArray'](h['sales'])?h['sales']:[],m=new Map();for(const M of l){if(!M||typeof M['name']!=='string')continue;m['set'](M['name'],{'price':balanceStr(M['price']?.['balance']??M['price']??0x0),'suspended':M['suspension']===!![]});}const n=a['items']??[...m['keys']()]['map'](N=>({'name':N,'quantity':0x1})),p=n['filter'](N=>!m['has'](N['name']));if(p['length']>0x0)throw new Error('Sale(s)\x20not\x20found\x20on\x20this\x20Service:\x20'+p['map'](N=>'\x27'+N['name']+'\x27')['join'](',\x20')+'.\x20'+('Available\x20sales:\x20'+([...m['keys']()]['map'](N=>'\x27'+N+'\x27')['join'](',\x20')||'<none>')+'.'));if(n['length']===0x0)throw new Error('This\x20Service\x20has\x20NO\x20configured\x20sales\x20—\x20nothing\x20to\x20quote.');const q=[];let t=0x0n;for(const N of n){const O=m['get'](N['name']),P=BigInt(O['price']||'0'),Q=P*BigInt(N['quantity']);t+=Q,q['push']({'name':N['name'],'quantity':N['quantity'],'unit_price':O['price'],'unit_price_display':await displayOf(O['price'],k,b),'line_total':Q['toString'](),'suspended':O['suspended']});}let u=t,w=null;if(typeof a['discount']==='string'&&a['discount']['trim']()!==''){const R=await a388a(a['discount'],'discount');let S=null;try{const a3=await query_objects({'objects':[R],'network':b});S=a3?.['objects']?.[0x0]??null;}catch{S=null;}if(!S)throw new Error('E_DISCOUNT_NOT_FOUND:\x20coupon\x20\x27'+R+'\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 T=String(S['service']??'');if(T['toLowerCase']()!==d['toLowerCase']())throw new Error('E_SERVICE_DISCOUNT_NOT_MATCH:\x20coupon\x20\x27'+R+'\x27\x20is\x20bound\x20to\x20service\x20'+((T||'<unparseable>')+',\x20not\x20to\x20'+d+'.\x20A\x20buy\x20with\x20this\x20coupon\x20aborts.'));const U=a4=>{const a5=balanceStr(a4)['trim']();return/^\d+$/['test'](a5)?BigInt(a5):0x0n;},V=BigInt(Date['now']()),W=U(S['time_start']),X=U(S['time_end']);if(V<W||V>X)throw new Error('E_DISCOUNT_TIME_INVALID:\x20coupon\x20\x27'+R+'\x27\x20is\x20valid\x20'+(W+'–'+X+'\x20(ms\x20epoch),\x20now\x20is\x20'+V+'.\x20A\x20buy\x20with\x20this\x20coupon\x20aborts.'));const Y=Number(S['discount_type'])===0x0,Z=U(S['off']),a0=S['benchmark']===null||S['benchmark']===undefined?null:U(S['benchmark']),a1=a0===null?!![]:t>=a0;let a2=![];a1&&(a2=!![],u=Y?t-t*Z/0x2710n:t>Z?t-Z:0x0n),w={'coupon':R,'name':typeof S['name']==='string'?S['name']:null,'type':Y?'rates':'minus','off':Z['toString'](),'benchmark':a0===null?null:a0['toString'](),'benchmark_met':a1,'applied':a2,'list_total':t['toString'](),'final_total':u['toString'](),'final_total_display':await displayOf(u['toString'](),k,b),'note':a2?u===0x0n?'DEAD\x20BASKET\x20(F-BS-75):\x20the\x20coupon\x20covers\x20the\x20entire\x20basket,\x20but\x20the\x20chain\x20REFUSES\x20zero-total\x20'+'buys\x20—\x20the\x20client\x20gate\x20(order_new_zero_total_dead_order)\x20and\x20the\x20on-chain\x20zero-total\x20gate\x20'+'(abort\x2042)\x20both\x20reject\x20this\x20buy;\x20NOTHING\x20is\x20purchasable\x20at\x20total\x200,\x20free\x20product\x20or\x20not.\x20'+'Lower\x20the\x20coupon\x20value\x20so\x20the\x20final\x20total\x20stays\x20>=\x201\x20smallest\x20unit\x20(or\x20price\x20a\x20deliberate\x20'+'free\x20tier\x20at\x201\x20smallest\x20unit).\x20allow_zero_total\x20on\x20the\x20coupon\x20is\x20disclosure-only\x20and\x20does\x20'+'NOT\x20unlock\x20this\x20buy\x20(F-BS-74).':'Discounted\x20total\x20shown\x20—\x20order_new.buy.total_pay.balance\x20must\x20equal\x20final_total.\x20'+'BURN-ON-USE\x20(F-ETS-03):\x20attaching\x20this\x20coupon\x20to\x20a\x20buy\x20DESTROYS\x20it\x20on\x20chain\x20—\x20the\x20coupon\x20'+'object\x20is\x20gone\x20once\x20the\x20order\x20is\x20created\x20(a\x20later\x20quote\x20hits\x20E_DISCOUNT_NOT_FOUND).\x20'+'CANCELLATION\x20REFUNDS\x20THE\x20DISCOUNTED\x20AMOUNT\x20ONLY:\x20refund\x20rails\x20pay\x20the\x20order\x27s\x20escrowed\x20'+'amount\x20(this\x20final_total),\x20so\x20a\x20cancelled\x20order\x20does\x20NOT\x20restore\x20the\x20coupon\x27s\x20face\x20value\x20—\x20'+'the\x20difference\x20is\x20forfeited\x20even\x20on\x20a\x20no-fault\x20cancel.\x20Disclose\x20this\x20to\x20the\x20buyer\x20before\x20checkout.':'⚠\x20Benchmark\x20NOT\x20met\x20(list\x20total\x20'+t+'\x20<\x20'+a0+'):\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'+a0+',\x20or\x20order\x20without\x20the\x20coupon\x20and\x20keep\x20it.'};}const x=balanceStr(h['compensation_fund']??0x0),y=/^\d+$/['test'](x['trim']())?BigInt(x['trim']()):0x0n,z=0x3n*u,A=z>y?z-y:0x0n,B=y/0x3n,C=await displayOf(B['toString'](),k,b),D={'fund_balance':y['toString'](),'fund_balance_display':await displayOf(y['toString'](),k,b),'max_coverable_order':B['toString'](),'max_coverable_order_display':C,'required_for_this_basket':z['toString'](),'required_display':await displayOf(z['toString'](),k,b),'shortfall':A['toString'](),'shortfall_display':await displayOf(A['toString'](),k,b),'covered':y>=z,'note':y===0x0n?'This\x20Service\x20runs\x20WITHOUT\x20a\x20compensation\x20fund\x20—\x20a\x20legitimate\x20merchant\x20choice,\x20never\x20blocked\x20at\x20buy.\x20An\x20arbitration\x20award\x20beyond\x20the\x20pool\x20aborts\x20the\x20buyer\x27s\x20payout\x20(code\x2027,\x20claim\x20NOT\x20consumed)\x20and\x20waits\x20on\x20the\x20merchant\x20wallet.':y>=z?'The\x20fund\x20covers\x203x\x20this\x20basket\x27s\x20amount\x20—\x20a\x20single\x20ruling\x20at\x20the\x20maximum\x20award\x20multiple\x20is\x20payable\x20from\x20the\x20pool.\x20Storefront\x20ceiling:\x20no\x20order\x20above\x20'+C+'\x20(fund/3)\x20can\x20be\x20created\x20—\x20quote\x20a\x20bigger\x20basket\x20against\x20the\x20ceiling,\x20not\x20just\x20this\x20one.':'BELOW\x20the\x20per-order\x20payout\x20requirement:\x20order\x20creation\x20will\x20be\x20BLOCKED\x20(compensation_fund_below_order_ceiling\x20—\x20no\x20money\x20moves)\x20until\x20the\x20merchant\x20tops\x20up\x20via\x20service.compensation_fund_add\x20by\x20'+await displayOf(A['toString'](),k,b)+'\x20(to\x20>=\x203x\x20this\x20basket).\x20Standing\x20ceiling:\x20orders\x20above\x20'+C+'\x20(fund/3)\x20are\x20refused\x20at\x20buy,\x20so\x20this\x20basket\x20is\x20only\x20the\x20latest\x20casualty\x20—\x20every\x20bigger\x20SKU\x20is\x20unbuyable\x20too.'},E=await displayOf(u['toString'](),k,b),F=h['order_allocators'],G=Array['isArray'](F?.['allocators'])?F['allocators']:[],H=G['length']>0x0?G[0x0]:undefined,I=H?{'allocator_index':0x0,'note':'Sharing\x20rows\x20of\x20the\x20FIRST\x20order_allocator\x20(index\x200\x20—\x20NOT\x20necessarily\x20the\x20normal\x20'+'payout\x20path:\x20services\x20that\x20ship\x20refund-first\x20rails\x20put\x20the\x20refund\x20track\x20at\x20index\x200,\x20'+'klk15\x20C-06).\x20Guards\x20select\x20per-case\x20allocators\x20(refund\x20/\x20damage\x20/\x20late-cancel),\x20so\x20'+'the\x20LIVE\x20split\x20depends\x20on\x20which\x20guard\x20passes\x20—\x20identify\x20the\x20settlement\x20allocator\x20'+'via\x20service_panorama\x20before\x20ordering.','sharing':(Array['isArray'](H['sharing'])?H['sharing']:[])['map'](a4=>({'recipient':describeRecipient(a4?.['who']),'mode':typeof a4?.['mode']==='string'?a4['mode']:null,'value':balanceStr(a4?.['sharing']?.['balance']??a4?.['sharing']??0x0)}))}:null,J=Array['isArray'](h['rewards'])?h['rewards']['filter'](a4=>typeof a4==='string'&&a4!==''):[];let K=null;if(J['length']>0x0){const a4=[],a5=[];let a6=[];try{const a7=await query_objects({'objects':J,'network':b});a6=Array['isArray'](a7?.['objects'])?a7['objects']:[];}catch(a8){a4['push']('Reward\x20lookup\x20failed\x20('+(a8 instanceof Error?a8['message']:String(a8))+')\x20—\x20reward\x20terms\x20NOT\x20verified;\x20do\x20not\x20rely\x20on\x20them.');}for(const a9 of J){const aa=a6['find'](an=>typeof an?.['object']==='string'&&an['object']['toLowerCase']()===a9['toLowerCase']());if(!aa){a4['push']('Reward\x20\x27'+a9+'\x27\x20could\x20not\x20be\x20read\x20—\x20its\x20terms\x20are\x20unknown;\x20do\x20not\x20rely\x20on\x20it.');continue;}const ab=balanceStr(aa['balance']??0x0),ac=/^\d+$/['test'](ab)?BigInt(ab):0x0n,ad=[];let ae=0x0n,af=![];for(const an of Array['isArray'](aa['guards'])?aa['guards']:[]){const ao=an?.['amount'],ap=ao!=null&&(ao['type']===0x1||ao['type']==='Fixed'),aq=an?.['expiration_time'],ar=aq==null?null:Number(aq),as=ar!=null&&Number['isFinite'](ar)?ar:null;if(ap){const at=balanceStr(ao['value']??0x0),au=/^\d+$/['test'](at)?BigInt(at):0x0n;if(au>ae)ae=au;ad['push']({'guard':String(an?.['guard']??''),'amount_type':'fixed','amount':at,'amount_display':await displayOf(at,k,b),'expiration_time':as,'expiration_display':as!=null?new Date(as)['toISOString']():null,'expired':as!=null?Date['now']()>as:null,'min_rating':null});}else af=!![],ad['push']({'guard':String(an?.['guard']??''),'amount_type':'guard_submission','amount':'submission\x20identifier\x20'+String(ao?.['value']??'?'),'amount_display':null,'expiration_time':as,'expiration_display':as!=null?new Date(as)['toISOString']():null,'expired':as!=null?Date['now']()>as:null,'min_rating':null});}const ag=Array['from'](new Set(ad['map'](av=>av['guard'])['filter'](av=>av!==''))),ah=new Map();if(ag['length']>0x0)try{const av=await query_objects({'objects':ag,'network':b});for(const aw of Array['isArray'](av?.['objects'])?av['objects']:[]){if(typeof aw?.['object']==='string')ah['set'](aw['object']['toLowerCase'](),aw);}}catch{a4['push']('Claim\x20guard\x20lookup\x20failed\x20—\x20rating\x20conditions\x20on\x20'+ag['length']+'\x20claim\x20guard(s)\x20NOT\x20verified;\x20do\x20not\x20promise\x20the\x20incentive.');}const ai=(ax,ay=0x0)=>{if(!ax||typeof ax!=='object'||ay>0x4)return null;if(ax['root']&&Array['isArray'](ax['table']))return ax;for(const az of Object['values'](ax)){if(az&&typeof az==='object'){const aA=ai(az,ay+0x1);if(aA)return aA;}}return null;},aj=(ax,ay)=>{const az=ax['table']['find'](aB=>aB?.['identifier']===ay&&aB?.['b_submission']===![]);if(!az)return null;const aA=typeof az['value']==='number'?az['value']:Number(String(az['value']??''));return Number['isFinite'](aA)?aA:null;},ak=(ax,ay,az=0x0)=>{if(!ax||typeof ax!=='object'||az>0x18)return null;const aA=typeof ax['type']==='string'?ax['type']:'';if(aA==='logic_as_u256_greater_or_equal'||aA==='logic_as_u256_greater'||aA==='logic_as_u256_equal'){const aB=Array['isArray'](ax['nodes'])?ax['nodes']:[],aC=aB[0x0];if(aB['length']>=0x2&&JSON['stringify'](aC??{})['includes']('repository.data')){const aD=aB[aB['length']-0x1],aE=aD?.['type']==='identifier'?aj(ay,Number(aD['identifier'])):typeof aD?.['value']==='number'?aD['value']:null;if(aE!=null){const aF=aA==='logic_as_u256_greater_or_equal'?'>=':aA==='logic_as_u256_greater'?'>':'==';return aF+'\x20'+aE;}}}for(const aG of Object['values'](ax)){if(Array['isArray'](aG))for(const aH of aG){const aI=ak(aH,ay,az+0x1);if(aI)return aI;}else{if(aG&&typeof aG==='object'){const aJ=ak(aG,ay,az+0x1);if(aJ)return aJ;}}}return null;};for(const ax of ad){ax['min_rating']=null;const ay=ah['get'](ax['guard']['toLowerCase']());if(!ay)continue;let az;try{az=JSON['stringify'](ay,(aC,aD)=>aD instanceof Uint8Array?Buffer['from'](aD)['toString']('base64'):aD);}catch{continue;}if(!az['includes']('\x22rating\x22'))continue;const aA=ai(ay),aB=aA?ak(aA['root'],aA):null;if(aB)ax['min_rating']=aB;else{const aC=az['toLowerCase']();if(aC['includes']('\x22like\x22'))ax['min_rating']='like';else{if(aC['includes']('\x22dislike\x22'))ax['min_rating']='dislike';else ax['min_rating']='unknown';}}}const al=ac===0x0n?'Pool\x20is\x20EMPTY\x20—\x20any\x20claim\x20aborts\x20on-chain\x20on\x20the\x20reward\x20module\x27s\x20E_INSUFFICIENT_BALANCE\x20(not\x20the\x20allocation\x20module\x27s\x20same-named\x20constant);\x20do\x20not\x20budget\x20on\x20this\x20reward.':af||ae===0x0n?null:'Pool\x20covers\x20~'+(ac/ae)['toString']()+'\x20further\x20claim(s)\x20at\x20the\x20largest\x20configured\x20per-claim\x20amount.',am=ad['filter'](aD=>aD['min_rating']==='unknown')['length'];am>0x0&&a4['push'](am+'\x20claim(s)\x20gate\x20on\x20a\x20rating\x20condition\x20whose\x20polarity\x20could\x20not\x20be\x20parsed\x20'+'(min_rating=unknown)\x20—\x20read\x20the\x20claim\x20guard\x20before\x20promising\x20this\x20incentive\x20to\x20the\x20buyer'),a5['push']({'reward':a9,'description':typeof aa['description']==='string'?aa['description']:null,'pool_balance':ac['toString'](),'pool_balance_display':await displayOf(ac['toString'](),k,b),'record_count':Number['isFinite'](Number(aa['record_count']))?Number(aa['record_count']):0x0,'claims':ad,'coverage':al});}K={'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':a5,'data_gaps':a4};}let L=null;try{const aD=await LocalMark['Instance']()['list']({'address':d});L=aD?.[0x0]?.['name']??null;}catch{L=null;}return{'action':'service_quote','network':String(b),'service':{'address':d,'name':L},'payment_token':{'coin_type':k,'display_note':k?'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':q,'total_pay':{'balance':u['toString'](),'display':E,'note':u===0x0n?'DEAD\x20BASKET\x20(F-BS-75):\x20this\x20quote\x20totals\x20ZERO\x20—\x20the\x20chain\x20REFUSES\x20zero-total\x20buys\x20(client\x20'+'order_new_zero_total_dead_order,\x20on-chain\x20abort\x2042),\x20so\x20this\x20basket\x20cannot\x20be\x20purchased\x20at\x20'+'all.\x20Either\x20the\x20basket\x20contains\x20a\x20zero-priced\x20SKU\x20(permanently\x20unbuyable\x20—\x20F-BS-76;\x20the\x20'+'merchant\x20must\x20reprice\x20it\x20to\x20>=\x201\x20smallest\x20unit)\x20or\x20a\x20coupon\x20zeroes\x20it\x20(lower\x20the\x20coupon\x20'+'value).\x20Do\x20NOT\x20attempt\x20the\x20buy.':w?.['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':w,'allocation_preview':I,'compensation_fund_coverage':D,'reward_terms':K};}
|
|
1
|
+
import{Config,LocalMark,query_objects,query_serviceContext}from'@wowok/wowok';import{resolveAddress as a390a}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'](),d=await a390a(a['service_address'],'service_address'),f=await query_serviceContext({'service':d,'network':b}),h=f['service'];if(!h)throw new Error('Service\x20\x27'+a['service_address']+'\x27\x20not\x20found\x20on\x20network\x20'+b+'.');const i=h?.['type_raw']??h?.['type']??'',j=i['match'](/<(.+)>$/),k=j?j[0x1]:null,l=Array['isArray'](h['sales'])?h['sales']:[],m=new Map();for(const M of l){if(!M||typeof M['name']!=='string')continue;m['set'](M['name'],{'price':balanceStr(M['price']?.['balance']??M['price']??0x0),'suspended':M['suspension']===!![]});}const n=a['items']??[...m['keys']()]['map'](N=>({'name':N,'quantity':0x1})),p=n['filter'](N=>!m['has'](N['name']));if(p['length']>0x0)throw new Error('Sale(s)\x20not\x20found\x20on\x20this\x20Service:\x20'+p['map'](N=>'\x27'+N['name']+'\x27')['join'](',\x20')+'.\x20'+('Available\x20sales:\x20'+([...m['keys']()]['map'](N=>'\x27'+N+'\x27')['join'](',\x20')||'<none>')+'.'));if(n['length']===0x0)throw new Error('This\x20Service\x20has\x20NO\x20configured\x20sales\x20—\x20nothing\x20to\x20quote.');const q=[];let t=0x0n;for(const N of n){const O=m['get'](N['name']),P=BigInt(O['price']||'0'),Q=P*BigInt(N['quantity']);t+=Q,q['push']({'name':N['name'],'quantity':N['quantity'],'unit_price':O['price'],'unit_price_display':await displayOf(O['price'],k,b),'line_total':Q['toString'](),'suspended':O['suspended']});}let u=t,w=null;if(typeof a['discount']==='string'&&a['discount']['trim']()!==''){const R=await a390a(a['discount'],'discount');let S=null;try{const a3=await query_objects({'objects':[R],'network':b});S=a3?.['objects']?.[0x0]??null;}catch{S=null;}if(!S)throw new Error('E_DISCOUNT_NOT_FOUND:\x20coupon\x20\x27'+R+'\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 T=String(S['service']??'');if(T['toLowerCase']()!==d['toLowerCase']())throw new Error('E_SERVICE_DISCOUNT_NOT_MATCH:\x20coupon\x20\x27'+R+'\x27\x20is\x20bound\x20to\x20service\x20'+((T||'<unparseable>')+',\x20not\x20to\x20'+d+'.\x20A\x20buy\x20with\x20this\x20coupon\x20aborts.'));const U=a4=>{const a5=balanceStr(a4)['trim']();return/^\d+$/['test'](a5)?BigInt(a5):0x0n;},V=BigInt(Date['now']()),W=U(S['time_start']),X=U(S['time_end']);if(V<W||V>X)throw new Error('E_DISCOUNT_TIME_INVALID:\x20coupon\x20\x27'+R+'\x27\x20is\x20valid\x20'+(W+'–'+X+'\x20(ms\x20epoch),\x20now\x20is\x20'+V+'.\x20A\x20buy\x20with\x20this\x20coupon\x20aborts.'));const Y=Number(S['discount_type'])===0x0,Z=U(S['off']),a0=S['benchmark']===null||S['benchmark']===undefined?null:U(S['benchmark']),a1=a0===null?!![]:t>=a0;let a2=![];a1&&(a2=!![],u=Y?t-t*Z/0x2710n:t>Z?t-Z:0x0n),w={'coupon':R,'name':typeof S['name']==='string'?S['name']:null,'type':Y?'rates':'minus','off':Z['toString'](),'benchmark':a0===null?null:a0['toString'](),'benchmark_met':a1,'applied':a2,'list_total':t['toString'](),'final_total':u['toString'](),'final_total_display':await displayOf(u['toString'](),k,b),'note':a2?u===0x0n?'DEAD\x20BASKET\x20(F-BS-75):\x20the\x20coupon\x20covers\x20the\x20entire\x20basket,\x20but\x20the\x20chain\x20REFUSES\x20zero-total\x20'+'buys\x20—\x20the\x20client\x20gate\x20(order_new_zero_total_dead_order)\x20and\x20the\x20on-chain\x20zero-total\x20gate\x20'+'(abort\x2042)\x20both\x20reject\x20this\x20buy;\x20NOTHING\x20is\x20purchasable\x20at\x20total\x200,\x20free\x20product\x20or\x20not.\x20'+'Lower\x20the\x20coupon\x20value\x20so\x20the\x20final\x20total\x20stays\x20>=\x201\x20smallest\x20unit\x20(or\x20price\x20a\x20deliberate\x20'+'free\x20tier\x20at\x201\x20smallest\x20unit).\x20allow_zero_total\x20on\x20the\x20coupon\x20is\x20disclosure-only\x20and\x20does\x20'+'NOT\x20unlock\x20this\x20buy\x20(F-BS-74).':'Discounted\x20total\x20shown\x20—\x20order_new.buy.total_pay.balance\x20must\x20equal\x20final_total.\x20'+'BURN-ON-USE\x20(F-ETS-03):\x20attaching\x20this\x20coupon\x20to\x20a\x20buy\x20DESTROYS\x20it\x20on\x20chain\x20—\x20the\x20coupon\x20'+'object\x20is\x20gone\x20once\x20the\x20order\x20is\x20created\x20(a\x20later\x20quote\x20hits\x20E_DISCOUNT_NOT_FOUND).\x20'+'CANCELLATION\x20REFUNDS\x20THE\x20DISCOUNTED\x20AMOUNT\x20ONLY:\x20refund\x20rails\x20pay\x20the\x20order\x27s\x20escrowed\x20'+'amount\x20(this\x20final_total),\x20so\x20a\x20cancelled\x20order\x20does\x20NOT\x20restore\x20the\x20coupon\x27s\x20face\x20value\x20—\x20'+'the\x20difference\x20is\x20forfeited\x20even\x20on\x20a\x20no-fault\x20cancel.\x20Disclose\x20this\x20to\x20the\x20buyer\x20before\x20checkout.':'⚠\x20Benchmark\x20NOT\x20met\x20(list\x20total\x20'+t+'\x20<\x20'+a0+'):\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'+a0+',\x20or\x20order\x20without\x20the\x20coupon\x20and\x20keep\x20it.'};}const x=balanceStr(h['compensation_fund']??0x0),y=/^\d+$/['test'](x['trim']())?BigInt(x['trim']()):0x0n,z=0x3n*u,A=z>y?z-y:0x0n,B=y/0x3n,C=await displayOf(B['toString'](),k,b),D={'fund_balance':y['toString'](),'fund_balance_display':await displayOf(y['toString'](),k,b),'max_coverable_order':B['toString'](),'max_coverable_order_display':C,'required_for_this_basket':z['toString'](),'required_display':await displayOf(z['toString'](),k,b),'shortfall':A['toString'](),'shortfall_display':await displayOf(A['toString'](),k,b),'covered':y>=z,'note':y===0x0n?'This\x20Service\x20runs\x20WITHOUT\x20a\x20compensation\x20fund\x20—\x20a\x20legitimate\x20merchant\x20choice,\x20never\x20blocked\x20at\x20buy.\x20An\x20arbitration\x20award\x20beyond\x20the\x20pool\x20aborts\x20the\x20buyer\x27s\x20payout\x20(code\x2027,\x20claim\x20NOT\x20consumed)\x20and\x20waits\x20on\x20the\x20merchant\x20wallet.':y>=z?'The\x20fund\x20covers\x203x\x20this\x20basket\x27s\x20amount\x20—\x20a\x20single\x20ruling\x20at\x20the\x20maximum\x20award\x20multiple\x20is\x20payable\x20from\x20the\x20pool.\x20Storefront\x20ceiling:\x20no\x20order\x20above\x20'+C+'\x20(fund/3)\x20can\x20be\x20created\x20—\x20quote\x20a\x20bigger\x20basket\x20against\x20the\x20ceiling,\x20not\x20just\x20this\x20one.':'BELOW\x20the\x20per-order\x20payout\x20requirement:\x20order\x20creation\x20will\x20be\x20BLOCKED\x20(compensation_fund_below_order_ceiling\x20—\x20no\x20money\x20moves)\x20until\x20the\x20merchant\x20tops\x20up\x20via\x20service.compensation_fund_add\x20by\x20'+await displayOf(A['toString'](),k,b)+'\x20(to\x20>=\x203x\x20this\x20basket).\x20Standing\x20ceiling:\x20orders\x20above\x20'+C+'\x20(fund/3)\x20are\x20refused\x20at\x20buy,\x20so\x20this\x20basket\x20is\x20only\x20the\x20latest\x20casualty\x20—\x20every\x20bigger\x20SKU\x20is\x20unbuyable\x20too.'},E=await displayOf(u['toString'](),k,b),F=h['order_allocators'],G=Array['isArray'](F?.['allocators'])?F['allocators']:[],H=G['length']>0x0?G[0x0]:undefined,I=H?{'allocator_index':0x0,'note':'Sharing\x20rows\x20of\x20the\x20FIRST\x20order_allocator\x20(index\x200\x20—\x20NOT\x20necessarily\x20the\x20normal\x20'+'payout\x20path:\x20services\x20that\x20ship\x20refund-first\x20rails\x20put\x20the\x20refund\x20track\x20at\x20index\x200,\x20'+'klk15\x20C-06).\x20Guards\x20select\x20per-case\x20allocators\x20(refund\x20/\x20damage\x20/\x20late-cancel),\x20so\x20'+'the\x20LIVE\x20split\x20depends\x20on\x20which\x20guard\x20passes\x20—\x20identify\x20the\x20settlement\x20allocator\x20'+'via\x20service_panorama\x20before\x20ordering.','sharing':(Array['isArray'](H['sharing'])?H['sharing']:[])['map'](a4=>({'recipient':describeRecipient(a4?.['who']),'mode':typeof a4?.['mode']==='string'?a4['mode']:null,'value':balanceStr(a4?.['sharing']?.['balance']??a4?.['sharing']??0x0)}))}:null,J=Array['isArray'](h['rewards'])?h['rewards']['filter'](a4=>typeof a4==='string'&&a4!==''):[];let K=null;if(J['length']>0x0){const a4=[],a5=[];let a6=[];try{const a7=await query_objects({'objects':J,'network':b});a6=Array['isArray'](a7?.['objects'])?a7['objects']:[];}catch(a8){a4['push']('Reward\x20lookup\x20failed\x20('+(a8 instanceof Error?a8['message']:String(a8))+')\x20—\x20reward\x20terms\x20NOT\x20verified;\x20do\x20not\x20rely\x20on\x20them.');}for(const a9 of J){const aa=a6['find'](an=>typeof an?.['object']==='string'&&an['object']['toLowerCase']()===a9['toLowerCase']());if(!aa){a4['push']('Reward\x20\x27'+a9+'\x27\x20could\x20not\x20be\x20read\x20—\x20its\x20terms\x20are\x20unknown;\x20do\x20not\x20rely\x20on\x20it.');continue;}const ab=balanceStr(aa['balance']??0x0),ac=/^\d+$/['test'](ab)?BigInt(ab):0x0n,ad=[];let ae=0x0n,af=![];for(const an of Array['isArray'](aa['guards'])?aa['guards']:[]){const ao=an?.['amount'],ap=ao!=null&&(ao['type']===0x1||ao['type']==='Fixed'),aq=an?.['expiration_time'],ar=aq==null?null:Number(aq),as=ar!=null&&Number['isFinite'](ar)?ar:null;if(ap){const at=balanceStr(ao['value']??0x0),au=/^\d+$/['test'](at)?BigInt(at):0x0n;if(au>ae)ae=au;ad['push']({'guard':String(an?.['guard']??''),'amount_type':'fixed','amount':at,'amount_display':await displayOf(at,k,b),'expiration_time':as,'expiration_display':as!=null?new Date(as)['toISOString']():null,'expired':as!=null?Date['now']()>as:null,'min_rating':null});}else af=!![],ad['push']({'guard':String(an?.['guard']??''),'amount_type':'guard_submission','amount':'submission\x20identifier\x20'+String(ao?.['value']??'?'),'amount_display':null,'expiration_time':as,'expiration_display':as!=null?new Date(as)['toISOString']():null,'expired':as!=null?Date['now']()>as:null,'min_rating':null});}const ag=Array['from'](new Set(ad['map'](av=>av['guard'])['filter'](av=>av!==''))),ah=new Map();if(ag['length']>0x0)try{const av=await query_objects({'objects':ag,'network':b});for(const aw of Array['isArray'](av?.['objects'])?av['objects']:[]){if(typeof aw?.['object']==='string')ah['set'](aw['object']['toLowerCase'](),aw);}}catch{a4['push']('Claim\x20guard\x20lookup\x20failed\x20—\x20rating\x20conditions\x20on\x20'+ag['length']+'\x20claim\x20guard(s)\x20NOT\x20verified;\x20do\x20not\x20promise\x20the\x20incentive.');}const ai=(ax,ay=0x0)=>{if(!ax||typeof ax!=='object'||ay>0x4)return null;if(ax['root']&&Array['isArray'](ax['table']))return ax;for(const az of Object['values'](ax)){if(az&&typeof az==='object'){const aA=ai(az,ay+0x1);if(aA)return aA;}}return null;},aj=(ax,ay)=>{const az=ax['table']['find'](aB=>aB?.['identifier']===ay&&aB?.['b_submission']===![]);if(!az)return null;const aA=typeof az['value']==='number'?az['value']:Number(String(az['value']??''));return Number['isFinite'](aA)?aA:null;},ak=(ax,ay,az=0x0)=>{if(!ax||typeof ax!=='object'||az>0x18)return null;const aA=typeof ax['type']==='string'?ax['type']:'';if(aA==='logic_as_u256_greater_or_equal'||aA==='logic_as_u256_greater'||aA==='logic_as_u256_equal'){const aB=Array['isArray'](ax['nodes'])?ax['nodes']:[],aC=aB[0x0];if(aB['length']>=0x2&&JSON['stringify'](aC??{})['includes']('repository.data')){const aD=aB[aB['length']-0x1],aE=aD?.['type']==='identifier'?aj(ay,Number(aD['identifier'])):typeof aD?.['value']==='number'?aD['value']:null;if(aE!=null){const aF=aA==='logic_as_u256_greater_or_equal'?'>=':aA==='logic_as_u256_greater'?'>':'==';return aF+'\x20'+aE;}}}for(const aG of Object['values'](ax)){if(Array['isArray'](aG))for(const aH of aG){const aI=ak(aH,ay,az+0x1);if(aI)return aI;}else{if(aG&&typeof aG==='object'){const aJ=ak(aG,ay,az+0x1);if(aJ)return aJ;}}}return null;};for(const ax of ad){ax['min_rating']=null;const ay=ah['get'](ax['guard']['toLowerCase']());if(!ay)continue;let az;try{az=JSON['stringify'](ay,(aD,aE)=>aE instanceof Uint8Array?Buffer['from'](aE)['toString']('base64'):aE);}catch{continue;}const aA=az['includes']('\x22rating\x22')||az['includes']('114,97,116,105,110,103')||az['toLowerCase']()['includes']('726174696e67')||az['includes']('cmF0aW5n');if(!aA)continue;const aB=ai(ay),aC=aB?ak(aB['root'],aB):null;if(aC)ax['min_rating']=aC;else{const aD=az['toLowerCase']();if(aD['includes']('\x22like\x22'))ax['min_rating']='like';else{if(aD['includes']('\x22dislike\x22'))ax['min_rating']='dislike';else ax['min_rating']='unknown';}}}const al=ac===0x0n?'Pool\x20is\x20EMPTY\x20—\x20any\x20claim\x20aborts\x20on-chain\x20on\x20the\x20reward\x20module\x27s\x20E_INSUFFICIENT_BALANCE\x20(not\x20the\x20allocation\x20module\x27s\x20same-named\x20constant);\x20do\x20not\x20budget\x20on\x20this\x20reward.':af||ae===0x0n?null:'Pool\x20covers\x20~'+(ac/ae)['toString']()+'\x20further\x20claim(s)\x20at\x20the\x20largest\x20configured\x20per-claim\x20amount.',am=ad['filter'](aE=>aE['min_rating']==='unknown')['length'];am>0x0&&a4['push'](am+'\x20claim(s)\x20gate\x20on\x20a\x20rating\x20condition\x20whose\x20polarity\x20could\x20not\x20be\x20parsed\x20'+'(min_rating=unknown)\x20—\x20read\x20the\x20claim\x20guard\x20before\x20promising\x20this\x20incentive\x20to\x20the\x20buyer'),a5['push']({'reward':a9,'description':typeof aa['description']==='string'?aa['description']:null,'pool_balance':ac['toString'](),'pool_balance_display':await displayOf(ac['toString'](),k,b),'record_count':Number['isFinite'](Number(aa['record_count']))?Number(aa['record_count']):0x0,'claims':ad,'coverage':al});}K={'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':a5,'data_gaps':a4};}let L=null;try{const aE=await LocalMark['Instance']()['list']({'address':d});L=aE?.[0x0]?.['name']??null;}catch{L=null;}return{'action':'service_quote','network':String(b),'service':{'address':d,'name':L},'payment_token':{'coin_type':k,'display_note':k?'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':q,'total_pay':{'balance':u['toString'](),'display':E,'note':u===0x0n?'DEAD\x20BASKET\x20(F-BS-75):\x20this\x20quote\x20totals\x20ZERO\x20—\x20the\x20chain\x20REFUSES\x20zero-total\x20buys\x20(client\x20'+'order_new_zero_total_dead_order,\x20on-chain\x20abort\x2042),\x20so\x20this\x20basket\x20cannot\x20be\x20purchased\x20at\x20'+'all.\x20Either\x20the\x20basket\x20contains\x20a\x20zero-priced\x20SKU\x20(permanently\x20unbuyable\x20—\x20F-BS-76;\x20the\x20'+'merchant\x20must\x20reprice\x20it\x20to\x20>=\x201\x20smallest\x20unit)\x20or\x20a\x20coupon\x20zeroes\x20it\x20(lower\x20the\x20coupon\x20'+'value).\x20Do\x20NOT\x20attempt\x20the\x20buy.':w?.['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':w,'allocation_preview':I,'compensation_fund_coverage':D,'reward_terms':K};}
|
package/dist/review/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{objectTypeFromAddress,ObjectType}from'@wowok/wowok';import{resolveAddress as
|
|
1
|
+
import{objectTypeFromAddress,ObjectType}from'@wowok/wowok';import{resolveAddress as a403a}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 a403a(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
|
|
1
|
+
import{CONFIRMATION_RULES,resolveOverrideId}from'../knowledge/safety-rules.js';import{isEnabled as a419a}from'../config/index.js';import{isPlanPreapproved}from'../goal/plan-approval.js';export function isConfirmGateEnabled(){return a419a('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']===!![];}
|
|
@@ -12,6 +12,48 @@ export declare const BenchmarkMigrationSchema: z.ZodObject<{
|
|
|
12
12
|
template_id: z.ZodOptional<z.ZodString>;
|
|
13
13
|
industry: z.ZodOptional<z.ZodString>;
|
|
14
14
|
description: z.ZodOptional<z.ZodString>;
|
|
15
|
+
semantic_ir: z.ZodOptional<z.ZodObject<{
|
|
16
|
+
schema_version: z.ZodLiteral<1>;
|
|
17
|
+
locale: z.ZodString;
|
|
18
|
+
traits: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
19
|
+
trait: z.ZodString;
|
|
20
|
+
value: z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>;
|
|
21
|
+
confidence: z.ZodNumber;
|
|
22
|
+
span: z.ZodOptional<z.ZodObject<{
|
|
23
|
+
start: z.ZodNumber;
|
|
24
|
+
end: z.ZodNumber;
|
|
25
|
+
}, z.core.$strict>>;
|
|
26
|
+
quote: z.ZodOptional<z.ZodString>;
|
|
27
|
+
}, z.core.$strict>>>;
|
|
28
|
+
domains: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
29
|
+
domain: z.ZodString;
|
|
30
|
+
confidence: z.ZodOptional<z.ZodNumber>;
|
|
31
|
+
span: z.ZodOptional<z.ZodObject<{
|
|
32
|
+
start: z.ZodNumber;
|
|
33
|
+
end: z.ZodNumber;
|
|
34
|
+
}, z.core.$strict>>;
|
|
35
|
+
quote: z.ZodOptional<z.ZodString>;
|
|
36
|
+
}, z.core.$strict>>>;
|
|
37
|
+
claims: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
38
|
+
key: z.ZodString;
|
|
39
|
+
value: z.ZodNumber;
|
|
40
|
+
confidence: z.ZodOptional<z.ZodNumber>;
|
|
41
|
+
span: z.ZodOptional<z.ZodObject<{
|
|
42
|
+
start: z.ZodNumber;
|
|
43
|
+
end: z.ZodNumber;
|
|
44
|
+
}, z.core.$strict>>;
|
|
45
|
+
quote: z.ZodOptional<z.ZodString>;
|
|
46
|
+
}, z.core.$strict>>>;
|
|
47
|
+
provenance: z.ZodObject<{
|
|
48
|
+
source: z.ZodEnum<{
|
|
49
|
+
human: "human";
|
|
50
|
+
caller_llm: "caller_llm";
|
|
51
|
+
}>;
|
|
52
|
+
model: z.ZodOptional<z.ZodString>;
|
|
53
|
+
prompt_version: z.ZodOptional<z.ZodString>;
|
|
54
|
+
generated_at: z.ZodOptional<z.ZodNumber>;
|
|
55
|
+
}, z.core.$strict>;
|
|
56
|
+
}, z.core.$strict>>;
|
|
15
57
|
url: z.ZodOptional<z.ZodString>;
|
|
16
58
|
fee_overrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>>;
|
|
17
59
|
guard_resolutions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
|
|
@@ -34,6 +76,7 @@ export declare const BenchmarkMigrationSchema: z.ZodObject<{
|
|
|
34
76
|
review_reward: "review_reward";
|
|
35
77
|
}>>;
|
|
36
78
|
reward_funding: z.ZodOptional<z.ZodString>;
|
|
79
|
+
reward_claim_amount: z.ZodOptional<z.ZodString>;
|
|
37
80
|
after_sales_mode: z.ZodOptional<z.ZodEnum<{
|
|
38
81
|
none: "none";
|
|
39
82
|
return: "return";
|
|
@@ -104,8 +147,6 @@ export declare const BenchmarkMigrationOutputSchema: z.ZodObject<{
|
|
|
104
147
|
action: z.ZodLiteral<"template_get">;
|
|
105
148
|
template: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
106
149
|
}, z.core.$strip>, z.ZodObject<{
|
|
107
|
-
action: z.ZodLiteral<"template_generate">;
|
|
108
|
-
template_id: z.ZodString;
|
|
109
150
|
scan: z.ZodObject<{
|
|
110
151
|
risk_level: z.ZodEnum<{
|
|
111
152
|
low: "low";
|
|
@@ -136,6 +177,10 @@ export declare const BenchmarkMigrationOutputSchema: z.ZodObject<{
|
|
|
136
177
|
blockers: z.ZodArray<z.ZodString>;
|
|
137
178
|
}, z.core.$strip>;
|
|
138
179
|
next_action: z.ZodString;
|
|
180
|
+
semantic_ir_digest: z.ZodOptional<z.ZodString>;
|
|
181
|
+
semantic_ir_issues: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
182
|
+
action: z.ZodLiteral<"template_generate">;
|
|
183
|
+
template_id: z.ZodString;
|
|
139
184
|
}, z.core.$strip>, z.ZodObject<{
|
|
140
185
|
action: z.ZodLiteral<"template_scan">;
|
|
141
186
|
scan: z.ZodObject<{
|
|
@@ -162,6 +207,9 @@ export declare const BenchmarkMigrationOutputSchema: z.ZodObject<{
|
|
|
162
207
|
red_flags: z.ZodArray<z.ZodString>;
|
|
163
208
|
}, z.core.$strip>;
|
|
164
209
|
}, z.core.$strip>, z.ZodObject<{
|
|
210
|
+
next_action: z.ZodString;
|
|
211
|
+
semantic_ir_digest: z.ZodOptional<z.ZodString>;
|
|
212
|
+
semantic_ir_issues: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
165
213
|
action: z.ZodLiteral<"migration_import">;
|
|
166
214
|
log: z.ZodObject<{
|
|
167
215
|
source: z.ZodObject<{
|
|
@@ -205,7 +253,11 @@ export declare const BenchmarkMigrationOutputSchema: z.ZodObject<{
|
|
|
205
253
|
localnet: "localnet";
|
|
206
254
|
}>;
|
|
207
255
|
}, z.core.$strip>;
|
|
208
|
-
|
|
256
|
+
inference_source: z.ZodOptional<z.ZodEnum<{
|
|
257
|
+
keywords: "keywords";
|
|
258
|
+
semantic_ir: "semantic_ir";
|
|
259
|
+
"semantic_ir+keywords": "semantic_ir+keywords";
|
|
260
|
+
}>>;
|
|
209
261
|
}, z.core.$strip>, z.ZodObject<{
|
|
210
262
|
action: z.ZodLiteral<"migration_review">;
|
|
211
263
|
log: z.ZodObject<{
|
|
@@ -258,13 +310,6 @@ export declare const BenchmarkMigrationOutputSchema: z.ZodObject<{
|
|
|
258
310
|
}, z.core.$strip>;
|
|
259
311
|
next_action: z.ZodString;
|
|
260
312
|
}, z.core.$strip>, z.ZodObject<{
|
|
261
|
-
action: z.ZodLiteral<"migration_apply">;
|
|
262
|
-
template_id: z.ZodString;
|
|
263
|
-
network: z.ZodEnum<{
|
|
264
|
-
testnet: "testnet";
|
|
265
|
-
mainnet: "mainnet";
|
|
266
|
-
localnet: "localnet";
|
|
267
|
-
}>;
|
|
268
313
|
scan: z.ZodObject<{
|
|
269
314
|
risk_level: z.ZodEnum<{
|
|
270
315
|
low: "low";
|
|
@@ -295,6 +340,15 @@ export declare const BenchmarkMigrationOutputSchema: z.ZodObject<{
|
|
|
295
340
|
blockers: z.ZodArray<z.ZodString>;
|
|
296
341
|
}, z.core.$strip>;
|
|
297
342
|
next_action: z.ZodString;
|
|
343
|
+
semantic_ir_digest: z.ZodOptional<z.ZodString>;
|
|
344
|
+
semantic_ir_issues: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
345
|
+
action: z.ZodLiteral<"migration_apply">;
|
|
346
|
+
template_id: z.ZodString;
|
|
347
|
+
network: z.ZodEnum<{
|
|
348
|
+
testnet: "testnet";
|
|
349
|
+
mainnet: "mainnet";
|
|
350
|
+
localnet: "localnet";
|
|
351
|
+
}>;
|
|
298
352
|
}, z.core.$strip>], "action">;
|
|
299
353
|
}, z.core.$strict>;
|
|
300
354
|
export type BenchmarkMigrationOutput = z.infer<typeof BenchmarkMigrationOutputSchema>;
|
|
@@ -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','localnet'])['describe']('Target\x20network\x20(default\x20testnet).\x20\x27localnet\x27\x20labels\x20plans\x20validated\x20against\x20a\x20local\x20net\x20—\x20the\x20migration\x20pipeline\x20is\x20network-agnostic,\x20this\x20is\x20provenance\x20metadata,\x20not\x20an\x20execution\x20target.')})['describe']('Structured\x20competitor-migration\x20log.'),SaleItemIncentiveSchema=z['object']({'amount':z['string']()['describe']('Incentive\x20amount\x20as\x20a\x20buyer-readable\x20string\x20(e.g.\x20\x225\x20USDC\x22\x20or\x20\x221000000000\x20WOW\x20smallest\x20units\x22).\x20Quote-time\x20disclosure\x20only\x20—\x20fund\x20the\x20actual\x20rail\x20separately\x20(e.g.\x20the\x20template\x27s\x20review_reward_pool).'),'conditions':z['string']()['describe']('What\x20the\x20buyer\x20must\x20do\x20to\x20earn\x20it\x20(e.g.\x20\x22leave\x20a\x20written\x20+\x20rated\x20review\x20of\x20the\x20delivered\x20work\x22).\x20Must\x20be\x20perceptible\x20BEFORE\x20the\x20order\x20is\x20placed.'),'basis':z['string']()['describe']('Accrual\x20scope:\x20\x22per-order\x22\x20/\x20\x22once-per-buyer\x22\x20/\x20\x22once-per-buyer-per-order\x22.\x20Matches\x20the\x20claim\x20guard\x27s\x20replay\x20semantics\x20—\x20a\x20recipient-only\x20gate\x20is\x20once-per-buyer-for-life,\x20an\x20order-scoped\x20stamp\x20is\x20per-order\x20(SV-2).'),'claim_window':z['string']()['describe']('How\x20long\x20the\x20buyer\x20has\x20to\x20claim\x20(e.g.\x20\x2214\x20days\x20from\x20the\x20review\x22).\x20Mirror\x20the\x20reward\x20claim\x20guard\x27s\x20window\x20fee_param\x20so\x20the\x20quote\x20never\x20promises\x20more\x20than\x20the\x20rail\x20pays.')})['strict']()['describe']('Optional\x20structured\x20incentive\x20for\x20one\x20sale\x20item\x20(G-07):\x20buyer-perceivable\x20reward\x20terms\x20carried\x20to\x20the\x20compiled\x20plan\x20for\x20quote-time\x20disclosure.\x20DECLARATION\x20ONLY\x20—\x20the\x20chain\x20SaleItem\x20has\x20no\x20such\x20field;\x20the\x20actual\x20payout\x20rail\x20is\x20configured\x20separately.'),SaleItemPlanSchema=z['object']({'incentive':SaleItemIncentiveSchema['optional']()})['passthrough']()['describe']('One\x20sellable\x20SKU\x20in\x20the\x20plan\x20catalog:\x20the\x20chain\x20SaleItem\x20fields\x20plus\x20the\x20optional\x20structured\x20`incentive`\x20declaration\x20(G-07).\x20Unknown\x20keys\x20pass\x20through\x20so\x20chain-side\x20fields\x20can\x20evolve\x20without\x20schema\x20changes.');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\x20plus\x20a\x20drift\x20face\x20—\x20disk-vs-catalog\x20provenance\x20of\x20the\x20'+'scanned\x20body;\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'+'Advisory\x20designs\x20that\x20do\x20not\x20apply\x20to\x20this\x20shop\x20may\x20be\x20resolved\x20with\x20{kind:\x27omit\x27}\x20instead\x20'+'(run75747\x20F-38:\x20honored\x20only\x20for\x20designs\x20with\x20no\x20inbound\x20binding;\x20an\x20omit\x20of\x20a\x20bound\x20design\x20'+'is\x20refused\x20with\x20GUARD_OMIT_UNSUPPORTED).\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.\x20HARD-REQUIRED\x20when\x20the\x20effective\x20review\x20mode\x20is\x20review_reward\x20(INV-4):\x20template_generate\x20refuses\x20the\x20build\x20up-front\x20with\x20error_code\x20\x27reward_funding_required\x27\x20rather\x20than\x20promising\x20an\x20unfunded\x20incentive\x20—\x20pass\x20this,\x20or\x20drop\x20the\x20mode\x20explicitly\x20(review_mode\x20\x27review\x27\x20keeps\x20the\x20rail\x20without\x20the\x20bounty;\x20\x27none\x27\x20removes\x20the\x20rail).\x20The\x20compile\x20kernel\x20also\x20blocks\x20with\x20REVIEW_REWARD_UNFUNDED\x20—\x20this\x20input\x20gate\x20just\x20fails\x20before\x20the\x20pipeline\x20runs.'),'after_sales_mode':z['enum'](['return','exchange','warranty','none'])['optional']()['describe']('Per-build\x20after-sales\x20mode\x20(D12\x20重构\x204).\x20Absent\x20=\x20the\x20template\x27s\x20declared\x20after_sales_mode\x20applies.\x20Declaring\x20a\x20mode\x20with\x20no\x20backing\x20rail\x20in\x20machine_shape\x20is\x20a\x20compile\x20blocker\x20(AFTER_SALES_RAIL_MISSING).'),'acceptance_mode':z['enum'](['milestone','contest','bounty','agent','none'])['optional']()['describe']('Per-build\x20acceptance/judging\x20mode\x20(D12\x20重构\x202).\x20Absent\x20=\x20the\x20template\x27s\x20declared\x20acceptance_mode\x20applies.\x20A\x20judge-decided\x20mode\x20(contest/bounty/agent)\x20without\x20arbitration_mode\x20\x27third_party\x27\x20is\x20a\x20compile\x20blocker\x20(ACCEPTANCE_JUDGE_NOT_INDEPENDENT);\x20a\x20finite\x20revision_rounds_max\x20with\x20no\x20counter\x20Repository\x20guard\x20is\x20a\x20compile\x20blocker\x20(ACCEPTANCE_REVISION_UNBOUNDED).'),'installment_mode':z['enum'](['deposit_balance','milestone_n','none'])['optional']()['describe']('Per-build\x20installment/deposit\x20mode\x20(D12\x20重构\x203).\x20Absent\x20=\x20the\x20template\x27s\x20declared\x20installment_mode\x20applies.\x20A\x20capture\x20forward\x20with\x20no\x20fund-gate\x20Guard\x20is\x20a\x20compile\x20blocker\x20(INSTALLMENT_FUNDING_UNGATED);\x20a\x20deposit-held\x20state\x20with\x20no\x20exit\x20rail\x20is\x20a\x20compile\x20blocker\x20(INSTALLMENT_DEPOSIT_STRANDED).'),'affiliate_mode':z['enum'](['commission','none'])['optional']()['describe']('Per-build\x20affiliate\x20commission\x20overlay\x20(D12\x20批\x205).\x20Absent\x20=\x20the\x20template\x27s\x20declared\x20affiliate_mode\x20applies.\x20A\x20declared\x20commission\x20overlay\x20with\x20no\x20commission\x20rail\x20is\x20a\x20compile\x20blocker\x20(AFFILIATE_RAIL_MISSING);\x20a\x20commission\x20with\x20no\x20post-lock\x20no-clawback\x20disclosure\x20build_note\x20is\x20a\x20compile\x20blocker\x20(AFFILIATE_CLAWBACK_UNDISCLOSED).'),'crowdfunding_mode':z['enum'](['threshold','flexible','none'])['optional']()['describe']('Per-build\x20crowdfunding\x20campaign\x20overlay\x20(D12\x20批\x207).\x20Absent\x20=\x20the\x20template\x27s\x20declared\x20crowdfunding_mode\x20applies.\x20A\x20declared\x20threshold/flexible\x20overlay\x20with\x20no\x20two-leg\x20escrow-exit\x20gate\x20(release\x20XOR\x20refund,\x20D-BUG-2)\x20is\x20a\x20compile\x20blocker\x20(CROWDFUNDING_THRESHOLD_GATE_MISSING);\x20a\x20threshold\x20gate\x20whose\x20aggregate\x20is\x20NOT\x20a\x20writer-bound\x20sum-where\x20(id_from\x20signer)\x20is\x20a\x20compile\x20blocker\x20(CROWDFUNDING_AGGREGATE_UNBOUND);\x20a\x20missing\x20L-04/L-01/L-05\x20disclosure\x20build_note\x20is\x20a\x20compile\x20blocker\x20(CROWDFUNDING_DISCLOSURE_MISSING).'),'sales':z['array'](SaleItemPlanSchema)['optional']()['describe']('The\x20sellable\x20SKU\x20catalog\x20(upwc-cat-261017\x20CAT-A1\x20/\x20PLAN-SALES-01).\x20REQUIRED\x20for\x20template_generate\x20(A-2,\x20amz9-ln-261023):\x20an\x20empty/absent\x20catalog\x20is\x20refused\x20up-front\x20with\x20error_code\x20\x27sales_required\x27\x20—\x20the\x20published\x20Service\x20would\x20freeze\x20with\x20sales:\x20[]\x20and\x20every\x20order_new\x20aborts;\x20PLAN-SALES-01\x20is\x20now\x20an\x20INPUT\x20error\x20on\x20this\x20action,\x20not\x20a\x20post-hoc\x20audit\x20finding.\x20migration_apply\x20keeps\x20the\x20audit-finding\x20posture\x20(it\x20confirms\x20an\x20already-reviewed\x20import).\x20Item\x20shape\x20follows\x20the\x20chain\x27s\x20SaleItem:\x20{\x20name,\x20price,\x20quantity?,\x20wip_hash?\x20}\x20with\x20price\x20in\x20smallest\x20units.\x20OPTIONAL\x20per\x20item:\x20a\x20structured\x20`incentive`\x20object\x20(G-07:\x20{\x20amount,\x20conditions,\x20basis,\x20claim_window\x20},\x20all\x20strings)\x20declaring\x20the\x20buyer-perceivable\x20reward\x20terms\x20—\x20carried\x20verbatim\x20into\x20the\x20compiled\x20plan\x27s\x20service_sales\x20step\x20for\x20quote-time\x20disclosure;\x20it\x20is\x20plan\x20metadata\x20only\x20and\x20never\x20an\x20on-chain\x20SaleItem\x20field.'),'log':z['record'](z['string'](),z['unknown']())['optional']()['describe']('A\x20prior\x20MigrationLog\x20(required\x20for\x20migration_review).'),'network':z['enum'](['testnet','mainnet','localnet'])['optional']()['describe']('Target\x20network\x20for\x20migration_import\x20/\x20migration_apply\x20(default\x20testnet;\x20mainnet\x20requires\x20explicit\x20user\x20confirmation;\x20\x27localnet\x27\x20is\x20a\x20provenance\x20label\x20for\x20locally\x20validated\x20plans\x20—\x20the\x20pipeline\x20never\x20executes\x20on-chain).')})['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','localnet']),'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']();
|
|
1
|
+
import{z}from'zod';import{GuardResolutionInputSchema}from'../goal/planning.js';import{SemanticIRInputSchema}from'../../knowledge/semantic-ir.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','localnet'])['describe']('Target\x20network\x20(default\x20testnet).\x20\x27localnet\x27\x20labels\x20plans\x20validated\x20against\x20a\x20local\x20net\x20—\x20the\x20migration\x20pipeline\x20is\x20network-agnostic,\x20this\x20is\x20provenance\x20metadata,\x20not\x20an\x20execution\x20target.')})['describe']('Structured\x20competitor-migration\x20log.'),SaleItemIncentiveSchema=z['object']({'amount':z['string']()['describe']('Incentive\x20amount\x20as\x20a\x20buyer-readable\x20string\x20(e.g.\x20\x225\x20USDC\x22\x20or\x20\x221000000000\x20WOW\x20smallest\x20units\x22).\x20Quote-time\x20disclosure\x20only\x20—\x20fund\x20the\x20actual\x20rail\x20separately\x20(e.g.\x20the\x20template\x27s\x20review_reward_pool).'),'conditions':z['string']()['describe']('What\x20the\x20buyer\x20must\x20do\x20to\x20earn\x20it\x20(e.g.\x20\x22leave\x20a\x20written\x20+\x20rated\x20review\x20of\x20the\x20delivered\x20work\x22).\x20Must\x20be\x20perceptible\x20BEFORE\x20the\x20order\x20is\x20placed.'),'basis':z['string']()['describe']('Accrual\x20scope:\x20\x22per-order\x22\x20/\x20\x22once-per-buyer\x22\x20/\x20\x22once-per-buyer-per-order\x22.\x20Matches\x20the\x20claim\x20guard\x27s\x20replay\x20semantics\x20—\x20a\x20recipient-only\x20gate\x20is\x20once-per-buyer-for-life,\x20an\x20order-scoped\x20stamp\x20is\x20per-order\x20(SV-2).'),'claim_window':z['string']()['describe']('How\x20long\x20the\x20buyer\x20has\x20to\x20claim\x20(e.g.\x20\x2214\x20days\x20from\x20the\x20review\x22).\x20Mirror\x20the\x20reward\x20claim\x20guard\x27s\x20window\x20fee_param\x20so\x20the\x20quote\x20never\x20promises\x20more\x20than\x20the\x20rail\x20pays.')})['strict']()['describe']('Optional\x20structured\x20incentive\x20for\x20one\x20sale\x20item\x20(G-07):\x20buyer-perceivable\x20reward\x20terms\x20carried\x20to\x20the\x20compiled\x20plan\x20for\x20quote-time\x20disclosure.\x20DECLARATION\x20ONLY\x20—\x20the\x20chain\x20SaleItem\x20has\x20no\x20such\x20field;\x20the\x20actual\x20payout\x20rail\x20is\x20configured\x20separately.'),SaleItemPlanSchema=z['object']({'incentive':SaleItemIncentiveSchema['optional']()})['passthrough']()['describe']('One\x20sellable\x20SKU\x20in\x20the\x20plan\x20catalog:\x20the\x20chain\x20SaleItem\x20fields\x20plus\x20the\x20optional\x20structured\x20`incentive`\x20declaration\x20(G-07).\x20Unknown\x20keys\x20pass\x20through\x20so\x20chain-side\x20fields\x20can\x20evolve\x20without\x20schema\x20changes.');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\x20plus\x20a\x20drift\x20face\x20—\x20disk-vs-catalog\x20provenance\x20of\x20the\x20'+'scanned\x20body;\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).'),'semantic_ir':SemanticIRInputSchema['optional']()['describe']('Canonical\x20Semantic\x20IR\x20produced\x20by\x20the\x20CALLING\x20agent\x20for\x20a\x20NON-ENGLISH\x20(or\x20lexicon-outside)\x20description\x20—\x20this\x20server\x20runs\x20no\x20LLM.\x20'+'The\x20server\x20validates\x20it,\x20then\x20reuses\x20it\x20on\x20the\x20same\x20deterministic\x20surfaces\x20as\x20recommend_industry:\x20'+'(a)\x20migration_import\x20narrows\x20template\x20matching\x20to\x20the\x20IR-resolved\x20industry\x20(an\x20explicit\x20product_ref\x20or\x20\x27industry\x27\x20hint\x20still\x20wins);\x20'+'(b)\x20template_generate\x20/\x20migration_apply\x20read\x20the\x20numeric\x20claim\x20\x27reward_pool_amount\x27\x20as\x20the\x20review-reward\x20pool\x20prefill\x20—\x20'+'explicit\x20fee_overrides\x20>\x20IR\x20claim\x20>\x20the\x20English\x20regex\x20fallback.\x20'+'Shape:\x20{schema_version:\x201,\x20locale:\x20\x27<BCP-47>\x27,\x20traits?,\x20domains?,\x20claims?:\x20[{key,\x20value,\x20confidence?}],\x20provenance:\x20{source:\x20\x27caller_llm\x27}}.\x20'+'Unknown\x20traits/domains/claims\x20and\x20out-of-vocabulary\x20values\x20are\x20dropped\x20and\x20reported\x20in\x20semantic_ir_issues.'),'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'+'Advisory\x20designs\x20that\x20do\x20not\x20apply\x20to\x20this\x20shop\x20may\x20be\x20resolved\x20with\x20{kind:\x27omit\x27}\x20instead\x20'+'(run75747\x20F-38:\x20honored\x20only\x20for\x20designs\x20with\x20no\x20inbound\x20binding;\x20an\x20omit\x20of\x20a\x20bound\x20design\x20'+'is\x20refused\x20with\x20GUARD_OMIT_UNSUPPORTED).\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.\x20HARD-REQUIRED\x20when\x20the\x20effective\x20review\x20mode\x20is\x20review_reward\x20(INV-4):\x20template_generate\x20refuses\x20the\x20build\x20up-front\x20with\x20error_code\x20\x27reward_funding_required\x27\x20rather\x20than\x20promising\x20an\x20unfunded\x20incentive\x20—\x20pass\x20this,\x20or\x20drop\x20the\x20mode\x20explicitly\x20(review_mode\x20\x27review\x27\x20keeps\x20the\x20rail\x20without\x20the\x20bounty;\x20\x27none\x27\x20removes\x20the\x20rail).\x20The\x20compile\x20kernel\x20also\x20blocks\x20with\x20REVIEW_REWARD_UNFUNDED\x20—\x20this\x20input\x20gate\x20just\x20fails\x20before\x20the\x20pipeline\x20runs.'),'reward_claim_amount':z['string']()['optional']()['describe']('Per-claim\x20reward\x20bounty\x20mounted\x20on\x20the\x20claim\x20guard_add,\x20smallest-unit\x20string.\x20Schema-required\x20on\x20the\x20mount\x20(BK15-F09):\x20compile\x20blocks\x20with\x20REVIEW_REWARD_AMOUNT_MISSING\x20when\x20absent\x20—\x20the\x20kernel\x20never\x20fabricates\x20a\x20real-money\x20parameter.'),'after_sales_mode':z['enum'](['return','exchange','warranty','none'])['optional']()['describe']('Per-build\x20after-sales\x20mode\x20(D12\x20refactor\x204).\x20Absent\x20=\x20the\x20template\x27s\x20declared\x20after_sales_mode\x20applies.\x20Declaring\x20a\x20mode\x20with\x20no\x20backing\x20rail\x20in\x20machine_shape\x20is\x20a\x20compile\x20blocker\x20(AFTER_SALES_RAIL_MISSING).'),'acceptance_mode':z['enum'](['milestone','contest','bounty','agent','none'])['optional']()['describe']('Per-build\x20acceptance/judging\x20mode\x20(D12\x20refactor\x202).\x20Absent\x20=\x20the\x20template\x27s\x20declared\x20acceptance_mode\x20applies.\x20A\x20judge-decided\x20mode\x20(contest/bounty/agent)\x20without\x20arbitration_mode\x20\x27third_party\x27\x20is\x20a\x20compile\x20blocker\x20(ACCEPTANCE_JUDGE_NOT_INDEPENDENT);\x20a\x20finite\x20revision_rounds_max\x20with\x20no\x20counter\x20Repository\x20guard\x20is\x20a\x20compile\x20blocker\x20(ACCEPTANCE_REVISION_UNBOUNDED).'),'installment_mode':z['enum'](['deposit_balance','milestone_n','none'])['optional']()['describe']('Per-build\x20installment/deposit\x20mode\x20(D12\x20refactor\x203).\x20Absent\x20=\x20the\x20template\x27s\x20declared\x20installment_mode\x20applies.\x20A\x20capture\x20forward\x20with\x20no\x20fund-gate\x20Guard\x20is\x20a\x20compile\x20blocker\x20(INSTALLMENT_FUNDING_UNGATED);\x20a\x20deposit-held\x20state\x20with\x20no\x20exit\x20rail\x20is\x20a\x20compile\x20blocker\x20(INSTALLMENT_DEPOSIT_STRANDED).'),'affiliate_mode':z['enum'](['commission','none'])['optional']()['describe']('Per-build\x20affiliate\x20commission\x20overlay\x20(D12\x20batch\x205).\x20Absent\x20=\x20the\x20template\x27s\x20declared\x20affiliate_mode\x20applies.\x20A\x20declared\x20commission\x20overlay\x20with\x20no\x20commission\x20rail\x20is\x20a\x20compile\x20blocker\x20(AFFILIATE_RAIL_MISSING);\x20a\x20commission\x20with\x20no\x20post-lock\x20no-clawback\x20disclosure\x20build_note\x20is\x20a\x20compile\x20blocker\x20(AFFILIATE_CLAWBACK_UNDISCLOSED).'),'crowdfunding_mode':z['enum'](['threshold','flexible','none'])['optional']()['describe']('Per-build\x20crowdfunding\x20campaign\x20overlay\x20(D12\x20batch\x207).\x20Absent\x20=\x20the\x20template\x27s\x20declared\x20crowdfunding_mode\x20applies.\x20A\x20declared\x20threshold/flexible\x20overlay\x20with\x20no\x20two-leg\x20escrow-exit\x20gate\x20(release\x20XOR\x20refund,\x20D-BUG-2)\x20is\x20a\x20compile\x20blocker\x20(CROWDFUNDING_THRESHOLD_GATE_MISSING);\x20a\x20threshold\x20gate\x20whose\x20aggregate\x20is\x20NOT\x20a\x20writer-bound\x20sum-where\x20(id_from\x20signer)\x20is\x20a\x20compile\x20blocker\x20(CROWDFUNDING_AGGREGATE_UNBOUND);\x20a\x20missing\x20L-04/L-01/L-05\x20disclosure\x20build_note\x20is\x20a\x20compile\x20blocker\x20(CROWDFUNDING_DISCLOSURE_MISSING).'),'sales':z['array'](SaleItemPlanSchema)['optional']()['describe']('The\x20sellable\x20SKU\x20catalog\x20(upwc-cat-261017\x20CAT-A1\x20/\x20PLAN-SALES-01).\x20REQUIRED\x20for\x20template_generate\x20(A-2,\x20amz9-ln-261023):\x20an\x20empty/absent\x20catalog\x20is\x20refused\x20up-front\x20with\x20error_code\x20\x27sales_required\x27\x20—\x20the\x20published\x20Service\x20would\x20freeze\x20with\x20sales:\x20[]\x20and\x20every\x20order_new\x20aborts;\x20PLAN-SALES-01\x20is\x20now\x20an\x20INPUT\x20error\x20on\x20this\x20action,\x20not\x20a\x20post-hoc\x20audit\x20finding.\x20migration_apply\x20keeps\x20the\x20audit-finding\x20posture\x20(it\x20confirms\x20an\x20already-reviewed\x20import).\x20Item\x20shape\x20follows\x20the\x20chain\x27s\x20SaleItem:\x20{\x20name,\x20price,\x20quantity?,\x20wip_hash?\x20}\x20with\x20price\x20in\x20smallest\x20units.\x20OPTIONAL\x20per\x20item:\x20a\x20structured\x20`incentive`\x20object\x20(G-07:\x20{\x20amount,\x20conditions,\x20basis,\x20claim_window\x20},\x20all\x20strings)\x20declaring\x20the\x20buyer-perceivable\x20reward\x20terms\x20—\x20carried\x20verbatim\x20into\x20the\x20compiled\x20plan\x27s\x20service_sales\x20step\x20for\x20quote-time\x20disclosure;\x20it\x20is\x20plan\x20metadata\x20only\x20and\x20never\x20an\x20on-chain\x20SaleItem\x20field.'),'log':z['record'](z['string'](),z['unknown']())['optional']()['describe']('A\x20prior\x20MigrationLog\x20(required\x20for\x20migration_review).'),'network':z['enum'](['testnet','mainnet','localnet'])['optional']()['describe']('Target\x20network\x20for\x20migration_import\x20/\x20migration_apply\x20(default\x20testnet;\x20mainnet\x20requires\x20explicit\x20user\x20confirmation;\x20\x27localnet\x27\x20is\x20a\x20provenance\x20label\x20for\x20locally\x20validated\x20plans\x20—\x20the\x20pipeline\x20never\x20executes\x20on-chain).')})['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).'),SemanticIrEcho={'semantic_ir_digest':z['string']()['optional']()['describe']('sha256\x20of\x20the\x20frozen\x20Semantic\x20IR\x20artifact\x20(present\x20only\x20when\x20semantic_ir\x20was\x20supplied).'),'semantic_ir_issues':z['array'](z['string']())['optional']()['describe']('IR\x20claims\x20dropped/clamped/conflicting\x20during\x20validation\x20(unknown\x20vocabulary,\x20inverted\x20span,\x20sub-threshold\x20confidence).')};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'](),...SemanticIrEcho,'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.'),'inference_source':z['enum'](['keywords','semantic_ir','semantic_ir+keywords'])['optional']()['describe']('Which\x20layer\x20resolved\x20the\x20industry:\x20\x27keywords\x27\x20=\x20English\x20lexical\x20match\x20only;\x20\x27semantic_ir\x27\x20=\x20'+'the\x20caller\x27s\x20IR\x20decided;\x20\x27semantic_ir+keywords\x27\x20=\x20both\x20contributed.\x20Present\x20only\x20when\x20semantic_ir\x20was\x20supplied.'),...SemanticIrEcho,'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','localnet']),...SemanticIrEcho,'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']();
|