@wowok/agent-mcp 3.2.3 → 3.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/chain-semantics/field-capability.js +1 -1
  2. package/dist/chain-semantics/freeze-map.js +1 -1
  3. package/dist/chain-semantics/fund-flow.js +1 -1
  4. package/dist/chain-semantics/guard-verbs.js +1 -1
  5. package/dist/communication/proof-reuse.d.ts +9 -0
  6. package/dist/communication/proof-reuse.js +1 -0
  7. package/dist/evaluation/builtins/graph-service.spec.js +1 -1
  8. package/dist/evaluation/engine.js +1 -1
  9. package/dist/experience/realtime-feedback.js +1 -1
  10. package/dist/graph/onchain/expand.js +1 -1
  11. package/dist/graph/onchain/exposure.js +1 -1
  12. package/dist/harness/recover.js +1 -1
  13. package/dist/knowledge/allocation-ledger.js +1 -1
  14. package/dist/knowledge/builtin-templates.d.ts +1 -1
  15. package/dist/knowledge/builtin-templates.js +1 -1
  16. package/dist/knowledge/getting-started.js +1 -1
  17. package/dist/knowledge/guard-bindings.js +1 -1
  18. package/dist/knowledge/guard-design-patterns.d.ts +1 -1
  19. package/dist/knowledge/guard-design-patterns.js +1 -1
  20. package/dist/knowledge/guard-ledger.js +1 -1
  21. package/dist/knowledge/guard-risk.js +1 -1
  22. package/dist/knowledge/guard-templates.js +1 -1
  23. package/dist/knowledge/index.js +1 -1
  24. package/dist/knowledge/industry-registry.js +1 -1
  25. package/dist/knowledge/jsonrpc-enum.js +1 -1
  26. package/dist/knowledge/machine-ledger.js +1 -1
  27. package/dist/knowledge/machine-templates.js +1 -1
  28. package/dist/knowledge/progress-ledger.js +1 -1
  29. package/dist/knowledge/scenario-modes.d.ts +1 -0
  30. package/dist/knowledge/template-loader.d.ts +1 -0
  31. package/dist/knowledge/template-loader.js +1 -1
  32. package/dist/knowledge/template-registry.js +1 -1
  33. package/dist/knowledge/template-scanner.js +1 -1
  34. package/dist/monitor/MonitorLoop.js +1 -1
  35. package/dist/participation/radar-core.js +1 -1
  36. package/dist/playbooks/service-build/business-puzzle.js +1 -1
  37. package/dist/playbooks/service-build/machine-panorama.js +1 -1
  38. package/dist/playbooks/service-build/object-panorama.js +1 -1
  39. package/dist/playbooks/service-build/participation-radar.js +1 -1
  40. package/dist/playbooks/service-build/relationship-profile.js +1 -1
  41. package/dist/playbooks/service-build/service-panorama.js +1 -1
  42. package/dist/playbooks/service-build/service-quote.js +1 -1
  43. package/dist/playbooks/service-build/service-quote.spec.d.ts +1 -0
  44. package/dist/playbooks/service-build/service-quote.spec.js +1 -0
  45. package/dist/review/index.js +1 -1
  46. package/dist/safety/confirm-gate.js +1 -1
  47. package/dist/schema/call/arbitration.js +1 -1
  48. package/dist/schema/call/base.d.ts +4 -0
  49. package/dist/schema/call/base.js +1 -1
  50. package/dist/schema/call/bridge.d.ts +1 -0
  51. package/dist/schema/call/error-codes.d.ts +1 -1
  52. package/dist/schema/call/error-codes.js +1 -1
  53. package/dist/schema/call/machine.js +1 -1
  54. package/dist/schema/call/semantic.js +1 -1
  55. package/dist/schema/call/service.js +1 -1
  56. package/dist/schema/common/index.js +1 -1
  57. package/dist/schema/interaction/index.d.ts +1 -1
  58. package/dist/schema/local/index.d.ts +10 -0
  59. package/dist/schema/local/index.js +1 -1
  60. package/dist/schema/query/bi.d.ts +26 -0
  61. package/dist/schema/query/bi.js +1 -1
  62. package/dist/schema/schema-version.js +1 -1
  63. package/dist/schema-query-impl/index.js +1 -1
  64. package/dist/schemas/account_operation.output.json +1 -0
  65. package/dist/schemas/bridge_operation.output.json +1 -0
  66. package/dist/schemas/index.json +1 -1
  67. package/dist/schemas/local_cache_operation.output.json +1 -0
  68. package/dist/schemas/local_history_operation.output.json +1 -0
  69. package/dist/schemas/local_info_operation.output.json +1 -0
  70. package/dist/schemas/local_mark_operation.output.json +1 -0
  71. package/dist/schemas/onchain_operations.output.json +1 -0
  72. package/dist/schemas/onchain_operations.schema.json +3 -3
  73. package/dist/schemas/onchain_operations_arbitration.schema.json +1 -1
  74. package/dist/schemas/onchain_operations_machine.schema.json +1 -1
  75. package/dist/schemas/onchain_operations_service.schema.json +1 -1
  76. package/dist/schemas/query_toolkit.output.json +91 -7
  77. package/dist/tools/handlers/config.js +1 -1
  78. package/dist/tools/handlers/messenger.js +1 -1
  79. package/dist/tools/handlers/onchain.js +1 -1
  80. package/dist/tools/move-fn-index.gen.js +1 -1
  81. package/dist/tools/wrap.js +1 -1
  82. package/package.json +2 -2
@@ -1 +1 @@
1
- import{readFileSync,existsSync,writeFileSync,mkdirSync}from'fs';import{resolve,join,dirname}from'path';import{fileURLToPath}from'url';import{TOOLS_REFERENCE,getToolReference,searchToolReference,getToolSequence}from'../knowledge/tools-reference.js';import{GUARD_DESIGN_PATTERNS,getGuardDesignPattern,GUARD_DESIGN_PATTERNS_VERSION,GUARD_SCHEMA_NOTES}from'../knowledge/guard-design-patterns.js';import{OBJECT_REUSE_RULES,CREATE_VS_MODIFY_PATTERN,IMMUTABILITY_RULES,OPERATION_TYPE_CLASSIFICATION,OPERATION_CLASS_META,NAMING_CONVENTIONS,SAFETY_RULES_VERSION}from'../knowledge/safety-rules.js';import{listTemplates as a423a,getTemplateDetail,instantiateTemplate,getTemplateCounts,TEMPLATE_OBJECT_TYPES}from'../knowledge/template-registry.js';import{lintGuard,formatLintResult}from'../knowledge/guard-lint.js';import{renderGuardTreeIndented,renderGuardMermaid,walkGuardTree}from'../knowledge/guard-render.js';import{getGuardQueryByIdOrName}from'../schema/utils/guard-query-utils.js';const __filename=fileURLToPath(import.meta.url),__dirname=fileURLToPath(new URL('.',import.meta.url)),SCHEMAS_DIR=resolve(__dirname,'../../dist/schemas'),GUARD_TEMPLATES_PATH_SCRIPTS=resolve(__dirname,'../../scripts/guard-templates.json'),GUARD_TEMPLATES_PATH_DIST=resolve(__dirname,'../../dist/schemas/guard-templates.json'),GUARD_TEMPLATES_PATH=existsSync(GUARD_TEMPLATES_PATH_SCRIPTS)?GUARD_TEMPLATES_PATH_SCRIPTS:GUARD_TEMPLATES_PATH_DIST,WORKSPACE_TMP_DIR=resolve(process['cwd'](),'.trae','tmp');export function areSchemasAvailable(){return existsSync(SCHEMAS_DIR)&&existsSync(join(SCHEMAS_DIR,'index.json'));}export function getSchemaIndex(){try{const a=join(SCHEMAS_DIR,'index.json');if(!existsSync(a))return null;const b=readFileSync(a,'utf-8');return JSON['parse'](b);}catch{return null;}}export function listSchemas(){const a=getSchemaIndex();if(!a)return[];return[...a['tools']||[],...a['operations']||[]];}export function getSchema(a){try{let b=join(SCHEMAS_DIR,a+'.schema.json');!existsSync(b)&&(b=join(SCHEMAS_DIR,a+'.json'));if(!existsSync(b))return null;const c=readFileSync(b,'utf-8'),d=JSON['parse'](c);return resolveSchemaRefs(d);}catch{return null;}}export function getOutputSchema(a){try{const b=join(SCHEMAS_DIR,a+'.output.json');if(!existsSync(b))return null;const c=readFileSync(b,'utf-8'),d=JSON['parse'](c);return resolveSchemaRefs(d);}catch{return null;}}export function getGuardTemplates(a){try{if(!existsSync(GUARD_TEMPLATES_PATH))return null;const b=readFileSync(GUARD_TEMPLATES_PATH,'utf-8'),c=JSON['parse'](b);if(!a)return{'version':c['version'],'description':c['description'],'templates':(c['templates']||[])['map'](e=>({'name':e['name'],'title':e['title'],'description':e['description'],'use_case':e['use_case']})),'query_reference':c['query_reference'],'node_return_types':c['node_return_types']};const d=(c['templates']||[])['find'](e=>e['name']===a);if(!d)return null;return d;}catch{return null;}}export function getSchemaField(a,b){const c=getSchema(a);if(!c)return null;const d=b['split']('.')['filter'](Boolean);let e=c;for(const f of d){if(!e||typeof e!=='object')return null;if(e['properties']&&f in e['properties']){e=e['properties'][f];continue;}if(e['items']&&typeof e['items']==='object'){if(/^\d+$/['test'](f)){e=e['items'];continue;}if(e['items']['properties']&&f in e['items']['properties']){e=e['items']['properties'][f];continue;}}if(Array['isArray'](e['oneOf'])||Array['isArray'](e['anyOf'])){const g=e['oneOf']??e['anyOf'];for(const h of g){if(h&&typeof h==='object'&&h['properties']&&f in h['properties']){e=h['properties'][f];break;}}continue;}if(f in e){e=e[f];continue;}return null;}return e;}function resolveSchemaRefs(a,b=new Set()){if(!a||typeof a!=='object')return a;if(Array['isArray'](a))return a['map'](d=>resolveSchemaRefs(d,b));const c={};for(const [d,e]of Object['entries'](a)){if(d==='$ref'&&typeof e==='string'){if(e['startsWith']('#'))c[d]=e;else{const f=loadRefSchema(e,b);f&&Object['assign'](c,resolveSchemaRefs(f,b));}}else typeof e==='object'?c[d]=resolveSchemaRefs(e,b):c[d]=e;}return c;}function loadRefSchema(a,b){if(a['startsWith']('#'))return null;if(b['has'](a))return{'description':'Circular\x20reference\x20to\x20'+a};b['add'](a);try{const c=join(SCHEMAS_DIR,a);if(!existsSync(c))return null;const d=readFileSync(c,'utf-8');return JSON['parse'](d);}catch{return null;}}export function searchSchemas(a){const b=listSchemas(),c=a['toLowerCase']();return b['filter'](d=>{const e=d['name']['toLowerCase']()['includes'](c),f=d['title']?.['toLowerCase']()['includes'](c),g=d['description']?.['toLowerCase']()['includes'](c);return e||f||g;});}export function listOperations(){const a=getSchemaIndex();if(!a)return[];return(a['operations']||[])['filter'](b=>b['name']['startsWith']('onchain_operations_'));}function writeResponseToFile(a,b){try{let c;if(b)c=resolve(process['cwd'](),b);else{!existsSync(WORKSPACE_TMP_DIR)&&mkdirSync(WORKSPACE_TMP_DIR,{'recursive':!![]});const g=Date['now']();c=join(WORKSPACE_TMP_DIR,'schema-'+g+'.json');}const d=dirname(c);!existsSync(d)&&mkdirSync(d,{'recursive':!![]});const f=typeof a==='string'?a:JSON['stringify'](a,null,0x2);return writeFileSync(c,f,'utf-8'),c;}catch(h){return null;}}const INLINE_CHAR_LIMIT=0x20*0x400,AUTO_OVERFLOW_DIR='.wowok/tmp';function unionVariantLabel(a){if(!a||typeof a!=='object')return'variant';const b=a['properties']&&typeof a['properties']==='object'?a['properties']:undefined;if(b)for(const [c,d]of Object['entries'](b)){if(d&&typeof d==='object'&&d['const']!==undefined)return c+'='+String(d['const']);}return typeof a['title']==='string'?a['title']:'variant';}export function buildSchemaSummary(a){const b=[];a&&typeof a['title']==='string'&&b['push']('Title:\x20'+a['title']);const c=a&&typeof a==='object'?a['properties']:undefined;if(c&&typeof c==='object'&&!Array['isArray'](c)){const d=Array['isArray'](a['required'])?a['required']:[],e=Object['keys'](c);b['push']('Top-level\x20fields\x20('+e['length']+',\x20*\x20=\x20required):');for(const f of e['slice'](0x0,0x28)){const g=c[f]??{},h=Array['isArray'](g['type'])?g['type']['join']('|'):g['type']??(g['$ref']?'ref':g['anyOf']||g['oneOf']?'union':'any'),i=d['includes'](f)?'*':'',j=typeof g['description']==='string'&&g['description']['length']>0x0?'\x20—\x20'+g['description']['split']('\x0a')[0x0]['slice'](0x0,0x50):'';b['push']('\x20\x20-\x20'+f+i+':\x20'+h+j);}e['length']>0x28&&b['push']('\x20\x20-\x20...and\x20'+(e['length']-0x28)+'\x20more\x20—\x20use\x20action=\x27get_field\x27\x20with\x20field_path\x20to\x20inspect');}else{if(a&&(Array['isArray'](a['oneOf'])||Array['isArray'](a['anyOf']))){const k=a['oneOf']??a['anyOf'];b['push']('Union\x20of\x20'+k['length']+'\x20variants:');for(const m of k['slice'](0x0,0x28)){const o=m&&typeof m['description']==='string'&&m['description']['length']>0x0?'\x20—\x20'+m['description']['split']('\x0a')[0x0]['slice'](0x0,0x50):'';b['push']('\x20\x20-\x20'+unionVariantLabel(m)+o);}k['length']>0x28&&b['push']('\x20\x20-\x20...and\x20'+(k['length']-0x28)+'\x20more');const l=k['filter'](q=>q&&typeof q==='object'&&q['properties']&&typeof q['properties']==='object');if(l['length']===k['length']&&l['length']>0x0){const q=Object['keys'](l[0x0]['properties'])['filter'](r=>l['every'](s=>Object['prototype']['hasOwnProperty']['call'](s['properties'],r)));b['push'](q['length']>0x0?'Common\x20fields\x20(declared\x20by\x20ALL\x20'+l['length']+'\x20variants):\x20'+q['join'](',\x20')+'.':'No\x20field\x20is\x20declared\x20by\x20all\x20'+l['length']+'\x20variants\x20—\x20each\x20variant\x20takes\x20its\x20own\x20parameters.');}else b['push']('Field\x20names\x20differ\x20per\x20variant\x20—\x20read\x20the\x20variant\x27s\x20own\x20list\x20above.\x20'+'The\x20discriminator\x20(\x22operation\x22\x20and\x20friends)\x20is\x20the\x20only\x20shared\x20key.');for(const r of k['slice'](0x0,0x28)){const s=r&&typeof r==='object'&&r['properties']&&typeof r['properties']==='object'?Object['keys'](r['properties']):[];if(s['length']===0x0)continue;b['push']('\x20\x20\x20\x20'+unionVariantLabel(r)+'\x20fields:\x20'+s['join'](',\x20'));}b['push']('Drill\x20into\x20the\x20variant\x20you\x20need\x20with\x20action=\x27get_field\x27\x20(name\x20+\x20field_path)\x20—\x20the\x20lists\x20above\x20are\x20a\x20summary,\x20not\x20the\x20schema.');}else b['push']('No\x20top-level\x20properties\x20map\x20—\x20use\x20action=\x27get_field\x27\x20with\x20a\x20field_path\x20to\x20inspect\x20this\x20schema.');}return b['join']('\x0a');}export function autoOverflowToFile(a,b){try{const c=JSON['stringify'](a)['length'];if(c<=INLINE_CHAR_LIMIT)return null;const d=process['env']['WOWOK_SCHEMA_TMP_DIR'],e=d?resolve(d):resolve(process['cwd'](),AUTO_OVERFLOW_DIR);!existsSync(e)&&mkdirSync(e,{'recursive':!![]});const f=b['replace'](/[^a-zA-Z0-9_-]/g,'_'),g=f+'.schema.json',h=join(e,g);return writeFileSync(h,JSON['stringify'](a,null,0x2),'utf-8'),{'absolute_path':h,'relative_path':d?h:join(AUTO_OVERFLOW_DIR,g),'bytes':c,'summary':buildSchemaSummary(a)};}catch{return null;}}export function processSchemaQuery(a){const {action:b,name:c,query:d,field_path:f,template:g,output_file:h,object_type:i,params:j}=a;if(b==='get_guard_templates'){const k=getGuardTemplates(g);if(!k)return{'success':![],'action':b,'data':null,'message':g?'Guard\x20template\x20\x27'+g+'\x27\x20not\x20found.\x20Omit\x20\x27template\x27\x20to\x20list\x20all\x20available\x20templates.':'Guard\x20templates\x20file\x20not\x20found.\x20Ensure\x20scripts/guard-templates.json\x20exists.','suggestions':['Omit\x20\x27template\x27\x20to\x20list\x20all\x20available\x20templates.','Available\x20template\x20names:\x20signer_verification,\x20progress_node_check,\x20order_owner_verification,\x20service_belonging_check,\x20reward_not_claimed,\x20combined_reward_guard']};if(h){const l=writeResponseToFile(k,h);if(l)return{'success':!![],'action':b,'data':null,'message':'Guard\x20template'+(g?'\x20\x27'+g+'\x27':'s')+'\x20written\x20to\x20file:\x20'+l,'output_file_path':l,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+l]};}return{'success':!![],'action':b,'data':k,'message':g?'Retrieved\x20Guard\x20template:\x20'+g:'Retrieved\x20'+(Array['isArray'](k['templates'])?k['templates']['length']:0x0)+'\x20Guard\x20templates'};}if(b==='get_templates'){if(!g){const p=a423a(i),q=getTemplateCounts(),r={'total':p['length'],'filter':i??null,'counts_by_object_type':q,'templates':p};if(h){const s=writeResponseToFile(r,h);if(s)return{'success':!![],'action':b,'data':null,'message':p['length']+'\x20templates\x20written\x20to\x20file:\x20'+s,'output_file_path':s,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+s]};}return{'success':!![],'action':b,'data':r,'message':p['length']+'\x20template(s)'+(i?'\x20for\x20object_type=\x27'+i+'\x27':'')+'\x20'+('(total\x20registry:\x20'+Object['values'](q)['reduce']((t,u)=>t+u,0x0)+'\x20across\x20'+TEMPLATE_OBJECT_TYPES['length']+'\x20object\x20types).\x20')+'Provide\x20\x27template\x27\x20(id)\x20for\x20full\x20detail;\x20add\x20\x27params\x27\x20(JSON\x20string)\x20to\x20instantiate.'};}if(!j){const t=getTemplateDetail(g);if(!t)return{'success':![],'action':b,'data':null,'message':'Template\x20\x27'+g+'\x27\x20not\x20found\x20in\x20the\x20unified\x20registry.','suggestions':['Omit\x20\x27template\x27\x20to\x20list\x20all\x20template\x20metadata\x20(id\x20+\x20object_type\x20+\x20parameters).','Filter\x20by\x20object_type:\x20'+TEMPLATE_OBJECT_TYPES['join'](',\x20')]};if(h){const u=writeResponseToFile(t,h);if(u)return{'success':!![],'action':b,'data':null,'message':'Template\x20\x27'+g+'\x27\x20detail\x20written\x20to\x20file:\x20'+u,'output_file_path':u,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+u]};}return{'success':!![],'action':b,'data':t,'message':'Template\x20\x27'+g+'\x27\x20('+t['object_type']+',\x20'+(t['instantiable']?'instantiable':'guidance-only')+').\x20'+'To\x20instantiate,\x20call\x20again\x20with\x20\x27params\x27\x20=\x20JSON\x20object\x20of\x20the\x20declared\x20parameters.'};}let m;try{const v=JSON['parse'](j);if(!v||typeof v!=='object'||Array['isArray'](v))return{'success':![],'action':b,'data':null,'message':'\x27params\x27\x20must\x20be\x20a\x20JSON\x20object\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27),\x20got\x20'+(Array['isArray'](v)?'array':typeof v)+'.'};m=v;}catch(w){return{'success':![],'action':b,'data':null,'message':'Failed\x20to\x20parse\x20\x27params\x27\x20as\x20JSON:\x20'+(w instanceof Error?w['message']:String(w)),'suggestions':['Example:\x20params=\x27{\x22whitelist\x22:[\x220xabc...\x22]}\x27']};}const n=instantiateTemplate(g,m);if(!n['ok'])return{'success':![],'action':b,'data':n['guidance']!==undefined?{'guidance':n['guidance']}:null,'message':'Instantiation\x20failed\x20for\x20\x27'+g+'\x27:\x20'+n['error'],'suggestions':n['missing_params']?['Missing\x20required\x20params:\x20'+n['missing_params']['join'](',\x20'),'Call\x20with\x20\x27template\x27\x20only\x20(no\x20\x27params\x27)\x20to\x20see\x20full\x20parameter\x20declarations.']:['Call\x20with\x20\x27template\x27\x20only\x20(no\x20\x27params\x27)\x20to\x20see\x20full\x20parameter\x20declarations.']};const o={'object_type':n['object_type'],'template_id':n['template_id'],'body':n['body'],...n['notes']?{'notes':n['notes']}:{}};if(h){const x=writeResponseToFile(o,h);if(x)return{'success':!![],'action':b,'data':null,'message':'Instantiated\x20template\x20\x27'+g+'\x27\x20written\x20to\x20file:\x20'+x,'output_file_path':x,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+x]};}return{'success':!![],'action':b,'data':o,'message':'Instantiated\x20\x27'+g+'\x27\x20('+n['object_type']+').\x20'+'Review\x20the\x20body\x20against\x20the\x20onchain_operations\x20schema\x20before\x20submitting.'};}if(b==='get_tool_reference'){if(c){const z=getToolReference(c);if(!z)return{'success':![],'action':b,'data':null,'message':'Tool\x20\x27'+c+'\x27\x20not\x20found\x20in\x20the\x20tool\x20reference.','suggestions':['Omit\x20\x27name\x27\x20to\x20list\x20all\x20tools.','Available\x20tools:\x20'+TOOLS_REFERENCE['map'](B=>B['name'])['join'](',\x20')]};const A=getToolSequence(c);return{'success':!![],'action':b,'data':{'tool':z,'call_sequence':A??null},'message':'Retrieved\x20tool\x20reference:\x20'+c};}if(d){const B=searchToolReference(d);return{'success':!![],'action':b,'data':{'tools':B,'count':B['length']},'message':'Found\x20'+B['length']+'\x20tool(s)\x20matching\x20\x27'+d+'\x27','suggestions':B['length']===0x0?['Try\x20a\x20broader\x20keyword\x20(e.g.\x20\x27onchain\x27,\x20\x27guard\x27,\x20\x27schema\x27),\x20or\x20omit\x20\x27query\x27\x20to\x20list\x20all\x20tools.']:undefined};}const y=TOOLS_REFERENCE['map'](C=>({'name':C['name'],'summary':C['summary'],'actions':C['actions']??[],'notes':C['notes']??[]}));return{'success':!![],'action':b,'data':{'tools':y,'count':y['length']},'message':'Retrieved\x20reference\x20for\x20'+y['length']+'\x20MCP\x20tools.\x20Pass\x20name=\x27<tool>\x27\x20for\x20full\x20detail\x20(params,\x20prerequisites,\x20follow-ups).'};}if(b==='get_guard_design_patterns'){if(c){const D=getGuardDesignPattern(c);if(!D)return{'success':![],'action':b,'data':null,'message':'Guard\x20design\x20pattern\x20\x27'+c+'\x27\x20not\x20found.','suggestions':['Omit\x20\x27name\x27\x20to\x20list\x20the\x20full\x20catalog.','Available\x20pattern\x20ids:\x20'+GUARD_DESIGN_PATTERNS['map'](E=>E['id'])['join'](',\x20')]};return{'success':!![],'action':b,'data':{'pattern':D},'message':'Retrieved\x20Guard\x20design\x20pattern:\x20'+c};}if(d){const E=GUARD_DESIGN_PATTERNS['filter'](G=>G['host']===d),F=E['length']>0x0?E:GUARD_DESIGN_PATTERNS['filter'](G=>G['business_requirement']['toLowerCase']()['includes'](d['toLowerCase']())||G['logic_summary']['toLowerCase']()['includes'](d['toLowerCase']()));return{'success':!![],'action':b,'data':{'patterns':F,'count':F['length'],'filtered_by':E['length']>0x0?'host':'keyword','schema_notes':GUARD_SCHEMA_NOTES},'message':'Found\x20'+F['length']+'\x20Guard\x20design\x20pattern(s)\x20matching\x20\x27'+d+'\x27','suggestions':F['length']===0x0?['Filter\x20by\x20host:\x20service_buy_guard,\x20service_allocator_guard,\x20machine_forward,\x20progress_submission,\x20reward_claim,\x20repository_write,\x20arbitration_usage,\x20arbitration_voting,\x20gen_passport']:undefined};}const C=GUARD_DESIGN_PATTERNS['map'](G=>({'id':G['id'],'business_requirement':G['business_requirement'],'host':G['host'],'data_source':G['data_source'],'verifier_level':G['verifier_level'],'logic_summary':G['logic_summary'],'key_queries':G['key_queries'],'notes':G['notes']??[]}));return{'success':!![],'action':b,'data':{'patterns':C,'count':C['length'],'version':GUARD_DESIGN_PATTERNS_VERSION,'schema_notes':GUARD_SCHEMA_NOTES},'message':'Retrieved\x20'+C['length']+'\x20Guard\x20design\x20patterns.\x20Pass\x20name=\x27<pattern_id>\x27\x20for\x20full\x20detail\x20(witness\x20types,\x20mitigated\x20risks,\x20industries).'};}if(b==='get_safety_rules')return{'success':!![],'action':b,'data':{'version':SAFETY_RULES_VERSION,'object_reuse_rules':OBJECT_REUSE_RULES,'create_vs_modify_pattern':CREATE_VS_MODIFY_PATTERN,'immutability_rules':IMMUTABILITY_RULES,'operation_type_classification':OPERATION_TYPE_CLASSIFICATION,'operation_class_meta':OPERATION_CLASS_META,'naming_conventions':NAMING_CONVENTIONS},'message':'Retrieved\x20safety\x20rule\x20tables\x20(reuse\x20/\x20immutability\x20/\x20operation\x20classification\x20/\x20naming).\x20'+'Key\x20points:\x20prefer\x20REUSING\x20existing\x20objects\x20(string\x20reference\x20=\x20reuse,\x20object\x20shape\x20=\x20create);\x20'+'Machine\x20publish\x20locks\x20nodes/pairs/forwards,\x20Service\x20publish\x20locks\x20machine/order_allocators/arbitrations\x20(sales\x20stays\x20mutable);\x20'+'Guard\x20is\x20CREATE-only\x20immutable;\x20on-chain\x20writes\x20require\x20explicit\x20user\x20confirmation.'};if(!areSchemasAvailable())return{'success':![],'action':b,'data':null,'message':'Schema\x20files\x20are\x20not\x20available.\x20Please\x20run\x20\x27npm\x20run\x20generate:schemas\x27\x20first.','suggestions':['Run\x20\x27npm\x20run\x20generate:schemas\x27\x20to\x20generate\x20schema\x20files','Ensure\x20the\x20dist/schemas\x20directory\x20exists']};switch(b){case'list':{const G=listSchemas();return{'success':!![],'action':b,'data':G,'message':'Found\x20'+G['length']+'\x20available\x20schemas'};}case'get':{if(!c)return{'success':![],'action':b,'data':null,'message':'Schema\x20name\x20is\x20required\x20for\x20\x27get\x27\x20action','suggestions':['Provide\x20a\x20schema\x20name','Use\x20\x27list\x27\x20action\x20to\x20see\x20available\x20schemas']};const H=getSchema(c);if(!H){const J=searchSchemas(c)['slice'](0x0,0x5);return{'success':![],'action':b,'data':null,'message':'Schema\x20\x27'+c+'\x27\x20not\x20found','suggestions':J['length']>0x0?J['map'](K=>'Did\x20you\x20mean:\x20'+K['name']+'?'):['Use\x20\x27list\x27\x20action\x20to\x20see\x20available\x20schemas']};}if(h){const K=writeResponseToFile(H,h);if(K)return{'success':!![],'action':b,'data':null,'message':'Schema\x20\x27'+c+'\x27\x20written\x20to\x20file:\x20'+K,'output_file_path':K,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+K]};}const I=autoOverflowToFile(H,c);if(I)return{'success':!![],'action':b,'data':null,'message':'Schema\x20\x27'+c+'\x27\x20is\x20large\x20('+Math['round'](I['bytes']/0x400)+'\x20KB)\x20—\x20'+'written\x20to\x20file\x20instead\x20of\x20inlining\x20to\x20protect\x20your\x20context.','output_file_path':I['absolute_path'],'inline_summary':I['summary'],'suggestions':['Read\x20the\x20full\x20file\x20with\x20the\x20Read\x20tool:\x20'+I['absolute_path'],'If\x20the\x20sandbox\x20blocks\x20that\x20path,\x20resolve\x20the\x20relative\x20path\x20\x27'+I['relative_path']+'\x27\x20against\x20the\x20workspace\x20root\x20and\x20read\x20that.','Without\x20file\x20access,\x20query\x20specific\x20fields\x20via\x20action=\x27get_field\x27\x20with\x20name=\x27'+c+'\x27\x20and\x20a\x20field_path\x20from\x20the\x20summary\x20below.']};return{'success':!![],'action':b,'data':H,'message':'Retrieved\x20schema:\x20'+c};}case'get_field':{if(!c||!f)return{'success':![],'action':b,'data':null,'message':'Both\x20\x27name\x27\x20and\x20\x27field_path\x27\x20are\x20required\x20for\x20\x27get_field\x27\x20action','suggestions':['Example:\x20{action:\x20\x27get_field\x27,\x20name:\x20\x27onchain_operations_machine\x27,\x20field_path:\x20\x27data.node\x27}','Use\x20\x27get\x27\x20action\x20to\x20retrieve\x20the\x20full\x20schema']};const L=getSchemaField(c,f);if(!L)return{'success':![],'action':b,'data':null,'message':'Field\x20path\x20\x27'+f+'\x27\x20not\x20found\x20in\x20schema\x20\x27'+c+'\x27','suggestions':['Check\x20the\x20field\x20path\x20(dot-separated,\x20e.g.\x20\x27data.node\x27)','Use\x20\x27get\x27\x20action\x20to\x20see\x20the\x20full\x20schema\x20structure']};return{'success':!![],'action':b,'data':L,'message':'Retrieved\x20field\x20\x27'+f+'\x27\x20from\x20schema\x20\x27'+c+'\x27'};}case'search':{if(!d)return{'success':![],'action':b,'data':null,'message':'Search\x20query\x20is\x20required\x20for\x20\x27search\x27\x20action'};const M=searchSchemas(d);return{'success':!![],'action':b,'data':M,'message':'Found\x20'+M['length']+'\x20schemas\x20matching\x20\x27'+d+'\x27'};}case'list_operations':{const N=listOperations();return{'success':!![],'action':b,'data':N,'message':'Found\x20'+N['length']+'\x20on-chain\x20operations'};}case'get_output':{if(!c)return{'success':![],'action':b,'data':null,'message':'Tool\x20name\x20is\x20required\x20for\x20\x27get_output\x27\x20action','suggestions':['Provide\x20a\x20tool\x20name','Use\x20\x27list\x27\x20action\x20to\x20see\x20available\x20tools\x20and\x20their\x20outputPath']};const O=getOutputSchema(c);if(!O){const Q=listSchemas(),R=Q['find'](T=>T['name']===c);if(R)return{'success':![],'action':b,'data':null,'message':'Tool\x20\x27'+c+'\x27\x20exists\x20but\x20has\x20no\x20output\x20schema\x20file.\x20The\x20tool\x20may\x20not\x20declare\x20an\x20outputSchema,\x20or\x20the\x20schema\x20file\x20was\x20not\x20generated.','suggestions':['Use\x20\x27get\x27\x20action\x20with\x20name=\x27'+c+'\x27\x20to\x20retrieve\x20its\x20input\x20schema']};const S=searchSchemas(c)['slice'](0x0,0x5);return{'success':![],'action':b,'data':null,'message':'Tool\x20\x27'+c+'\x27\x20not\x20found','suggestions':S['length']>0x0?S['map'](T=>'Did\x20you\x20mean:\x20'+T['name']+'?'):['Use\x20\x27list\x27\x20action\x20to\x20see\x20available\x20tools']};}if(h){const T=writeResponseToFile(O,h);if(T)return{'success':!![],'action':b,'data':null,'message':'Output\x20schema\x20\x27'+c+'\x27\x20written\x20to\x20file:\x20'+T,'output_file_path':T,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+T]};}const P=autoOverflowToFile(O,c);if(P)return{'success':!![],'action':b,'data':null,'message':'Output\x20schema\x20\x27'+c+'\x27\x20is\x20large\x20('+Math['round'](P['bytes']/0x400)+'\x20KB)\x20—\x20'+'written\x20to\x20file\x20instead\x20of\x20inlining\x20to\x20protect\x20your\x20context.','output_file_path':P['absolute_path'],'inline_summary':P['summary'],'suggestions':['Read\x20the\x20full\x20file\x20with\x20the\x20Read\x20tool:\x20'+P['absolute_path'],'If\x20the\x20sandbox\x20blocks\x20that\x20path,\x20resolve\x20the\x20relative\x20path\x20\x27'+P['relative_path']+'\x27\x20against\x20the\x20workspace\x20root\x20and\x20read\x20that.','Without\x20file\x20access,\x20query\x20specific\x20fields\x20via\x20action=\x27get_field\x27\x20with\x20name=\x27'+c+'\x27\x20and\x20a\x20field_path\x20from\x20the\x20summary\x20below.']};return{'success':!![],'action':b,'data':O,'message':'Retrieved\x20output\x20schema:\x20'+c};}default:return{'success':![],'action':b,'data':null,'message':'Unknown\x20action:\x20'+b,'suggestions':['Use\x20\x27list\x27,\x20\x27get\x27,\x20\x27get_field\x27,\x20\x27get_output\x27,\x20\x27search\x27,\x20\x27list_operations\x27,\x20\x27get_guard_templates\x27,\x20\x27get_tool_reference\x27,\x20\x27get_guard_design_patterns\x27,\x20\x27get_safety_rules\x27,\x20\x27get_templates\x27,\x20or\x20\x27analyze_guard_semantics\x27']};}}const GUARD_SEMANTICS_READING_CHECKLIST=['WHO\x20can\x20satisfy\x20this\x20Guard\x20(identity:\x20Signer\x20bindings,\x20Entity\x20membership,\x20allowlists)?','WHEN\x20can\x20it\x20be\x20satisfied\x20(time:\x20Clock\x20comparisons,\x20deadlines,\x20windows)?','WHAT\x20evidence\x20must\x20the\x20caller\x20submit\x20(b_submission\x20table\x20entries\x20—\x20Payment/Order/Proof\x20objects)?','WHICH\x20on-chain\x20data\x20does\x20it\x20read,\x20and\x20can\x20that\x20data\x20change\x20(Repository\x20entries\x20are\x20MUTABLE\x20—\x20who\x20controls\x20the\x20writes)?','WHAT\x20does\x20the\x20counterparty\x20gain/lose\x20in\x20each\x20branch\x20of\x20the\x20logic\x20tree?','ARE\x20there\x20error-level\x20diagnostics\x20or\x20critical\x20risks\x20(they\x20block\x20or\x20endanger\x20execution)?'];export async function analyzeGuardSemantics(a){const b=await lintGuard(a,{'auto_fix':![]}),c={'root':a['root'],'table':(a['table']??[])['map'](k=>({'identifier':k['identifier'],'name':k['name'],'value_type':k['value_type']??'Address','b_submission':k['b_submission']??![],'value':k['value']})),'guardName':a['description']??null,'rely':a['rely']??null},d=renderGuardTreeIndented(c),e=renderGuardMermaid(a['root']),f=new Set(),g=[];let h=![],i=![];walkGuardTree(a['root'],k=>{if(k['type']==='context'){if(k['context']==='Clock')h=!![];if(k['context']==='Signer')i=!![];}if(k['type']==='query'&&k['query']!==undefined&&k['query']!==null){if(typeof k['query']==='number'){const l=getGuardQueryByIdOrName(k['query']);if(l)f['add'](l['id']);else g['push'](k['query']);}else{const m=getGuardQueryByIdOrName(k['query']);if(m)f['add'](m['id']);else g['push'](k['query']);}}});const j={'submission_requirements':(a['table']??[])['filter'](k=>k['b_submission']===!![])['map'](k=>({'identifier':k['identifier'],'value_type':k['value_type'],'object_type':k['object_type'],'name':k['name']})),'data_sources':(a['table']??[])['filter'](k=>k['b_submission']!==!![])['map'](k=>({'identifier':k['identifier'],'kind':k['is_system_address']?'system_address':k['object_type']?'object':'fixed_value','value_type':k['value_type'],'object_type':k['object_type'],'name':k['name'],'is_mutable_onchain':k['object_type']==='Repository'})),'query_dependencies':[...f]['sort']((k,l)=>k-l),'unresolved_queries':g,'has_time_conditions':h,'has_signer_constraints':i,'has_rely_composition':Array['isArray'](a['rely']?.['guards'])&&a['rely']['guards']['length']>0x0,'reading_checklist':GUARD_SEMANTICS_READING_CHECKLIST};return{'render':{'tree_indented':d,'mermaid':e},'lint':b,'party_evaluation':j};}export{formatLintResult};
1
+ import{readFileSync,existsSync,writeFileSync,mkdirSync}from'fs';import{resolve,join,dirname}from'path';import{fileURLToPath}from'url';import{TOOLS_REFERENCE,getToolReference,searchToolReference,getToolSequence}from'../knowledge/tools-reference.js';import{GUARD_DESIGN_PATTERNS,getGuardDesignPattern,GUARD_DESIGN_PATTERNS_VERSION,GUARD_SCHEMA_NOTES}from'../knowledge/guard-design-patterns.js';import{OBJECT_REUSE_RULES,CREATE_VS_MODIFY_PATTERN,IMMUTABILITY_RULES,OPERATION_TYPE_CLASSIFICATION,OPERATION_CLASS_META,NAMING_CONVENTIONS,SAFETY_RULES_VERSION}from'../knowledge/safety-rules.js';import{listTemplates as a425a,getTemplateDetail,instantiateTemplate,getTemplateCounts,TEMPLATE_OBJECT_TYPES}from'../knowledge/template-registry.js';import{lintGuard,formatLintResult}from'../knowledge/guard-lint.js';import{renderGuardTreeIndented,renderGuardMermaid,walkGuardTree}from'../knowledge/guard-render.js';import{getGuardQueryByIdOrName}from'../schema/utils/guard-query-utils.js';const __filename=fileURLToPath(import.meta.url),__dirname=fileURLToPath(new URL('.',import.meta.url)),SCHEMAS_DIR=resolve(__dirname,'../../dist/schemas'),GUARD_TEMPLATES_PATH_SCRIPTS=resolve(__dirname,'../../scripts/guard-templates.json'),GUARD_TEMPLATES_PATH_DIST=resolve(__dirname,'../../dist/schemas/guard-templates.json'),GUARD_TEMPLATES_PATH=existsSync(GUARD_TEMPLATES_PATH_SCRIPTS)?GUARD_TEMPLATES_PATH_SCRIPTS:GUARD_TEMPLATES_PATH_DIST,WORKSPACE_TMP_DIR=resolve(process['cwd'](),'.trae','tmp');export function areSchemasAvailable(){return existsSync(SCHEMAS_DIR)&&existsSync(join(SCHEMAS_DIR,'index.json'));}export function getSchemaIndex(){try{const a=join(SCHEMAS_DIR,'index.json');if(!existsSync(a))return null;const b=readFileSync(a,'utf-8');return JSON['parse'](b);}catch{return null;}}export function listSchemas(){const a=getSchemaIndex();if(!a)return[];return[...a['tools']||[],...a['operations']||[]];}export function getSchema(a){try{let b=join(SCHEMAS_DIR,a+'.schema.json');!existsSync(b)&&(b=join(SCHEMAS_DIR,a+'.json'));if(!existsSync(b))return null;const c=readFileSync(b,'utf-8'),d=JSON['parse'](c);return resolveSchemaRefs(d);}catch{return null;}}export function getOutputSchema(a){try{const b=join(SCHEMAS_DIR,a+'.output.json');if(!existsSync(b))return null;const c=readFileSync(b,'utf-8'),d=JSON['parse'](c);return resolveSchemaRefs(d);}catch{return null;}}export function getGuardTemplates(a){try{if(!existsSync(GUARD_TEMPLATES_PATH))return null;const b=readFileSync(GUARD_TEMPLATES_PATH,'utf-8'),c=JSON['parse'](b);if(!a)return{'version':c['version'],'description':c['description'],'templates':(c['templates']||[])['map'](e=>({'name':e['name'],'title':e['title'],'description':e['description'],'use_case':e['use_case']})),'query_reference':c['query_reference'],'node_return_types':c['node_return_types']};const d=(c['templates']||[])['find'](e=>e['name']===a);if(!d)return null;return d;}catch{return null;}}export function getSchemaField(a,b){const c=getSchema(a);if(!c)return null;const d=b['split']('.')['filter'](Boolean);let e=c;for(const f of d){if(!e||typeof e!=='object')return null;if(e['properties']&&f in e['properties']){e=e['properties'][f];continue;}if(e['items']&&typeof e['items']==='object'){if(/^\d+$/['test'](f)){e=e['items'];continue;}if(e['items']['properties']&&f in e['items']['properties']){e=e['items']['properties'][f];continue;}}if(Array['isArray'](e['oneOf'])||Array['isArray'](e['anyOf'])){const g=e['oneOf']??e['anyOf'];for(const h of g){if(h&&typeof h==='object'&&h['properties']&&f in h['properties']){e=h['properties'][f];break;}}continue;}if(f in e){e=e[f];continue;}return null;}return e;}function resolveSchemaRefs(a,b=new Set()){if(!a||typeof a!=='object')return a;if(Array['isArray'](a))return a['map'](d=>resolveSchemaRefs(d,b));const c={};for(const [d,e]of Object['entries'](a)){if(d==='$ref'&&typeof e==='string'){if(e['startsWith']('#'))c[d]=e;else{const f=loadRefSchema(e,b);f&&Object['assign'](c,resolveSchemaRefs(f,b));}}else typeof e==='object'?c[d]=resolveSchemaRefs(e,b):c[d]=e;}return c;}function loadRefSchema(a,b){if(a['startsWith']('#'))return null;if(b['has'](a))return{'description':'Circular\x20reference\x20to\x20'+a};b['add'](a);try{const c=join(SCHEMAS_DIR,a);if(!existsSync(c))return null;const d=readFileSync(c,'utf-8');return JSON['parse'](d);}catch{return null;}}export function searchSchemas(a){const b=listSchemas(),c=a['toLowerCase']();return b['filter'](d=>{const e=d['name']['toLowerCase']()['includes'](c),f=d['title']?.['toLowerCase']()['includes'](c),g=d['description']?.['toLowerCase']()['includes'](c);return e||f||g;});}export function listOperations(){const a=getSchemaIndex();if(!a)return[];return(a['operations']||[])['filter'](b=>b['name']['startsWith']('onchain_operations_'));}function writeResponseToFile(a,b){try{let c;if(b)c=resolve(process['cwd'](),b);else{!existsSync(WORKSPACE_TMP_DIR)&&mkdirSync(WORKSPACE_TMP_DIR,{'recursive':!![]});const g=Date['now']();c=join(WORKSPACE_TMP_DIR,'schema-'+g+'.json');}const d=dirname(c);!existsSync(d)&&mkdirSync(d,{'recursive':!![]});const f=typeof a==='string'?a:JSON['stringify'](a,null,0x2);return writeFileSync(c,f,'utf-8'),c;}catch(h){return null;}}const INLINE_CHAR_LIMIT=0x20*0x400,AUTO_OVERFLOW_DIR='.wowok/tmp';function unionVariantLabel(a){if(!a||typeof a!=='object')return'variant';const b=a['properties']&&typeof a['properties']==='object'?a['properties']:undefined;if(b)for(const [c,d]of Object['entries'](b)){if(d&&typeof d==='object'&&d['const']!==undefined)return c+'='+String(d['const']);}return typeof a['title']==='string'?a['title']:'variant';}export function buildSchemaSummary(a){const b=[];a&&typeof a['title']==='string'&&b['push']('Title:\x20'+a['title']);const c=a&&typeof a==='object'?a['properties']:undefined;if(c&&typeof c==='object'&&!Array['isArray'](c)){const d=Array['isArray'](a['required'])?a['required']:[],e=Object['keys'](c);b['push']('Top-level\x20fields\x20('+e['length']+',\x20*\x20=\x20required):');for(const f of e['slice'](0x0,0x28)){const g=c[f]??{},h=Array['isArray'](g['type'])?g['type']['join']('|'):g['type']??(g['$ref']?'ref':g['anyOf']||g['oneOf']?'union':'any'),i=d['includes'](f)?'*':'',j=typeof g['description']==='string'&&g['description']['length']>0x0?'\x20—\x20'+g['description']['split']('\x0a')[0x0]['slice'](0x0,0x50):'';b['push']('\x20\x20-\x20'+f+i+':\x20'+h+j);}e['length']>0x28&&b['push']('\x20\x20-\x20...and\x20'+(e['length']-0x28)+'\x20more\x20—\x20use\x20action=\x27get_field\x27\x20with\x20field_path\x20to\x20inspect');}else{if(a&&(Array['isArray'](a['oneOf'])||Array['isArray'](a['anyOf']))){const k=a['oneOf']??a['anyOf'];b['push']('Union\x20of\x20'+k['length']+'\x20variants:');for(const m of k['slice'](0x0,0x28)){const o=m&&typeof m['description']==='string'&&m['description']['length']>0x0?'\x20—\x20'+m['description']['split']('\x0a')[0x0]['slice'](0x0,0x50):'';b['push']('\x20\x20-\x20'+unionVariantLabel(m)+o);}k['length']>0x28&&b['push']('\x20\x20-\x20...and\x20'+(k['length']-0x28)+'\x20more');const l=k['filter'](q=>q&&typeof q==='object'&&q['properties']&&typeof q['properties']==='object');if(l['length']===k['length']&&l['length']>0x0){const q=Object['keys'](l[0x0]['properties'])['filter'](r=>l['every'](s=>Object['prototype']['hasOwnProperty']['call'](s['properties'],r)));b['push'](q['length']>0x0?'Common\x20fields\x20(declared\x20by\x20ALL\x20'+l['length']+'\x20variants):\x20'+q['join'](',\x20')+'.':'No\x20field\x20is\x20declared\x20by\x20all\x20'+l['length']+'\x20variants\x20—\x20each\x20variant\x20takes\x20its\x20own\x20parameters.');}else b['push']('Field\x20names\x20differ\x20per\x20variant\x20—\x20read\x20the\x20variant\x27s\x20own\x20list\x20above.\x20'+'The\x20discriminator\x20(\x22operation\x22\x20and\x20friends)\x20is\x20the\x20only\x20shared\x20key.');for(const r of k['slice'](0x0,0x28)){const s=r&&typeof r==='object'&&r['properties']&&typeof r['properties']==='object'?Object['keys'](r['properties']):[];if(s['length']===0x0)continue;b['push']('\x20\x20\x20\x20'+unionVariantLabel(r)+'\x20fields:\x20'+s['join'](',\x20'));}b['push']('Drill\x20into\x20the\x20variant\x20you\x20need\x20with\x20action=\x27get_field\x27\x20(name\x20+\x20field_path)\x20—\x20the\x20lists\x20above\x20are\x20a\x20summary,\x20not\x20the\x20schema.');}else b['push']('No\x20top-level\x20properties\x20map\x20—\x20use\x20action=\x27get_field\x27\x20with\x20a\x20field_path\x20to\x20inspect\x20this\x20schema.');}return b['join']('\x0a');}export function autoOverflowToFile(a,b){try{const c=JSON['stringify'](a)['length'];if(c<=INLINE_CHAR_LIMIT)return null;const d=process['env']['WOWOK_SCHEMA_TMP_DIR'],e=d?resolve(d):resolve(process['cwd'](),AUTO_OVERFLOW_DIR);!existsSync(e)&&mkdirSync(e,{'recursive':!![]});const f=b['replace'](/[^a-zA-Z0-9_-]/g,'_'),g=f+'.schema.json',h=join(e,g);return writeFileSync(h,JSON['stringify'](a,null,0x2),'utf-8'),{'absolute_path':h,'relative_path':d?h:join(AUTO_OVERFLOW_DIR,g),'bytes':c,'summary':buildSchemaSummary(a)};}catch{return null;}}export function processSchemaQuery(a){const {action:b,name:c,query:d,field_path:f,template:g,output_file:h,object_type:i,params:j}=a;if(b==='get_guard_templates'){const k=getGuardTemplates(g);if(!k)return{'success':![],'action':b,'data':null,'message':g?'Guard\x20template\x20\x27'+g+'\x27\x20not\x20found.\x20Omit\x20\x27template\x27\x20to\x20list\x20all\x20available\x20templates.':'Guard\x20templates\x20file\x20not\x20found.\x20Ensure\x20scripts/guard-templates.json\x20exists.','suggestions':['Omit\x20\x27template\x27\x20to\x20list\x20all\x20available\x20templates.','Available\x20template\x20names:\x20signer_verification,\x20progress_node_check,\x20order_owner_verification,\x20service_belonging_check,\x20reward_not_claimed,\x20combined_reward_guard']};if(h){const l=writeResponseToFile(k,h);if(l)return{'success':!![],'action':b,'data':null,'message':'Guard\x20template'+(g?'\x20\x27'+g+'\x27':'s')+'\x20written\x20to\x20file:\x20'+l,'output_file_path':l,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+l]};}return{'success':!![],'action':b,'data':k,'message':g?'Retrieved\x20Guard\x20template:\x20'+g:'Retrieved\x20'+(Array['isArray'](k['templates'])?k['templates']['length']:0x0)+'\x20Guard\x20templates'};}if(b==='get_templates'){if(!g){const p=a425a(i),q=getTemplateCounts(),r={'total':p['length'],'filter':i??null,'counts_by_object_type':q,'templates':p};if(h){const s=writeResponseToFile(r,h);if(s)return{'success':!![],'action':b,'data':null,'message':p['length']+'\x20templates\x20written\x20to\x20file:\x20'+s,'output_file_path':s,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+s]};}return{'success':!![],'action':b,'data':r,'message':p['length']+'\x20template(s)'+(i?'\x20for\x20object_type=\x27'+i+'\x27':'')+'\x20'+('(total\x20registry:\x20'+Object['values'](q)['reduce']((t,u)=>t+u,0x0)+'\x20across\x20'+TEMPLATE_OBJECT_TYPES['length']+'\x20object\x20types).\x20')+'Provide\x20\x27template\x27\x20(id)\x20for\x20full\x20detail;\x20add\x20\x27params\x27\x20(JSON\x20string)\x20to\x20instantiate.'};}if(!j){const t=getTemplateDetail(g);if(!t)return{'success':![],'action':b,'data':null,'message':'Template\x20\x27'+g+'\x27\x20not\x20found\x20in\x20the\x20unified\x20registry.','suggestions':['Omit\x20\x27template\x27\x20to\x20list\x20all\x20template\x20metadata\x20(id\x20+\x20object_type\x20+\x20parameters).','Filter\x20by\x20object_type:\x20'+TEMPLATE_OBJECT_TYPES['join'](',\x20')]};if(h){const u=writeResponseToFile(t,h);if(u)return{'success':!![],'action':b,'data':null,'message':'Template\x20\x27'+g+'\x27\x20detail\x20written\x20to\x20file:\x20'+u,'output_file_path':u,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+u]};}return{'success':!![],'action':b,'data':t,'message':'Template\x20\x27'+g+'\x27\x20('+t['object_type']+',\x20'+(t['instantiable']?'instantiable':'guidance-only')+').\x20'+'To\x20instantiate,\x20call\x20again\x20with\x20\x27params\x27\x20=\x20JSON\x20object\x20of\x20the\x20declared\x20parameters.'};}let m;try{const v=JSON['parse'](j);if(!v||typeof v!=='object'||Array['isArray'](v))return{'success':![],'action':b,'data':null,'message':'\x27params\x27\x20must\x20be\x20a\x20JSON\x20object\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27),\x20got\x20'+(Array['isArray'](v)?'array':typeof v)+'.'};m=v;}catch(w){return{'success':![],'action':b,'data':null,'message':'Failed\x20to\x20parse\x20\x27params\x27\x20as\x20JSON:\x20'+(w instanceof Error?w['message']:String(w)),'suggestions':['Example:\x20params=\x27{\x22whitelist\x22:[\x220xabc...\x22]}\x27']};}const n=instantiateTemplate(g,m);if(!n['ok'])return{'success':![],'action':b,'data':n['guidance']!==undefined?{'guidance':n['guidance']}:null,'message':'Instantiation\x20failed\x20for\x20\x27'+g+'\x27:\x20'+n['error'],'suggestions':n['missing_params']?['Missing\x20required\x20params:\x20'+n['missing_params']['join'](',\x20'),'Call\x20with\x20\x27template\x27\x20only\x20(no\x20\x27params\x27)\x20to\x20see\x20full\x20parameter\x20declarations.']:['Call\x20with\x20\x27template\x27\x20only\x20(no\x20\x27params\x27)\x20to\x20see\x20full\x20parameter\x20declarations.']};const o={'object_type':n['object_type'],'template_id':n['template_id'],'body':n['body'],...n['notes']?{'notes':n['notes']}:{}};if(h){const x=writeResponseToFile(o,h);if(x)return{'success':!![],'action':b,'data':null,'message':'Instantiated\x20template\x20\x27'+g+'\x27\x20written\x20to\x20file:\x20'+x,'output_file_path':x,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+x]};}return{'success':!![],'action':b,'data':o,'message':'Instantiated\x20\x27'+g+'\x27\x20('+n['object_type']+').\x20'+'Review\x20the\x20body\x20against\x20the\x20onchain_operations\x20schema\x20before\x20submitting.'};}if(b==='get_tool_reference'){if(c){const z=getToolReference(c);if(!z)return{'success':![],'action':b,'data':null,'message':'Tool\x20\x27'+c+'\x27\x20not\x20found\x20in\x20the\x20tool\x20reference.','suggestions':['Omit\x20\x27name\x27\x20to\x20list\x20all\x20tools.','Available\x20tools:\x20'+TOOLS_REFERENCE['map'](B=>B['name'])['join'](',\x20')]};const A=getToolSequence(c);return{'success':!![],'action':b,'data':{'tool':z,'call_sequence':A??null},'message':'Retrieved\x20tool\x20reference:\x20'+c};}if(d){const B=searchToolReference(d);return{'success':!![],'action':b,'data':{'tools':B,'count':B['length']},'message':'Found\x20'+B['length']+'\x20tool(s)\x20matching\x20\x27'+d+'\x27','suggestions':B['length']===0x0?['Try\x20a\x20broader\x20keyword\x20(e.g.\x20\x27onchain\x27,\x20\x27guard\x27,\x20\x27schema\x27),\x20or\x20omit\x20\x27query\x27\x20to\x20list\x20all\x20tools.']:undefined};}const y=TOOLS_REFERENCE['map'](C=>({'name':C['name'],'summary':C['summary'],'actions':C['actions']??[],'notes':C['notes']??[]}));return{'success':!![],'action':b,'data':{'tools':y,'count':y['length']},'message':'Retrieved\x20reference\x20for\x20'+y['length']+'\x20MCP\x20tools.\x20Pass\x20name=\x27<tool>\x27\x20for\x20full\x20detail\x20(params,\x20prerequisites,\x20follow-ups).'};}if(b==='get_guard_design_patterns'){if(c){const D=getGuardDesignPattern(c);if(!D)return{'success':![],'action':b,'data':null,'message':'Guard\x20design\x20pattern\x20\x27'+c+'\x27\x20not\x20found.','suggestions':['Omit\x20\x27name\x27\x20to\x20list\x20the\x20full\x20catalog.','Available\x20pattern\x20ids:\x20'+GUARD_DESIGN_PATTERNS['map'](E=>E['id'])['join'](',\x20')]};return{'success':!![],'action':b,'data':{'pattern':D},'message':'Retrieved\x20Guard\x20design\x20pattern:\x20'+c};}if(d){const E=GUARD_DESIGN_PATTERNS['filter'](G=>G['host']===d),F=E['length']>0x0?E:GUARD_DESIGN_PATTERNS['filter'](G=>G['business_requirement']['toLowerCase']()['includes'](d['toLowerCase']())||G['logic_summary']['toLowerCase']()['includes'](d['toLowerCase']()));return{'success':!![],'action':b,'data':{'patterns':F,'count':F['length'],'filtered_by':E['length']>0x0?'host':'keyword','schema_notes':GUARD_SCHEMA_NOTES},'message':'Found\x20'+F['length']+'\x20Guard\x20design\x20pattern(s)\x20matching\x20\x27'+d+'\x27','suggestions':F['length']===0x0?['Filter\x20by\x20host:\x20service_buy_guard,\x20service_allocator_guard,\x20machine_forward,\x20progress_submission,\x20reward_claim,\x20repository_write,\x20arbitration_usage,\x20arbitration_voting,\x20gen_passport']:undefined};}const C=GUARD_DESIGN_PATTERNS['map'](G=>({'id':G['id'],'business_requirement':G['business_requirement'],'host':G['host'],'data_source':G['data_source'],'verifier_level':G['verifier_level'],'logic_summary':G['logic_summary'],'key_queries':G['key_queries'],'notes':G['notes']??[]}));return{'success':!![],'action':b,'data':{'patterns':C,'count':C['length'],'version':GUARD_DESIGN_PATTERNS_VERSION,'schema_notes':GUARD_SCHEMA_NOTES},'message':'Retrieved\x20'+C['length']+'\x20Guard\x20design\x20patterns.\x20Pass\x20name=\x27<pattern_id>\x27\x20for\x20full\x20detail\x20(witness\x20types,\x20mitigated\x20risks,\x20industries).'};}if(b==='get_safety_rules')return{'success':!![],'action':b,'data':{'version':SAFETY_RULES_VERSION,'object_reuse_rules':OBJECT_REUSE_RULES,'create_vs_modify_pattern':CREATE_VS_MODIFY_PATTERN,'immutability_rules':IMMUTABILITY_RULES,'operation_type_classification':OPERATION_TYPE_CLASSIFICATION,'operation_class_meta':OPERATION_CLASS_META,'naming_conventions':NAMING_CONVENTIONS},'message':'Retrieved\x20safety\x20rule\x20tables\x20(reuse\x20/\x20immutability\x20/\x20operation\x20classification\x20/\x20naming).\x20'+'Key\x20points:\x20prefer\x20REUSING\x20existing\x20objects\x20(string\x20reference\x20=\x20reuse,\x20object\x20shape\x20=\x20create);\x20'+'Machine\x20publish\x20locks\x20nodes/pairs/forwards,\x20Service\x20publish\x20locks\x20machine/order_allocators/arbitrations\x20(sales\x20stays\x20mutable);\x20'+'Guard\x20is\x20CREATE-only\x20immutable;\x20on-chain\x20writes\x20require\x20explicit\x20user\x20confirmation.'};if(!areSchemasAvailable())return{'success':![],'action':b,'data':null,'message':'Schema\x20files\x20are\x20not\x20available.\x20Please\x20run\x20\x27npm\x20run\x20generate:schemas\x27\x20first.','suggestions':['Run\x20\x27npm\x20run\x20generate:schemas\x27\x20to\x20generate\x20schema\x20files','Ensure\x20the\x20dist/schemas\x20directory\x20exists']};switch(b){case'list':{const G=listSchemas();return{'success':!![],'action':b,'data':G,'message':'Found\x20'+G['length']+'\x20available\x20schemas'};}case'get':{if(!c)return{'success':![],'action':b,'data':null,'message':'Schema\x20name\x20is\x20required\x20for\x20\x27get\x27\x20action','suggestions':['Provide\x20a\x20schema\x20name','Use\x20\x27list\x27\x20action\x20to\x20see\x20available\x20schemas']};const H=getSchema(c);if(!H){const J=searchSchemas(c)['slice'](0x0,0x5);return{'success':![],'action':b,'data':null,'message':'Schema\x20\x27'+c+'\x27\x20not\x20found','suggestions':J['length']>0x0?J['map'](K=>'Did\x20you\x20mean:\x20'+K['name']+'?'):['Use\x20\x27list\x27\x20action\x20to\x20see\x20available\x20schemas']};}if(h){const K=writeResponseToFile(H,h);if(K)return{'success':!![],'action':b,'data':null,'message':'Schema\x20\x27'+c+'\x27\x20written\x20to\x20file:\x20'+K,'output_file_path':K,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+K]};}const I=autoOverflowToFile(H,c);if(I)return{'success':!![],'action':b,'data':null,'message':'Schema\x20\x27'+c+'\x27\x20is\x20large\x20('+Math['round'](I['bytes']/0x400)+'\x20KB)\x20—\x20'+'written\x20to\x20file\x20instead\x20of\x20inlining\x20to\x20protect\x20your\x20context.','output_file_path':I['absolute_path'],'inline_summary':I['summary'],'suggestions':['Read\x20the\x20full\x20file\x20with\x20the\x20Read\x20tool:\x20'+I['absolute_path'],'If\x20the\x20sandbox\x20blocks\x20that\x20path,\x20resolve\x20the\x20relative\x20path\x20\x27'+I['relative_path']+'\x27\x20against\x20the\x20workspace\x20root\x20and\x20read\x20that.','Without\x20file\x20access,\x20query\x20specific\x20fields\x20via\x20action=\x27get_field\x27\x20with\x20name=\x27'+c+'\x27\x20and\x20a\x20field_path\x20from\x20the\x20summary\x20below.']};return{'success':!![],'action':b,'data':H,'message':'Retrieved\x20schema:\x20'+c};}case'get_field':{if(!c||!f)return{'success':![],'action':b,'data':null,'message':'Both\x20\x27name\x27\x20and\x20\x27field_path\x27\x20are\x20required\x20for\x20\x27get_field\x27\x20action','suggestions':['Example:\x20{action:\x20\x27get_field\x27,\x20name:\x20\x27onchain_operations_machine\x27,\x20field_path:\x20\x27data.node\x27}','Use\x20\x27get\x27\x20action\x20to\x20retrieve\x20the\x20full\x20schema']};const L=getSchemaField(c,f);if(!L)return{'success':![],'action':b,'data':null,'message':'Field\x20path\x20\x27'+f+'\x27\x20not\x20found\x20in\x20schema\x20\x27'+c+'\x27','suggestions':['Check\x20the\x20field\x20path\x20(dot-separated,\x20e.g.\x20\x27data.node\x27)','Use\x20\x27get\x27\x20action\x20to\x20see\x20the\x20full\x20schema\x20structure']};return{'success':!![],'action':b,'data':L,'message':'Retrieved\x20field\x20\x27'+f+'\x27\x20from\x20schema\x20\x27'+c+'\x27'};}case'search':{if(!d)return{'success':![],'action':b,'data':null,'message':'Search\x20query\x20is\x20required\x20for\x20\x27search\x27\x20action'};const M=searchSchemas(d);return{'success':!![],'action':b,'data':M,'message':'Found\x20'+M['length']+'\x20schemas\x20matching\x20\x27'+d+'\x27'};}case'list_operations':{const N=listOperations();return{'success':!![],'action':b,'data':N,'message':'Found\x20'+N['length']+'\x20on-chain\x20operations'};}case'get_output':{if(!c)return{'success':![],'action':b,'data':null,'message':'Tool\x20name\x20is\x20required\x20for\x20\x27get_output\x27\x20action','suggestions':['Provide\x20a\x20tool\x20name','Use\x20\x27list\x27\x20action\x20to\x20see\x20available\x20tools\x20and\x20their\x20outputPath']};const O=getOutputSchema(c);if(!O){const Q=listSchemas(),R=Q['find'](T=>T['name']===c);if(R)return{'success':![],'action':b,'data':null,'message':'Tool\x20\x27'+c+'\x27\x20exists\x20but\x20has\x20no\x20output\x20schema\x20file.\x20The\x20tool\x20may\x20not\x20declare\x20an\x20outputSchema,\x20or\x20the\x20schema\x20file\x20was\x20not\x20generated.','suggestions':['Use\x20\x27get\x27\x20action\x20with\x20name=\x27'+c+'\x27\x20to\x20retrieve\x20its\x20input\x20schema']};const S=searchSchemas(c)['slice'](0x0,0x5);return{'success':![],'action':b,'data':null,'message':'Tool\x20\x27'+c+'\x27\x20not\x20found','suggestions':S['length']>0x0?S['map'](T=>'Did\x20you\x20mean:\x20'+T['name']+'?'):['Use\x20\x27list\x27\x20action\x20to\x20see\x20available\x20tools']};}if(h){const T=writeResponseToFile(O,h);if(T)return{'success':!![],'action':b,'data':null,'message':'Output\x20schema\x20\x27'+c+'\x27\x20written\x20to\x20file:\x20'+T,'output_file_path':T,'suggestions':['Use\x20Read\x20tool\x20to\x20open\x20'+T]};}const P=autoOverflowToFile(O,c);if(P)return{'success':!![],'action':b,'data':null,'message':'Output\x20schema\x20\x27'+c+'\x27\x20is\x20large\x20('+Math['round'](P['bytes']/0x400)+'\x20KB)\x20—\x20'+'written\x20to\x20file\x20instead\x20of\x20inlining\x20to\x20protect\x20your\x20context.','output_file_path':P['absolute_path'],'inline_summary':P['summary'],'suggestions':['Read\x20the\x20full\x20file\x20with\x20the\x20Read\x20tool:\x20'+P['absolute_path'],'If\x20the\x20sandbox\x20blocks\x20that\x20path,\x20resolve\x20the\x20relative\x20path\x20\x27'+P['relative_path']+'\x27\x20against\x20the\x20workspace\x20root\x20and\x20read\x20that.','Without\x20file\x20access,\x20query\x20specific\x20fields\x20via\x20action=\x27get_field\x27\x20with\x20name=\x27'+c+'\x27\x20and\x20a\x20field_path\x20from\x20the\x20summary\x20below.']};return{'success':!![],'action':b,'data':O,'message':'Retrieved\x20output\x20schema:\x20'+c};}default:return{'success':![],'action':b,'data':null,'message':'Unknown\x20action:\x20'+b,'suggestions':['Use\x20\x27list\x27,\x20\x27get\x27,\x20\x27get_field\x27,\x20\x27get_output\x27,\x20\x27search\x27,\x20\x27list_operations\x27,\x20\x27get_guard_templates\x27,\x20\x27get_tool_reference\x27,\x20\x27get_guard_design_patterns\x27,\x20\x27get_safety_rules\x27,\x20\x27get_templates\x27,\x20or\x20\x27analyze_guard_semantics\x27']};}}const GUARD_SEMANTICS_READING_CHECKLIST=['WHO\x20can\x20satisfy\x20this\x20Guard\x20(identity:\x20Signer\x20bindings,\x20Entity\x20membership,\x20allowlists)?','WHEN\x20can\x20it\x20be\x20satisfied\x20(time:\x20Clock\x20comparisons,\x20deadlines,\x20windows)?','WHAT\x20evidence\x20must\x20the\x20caller\x20submit\x20(b_submission\x20table\x20entries\x20—\x20Payment/Order/Proof\x20objects)?','WHICH\x20on-chain\x20data\x20does\x20it\x20read,\x20and\x20can\x20that\x20data\x20change\x20(Repository\x20entries\x20are\x20MUTABLE\x20—\x20who\x20controls\x20the\x20writes)?','WHAT\x20does\x20the\x20counterparty\x20gain/lose\x20in\x20each\x20branch\x20of\x20the\x20logic\x20tree?','ARE\x20there\x20error-level\x20diagnostics\x20or\x20critical\x20risks\x20(they\x20block\x20or\x20endanger\x20execution)?'];export async function analyzeGuardSemantics(a){const b=await lintGuard(a,{'auto_fix':![]}),c={'root':a['root'],'table':(a['table']??[])['map'](k=>({'identifier':k['identifier'],'name':k['name'],'value_type':k['value_type']??'Address','b_submission':k['b_submission']??![],'value':k['value']})),'guardName':a['description']??null,'rely':a['rely']??null},d=renderGuardTreeIndented(c),e=renderGuardMermaid(a['root']),f=new Set(),g=[];let h=![],i=![];walkGuardTree(a['root'],k=>{if(k['type']==='context'){if(k['context']==='Clock')h=!![];if(k['context']==='Signer')i=!![];}if(k['type']==='query'&&k['query']!==undefined&&k['query']!==null){if(typeof k['query']==='number'){const l=getGuardQueryByIdOrName(k['query']);if(l)f['add'](l['id']);else g['push'](k['query']);}else{const m=getGuardQueryByIdOrName(k['query']);if(m)f['add'](m['id']);else g['push'](k['query']);}}});const j={'submission_requirements':(a['table']??[])['filter'](k=>k['b_submission']===!![])['map'](k=>({'identifier':k['identifier'],'value_type':k['value_type'],'object_type':k['object_type'],'name':k['name']})),'data_sources':(a['table']??[])['filter'](k=>k['b_submission']!==!![])['map'](k=>({'identifier':k['identifier'],'kind':k['is_system_address']?'system_address':k['object_type']?'object':'fixed_value','value_type':k['value_type'],'object_type':k['object_type'],'name':k['name'],'is_mutable_onchain':k['object_type']==='Repository'})),'query_dependencies':[...f]['sort']((k,l)=>k-l),'unresolved_queries':g,'has_time_conditions':h,'has_signer_constraints':i,'has_rely_composition':Array['isArray'](a['rely']?.['guards'])&&a['rely']['guards']['length']>0x0,'reading_checklist':GUARD_SEMANTICS_READING_CHECKLIST};return{'render':{'tree_indented':d,'mermaid':e},'lint':b,'party_evaluation':j};}export{formatLintResult};
@@ -2355,6 +2355,7 @@
2355
2355
  "config_error",
2356
2356
  "wip_verification_failed",
2357
2357
  "wip_storage_unavailable",
2358
+ "submission_unknown",
2358
2359
  "unknown"
2359
2360
  ]
2360
2361
  },
@@ -64,6 +64,7 @@
64
64
  "config_error",
65
65
  "wip_verification_failed",
66
66
  "wip_storage_unavailable",
67
+ "submission_unknown",
67
68
  "unknown"
68
69
  ]
69
70
  },
@@ -2,7 +2,7 @@
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
3
  "title": "WoWok MCP Schema Index",
4
4
  "description": "Index of all available JSON schemas for WoWok MCP tools",
5
- "generatedAt": "2026-10-07T12:46:23.631Z",
5
+ "generatedAt": "2026-10-08T07:43:04.014Z",
6
6
  "tools": [
7
7
  {
8
8
  "name": "onchain_operations",
@@ -237,6 +237,7 @@
237
237
  "config_error",
238
238
  "wip_verification_failed",
239
239
  "wip_storage_unavailable",
240
+ "submission_unknown",
240
241
  "unknown"
241
242
  ]
242
243
  },
@@ -184,6 +184,7 @@
184
184
  "config_error",
185
185
  "wip_verification_failed",
186
186
  "wip_storage_unavailable",
187
+ "submission_unknown",
187
188
  "unknown"
188
189
  ]
189
190
  },
@@ -70,6 +70,7 @@
70
70
  "config_error",
71
71
  "wip_verification_failed",
72
72
  "wip_storage_unavailable",
73
+ "submission_unknown",
73
74
  "unknown"
74
75
  ]
75
76
  },
@@ -162,6 +162,7 @@
162
162
  "config_error",
163
163
  "wip_verification_failed",
164
164
  "wip_storage_unavailable",
165
+ "submission_unknown",
165
166
  "unknown"
166
167
  ]
167
168
  },
@@ -5684,6 +5684,7 @@
5684
5684
  "config_error",
5685
5685
  "wip_verification_failed",
5686
5686
  "wip_storage_unavailable",
5687
+ "submission_unknown",
5687
5688
  "unknown"
5688
5689
  ]
5689
5690
  },
@@ -231,7 +231,7 @@
231
231
  "additionalProperties": false
232
232
  },
233
233
  "order_required_info": {
234
- "description": "Contact object ID or WTS Proof object, recorded on the Order as proof that the order holder delivered the required private information (service.customer_required) to the merchant. FLOW: when a Service declares customer_required (e.g. phone/email/shipping_address), the order holder MUST send that private information to the Service's Contact (um) via end-to-end encrypted Messenger, then pass the Contact object ID or the generated WTS Proof here so the delivery is verifiable on-chain.",
234
+ "description": "Contact object ID or WTS Proof object, RECORDED on the Order as evidence that the order holder delivered the private information the Service declares in customer_required (e.g. phone/email/shipping_address). RECORD-ONLY, NOT ENFORCED: nothing on-chain reads this field — the purchase entry never requires it, and an order supplying none of the declared fields is still created. FLOW: the order holder sends the information to the Service's Contact (um) via end-to-end encrypted Messenger, then passes the Contact object ID or the generated WTS Proof here. To ENFORCE delivery on-chain, mount the pattern.required_info_evidence_gate Guard on the forward that hands over goods or funds, asserting order.required_info is some (presence-only — the recorded address value is never a guard condition; accepting the delivered information is the merchant's confirming forward).",
235
235
  "type": "string"
236
236
  },
237
237
  "transfer": {
@@ -3450,7 +3450,7 @@
3450
3450
  "type": "boolean"
3451
3451
  },
3452
3452
  "publish": {
3453
- "description": "Whether to publish the object. After the object is published, new Progress objects can be generated; and node settings will no longer be changeable. ⚠️ PUBLISH IS A ONE-WAY DOOR AND THE CHAIN VALIDATES THE WHOLE GRAPH AT THAT MOMENT: machine::assert_publishable rejects a Machine that is empty, has no entry edge (no pair with prev_node:\"\"), has an entry pair with no forward, references a prev_node that is not a node of this Machine, carries a forward with neither namedOperator nor permissionIndex (a guard is NOT an identity), or has a pair whose threshold exceeds the sum of its forward weights (each forward counts at most once). These aborts (machine:17-22) fire BEFORE the publish lands, so the graph is still editable — but after it succeeds, nodes/forwards, Guard bindings and Service.machine are frozen forever, and a broken graph would only surface at the first transition with no repair path. Send the nodes in the SAME call as publish:true (bReplace:true or op:\"set\") so the complete graph is validated together. ⚠️ Before publishing, enumerate the graph STOP NODES (nodes with no outgoing Pair) plus every waiting state (review window, handover, open dispute) and verify each has a defined fund exit in the Service order_allocators — withdrawal (release) AND refund. Machine + Allocator are immutable after publish (IMMUT-001); an uncovered stop node strands funds permanently (rule R-M5-03, checklist pattern.fund_flow_stop_node_coverage).",
3453
+ "description": "Whether to publish the object. After the object is published, new Progress objects can be generated; and node settings will no longer be changeable. ⚠️ PUBLISH IS A ONE-WAY DOOR AND THE CHAIN VALIDATES THE WHOLE GRAPH AT THAT MOMENT: the on-chain publish gate rejects a Machine that is empty, has no entry edge (no pair with prev_node:\"\"), has an entry pair with no forward, references a prev_node that is not a node of this Machine, carries a forward with neither namedOperator nor permissionIndex (a guard is NOT an identity), or has a pair whose threshold exceeds the sum of its forward weights (each forward counts at most once). These aborts (machine:17-22) fire BEFORE the publish lands, so the graph is still editable — but after it succeeds, nodes/forwards, Guard bindings and Service.machine are frozen forever, and a broken graph would only surface at the first transition with no repair path. Send the nodes in the SAME call as publish:true (bReplace:true or op:\"set\") so the complete graph is validated together. ⚠️ Before publishing, enumerate the graph STOP NODES (nodes with no outgoing Pair) plus every waiting state (review window, handover, open dispute) and verify each has a defined fund exit in the Service order_allocators — withdrawal (release) AND refund. Machine + Allocator are immutable after publish (IMMUT-001); an uncovered stop node strands funds permanently (rule R-M5-03, checklist pattern.fund_flow_stop_node_coverage).",
3454
3454
  "type": "boolean"
3455
3455
  },
3456
3456
  "owner_receive": {
@@ -6825,7 +6825,7 @@
6825
6825
  "description": "Two ways to specify an object: (1) STRING - Reference an EXISTING object by name or ID; (2) OBJECT - CREATE a NEW object with full configuration including name, tags, description, token type for payments, and Permission-based access control. The object format is used when you need both token specification AND permission management."
6826
6826
  },
6827
6827
  "dispute": {
6828
- "description": "Create a new Arb object for the order; the case lands directly in state 1 (Arbitrator_confirming) — the customer does not confirm at filing time.",
6828
+ "description": "Create a new Arb object for the order; the case lands directly in state 1 (Arbitrator_confirming) — the customer does not confirm at filing time. FILING IS SERVICE-BOUND: the SDK resolves the order's Service and files through its Service-side dispute entry points, which enforce the merchant's arbitrator allowlist, the service-arbitration neutrality rule and the order binding before the case is minted (venues gated by a usage_guard require the passport path, verified in the same transaction). Direct calls to the removed arbitration-side dispute entries abort with arbitration:10",
6829
6829
  "type": "object",
6830
6830
  "properties": {
6831
6831
  "order": {
@@ -95,7 +95,7 @@
95
95
  "description": "Two ways to specify an object: (1) STRING - Reference an EXISTING object by name or ID; (2) OBJECT - CREATE a NEW object with full configuration including name, tags, description, token type for payments, and Permission-based access control. The object format is used when you need both token specification AND permission management."
96
96
  },
97
97
  "dispute": {
98
- "description": "Create a new Arb object for the order; the case lands directly in state 1 (Arbitrator_confirming) — the customer does not confirm at filing time.",
98
+ "description": "Create a new Arb object for the order; the case lands directly in state 1 (Arbitrator_confirming) — the customer does not confirm at filing time. FILING IS SERVICE-BOUND: the SDK resolves the order's Service and files through its Service-side dispute entry points, which enforce the merchant's arbitrator allowlist, the service-arbitration neutrality rule and the order binding before the case is minted (venues gated by a usage_guard require the passport path, verified in the same transaction). Direct calls to the removed arbitration-side dispute entries abort with arbitration:10",
99
99
  "type": "object",
100
100
  "properties": {
101
101
  "order": {
@@ -1068,7 +1068,7 @@
1068
1068
  "type": "boolean"
1069
1069
  },
1070
1070
  "publish": {
1071
- "description": "Whether to publish the object. After the object is published, new Progress objects can be generated; and node settings will no longer be changeable. ⚠️ PUBLISH IS A ONE-WAY DOOR AND THE CHAIN VALIDATES THE WHOLE GRAPH AT THAT MOMENT: machine::assert_publishable rejects a Machine that is empty, has no entry edge (no pair with prev_node:\"\"), has an entry pair with no forward, references a prev_node that is not a node of this Machine, carries a forward with neither namedOperator nor permissionIndex (a guard is NOT an identity), or has a pair whose threshold exceeds the sum of its forward weights (each forward counts at most once). These aborts (machine:17-22) fire BEFORE the publish lands, so the graph is still editable — but after it succeeds, nodes/forwards, Guard bindings and Service.machine are frozen forever, and a broken graph would only surface at the first transition with no repair path. Send the nodes in the SAME call as publish:true (bReplace:true or op:\"set\") so the complete graph is validated together. ⚠️ Before publishing, enumerate the graph STOP NODES (nodes with no outgoing Pair) plus every waiting state (review window, handover, open dispute) and verify each has a defined fund exit in the Service order_allocators — withdrawal (release) AND refund. Machine + Allocator are immutable after publish (IMMUT-001); an uncovered stop node strands funds permanently (rule R-M5-03, checklist pattern.fund_flow_stop_node_coverage).",
1071
+ "description": "Whether to publish the object. After the object is published, new Progress objects can be generated; and node settings will no longer be changeable. ⚠️ PUBLISH IS A ONE-WAY DOOR AND THE CHAIN VALIDATES THE WHOLE GRAPH AT THAT MOMENT: the on-chain publish gate rejects a Machine that is empty, has no entry edge (no pair with prev_node:\"\"), has an entry pair with no forward, references a prev_node that is not a node of this Machine, carries a forward with neither namedOperator nor permissionIndex (a guard is NOT an identity), or has a pair whose threshold exceeds the sum of its forward weights (each forward counts at most once). These aborts (machine:17-22) fire BEFORE the publish lands, so the graph is still editable — but after it succeeds, nodes/forwards, Guard bindings and Service.machine are frozen forever, and a broken graph would only surface at the first transition with no repair path. Send the nodes in the SAME call as publish:true (bReplace:true or op:\"set\") so the complete graph is validated together. ⚠️ Before publishing, enumerate the graph STOP NODES (nodes with no outgoing Pair) plus every waiting state (review window, handover, open dispute) and verify each has a defined fund exit in the Service order_allocators — withdrawal (release) AND refund. Machine + Allocator are immutable after publish (IMMUT-001); an uncovered stop node strands funds permanently (rule R-M5-03, checklist pattern.fund_flow_stop_node_coverage).",
1072
1072
  "type": "boolean"
1073
1073
  },
1074
1074
  "owner_receive": {
@@ -229,7 +229,7 @@
229
229
  "additionalProperties": false
230
230
  },
231
231
  "order_required_info": {
232
- "description": "Contact object ID or WTS Proof object, recorded on the Order as proof that the order holder delivered the required private information (service.customer_required) to the merchant. FLOW: when a Service declares customer_required (e.g. phone/email/shipping_address), the order holder MUST send that private information to the Service's Contact (um) via end-to-end encrypted Messenger, then pass the Contact object ID or the generated WTS Proof here so the delivery is verifiable on-chain.",
232
+ "description": "Contact object ID or WTS Proof object, RECORDED on the Order as evidence that the order holder delivered the private information the Service declares in customer_required (e.g. phone/email/shipping_address). RECORD-ONLY, NOT ENFORCED: nothing on-chain reads this field — the purchase entry never requires it, and an order supplying none of the declared fields is still created. FLOW: the order holder sends the information to the Service's Contact (um) via end-to-end encrypted Messenger, then passes the Contact object ID or the generated WTS Proof here. To ENFORCE delivery on-chain, mount the pattern.required_info_evidence_gate Guard on the forward that hands over goods or funds, asserting order.required_info is some (presence-only — the recorded address value is never a guard condition; accepting the delivered information is the merchant's confirming forward).",
233
233
  "type": "string"
234
234
  },
235
235
  "transfer": {
@@ -16309,7 +16309,7 @@
16309
16309
  "properties": {
16310
16310
  "balance": {
16311
16311
  "type": "string",
16312
- "description": "Raw smallest units: Σ(unit_price × quantity)."
16312
+ "description": "Raw smallest units: Σ(unit_price × quantity), AFTER the discount when one applies."
16313
16313
  },
16314
16314
  "display": {
16315
16315
  "type": "string"
@@ -16326,6 +16326,89 @@
16326
16326
  ],
16327
16327
  "additionalProperties": false
16328
16328
  },
16329
+ "discount": {
16330
+ "anyOf": [
16331
+ {
16332
+ "type": "object",
16333
+ "properties": {
16334
+ "coupon": {
16335
+ "type": "string",
16336
+ "description": "Resolved Discount object address."
16337
+ },
16338
+ "name": {
16339
+ "anyOf": [
16340
+ {
16341
+ "type": "string"
16342
+ },
16343
+ {
16344
+ "type": "null"
16345
+ }
16346
+ ]
16347
+ },
16348
+ "type": {
16349
+ "type": "string",
16350
+ "description": "'rates' (off is bps of the list total) or 'minus' (off is a fixed smallest-units amount)."
16351
+ },
16352
+ "off": {
16353
+ "type": "string",
16354
+ "description": "Coupon off value in raw smallest units (minus) or bps (rates)."
16355
+ },
16356
+ "benchmark": {
16357
+ "anyOf": [
16358
+ {
16359
+ "type": "string"
16360
+ },
16361
+ {
16362
+ "type": "null"
16363
+ }
16364
+ ],
16365
+ "description": "Order-total threshold in smallest units; null = unconditional coupon."
16366
+ },
16367
+ "benchmark_met": {
16368
+ "type": "boolean",
16369
+ "description": "False when the list total is below benchmark — on chain the buy still succeeds at FULL price and DESTROYS the coupon."
16370
+ },
16371
+ "applied": {
16372
+ "type": "boolean",
16373
+ "description": "True when the discount reduced the total."
16374
+ },
16375
+ "list_total": {
16376
+ "type": "string",
16377
+ "description": "Undiscounted basket total (the benchmark comparison base)."
16378
+ },
16379
+ "final_total": {
16380
+ "type": "string",
16381
+ "description": "The total_pay.balance a discounted buy must carry."
16382
+ },
16383
+ "final_total_display": {
16384
+ "type": "string"
16385
+ },
16386
+ "note": {
16387
+ "type": "string",
16388
+ "description": "Burn warning when benchmark is unmet; guidance to use final_total when applied."
16389
+ }
16390
+ },
16391
+ "required": [
16392
+ "coupon",
16393
+ "name",
16394
+ "type",
16395
+ "off",
16396
+ "benchmark",
16397
+ "benchmark_met",
16398
+ "applied",
16399
+ "list_total",
16400
+ "final_total",
16401
+ "final_total_display",
16402
+ "note"
16403
+ ],
16404
+ "additionalProperties": false
16405
+ },
16406
+ {
16407
+ "type": "null"
16408
+ }
16409
+ ],
16410
+ "description": "Discount pricing block, mirroring the on-chain discounted-quote validation and price-reduction rules (service.move:282-302, 357-365). null when no discount was requested. Wrong-service or expired coupons REJECT the quote (the chain aborts the same way); an unmet benchmark returns applied:false with a burn warning (the only non-aborting failure). Read-only — quoting never consumes the coupon."
16411
+ },
16329
16412
  "allocation_preview": {
16330
16413
  "anyOf": [
16331
16414
  {
@@ -16392,6 +16475,7 @@
16392
16475
  "payment_token",
16393
16476
  "items",
16394
16477
  "total_pay",
16478
+ "discount",
16395
16479
  "allocation_preview"
16396
16480
  ],
16397
16481
  "additionalProperties": false,
@@ -16870,7 +16954,7 @@
16870
16954
  "onchain_operations",
16871
16955
  "workflow_operation"
16872
16956
  ],
16873
- "description": "Tool that executes the forward: onchain_operations order.data.progress (OrderHolder short-circuit) or workflow_operation data.operate (permission index / named operator)."
16957
+ "description": "Tool that executes the forward: onchain_operations order.data.progress (OrderHolder short-circuit) or workflow_operation data.operate (permission index / named operator; auto-routes order-bound when the Progress task is an Order)."
16874
16958
  },
16875
16959
  "path": {
16876
16960
  "type": "string",
@@ -16878,7 +16962,7 @@
16878
16962
  },
16879
16963
  "reason": {
16880
16964
  "type": "string",
16881
- "description": "Chain-authoritative routing reason, including the wrong-route abort code (direct Progress execution on a namedOperator='' forward aborts permission#5 'Permission denied') and the Guard passport requirement when the forward binds one."
16965
+ "description": "Chain-authoritative routing reason, including the Guard passport requirement when the forward binds one, and the standalone-Progress limitation for namedOperator='' forwards (abort 8 — no order payer)."
16882
16966
  }
16883
16967
  },
16884
16968
  "required": [
@@ -17316,7 +17400,7 @@
17316
17400
  "onchain_operations",
17317
17401
  "workflow_operation"
17318
17402
  ],
17319
- "description": "Tool that executes the forward: onchain_operations order.data.progress (OrderHolder short-circuit) or workflow_operation data.operate (permission index / named operator)."
17403
+ "description": "Tool that executes the forward: onchain_operations order.data.progress (OrderHolder short-circuit) or workflow_operation data.operate (permission index / named operator; auto-routes order-bound when the Progress task is an Order)."
17320
17404
  },
17321
17405
  "path": {
17322
17406
  "type": "string",
@@ -17324,7 +17408,7 @@
17324
17408
  },
17325
17409
  "reason": {
17326
17410
  "type": "string",
17327
- "description": "Chain-authoritative routing reason, including the wrong-route abort code (direct Progress execution on a namedOperator='' forward aborts permission#5 'Permission denied') and the Guard passport requirement when the forward binds one."
17411
+ "description": "Chain-authoritative routing reason, including the Guard passport requirement when the forward binds one, and the standalone-Progress limitation for namedOperator='' forwards (abort 8 — no order payer)."
17328
17412
  }
17329
17413
  },
17330
17414
  "required": [
@@ -18854,7 +18938,7 @@
18854
18938
  "onchain_operations",
18855
18939
  "workflow_operation"
18856
18940
  ],
18857
- "description": "Tool that executes the forward: onchain_operations order.data.progress (OrderHolder short-circuit) or workflow_operation data.operate (permission index / named operator)."
18941
+ "description": "Tool that executes the forward: onchain_operations order.data.progress (OrderHolder short-circuit) or workflow_operation data.operate (permission index / named operator; auto-routes order-bound when the Progress task is an Order)."
18858
18942
  },
18859
18943
  "path": {
18860
18944
  "type": "string",
@@ -18862,7 +18946,7 @@
18862
18946
  },
18863
18947
  "reason": {
18864
18948
  "type": "string",
18865
- "description": "Chain-authoritative routing reason, including the wrong-route abort code (direct Progress execution on a namedOperator='' forward aborts permission#5 'Permission denied') and the Guard passport requirement when the forward binds one."
18949
+ "description": "Chain-authoritative routing reason, including the Guard passport requirement when the forward binds one, and the standalone-Progress limitation for namedOperator='' forwards (abort 8 — no order payer)."
18866
18950
  }
18867
18951
  },
18868
18952
  "required": [
@@ -1 +1 @@
1
- import{listServices,getServiceInfo,toggle as a438a,setEnabled as a438b,reset as a438c}from'../../config/index.js';import{judgmentStatus,setJudgmentOverride,clearJudgmentOverride,clearJudgmentOverrides,patchUserJudgmentDoc,readUserJudgmentDocView}from'../../config/judgment.js';import{strictParse}from'../../schema/index.js';import{ConfigOperationInputSchema}from'../../schema/config/index.js';export async function handleConfigOperation(a){const b=strictParse(ConfigOperationInputSchema,a,'config_operation\x20input'),{action:c,service:d,path:e,value:f}=b;let g;switch(c){case'list':g={'action':'list','services':listServices()};break;case'toggle':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20toggle');const h=d,i=getServiceInfo(h);if(!i)throw new Error('Unknown\x20service:\x20'+h+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');if(h==='confirm_gate'&&i['enabled'])throw new Error('confirm_gate\x20cannot\x20be\x20disabled\x20at\x20runtime.\x20'+'Set\x20WOWOK_CONFIRM_GATE=0\x20in\x20the\x20server\x20environment\x20and\x20restart\x20if\x20you\x20really\x20want\x20it\x20off.');const j=a438a(h);g={'action':'toggle','service':h,'enabled':j,'reminder':i['reminder']};break;}case'disable':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20disable');const k=d,l=getServiceInfo(k);if(!l)throw new Error('Unknown\x20service:\x20'+k+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');if(k==='confirm_gate')throw new Error('confirm_gate\x20cannot\x20be\x20disabled\x20at\x20runtime.\x20'+'Set\x20WOWOK_CONFIRM_GATE=0\x20in\x20the\x20server\x20environment\x20and\x20restart\x20if\x20you\x20really\x20want\x20it\x20off.');a438b(k,![]),g={'action':'disable','service':k,'enabled':![],'reminder':l['reminder']};break;}case'enable':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20enable');const m=d,n=getServiceInfo(m);if(!n)throw new Error('Unknown\x20service:\x20'+m+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');a438b(m,!![]),g={'action':'enable','service':m,'enabled':!![],'reminder':n['reminder']};break;}case'reset':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20reset');const o=d,p=getServiceInfo(o);if(!p)throw new Error('Unknown\x20service:\x20'+o+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');a438c(o),g={'action':'reset','service':o,'enabled':getServiceInfo(o)?.['enabled'],'reminder':p['reminder'],'reset':!![]};break;}case'info':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20info');const q=d,r=getServiceInfo(q);if(!r)throw new Error('Unknown\x20service:\x20'+q+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');g={'action':'info',...r};break;}case'judgment_list':g={'action':'judgment_list',...judgmentStatus()};break;case'judgment_set':{if(!e)throw new Error('\x27path\x27\x20param\x20is\x20required\x20for\x20judgment_set\x20(dotted,\x20e.g.\x20\x27evaluation.weights.trust_reviews\x27)');if(!('value'in b))throw new Error('\x27value\x27\x20param\x20is\x20required\x20for\x20judgment_set');const s=setJudgmentOverride(e,f);if(!s['ok'])throw new Error(s['error']);g={'action':'judgment_set','path':e,'value':f,'applied':!![]};break;}case'judgment_reset':{const t=e?clearJudgmentOverride(e)?0x1:0x0:clearJudgmentOverrides();g={'action':'judgment_reset',...e?{'path':e}:{},'cleared':t};break;}case'judgment_doc_read':{g={'action':'judgment_doc_read',...readUserJudgmentDocView()};break;}case'judgment_doc_patch':{if(!b['patch']||typeof b['patch']!=='object'||Array['isArray'](b['patch']))throw new Error('\x27patch\x27\x20param\x20is\x20required\x20for\x20judgment_doc_patch\x20(a\x20partial\x20judgment\x20document\x20object,\x20e.g.\x20{\x22evaluation\x22:\x20{\x22weights\x22:\x20{…}}})');g={'action':'judgment_doc_patch',...patchUserJudgmentDoc(b['patch'])};break;}default:throw new Error('Unknown\x20config_operation\x20action:\x20'+String(c));}return{'content':[{'type':'text','text':JSON['stringify']({'result':g})}],'structuredContent':{'result':g}};}
1
+ import{listServices,getServiceInfo,toggle as a440a,setEnabled as a440b,reset as a440c}from'../../config/index.js';import{judgmentStatus,setJudgmentOverride,clearJudgmentOverride,clearJudgmentOverrides,patchUserJudgmentDoc,readUserJudgmentDocView}from'../../config/judgment.js';import{strictParse}from'../../schema/index.js';import{ConfigOperationInputSchema}from'../../schema/config/index.js';export async function handleConfigOperation(a){const b=strictParse(ConfigOperationInputSchema,a,'config_operation\x20input'),{action:c,service:d,path:e,value:f}=b;let g;switch(c){case'list':g={'action':'list','services':listServices()};break;case'toggle':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20toggle');const h=d,i=getServiceInfo(h);if(!i)throw new Error('Unknown\x20service:\x20'+h+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');if(h==='confirm_gate'&&i['enabled'])throw new Error('confirm_gate\x20cannot\x20be\x20disabled\x20at\x20runtime.\x20'+'Set\x20WOWOK_CONFIRM_GATE=0\x20in\x20the\x20server\x20environment\x20and\x20restart\x20if\x20you\x20really\x20want\x20it\x20off.');const j=a440a(h);g={'action':'toggle','service':h,'enabled':j,'reminder':i['reminder']};break;}case'disable':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20disable');const k=d,l=getServiceInfo(k);if(!l)throw new Error('Unknown\x20service:\x20'+k+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');if(k==='confirm_gate')throw new Error('confirm_gate\x20cannot\x20be\x20disabled\x20at\x20runtime.\x20'+'Set\x20WOWOK_CONFIRM_GATE=0\x20in\x20the\x20server\x20environment\x20and\x20restart\x20if\x20you\x20really\x20want\x20it\x20off.');a440b(k,![]),g={'action':'disable','service':k,'enabled':![],'reminder':l['reminder']};break;}case'enable':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20enable');const m=d,n=getServiceInfo(m);if(!n)throw new Error('Unknown\x20service:\x20'+m+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');a440b(m,!![]),g={'action':'enable','service':m,'enabled':!![],'reminder':n['reminder']};break;}case'reset':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20reset');const o=d,p=getServiceInfo(o);if(!p)throw new Error('Unknown\x20service:\x20'+o+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');a440c(o),g={'action':'reset','service':o,'enabled':getServiceInfo(o)?.['enabled'],'reminder':p['reminder'],'reset':!![]};break;}case'info':{if(!d)throw new Error('\x27service\x27\x20param\x20is\x20required\x20for\x20info');const q=d,r=getServiceInfo(q);if(!r)throw new Error('Unknown\x20service:\x20'+q+'.\x20Use\x20action=\x27list\x27\x20to\x20see\x20all\x20valid\x20services.');g={'action':'info',...r};break;}case'judgment_list':g={'action':'judgment_list',...judgmentStatus()};break;case'judgment_set':{if(!e)throw new Error('\x27path\x27\x20param\x20is\x20required\x20for\x20judgment_set\x20(dotted,\x20e.g.\x20\x27evaluation.weights.trust_reviews\x27)');if(!('value'in b))throw new Error('\x27value\x27\x20param\x20is\x20required\x20for\x20judgment_set');const s=setJudgmentOverride(e,f);if(!s['ok'])throw new Error(s['error']);g={'action':'judgment_set','path':e,'value':f,'applied':!![]};break;}case'judgment_reset':{const t=e?clearJudgmentOverride(e)?0x1:0x0:clearJudgmentOverrides();g={'action':'judgment_reset',...e?{'path':e}:{},'cleared':t};break;}case'judgment_doc_read':{g={'action':'judgment_doc_read',...readUserJudgmentDocView()};break;}case'judgment_doc_patch':{if(!b['patch']||typeof b['patch']!=='object'||Array['isArray'](b['patch']))throw new Error('\x27patch\x27\x20param\x20is\x20required\x20for\x20judgment_doc_patch\x20(a\x20partial\x20judgment\x20document\x20object,\x20e.g.\x20{\x22evaluation\x22:\x20{\x22weights\x22:\x20{…}}})');g={'action':'judgment_doc_patch',...patchUserJudgmentDoc(b['patch'])};break;}default:throw new Error('Unknown\x20config_operation\x20action:\x20'+String(c));}return{'content':[{'type':'text','text':JSON['stringify']({'result':g})}],'structuredContent':{'result':g}};}
@@ -1 +1 @@
1
- import{strictParse,MessengerOperationInputSchema}from'../../schema/index.js';import{watch_conversations,send_message,send_file,watch_messages,export_attachment,pull_messages,generate_wts,verify_wts,sign_wts,wts2html,proof_message,mark_messages_as_viewed,mark_conversation_as_viewed,blacklist,friendslist,guardlist,settings,LocalInfo}from'@wowok/wowok';import{classifyError,buildDataSemantic}from'../../schema/call/semantic.js';import{classifyCommunicationEvidence}from'../../communication/evidence.js';import{attestWtsFile}from'../../communication/wts-attestation.js';import{goalEngine}from'../../goal/GoalEngine.js';export function normalizeAccountOrMark(a){if(typeof a==='string')return{'name_or_address':a,'local_mark_first':!![]};return a;}export function normalizeOptionalAccountOrMark(a){if(a===undefined||a===null)return undefined;return normalizeAccountOrMark(a);}export function normalizeManyAccountOrMark(a){if(a===undefined||a===null)return undefined;if(Array['isArray'](a))return{'entities':a['map'](b=>typeof b==='string'?{'name_or_address':b,'local_mark_first':!![]}:b),'check_all_founded':!![]};return a;}function communicationEvidencePayload(a,b){const c=b??{};switch(a){case'send_message':case'send_file':{const d=typeof c['messageId']==='string'?c['messageId']:undefined;return{'detail':d?'message\x20'+d:'message\x20sent','data':d?{'message_id':d}:{}};}case'send_required_info':{const e=typeof c['messageId']==='string'?c['messageId']:undefined,f=Array['isArray'](c['sent_fields'])?c['sent_fields']:undefined;return{'detail':'required-info\x20confirmation\x20sent','data':{...e?{'message_id':e}:{},...f?{'sent_fields':f}:{}}};}case'generate_wts':{const g=typeof c['totalMessageCount']==='number'?c['totalMessageCount']:undefined,h=Array['isArray'](c['files'])?c['files']:undefined,i=Array['isArray'](c['htmlFiles'])?c['htmlFiles']:undefined;return{'detail':'WTS\x20evidence\x20packet\x20generated','data':{...g!==undefined?{'message_count':g}:{},...h?{'files':h}:{},...i?{'html_reports':i}:{}}};}case'verify_wts':{const j=c['attestation'],k=typeof c['error']==='string'?c['error']:undefined;return{'detail':j?'WTS\x20verification\x20—\x20'+j['attested_count']+'/'+j['total_messages']+'\x20message(s)\x20server-attested':'WTS\x20verification\x20—\x20server\x20attestation\x20unavailable','data':{'valid':c['valid']===!![],'hash_valid':c['hashValid']===!![],'has_signature':c['hasSignature']===!![],...c['signatureValid']===undefined?{}:{'packet_signature_valid':c['signatureValid']===!![]},...k?{'error':k}:{},...j?{'attested_messages':j['attested_count'],'total_messages':j['total_messages'],'fully_attested':j['fully_attested'],'packet_signed':j['packet_signed'],'server_public_keys':j['server_public_keys'],'verdict':j['verdict']}:{'attestation':'unavailable\x20—\x20cross-check\x20the\x20seal\x20signer\x20and\x20server\x20keys\x20independently\x20before\x20treating\x20the\x20packet\x20as\x20third-party\x20evidence'}}};}case'sign_wts':{return{'detail':typeof b==='string'?b:'WTS\x20evidence\x20signed','data':{}};}case'proof_message':{const l=typeof c['proofAddress']==='string'?c['proofAddress']:undefined;return{'detail':l?'proof\x20'+l:'message\x20proofed\x20on-chain','data':l?{'proof_address':l}:{}};}default:return{'detail':a,'data':{}};}}export async function handleMessengerOperation(a){let b;try{b=strictParse(MessengerOperationInputSchema,a,'messenger_operation\x20input');const c=b['operation'];let d;switch(b['operation']){case'watch_conversations':{const g=await watch_conversations(b['filter']);d={'operation':'watch_conversations','result':g};break;}case'send_message':{const h=await send_message(normalizeOptionalAccountOrMark(b['from']),normalizeAccountOrMark(b['to']),b['content'],b['options']);if(h['authRequired']){d={'operation':'send_message','result':h};break;}const i=h,j={...i,'merkleData':i['merkleData']?{'leafIndex':i['merkleData']['leafIndex'],'prevRoot':i['merkleData']['prevRoot'],'newRoot':i['merkleData']['newRoot'],'serverSignature':i['merkleData']['serverSignature'],'serverTimestamp':i['merkleData']['serverTimestamp'],'serverPublicKey':i['merkleData']['serverPublicKey']}:undefined};d={'operation':'send_message','result':j};break;}case'send_file':{const k=await send_file(normalizeOptionalAccountOrMark(b['from']),normalizeAccountOrMark(b['to']),b['filePath'],b['options']),l=k,m={...l,'merkleData':l['merkleData']?{'leafIndex':l['merkleData']['leafIndex'],'prevRoot':l['merkleData']['prevRoot'],'newRoot':l['merkleData']['newRoot'],'serverSignature':l['merkleData']['serverSignature'],'serverTimestamp':l['merkleData']['serverTimestamp'],'serverPublicKey':l['merkleData']['serverPublicKey']}:undefined};d={'operation':'send_file','result':m};break;}case'send_required_info':{let n=b['content'];const o=[];if(!n){const s=await LocalInfo['Instance']()['list'](),t=b['fields'],u=t&&t['length']>0x0?s['filter'](v=>t['includes'](v['name'])):s;if(u['length']===0x0)throw new Error('No\x20LocalInfo\x20fields\x20available.\x20Add\x20private\x20info\x20first\x20via\x20local_info_operation.');n=u['map'](v=>v['name']+':\x20'+v['default'])['join']('\x0a'),o['push'](...u['map'](v=>v['name']));}const p=await send_message(normalizeOptionalAccountOrMark(b['from']),normalizeAccountOrMark(b['to']),n,b['options']),q=p,r={...q,'merkleData':q['merkleData']?{'leafIndex':q['merkleData']['leafIndex'],'prevRoot':q['merkleData']['prevRoot'],'newRoot':q['merkleData']['newRoot'],'serverSignature':q['merkleData']['serverSignature'],'serverTimestamp':q['merkleData']['serverTimestamp'],'serverPublicKey':q['merkleData']['serverPublicKey']}:undefined,'sent_fields':o};d={'operation':'send_required_info','result':r};break;}case'watch_messages':{const v=b['filter']?{...b['filter'],'peerAddress':b['filter']['peerAddress']?normalizeAccountOrMark(b['filter']['peerAddress']):undefined,'account':b['filter']['account']?normalizeOptionalAccountOrMark(b['filter']['account']):undefined}:undefined,w=await watch_messages(v);d={'operation':'watch_messages','result':w};break;}case'save_attachment':{const x=await export_attachment(normalizeOptionalAccountOrMark(b['account']),b['messageId'],{'outputDir':b['outputDir'],'saveAs':b['saveAs']});d={'operation':'save_attachment','result':x};break;}case'generate_wts':{const y=b['params']?{...b['params'],'peerAccount':normalizeAccountOrMark(b['params']['peerAccount']),'myAccount':normalizeOptionalAccountOrMark(b['params']['myAccount'])}:undefined,z=await generate_wts(y);d={'operation':'generate_wts','result':z};break;}case'verify_wts':{const A=await verify_wts(b['wtsFilePath']),B=await attestWtsFile(b['wtsFilePath']);d={'operation':'verify_wts','result':B?{...A,'attestation':B}:{...A,'attestation_unavailable':'Per-message\x20server\x20attestation\x20could\x20not\x20be\x20computed\x20(file\x20not\x20readable\x20locally\x20or\x20not\x20JSON).\x20The\x20guarded\x20verifier\x27s\x20valid\x20flag\x20already\x20required\x20server\x20attestation\x20+\x20seal;\x20cross-check\x20the\x20seal\x20signer\x20and\x20server\x20keys\x20yourself\x20before\x20treating\x20it\x20as\x20third-party\x20evidence.'}};break;}case'sign_wts':{const C=await sign_wts(b['wtsFilePath'],normalizeOptionalAccountOrMark(b['account']),b['outputPath']);d={'operation':'sign_wts','result':C};break;}case'wts2html':{const D=await wts2html(b['wtsPath'],b['options']);d={'operation':'wts2html','result':D};break;}case'proof_message':{const E=await proof_message(normalizeOptionalAccountOrMark(b['account']),b['messageId'],b['network']);d={'operation':'proof_message','result':E};break;}case'blacklist':{const F={'account':normalizeOptionalAccountOrMark(b['account']),'op':b['blacklist']['op']};'users'in b['blacklist']&&(F['users']=normalizeManyAccountOrMark(b['blacklist']['users']));const G=await blacklist(F);d={'operation':'blacklist','op':b['blacklist']['op'],'result':G['result']};break;}case'friendslist':{const H={'account':normalizeOptionalAccountOrMark(b['account']),'op':b['friendslist']['op']};'users'in b['friendslist']&&(H['users']=normalizeManyAccountOrMark(b['friendslist']['users']));const I=await friendslist(H);d={'operation':'friendslist','op':b['friendslist']['op'],'result':I['result']};break;}case'guardlist':{const J=await guardlist({'account':normalizeOptionalAccountOrMark(b['account']),...b['guardlist']});d={'operation':'guardlist','op':b['guardlist']['op'],'result':J['result']};break;}case'settings':{const K=await settings({'account':normalizeOptionalAccountOrMark(b['account']),...b['settings']});d={'operation':'settings','op':b['settings']['op'],'result':K['result']};break;}case'mark_messages_as_viewed':{const L=await mark_messages_as_viewed(b['messageIds'],normalizeOptionalAccountOrMark(b['account']));d={'operation':'mark_messages_as_viewed','result':L};break;}case'mark_conversation_as_viewed':{const M=await mark_conversation_as_viewed(normalizeAccountOrMark(b['peerAddress']),normalizeOptionalAccountOrMark(b['account']));d={'operation':'mark_conversation_as_viewed','result':M};break;}case'pull_messages':{const N=await pull_messages(normalizeOptionalAccountOrMark(b['account']),b['limit'],{'allAccounts':b['allAccounts'],'accounts':b['accounts']?.['map'](O=>normalizeAccountOrMark(O)),'concurrency':b['concurrency']});d={'operation':'pull_messages','result':N};break;}default:throw new Error('Unknown\x20messenger\x20operation:\x20'+c);}const e=classifyCommunicationEvidence(c),f=b['goal_id'];if(e&&f){const O=d['result'],{detail:P,data:Q}=communicationEvidencePayload(c,O);await goalEngine['recordCommunicationEvidence'](f,{'operation':c,'kind':e['kind'],'title':e['title'],'detail':P,'data':Q},b['network']??'default');}return{'content':[{'type':'text','text':JSON['stringify'](d)}],'structuredContent':{'result':d}};}catch(R){const S=R instanceof Error?R['message']:String(R),T=b?{'operation_type':'messenger_'+b['operation'],'data':b}:undefined,U=classifyError(S),V={'operation':'error','error':S};if(U['error_code']!==undefined)V['error_code']=U['error_code'];if(U['retryable']!==undefined)V['retryable']=U['retryable'];if(U['recovery_hint']!==undefined)V['recovery_hint']=U['recovery_hint'];return{'content':[{'type':'text','text':'Error:\x20'+S}],'structuredContent':{'result':V,'semantic':buildDataSemantic(undefined,T,!![],S)}};}}
1
+ import{strictParse,MessengerOperationInputSchema}from'../../schema/index.js';import{watch_conversations,send_message,send_file,watch_messages,export_attachment,pull_messages,generate_wts,verify_wts,sign_wts,wts2html,proof_message,mark_messages_as_viewed,mark_conversation_as_viewed,blacklist,friendslist,guardlist,settings,LocalInfo}from'@wowok/wowok';import{classifyError,buildDataSemantic}from'../../schema/call/semantic.js';import{classifyCommunicationEvidence}from'../../communication/evidence.js';import{noteProofIssued}from'../../communication/proof-reuse.js';import{attestWtsFile}from'../../communication/wts-attestation.js';import{goalEngine}from'../../goal/GoalEngine.js';export function normalizeAccountOrMark(a){if(typeof a==='string')return{'name_or_address':a,'local_mark_first':!![]};return a;}export function normalizeOptionalAccountOrMark(a){if(a===undefined||a===null)return undefined;return normalizeAccountOrMark(a);}export function normalizeManyAccountOrMark(a){if(a===undefined||a===null)return undefined;if(Array['isArray'](a))return{'entities':a['map'](b=>typeof b==='string'?{'name_or_address':b,'local_mark_first':!![]}:b),'check_all_founded':!![]};return a;}function communicationEvidencePayload(a,b){const c=b??{};switch(a){case'send_message':case'send_file':{const d=typeof c['messageId']==='string'?c['messageId']:undefined;return{'detail':d?'message\x20'+d:'message\x20sent','data':d?{'message_id':d}:{}};}case'send_required_info':{const e=typeof c['messageId']==='string'?c['messageId']:undefined,f=Array['isArray'](c['sent_fields'])?c['sent_fields']:undefined;return{'detail':'required-info\x20confirmation\x20sent','data':{...e?{'message_id':e}:{},...f?{'sent_fields':f}:{}}};}case'generate_wts':{const g=typeof c['totalMessageCount']==='number'?c['totalMessageCount']:undefined,h=Array['isArray'](c['files'])?c['files']:undefined,i=Array['isArray'](c['htmlFiles'])?c['htmlFiles']:undefined;return{'detail':'WTS\x20evidence\x20packet\x20generated','data':{...g!==undefined?{'message_count':g}:{},...h?{'files':h}:{},...i?{'html_reports':i}:{}}};}case'verify_wts':{const j=c['attestation'],k=typeof c['error']==='string'?c['error']:undefined;return{'detail':j?'WTS\x20verification\x20—\x20'+j['attested_count']+'/'+j['total_messages']+'\x20message(s)\x20server-attested':'WTS\x20verification\x20—\x20server\x20attestation\x20unavailable','data':{'valid':c['valid']===!![],'hash_valid':c['hashValid']===!![],'has_signature':c['hasSignature']===!![],...c['signatureValid']===undefined?{}:{'packet_signature_valid':c['signatureValid']===!![]},...k?{'error':k}:{},...j?{'attested_messages':j['attested_count'],'total_messages':j['total_messages'],'fully_attested':j['fully_attested'],'packet_signed':j['packet_signed'],'server_public_keys':j['server_public_keys'],'verdict':j['verdict']}:{'attestation':'unavailable\x20—\x20cross-check\x20the\x20seal\x20signer\x20and\x20server\x20keys\x20independently\x20before\x20treating\x20the\x20packet\x20as\x20third-party\x20evidence'}}};}case'sign_wts':{return{'detail':typeof b==='string'?b:'WTS\x20evidence\x20signed','data':{}};}case'proof_message':{const l=typeof c['proofAddress']==='string'?c['proofAddress']:undefined;return{'detail':l?'proof\x20'+l:'message\x20proofed\x20on-chain','data':l?{'proof_address':l}:{}};}default:return{'detail':a,'data':{}};}}export async function handleMessengerOperation(a){let b;try{b=strictParse(MessengerOperationInputSchema,a,'messenger_operation\x20input');const c=b['operation'];let d;switch(b['operation']){case'watch_conversations':{const g=await watch_conversations(b['filter']);d={'operation':'watch_conversations','result':g};break;}case'send_message':{const h=await send_message(normalizeOptionalAccountOrMark(b['from']),normalizeAccountOrMark(b['to']),b['content'],b['options']);if(h['authRequired']){d={'operation':'send_message','result':h};break;}const i=h,j={...i,'merkleData':i['merkleData']?{'leafIndex':i['merkleData']['leafIndex'],'prevRoot':i['merkleData']['prevRoot'],'newRoot':i['merkleData']['newRoot'],'serverSignature':i['merkleData']['serverSignature'],'serverTimestamp':i['merkleData']['serverTimestamp'],'serverPublicKey':i['merkleData']['serverPublicKey']}:undefined};d={'operation':'send_message','result':j};break;}case'send_file':{const k=await send_file(normalizeOptionalAccountOrMark(b['from']),normalizeAccountOrMark(b['to']),b['filePath'],b['options']),l=k,m={...l,'merkleData':l['merkleData']?{'leafIndex':l['merkleData']['leafIndex'],'prevRoot':l['merkleData']['prevRoot'],'newRoot':l['merkleData']['newRoot'],'serverSignature':l['merkleData']['serverSignature'],'serverTimestamp':l['merkleData']['serverTimestamp'],'serverPublicKey':l['merkleData']['serverPublicKey']}:undefined};d={'operation':'send_file','result':m};break;}case'send_required_info':{let n=b['content'];const o=[];if(!n){const s=await LocalInfo['Instance']()['list'](),t=b['fields'],u=t&&t['length']>0x0?s['filter'](v=>t['includes'](v['name'])):s;if(u['length']===0x0)throw new Error('No\x20LocalInfo\x20fields\x20available.\x20Add\x20private\x20info\x20first\x20via\x20local_info_operation.');n=u['map'](v=>v['name']+':\x20'+v['default'])['join']('\x0a'),o['push'](...u['map'](v=>v['name']));}const p=await send_message(normalizeOptionalAccountOrMark(b['from']),normalizeAccountOrMark(b['to']),n,b['options']),q=p,r={...q,'merkleData':q['merkleData']?{'leafIndex':q['merkleData']['leafIndex'],'prevRoot':q['merkleData']['prevRoot'],'newRoot':q['merkleData']['newRoot'],'serverSignature':q['merkleData']['serverSignature'],'serverTimestamp':q['merkleData']['serverTimestamp'],'serverPublicKey':q['merkleData']['serverPublicKey']}:undefined,'sent_fields':o};d={'operation':'send_required_info','result':r};break;}case'watch_messages':{const v=b['filter']?{...b['filter'],'peerAddress':b['filter']['peerAddress']?normalizeAccountOrMark(b['filter']['peerAddress']):undefined,'account':b['filter']['account']?normalizeOptionalAccountOrMark(b['filter']['account']):undefined}:undefined,w=await watch_messages(v);d={'operation':'watch_messages','result':w};break;}case'save_attachment':{const x=await export_attachment(normalizeOptionalAccountOrMark(b['account']),b['messageId'],{'outputDir':b['outputDir'],'saveAs':b['saveAs']});d={'operation':'save_attachment','result':x};break;}case'generate_wts':{const y=b['params']?{...b['params'],'peerAccount':normalizeAccountOrMark(b['params']['peerAccount']),'myAccount':normalizeOptionalAccountOrMark(b['params']['myAccount'])}:undefined,z=await generate_wts(y);d={'operation':'generate_wts','result':z};break;}case'verify_wts':{const A=await verify_wts(b['wtsFilePath']),B=await attestWtsFile(b['wtsFilePath']);d={'operation':'verify_wts','result':B?{...A,'attestation':B}:{...A,'attestation_unavailable':'Per-message\x20server\x20attestation\x20could\x20not\x20be\x20computed\x20(file\x20not\x20readable\x20locally\x20or\x20not\x20JSON).\x20The\x20guarded\x20verifier\x27s\x20valid\x20flag\x20already\x20required\x20server\x20attestation\x20+\x20seal;\x20cross-check\x20the\x20seal\x20signer\x20and\x20server\x20keys\x20yourself\x20before\x20treating\x20it\x20as\x20third-party\x20evidence.'}};break;}case'sign_wts':{const C=await sign_wts(b['wtsFilePath'],normalizeOptionalAccountOrMark(b['account']),b['outputPath']);d={'operation':'sign_wts','result':C};break;}case'wts2html':{const D=await wts2html(b['wtsPath'],b['options']);d={'operation':'wts2html','result':D};break;}case'proof_message':{const E=await proof_message(normalizeOptionalAccountOrMark(b['account']),b['messageId'],b['network']),F=E?.['proofAddress'];if(typeof F==='string')noteProofIssued(F);d={'operation':'proof_message','result':E};break;}case'blacklist':{const G={'account':normalizeOptionalAccountOrMark(b['account']),'op':b['blacklist']['op']};'users'in b['blacklist']&&(G['users']=normalizeManyAccountOrMark(b['blacklist']['users']));const H=await blacklist(G);d={'operation':'blacklist','op':b['blacklist']['op'],'result':H['result']};break;}case'friendslist':{const I={'account':normalizeOptionalAccountOrMark(b['account']),'op':b['friendslist']['op']};'users'in b['friendslist']&&(I['users']=normalizeManyAccountOrMark(b['friendslist']['users']));const J=await friendslist(I);d={'operation':'friendslist','op':b['friendslist']['op'],'result':J['result']};break;}case'guardlist':{const K=await guardlist({'account':normalizeOptionalAccountOrMark(b['account']),...b['guardlist']});d={'operation':'guardlist','op':b['guardlist']['op'],'result':K['result']};break;}case'settings':{const L=await settings({'account':normalizeOptionalAccountOrMark(b['account']),...b['settings']});d={'operation':'settings','op':b['settings']['op'],'result':L['result']};break;}case'mark_messages_as_viewed':{const M=await mark_messages_as_viewed(b['messageIds'],normalizeOptionalAccountOrMark(b['account']));d={'operation':'mark_messages_as_viewed','result':M};break;}case'mark_conversation_as_viewed':{const N=await mark_conversation_as_viewed(normalizeAccountOrMark(b['peerAddress']),normalizeOptionalAccountOrMark(b['account']));d={'operation':'mark_conversation_as_viewed','result':N};break;}case'pull_messages':{const O=await pull_messages(normalizeOptionalAccountOrMark(b['account']),b['limit'],{'allAccounts':b['allAccounts'],'accounts':b['accounts']?.['map'](P=>normalizeAccountOrMark(P)),'concurrency':b['concurrency']});d={'operation':'pull_messages','result':O};break;}default:throw new Error('Unknown\x20messenger\x20operation:\x20'+c);}const e=classifyCommunicationEvidence(c),f=b['goal_id'];if(e&&f){const P=d['result'],{detail:Q,data:R}=communicationEvidencePayload(c,P);await goalEngine['recordCommunicationEvidence'](f,{'operation':c,'kind':e['kind'],'title':e['title'],'detail':Q,'data':R},b['network']??'default');}return{'content':[{'type':'text','text':JSON['stringify'](d)}],'structuredContent':{'result':d}};}catch(S){const T=S instanceof Error?S['message']:String(S),U=b?{'operation_type':'messenger_'+b['operation'],'data':b}:undefined,V=classifyError(T),W={'operation':'error','error':T};if(V['error_code']!==undefined)W['error_code']=V['error_code'];if(V['retryable']!==undefined)W['retryable']=V['retryable'];if(V['recovery_hint']!==undefined)W['recovery_hint']=V['recovery_hint'];return{'content':[{'type':'text','text':'Error:\x20'+T}],'structuredContent':{'result':W,'semantic':buildDataSemantic(undefined,U,!![],T)}};}}