@wowok/agent-mcp 3.3.0 → 3.3.2
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/field-capability.js +1 -1
- package/dist/chain-semantics/freeze-map.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.d.ts +5 -0
- package/dist/composition/audit.js +1 -1
- package/dist/composition/blueprint-view.d.ts +0 -1
- package/dist/composition/blueprint-view.js +1 -1
- package/dist/composition/compile.d.ts +4 -2
- package/dist/composition/compile.js +1 -1
- package/dist/composition/inflight.d.ts +8 -4
- package/dist/composition/inflight.js +1 -1
- package/dist/customer/industry-risks.js +1 -1
- package/dist/customer/user-preferences.js +1 -1
- package/dist/extensions/business-modules.d.ts +7 -2
- package/dist/extensions/business-modules.js +1 -1
- package/dist/extensions/industry-audit.spec.js +1 -1
- package/dist/extensions/industry-pack.d.ts +3 -2
- package/dist/extensions/industry-pack.js +1 -1
- package/dist/extensions/modes.js +1 -1
- package/dist/graph/onchain/project-relationship.js +1 -1
- package/dist/knowledge/acquisition-flywheel.js +1 -1
- package/dist/knowledge/allocation-ledger.d.ts +4 -1
- package/dist/knowledge/allocation-ledger.js +1 -1
- package/dist/knowledge/allocation-puzzle.d.ts +1 -0
- package/dist/knowledge/allocation-puzzle.js +1 -1
- package/dist/knowledge/allocation-risk.d.ts +1 -1
- package/dist/knowledge/allocation-risk.js +1 -1
- package/dist/knowledge/arb-fund-facts.d.ts +5 -0
- package/dist/knowledge/arb-fund-facts.js +1 -1
- package/dist/knowledge/audit-rules.d.ts +4 -3
- package/dist/knowledge/audit-rules.js +1 -1
- package/dist/knowledge/baselines/rules/plan.json +48 -2
- package/dist/knowledge/baselines/rules/reward.json +1 -1
- package/dist/knowledge/builtin-templates.d.ts +9 -1
- package/dist/knowledge/builtin-templates.js +1 -1
- package/dist/knowledge/discount-threshold.js +1 -1
- package/dist/knowledge/guard-bindings.js +1 -1
- package/dist/knowledge/guard-design-patterns.js +1 -1
- package/dist/knowledge/guard-field-cognition.js +1 -1
- package/dist/knowledge/guard-lint.js +1 -1
- package/dist/knowledge/guard-submission-brief.d.ts +5 -0
- package/dist/knowledge/guard-submission-brief.js +1 -1
- package/dist/knowledge/guard-submission-prompt.d.ts +2 -1
- package/dist/knowledge/guard-submission-prompt.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.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/industry-strategy.js +1 -1
- package/dist/knowledge/reward-ledger.js +1 -1
- package/dist/knowledge/reward-puzzle.d.ts +1 -1
- package/dist/knowledge/reward-risk.d.ts +1 -1
- package/dist/knowledge/scenario-modes.d.ts +2 -2
- package/dist/knowledge/scenario-modes.js +1 -1
- package/dist/knowledge/scenario-topology.js +1 -1
- package/dist/knowledge/strategy-manuals.js +1 -1
- package/dist/knowledge/template-index.d.ts +19 -0
- package/dist/knowledge/template-index.js +1 -0
- package/dist/knowledge/template-loader.d.ts +36 -0
- package/dist/knowledge/template-loader.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/template-scanner.d.ts +7 -0
- package/dist/knowledge/template-scanner.js +1 -1
- package/dist/knowledge/tool-constraints.js +1 -1
- package/dist/knowledge/workflow-guidance.js +1 -1
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/participation/radar-core.d.ts +1 -0
- package/dist/participation/radar-core.js +1 -1
- package/dist/persona/defaults.js +1 -1
- package/dist/persona/topology-focus.js +1 -1
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/game-theory.d.ts +4 -1
- package/dist/playbooks/service-build/game-theory.js +1 -1
- package/dist/playbooks/service-build/machine-panorama.js +1 -1
- package/dist/playbooks/service-build/merchant-guide.d.ts +25 -1
- package/dist/playbooks/service-build/merchant-guide.js +1 -1
- package/dist/playbooks/service-build/migration-planner.js +1 -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/pipeline-actions.d.ts +4 -1
- package/dist/playbooks/service-build/pipeline-actions.js +1 -1
- package/dist/playbooks/service-build/relationship-profile.js +1 -1
- package/dist/playbooks/service-build/service-panorama.d.ts +4 -0
- package/dist/playbooks/service-build/service-panorama.js +1 -1
- package/dist/playbooks/service-build/service-quote.js +1 -1
- package/dist/relationship/derivation.d.ts +1 -1
- package/dist/review/index.js +1 -1
- package/dist/rules.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/benchmark-migration/index.d.ts +35 -0
- package/dist/schema/benchmark-migration/index.js +1 -1
- package/dist/schema/call/allocation.d.ts +46 -3
- package/dist/schema/call/allocation.js +1 -1
- package/dist/schema/call/contact.js +1 -1
- package/dist/schema/call/guard.js +1 -1
- package/dist/schema/call/handler.js +1 -1
- package/dist/schema/call/order.js +1 -1
- package/dist/schema/call/progress.d.ts +6 -3
- package/dist/schema/call/progress.js +1 -1
- package/dist/schema/call/repository.js +1 -1
- package/dist/schema/call/reward.d.ts +2 -2
- package/dist/schema/call/reward.js +1 -1
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.d.ts +8 -4
- package/dist/schema/call/service.js +1 -1
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/goal/index.d.ts +54 -0
- package/dist/schema/goal/planning.d.ts +86 -0
- package/dist/schema/goal/planning.js +1 -1
- package/dist/schema/local/index.d.ts +39 -0
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/operations.d.ts +20 -5
- package/dist/schema/operations.js +1 -1
- package/dist/schema/query/bi.d.ts +2 -0
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/query/index.d.ts +24 -12
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-version.d.ts +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema/workspace/index.d.ts +9 -0
- package/dist/schema/workspace/index.js +1 -1
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +28 -3
- package/dist/schemas/benchmark_migration_operation.schema.json +87 -0
- package/dist/schemas/goal_operation.schema.json +94 -0
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/onchain_operations.output.json +1 -1
- package/dist/schemas/onchain_operations.schema.json +409 -119
- package/dist/schemas/onchain_operations_allocation.schema.json +290 -6
- package/dist/schemas/onchain_operations_arbitration.schema.json +2 -2
- package/dist/schemas/onchain_operations_contact.schema.json +2 -2
- package/dist/schemas/onchain_operations_demand.schema.json +3 -3
- package/dist/schemas/onchain_operations_gen_passport.schema.json +1 -1
- package/dist/schemas/onchain_operations_guard.schema.json +63 -63
- package/dist/schemas/onchain_operations_machine.schema.json +1 -1
- package/dist/schemas/onchain_operations_order.schema.json +2 -2
- package/dist/schemas/onchain_operations_progress.schema.json +7 -3
- package/dist/schemas/onchain_operations_proof.schema.json +1 -1
- package/dist/schemas/onchain_operations_repository.schema.json +2 -2
- package/dist/schemas/onchain_operations_reward.schema.json +8 -8
- package/dist/schemas/onchain_operations_service.schema.json +20 -18
- package/dist/schemas/onchain_operations_treasury.schema.json +7 -7
- package/dist/schemas/query_toolkit.output.json +67 -53
- package/dist/schemas/workflow_operation.schema.json +1 -1
- package/dist/schemas/workspace_operation.output.json +23 -3
- package/dist/schemas/workspace_operation.schema.json +3 -3
- package/dist/tools/handlers/benchmark-migration.js +1 -1
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/file-export.js +1 -1
- package/dist/tools/handlers/industry-pack.d.ts +1 -0
- package/dist/tools/handlers/industry-pack.js +1 -1
- package/dist/tools/handlers/local.js +1 -1
- package/dist/tools/handlers/onchain.d.ts +24 -0
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/handlers/review-chain.d.ts +1 -1
- package/dist/tools/handlers/review-chain.js +1 -1
- package/dist/tools/handlers/schema-query.js +1 -1
- package/dist/tools/handlers/workflow.js +1 -1
- package/dist/tools/handlers/workspace.js +1 -1
- package/dist/tools/registry/agent.js +1 -1
- package/dist/tools/registry/local.js +1 -1
- package/dist/tools/wip-deploy-assist.js +1 -1
- package/dist/tools/wrap.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{initServicePuzzleFromIntent,initMachinePuzzleFromIntent,initAllocationPuzzleFromIntent,initTreasuryPuzzleFromIntent,initArbitrationPuzzleFromIntent,initRewardPuzzleFromIntent,initProgressPuzzleFromIntent,initOrderPuzzleFromIntent,initPuzzleFromIntent as
|
|
1
|
+
import{initServicePuzzleFromIntent,initMachinePuzzleFromIntent,initAllocationPuzzleFromIntent,initTreasuryPuzzleFromIntent,initArbitrationPuzzleFromIntent,initRewardPuzzleFromIntent,initProgressPuzzleFromIntent,initOrderPuzzleFromIntent,initPuzzleFromIntent as a321a,checkServicePuzzleCompleteness,checkMachinePuzzleCompleteness,checkAllocationPuzzleCompleteness,checkTreasuryPuzzleCompleteness,checkArbitrationPuzzleCompleteness,checkRewardPuzzleCompleteness,checkProgressPuzzleCompleteness,checkOrderPuzzleCompleteness,checkPuzzleCompleteness as a321b}from'../../knowledge/index.js';import{initPuzzleFromIntent as a321c,checkPuzzleCompleteness as a321d}from'../../knowledge/permission-puzzle.js';const KEYWORD_TABLE=[{'category':'Product/Service','keywords_zh':['product','selling','sell','sales','store','open\x20shop'],'keywords_en':['sell','product','sale','shop','store'],'objects':['service','order','progress'],'required_level':'R','scene_id':'retail'},{'category':'Subscription','keywords_zh':['subscription','cycle','renewal'],'keywords_en':['subscribe','recurring','subscription'],'objects':['service','machine','reward'],'required_level':'C','scene_id':'subscription'},{'category':'Rental','keywords_zh':['rent','lease','return'],'keywords_en':['rent','lease','return'],'objects':['service','machine','arb'],'required_level':'C','scene_id':'rental_return'},{'category':'Trust','keywords_zh':['deposit','pledge','verify','trust'],'keywords_en':['deposit','trust','verify'],'objects':['guard','permission','treasury'],'required_level':'R','scene_id':'trust_deposit'},{'category':'Funds','keywords_zh':['split','collect','share\x20profit','income','incentive'],'keywords_en':['split','revenue','reward'],'objects':['allocation','treasury','reward'],'required_level':'R','scene_id':'revenue_split'},{'category':'Workflow','keywords_zh':['node','stage','process','workflow'],'keywords_en':['workflow','stage','node'],'objects':['machine','progress'],'required_level':'R','scene_id':'workflow'},{'category':'Dispute','keywords_zh':['arbitration','refund','conflict','rights\x20protection'],'keywords_en':['arbitration','refund','dispute'],'objects':['arb','proof'],'required_level':'C','scene_id':'arbitration_dispute'},{'category':'Contact','keywords_zh':['customer\x20service','contact','communication'],'keywords_en':['contact','support','im'],'objects':['contact'],'required_level':'C','scene_id':'contact_im'},{'category':'Data','keywords_zh':['evidence','record','data'],'keywords_en':['evidence','record','data'],'objects':['repository','proof'],'required_level':'C','scene_id':'evidence_record'},{'category':'User\x20Profile','keywords_zh':['personal\x20info','preference','privacy'],'keywords_en':['personal','profile','privacy'],'objects':['personal','contact'],'required_level':'OPTIONAL','scene_id':'user_profile'},{'category':'Demand\x20Submission','keywords_zh':['demand','publish','inquiry'],'keywords_en':['demand','request','inquiry'],'objects':['demand'],'required_level':'OPTIONAL','scene_id':'demand_inquiry'}],INDUSTRY_KEYWORDS=[{'industry':'freelance','words':['freelance','outsourcing','freelance','gig']},{'industry':'rental','words':['rental','lease','rental','rent']},{'industry':'education','words':['education','course','training','education','course']},{'industry':'travel','words':['travel','tour','itinerary','travel','trip']},{'industry':'subscription','words':['subscription','cycle','subscription','recurring']}];function buildPuzzleDispatch(){const a=(c,d)=>{try{return c(d);}catch{return undefined;}},b=(c,d)=>{if(!c)return{'missing':[],'complete':![],'next_step':'init\x20failed'};try{return d(c);}catch{return{'missing':[],'complete':![],'next_step':'check\x20failed'};}};return{'service':{'init':c=>a(initServicePuzzleFromIntent,{'primary_goal':c}),'check':c=>b(c,checkServicePuzzleCompleteness)},'machine':{'init':c=>a(initMachinePuzzleFromIntent,c),'check':c=>b(c,checkMachinePuzzleCompleteness)},'allocation':{'init':c=>a(initAllocationPuzzleFromIntent,{'primary_goal':c}),'check':c=>b(c,checkAllocationPuzzleCompleteness)},'treasury':{'init':c=>a(initTreasuryPuzzleFromIntent,{'primary_goal':c}),'check':c=>b(c,checkTreasuryPuzzleCompleteness)},'arb':{'init':c=>a(initArbitrationPuzzleFromIntent,{'primary_goal':c}),'check':c=>b(c,checkArbitrationPuzzleCompleteness)},'reward':{'init':c=>a(initRewardPuzzleFromIntent,{'primary_goal':c}),'check':c=>b(c,checkRewardPuzzleCompleteness)},'progress':{'init':c=>a(initProgressPuzzleFromIntent,{'primary_goal':c}),'check':c=>b(c,checkProgressPuzzleCompleteness)},'order':{'init':c=>a(initOrderPuzzleFromIntent,{'primary_goal':c}),'check':c=>b(c,checkOrderPuzzleCompleteness)},'permission':{'init':c=>a(a321c,{'primary_goal':c}),'check':c=>b(c,a321d)},'guard':{'init':c=>a(a321a,{'primary_goal':c}),'check':c=>b(c,a321b)}};}export function extractKeywords(a){if(!a||typeof a!=='string')return[];const b=[];for(const c of KEYWORD_TABLE){const d=[...c['keywords_zh'],...c['keywords_en']];for(const e of d){try{const f=new RegExp(escapeRegex(e),'gi'),g=(a['match'](f)||[])['length'];g>0x0&&b['push']({'keyword':e,'category':c['category'],'matched_objects':[...c['objects']],'required_level':c['required_level'],'match_count':g});}catch{}}}return b['sort']((h,i)=>i['match_count']-h['match_count']),b;}function escapeRegex(a){return a['replace'](/[.*+?^${}()|[\]\\]/g,'\x5c$&');}export function resolveIndustry(a,b){const c=((a??'')+'\x20'+(b??''))['toLowerCase']();for(const d of INDUSTRY_KEYWORDS){for(const e of d['words']){if(c['includes'](e['toLowerCase']()))return d['industry'];}}return'general';}export function identifyObjects(a,b){if(b['length']===0x0)return{'primary':'service','secondary':['permission','machine','progress'],'scenes':[{'object':'service','scene_id':'general'}]};const c=b['find'](i=>i['required_level']==='R'),d=(c??b[0x0])['matched_objects'][0x0],e=new Set([d]),f=[];for(const i of b){for(const j of i['matched_objects']){!e['has'](j)&&(e['add'](j),f['push'](j));}}const g=[],h=new Set();for(const k of KEYWORD_TABLE){const l=b['find'](n=>n['category']===k['category']);if(!l)continue;if(h['has'](k['scene_id']))continue;h['add'](k['scene_id']),g['push']({'object':k['objects'][0x0],'scene_id':k['scene_id']});}return{'primary':d,'secondary':f,'scenes':g};}export function analyzeBusinessIntent(a){const b=[];if(!a||!a['user_intent']||typeof a['user_intent']!=='string')return{'intent_parsed':{'primary_object':'service','secondary_objects':[],'detected_scenes':[],'industry':'general','keyword_matches':[]},'puzzles':{},'overall_completeness':'empty','next_step':'Please\x20provide\x20a\x20non-empty\x20business\x20intent.','recommended_creation_order':[],'warnings':['input.user_intent\x20is\x20empty']};const c=a['user_intent'],e=extractKeywords(c),f=resolveIndustry(c,a['industry']),{primary:g,secondary:h,scenes:i}=identifyObjects(c,e);let j=[g,...h];if(a['target_objects']&&a['target_objects']['length']>0x0){const p=a['target_objects']['filter'](q=>['service','machine','guard','permission','reward','arb','progress','treasury','demand','repository','contact','order','allocation','personal','payment','proof']['includes'](q));if(p['length']>0x0)j=p;}const k=buildPuzzleDispatch(),l={};for(const q of j){const r=k[q];if(!r){b['push']('No\x20puzzle\x20module\x20for\x20\x27'+q+'\x27\x20—\x20skipped\x20(L3\x20object)');continue;}const s=r['init'](c),t=s?r['check'](s):undefined,u=extractMissingDimensions(t);l[q]={'puzzle':s,'completeness':t,'missing_dimensions':u},!s&&b['push']('Puzzle\x20init\x20failed\x20for\x20\x27'+q+'\x27');}const m=aggregatePuzzleCompleteness(l),n=suggestNextPuzzleStep({'intent_parsed':{'primary_object':g,'secondary_objects':h,'detected_scenes':i,'industry':f,'keyword_matches':e},'puzzles':l,'overall_completeness':m,'next_step':'','recommended_creation_order':[],'warnings':b}),o=['permission','progress','machine','guard','allocation','service'];return{'intent_parsed':{'primary_object':g,'secondary_objects':h,'detected_scenes':i,'industry':f,'keyword_matches':e},'puzzles':l,'overall_completeness':m,'next_step':n,'recommended_creation_order':o,'warnings':b};}function extractMissingDimensions(a){if(!a||typeof a!=='object')return[];const b=a,d=b['missing'];if(Array['isArray'](d))return d['map'](f=>String(f));const e=b['missing_details'];if(Array['isArray'](e))return e['map'](f=>String(f?.['dimension']??f));return[];}export function aggregatePuzzleCompleteness(a){const b=Object['values'](a??{});if(b['length']===0x0)return'empty';const c=b['filter'](f=>!f['puzzle'])['length'];if(c===b['length'])return'empty';const d=b['reduce']((f,g)=>f+(g['missing_dimensions']?.['length']??0x0),0x0);if(d===0x0)return'complete';return'partial';}export function suggestNextPuzzleStep(a){if(!a)return'No\x20result\x20to\x20suggest\x20from.';if(a['overall_completeness']==='complete')return'All\x20puzzle\x20dimensions\x20are\x20complete\x20—\x20ready\x20for\x20risk\x20calibration\x20(stage\x203).';if(a['overall_completeness']==='empty')return'No\x20puzzle\x20has\x20been\x20initialized.\x20Provide\x20more\x20concrete\x20business\x20intent\x20so\x20the\x20primary\x20object\x20can\x20be\x20identified.';const b=['permission','treasury','allocation','guard','machine','service','order','progress','arb','reward','proof','repository','demand','contact','personal','payment'],d=a['puzzles']??{},e=b['filter'](f=>d[f]);for(const f of e){const g=d[f];if(!g)continue;const h=g['missing_dimensions']??[];if(h['length']===0x0)continue;const i=g['completeness'],j=i&&typeof i==='object'?i['next_step']:undefined;if(typeof j==='string'&&j['trim']())return'['+f+']\x20'+j;return'['+f+']\x20Complete\x20dimension'+(h['length']>0x1?'s':'')+'\x20'+h['join'](',\x20')+'\x20to\x20advance\x20the\x20puzzle.';}return'Continue\x20dialog\x20to\x20fill\x20remaining\x20pending\x20fields.';}
|
|
@@ -22,6 +22,9 @@ export interface GameTheoryConstraint {
|
|
|
22
22
|
recommendation: string;
|
|
23
23
|
appliesWhen?: (intent: BusinessIntent) => boolean;
|
|
24
24
|
}
|
|
25
|
+
export interface MachineShapeFacts {
|
|
26
|
+
expiredTerminal?: boolean;
|
|
27
|
+
}
|
|
25
28
|
export interface GameTheoryCheckResult {
|
|
26
29
|
scenario: GameScenario;
|
|
27
30
|
conflict: string;
|
|
@@ -41,4 +44,4 @@ export interface GameTheoryReport {
|
|
|
41
44
|
summary: string;
|
|
42
45
|
}
|
|
43
46
|
export declare const GAME_THEORY_CONSTRAINTS: GameTheoryConstraint[];
|
|
44
|
-
export declare function checkGameTheoryConstraints(graph: Blueprint, intent: BusinessIntent): GameTheoryReport;
|
|
47
|
+
export declare function checkGameTheoryConstraints(graph: Blueprint, intent: BusinessIntent, machineFacts?: MachineShapeFacts): GameTheoryReport;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const GAME_THEORY_CONSTRAINTS=[{'scenario':'merchant_may_deliver_late','conflict':'Merchant\x20incentive:\x20collect\x20payment\x20fast,\x20deliver\x20at\x20own\x20pace\x20(or\x20never).\x20User\x20bears\x20schedule\x20risk\x20with\x20no\x20leverage\x20once\x20funds\x20leave\x20their\x20wallet.','userProtection':{'mechanism':'Milestone\x20escrow\x20—\x20funds\x20locked\x20in\x20Order,\x20released\x20per\x20verified\x20milestone','object':'Order\x20+\x20Allocation','guard':'milestone\x20forward\x20guard\x20verifies\x20deliverable\x20before\x20release'},'merchantConstraint':{'requiredDeposit':!![],'timeoutPenalty':'compensation_fund\x20covers\x20refund\x20for\x20unstarted\x20milestones'},'evaluationMetric':'timeout_protection','mitigationSignals':[['edge:has_order_allocators','node:main_machine'],['module:milestone_escrow']],'mitigatingModules':['milestone_escrow','refund_guarantee'],'recommendation':'Adopt\x20milestone_escrow\x20module:\x20bind\x20order_allocators\x20+\x20Machine\x20so\x20funds\x20release\x20only\x20per\x20verified\x20milestone.\x20Add\x20compensation_fund\x20for\x20late-delivery\x20refunds.'},{'scenario':'merchant_may_abandon','conflict':'Merchant\x20incentive:\x20maximize\x20intake\x20then\x20abandon\x20the\x20service\x20(exit\x20scam).\x20User\x20has\x20no\x20recourse\x20without\x20locked\x20funds\x20or\x20deposit.','userProtection':{'mechanism':'Escrow\x20+\x20compensation\x20fund\x20—\x20user\x20refunds\x20from\x20on-chain\x20fund\x20even\x20if\x20merchant\x20vanishes','object':'Service.compensation_fund\x20+\x20Order','guard':'refund_guard\x20validates\x20claim\x20conditions'},'merchantConstraint':{'requiredDeposit':!![],'requiredArbitration':!![]},'evaluationMetric':'escrow_quality','mitigationSignals':[['edge:has_order_allocators','module:refund_guarantee'],['module:refund_guarantee','node:main_arbitration']],'mitigatingModules':['refund_guarantee','milestone_escrow','reputation_on_chain'],'recommendation':'Adopt\x20refund_guarantee\x20module:\x20compensation_fund_add\x20>\x200\x20with\x20refund_guard.\x20Escrow\x20via\x20order_allocators\x20prevents\x20merchant\x20from\x20touching\x20funds\x20before\x20delivery.'},{'scenario':'customer_may_deny_acceptance','conflict':'Customer\x20incentive:\x20withhold\x20acceptance\x20confirmation\x20to\x20delay\x20payment\x20indefinitely\x20while\x20using\x20the\x20deliverable.\x20Merchant\x27s\x20funds\x20stay\x20locked.','userProtection':{'mechanism':'Accept\x20timeout\x20—\x20after\x20N\x20days\x20without\x20response,\x20order\x20auto-advances\x20(adminUnhold)\x20and\x20merchant\x20gets\x20paid','object':'Machine\x20forward\x20+\x20Progress','guard':'time_guard\x20on\x20accept\x20forward'},'merchantConstraint':{'timeoutPenalty':'user\x20silence\x20past\x20timeout\x20=\x20implicit\x20acceptance'},'evaluationMetric':'timeout_protection','mitigationSignals':[['module:accept_timeout_protection'],['node:guard_accept_timeout_protection']],'mitigatingModules':['accept_timeout_protection'],'recommendation':'Adopt\x20accept_timeout_protection\x20module:\x20time_guard\x20on\x20the\x20accept\x20forward\x20(e.g.\x207\x20days)\x20+\x20PROGRESS_UNHOLD\x20permission\x20so\x20the\x20workflow\x20auto-advances\x20on\x20customer\x20silence.'},{'scenario':'customer_may_false_claim','conflict':'Customer\x20incentive:\x20claim\x20non-delivery\x20or\x20defect\x20to\x20obtain\x20refund\x20while\x20keeping\x20the\x20goods/service.\x20Merchant\x20loses\x20both\x20deliverable\x20and\x20payment.','userProtection':{'mechanism':'WIP\x20provenance\x20—\x20delivery\x20hash\x20committed\x20on-chain\x20before/at\x20delivery;\x20independent\x20arbitration\x20verifies\x20evidence','object':'Repository\x20+\x20Arbitration','guard':'Guard\x20compares\x20proof.signer/proof.time\x20against\x20committed\x20WIP\x20hash'},'merchantConstraint':{'requiredProof':'wip_hash\x20committed\x20to\x20Repository\x20before\x20fund\x20release','requiredArbitration':!![]},'evaluationMetric':'proof_integrity','mitigationSignals':[['node:main_repository','node:main_arbitration'],['module:wip_provenance','node:main_arbitration']],'mitigatingModules':['wip_provenance','independent_arbitration','damage_attestation'],'recommendation':'Adopt\x20wip_provenance\x20+\x20independent_arbitration\x20modules:\x20Repository\x20stores\x20WIP\x20hashes\x20as\x20tamper-proof\x20delivery\x20evidence;\x20Arbitration\x20(independent\x20Permission)\x20resolves\x20false\x20claims\x20against\x20on-chain\x20proof.'},{'scenario':'supplier_may_not_deliver','conflict':'Supplier\x20incentive:\x20accept\x20sub-order\x20payment\x20terms\x20then\x20under-deliver,\x20leaving\x20the\x20merchant\x20liable\x20to\x20the\x20end\x20customer.\x20Multi-party\x20opacity\x20hides\x20the\x20failure\x20point.','userProtection':{'mechanism':'Supplier\x20visibility\x20—\x20Demand\x20+\x20sub-order\x20flow\x20with\x20multi-tier\x20Allocation;\x20each\x20tier\x20paid\x20only\x20on\x20its\x20own\x20verified\x20delivery','object':'Demand\x20+\x20Allocation\x20(multi-tier)','guard':'per-tier\x20release\x20guard'},'merchantConstraint':{'requiredProof':'sub-delivery\x20proof\x20per\x20Allocation\x20tier'},'evaluationMetric':'supplier_visibility','mitigationSignals':[['module:supplier_collaboration'],['module:multi_tier_allocation']],'mitigatingModules':['supplier_collaboration','multi_tier_allocation'],'recommendation':'Adopt\x20supplier_collaboration\x20module:\x20publish\x20Demand\x20referencing\x20the\x20main\x20Service,\x20split\x20Allocation\x20across\x20tiers\x20so\x20each\x20supplier\x20is\x20paid\x20only\x20for\x20verified\x20sub-delivery.','appliesWhen':a=>Array['isArray'](a['roles']?.['suppliers'])&&a['roles']['suppliers']['length']>0x0}];function evalSignal(a,b,c){const [
|
|
1
|
+
export const GAME_THEORY_CONSTRAINTS=[{'scenario':'merchant_may_deliver_late','conflict':'Merchant\x20incentive:\x20collect\x20payment\x20fast,\x20deliver\x20at\x20own\x20pace\x20(or\x20never).\x20User\x20bears\x20schedule\x20risk\x20with\x20no\x20leverage\x20once\x20funds\x20leave\x20their\x20wallet.','userProtection':{'mechanism':'Milestone\x20escrow\x20—\x20funds\x20locked\x20in\x20Order,\x20released\x20per\x20verified\x20milestone','object':'Order\x20+\x20Allocation','guard':'milestone\x20forward\x20guard\x20verifies\x20deliverable\x20before\x20release'},'merchantConstraint':{'requiredDeposit':!![],'timeoutPenalty':'compensation_fund\x20covers\x20refund\x20for\x20unstarted\x20milestones'},'evaluationMetric':'timeout_protection','mitigationSignals':[['edge:has_order_allocators','node:main_machine'],['module:milestone_escrow']],'mitigatingModules':['milestone_escrow','refund_guarantee'],'recommendation':'Adopt\x20milestone_escrow\x20module:\x20bind\x20order_allocators\x20+\x20Machine\x20so\x20funds\x20release\x20only\x20per\x20verified\x20milestone.\x20Add\x20compensation_fund\x20for\x20late-delivery\x20refunds.'},{'scenario':'merchant_may_abandon','conflict':'Merchant\x20incentive:\x20maximize\x20intake\x20then\x20abandon\x20the\x20service\x20(exit\x20scam).\x20User\x20has\x20no\x20recourse\x20without\x20locked\x20funds\x20or\x20deposit.','userProtection':{'mechanism':'Escrow\x20+\x20compensation\x20fund\x20—\x20user\x20refunds\x20from\x20on-chain\x20fund\x20even\x20if\x20merchant\x20vanishes','object':'Service.compensation_fund\x20+\x20Order','guard':'refund_guard\x20validates\x20claim\x20conditions'},'merchantConstraint':{'requiredDeposit':!![],'requiredArbitration':!![]},'evaluationMetric':'escrow_quality','mitigationSignals':[['edge:has_order_allocators','module:refund_guarantee'],['module:refund_guarantee','node:main_arbitration']],'mitigatingModules':['refund_guarantee','milestone_escrow','reputation_on_chain'],'recommendation':'Adopt\x20refund_guarantee\x20module:\x20compensation_fund_add\x20>\x200\x20with\x20refund_guard.\x20Escrow\x20via\x20order_allocators\x20prevents\x20merchant\x20from\x20touching\x20funds\x20before\x20delivery.'},{'scenario':'customer_may_deny_acceptance','conflict':'Customer\x20incentive:\x20withhold\x20acceptance\x20confirmation\x20to\x20delay\x20payment\x20indefinitely\x20while\x20using\x20the\x20deliverable.\x20Merchant\x27s\x20funds\x20stay\x20locked.','userProtection':{'mechanism':'Accept\x20timeout\x20—\x20after\x20N\x20days\x20without\x20response,\x20order\x20auto-advances\x20(adminUnhold)\x20and\x20merchant\x20gets\x20paid','object':'Machine\x20forward\x20+\x20Progress','guard':'time_guard\x20on\x20accept\x20forward'},'merchantConstraint':{'timeoutPenalty':'user\x20silence\x20past\x20timeout\x20=\x20implicit\x20acceptance'},'evaluationMetric':'timeout_protection','mitigationSignals':[['module:accept_timeout_protection'],['node:guard_accept_timeout_protection'],['machine:expired_terminal']],'mitigatingModules':['accept_timeout_protection'],'recommendation':'Adopt\x20accept_timeout_protection\x20module:\x20time_guard\x20on\x20the\x20accept\x20forward\x20(e.g.\x207\x20days)\x20+\x20PROGRESS_UNHOLD\x20permission\x20so\x20the\x20workflow\x20auto-advances\x20on\x20customer\x20silence.'},{'scenario':'customer_may_false_claim','conflict':'Customer\x20incentive:\x20claim\x20non-delivery\x20or\x20defect\x20to\x20obtain\x20refund\x20while\x20keeping\x20the\x20goods/service.\x20Merchant\x20loses\x20both\x20deliverable\x20and\x20payment.','userProtection':{'mechanism':'WIP\x20provenance\x20—\x20delivery\x20hash\x20committed\x20on-chain\x20before/at\x20delivery;\x20independent\x20arbitration\x20verifies\x20evidence','object':'Repository\x20+\x20Arbitration','guard':'Guard\x20compares\x20proof.signer/proof.time\x20against\x20committed\x20WIP\x20hash'},'merchantConstraint':{'requiredProof':'wip_hash\x20committed\x20to\x20Repository\x20before\x20fund\x20release','requiredArbitration':!![]},'evaluationMetric':'proof_integrity','mitigationSignals':[['node:main_repository','node:main_arbitration'],['module:wip_provenance','node:main_arbitration']],'mitigatingModules':['wip_provenance','independent_arbitration','damage_attestation'],'recommendation':'Adopt\x20wip_provenance\x20+\x20independent_arbitration\x20modules:\x20Repository\x20stores\x20WIP\x20hashes\x20as\x20tamper-proof\x20delivery\x20evidence;\x20Arbitration\x20(independent\x20Permission)\x20resolves\x20false\x20claims\x20against\x20on-chain\x20proof.'},{'scenario':'supplier_may_not_deliver','conflict':'Supplier\x20incentive:\x20accept\x20sub-order\x20payment\x20terms\x20then\x20under-deliver,\x20leaving\x20the\x20merchant\x20liable\x20to\x20the\x20end\x20customer.\x20Multi-party\x20opacity\x20hides\x20the\x20failure\x20point.','userProtection':{'mechanism':'Supplier\x20visibility\x20—\x20Demand\x20+\x20sub-order\x20flow\x20with\x20multi-tier\x20Allocation;\x20each\x20tier\x20paid\x20only\x20on\x20its\x20own\x20verified\x20delivery','object':'Demand\x20+\x20Allocation\x20(multi-tier)','guard':'per-tier\x20release\x20guard'},'merchantConstraint':{'requiredProof':'sub-delivery\x20proof\x20per\x20Allocation\x20tier'},'evaluationMetric':'supplier_visibility','mitigationSignals':[['module:supplier_collaboration'],['module:multi_tier_allocation']],'mitigatingModules':['supplier_collaboration','multi_tier_allocation'],'recommendation':'Adopt\x20supplier_collaboration\x20module:\x20publish\x20Demand\x20referencing\x20the\x20main\x20Service,\x20split\x20Allocation\x20across\x20tiers\x20so\x20each\x20supplier\x20is\x20paid\x20only\x20for\x20verified\x20sub-delivery.','appliesWhen':a=>Array['isArray'](a['roles']?.['suppliers'])&&a['roles']['suppliers']['length']>0x0}];function evalSignal(a,b,c,d){const [e,f]=a['split'](':',0x2);switch(e){case'node':return b['nodes']['some'](g=>g['id']===f||g['id']===f['replace'](/^main_/,''));case'edge':return b['edges']['some'](g=>g['relation']===f);case'module':return b['adoptedModules']['includes'](f);case'type':return b['nodes']['some'](g=>g['type']===f);case'trust':{const g=c['trust'];return g[f]===!![]||typeof g[f]==='string'&&g[f]!=='none';}case'machine':{const h=f['replace'](/_([a-z])/g,(i,j)=>j['toUpperCase']());return d?.[h]===!![];}default:return![];}}export function checkGameTheoryConstraints(a,b,d){const e=[];for(const i of GAME_THEORY_CONSTRAINTS){if(i['appliesWhen']&&!i['appliesWhen'](b))continue;let j=null,k=[],l=-0x1;for(const m of i['mitigationSignals']){const n=m['filter'](p=>evalSignal(p,a,b,d));if(n['length']===m['length']){j=m;break;}const o=n['length']/m['length'];n['length']>0x0&&o>l&&(l=o,k=n);}e['push']({'scenario':i['scenario'],'conflict':i['conflict'],'covered':j!==null,'matchedSignals':j??[],'partialSignals':j?[]:k,'userProtection':i['userProtection']['mechanism']+'\x20('+i['userProtection']['object']+(i['userProtection']['guard']?',\x20guard:\x20'+i['userProtection']['guard']:'')+')','evaluationMetric':i['evaluationMetric'],'recommendation':j?undefined:i['recommendation']});}const f=e['filter'](p=>p['covered']),g=e['filter'](p=>!p['covered']),h=[];return a['edges']['some'](p=>p['relation']==='has_order_allocators')&&h['push']('Milestone\x20escrow:\x20funds\x20locked\x20in\x20Order,\x20released\x20per\x20verified\x20milestone\x20—\x20merchant\x20paid\x20for\x20delivery,\x20user\x20pays\x20for\x20value'),a['adoptedModules']['includes']('accept_timeout_protection')&&h['push']('Accept\x20timeout:\x20customer\x20silence\x20past\x20N\x20days\x20=\x20implicit\x20acceptance\x20—\x20merchant\x20protected\x20from\x20payment\x20stalling'),a['nodes']['some'](p=>p['id']==='repository')&&h['push']('WIP\x20provenance:\x20delivery\x20hash\x20on-chain\x20—\x20false\x20claims\x20verifiable\x20against\x20tamper-proof\x20evidence'),a['nodes']['some'](p=>p['id']==='arbitration')&&h['push']('Micro-arbitration:\x20Guard-weighted\x20voting\x20with\x20independent\x20Permission\x20—\x20low-cost\x20dispute\x20resolution\x20without\x20platform\x20fees'),a['adoptedModules']['includes']('reputation_on_chain')&&h['push']('On-chain\x20reputation:\x20both\x20sides\x27\x20behavior\x20permanently\x20recorded\x20—\x20future\x20transactions\x20price\x20the\x20risk'),{'results':e,'coveredCount':f['length'],'totalCount':e['length'],'exposedScenarios':g['map'](p=>p['scenario']),'wowAlignments':h,'summary':g['length']===0x0?'All\x20'+e['length']+'\x20adversarial\x20scenarios\x20have\x20on-chain\x20mitigations.':g['length']+'/'+e['length']+'\x20adversarial\x20scenarios\x20EXPOSED:\x20'+g['map'](p=>p['scenario'])['join'](',\x20')+'.\x20Apply\x20the\x20recommendations\x20to\x20align\x20incentives.'};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Config,LocalMark,query_objects,objectTypeFromAddress,ObjectType}from'@wowok/wowok';import{resolveAddress as
|
|
1
|
+
import{Config,LocalMark,query_objects,objectTypeFromAddress,ObjectType}from'@wowok/wowok';import{resolveAddress as a329a}from'../../tools/handlers/name-resolution.js';import{fetchMachineNodes,buildMachineGraph}from'./machine-nodes.js';import{batchQueryObjectsByIds,fetchObjectLinkerTx,ringWindowSaturated}from'../../graph/onchain/sdk-batch.js';export async function handleMachinePanorama(a){const b=a['object_address'];if(!b)throw new Error('\x27object_address\x27\x20is\x20required\x20for\x20machine_panorama');let c=a['context_network']??undefined;const d=[];let f=await a329a(b,'machine'),g=null;try{if(!c)c=await Config['Instance']()['network_get']();const x=await query_objects({'objects':[f],'network':c});g=x?.['objects']?.[0x0]??null;if(!g&&a['context_network']){const y=await Config['Instance']()['network_get']();if(y&&y!==c){const z=await query_objects({'objects':[f],'network':y,'no_cache':!![]}),A=z?.['objects']?.[0x0]??null;A&&(g=A,c=y);}}}catch(B){throw new Error('Failed\x20to\x20query\x20Machine\x20'+f+'\x20on\x20'+c+':\x20'+(''+(B instanceof Error?B['message']:String(B))));}if(!g)throw new Error('Machine\x20'+f+'\x20not\x20found\x20on\x20'+c+'.\x20It\x20may\x20not\x20exist\x20on\x20this\x20network.');f=g['object']??f;let h=null,j=[];try{const C=await LocalMark['Instance']()['list']({'address':f});C['length']>0x0&&(h=C[0x0]['name']??null,j=(C[0x0]['tags']??[])['map'](D=>String(D)));}catch{d['push']('head:\x20LocalMark\x20lookup\x20failed');}let k={'nodes':[],'edges':[]};try{const D=await fetchMachineNodes(f,c,!![]);k=buildMachineGraph(D);}catch{d['push']('graph:\x20node\x20fetch\x20failed\x20(non-blocking)');}if(typeof g['permission']==='string'&&g['permission'])try{const E=await query_objects({'objects':[g['permission']],'network':c}),F=E?.['objects']?.[0x0]??null,G=Array['isArray'](F?.['perm_remark'])?F['perm_remark']:Array['isArray'](F?.['remark'])?F['remark']:[],H=G['map'](I=>({'index':typeof I?.['index']==='number'?I['index']:parseInt(I?.['index'],0xa),'remark':typeof I?.['remark']==='string'?I['remark']:''}))['filter'](I=>Number['isFinite'](I['index']));k['permission']={'address':g['permission'],'remarks':H};}catch{d['push']('graph:\x20permission\x20read\x20failed\x20(non-blocking)');}const l=[];let m=0x0,n=null,p=null,q=0x0,s=![],u=[];try{const I=await fetchObjectLinkerTx(f,c,!![]),J=I?.['items']??[];s=ringWindowSaturated(J['length']);const K=new Map();for(const R of J){const S=typeof R?.['who']==='string'?R['who']['toLowerCase']():'';if(!S||S==='0x0')continue;if(!objectTypeFromAddress(S))continue;const T=typeof R?.['time']==='number'?R['time']:null,U=K['get'](S);K['set'](S,U==null?T:T==null?U:Math['max'](U,T));}q=K['size'];const L=new Map();for(const [V,W]of K){const X=String(objectTypeFromAddress(V)),Y=L['get'](X)??[];Y['push']({'address':V,'time':W}),L['set'](X,Y);}for(const Z of L['values']()){Z['sort']((a0,a1)=>(a1['time']??0x0)-(a0['time']??0x0));}const M=['Progress','Allocation','Payment','Guard'];u=[];for(const a0 of M){const a1=L['get'](a0);a1&&a1['length']>0x0&&(u['push']({'label':a0,'items':a1}),L['delete'](a0));}for(const [a2,a3]of L){if(a3['length']>0x0)u['push']({'label':a2,'items':a3});}const N=J['filter'](a4=>objectTypeFromAddress(a4['who'])===ObjectType['Progress']);m=N['length'];for(const a4 of N){if(typeof a4?.['time']==='number'){if(n===null||a4['time']<n)n=a4['time'];if(p===null||a4['time']>p)p=a4['time'];}}const O=N['slice'](-0x3)['reverse'](),P=O['map'](a5=>a5['who']),Q=new Map();if(P['length']>0x0)try{const a5=await batchQueryObjectsByIds(P,c,!![]);for(const a6 of a5){if(a6?.['object'])Q['set'](a6['object'],a6);}}catch{d['push']('progresses:\x20detail\x20fetch\x20failed');}for(const a7 of O){const a8=typeof a7?.['who']==='string'?a7['who']:'';if(!a8)continue;const a9=Q['get'](a8);l['push']({'progress':a8,'name':null,'current':a9?.['current']??null,'task':a9?.['task']??null,'history_count':typeof a9?.['history_count']==='number'?a9['history_count']:null,'current_time':typeof a9?.['current_time']==='number'?a9['current_time']:null,'created_at':typeof a7?.['time']==='number'?a7['time']:null});}}catch{d['push']('progresses:\x20global-table\x20lookup\x20failed\x20(non-blocking)');}const w='Analyze\x20ALL\x20workflow\x20progresses\x20of\x20Machine\x20'+f+'\x20('+c+')\x20one\x20by\x20one,\x20newest\x20first.\x20'+('The\x20progresses\x20live\x20in\x20the\x20machine\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'+m+(s?',\x20saturated':'')+').\x20')+'For\x20each\x20progress\x20call\x20object_panorama\x20with\x20the\x20progress\x27s\x20FULL\x200x\x20address\x20(collect\x20the\x20addresses\x20from\x20the\x20same\x20reverse-index\x20source;\x20work\x20newest-first)\x20and\x20render\x20ONE\x20table\x20row\x20per\x20progress:\x20'+'progress\x20address\x20chip\x20(first\x20column)\x20|\x20current\x20node\x20|\x20task\x20|\x20history\x20events\x20|\x20last\x20activity\x20(local\x20date)\x20|\x20registered\x20(local\x20date).\x20'+'Close\x20with\x20the\x203\x20most\x20valuable\x20patterns\x20across\x20the\x20rows\x20(stuck\x20nodes,\x20age\x20of\x20active\x20progresses,\x20throughput).\x20Progresses\x20only\x20—\x20do\x20not\x20re-analyze\x20the\x20Machine\x20graph\x20itself.';return{'action':'machine_panorama','machineAddress':f,'network':String(c),'head':{'name':h,'tags':j,'description':typeof g['description']==='string'?g['description']:null,'published':typeof g['bPublished']==='boolean'?g['bPublished']:null,'paused':typeof g['bPaused']==='boolean'?g['bPaused']:null},'fields':{'permission':g['permission']??null,'um':g['um']??null,'node_count':k['nodes']['length']>0x0?k['nodes']['length']:typeof g['node_count']==='number'?g['node_count']+0x1:null,'onchain_table_node_count':typeof g['node_count']==='number'?g['node_count']:k['nodes']['length']>0x0?k['nodes']['length']-0x1:null,'consensus_repositories':Array['isArray'](g['consensus_repositories'])?g['consensus_repositories']:[]},'graph':k,'progresses':{'count':m,'window_saturated':s,'preview_truncated':m>l['length'],'stats':{'first_created_ms':n,'last_created_ms':p},...m>l['length']?{'drilldown':{'total_count':m,'analyzed_count':l['length'],'prompt':w}}:{},'items':l},'related':{'count':q,'window_saturated':s,'groups':u},'data_gaps':d};}
|
|
@@ -12,6 +12,12 @@ export interface GuideState {
|
|
|
12
12
|
guard_resolutions?: Record<string, unknown>;
|
|
13
13
|
review_mode?: "review" | "review_reward" | "none";
|
|
14
14
|
reward_funding?: string;
|
|
15
|
+
after_sales_mode?: "return" | "exchange" | "warranty" | "none";
|
|
16
|
+
acceptance_mode?: "milestone" | "contest" | "bounty" | "agent" | "none";
|
|
17
|
+
installment_mode?: "deposit_balance" | "milestone_n" | "none";
|
|
18
|
+
affiliate_mode?: "commission" | "none";
|
|
19
|
+
crowdfunding_mode?: "threshold" | "flexible" | "none";
|
|
20
|
+
sales?: unknown[];
|
|
15
21
|
}
|
|
16
22
|
export interface MerchantGuideInput {
|
|
17
23
|
intent?: string;
|
|
@@ -26,6 +32,12 @@ export interface MerchantGuideInput {
|
|
|
26
32
|
guard_resolutions?: Record<string, unknown>;
|
|
27
33
|
review_mode?: string;
|
|
28
34
|
reward_funding?: string;
|
|
35
|
+
after_sales_mode?: string;
|
|
36
|
+
acceptance_mode?: string;
|
|
37
|
+
installment_mode?: string;
|
|
38
|
+
affiliate_mode?: string;
|
|
39
|
+
crowdfunding_mode?: string;
|
|
40
|
+
sales?: unknown[];
|
|
29
41
|
};
|
|
30
42
|
guide_confirm?: {
|
|
31
43
|
industry?: string;
|
|
@@ -37,6 +49,12 @@ export interface MerchantGuideInput {
|
|
|
37
49
|
guard_resolutions?: Record<string, unknown>;
|
|
38
50
|
review_mode?: string;
|
|
39
51
|
reward_funding?: string;
|
|
52
|
+
after_sales_mode?: string;
|
|
53
|
+
acceptance_mode?: string;
|
|
54
|
+
installment_mode?: string;
|
|
55
|
+
affiliate_mode?: string;
|
|
56
|
+
crowdfunding_mode?: string;
|
|
57
|
+
sales?: unknown[];
|
|
40
58
|
};
|
|
41
59
|
template_override?: IndustryTemplate;
|
|
42
60
|
name_base?: string;
|
|
@@ -120,7 +138,6 @@ export declare function handleMerchantGuide(v: MerchantGuideInput): Promise<{
|
|
|
120
138
|
};
|
|
121
139
|
evaluation_preview: {
|
|
122
140
|
estimatedRiskScore: number;
|
|
123
|
-
estimatedTrustScore: number;
|
|
124
141
|
estimatedCompletenessScore: number;
|
|
125
142
|
keyRisks: string[];
|
|
126
143
|
strengths: string[];
|
|
@@ -145,6 +162,7 @@ export declare function handleMerchantGuide(v: MerchantGuideInput): Promise<{
|
|
|
145
162
|
missing: string[] | undefined;
|
|
146
163
|
reason: string | undefined;
|
|
147
164
|
estimated_score_boost: number;
|
|
165
|
+
evidence_matched: boolean | undefined;
|
|
148
166
|
}[];
|
|
149
167
|
blocking_issues: ({
|
|
150
168
|
module: BusinessModuleId;
|
|
@@ -213,6 +231,12 @@ export declare function handleMerchantGuide(v: MerchantGuideInput): Promise<{
|
|
|
213
231
|
guard_resolutions?: Record<string, unknown>;
|
|
214
232
|
review_mode?: "review" | "review_reward" | "none";
|
|
215
233
|
reward_funding?: string;
|
|
234
|
+
after_sales_mode?: "return" | "exchange" | "warranty" | "none";
|
|
235
|
+
acceptance_mode?: "milestone" | "contest" | "bounty" | "agent" | "none";
|
|
236
|
+
installment_mode?: "deposit_balance" | "milestone_n" | "none";
|
|
237
|
+
affiliate_mode?: "commission" | "none";
|
|
238
|
+
crowdfunding_mode?: "threshold" | "flexible" | "none";
|
|
239
|
+
sales?: unknown[];
|
|
216
240
|
};
|
|
217
241
|
intent: {
|
|
218
242
|
intent_type: import("./intent-analyzer.js").BusinessIntentType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{analyzeIntent}from'./intent-analyzer.js';import{compileTemplate}from'../../composition/compile.js';import{reflux,auditScore}from'../../composition/reflux.js';import{planBlueprint}from'../../composition/blueprint-view.js';import{getGuardDesignPattern}from'../../knowledge/guard-design-patterns.js';import{GUARD_TEMPLATES,getTemplatesByScene}from'../../knowledge/guard-templates.js';import{checkGameTheoryConstraints}from'./game-theory.js';import{assessWorkflowDesign}from'./workflow-design-assessment.js';import{CORE_BUSINESS_MODULES,getBusinessModule,recommendModules,checkModuleConstraints}from'../../extensions/business-modules.js';import{recipientDesignGuidance}from'../../knowledge/recipient-constraint.js';import{getTemplate,getTemplatesByIndustry}from'../../knowledge/template-loader.js';function derivePlanSatisfiedConstraints(a,b){const c=new Set(),d=i=>a['edges']['some'](j=>j['relation']===i),e=i=>a['nodes']['some'](j=>j['id']===i),f=i=>a['nodes']['some'](j=>j['type']===i),g=i=>a['adoptedModules']['includes'](i);if(d('has_order_allocators'))c['add']('order_allocators_bound');if(d('uses_machine'))c['add']('machine_bound_before_publish');if(d('has_arbitration'))c['add']('arbitration_bound_to_service');if(e('machine'))c['add']('machine_published');if(e('repository'))c['add']('repository_published');if(e('service'))c['add']('service_published');e('permission_arb')&&e('permission')&&c['add']('arbitration_permission_independent');g('independent_arbitration')&&a['nodes']['some'](i=>i['id']['includes']('guard')&&i['id']['includes']('arbitration'))&&c['add']('voting_guard_configured');g('accept_timeout_protection')&&(c['add']('time_guard_configured'),c['add']('adminUnhold_permission'));g('milestone_escrow')&&f('guard')&&c['add']('milestone_forward_guarded');const h=d('has_order_allocators');if(h&&b['payment']['allocation']&&b['payment']['allocation']['length']>0x0){c['add']('allocators_configured');const i=b['payment']['allocation']['reduce']((k,l)=>k+l['percentage'],0x0);if(Math['abs'](i-0x64)<0.001)c['add']('sharing_sum_100');const j=b['payment']['allocation']['find'](k=>k['recipient']==='platform');if(!j||j['percentage']===0x0)c['add']('platform_fee_zero');g('supplier_collaboration')&&(c['add']('allocation_sharing_configured'),c['add']('demand_configured'));}g('wip_provenance')&&e('repository')&&c['add']('wip_hash_before_delivery');g('subscription_with_proof')&&e('repository')&&(c['add']('delivery_guard_per_cycle'),c['add']('repository_updated'));g('damage_attestation')&&(c['add']('pre_rental_hash'),c['add']('post_rental_hash'));g('refund_guarantee')&&(c['add']('compensation_fund_positive'),c['add']('refund_guard_configured'));if(g('praise_incentive')){const k=a['plan']['steps']['some'](m=>m['op']==='create'&&m['object']==='reward'),l=a['plan']['steps']['some'](m=>m['op']==='configure'&&m['method']==='coin_add');k&&l&&(c['add']('reward_pool_funded'),c['add']('reward_claim_replay_armed'));}return g('discount_lifecycle')&&(c['add']('discount_budget_planned'),c['add']('discount_burn_disclosed')),c;}function deriveDeployTimeChecks(a){const b=[];return a['nodes']['some'](c=>c['id']==='machine')&&b['push']('Machine\x20published\x20AND\x20bound\x20to\x20Service\x20BEFORE\x20Service.publish\x20(machine\x20is\x20immutable\x20after\x20publish)'),a['edges']['some'](c=>c['relation']==='has_order_allocators')&&(b['push']('Service.order_allocators\x20bound\x20(verify\x20via\x20query_objects\x20after\x20publish\x20—\x20order_allocators\x20is\x20FROZEN\x20at\x20publish)'),b['push']('Settlement\x20is\x20NOT\x20triggered\x20by\x20reaching\x20a\x20Machine\x20node\x20alone\x20—\x20an\x20explicit\x20alloc_by_guard\x20call\x20(keeper\x20or\x20merchant)\x20fires\x20the\x20settlement\x20Allocator\x20once\x20its\x20Guard\x20passes.\x20Declare\x20the\x20node->allocator\x20trigger\x20(which\x20terminal\x20node\x20unlocks\x20settlement)\x20and\x20schedule\x20the\x20keeper\x20step;\x20otherwise\x20orders\x20stall\x20at\x20the\x20settle\x20node\x20with\x20allocation_state=pending')),(a['adoptedModules']['includes']('refund_guarantee')||a['nodes']['some'](c=>c['id']==='arbitration'))&&b['push']('compensation_fund\x20MUST\x20be\x20able\x20to\x20cover\x20payouts:\x20a\x20claim\x20against\x20a\x20drained\x20fund\x20aborts\x20(service.move\x20E_COMPENSATION_NOT_MATCH).\x20Size\x20the\x20fund\x20>=\x203x\x20a\x20TYPICAL\x20single\x20order\x20(3x\x20IS\x20the\x20chain\x27s\x20hard\x20award\x20ceiling,\x20MAX_INDEMNITY_MULTIPLE)\x20—\x20per-order\x20coverage\x20is\x20enforced\x20at\x20BUY\x20time\x20(each\x20order\x20is\x20checked\x20against\x203x\x20ITS\x20OWN\x20amount,\x20not\x203x\x20the\x20highest\x20SKU),\x20so\x20publish\x20no\x20longer\x20blocks\x20on\x20coverage;\x20verify\x20the\x20on-chain\x20balance\x20before\x20going\x20live'),a['nodes']['some'](c=>c['id']==='arbitration')&&(b['push']('Arbitration.permission\x20!=\x20Service.permission\x20on-chain\x20(E_ARBITRATION_PERMISSION_CONFLICT=33)'),b['push']('A\x20freshly\x20created\x20Arbitration\x20defaults\x20to\x20PAUSED\x20—\x20unpause\x20it\x20(arbitration\x20activation)\x20before\x20the\x20first\x20case\x20can\x20be\x20filed,\x20otherwise\x20dispute\x20filing\x20aborts')),a['nodes']['some'](c=>c['id']==='repository')&&b['push']('Repository\x20published\x20and\x20Guard\x20write\x20validation\x20configured'),b['push']('After\x20materialization,\x20confirm\x20the\x20on-chain\x20state\x20matches\x20this\x20plan\x20(query_toolkit\x20query_type=\x27service_panorama\x27)'),b;}function derivePostDeploySteps(a){const b=[];return(a['adoptedModules']['includes']('refund_guarantee')||a['nodes']['some'](c=>c['id']==='arbitration'))&&b['push']({'order':b['length']+0x1,'id':'compensation_fund_topup','title':'Top\x20up\x20the\x20compensation\x20fund','when':'After\x20the\x20Service\x20object\x20is\x20created,\x20BEFORE\x20the\x20service\x20goes\x20live\x20(before\x20the\x20first\x20order)','action':'Call\x20compensation_fund_add\x20sized\x20>=\x203x\x20a\x20TYPICAL\x20single\x20order\x20(3x\x20=\x20the\x20chain\x27s\x20hard\x20award\x20ceiling,\x20MAX_INDEMNITY_MULTIPLE;\x20above\x203x\x20only\x20buys\x20headroom\x20for\x20concurrent\x20claims).\x20Per-order\x20coverage\x20is\x20enforced\x20at\x20BUY\x20time\x20—\x20each\x20incoming\x20order\x20is\x20checked\x20against\x203x\x20ITS\x20OWN\x20amount\x20and\x20under-covered\x20orders\x20cannot\x20be\x20created\x20—\x20then\x20verify\x20the\x20on-chain\x20fund\x20balance\x20via\x20query_objects','tool_hint':'onchain_operations\x20(service.compensation_fund_add)','failure_if_skipped':'a\x20compensation\x20claim\x20against\x20an\x20empty\x20fund\x20aborts\x20(E_COMPENSATION_NOT_MATCH,\x20testnet\x20lesson\x20R-4)'}),a['nodes']['some'](c=>c['id']==='arbitration')&&b['push']({'order':b['length']+0x1,'id':'arbitration_unpause','title':'Activate\x20the\x20Arbitration\x20(unpause)','when':'Immediately\x20after\x20the\x20Arbitration\x20object\x20is\x20created,\x20before\x20the\x20first\x20dispute\x20is\x20filed','action':'Unpause/activate\x20the\x20Arbitration\x20so\x20dispute\x20filing\x20is\x20accepted;\x20keep\x20its\x20Permission\x20distinct\x20from\x20the\x20Service\x20Permission\x20(E_ARBITRATION_PERMISSION_CONFLICT=33)','tool_hint':'onchain_operations\x20(arbitration\x20activation)','failure_if_skipped':'a\x20freshly\x20created\x20Arbitration\x20defaults\x20to\x20PAUSED\x20—\x20dispute\x20filing\x20aborts\x20(testnet\x20lesson\x20R-5)'}),a['edges']['some'](c=>c['relation']==='has_order_allocators')&&b['push']({'order':b['length']+0x1,'id':'settlement_alloc_by_guard','title':'Fire\x20settlement\x20via\x20alloc_by_guard\x20(keeper/merchant\x20step)','when':'Recurring\x20—\x20after\x20EACH\x20order\x20reaches\x20its\x20settlement\x20terminal\x20node\x20(declare\x20which\x20node\x20unlocks\x20settlement)','action':'Call\x20alloc_by_guard\x20on\x20the\x20order\x27s\x20allocation\x20with\x20the\x20settlement\x20Guard;\x20reaching\x20the\x20Machine\x20node\x20alone\x20does\x20NOT\x20settle\x20(allocation_state\x20stays\x20pending)','tool_hint':'onchain_operations\x20(allocation.alloc_by_guard);\x20schedule\x20as\x20a\x20keeper\x20step','failure_if_skipped':'orders\x20stall\x20at\x20the\x20settle\x20node\x20with\x20funds\x20locked\x20in\x20escrow\x20(testnet\x20lesson\x20R-2)'}),b['push']({'order':b['length']+0x1,'id':'verify_service_panorama','title':'Verify\x20the\x20on-chain\x20state\x20matches\x20the\x20plan','when':'After\x20all\x20creation\x20steps\x20and\x20the\x20steps\x20above\x20are\x20done','action':'Run\x20the\x20service\x20panorama\x20query\x20and\x20diff\x20it\x20against\x20this\x20plan\x27s\x20blueprint/creation_plan','tool_hint':'query_toolkit\x20query_type=\x27service_panorama\x27','failure_if_skipped':'plan/chain\x20drift\x20(missing\x20binding,\x20wrong\x20allocator\x20order)\x20stays\x20undetected\x20until\x20an\x20order\x20hits\x20it'}),b;}function buildCreationPlan(a){const b=[],c=new Map(a['nodes']['map'](k=>[k['id'],k])),f=new Map();for(const k of a['nodes'])f['set'](k['id'],new Set());for(const l of a['edges']){if(!f['has'](l['from'])||!c['has'](l['to']))continue;const m=l['relation']==='has_guard'?l['to']:l['from'],o=l['relation']==='has_guard'?l['from']:l['to'];if(m===o||!f['has'](m))continue;f['get'](m)['add'](o);}for(const p of a['nodes']){for(const q of Object['values'](p['config'])){q['type']==='address_ref'&&q['targetId']!==p['id']&&f['has'](q['targetId'])&&f['get'](p['id'])['add'](q['targetId']);}}const g=a['nodes']['filter'](r=>r['type']==='service')['map'](r=>r['id']);if(g['length']>0x0)for(const r of a['nodes']){if(r['type']!=='guard')continue;const s=f['get'](r['id']);if(s===undefined)continue;for(const t of g)s['add'](t);}const h=new Map([...f]['map'](([u,v])=>[u,[...v]])),i=[],j=new Map(f);while(j['size']>0x0){const u=[...j['entries']()]['filter'](([,v])=>v['size']===0x0)['map'](([v])=>v);if(u['length']===0x0){i['push'](...j['keys']());break;}u['sort']();for(const v of u){i['push'](v),j['delete'](v);for(const w of j['values']())w['delete'](v);}}return i['forEach']((x,y)=>{const z=c['get'](x),A=z['config']['name'],B=A?.['type']==='string'?A['value']:x,C=B['includes']('/')?B['replaceAll']('/','__'):B;b['push']({'order':y+0x1,'node_id':x,'object_type':z['type'],'suggested_name':C,'depends_on':h['get'](x)??[],'operation_hint':'Create\x20'+z['type']+'\x20via\x20onchain_operations,\x20then\x20configure.\x20Purpose:\x20'+z['purpose']});}),b;}function resolveTemplate(a){if(!a)return undefined;const b=getTemplate(a);if(b)return b;const c=getTemplatesByIndustry(a);if(c['length']>0x0)return c[0x0];return undefined;}export async function handleMerchantGuide(a){const b=a['guide_state']??{'intent_text':''},c=a['guide_confirm']??{},d={'intent_text':(a['intent']??b['intent_text']??'')['trim'](),'confirmed_industry':c['industry']??b['confirmed_industry'],'currency':c['currency']??b['currency'],'deliverables':c['deliverables']??b['deliverables'],'payment_override':c['payment']??b['payment_override'],'trust_override':c['trust']??b['trust_override'],'adopted_module_ids':c['adopted_module_ids']??b['adopted_module_ids'],'guard_resolutions':{...b['guard_resolutions']??{},...c['guard_resolutions']??{}},'review_mode':c['review_mode']??b['review_mode'],'reward_funding':c['reward_funding']??b['reward_funding']};for(const L of Object['keys'](d)){if(d[L]===undefined)delete d[L];}if(d['guard_resolutions']&&Object['keys'](d['guard_resolutions'])['length']===0x0)delete d['guard_resolutions'];if(!d['intent_text'])throw new Error('merchant_guide\x20requires\x20\x27intent\x27\x20(business\x20description)\x20for\x20Step\x201.\x20'+'Example:\x20intent=\x27I\x20want\x20to\x20offer\x20online\x20design\x20service\x20with\x20milestone\x20payments\x27.\x20'+'Pass\x20the\x20returned\x20guide_state\x20back\x20UNCHANGED\x20on\x20subsequent\x20calls,\x20plus\x20guide_confirm\x20for\x20merchant\x20decisions.');const e=await analyzeIntent(d['intent_text'],{'preferredIndustry':d['confirmed_industry'],'currency':d['currency']});if(!d['confirmed_industry'])return{'action':'merchant_guide','current_step':0x2,'step_name':'Industry\x20Matching','guide_state':d,'intent_draft':e['intent'],'industry_options':{'inferred':e['inferredIndustry'],'confidence':e['industryConfidence'],'similar':e['similarIndustries']},'warnings':e['warnings'],'next_action':'Confirm\x20the\x20industry\x20by\x20calling\x20merchant_guide\x20again\x20with\x20guide_state\x20(UNCHANGED)\x20'+('plus\x20guide_confirm={\x20industry:\x20\x27<one\x20of:\x20'+e['similarIndustries']['join'](',\x20')+'\x20—\x20or\x20any\x20other\x20industry\x20id>\x27\x20}')};const f={...e['intent'],'industry':d['confirmed_industry'],'deliverables':d['deliverables']??e['intent']['deliverables'],'payment':{...e['intent']['payment'],...d['payment_override']??{}},'trust':{...e['intent']['trust'],...d['trust_override']??{}}},h=d['adopted_module_ids']?d['adopted_module_ids']['map'](M=>getBusinessModule(M))['filter'](M=>!!M):recommendModules(d['confirmed_industry'],d['intent_text'],{'maxModules':0x5}),i=a['template_override']??resolveTemplate(d['confirmed_industry']);if(!i)throw new Error('No\x20compilable\x20template\x20found\x20for\x20industry\x20\x27'+d['confirmed_industry']+'\x27.\x20'+'Register\x20a\x20template\x20via\x20industry_pack_operation\x20or\x20pass\x20template_override\x20explicitly.');const j={'currency':d['currency']??f['payment']['currency'],...d['payment_override']?{'payment':d['payment_override']}:{},...d['trust_override']?{'trust':d['trust_override']}:{},...d['deliverables']?{'deliverables':d['deliverables']}:{},...d['adopted_module_ids']?{'adopted_module_ids':d['adopted_module_ids']}:{},...d['review_mode']?{'review_mode':d['review_mode']}:{},...d['reward_funding']!==undefined?{'reward_funding':d['reward_funding']}:{}},l={};for(const M of h){for(const N of M['templateRefs']){if(N['object_type']!=='guard')continue;const O=i['guards']['filter'](P=>P['template_id']===N['template_id']);if(O['length']===0x0)continue;for(const P of O){l[P['key']??N['template_id']+'#'+i['guards']['indexOf'](P)]={'kind':'template','template_id':N['template_id']};}}}Object['assign'](l,d['guard_resolutions']??{});const m=compileTemplate(i,j,{'nameBase':a['name_base']??i['id'],'intent':d['intent_text'],'guardResolutions':l}),n=reflux(m['plan']),o=n['plan'],p=n['audit'],q=auditScore(p),r=planBlueprint(o,f,h['map'](Q=>Q['id'])),s=m['blockers']['map'](Q=>({'module':'template','missing_constraints':[Q['code']],'fix':Q['detail']})),t=derivePlanSatisfiedConstraints(r,f),u=h['map'](Q=>checkModuleConstraints(Q,t)),w=deriveDeployTimeChecks(r),x=derivePostDeploySteps(r),y=r['edges']['some'](Q=>Q['relation']==='has_order_allocators')?recipientDesignGuidance()['map'](Q=>({'id':Q['id'],'move_recipient':Q['move_recipient'],'semantics':Q['semantics'],'required_constraints':Q['required_constraints'],'finding_if_unmet':Q['finding_if_unmet']})):undefined,z=[...u['filter'](Q=>!Q['adopted']),...s],A=p['findings']['filter'](Q=>Q['level']==='critical'||Q['level']==='high')['map'](Q=>({'module':'audit','missing_constraints':[Q['rule_id']],'fix':Q['title']+'\x20—\x20'+(Q['mitigation']??Q['description'])})),B=[{'re':/allocat|refund|recover|claimed_by|settle|escrow/i,'scene':'service_order_allocators_guard'},{'re':/\bbuy\b|purchase|allowlist|blocklist/i,'scene':'service_buy_guard'},{'re':/reward/i,'scene':'reward_claim'},{'re':/write_guard|repository_write/i,'scene':'repository_write_guard'},{'re':/arbitrat|ruling|voting/i,'scene':'arbitration_usage_guard'},{'re':/forward|node|witness|deliver|review|cancel|expire|submission|progress/i,'scene':'machine_forward_guard'}],C=[{'re':/claimed_by\s*some\s*==\s*true/i,'tpl':'tpl_allocator_node_gate_recover'},{'re':/claimed_by\s*some\s*==\s*false|claimed_by\s*(?:is\s+)?none|\brefund|\bcancel/i,'tpl':'tpl_allocator_node_gate_refund'},{'re':/claimed_by\s*some|\brecover|\baward/i,'tpl':'tpl_allocator_node_gate_recover'}],D=[{'host':'machine','re':/pattern\.time_lock_progress/i,'tpl':'tpl_time_lock_progress'},{'host':'machine','re':/pattern\.time_window_upper_bound/i,'tpl':'tpl_time_window_upper'},{'host':'reward','re':/pattern\./i,'tpl':'tpl_reward_one_time_claim'}],E=(Q,R,S,T,U)=>{let V;const W=/tpl_[a-z0-9_]+/['exec'](Q+'\x20'+R);W!==null&&(V=GUARD_TEMPLATES['find'](a1=>a1['id']===W[0x0])?.['scene_id']);V===undefined&&T!=='reward'&&/\ballocators?\b|claimed_by|guard_identifier|order_allocators/i['test'](R)&&(V='service_order_allocators_guard');if(V===undefined){if(T==='machine'||T==='machine_forward')V='machine_forward_guard';else{if(T==='reward')V='reward_claim';else{if(T==='repository')V='repository_write_guard';else{if(T==='arbitration')V='arbitration_usage_guard';else{const a1=B['find'](a2=>a2['re']['test'](Q+'\x20'+R));V=a1?.['scene'];}}}}}if(V===undefined)return undefined;const X=getTemplatesByScene(V);let Y=S!==undefined&&X['some'](a2=>a2['applicable_industries']['includes'](S))?X['filter'](a2=>a2['applicable_industries']['includes'](S)):X;if(/\btime[_-]?lock|\bwindow|\btimeout|\bduration|\bdeadline|\bdays?\b|\bclock|\bdelay/i['test'](Q+'\x20'+R)){const a2=Y['filter'](a3=>JSON['stringify'](a3['example_root']??{})['toLowerCase']()['includes']('clock'));if(a2['length']===0x0)return undefined;Y=a2;}if(U['length']>0x0){const a3=Y['filter'](a4=>{const a5=[];if(a4['example_root']!==undefined){const a6=JSON['stringify'](a4['example_root']);for(const a7 of a6['matchAll'](/"query":"([^"]+)"/g))a5['push'](a7[0x1]);if(a6['includes']('\x22type\x22:\x22query_progress_history_time\x22'))a5['push']('progress.history.time');if(a6['includes']('\x22type\x22:\x22query_progress_history_find\x22'))a5['push']('progress.history.find');}return a5['some'](a8=>U['some'](a9=>a8===a9||a8['startsWith'](a9)||a9['startsWith'](a8)));});if(a3['length']===0x0)return undefined;Y=a3;}const Z=T==='machine_forward'?'machine':T,a0=D['find'](a4=>a4['host']===Z&&a4['re']['test'](Q+'\x20'+R)&&Y['some'](a5=>a5['id']===a4['tpl']));a0!==undefined&&(Y=[...Y]['sort']((a4,a5)=>(a4['id']===a0['tpl']?0x0:0x1)-(a5['id']===a0['tpl']?0x0:0x1)));if(V==='service_order_allocators_guard'){const a4=C['find'](a5=>a5['re']['test'](Q+'\x20'+R));a4!==undefined&&(Y=[...Y]['sort']((a5,a6)=>(a5['id']===a4['tpl']?0x0:0x1)-(a6['id']===a4['tpl']?0x0:0x1)));}return Y['slice'](0x0,0x3)['map'](a5=>({'template_id':a5['id'],'name':a5['name'],'parameters':a5['parameters']['map'](a6=>({'name':a6['name'],'required':a6['required'],...a6['default']!==undefined?{'default':a6['default']}:{},'description':a6['description']}))}));},F=m['unresolved']['map'](Q=>{const R=getGuardDesignPattern(Q['template_id']),S=E(Q['template_id'],Q['purpose'],i?.['industry'],Q['host'],R?.['key_queries']??[]),T=new Set((i?.['machine_shape']??[])['flatMap'](Y=>(Y['from']??[])['map'](Z=>typeof Z==='string'?undefined:Z['guard_key'])['filter'](Z=>typeof Z==='string'))),U=new Map((i?.['allocator']['rows']??[])['filter'](Y=>typeof Y['guard_key']==='string')['map'](Y=>[Y['guard_key'],Y])),V=U['get'](Q['key']),W=V!==undefined&&!T['has'](Q['key']),X=!T['has'](Q['key'])&&!U['has'](Q['key'])&&Q['policy']===undefined&&Q['host']!=='reward'&&!(Q['host']==='service'&&Q['key']==='buy');return{'key':Q['key'],'template_id':Q['template_id'],'host':Q['host'],'purpose':Q['purpose'],...R?.['logic_summary']?{'logic_summary':R['logic_summary']}:{},...R?.['key_queries']?.['length']?{'key_queries':R['key_queries']}:{},...S!==undefined&&S['length']>0x0?{'suggested_templates':S}:{},'how_to_resolve':'guide_confirm.guard_resolutions[\x27'+Q['key']+'\x27]\x20=\x20{\x20kind:\x20\x27inline\x27,\x20table,\x20root\x20}\x20(a\x20resolved\x20Guard),\x20'+'or\x20{\x20kind:\x20\x27template\x27,\x20template_id:\x20\x27tpl_*\x27,\x20params\x20}\x20when\x20a\x20guard\x20template\x20matches\x20this\x20design'+(S!==undefined&&S['length']>0x0?'\x20(suggested_templates\x20below\x20list\x20the\x20matching\x20executable\x20forms\x20and\x20their\x20parameters)':'.')+(Q['host']==='machine'&&!W?'\x20MACHINE-HOST\x20REQUIREMENT:\x20the\x20inline\x20table\x20MUST\x20declare\x20the\x20protocol\x20task-binding\x20slot\x20'+'{\x20identifier:\x20254,\x20b_submission:\x20true,\x20value_type:\x20\x22Address\x22\x20}\x20—\x20the\x20forward\x27s\x20passport\x20only\x20emits\x20'+'DECLARED\x20slots,\x20so\x20a\x20machine-forward\x20guard\x20without\x20this\x20row\x20aborts\x20EVERY\x20order-bound\x20forward\x20'+'it\x20gates\x20(code\x2011)\x20and\x20the\x20pre-publish\x20gate\x20blocks\x20the\x20Machine\x20publish.':'')+(W?'\x20ALLOCATOR-RAIL\x20NOTE:\x20this\x20design\x20gates\x20an\x20allocator\x20rail\x20(not\x20a\x20machine\x20forward)\x20—\x20do\x20NOT\x20add\x20the\x20'+'254\x20task-binding\x20slot:\x20a\x20254\x20declaration\x20arms\x20once-per-order\x20replay\x20protection\x20at\x20alloc\x20time\x20'+'(allocation\x20ONCE_FOR_OBJECT)\x20and\x20permanently\x20blocks\x20multi-fire\x20rails\x20(a\x20second\x20release\x20aborts\x20'+'E_ONCE_TRIGGERED).\x20The\x20kernel\x20injects\x20254\x20ONLY\x20for\x20GuardIdentifier(254)-recipient\x20rails.'+(V['recipient']==='guard_identifier'&&V['recipient_key']!=='254'?'\x20This\x20rail\x27s\x20recipient\x20is\x20GuardIdentifier('+(V['recipient_key']??'0')+')\x20—\x20the\x20inline\x20table\x20MUST\x20'+('declare\x20slot\x20'+(V['recipient_key']??'0')+'\x20as\x20an\x20Address\x20submission\x20instead\x20(N-K21:\x20the\x20passport\x20')+'submits\x20the\x20ORDER\x20address\x20into\x20it;\x20an\x20undeclared\x20slot\x20makes\x20the\x20rail\x20unexecutable).':''):'')+(X?'\x20ADVISORY\x20DESIGN\x20(run75747\x20F-38):\x20nothing\x20in\x20this\x20archetype\x20binds\x20this\x20key\x20—\x20no\x20machine\x20edge,\x20allocator\x20'+'rail,\x20repository\x20policy,\x20or\x20service\x20mount.\x20If\x20this\x20design\x20does\x20not\x20apply\x20to\x20your\x20shop\x20you\x20may\x20resolve\x20'+'it\x20with\x20{\x20kind:\x20\x27omit\x27\x20}\x20instead\x20of\x20building\x20a\x20Guard\x20no\x20one\x20consumes:\x20the\x20design\x20leaves\x20'+'pending_guard_designs,\x20no\x20Guard\x20object\x20is\x20created,\x20and\x20the\x20decision\x20is\x20recorded\x20in\x20the\x20build\x27s\x20'+'warnings.\x20An\x20omit\x20of\x20a\x20BOUND\x20design\x20is\x20refused\x20(GUARD_OMIT_UNSUPPORTED).':'')};}),G=z['length']>0x0||p['blocking'],H=checkGameTheoryConstraints(r,f),I=assessWorkflowDesign(r),J=buildCreationPlan(r),K=i?{'name':i['id'],'display_name':i['variant']+'\x20archetype\x20('+i['industry']+')','source':a['template_override']?'custom':'builtin','risk_appetite':'medium','key_risk':i['key_risk'],'machine_shape':i['machine_shape']['map'](Q=>({'name':Q['name'],'role':Q['role'],...Q['operator']?{'operator':Q['operator']}:{},...Q['semantic_role']?{'semantic_role':Q['semantic_role']}:{}})),'guards':i['guards']['map'](Q=>({'template_id':Q['template_id'],'host':Q['host'],'purpose':Q['purpose']})),'allocator':i['allocator'],'risk_constraints':{},'build_notes':i['build_notes']??[],...i['time_anchors']?{'time_anchors':i['time_anchors']}:{}}:undefined;return{'action':'merchant_guide','current_step':G?0x9:0xa,'step_name':G?'Harness\x20Check\x20(issues\x20found)':'Submission\x20Plan\x20Ready','guide_state':{...d,'adopted_module_ids':h['map'](Q=>Q['id'])},'intent':{'intent_type':f['intent'],'industry':f['industry'],'roles':f['roles'],'deliverables':f['deliverables'],'payment':f['payment'],'trust':f['trust']},'adopted_modules':h['map'](Q=>({'id':Q['id'],'name':Q['name'],'description':Q['description'],'requires_keeper':Q['requiresKeeper'],'keeper_hint':Q['keeperHint'],'user_protections':Q['userProtections'],'merchant_obligations':Q['merchantObligations']})),'mode_prior':K,...K?.['time_anchors']?{'time_anchor_instructions':Object['entries'](K['time_anchors'])['map'](([Q,R])=>{const S=R['startsWith']('order.time')?'\x20(order-creation\x20time\x20—\x20PRE-checkout\x20branches\x20only;\x20a\x20post-checkout\x20window\x20anchored\x20here\x20is\x20unreachable)':R['startsWith']('progress.current_time')?'\x20(entry\x20time\x20of\x20the\x20window\x27s\x20source\x20node\x20—\x20witness-derived\x20via\x20OrderProgress,\x20one\x20Guard\x20serves\x20every\x20order)':R['startsWith']('absolute_date')?'\x20(per-order\x20instance\x20Guard\x20—\x20the\x20absolute\x20date\x20differs\x20per\x20booking)':'';return'Time\x20windows\x20for\x20\x27'+Q+'\x27\x20anchor\x20to\x20'+R+S;})}:{},'blueprint':{'nodes':r['nodes']['map'](Q=>({'id':Q['id'],'type':Q['type'],'purpose':Q['purpose']})),'edges':r['edges']['map'](Q=>({'from':Q['from'],'to':Q['to'],'relation':Q['relation'],'required':Q['required']}))},'evaluation_preview':{'estimatedRiskScore':q,'estimatedTrustScore':Math['max'](0x0,0x64-q),'estimatedCompletenessScore':Math['min'](0x64,0x1e+h['length']*0x8),'keyRisks':p['findings']['filter'](Q=>Q['level']==='critical'||Q['level']==='high')['map'](Q=>Q['title']),'strengths':p['findings']['filter'](Q=>Q['level']==='info')['map'](Q=>Q['title']),'moduleBoosts':{}},'graph_validation':{'valid':p['issues']['length']===0x0,'hard_violations':p['issues']['map'](Q=>({'id':Q['code'],'description':Q['detail'],'fix':'Fix\x20the\x20Plan\x20structure'})),'soft_notes':p['findings']['filter'](Q=>Q['level']==='medium'||Q['level']==='low')['map'](Q=>({'id':Q['rule_id'],'description':Q['title']}))},'harness_check':{'module_constraints':u['map'](Q=>({'module':Q['module'],'plan_satisfied':Q['adopted'],'missing':Q['missingConstraints'],'reason':Q['module']==='discount_lifecycle'&&Q['adopted']?'ADOPTION-BASED\x20satisfaction\x20(disclosure\x20obligations\x20accepted\x20with\x20module\x20adoption),\x20NOT\x20plan\x20structure:\x20creation_plan\x20intentionally\x20carries\x20no\x20Discount/SKU\x20nodes\x20—\x20they\x20are\x20minted\x20in\x20merchant\x20post-deploy\x20steps\x20and\x20verified\x20on-chain\x20after\x20deploy\x20(query\x20the\x20minted\x20Service.discount).\x20Reward\x20rails\x20likewise\x20ride\x20review_mode\x20compile\x20emission,\x20not\x20a\x20creation_plan\x20node.':Q['reason'],'estimated_score_boost':Q['estimatedScoreBoost']})),'blocking_issues':[...u['filter'](Q=>!Q['adopted'])['map'](Q=>({'module':Q['module'],'missing_constraints':Q['missingConstraints'],'fix':Q['reason']})),...s['map'](Q=>({'module':Q['module'],'missing_constraints':Q['missing_constraints'],'fix':Q['fix']})),...A],'deploy_time_checks':w,'recipient_design_guidance':y},'game_theory':{'summary':H['summary'],'coverage':H['coveredCount']+'/'+H['totalCount'],'exposed_scenarios':H['exposedScenarios'],'wow_alignments':H['wowAlignments'],'scenarios':H['results']['map'](Q=>({'scenario':Q['scenario'],'covered':Q['covered'],'conflict':Q['conflict'],'user_protection':Q['userProtection'],'evaluation_metric':Q['evaluationMetric'],'recommendation':Q['recommendation']}))},'workflow_design_assessment':{'score':I['score'],'summary':I['summary'],'findings':I['findings']['map'](Q=>({'kind':Q['kind'],'severity':Q['severity'],'message':Q['message'],'fix':Q['fix']})),'checks':I['checks']['map'](Q=>({'id':Q['id'],'dimension':Q['dimension'],'passed':Q['passed'],'severity':Q['severity'],'message':Q['message'],'fix':Q['fix']}))},'creation_plan':J,'post_deploy_steps':x,...F['length']>0x0?{'pending_guard_designs':F}:{},'warnings':[...e['warnings'],...m['omitted']['length']>0x0?['Advisory\x20guard\x20design(s)\x20omitted\x20by\x20decision\x20({kind:\x27omit\x27}):\x20'+m['omitted']['join'](',\x20')+'\x20—\x20'+'no\x20Guard\x20created,\x20nothing\x20binds\x20them\x20(run75747\x20F-38).']:[]],'next_action':z['length']>0x0?'Resolve\x20the\x20blocking_issues\x20above\x20(adjust\x20guide_confirm\x20payment/trust/modules,\x20or\x20accept\x20and\x20drop\x20the\x20affected\x20module\x20via\x20guide_confirm.adopted_module_ids),\x20then\x20call\x20merchant_guide\x20again.':p['blocking']?'The\x20plan\x20audit\x20is\x20BLOCKING\x20(see\x20harness_check.blocking_issues\x20and\x20audit.findings\x20—\x20e.g.\x20a\x20terminal\x20node\x20with\x20no\x20fund\x20exit,\x20or\x20an\x20unresolved\x20guard\x20bound\x20to\x20a\x20fund\x20path).\x20Fix\x20the\x20plan/template\x20or\x20guard\x20resolutions\x20and\x20call\x20merchant_guide\x20again;\x20do\x20NOT\x20materialize\x20this\x20plan.'+(F['length']>0x0?'\x20Pending\x20guard\x20designs:\x20'+F['length']+'\x20listed\x20in\x20pending_guard_designs\x20—\x20resolve\x20each\x20via\x20guide_confirm.guard_resolutions\x20(kind\x20\x27inline\x27\x20with\x20the\x20Guard\x20table+root,\x20kind\x20\x27template\x27\x20with\x20a\x20tpl_*\x20id,\x20or\x20{kind:\x27omit\x27}\x20for\x20advisory\x20designs\x20that\x20do\x20not\x20apply\x20to\x20this\x20shop),\x20then\x20call\x20merchant_guide\x20again.':''):'Plan\x20ready.\x20Materialize:\x20create\x20the\x20objects\x20in\x20creation_plan\x20order\x20via\x20onchain_operations,\x20then\x20run\x20post_deploy_steps\x20in\x20order\x20(compensation\x20fund\x20top-up,\x20arbitration\x20unpause,\x20per-order\x20settlement\x20via\x20alloc_by_guard).\x20WIZARD\x20CONTRACT:\x20on\x20the\x20Service\x20publish\x20call\x20(data.publish=true),\x20pass\x20this\x20exact\x20plan\x20back\x20as\x20data.creation_plan\x20—\x20the\x20publish\x20gate\x20replays\x20its\x20freeze\x20matrix\x20and\x20rejects\x20the\x20publish\x20if\x20any\x20gate\x20fails;\x20omitting\x20it\x20leaves\x20the\x20manual\x20path\x20ungated.','plan':o,'audit':{'issues':p['issues'],'findings':p['findings'],'blocking':p['blocking'],'score':q},'reflux':{'applied':n['applied'],'blocks':n['blocks'],'iterations':n['iterations']}};}export function listBusinessModules(){return CORE_BUSINESS_MODULES['map'](a=>({'id':a['id'],'name':a['name'],'description':a['description'],'industry_fit':a['industryFit'],'addresses_pain_points':a['addressesPainPoints'],'requires_keeper':a['requiresKeeper']}));}
|
|
1
|
+
import{analyzeIntent}from'./intent-analyzer.js';import{compileTemplate}from'../../composition/compile.js';import{reflux,auditScore}from'../../composition/reflux.js';import{planBlueprint}from'../../composition/blueprint-view.js';import{getGuardDesignPattern}from'../../knowledge/guard-design-patterns.js';import{GUARD_TEMPLATES,getTemplatesByScene}from'../../knowledge/guard-templates.js';import{checkGameTheoryConstraints}from'./game-theory.js';import{assessWorkflowDesign}from'./workflow-design-assessment.js';import{CORE_BUSINESS_MODULES,getBusinessModule,recommendModules,checkModuleConstraints,moduleHasIntentEvidence}from'../../extensions/business-modules.js';import{recipientDesignGuidance}from'../../knowledge/recipient-constraint.js';import{getTemplate,getTemplatesByIndustry}from'../../knowledge/template-loader.js';import{getScenarioMode}from'../../knowledge/scenario-modes.js';function derivePlanSatisfiedConstraints(a,b){const c=new Set(),d=i=>a['edges']['some'](j=>j['relation']===i),e=i=>a['nodes']['some'](j=>j['id']===i),f=i=>a['nodes']['some'](j=>j['type']===i),g=i=>a['adoptedModules']['includes'](i);if(d('has_order_allocators'))c['add']('order_allocators_bound');if(d('uses_machine'))c['add']('machine_bound_before_publish');if(d('has_arbitration'))c['add']('arbitration_bound_to_service');if(e('machine'))c['add']('machine_published');if(e('repository'))c['add']('repository_published');if(e('service'))c['add']('service_published');e('permission_arb')&&e('permission')&&c['add']('arbitration_permission_independent');g('independent_arbitration')&&a['nodes']['some'](i=>i['id']['includes']('guard')&&i['id']['includes']('arbitration'))&&c['add']('voting_guard_configured');g('accept_timeout_protection')&&(c['add']('time_guard_configured'),c['add']('adminUnhold_permission'));g('milestone_escrow')&&f('guard')&&c['add']('milestone_forward_guarded');const h=d('has_order_allocators');if(h&&b['payment']['allocation']&&b['payment']['allocation']['length']>0x0){c['add']('allocators_configured');const i=b['payment']['allocation']['reduce']((k,l)=>k+l['percentage'],0x0);if(Math['abs'](i-0x64)<0.001)c['add']('sharing_sum_100');const j=b['payment']['allocation']['find'](k=>k['recipient']==='platform');if(!j||j['percentage']===0x0)c['add']('platform_fee_zero');g('supplier_collaboration')&&(c['add']('allocation_sharing_configured'),c['add']('demand_configured'));}g('wip_provenance')&&e('repository')&&c['add']('wip_hash_before_delivery');g('subscription_with_proof')&&e('repository')&&(c['add']('delivery_guard_per_cycle'),c['add']('repository_updated'));g('damage_attestation')&&(c['add']('pre_rental_hash'),c['add']('post_rental_hash'));g('refund_guarantee')&&(c['add']('compensation_fund_positive'),c['add']('refund_guard_configured'));if(g('praise_incentive')){const k=a['plan']['steps']['some'](m=>m['op']==='create'&&m['object']==='reward'),l=a['plan']['steps']['some'](m=>m['op']==='configure'&&m['method']==='coin_add');k&&l&&(c['add']('reward_pool_funded'),c['add']('reward_claim_replay_armed'));}g('discount_lifecycle')&&(c['add']('discount_budget_planned'),c['add']('discount_burn_disclosed'));if(g('after_sales_guarantee')){const m=a['plan']['steps']['find'](p=>p['op']==='create'&&p['object']==='machine'),n=m?.['params']?.['nodes']??[],o=n['some'](p=>/return|refund|exchange|replace|reship|swap|warranty|repair/i['test'](p['name']??''));o&&(c['add']('after_sales_rail_present'),c['add']('after_sales_polarity_pair'),c['add']('after_sales_window_anchored'),c['add']('after_sales_no_double_remedy'));}if(g('acceptance_judging')){const p=a['plan']['steps']['find'](t=>t['op']==='create'&&t['object']==='machine'),q=p?.['params']?.['nodes']??[],r=q['map'](t=>t['name']??''),s=r['some'](t=>/accept|approv|award|ruling|place|placement|triage|vot|evaluat|winner|judge/i['test'](t));if(s){const t=r['some'](u=>/revis|redeliver|resubmit|rework/i['test'](u));c['add']('acceptance_race_free');if(e('arbitration'))c['add']('acceptance_judge_independent');if(!t||e('repository'))c['add']('acceptance_revision_bounded');}}if(g('installment_deposit')){const u=a['plan']['steps']['find'](z=>z['op']==='create'&&z['object']==='machine'),v=u?.['params']?.['nodes']??[],w=v['map'](z=>z['name']??''),x=w['some'](z=>/(deposit|down_?pay|balance_due|balance_owed|installment|milestone|awaiting|owed)/i['test'](z)),y=w['some'](z=>/(paid|funded|captured|settled)/i['test'](z));x&&y&&(c['add']('installment_funding_gated'),c['add']('installment_deposit_exit'),c['add']('installment_release_once'));}if(g('affiliate_commission')){const z=a['plan']['steps']['find'](D=>D['op']==='create'&&D['object']==='machine'),A=z?.['params']?.['nodes']??[],B=A['map'](D=>D['name']??''),C=B['some'](D=>/(commission|affiliate|referr|attribut|partner_?payout)/i['test'](D));C&&(c['add']('affiliate_rail_present'),c['add']('affiliate_clawback_disclosed'),c['add']('affiliate_window_anchored'));}if(g('crowdfunding')){const D=a['plan']['steps']['find'](H=>H['op']==='create'&&H['object']==='machine'),E=D?.['params']?.['nodes']??[],F=E['map'](H=>H['name']??''),G=F['some'](H=>/(releas|settle|funded|disburs|project)/i['test'](H));G&&(c['add']('crowdfunding_exit_rail_present'),c['add']('crowdfunding_aggregate_writer_bound'),c['add']('crowdfunding_disclosure_present'));}return c;}function deriveDeployTimeChecks(a,b=![]){const c=[];return a['nodes']['some'](d=>d['id']==='machine')&&c['push']('Machine\x20published\x20AND\x20bound\x20to\x20Service\x20BEFORE\x20Service.publish\x20(machine\x20is\x20immutable\x20after\x20publish)'),a['edges']['some'](d=>d['relation']==='has_order_allocators')&&(c['push']('Service.order_allocators\x20bound\x20(verify\x20via\x20query_objects\x20after\x20publish\x20—\x20order_allocators\x20is\x20FROZEN\x20at\x20publish)'),c['push']('Settlement\x20is\x20NOT\x20triggered\x20by\x20reaching\x20a\x20Machine\x20node\x20alone\x20—\x20an\x20explicit\x20alloc_by_guard\x20call\x20(keeper\x20or\x20merchant)\x20fires\x20the\x20settlement\x20Allocator\x20once\x20its\x20Guard\x20passes.\x20Declare\x20the\x20node->allocator\x20trigger\x20(which\x20terminal\x20node\x20unlocks\x20settlement)\x20and\x20schedule\x20the\x20keeper\x20step;\x20otherwise\x20orders\x20stall\x20at\x20the\x20settle\x20node\x20with\x20allocation_state=pending')),(a['adoptedModules']['includes']('refund_guarantee')||a['nodes']['some'](d=>d['id']==='arbitration'))&&(b?c['push']('COMPENSATION\x20FUND:\x20DO\x20NOT\x20FUND\x20—\x20this\x20template\x20declares\x20compensation_fund_policy=forbidden\x20(the\x20unreserved\x20pool\x20is\x20double-takeable\x20via\x20refund-then-claim\x20until\x20the\x20arbitration-escrow\x20shared\x20gate\x20lands;\x20user\x20ruling\x202026-10-15).\x20Disputes\x20ride\x20the\x20escrow\x20rails\x20only;\x20the\x20compensation_fund_topup\x20post-deploy\x20step\x20is\x20intentionally\x20absent'):c['push']('compensation_fund\x20MUST\x20be\x20able\x20to\x20cover\x20payouts:\x20a\x20claim\x20against\x20a\x20drained\x20fund\x20aborts\x20(service.move\x20E_COMPENSATION_NOT_MATCH).\x20Size\x20the\x20fund\x20>=\x203x\x20a\x20TYPICAL\x20single\x20order\x20(3x\x20IS\x20the\x20chain\x27s\x20hard\x20award\x20ceiling,\x20MAX_INDEMNITY_MULTIPLE)\x20—\x20per-order\x20coverage\x20is\x20enforced\x20at\x20BUY\x20time\x20(each\x20order\x20is\x20checked\x20against\x203x\x20ITS\x20OWN\x20amount,\x20not\x203x\x20the\x20highest\x20SKU),\x20so\x20publish\x20no\x20longer\x20blocks\x20on\x20coverage;\x20verify\x20the\x20on-chain\x20balance\x20before\x20going\x20live')),a['nodes']['some'](d=>d['id']==='arbitration')&&(c['push']('Arbitration.permission\x20!=\x20Service.permission\x20on-chain\x20(E_ARBITRATION_PERMISSION_CONFLICT=33)'),c['push']('A\x20freshly\x20created\x20Arbitration\x20defaults\x20to\x20PAUSED\x20—\x20unpause\x20it\x20(arbitration\x20activation)\x20before\x20the\x20first\x20case\x20can\x20be\x20filed,\x20otherwise\x20dispute\x20filing\x20aborts')),a['nodes']['some'](d=>d['id']==='repository')&&c['push']('Repository\x20published\x20and\x20Guard\x20write\x20validation\x20configured'),c['push']('After\x20materialization,\x20confirm\x20the\x20on-chain\x20state\x20matches\x20this\x20plan\x20(query_toolkit\x20query_type=\x27service_panorama\x27)'),c;}function derivePostDeploySteps(a,b=![]){const c=[];return!b&&(a['adoptedModules']['includes']('refund_guarantee')||a['nodes']['some'](d=>d['id']==='arbitration'))&&c['push']({'order':c['length']+0x1,'id':'compensation_fund_topup','title':'Top\x20up\x20the\x20compensation\x20fund','when':'After\x20the\x20Service\x20object\x20is\x20created,\x20BEFORE\x20the\x20service\x20goes\x20live\x20(before\x20the\x20first\x20order)','action':'Call\x20compensation_fund_add\x20sized\x20>=\x203x\x20a\x20TYPICAL\x20single\x20order\x20(3x\x20=\x20the\x20chain\x27s\x20hard\x20award\x20ceiling,\x20MAX_INDEMNITY_MULTIPLE;\x20above\x203x\x20only\x20buys\x20headroom\x20for\x20concurrent\x20claims).\x20Per-order\x20coverage\x20is\x20enforced\x20at\x20BUY\x20time\x20—\x20each\x20incoming\x20order\x20is\x20checked\x20against\x203x\x20ITS\x20OWN\x20amount\x20and\x20under-covered\x20orders\x20cannot\x20be\x20created\x20—\x20then\x20verify\x20the\x20on-chain\x20fund\x20balance\x20via\x20query_objects','tool_hint':'onchain_operations\x20(service.compensation_fund_add)','failure_if_skipped':'a\x20compensation\x20claim\x20against\x20an\x20empty\x20fund\x20aborts\x20(E_COMPENSATION_NOT_MATCH,\x20testnet\x20lesson\x20R-4)'}),a['nodes']['some'](d=>d['id']==='arbitration')&&c['push']({'order':c['length']+0x1,'id':'arbitration_unpause','title':'Activate\x20the\x20Arbitration\x20(unpause)','when':'Immediately\x20after\x20the\x20Arbitration\x20object\x20is\x20created,\x20before\x20the\x20first\x20dispute\x20is\x20filed','action':'Unpause/activate\x20the\x20Arbitration\x20so\x20dispute\x20filing\x20is\x20accepted;\x20keep\x20its\x20Permission\x20distinct\x20from\x20the\x20Service\x20Permission\x20(E_ARBITRATION_PERMISSION_CONFLICT=33)','tool_hint':'onchain_operations\x20(arbitration\x20activation)','failure_if_skipped':'a\x20freshly\x20created\x20Arbitration\x20defaults\x20to\x20PAUSED\x20—\x20dispute\x20filing\x20aborts\x20(testnet\x20lesson\x20R-5)'}),a['edges']['some'](d=>d['relation']==='has_order_allocators')&&c['push']({'order':c['length']+0x1,'id':'settlement_alloc_by_guard','title':'Fire\x20settlement\x20via\x20alloc_by_guard\x20(keeper/merchant\x20step)','when':'Recurring\x20—\x20after\x20EACH\x20order\x20reaches\x20its\x20settlement\x20terminal\x20node\x20(declare\x20which\x20node\x20unlocks\x20settlement)','action':'Call\x20alloc_by_guard\x20on\x20the\x20order\x27s\x20allocation\x20with\x20the\x20settlement\x20Guard;\x20reaching\x20the\x20Machine\x20node\x20alone\x20does\x20NOT\x20settle\x20(allocation_state\x20stays\x20pending)','tool_hint':'onchain_operations\x20(allocation.alloc_by_guard);\x20schedule\x20as\x20a\x20keeper\x20step','failure_if_skipped':'orders\x20stall\x20at\x20the\x20settle\x20node\x20with\x20funds\x20locked\x20in\x20escrow\x20(testnet\x20lesson\x20R-2)'}),c['push']({'order':c['length']+0x1,'id':'verify_service_panorama','title':'Verify\x20the\x20on-chain\x20state\x20matches\x20the\x20plan','when':'After\x20all\x20creation\x20steps\x20and\x20the\x20steps\x20above\x20are\x20done','action':'Run\x20the\x20service\x20panorama\x20query\x20and\x20diff\x20it\x20against\x20this\x20plan\x27s\x20blueprint/creation_plan','tool_hint':'query_toolkit\x20query_type=\x27service_panorama\x27','failure_if_skipped':'plan/chain\x20drift\x20(missing\x20binding,\x20wrong\x20allocator\x20order)\x20stays\x20undetected\x20until\x20an\x20order\x20hits\x20it'}),c;}function buildCreationPlan(a){const b=[],c=new Map(a['nodes']['map'](k=>[k['id'],k])),f=new Map();for(const k of a['nodes'])f['set'](k['id'],new Set());for(const l of a['edges']){if(!f['has'](l['from'])||!c['has'](l['to']))continue;const m=l['relation']==='has_guard'?l['to']:l['from'],o=l['relation']==='has_guard'?l['from']:l['to'];if(m===o||!f['has'](m))continue;f['get'](m)['add'](o);}for(const p of a['nodes']){for(const q of Object['values'](p['config'])){q['type']==='address_ref'&&q['targetId']!==p['id']&&f['has'](q['targetId'])&&f['get'](p['id'])['add'](q['targetId']);}}const g=a['nodes']['filter'](r=>r['type']==='service')['map'](r=>r['id']);if(g['length']>0x0)for(const r of a['nodes']){if(r['type']!=='guard')continue;const s=f['get'](r['id']);if(s===undefined)continue;for(const t of g)s['add'](t);}const h=new Map([...f]['map'](([u,v])=>[u,[...v]])),i=[],j=new Map(f);while(j['size']>0x0){const u=[...j['entries']()]['filter'](([,v])=>v['size']===0x0)['map'](([v])=>v);if(u['length']===0x0){i['push'](...j['keys']());break;}u['sort']();for(const v of u){i['push'](v),j['delete'](v);for(const w of j['values']())w['delete'](v);}}return i['forEach']((x,y)=>{const z=c['get'](x),A=z['config']['name'],B=A?.['type']==='string'?A['value']:x,C=B['includes']('/')?B['replaceAll']('/','__'):B;b['push']({'order':y+0x1,'node_id':x,'object_type':z['type'],'suggested_name':C,'depends_on':h['get'](x)??[],'operation_hint':'Create\x20'+z['type']+'\x20via\x20onchain_operations,\x20then\x20configure.\x20Purpose:\x20'+z['purpose']});}),b;}function resolveTemplate(a,b){if(!a)return undefined;const c=getTemplate(a);if(c)return c;const d=getTemplatesByIndustry(a);if(b){const f=b['toLowerCase'](),g=d['filter'](h=>{const i=String(h['product_ref']??'')['trim']()['toLowerCase']();return i['length']>0x0&&f['includes'](i);});if(g['length']===0x1)return g[0x0];}const e=getScenarioMode(a)?.['default_template'];if(e){const h=getTemplate(e);if(h)return h;}if(d['length']>0x0)return d[0x0];return undefined;}export async function handleMerchantGuide(a){const b=a['guide_state']??{'intent_text':''},c=a['guide_confirm']??{},d={'intent_text':(a['intent']??b['intent_text']??'')['trim'](),'confirmed_industry':c['industry']??b['confirmed_industry'],'currency':c['currency']??b['currency'],'deliverables':c['deliverables']??b['deliverables'],'payment_override':c['payment']??b['payment_override'],'trust_override':c['trust']??b['trust_override'],'adopted_module_ids':c['adopted_module_ids']??b['adopted_module_ids'],'guard_resolutions':{...b['guard_resolutions']??{},...c['guard_resolutions']??{}},'review_mode':c['review_mode']??b['review_mode'],'reward_funding':c['reward_funding']??b['reward_funding'],'after_sales_mode':c['after_sales_mode']??b['after_sales_mode'],'acceptance_mode':c['acceptance_mode']??b['acceptance_mode'],'installment_mode':c['installment_mode']??b['installment_mode'],'affiliate_mode':c['affiliate_mode']??b['affiliate_mode'],'crowdfunding_mode':c['crowdfunding_mode']??b['crowdfunding_mode'],'sales':c['sales']??b['sales']};for(const O of Object['keys'](d)){if(d[O]===undefined)delete d[O];}if(d['guard_resolutions']&&Object['keys'](d['guard_resolutions'])['length']===0x0)delete d['guard_resolutions'];if(!d['intent_text'])throw new Error('merchant_guide\x20requires\x20\x27intent\x27\x20(business\x20description)\x20for\x20Step\x201.\x20'+'Example:\x20intent=\x27I\x20want\x20to\x20offer\x20online\x20design\x20service\x20with\x20milestone\x20payments\x27.\x20'+'Pass\x20the\x20returned\x20guide_state\x20back\x20UNCHANGED\x20on\x20subsequent\x20calls,\x20plus\x20guide_confirm\x20for\x20merchant\x20decisions.');const e=await analyzeIntent(d['intent_text'],{'preferredIndustry':d['confirmed_industry'],'currency':d['currency']});if(!d['confirmed_industry'])return{'action':'merchant_guide','current_step':0x2,'step_name':'Industry\x20Matching','guide_state':d,'intent_draft':e['intent'],'industry_options':{'inferred':e['inferredIndustry'],'confidence':e['industryConfidence'],'similar':e['similarIndustries']},'warnings':e['warnings'],'next_action':'Confirm\x20the\x20industry\x20by\x20calling\x20merchant_guide\x20again\x20with\x20guide_state\x20(UNCHANGED)\x20'+('plus\x20guide_confirm={\x20industry:\x20\x27<one\x20of:\x20'+e['similarIndustries']['join'](',\x20')+'\x20—\x20or\x20any\x20other\x20industry\x20id>\x27\x20}')};const f={...e['intent'],'industry':d['confirmed_industry'],'deliverables':d['deliverables']??e['intent']['deliverables'],'payment':{...e['intent']['payment'],...d['payment_override']??{}},'trust':{...e['intent']['trust'],...d['trust_override']??{}}},h=!!d['adopted_module_ids'],i=d['adopted_module_ids']?d['adopted_module_ids']['map'](P=>getBusinessModule(P))['filter'](P=>!!P):recommendModules(d['confirmed_industry'],d['intent_text'],{'maxModules':0x5}),j=a['template_override']??resolveTemplate(d['confirmed_industry'],d['intent_text']);if(!j)throw new Error('No\x20compilable\x20template\x20found\x20for\x20industry\x20\x27'+d['confirmed_industry']+'\x27.\x20'+'Register\x20a\x20template\x20via\x20industry_pack_operation\x20or\x20pass\x20template_override\x20explicitly.');const l={'currency':d['currency']??f['payment']['currency'],...d['payment_override']?{'payment':d['payment_override']}:{},...d['trust_override']?{'trust':d['trust_override']}:{},...d['deliverables']?{'deliverables':d['deliverables']}:{},...d['adopted_module_ids']?{'adopted_module_ids':d['adopted_module_ids']}:{},...d['review_mode']?{'review_mode':d['review_mode']}:{},...d['reward_funding']!==undefined?{'reward_funding':d['reward_funding']}:{},...d['after_sales_mode']?{'after_sales_mode':d['after_sales_mode']}:{},...d['acceptance_mode']?{'acceptance_mode':d['acceptance_mode']}:{},...d['installment_mode']?{'installment_mode':d['installment_mode']}:{},...d['affiliate_mode']?{'affiliate_mode':d['affiliate_mode']}:{},...d['crowdfunding_mode']?{'crowdfunding_mode':d['crowdfunding_mode']}:{},...d['sales']?.['length']?{'sales':d['sales']}:{}},m={};for(const P of i){for(const Q of P['templateRefs']){if(Q['object_type']!=='guard')continue;const R=j['guards']['filter'](S=>S['template_id']===Q['template_id']);if(R['length']===0x0)continue;for(const S of R){m[S['key']??Q['template_id']+'#'+j['guards']['indexOf'](S)]={'kind':'template','template_id':Q['template_id']};}}}Object['assign'](m,d['guard_resolutions']??{});const n=compileTemplate(j,l,{'nameBase':a['name_base']??j['id'],'intent':d['intent_text'],'guardResolutions':m}),o=reflux(n['plan']),p=o['plan'],q=o['audit'],r=auditScore(q),s=planBlueprint(p,f,i['map'](T=>T['id'])),t=n['blockers']['map'](T=>({'module':'template','missing_constraints':[T['code']],'fix':T['detail']})),u=derivePlanSatisfiedConstraints(s,f),w=i['map'](T=>checkModuleConstraints(T,u,{'evidenceMatched':h||moduleHasIntentEvidence(T,d['intent_text'])})),x=j['compensation_fund_policy']==='forbidden',y=deriveDeployTimeChecks(s,x),z=derivePostDeploySteps(s,x),A=s['edges']['some'](T=>T['relation']==='has_order_allocators')?recipientDesignGuidance()['map'](T=>({'id':T['id'],'move_recipient':T['move_recipient'],'semantics':T['semantics'],'required_constraints':T['required_constraints'],'finding_if_unmet':T['finding_if_unmet']})):undefined,B=[...w['filter'](T=>!T['adopted']),...t],C=q['findings']['filter'](T=>T['level']==='critical'||T['level']==='high')['map'](T=>({'module':'audit','missing_constraints':[T['rule_id']],'fix':T['title']+'\x20—\x20'+(T['mitigation']??T['description'])})),D=[{'re':/allocat|refund|recover|claimed_by|settle|escrow/i,'scene':'service_order_allocators_guard'},{'re':/\bbuy\b|purchase|allowlist|blocklist/i,'scene':'service_buy_guard'},{'re':/reward/i,'scene':'reward_claim'},{'re':/write_guard|repository_write/i,'scene':'repository_write_guard'},{'re':/arbitrat|ruling|voting/i,'scene':'arbitration_usage_guard'},{'re':/forward|node|witness|deliver|review|cancel|expire|submission|progress/i,'scene':'machine_forward_guard'}],E=[{'re':/claimed_by\s*some\s*==\s*true/i,'tpl':'tpl_allocator_node_gate_recover'},{'re':/claimed_by\s*some\s*==\s*false|claimed_by\s*(?:is\s+)?none|\brefund|\bcancel/i,'tpl':'tpl_allocator_node_gate_refund'},{'re':/claimed_by\s*some|\brecover|\baward/i,'tpl':'tpl_allocator_node_gate_recover'}],F=[{'host':'machine','re':/pattern\.time_lock_progress/i,'tpl':'tpl_time_lock_progress'},{'host':'machine','re':/pattern\.time_window_upper_bound/i,'tpl':'tpl_time_window_upper'},{'host':'reward','re':/pattern\./i,'tpl':'tpl_reward_one_time_claim'}],G=(T,U,V,W,X)=>{let Y;const Z=/tpl_[a-z0-9_]+/['exec'](T+'\x20'+U);Z!==null&&(Y=GUARD_TEMPLATES['find'](a4=>a4['id']===Z[0x0])?.['scene_id']);Y===undefined&&W!=='reward'&&/\ballocators?\b|claimed_by|guard_identifier|order_allocators/i['test'](U)&&(Y='service_order_allocators_guard');if(Y===undefined){if(W==='machine'||W==='machine_forward')Y='machine_forward_guard';else{if(W==='reward')Y='reward_claim';else{if(W==='repository')Y='repository_write_guard';else{if(W==='arbitration')Y='arbitration_usage_guard';else{const a4=D['find'](a5=>a5['re']['test'](T+'\x20'+U));Y=a4?.['scene'];}}}}}if(Y===undefined)return undefined;const a0=getTemplatesByScene(Y);let a1=V!==undefined&&a0['some'](a5=>a5['applicable_industries']['includes'](V))?a0['filter'](a5=>a5['applicable_industries']['includes'](V)):a0;if(/\btime[_-]?lock|\bwindow|\btimeout|\bduration|\bdeadline|\bdays?\b|\bclock|\bdelay/i['test'](T+'\x20'+U)){const a5=a1['filter'](a6=>JSON['stringify'](a6['example_root']??{})['toLowerCase']()['includes']('clock'));if(a5['length']===0x0)return undefined;a1=a5;}if(X['length']>0x0){const a6=Z!==null?a1['find'](a8=>a8['id']===Z[0x0]):undefined,a7=a1['filter'](a8=>{const a9=[];if(a8['example_root']!==undefined){const aa=JSON['stringify'](a8['example_root']);for(const ab of aa['matchAll'](/"query":"([^"]+)"/g))a9['push'](ab[0x1]);if(aa['includes']('\x22type\x22:\x22query_progress_history_time\x22'))a9['push']('progress.history.time');if(aa['includes']('\x22type\x22:\x22query_progress_history_find\x22'))a9['push']('progress.history.find');}return a9['some'](ac=>X['some'](ad=>ac===ad||ac['startsWith'](ad)||ad['startsWith'](ac)));});if(a6!==undefined&&!a7['includes'](a6))a7['push'](a6);if(a7['length']===0x0)return undefined;a1=a7;}const a2=W==='machine_forward'?'machine':W,a3=F['find'](a8=>a8['host']===a2&&a8['re']['test'](T+'\x20'+U)&&a1['some'](a9=>a9['id']===a8['tpl']));a3!==undefined&&(a1=[...a1]['sort']((a8,a9)=>(a8['id']===a3['tpl']?0x0:0x1)-(a9['id']===a3['tpl']?0x0:0x1)));if(Y==='service_order_allocators_guard'){const a8=E['find'](a9=>a9['re']['test'](T+'\x20'+U));a8!==undefined&&(a1=[...a1]['sort']((a9,aa)=>(a9['id']===a8['tpl']?0x0:0x1)-(aa['id']===a8['tpl']?0x0:0x1)));}return a1['slice'](0x0,0x3)['map'](a9=>({'template_id':a9['id'],'name':a9['name'],'parameters':a9['parameters']['map'](aa=>({'name':aa['name'],'required':aa['required'],...aa['default']!==undefined?{'default':aa['default']}:{},'description':aa['description']}))}));},H=n['unresolved']['map'](T=>{const U=getGuardDesignPattern(T['template_id']),V=G(T['template_id'],T['purpose'],j?.['industry'],T['host'],U?.['key_queries']??[]),W=new Set((j?.['machine_shape']??[])['flatMap'](a1=>(a1['from']??[])['map'](a2=>typeof a2==='string'?undefined:a2['guard_key'])['filter'](a2=>typeof a2==='string'))),X=new Map((j?.['allocator']['rows']??[])['filter'](a1=>typeof a1['guard_key']==='string')['map'](a1=>[a1['guard_key'],a1])),Y=X['get'](T['key']),Z=Y!==undefined&&!W['has'](T['key']),a0=!W['has'](T['key'])&&!X['has'](T['key'])&&T['policy']===undefined&&T['host']!=='reward'&&!(T['host']==='service'&&T['key']==='buy');return{'key':T['key'],'template_id':T['template_id'],'host':T['host'],'purpose':T['purpose'],...U?.['logic_summary']?{'logic_summary':U['logic_summary']}:{},...U?.['key_queries']?.['length']?{'key_queries':U['key_queries']}:{},...V!==undefined&&V['length']>0x0?{'suggested_templates':V}:{},'how_to_resolve':'guide_confirm.guard_resolutions[\x27'+T['key']+'\x27]\x20=\x20{\x20kind:\x20\x27inline\x27,\x20table,\x20root\x20}\x20(a\x20resolved\x20Guard),\x20'+'or\x20{\x20kind:\x20\x27template\x27,\x20template_id:\x20\x27tpl_*\x27,\x20params\x20}\x20when\x20a\x20guard\x20template\x20matches\x20this\x20design'+(V!==undefined&&V['length']>0x0?'\x20(suggested_templates\x20below\x20list\x20the\x20matching\x20executable\x20forms\x20and\x20their\x20parameters)':'.')+(T['host']==='machine'&&!Z?'\x20MACHINE-HOST\x20REQUIREMENT:\x20the\x20inline\x20table\x20MUST\x20declare\x20the\x20protocol\x20task-binding\x20slot\x20'+'{\x20identifier:\x20254,\x20b_submission:\x20true,\x20value_type:\x20\x22Address\x22\x20}\x20—\x20the\x20forward\x27s\x20passport\x20only\x20emits\x20'+'DECLARED\x20slots,\x20so\x20a\x20machine-forward\x20guard\x20without\x20this\x20row\x20aborts\x20EVERY\x20order-bound\x20forward\x20'+'it\x20gates\x20(code\x2011)\x20and\x20the\x20pre-publish\x20gate\x20blocks\x20the\x20Machine\x20publish.':'')+(Z?'\x20ALLOCATOR-RAIL\x20NOTE:\x20this\x20design\x20gates\x20an\x20allocator\x20rail\x20(not\x20a\x20machine\x20forward)\x20—\x20do\x20NOT\x20add\x20the\x20'+'254\x20task-binding\x20slot:\x20a\x20254\x20declaration\x20arms\x20once-per-order\x20replay\x20protection\x20at\x20alloc\x20time\x20'+'(allocation\x20ONCE_FOR_OBJECT)\x20and\x20permanently\x20blocks\x20multi-fire\x20rails\x20(a\x20second\x20release\x20aborts\x20'+'E_ONCE_TRIGGERED).\x20The\x20kernel\x20injects\x20254\x20ONLY\x20for\x20GuardIdentifier(254)-recipient\x20rails.'+(Y['recipient']==='guard_identifier'&&Y['recipient_key']!=='254'?'\x20This\x20rail\x27s\x20recipient\x20is\x20GuardIdentifier('+(Y['recipient_key']??'0')+')\x20—\x20the\x20inline\x20table\x20MUST\x20'+('declare\x20slot\x20'+(Y['recipient_key']??'0')+'\x20as\x20an\x20Address\x20submission\x20instead\x20(N-K21:\x20the\x20passport\x20')+'submits\x20the\x20ORDER\x20address\x20into\x20it;\x20an\x20undeclared\x20slot\x20makes\x20the\x20rail\x20unexecutable).':''):'')+(a0?'\x20ADVISORY\x20DESIGN\x20(run75747\x20F-38):\x20nothing\x20in\x20this\x20archetype\x20binds\x20this\x20key\x20—\x20no\x20machine\x20edge,\x20allocator\x20'+'rail,\x20repository\x20policy,\x20or\x20service\x20mount.\x20If\x20this\x20design\x20does\x20not\x20apply\x20to\x20your\x20shop\x20you\x20may\x20resolve\x20'+'it\x20with\x20{\x20kind:\x20\x27omit\x27\x20}\x20instead\x20of\x20building\x20a\x20Guard\x20no\x20one\x20consumes:\x20the\x20design\x20leaves\x20'+'pending_guard_designs,\x20no\x20Guard\x20object\x20is\x20created,\x20and\x20the\x20decision\x20is\x20recorded\x20in\x20the\x20build\x27s\x20'+'warnings.\x20An\x20omit\x20of\x20a\x20BOUND\x20design\x20is\x20refused\x20(GUARD_OMIT_UNSUPPORTED).':'')};}),I=B['length']>0x0||q['blocking'],J={'expiredTerminal':(j['machine_shape']??[])['some'](T=>/expire|deadline|timeout/i['test'](String(T?.['name']??'')))},K=checkGameTheoryConstraints(s,f,J),L=assessWorkflowDesign(s),M=buildCreationPlan(s),N=j?{'name':j['id'],'display_name':j['variant']+'\x20archetype\x20('+j['industry']+')','source':a['template_override']?'custom':'builtin','risk_appetite':'medium','key_risk':j['key_risk'],'machine_shape':j['machine_shape']['map'](T=>({'name':T['name'],'role':T['role'],...T['operator']?{'operator':T['operator']}:{},...T['semantic_role']?{'semantic_role':T['semantic_role']}:{}})),'guards':j['guards']['map'](T=>({'template_id':T['template_id'],'host':T['host'],'purpose':T['purpose']})),'allocator':j['allocator'],'risk_constraints':{},'build_notes':j['build_notes']??[],...j['time_anchors']?{'time_anchors':j['time_anchors']}:{}}:undefined;return{'action':'merchant_guide','current_step':I?0x9:0xa,'step_name':I?'Harness\x20Check\x20(issues\x20found)':'Submission\x20Plan\x20Ready','guide_state':{...d,'adopted_module_ids':i['map'](T=>T['id'])},'intent':{'intent_type':f['intent'],'industry':f['industry'],'roles':f['roles'],'deliverables':f['deliverables'],'payment':f['payment'],'trust':f['trust']},'adopted_modules':i['map'](T=>({'id':T['id'],'name':T['name'],'description':T['description'],'requires_keeper':T['requiresKeeper'],'keeper_hint':T['keeperHint'],'user_protections':T['userProtections'],'merchant_obligations':T['merchantObligations']})),'mode_prior':N,...N?.['time_anchors']?{'time_anchor_instructions':Object['entries'](N['time_anchors'])['map'](([T,U])=>{const V=U['startsWith']('order.time')?'\x20(order-creation\x20time\x20—\x20PRE-checkout\x20branches\x20only;\x20a\x20post-checkout\x20window\x20anchored\x20here\x20is\x20unreachable)':U['startsWith']('progress.current_time')?'\x20(entry\x20time\x20of\x20the\x20window\x27s\x20source\x20node\x20—\x20witness-derived\x20via\x20OrderProgress,\x20one\x20Guard\x20serves\x20every\x20order)':U['startsWith']('absolute_date')?'\x20(per-order\x20instance\x20Guard\x20—\x20the\x20absolute\x20date\x20differs\x20per\x20booking)':'';return'Time\x20windows\x20for\x20\x27'+T+'\x27\x20anchor\x20to\x20'+U+V;})}:{},'blueprint':{'nodes':s['nodes']['map'](T=>({'id':T['id'],'type':T['type'],'purpose':T['purpose']})),'edges':s['edges']['map'](T=>({'from':T['from'],'to':T['to'],'relation':T['relation'],'required':T['required']}))},'evaluation_preview':{'estimatedRiskScore':r,'estimatedCompletenessScore':Math['min'](0x64,0x1e+i['length']*0x8),'keyRisks':q['findings']['filter'](T=>T['level']==='critical'||T['level']==='high')['map'](T=>T['title']),'strengths':q['findings']['filter'](T=>T['level']==='info')['map'](T=>T['title']),'moduleBoosts':{}},'graph_validation':{'valid':q['issues']['length']===0x0,'hard_violations':q['issues']['map'](T=>({'id':T['code'],'description':T['detail'],'fix':'Fix\x20the\x20Plan\x20structure'})),'soft_notes':q['findings']['filter'](T=>T['level']==='medium'||T['level']==='low')['map'](T=>({'id':T['rule_id'],'description':T['title']}))},'harness_check':{'module_constraints':w['map'](T=>{const U=T['module']==='discount_lifecycle'&&T['adopted']?'ADOPTION-BASED\x20satisfaction\x20(disclosure\x20obligations\x20accepted\x20with\x20module\x20adoption),\x20NOT\x20plan\x20structure:\x20creation_plan\x20intentionally\x20carries\x20no\x20Discount/SKU\x20nodes\x20—\x20they\x20are\x20minted\x20in\x20merchant\x20post-deploy\x20steps\x20and\x20verified\x20on-chain\x20after\x20deploy\x20(query\x20the\x20minted\x20Service.discount).\x20Reward\x20FUNDING\x20rides\x20review_mode\x20compile\x20emission,\x20BUT\x20the\x20reward\x20claim\x20GUARD\x20SPEC\x20must\x20still\x20be\x20declared\x20in\x20the\x20plan\x27s\x20guards[]\x20(host:\x27reward\x27)\x20—\x20compile\x20emits\x20the\x20rail\x20only\x20from\x20that\x20spec,\x20and\x20REVIEW_REWARD_GUARD_MISSING\x20hard-blocks\x20publish\x20when\x20it\x20is\x20omitted\x20(G-02,\x20onlyfans-mn\x20261019:\x20the\x20old\x20prose\x20denied\x20the\x20guard\x20spec\x20and\x20deadlocked\x20every\x20reward\x20publish).':T['reason'],V=T['evidence_matched']===![]?''+(U?U+'\x20':'')+'Adopted\x20WITHOUT\x20explicit\x20intent\x20evidence\x20(score-based\x20auto-recommendation\x20only):\x20estimated_score_boost\x20recorded\x20as\x200.\x20Keep\x20it\x20deliberately\x20or\x20drop\x20it\x20via\x20guide_state.adopted_module_ids.':U;return{'module':T['module'],'plan_satisfied':T['adopted'],'missing':T['missingConstraints'],'reason':V,'estimated_score_boost':T['estimatedScoreBoost'],'evidence_matched':T['evidence_matched']};}),'blocking_issues':[...w['filter'](T=>!T['adopted'])['map'](T=>({'module':T['module'],'missing_constraints':T['missingConstraints'],'fix':T['reason']})),...t['map'](T=>({'module':T['module'],'missing_constraints':T['missing_constraints'],'fix':T['fix']})),...C],'deploy_time_checks':y,'recipient_design_guidance':A},'game_theory':{'summary':K['summary'],'coverage':K['coveredCount']+'/'+K['totalCount'],'exposed_scenarios':K['exposedScenarios'],'wow_alignments':K['wowAlignments'],'scenarios':K['results']['map'](T=>({'scenario':T['scenario'],'covered':T['covered'],'conflict':T['conflict'],'user_protection':T['userProtection'],'evaluation_metric':T['evaluationMetric'],'recommendation':T['recommendation']}))},'workflow_design_assessment':{'score':L['score'],'summary':L['summary'],'findings':L['findings']['map'](T=>({'kind':T['kind'],'severity':T['severity'],'message':T['message'],'fix':T['fix']})),'checks':L['checks']['map'](T=>({'id':T['id'],'dimension':T['dimension'],'passed':T['passed'],'severity':T['severity'],'message':T['message'],'fix':T['fix']}))},'creation_plan':M,'post_deploy_steps':z,...H['length']>0x0?{'pending_guard_designs':H}:{},'warnings':[...e['warnings'],...n['omitted']['length']>0x0?['Advisory\x20guard\x20design(s)\x20omitted\x20by\x20decision\x20({kind:\x27omit\x27}):\x20'+n['omitted']['join'](',\x20')+'\x20—\x20'+'no\x20Guard\x20created,\x20nothing\x20binds\x20them\x20(run75747\x20F-38).']:[]],'next_action':B['length']>0x0?'Resolve\x20the\x20blocking_issues\x20above\x20(adjust\x20guide_confirm\x20payment/trust/modules,\x20or\x20accept\x20and\x20drop\x20the\x20affected\x20module\x20via\x20guide_confirm.adopted_module_ids),\x20then\x20call\x20merchant_guide\x20again.':q['blocking']?'The\x20plan\x20audit\x20is\x20BLOCKING\x20(see\x20harness_check.blocking_issues\x20and\x20audit.findings\x20—\x20e.g.\x20a\x20terminal\x20node\x20with\x20no\x20fund\x20exit,\x20or\x20an\x20unresolved\x20guard\x20bound\x20to\x20a\x20fund\x20path).\x20Fix\x20the\x20plan/template\x20or\x20guard\x20resolutions\x20and\x20call\x20merchant_guide\x20again;\x20do\x20NOT\x20materialize\x20this\x20plan.'+(H['length']>0x0?'\x20Pending\x20guard\x20designs:\x20'+H['length']+'\x20listed\x20in\x20pending_guard_designs\x20—\x20resolve\x20each\x20via\x20guide_confirm.guard_resolutions\x20(kind\x20\x27inline\x27\x20with\x20the\x20Guard\x20table+root,\x20kind\x20\x27template\x27\x20with\x20a\x20tpl_*\x20id,\x20or\x20{kind:\x27omit\x27}\x20for\x20advisory\x20designs\x20that\x20do\x20not\x20apply\x20to\x20this\x20shop),\x20then\x20call\x20merchant_guide\x20again.':''):'Plan\x20ready.\x20Materialize:\x20create\x20the\x20objects\x20in\x20creation_plan\x20order\x20via\x20onchain_operations,\x20then\x20run\x20post_deploy_steps\x20in\x20order\x20('+z['map'](T=>T['id'])['join'](',\x20')+').\x20WIZARD\x20CONTRACT:\x20on\x20the\x20Service\x20publish\x20call\x20(data.publish=true),\x20pass\x20this\x20exact\x20plan\x20back\x20as\x20data.creation_plan\x20—\x20the\x20publish\x20gate\x20replays\x20its\x20freeze\x20matrix\x20and\x20rejects\x20the\x20publish\x20if\x20any\x20gate\x20fails;\x20omitting\x20it\x20leaves\x20the\x20manual\x20path\x20ungated.','plan':p,'audit':{'issues':q['issues'],'findings':q['findings'],'blocking':q['blocking'],'score':r},'reflux':{'applied':o['applied'],'blocks':o['blocks'],'iterations':o['iterations']}};}export function listBusinessModules(){return CORE_BUSINESS_MODULES['map'](a=>({'id':a['id'],'name':a['name'],'description':a['description'],'industry_fit':a['industryFit'],'addresses_pain_points':a['addressesPainPoints'],'requires_keeper':a['requiresKeeper']}));}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{matchScenarioMode}from'../../knowledge/scenario-modes.js';import{getTemplate,listTemplates}from'../../knowledge/template-loader.js';import{scanTemplate}from'../../knowledge/template-scanner.js';import{TEMPLATE_KEYWORDS}from'../../knowledge/builtin-templates.js';
|
|
1
|
+
import{matchScenarioMode}from'../../knowledge/scenario-modes.js';import{getTemplate,listTemplates}from'../../knowledge/template-loader.js';import{scanTemplate}from'../../knowledge/template-scanner.js';import{TEMPLATE_KEYWORDS,TEMPLATE_TAGS}from'../../knowledge/builtin-templates.js';import{buildTemplateIndex,resolveByProductRef}from'../../knowledge/template-index.js';export function matchTemplate(a){const b=a['toLowerCase'](),{templates:c}=listTemplates(),e=buildTemplateIndex(c),f=resolveByProductRef(e,a);if(f){const j=c['find'](k=>k['id']===f);if(j)return{'template':j,'confidence':0x1};}const {mode:g,confidence:h}=matchScenarioMode(a);let i;for(const k of c){const l=TEMPLATE_KEYWORDS[k['id']]??[],m=TEMPLATE_TAGS[k['id']]??[];let n=0x0;for(const p of l){if(b['includes'](p))n+=0x1;}for(const q of m){if(b['includes'](q))n+=0x1;}if(g['name']===k['industry'])n+=h;const o=l['length']+m['length']+0x1;if(!i||n>i['score'])i={'template':k,'score':n,'max':o};}if(!i||i['score']<=0x0)return undefined;return{'template':i['template'],'confidence':Math['min'](0x1,i['score']/ i['max'])};}function dryRunRiskCheck(a){const b=scanTemplate(a);return{'passed':b['passed'],'findings':b['findings']['map'](c=>'['+c['severity']+']\x20'+(c['rule_id']??'scan')+':\x20'+c['title']+'\x20—\x20'+c['suggestion'])};}function genericMappedEntries(a){return[{'source_element':'Order\x20lifecycle\x20/\x20status\x20flow','target_object':'Machine','mapping_note':a['machine_shape']['length']+'-node\x20workflow\x20adopted\x20from\x20the\x20'+a['id']+'\x20template'},{'source_element':'Business\x20rules\x20and\x20time\x20windows','target_object':'Guard','mapping_note':a['guards']['length']+'\x20guard\x20templates\x20carry\x20the\x20rule\x20parameters\x20as\x20immutable\x20on-chain\x20conditions'},{'source_element':'Payment\x20split\x20/\x20settlement','target_object':'Allocator','mapping_note':a['allocator']['description']},{'source_element':'Refund\x20policy','target_object':'Allocator\x20(refund\x20route)','mapping_note':'Refunds\x20route\x20via\x20Allocators\x20triggered\x20by\x20business\x20states\x20—\x20never\x20Machine\x20terminal\x20nodes\x20(R-M1-11)'},{'source_element':'Dispute\x20resolution','target_object':'Arbitration','mapping_note':'Independent\x20Arbitration\x20object\x20with\x20its\x20own\x20Permission\x20—\x20disputes\x20flow\x20off-Machine'},{'source_element':'Operator\x20roles\x20(staff/fulfiller/finance)','target_object':'Permission','mapping_note':'Role\x20slots\x20as\x20Permission\x20entities;\x20the\x20order\x20payer\x20acts\x20as\x20the\x20named\x20operator\x20without\x20occupying\x20a\x20slot'},{'source_element':'Evidence\x20and\x20records','target_object':'Repository','mapping_note':'Write-guarded\x20Repository\x20policies\x20anchor\x20evidence\x20hashes\x20(delivery,\x20inspection,\x20settlement\x20ledger)'},{'source_element':'Service\x20listing\x20and\x20pricing','target_object':'Service','mapping_note':'Service\x20carries\x20the\x20sale\x20structure,\x20buy\x20gate,\x20and\x20bound\x20Machine/Guards/Arbitration\x20before\x20publish'}];}function genericUnmappedEntries(a){const b=[{'source_element':'Incumbent\x20platform\x20internal\x20ranking\x20/\x20search\x20algorithm','mapping_note':'Marketplace\x20discovery\x20logic\x20has\x20no\x20on-chain\x20equivalent','reason':'Off-chain\x20platform\x20intelligence\x20—\x20use\x20the\x20WoWok\x20market\x20layer\x20(demand\x20matching)\x20instead'},{'source_element':'Incumbent\x20platform\x20user\x20account\x20/\x20login\x20system','mapping_note':'Identity\x20lives\x20in\x20wallets\x20and\x20Passports,\x20not\x20platform\x20accounts','reason':'WoWok\x20is\x20account-less\x20by\x20design\x20—\x20addresses\x20+\x20Passports\x20replace\x20platform\x20logins'},{'source_element':'Automatic\x20recurring\x20charges\x20(card\x20auto-debit)','mapping_note':'Recurring\x20charges\x20are\x20replaced\x20by\x20explicit\x20per-period\x20subscriber\x20signatures','reason':'Silent\x20auto-charge\x20is\x20an\x20anti-pattern\x20on\x20WoWok\x20—\x20renewal\x20requires\x20the\x20payer\x27s\x20signature\x20every\x20period'}];return a['industry']==='subscription'&&b['push']({'source_element':'Content\x20moderation\x20/\x20takedown\x20pipeline','mapping_note':'Only\x20content\x20hashes\x20live\x20on-chain;\x20content\x20bodies\x20stay\x20off-chain','reason':'Content\x20governance\x20is\x20structurally\x20out\x20of\x20scope\x20for\x20on-chain\x20objects\x20—\x20handle\x20it\x20at\x20the\x20hosting\x20layer'}),(a['industry']==='retail'||a['industry']==='rental')&&b['push']({'source_element':'Physical\x20logistics\x20/\x20courier\x20integration','mapping_note':'Logistics\x20stays\x20off-chain;\x20tracking\x20evidence\x20is\x20anchored\x20via\x20WIP\x20hashes','reason':'Carriers\x20are\x20external\x20systems\x20—\x20the\x20Machine\x20consumes\x20their\x20evidence,\x20not\x20their\x20API'}),b;}function manualReviewEntries(a){const b=[{'source_element':'Fee\x20and\x20split\x20parameters','mapping_note':'Template\x20defaults:\x20'+Object['entries'](a['fee_params'])['map'](([c,d])=>c+'='+d)['join'](',\x20'),'reason':'Confirm\x20or\x20override\x20each\x20parameter\x20before\x20generation'},{'source_element':'Operating\x20role','mapping_note':'Recommended:\x20'+a['recommended_role']+'\x20—\x20'+a['role_rationale'],'reason':'The\x20user\x20may\x20switch\x20role\x20(merchant\x20<->\x20supplier)\x20before\x20apply'},{'source_element':'Target\x20network','mapping_note':'Default\x20testnet\x20for\x20the\x20first\x20deployment','reason':'Mainnet\x20deployment\x20requires\x20explicit\x20user\x20confirmation'}];return a['keeper_dependencies']['length']>0x0&&b['push']({'source_element':'Off-chain\x20keeper\x20operations','mapping_note':'Declared\x20keepers:\x20'+a['keeper_dependencies']['join'](';\x20'),'reason':'Time-driven\x20transitions\x20only\x20ALLOW\x20advancement\x20—\x20someone\x20must\x20run\x20the\x20keepers'}),b;}function wowokAdvantages(a){const b=['Every\x20rule\x20is\x20an\x20immutable\x20on-chain\x20Guard\x20—\x20customers\x20can\x20verify\x20the\x20exact\x20policy\x20before\x20paying','Disputes\x20resolve\x20through\x20independent\x20Arbitration\x20with\x20a\x20funded\x20compensation\x20pool','Fund\x20splits\x20execute\x20by\x20contract\x20at\x20the\x20configured\x20release\x20points\x20—\x20no\x20platform\x20discretion'];return a['industry']==='subscription'&&b['push']('Per-period\x20explicit-signature\x20renewal\x20—\x20the\x20anti-auto-renew\x20trap\x20is\x20a\x20selling\x20point'),a['industry']==='freelance'&&b['push']('Chain-verifiable\x200%\x20(or\x20low)\x20commission\x20via\x20the\x20allocator\x20split\x20itself'),a['industry']==='travel'&&b['push']('Two-tier\x20allocation\x20pays\x20each\x20supplier\x20at\x20its\x20own\x20segment\x20release\x20—\x20multi-party\x20transparency'),a['industry']==='education'&&b['push']('Regulatory\x20prepay\x20caps\x20and\x20per-session\x20release\x20protect\x20students\x20from\x20run-away\x20institutions'),a['industry']==='rental'&&b['push']('Deposit\x20escrow\x20+\x20evidence-gated\x20deduction\x20—\x20neither\x20side\x20can\x20unilaterally\x20seize\x20the\x20deposit'),a['industry']==='retail'&&b['push']('Escrow\x20+\x20confirm-on-receipt\x20release\x20—\x20the\x20buyer\x27s\x20confirmation\x20is\x20the\x20only\x20release\x20trigger'),b;}function customizableModules(a){const b=['independent_arbitration','refund_guarantee','reputation_on_chain','wip_provenance'];switch(a['industry']){case'freelance':return[...b,'milestone_escrow','accept_timeout_protection'];case'rental':return[...b,'damage_attestation'];case'education':return[...b,'accept_timeout_protection'];case'travel':return[...b,'multi_tier_allocation','supplier_collaboration'];case'subscription':return[...b,'subscription_with_proof'];case'retail':return[...b,'accept_timeout_protection'];default:return b;}}export function planMigration(a){let b;if(a['template_id']){b=getTemplate(a['template_id']);if(b&&a['industry']&&b['industry']!==a['industry']){const c=matchTemplate(a['industry']+'\x20'+a['description']);if(c&&c['template']['industry']===a['industry'])b=c['template'];}}else{const d=a['industry']?a['industry']+'\x20'+a['description']:a['description'],e=matchTemplate(d);b=e?.['template'],!b&&a['industry']&&(b=listTemplates()['templates']['find'](f=>f['industry']===a['industry']&&f['archetype']==='leader'));}if(!b)return undefined;return{'source':{'url':a['url'],'description':a['description'],'detected_industry':b['industry'],'matched_template':b['id']},'mapped':genericMappedEntries(b),'unmapped':genericUnmappedEntries(b),'manual_review':manualReviewEntries(b),'wowok_advantages':wowokAdvantages(b),'customizable_modules':customizableModules(b),'role_assessment':{'recommended':b['recommended_role'],'rationale':b['role_rationale'],'alternatives':['merchant','supplier','both']['filter'](f=>f!==b['recommended_role'])},'risk_check':dryRunRiskCheck(b),...b['conditional_guards']?.['length']?{'questions':[...new Set(b['conditional_guards']['map'](f=>f['param']))]['map'](f=>{const g=b['conditional_guards']['find'](h=>h['param']===f);return{'param':f,'question':g['question'],'options':[...g['values']],'default':String(b['fee_params'][f]??'')};})}:{},'network':a['network']??'testnet'};}
|