@wowok/agent-mcp 3.2.1 → 3.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/dist/communication/wts-attestation.d.ts +34 -0
  2. package/dist/communication/wts-attestation.js +1 -0
  3. package/dist/config/judgment.d.ts +25 -0
  4. package/dist/config/rule-engine.d.ts +10 -0
  5. package/dist/config/rule-engine.js +1 -1
  6. package/dist/evaluation/builtins/graph-service.spec.js +1 -1
  7. package/dist/evaluation/engine.js +1 -1
  8. package/dist/experience/realtime-feedback.js +1 -1
  9. package/dist/extensions/industry-pack.js +1 -1
  10. package/dist/graph/onchain/expand.js +1 -1
  11. package/dist/graph/onchain/exposure.js +1 -1
  12. package/dist/knowledge/allocation-risk.d.ts +2 -1
  13. package/dist/knowledge/allocation-risk.js +1 -1
  14. package/dist/knowledge/allocation-templates.js +1 -1
  15. package/dist/knowledge/audit-rules.js +1 -1
  16. package/dist/knowledge/baselines/rules/allocation.json +31 -1
  17. package/dist/knowledge/builtin-templates.d.ts +3 -1
  18. package/dist/knowledge/builtin-templates.js +1 -1
  19. package/dist/knowledge/entity-recipient-guard.d.ts +21 -0
  20. package/dist/knowledge/entity-recipient-guard.js +1 -0
  21. package/dist/knowledge/getting-started.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-topology.d.ts +34 -0
  27. package/dist/knowledge/machine-topology.js +1 -1
  28. package/dist/knowledge/scenario-modes.d.ts +1 -0
  29. package/dist/knowledge/scenario-modes.js +1 -1
  30. package/dist/knowledge/strategy-manuals.js +1 -1
  31. package/dist/knowledge/template-loader.d.ts +21 -0
  32. package/dist/knowledge/template-loader.js +1 -1
  33. package/dist/knowledge/template-registry.js +1 -1
  34. package/dist/knowledge/template-scanner.js +1 -1
  35. package/dist/knowledge/tool-constraints.js +1 -1
  36. package/dist/knowledge/tools-reference.js +1 -1
  37. package/dist/knowledge/workflow-guidance.d.ts +4 -0
  38. package/dist/knowledge/workflow-guidance.js +1 -1
  39. package/dist/monitor/MonitorLoop.js +1 -1
  40. package/dist/playbooks/service-build/business-puzzle.js +1 -1
  41. package/dist/playbooks/service-build/index.d.ts +1 -0
  42. package/dist/playbooks/service-build/intent-analyzer.d.ts +1 -0
  43. package/dist/playbooks/service-build/intent-analyzer.js +1 -1
  44. package/dist/playbooks/service-build/machine-nodes.d.ts +1 -1
  45. package/dist/playbooks/service-build/machine-nodes.js +1 -1
  46. package/dist/playbooks/service-build/machine-panorama.js +1 -1
  47. package/dist/playbooks/service-build/object-panorama.d.ts +27 -1
  48. package/dist/playbooks/service-build/object-panorama.js +1 -1
  49. package/dist/playbooks/service-build/participation-radar.js +1 -1
  50. package/dist/playbooks/service-build/pipeline-actions.d.ts +4 -0
  51. package/dist/playbooks/service-build/pipeline-actions.js +1 -1
  52. package/dist/playbooks/service-build/relationship-profile.js +1 -1
  53. package/dist/playbooks/service-build/semantic-graph.d.ts +1 -0
  54. package/dist/playbooks/service-build/semantic-graph.js +1 -1
  55. package/dist/playbooks/service-build/service-panorama.js +1 -1
  56. package/dist/playbooks/service-build/service-quote.js +1 -1
  57. package/dist/review/index.js +1 -1
  58. package/dist/safety/confirm-gate.js +1 -1
  59. package/dist/schema/call/machine.d.ts +1 -0
  60. package/dist/schema/call/machine.js +1 -1
  61. package/dist/schema/call/semantic.js +1 -1
  62. package/dist/schema/call/service.js +1 -1
  63. package/dist/schema/common/index.js +1 -1
  64. package/dist/schema/goal/planning.d.ts +7 -0
  65. package/dist/schema/goal/planning.js +1 -1
  66. package/dist/schema/industry-pack/index.d.ts +24 -0
  67. package/dist/schema/industry-pack/index.js +1 -1
  68. package/dist/schema/local/index.js +1 -1
  69. package/dist/schema/messenger/index.d.ts +20 -0
  70. package/dist/schema/messenger/index.js +1 -1
  71. package/dist/schema/operations.d.ts +2 -0
  72. package/dist/schema/persona/index.d.ts +110 -0
  73. package/dist/schema/query/bi.d.ts +2 -0
  74. package/dist/schema/query/bi.js +1 -1
  75. package/dist/schema/schema-version.js +1 -1
  76. package/dist/schema/utils/node-parser.js +1 -1
  77. package/dist/schema-query-impl/index.js +1 -1
  78. package/dist/schemas/index.json +1 -1
  79. package/dist/schemas/industry_pack_operation.output.json +109 -0
  80. package/dist/schemas/industry_pack_operation.schema.json +3 -1
  81. package/dist/schemas/messenger_operation.output.json +42 -4
  82. package/dist/schemas/onchain_operations.schema.json +5 -5
  83. package/dist/schemas/onchain_operations_machine.schema.json +2 -2
  84. package/dist/schemas/onchain_operations_service.schema.json +3 -3
  85. package/dist/schemas/onchain_table_data.output.json +5 -1
  86. package/dist/schemas/persona_operation.output.json +266 -0
  87. package/dist/schemas/persona_operation.schema.json +42 -0
  88. package/dist/schemas/query_toolkit.output.json +1 -1
  89. package/dist/schemas/query_toolkit.schema.json +5 -1
  90. package/dist/tools/handlers/benchmark-migration.d.ts +17 -0
  91. package/dist/tools/handlers/benchmark-migration.js +1 -1
  92. package/dist/tools/handlers/config.js +1 -1
  93. package/dist/tools/handlers/industry-pack.js +1 -1
  94. package/dist/tools/handlers/messenger.js +1 -1
  95. package/dist/tools/handlers/onchain.js +1 -1
  96. package/dist/tools/registry/business.js +1 -1
  97. package/package.json +4 -3
@@ -1 +1 @@
1
- import{NodeSchema}from'../call/machine.js';import{MachineNodeSchema,MachineNodePairSchema,MachineForwardSchema}from'../query/index.js';import{writeFileSync}from'fs';function detectFormat(a){const b=a['trim']();if(b['startsWith']('{')||b['startsWith']('['))return'json';return'markdown';}function extractJsonFromMarkdown(a){const b=/```(?:json)?\s*\n([\s\S]*?)```/g;let c,d=null;while((c=b['exec'](a))!==null){const e=c[0x1]['trim']();if(e['startsWith']('[')||e['startsWith']('{')){const f=a['substring'](0x0,c['index']),g=(f['match'](/\n/g)||[])['length']+0x1;d={'json':e,'lineOffset':g};}}return d;}function parseMarkdownToNodeData(a){const b=[],c=extractJsonFromMarkdown(a);if(c)try{const j=JSON['parse'](c['json']);return{'data':j,'errors':[]};}catch(k){return b['push']({'message':'Failed\x20to\x20parse\x20JSON\x20from\x20markdown:\x20'+k['message'],'path':'/'}),{'data':null,'errors':b};}const d={'op':'add'},f=[],g=a['match'](/(?:^|\n)#+\s*Operation[^\n]*\n+[-*]\s*op\s*:\s*(\w+)/i);g&&(d['op']=g[0x1]['toLowerCase']());const h=a['match'](/(?:^|\n)#+\s*Options[^\n]*\n+[-*]\s*bReplace\s*:\s*(true|false)/i);h&&(d['bReplace']=h[0x1]['toLowerCase']()==='true');const i=a['split'](/(?=^##\s*Node[:\s])/m);for(const l of i['slice'](0x1)){const m=l['match'](/^##\s*Node[:\s]+(.+?)(?:\n|$)/im);if(!m)continue;const n=m[0x1]['trim'](),o={'name':n,'pairs':[]},p=l['split'](/(?=^###\s*(?:Pair|Previous Node)[:\s])/m);for(const q of p['slice'](0x1)){const r=q['match'](/(?:^|\n)[-*]\s*prev_node\s*[:]\s*(.+?)(?:\n|$)/im)||q['match'](/^###\s*(?:Pair|Previous Node)[:\s]+(.+?)(?:\n|$)/im),s=q['match'](/(?:^|\n)[-*]\s*threshold\s*[:]\s*(\d+)/i);if(!r)continue;const t={'prev_node':r[0x1]['trim'](),'threshold':s?parseInt(s[0x1],0xa):0x0,'forwards':[]},u=q['match'](/\|[^\n]+\|/g);if(u&&u['length']>0x2)for(const w of u['slice'](0x2)){const x=w['split']('|')['filter'](y=>y['trim']())['map'](y=>y['trim']());if(x['length']>=0x2){const y={'name':x[0x0],'weight':parseInt(x[0x1],0xa)||0x0};x['length']>=0x3&&x[0x2]&&x[0x2]!=='-'&&(y['namedOperator']=x[0x2]),x['length']>=0x4&&x[0x3]&&x[0x3]!=='-'&&(y['permissionIndex']=parseInt(x[0x3],0xa)),x['length']>=0x5&&x[0x4]&&x[0x4]!=='-'&&(y['guard']=x[0x4]),t['forwards']['push'](y);}}const v=q['matchAll'](/(?:^|\n)[-*]\s*(?:forward)?\s*[:]?\s*\n?([\s\S]*?)(?=(?:\n[-*]\s*(?:forward|prev_node|threshold))|\n###|\n##|$)/gi);for(const z of v){const A=z[0x1],B=A['match'](/\s*name\s*[:]\s*(.+?)(?:\n|$)/im),C=A['match'](/\s*weight\s*[:]\s*(\d+)/i);if(B&&C){const D={'name':B[0x1]['trim'](),'weight':parseInt(C[0x1],0xa)},E=A['match'](/\s*namedOperator\s*[:]\s*(.+?)(?:\n|$)/im),F=A['match'](/\s*permissionIndex\s*[:]\s*(\d+)/i),G=A['match'](/\s*guard\s*[:]\s*(.+?)(?:\n|$)/im);E&&(D['namedOperator']=E[0x1]['trim']()),F&&(D['permissionIndex']=parseInt(F[0x1],0xa)),G&&(D['guard']=G[0x1]['trim']()),t['forwards']['push'](D);}}o['pairs']['push'](t);}f['push'](o);}return f['length']>0x0&&(d['nodes']=f),{'data':d,'errors':b};}function formatZodPath(a){return'/'+a['map'](b=>String(b)['replace'](/~/g,'~0')['replace'](/\//g,'~1'))['join']('/');}function parseJsonWithErrors(a){const b=[];try{const c=JSON['parse'](a);return{'data':c,'errors':[]};}catch(d){const f=d,g=f['message']['match'](/position\s+(\d+)/);let h=0x1,i=0x1;if(g){const j=parseInt(g[0x1],0xa),k=a['substring'](0x0,j)['split']('\x0a');h=k['length'],i=k[k['length']-0x1]['length']+0x1;}return b['push']({'message':'JSON\x20parse\x20error:\x20'+f['message'],'path':'/','line':h,'column':i}),{'data':null,'errors':b};}}function validateWithZod(a,b,c=''){const d=[],e=a['safeParse'](b);if(e['success'])return{'success':!![],'data':e['data'],'errors':[]};for(const f of e['error']['issues']){const g=c+formatZodPath(f['path']);d['push']({'message':f['message'],'path':g});}return{'success':![],'errors':d};}export function parseNodeFromText(a){const b=a['trim'](),c=detectFormat(b);let d;if(c==='markdown'){const f=parseMarkdownToNodeData(b);if(f['errors']['length']>0x0)return{'success':![],'errors':f['errors']};d=f['data'];}else{const g=parseJsonWithErrors(b);if(g['errors']['length']>0x0)return{'success':![],'errors':g['errors']};d=g['data'];}const e=validateWithZod(NodeSchema,d);return{'success':e['success'],'data':e['data'],'errors':e['errors']};}export function parseMachineNodesFromText(a){const b=a['trim'](),c=detectFormat(b);let d,e=[];if(c==='markdown'){const h=parseMarkdownToNodeData(b);if(h['errors']['length']>0x0)return{'success':![],'errors':h['errors']};typeof h['data']==='object'&&h['data']!==null&&'nodes'in h['data']?d=h['data']['nodes']:d=h['data'];}else{const j=parseJsonWithErrors(b);if(j['errors']['length']>0x0)return{'success':![],'errors':j['errors']};d=j['data'];}if(!Array['isArray'](d)){if(typeof d==='object'&&d!==null&&'op'in d)return{'success':![],'errors':[{'message':'Expected\x20JSON\x20array\x20of\x20nodes\x20for\x20json_or_markdown\x20mode.\x20Use\x20schema\x20mode\x20for\x20operations\x20with\x20\x22op\x22\x20field.','path':'/'}]};return{'success':![],'errors':[{'message':'Expected\x20JSON\x20array\x20of\x20nodes','path':'/'}]};}const f=[];for(let k=0x0;k<d['length'];k++){const l=d[k],m=validateWithZod(MachineNodeSchema,l,'/'+k);m['success']&&m['data']?f['push'](m['data']):e['push'](...m['errors']);}if(e['length']>0x0)return{'success':![],'errors':e};const g=f['some'](n=>n['pairs']['some'](o=>o['prev_node']===''));if(!g)return{'success':![],'errors':[{'message':'Machine\x20has\x20no\x20entry\x20forward.\x20At\x20least\x20one\x20node\x20must\x20have\x20a\x20pair\x20with\x20prev_node=\x22\x22\x20(empty\x20string),\x20'+'which\x20defines\x20how\x20Progress\x20advances\x20from\x20the\x20initial\x20state\x20(current=\x22\x22)\x20to\x20the\x20first\x20node.\x20'+'Without\x20an\x20entry\x20forward,\x20the\x20workflow\x20will\x20be\x20permanently\x20stuck.\x20'+'Example:\x20{name:\x20\x22Subscribed\x22,\x20pairs:\x20[{prev_node:\x20\x22\x22,\x20forwards:\x20[{name:\x20\x22Subscribe\x22,\x20weight:\x201}]}]}','path':'/'}]};return{'success':!![],'data':f,'errors':[]};}export function formatNodeErrors(a){return a['map'](b=>{let c='Path:\x20'+b['path'];return b['line']!==undefined&&b['column']!==undefined&&(c+='\x20(line\x20'+b['line']+',\x20column\x20'+b['column']+')'),c+='\x0a\x20\x20Error:\x20'+b['message'],c;})['join']('\x0a\x0a');}export function validateMachineNode(a){return validateWithZod(MachineNodeSchema,a);}export function validateMachineNodePair(a){const b=MachineNodePairSchema['safeParse'](a);if(b['success'])return{'success':!![],'errors':[]};const c=b['error']['issues']['map'](d=>({'message':d['message'],'path':formatZodPath(d['path'])}));return{'success':![],'errors':c};}export function validateMachineForward(a){const b=MachineForwardSchema['safeParse'](a);if(b['success'])return{'success':!![],'errors':[]};const c=b['error']['issues']['map'](d=>({'message':d['message'],'path':formatZodPath(d['path'])}));return{'success':![],'errors':c};}export function machineNodesToJson(a,b={}){const {machineId:c,includeComments:includeComments=!![]}=b;let d='';return includeComments&&c&&(d+='//\x20Machine\x20ID:\x20'+c+'\x0a'),d+=JSON['stringify'](a,null,0x2),d;}export function machineNodesToMarkdown(a,b={}){const {machineName:c,machineAddress:d,machineId:e,includeComments:includeComments=!![]}=b;let f='#\x20Machine\x20Node\x20Definition\x0a\x0a';c&&(f+='**Machine:**\x20'+c+'\x0a\x0a');d&&(f+='**Address:**\x20'+d+'\x0a\x0a');e&&(f+='**ID:**\x20'+e+'\x0a\x0a');f+='**Total\x20Nodes:**\x20'+a['length']+'\x0a\x0a',f+='---\x0a\x0a';for(const g of a){f+='##\x20Node:\x20'+g['name']+'\x0a\x0a';includeComments&&(f+='<!--\x20Node\x20definition\x20with\x20pairs\x20and\x20forwards\x20-->\x0a\x0a');for(const h of g['pairs']){f+='###\x20Pair:\x20'+h['prev_node']+'\x0a\x0a',f+='-\x20**prev_node**:\x20'+h['prev_node']+'\x0a',f+='-\x20**threshold**:\x20'+h['threshold']+'\x0a\x0a';if(h['forwards']&&h['forwards']['length']>0x0){f+='####\x20Forwards\x0a\x0a',f+='|\x20name\x20|\x20weight\x20|\x20namedOperator\x20|\x20permissionIndex\x20|\x20guard\x20|\x0a',f+='|------|--------|---------------|-----------------|-------|\x0a';for(const i of h['forwards']){const j=i['namedOperator']||'',k=i['permissionIndex']?.['toString']()||'',l=i['guard'],m=typeof l==='string'?l:l?.['guard']||'';f+='|\x20'+i['name']+'\x20|\x20'+i['weight']+'\x20|\x20'+j+'\x20|\x20'+k+'\x20|\x20'+m+'\x20|\x0a';}f+='\x0a';}}f+='---\x0a\x0a';}return f+='##\x20JSON\x20Definition\x0a\x0a',includeComments&&(f+='<!--\x20You\x20can\x20also\x20use\x20the\x20JSON\x20format\x20below\x20-->\x0a\x0a'),f+='```json\x0a',includeComments&&e&&(f+='//\x20Machine\x20ID:\x20'+e+'\x0a'),f+=JSON['stringify'](a,null,0x2),f+='\x0a```\x0a',f;}export function saveMachineNodesToFile(a,b,c='json',d={}){const e=c==='json'?machineNodesToJson(a,d):machineNodesToMarkdown(a,d);writeFileSync(b,e,'utf-8');}
1
+ import{NodeSchema}from'../call/machine.js';import{MachineNodeSchema,MachineNodePairSchema,MachineForwardSchema}from'../query/index.js';import{writeFileSync}from'fs';function detectFormat(a){const b=a['trim']();if(b['startsWith']('{')||b['startsWith']('['))return'json';return'markdown';}function extractJsonFromMarkdown(a){const b=/```(?:json)?\s*\n([\s\S]*?)```/g;let c,d=null;while((c=b['exec'](a))!==null){const e=c[0x1]['trim']();if(e['startsWith']('[')||e['startsWith']('{')){const f=a['substring'](0x0,c['index']),g=(f['match'](/\n/g)||[])['length']+0x1;d={'json':e,'lineOffset':g};}}return d;}function parseMarkdownToNodeData(a){const b=[],c=extractJsonFromMarkdown(a);if(c)try{const j=JSON['parse'](c['json']);return{'data':j,'errors':[]};}catch(k){return b['push']({'message':'Failed\x20to\x20parse\x20JSON\x20from\x20markdown:\x20'+k['message'],'path':'/'}),{'data':null,'errors':b};}const d={'op':'add'},f=[],g=a['match'](/(?:^|\n)#+\s*Operation[^\n]*\n+[-*]\s*op\s*:\s*(\w+)/i);g&&(d['op']=g[0x1]['toLowerCase']());const h=a['match'](/(?:^|\n)#+\s*Options[^\n]*\n+[-*]\s*bReplace\s*:\s*(true|false)/i);h&&(d['bReplace']=h[0x1]['toLowerCase']()==='true');const i=a['split'](/(?=^##\s*Node[:\s])/m);for(const l of i['slice'](0x1)){const m=l['match'](/^##\s*Node[:\s]+(.+?)(?:\n|$)/im);if(!m)continue;const n=m[0x1]['trim'](),o={'name':n,'pairs':[]},p=l['split'](/(?=^###\s*(?:Pair|Previous Node)[:\s])/m);for(const q of p['slice'](0x1)){const r=q['match'](/(?:^|\n)[-*]\s*prev_node\s*[:]\s*(.+?)(?:\n|$)/im)||q['match'](/^###\s*(?:Pair|Previous Node)[:\s]+(.+?)(?:\n|$)/im),s=q['match'](/(?:^|\n)[-*]\s*threshold\s*[:]\s*(\d+)/i);if(!r){const w=q['match'](/(?:^|\n)[-*]\s*prior_node\s*[:]\s*(.+?)(?:\n|$)/im);b['push']({'message':w?'Pair\x20under\x20node\x20\x22'+n+'\x22\x20uses\x20key\x20\x22prior_node:\x20'+w[0x1]['trim']()+'\x22.\x20The\x20field\x20is\x20\x22prev_node\x22\x20—\x20and\x20a\x20pair\x20belongs\x20to\x20the\x20node\x20it\x20advances\x20INTO,\x20not\x20the\x20node\x20it\x20leaves.\x20Rewrite\x20as:\x20{name:\x20\x22<destination>\x22,\x20pairs:\x20[{prev_node:\x20\x22'+w[0x1]['trim']()+'\x22,\x20forwards:\x20[...]}]}':'Pair\x20section\x20under\x20node\x20\x22'+n+'\x22\x20declares\x20no\x20prev_node\x20—\x20the\x20edge\x20would\x20be\x20dropped\x20and\x20the\x20node\x20left\x20with\x20no\x20incoming\x20pair.\x20Add\x20\x22-\x20prev_node:\x20<source\x20node>\x22\x20(use\x20\x22\x22\x20for\x20the\x20entry\x20edge).','path':'/'+n});continue;}const t={'prev_node':r[0x1]['trim'](),'threshold':s?parseInt(s[0x1],0xa):0x0,'forwards':[]},u=q['match'](/\|[^\n]+\|/g);if(u&&u['length']>0x2)for(const x of u['slice'](0x2)){const y=x['split']('|')['filter'](z=>z['trim']())['map'](z=>z['trim']());if(y['length']>=0x2){const z={'name':y[0x0],'weight':parseInt(y[0x1],0xa)||0x0};y['length']>=0x3&&y[0x2]&&y[0x2]!=='-'&&(z['namedOperator']=y[0x2]),y['length']>=0x4&&y[0x3]&&y[0x3]!=='-'&&(z['permissionIndex']=parseInt(y[0x3],0xa)),y['length']>=0x5&&y[0x4]&&y[0x4]!=='-'&&(z['guard']=y[0x4]),t['forwards']['push'](z);}}const v=q['matchAll'](/(?:^|\n)[-*]\s*(?:forward)?\s*[:]?\s*\n?([\s\S]*?)(?=(?:\n[-*]\s*(?:forward|prev_node|threshold))|\n###|\n##|$)/gi);for(const A of v){const B=A[0x1],C=B['match'](/\s*name\s*[:]\s*(.+?)(?:\n|$)/im),D=B['match'](/\s*weight\s*[:]\s*(\d+)/i);if(C&&D){const E={'name':C[0x1]['trim'](),'weight':parseInt(D[0x1],0xa)},F=B['match'](/\s*namedOperator\s*[:]\s*(.+?)(?:\n|$)/im),G=B['match'](/\s*permissionIndex\s*[:]\s*(\d+)/i),H=B['match'](/\s*guard\s*[:]\s*(.+?)(?:\n|$)/im);F&&(E['namedOperator']=F[0x1]['trim']()),G&&(E['permissionIndex']=parseInt(G[0x1],0xa)),H&&(E['guard']=H[0x1]['trim']()),t['forwards']['push'](E);}}o['pairs']['push'](t);}f['push'](o);}return f['length']>0x0&&(d['nodes']=f),{'data':d,'errors':b};}function formatZodPath(a){return'/'+a['map'](b=>String(b)['replace'](/~/g,'~0')['replace'](/\//g,'~1'))['join']('/');}function parseJsonWithErrors(a){const b=[];try{const c=JSON['parse'](a);return{'data':c,'errors':[]};}catch(d){const f=d,g=f['message']['match'](/position\s+(\d+)/);let h=0x1,i=0x1;if(g){const j=parseInt(g[0x1],0xa),k=a['substring'](0x0,j)['split']('\x0a');h=k['length'],i=k[k['length']-0x1]['length']+0x1;}return b['push']({'message':'JSON\x20parse\x20error:\x20'+f['message'],'path':'/','line':h,'column':i}),{'data':null,'errors':b};}}function validateWithZod(a,b,c=''){const d=[],e=a['safeParse'](b);if(e['success'])return{'success':!![],'data':e['data'],'errors':[]};for(const f of e['error']['issues']){const g=c+formatZodPath(f['path']);d['push']({'message':f['message'],'path':g});}return{'success':![],'errors':d};}export function parseNodeFromText(a){const b=a['trim'](),c=detectFormat(b);let d;if(c==='markdown'){const f=parseMarkdownToNodeData(b);if(f['errors']['length']>0x0)return{'success':![],'errors':f['errors']};d=f['data'];}else{const g=parseJsonWithErrors(b);if(g['errors']['length']>0x0)return{'success':![],'errors':g['errors']};d=g['data'];}const e=validateWithZod(NodeSchema,d);return{'success':e['success'],'data':e['data'],'errors':e['errors']};}export function parseMachineNodesFromText(a){const b=a['trim'](),c=detectFormat(b);let d,e=[];if(c==='markdown'){const h=parseMarkdownToNodeData(b);if(h['errors']['length']>0x0)return{'success':![],'errors':h['errors']};typeof h['data']==='object'&&h['data']!==null&&'nodes'in h['data']?d=h['data']['nodes']:d=h['data'];}else{const j=parseJsonWithErrors(b);if(j['errors']['length']>0x0)return{'success':![],'errors':j['errors']};d=j['data'];}if(!Array['isArray'](d)){if(typeof d==='object'&&d!==null&&'op'in d)return{'success':![],'errors':[{'message':'Expected\x20JSON\x20array\x20of\x20nodes\x20for\x20json_or_markdown\x20mode.\x20Use\x20schema\x20mode\x20for\x20operations\x20with\x20\x22op\x22\x20field.','path':'/'}]};return{'success':![],'errors':[{'message':'Expected\x20JSON\x20array\x20of\x20nodes','path':'/'}]};}const f=[];for(let k=0x0;k<d['length'];k++){const l=d[k],m=validateWithZod(MachineNodeSchema,l,'/'+k);m['success']&&m['data']?f['push'](m['data']):e['push'](...m['errors']);}if(e['length']>0x0)return{'success':![],'errors':e};const g=f['some'](n=>n['pairs']['some'](o=>o['prev_node']===''));if(!g)return{'success':![],'errors':[{'message':'Machine\x20has\x20no\x20entry\x20forward.\x20At\x20least\x20one\x20node\x20must\x20have\x20a\x20pair\x20with\x20prev_node=\x22\x22\x20(empty\x20string),\x20'+'which\x20defines\x20how\x20Progress\x20advances\x20from\x20the\x20initial\x20state\x20(current=\x22\x22)\x20to\x20the\x20first\x20node.\x20'+'Without\x20an\x20entry\x20forward,\x20the\x20workflow\x20will\x20be\x20permanently\x20stuck.\x20'+'Example:\x20{name:\x20\x22Subscribed\x22,\x20pairs:\x20[{prev_node:\x20\x22\x22,\x20forwards:\x20[{name:\x20\x22Subscribe\x22,\x20weight:\x201}]}]}','path':'/'}]};return{'success':!![],'data':f,'errors':[]};}export function formatNodeErrors(a){return a['map'](b=>{let c='Path:\x20'+b['path'];return b['line']!==undefined&&b['column']!==undefined&&(c+='\x20(line\x20'+b['line']+',\x20column\x20'+b['column']+')'),c+='\x0a\x20\x20Error:\x20'+b['message'],c;})['join']('\x0a\x0a');}export function validateMachineNode(a){return validateWithZod(MachineNodeSchema,a);}export function validateMachineNodePair(a){const b=MachineNodePairSchema['safeParse'](a);if(b['success'])return{'success':!![],'errors':[]};const c=b['error']['issues']['map'](d=>({'message':d['message'],'path':formatZodPath(d['path'])}));return{'success':![],'errors':c};}export function validateMachineForward(a){const b=MachineForwardSchema['safeParse'](a);if(b['success'])return{'success':!![],'errors':[]};const c=b['error']['issues']['map'](d=>({'message':d['message'],'path':formatZodPath(d['path'])}));return{'success':![],'errors':c};}export function machineNodesToJson(a,b={}){const {machineId:c,includeComments:includeComments=!![]}=b;let d='';return includeComments&&c&&(d+='//\x20Machine\x20ID:\x20'+c+'\x0a'),d+=JSON['stringify'](a,null,0x2),d;}export function machineNodesToMarkdown(a,b={}){const {machineName:c,machineAddress:d,machineId:e,includeComments:includeComments=!![]}=b;let f='#\x20Machine\x20Node\x20Definition\x0a\x0a';c&&(f+='**Machine:**\x20'+c+'\x0a\x0a');d&&(f+='**Address:**\x20'+d+'\x0a\x0a');e&&(f+='**ID:**\x20'+e+'\x0a\x0a');f+='**Total\x20Nodes:**\x20'+a['length']+'\x0a\x0a',f+='---\x0a\x0a';for(const g of a){f+='##\x20Node:\x20'+g['name']+'\x0a\x0a';includeComments&&(f+='<!--\x20Node\x20definition\x20with\x20pairs\x20and\x20forwards\x20-->\x0a\x0a');for(const h of g['pairs']){f+='###\x20Pair:\x20'+h['prev_node']+'\x0a\x0a',f+='-\x20**prev_node**:\x20'+h['prev_node']+'\x0a',f+='-\x20**threshold**:\x20'+h['threshold']+'\x0a\x0a';if(h['forwards']&&h['forwards']['length']>0x0){f+='####\x20Forwards\x0a\x0a',f+='|\x20name\x20|\x20weight\x20|\x20namedOperator\x20|\x20permissionIndex\x20|\x20guard\x20|\x0a',f+='|------|--------|---------------|-----------------|-------|\x0a';for(const i of h['forwards']){const j=i['namedOperator']||'',k=i['permissionIndex']?.['toString']()||'',l=i['guard'],m=typeof l==='string'?l:l?.['guard']||'';f+='|\x20'+i['name']+'\x20|\x20'+i['weight']+'\x20|\x20'+j+'\x20|\x20'+k+'\x20|\x20'+m+'\x20|\x0a';}f+='\x0a';}}f+='---\x0a\x0a';}return f+='##\x20JSON\x20Definition\x0a\x0a',includeComments&&(f+='<!--\x20You\x20can\x20also\x20use\x20the\x20JSON\x20format\x20below\x20-->\x0a\x0a'),f+='```json\x0a',includeComments&&e&&(f+='//\x20Machine\x20ID:\x20'+e+'\x0a'),f+=JSON['stringify'](a,null,0x2),f+='\x0a```\x0a',f;}export function saveMachineNodesToFile(a,b,c='json',d={}){const e=c==='json'?machineNodesToJson(a,d):machineNodesToMarkdown(a,d);writeFileSync(b,e,'utf-8');}
@@ -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 a407a,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=a407a(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 a409a,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=a409a(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};
@@ -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-05T05:05:40.962Z",
5
+ "generatedAt": "2026-10-06T03:08:52.880Z",
6
6
  "tools": [
7
7
  {
8
8
  "name": "onchain_operations",
@@ -135,6 +135,115 @@
135
135
  ],
136
136
  "additionalProperties": false
137
137
  },
138
+ {
139
+ "type": "object",
140
+ "properties": {
141
+ "action": {
142
+ "type": "string",
143
+ "const": "repair_builtin_templates"
144
+ },
145
+ "dir": {
146
+ "type": "string"
147
+ },
148
+ "reseeded_count": {
149
+ "type": "integer",
150
+ "minimum": 0,
151
+ "maximum": 9007199254740991
152
+ },
153
+ "results": {
154
+ "type": "array",
155
+ "items": {
156
+ "type": "object",
157
+ "properties": {
158
+ "template": {
159
+ "type": "string"
160
+ },
161
+ "status": {
162
+ "type": "string"
163
+ },
164
+ "path": {
165
+ "type": "string"
166
+ },
167
+ "detail": {
168
+ "type": "string"
169
+ }
170
+ },
171
+ "required": [
172
+ "template",
173
+ "status",
174
+ "path"
175
+ ],
176
+ "additionalProperties": false
177
+ }
178
+ },
179
+ "note": {
180
+ "type": "string"
181
+ }
182
+ },
183
+ "required": [
184
+ "action",
185
+ "dir",
186
+ "reseeded_count",
187
+ "results",
188
+ "note"
189
+ ],
190
+ "additionalProperties": false
191
+ },
192
+ {
193
+ "type": "object",
194
+ "properties": {
195
+ "action": {
196
+ "type": "string",
197
+ "const": "template_drift"
198
+ },
199
+ "dir": {
200
+ "type": "string"
201
+ },
202
+ "drift_count": {
203
+ "type": "integer",
204
+ "minimum": 0,
205
+ "maximum": 9007199254740991
206
+ },
207
+ "drift": {
208
+ "type": "array",
209
+ "items": {
210
+ "type": "object",
211
+ "properties": {
212
+ "template": {
213
+ "type": "string"
214
+ },
215
+ "path": {
216
+ "type": "string"
217
+ },
218
+ "state": {
219
+ "type": "string"
220
+ },
221
+ "detail": {
222
+ "type": "string"
223
+ }
224
+ },
225
+ "required": [
226
+ "template",
227
+ "path",
228
+ "state",
229
+ "detail"
230
+ ],
231
+ "additionalProperties": false
232
+ }
233
+ },
234
+ "note": {
235
+ "type": "string"
236
+ }
237
+ },
238
+ "required": [
239
+ "action",
240
+ "dir",
241
+ "drift_count",
242
+ "drift",
243
+ "note"
244
+ ],
245
+ "additionalProperties": false
246
+ },
138
247
  {
139
248
  "type": "object",
140
249
  "properties": {
@@ -11,6 +11,8 @@
11
11
  "scaffold",
12
12
  "list",
13
13
  "scan",
14
+ "repair_builtin_templates",
15
+ "template_drift",
14
16
  "resolve",
15
17
  "list_files",
16
18
  "read_file",
@@ -36,7 +38,7 @@
36
38
  "unregister_custom_constraint",
37
39
  "list_metrics_constraints"
38
40
  ],
39
- "description": "Action: 'scaffold' = generate a pack template skeleton (requires name); 'list' = list registered packs; 'scan' = scan + register packs under the default directory; 'resolve' = return the industry root directory; 'list_files' = list files under the industry directory; 'read_file' = read a file under the industry directory (path required); 'write_file' = write content to a file under the industry directory (path + content required); 'get' = return registered layer data for an industry (name required; dispute/compliance/supply/rules/playbook); 'diff' = compare registered vs on-disk manifest version/layers (name required); 'reset' = restore a file or entire pack folder to its pristine annotated template (path required). 'delete_file' = delete a file or directory (path required). 'create_file' = create an empty file (path required; content optional). 'create_dir' = create a directory recursively (path required). 'copy' = copy a file or directory (from + to required). 'move' / 'rename' = move or rename a file or directory (from + to required). Mode registry (industry/scenario configuration): 'recommend_industry' = business intent → top-3 similar industries + reference examples; 'list_modes' = builtin + custom modes; 'derive_user_mode' = derive a custom mode from a builtin; 'evolve_user_mode' = iterate an existing custom mode; 'register_user_mode' = register a fully custom mode; 'unregister_user_mode' = delete a custom mode; 'register_custom_metric' / 'register_custom_constraint' = register global evaluation metric/constraint; 'list_metrics_constraints' = list metrics + constraints (filterable)."
41
+ "description": "Action: 'scaffold' = generate a pack template skeleton (requires name); 'list' = list registered packs; 'scan' = scan + register packs under the default directory; 'template_drift' = REPORT builtin template files whose on-disk body differs from the in-code catalog (classifies no_sentinel_legacy / stale_release / user_modified); run it FIRST when a template change 'seems to have no effect. 'repair_builtin_templates' = RESEED those legacy files from the in-code catalog (identity-gated on a known builtin id, previous body kept as <file>.bak; custom templates never touched)'resolve' = return the industry root directory; 'list_files' = list files under the industry directory; 'read_file' = read a file under the industry directory (path required); 'write_file' = write content to a file under the industry directory (path + content required); 'get' = return registered layer data for an industry (name required; dispute/compliance/supply/rules/playbook); 'diff' = compare registered vs on-disk manifest version/layers (name required); 'reset' = restore a file or entire pack folder to its pristine annotated template (path required). 'delete_file' = delete a file or directory (path required). 'create_file' = create an empty file (path required; content optional). 'create_dir' = create a directory recursively (path required). 'copy' = copy a file or directory (from + to required). 'move' / 'rename' = move or rename a file or directory (from + to required). Mode registry (industry/scenario configuration): 'recommend_industry' = business intent → top-3 similar industries + reference examples; 'list_modes' = builtin + custom modes; 'derive_user_mode' = derive a custom mode from a builtin; 'evolve_user_mode' = iterate an existing custom mode; 'register_user_mode' = register a fully custom mode; 'unregister_user_mode' = delete a custom mode; 'register_custom_metric' / 'register_custom_constraint' = register global evaluation metric/constraint; 'list_metrics_constraints' = list metrics + constraints (filterable)."
40
42
  },
41
43
  "name": {
42
44
  "description": "Industry name (lowercase snake_case, e.g. 'life_service'); required for scaffold and get.",
@@ -1182,7 +1182,7 @@
1182
1182
  "properties": {
1183
1183
  "valid": {
1184
1184
  "type": "boolean",
1185
- "description": "Whether verification succeeded"
1185
+ "description": "Whether verification succeeded. TRUE only when ALL hold (no opt-out exists): the packet is self-consistent (Merkle chain + digest), EVERY message carries a verifying per-message Falcon512 serverSignature, meta.signature seals the packet (binding the declared serverPublicKeys), AND every message's server key exists in the messenger server's official key history with a validity window covering the message's server timestamp (serverKeysOfficial). A freshly generated packet is valid:false until sign_wts seals it."
1186
1186
  },
1187
1187
  "error": {
1188
1188
  "description": "Error message if verification failed",
@@ -1194,14 +1194,14 @@
1194
1194
  },
1195
1195
  "hasSignature": {
1196
1196
  "type": "boolean",
1197
- "description": "Whether WTS has signatures"
1197
+ "description": "Whether the packet carries a meta.signature seal"
1198
1198
  },
1199
1199
  "signatureValid": {
1200
- "description": "Whether signature validation passed",
1200
+ "description": "Whether the packet seal (meta.signature) verified",
1201
1201
  "type": "boolean"
1202
1202
  },
1203
1203
  "signatures": {
1204
- "description": "Signature verification details",
1204
+ "description": "Packet seal verification details (per signer address)",
1205
1205
  "type": "array",
1206
1206
  "items": {
1207
1207
  "type": "object",
@@ -1226,6 +1226,44 @@
1226
1226
  "additionalProperties": false,
1227
1227
  "description": "WTS signature verification details"
1228
1228
  }
1229
+ },
1230
+ "attestedCount": {
1231
+ "description": "Messages whose serverSignature verified under a key the packet supplies",
1232
+ "type": "number"
1233
+ },
1234
+ "unattestedCount": {
1235
+ "description": "Messages with no verifying server signature (absent, or key unresolvable)",
1236
+ "type": "number"
1237
+ },
1238
+ "serverKeysOfficial": {
1239
+ "description": "True when every message's server key is in the server's OFFICIAL key history (rotation-aware) AND the key book itself matches its ON-CHAIN anchor (a well-known Repository record writable only by the pinned wowok signer). False — or absent because the key book or chain was unreachable — means the packet must NOT be treated as third-party evidence: a forger can mint a server key and self-sign a fully 'verifying' packet, and a fake server can serve a book full of forger keys.",
1240
+ "type": "boolean"
1241
+ },
1242
+ "serverKeyAnchor": {
1243
+ "description": "On-chain anchor verdict for the key book: the locally recomputed canonical hash must equal the hash in the keybook Repository record. verified:false (signer not pinned, anchor not deployed, hash mismatch, chain unreachable) forces valid:false and serverKeysOfficial:false.",
1244
+ "type": "object",
1245
+ "properties": {
1246
+ "verified": {
1247
+ "type": "boolean"
1248
+ },
1249
+ "network": {
1250
+ "type": "string"
1251
+ },
1252
+ "anchoredHash": {
1253
+ "type": "string"
1254
+ },
1255
+ "computedHash": {
1256
+ "type": "string"
1257
+ },
1258
+ "reason": {
1259
+ "type": "string"
1260
+ }
1261
+ },
1262
+ "required": [
1263
+ "verified",
1264
+ "network"
1265
+ ],
1266
+ "additionalProperties": false
1229
1267
  }
1230
1268
  },
1231
1269
  "required": [
@@ -250,7 +250,7 @@
250
250
  "additionalProperties": false
251
251
  },
252
252
  "namedNewOrder": {
253
- "description": "RECOMMENDED: Set a local name for the newly created Order object. Without this, the Order is only referenceable by its on-chain address. Example: {name: 'my_order_v1'} allows subsequent operations to use 'my_order_v1' instead of the address. PLACEMENT: this field MUST be inside data.order_new (it is an OrderNew field) — putting namedNewOrder at the data root fails schema validation with 'Unrecognized key'. MIGRATION TIP: for batch/migration order creation, always auto-generate readable names (e.g. '<source>_<service>_<seq>' like 'upwork_svc_v1_0001') — unnamed orders (head.name = null) are only address-referenceable, which breaks downstream queries, displays and audits (E-8).",
253
+ "description": "RECOMMENDED: Set a local name for the newly created Order object. Without this, the Order is only referenceable by its on-chain address. Example: {name: 'my_order_v1'} allows subsequent operations to use 'my_order_v1' instead of the address. PLACEMENT: this field MUST be inside data.order_new (it is an OrderNew field) — putting namedNewOrder at the data root fails schema validation with 'Unrecognized key'. MIGRATION TIP: for batch/migration order creation, always auto-generate readable names (e.g. '<source>_<service>_<seq>' like 'my_shop_svc_v1_0001') — unnamed orders (head.name = null) are only address-referenceable, which breaks downstream queries, displays and audits (E-8).",
254
254
  "type": "object",
255
255
  "properties": {
256
256
  "name": {
@@ -668,7 +668,7 @@
668
668
  "suspension"
669
669
  ],
670
670
  "additionalProperties": false,
671
- "description": "Suspend or resume ONE product without removing it (keeps price/stock/WIP binding). The Amazon-style 'out of stock / listing inactive' state. Only the named product is touched; an unknown sale_name is silently ignored on-chain (verify with query_toolkit afterwards)."
671
+ "description": "Suspend or resume ONE product without removing it (keeps price/stock/WIP binding). The retail-style 'out of stock / listing inactive' state. Only the named product is touched; an unknown sale_name is silently ignored on-chain (verify with query_toolkit afterwards)."
672
672
  }
673
673
  ]
674
674
  },
@@ -1014,7 +1014,7 @@
1014
1014
  }
1015
1015
  },
1016
1016
  "order_allocators": {
1017
- "description": "Order fund allocator. Max 100 allocators (MAX_ALLOCATOR_COUNT). ✅ EACH allocator has a guard, and EVERY allocator whose guard address matches the supplied guard RUNS — they are NOT mutually exclusive and NOT first-match-wins. One guard may legitimately authorize several distribution rules (different fix / rate / cap); each contributes its own Payment and consumes its own once-slot (keyed by the allocator index). Allocators are evaluated in vector order against the SHRINKING pool, so a later allocator only sees the balance left by the earlier ones — which is exactly how a waterfall (e.g. Amount fee + net Rate split) is built. On-chain truth: wow::allocation (allocation.move:291-296, `while` loop over all allocators, `if (guard address == alloc.guard)`). ⚠️ If you WANT mutual exclusion you must express it inside the Guard itself (make the conditions logically exclusive). Set to null to clear. ⚠️ PERMANENTLY IMMUTABLE after publish: order_allocators can ONLY be set BEFORE publish=true (on-chain check rejects after publish — E_ALREADY_PUBLISHED). After publish, the ONLY way to change allocation rules is to create a NEW Service object. There is NO pause+lock exception for order_allocators (unlike arbitrations/rewards which have time-lock removal). PRE-PUBLISH CHECKLIST: verify all guard names resolve, all sharing amounts are correct, threshold is set, and recipient types (Entity/Signer/GuardIdentifier) are intended before calling publish=true. GuardIdentifier sharing mode: {who: {GuardIdentifier: <u8>}, sharing: <rate>, mode: 'Rate'} — resolves recipient from the Guard table submission at allocation time. BINDING SEMANTICS (contract-enforced, abort code 15): in a Service-created Allocation EVERY GuardIdentifier submission must equal the PAYING order — it is always 'the order', never a third party whose address is supplied at trigger time; use {who:{Entity:...}} for named parties. Canonical order pattern: the recipient slot is the single submitted Order (constrained by the Guard — service binding, qualifying node, signer==order.owner); funds land at that order object and are receivable only by its owner (object receipt = owner receipt). Safety is determined by constraint sufficiency — run the recipient constraint audit before publish. Fixed recipients should use {who:{Entity:...}}; unbound Signer recipients are a CRITICAL theft risk. MULTI-CALL ALLOCATION: an allocation can be executed MULTIPLE times (no consumed flag in contract). Use Amount mode (not Surplus) for recurring allocations — Surplus calls balance::withdraw_all which drains the balance. For monthly payment scenarios, create multiple Allocators with time-based Guards + Amount mode sharing items.",
1017
+ "description": "Order fund allocator. Max 100 allocators (MAX_ALLOCATOR_COUNT). ✅ EACH allocator has a guard, and EVERY allocator whose guard address matches the supplied guard RUNS — they are NOT mutually exclusive and NOT first-match-wins. One guard may legitimately authorize several distribution rules (different fix / rate / cap); each contributes its own Payment and consumes its own once-slot (keyed by the allocator index). Allocators are evaluated in vector order against the SHRINKING pool, so a later allocator only sees the balance left by the earlier ones — which is exactly how a waterfall (e.g. Amount fee + net Rate split) is built. On-chain truth: wow::allocation (allocation.move:366-368, `while` loop over all allocators, `if (guard address == alloc.guard)`). ⚠️ If you WANT mutual exclusion you must express it inside the Guard itself (make the conditions logically exclusive). Set to null to clear. ⚠️ PERMANENTLY IMMUTABLE after publish: order_allocators can ONLY be set BEFORE publish=true (on-chain check rejects after publish — E_ALREADY_PUBLISHED). After publish, the ONLY way to change allocation rules is to create a NEW Service object. There is NO pause+lock exception for order_allocators (unlike arbitrations/rewards which have time-lock removal). PRE-PUBLISH CHECKLIST: verify all guard names resolve, all sharing amounts are correct, threshold is set, and recipient types (Entity/Signer/GuardIdentifier) are intended before calling publish=true. GuardIdentifier sharing mode: {who: {GuardIdentifier: <u8>}, sharing: <rate>, mode: 'Rate'} — resolves recipient from the Guard table submission at allocation time. BINDING SEMANTICS (contract-enforced, abort code 15): in a Service-created Allocation EVERY GuardIdentifier submission must equal the PAYING order — it is always 'the order', never a third party whose address is supplied at trigger time; use {who:{Entity:...}} for named parties. Canonical order pattern: the recipient slot is the single submitted Order (constrained by the Guard — service binding, qualifying node, signer==order.owner); funds land at that order object and are receivable only by its owner (object receipt = owner receipt). Safety is determined by constraint sufficiency — run the recipient constraint audit before publish. Fixed recipients should use {who:{Entity:...}}; unbound Signer recipients are a CRITICAL theft risk. MULTI-CALL ALLOCATION: an allocation can be executed MULTIPLE times (no consumed flag in contract). Use Amount mode (not Surplus) for recurring allocations — Surplus calls balance::withdraw_all which drains the balance. For monthly payment scenarios, create multiple Allocators with time-based Guards + Amount mode sharing items.",
1018
1018
  "anyOf": [
1019
1019
  {
1020
1020
  "type": "object",
@@ -3256,7 +3256,7 @@
3256
3256
  "properties": {
3257
3257
  "json_or_markdown_file": {
3258
3258
  "type": "string",
3259
- "description": "Path to a JSON or Markdown file containing node array for COMPLETE REPLACEMENT of all nodes.\n\n**File Format Requirements:**\n- Must contain a JSON ARRAY of node objects: [{\"name\": \"...\", \"pairs\": [...]}, {...}]\n- NOT an operation object with \"op\" field (use NodeSchema for operations)\n- Supports JSON or Markdown (with ```json code blocks)\n\n**Node Structure:**\nEach node is a directed graph element representing workflow states and transitions:\n- name: Node identifier\n- role: (optional) business role tag for display layers — one of draft/active/delivered/final/cancelled. SESSION METADATA ONLY (not stored on-chain; echoed back as a NODE ROLES warning)\n- pairs: Array of {prior_node, forwards, threshold} defining connections\n- forwards: Operations available from this node\n- threshold: Required weight to advance\n\n**Behavior:**\n- COMPLETELY REPLACES all existing nodes (equivalent to \"set\" with bReplace=true)\n- Auto-detects format based on file content\n- If parsing fails, error includes line number and column information"
3259
+ "description": "Path to a JSON or Markdown file containing node array for COMPLETE REPLACEMENT of all nodes.\n\n**File Format Requirements:**\n- Must contain a JSON ARRAY of node objects: [{\"name\": \"...\", \"pairs\": [...]}, {...}]\n- NOT an operation object with \"op\" field (use NodeSchema for operations)\n- Supports JSON or Markdown (with ```json code blocks)\n\n**Node Structure:**\nEach node is a directed graph element representing a workflow STATE that an order\ncan rest in. Its Pairs are the INCOMING edges — this is the one convention the\nchain enforces, and getting it backwards silently builds a wrong graph:\n- name: Node identifier — the DESTINATION of every pair it owns\n- role: (optional) business role tag for display layers — one of draft/active/delivered/final/cancelled. SESSION METADATA ONLY (not stored on-chain; echoed back as a NODE ROLES warning)\n- pairs: Array of {prev_node, forwards, threshold} — edges ENTERING this node. The key is `prev_node`; `prior_node` is not recognized and is silently dropped.\n- forwards: Operations that advance INTO this node FROM its prev_node (NOT operations available from this node)\n- threshold: Weight required to migrate into this node along that pair\n\nDiagram `A --[Go]--> B` therefore lives in node **B**: {name:\"B\", pairs:[{prev_node:\"A\", forwards:[{name:\"Go\", weight:1}]}]}.\n\n**Forward names must determine the destination.** `next_node` is a CALLER argument\n(progress.move:540) and the chain resolves (current, next_node, forward) inside the\ndestination node (machine.move:275), so one forward name shared by two destinations\nfrom the same prev_node is legal and lets the caller pick the outcome — including\nwhether a refund Allocator ever fires. Give each destination its own forward name.\n\n**Behavior:**\n- COMPLETELY REPLACES all existing nodes (equivalent to \"set\" with bReplace=true)\n- Auto-detects format based on file content\n- If parsing fails, error includes line number and column information"
3260
3260
  }
3261
3261
  },
3262
3262
  "required": [
@@ -3271,7 +3271,7 @@
3271
3271
  "type": "boolean"
3272
3272
  },
3273
3273
  "publish": {
3274
- "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. ⚠️ 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).",
3274
+ "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).",
3275
3275
  "type": "boolean"
3276
3276
  },
3277
3277
  "owner_receive": {
@@ -1053,7 +1053,7 @@
1053
1053
  "properties": {
1054
1054
  "json_or_markdown_file": {
1055
1055
  "type": "string",
1056
- "description": "Path to a JSON or Markdown file containing node array for COMPLETE REPLACEMENT of all nodes.\n\n**File Format Requirements:**\n- Must contain a JSON ARRAY of node objects: [{\"name\": \"...\", \"pairs\": [...]}, {...}]\n- NOT an operation object with \"op\" field (use NodeSchema for operations)\n- Supports JSON or Markdown (with ```json code blocks)\n\n**Node Structure:**\nEach node is a directed graph element representing workflow states and transitions:\n- name: Node identifier\n- role: (optional) business role tag for display layers — one of draft/active/delivered/final/cancelled. SESSION METADATA ONLY (not stored on-chain; echoed back as a NODE ROLES warning)\n- pairs: Array of {prior_node, forwards, threshold} defining connections\n- forwards: Operations available from this node\n- threshold: Required weight to advance\n\n**Behavior:**\n- COMPLETELY REPLACES all existing nodes (equivalent to \"set\" with bReplace=true)\n- Auto-detects format based on file content\n- If parsing fails, error includes line number and column information"
1056
+ "description": "Path to a JSON or Markdown file containing node array for COMPLETE REPLACEMENT of all nodes.\n\n**File Format Requirements:**\n- Must contain a JSON ARRAY of node objects: [{\"name\": \"...\", \"pairs\": [...]}, {...}]\n- NOT an operation object with \"op\" field (use NodeSchema for operations)\n- Supports JSON or Markdown (with ```json code blocks)\n\n**Node Structure:**\nEach node is a directed graph element representing a workflow STATE that an order\ncan rest in. Its Pairs are the INCOMING edges — this is the one convention the\nchain enforces, and getting it backwards silently builds a wrong graph:\n- name: Node identifier — the DESTINATION of every pair it owns\n- role: (optional) business role tag for display layers — one of draft/active/delivered/final/cancelled. SESSION METADATA ONLY (not stored on-chain; echoed back as a NODE ROLES warning)\n- pairs: Array of {prev_node, forwards, threshold} — edges ENTERING this node. The key is `prev_node`; `prior_node` is not recognized and is silently dropped.\n- forwards: Operations that advance INTO this node FROM its prev_node (NOT operations available from this node)\n- threshold: Weight required to migrate into this node along that pair\n\nDiagram `A --[Go]--> B` therefore lives in node **B**: {name:\"B\", pairs:[{prev_node:\"A\", forwards:[{name:\"Go\", weight:1}]}]}.\n\n**Forward names must determine the destination.** `next_node` is a CALLER argument\n(progress.move:540) and the chain resolves (current, next_node, forward) inside the\ndestination node (machine.move:275), so one forward name shared by two destinations\nfrom the same prev_node is legal and lets the caller pick the outcome — including\nwhether a refund Allocator ever fires. Give each destination its own forward name.\n\n**Behavior:**\n- COMPLETELY REPLACES all existing nodes (equivalent to \"set\" with bReplace=true)\n- Auto-detects format based on file content\n- If parsing fails, error includes line number and column information"
1057
1057
  }
1058
1058
  },
1059
1059
  "required": [
@@ -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. ⚠️ 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: 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).",
1072
1072
  "type": "boolean"
1073
1073
  },
1074
1074
  "owner_receive": {
@@ -248,7 +248,7 @@
248
248
  "additionalProperties": false
249
249
  },
250
250
  "namedNewOrder": {
251
- "description": "RECOMMENDED: Set a local name for the newly created Order object. Without this, the Order is only referenceable by its on-chain address. Example: {name: 'my_order_v1'} allows subsequent operations to use 'my_order_v1' instead of the address. PLACEMENT: this field MUST be inside data.order_new (it is an OrderNew field) — putting namedNewOrder at the data root fails schema validation with 'Unrecognized key'. MIGRATION TIP: for batch/migration order creation, always auto-generate readable names (e.g. '<source>_<service>_<seq>' like 'upwork_svc_v1_0001') — unnamed orders (head.name = null) are only address-referenceable, which breaks downstream queries, displays and audits (E-8).",
251
+ "description": "RECOMMENDED: Set a local name for the newly created Order object. Without this, the Order is only referenceable by its on-chain address. Example: {name: 'my_order_v1'} allows subsequent operations to use 'my_order_v1' instead of the address. PLACEMENT: this field MUST be inside data.order_new (it is an OrderNew field) — putting namedNewOrder at the data root fails schema validation with 'Unrecognized key'. MIGRATION TIP: for batch/migration order creation, always auto-generate readable names (e.g. '<source>_<service>_<seq>' like 'my_shop_svc_v1_0001') — unnamed orders (head.name = null) are only address-referenceable, which breaks downstream queries, displays and audits (E-8).",
252
252
  "type": "object",
253
253
  "properties": {
254
254
  "name": {
@@ -666,7 +666,7 @@
666
666
  "suspension"
667
667
  ],
668
668
  "additionalProperties": false,
669
- "description": "Suspend or resume ONE product without removing it (keeps price/stock/WIP binding). The Amazon-style 'out of stock / listing inactive' state. Only the named product is touched; an unknown sale_name is silently ignored on-chain (verify with query_toolkit afterwards)."
669
+ "description": "Suspend or resume ONE product without removing it (keeps price/stock/WIP binding). The retail-style 'out of stock / listing inactive' state. Only the named product is touched; an unknown sale_name is silently ignored on-chain (verify with query_toolkit afterwards)."
670
670
  }
671
671
  ]
672
672
  },
@@ -1012,7 +1012,7 @@
1012
1012
  }
1013
1013
  },
1014
1014
  "order_allocators": {
1015
- "description": "Order fund allocator. Max 100 allocators (MAX_ALLOCATOR_COUNT). ✅ EACH allocator has a guard, and EVERY allocator whose guard address matches the supplied guard RUNS — they are NOT mutually exclusive and NOT first-match-wins. One guard may legitimately authorize several distribution rules (different fix / rate / cap); each contributes its own Payment and consumes its own once-slot (keyed by the allocator index). Allocators are evaluated in vector order against the SHRINKING pool, so a later allocator only sees the balance left by the earlier ones — which is exactly how a waterfall (e.g. Amount fee + net Rate split) is built. On-chain truth: wow::allocation (allocation.move:291-296, `while` loop over all allocators, `if (guard address == alloc.guard)`). ⚠️ If you WANT mutual exclusion you must express it inside the Guard itself (make the conditions logically exclusive). Set to null to clear. ⚠️ PERMANENTLY IMMUTABLE after publish: order_allocators can ONLY be set BEFORE publish=true (on-chain check rejects after publish — E_ALREADY_PUBLISHED). After publish, the ONLY way to change allocation rules is to create a NEW Service object. There is NO pause+lock exception for order_allocators (unlike arbitrations/rewards which have time-lock removal). PRE-PUBLISH CHECKLIST: verify all guard names resolve, all sharing amounts are correct, threshold is set, and recipient types (Entity/Signer/GuardIdentifier) are intended before calling publish=true. GuardIdentifier sharing mode: {who: {GuardIdentifier: <u8>}, sharing: <rate>, mode: 'Rate'} — resolves recipient from the Guard table submission at allocation time. BINDING SEMANTICS (contract-enforced, abort code 15): in a Service-created Allocation EVERY GuardIdentifier submission must equal the PAYING order — it is always 'the order', never a third party whose address is supplied at trigger time; use {who:{Entity:...}} for named parties. Canonical order pattern: the recipient slot is the single submitted Order (constrained by the Guard — service binding, qualifying node, signer==order.owner); funds land at that order object and are receivable only by its owner (object receipt = owner receipt). Safety is determined by constraint sufficiency — run the recipient constraint audit before publish. Fixed recipients should use {who:{Entity:...}}; unbound Signer recipients are a CRITICAL theft risk. MULTI-CALL ALLOCATION: an allocation can be executed MULTIPLE times (no consumed flag in contract). Use Amount mode (not Surplus) for recurring allocations — Surplus calls balance::withdraw_all which drains the balance. For monthly payment scenarios, create multiple Allocators with time-based Guards + Amount mode sharing items.",
1015
+ "description": "Order fund allocator. Max 100 allocators (MAX_ALLOCATOR_COUNT). ✅ EACH allocator has a guard, and EVERY allocator whose guard address matches the supplied guard RUNS — they are NOT mutually exclusive and NOT first-match-wins. One guard may legitimately authorize several distribution rules (different fix / rate / cap); each contributes its own Payment and consumes its own once-slot (keyed by the allocator index). Allocators are evaluated in vector order against the SHRINKING pool, so a later allocator only sees the balance left by the earlier ones — which is exactly how a waterfall (e.g. Amount fee + net Rate split) is built. On-chain truth: wow::allocation (allocation.move:366-368, `while` loop over all allocators, `if (guard address == alloc.guard)`). ⚠️ If you WANT mutual exclusion you must express it inside the Guard itself (make the conditions logically exclusive). Set to null to clear. ⚠️ PERMANENTLY IMMUTABLE after publish: order_allocators can ONLY be set BEFORE publish=true (on-chain check rejects after publish — E_ALREADY_PUBLISHED). After publish, the ONLY way to change allocation rules is to create a NEW Service object. There is NO pause+lock exception for order_allocators (unlike arbitrations/rewards which have time-lock removal). PRE-PUBLISH CHECKLIST: verify all guard names resolve, all sharing amounts are correct, threshold is set, and recipient types (Entity/Signer/GuardIdentifier) are intended before calling publish=true. GuardIdentifier sharing mode: {who: {GuardIdentifier: <u8>}, sharing: <rate>, mode: 'Rate'} — resolves recipient from the Guard table submission at allocation time. BINDING SEMANTICS (contract-enforced, abort code 15): in a Service-created Allocation EVERY GuardIdentifier submission must equal the PAYING order — it is always 'the order', never a third party whose address is supplied at trigger time; use {who:{Entity:...}} for named parties. Canonical order pattern: the recipient slot is the single submitted Order (constrained by the Guard — service binding, qualifying node, signer==order.owner); funds land at that order object and are receivable only by its owner (object receipt = owner receipt). Safety is determined by constraint sufficiency — run the recipient constraint audit before publish. Fixed recipients should use {who:{Entity:...}}; unbound Signer recipients are a CRITICAL theft risk. MULTI-CALL ALLOCATION: an allocation can be executed MULTIPLE times (no consumed flag in contract). Use Amount mode (not Surplus) for recurring allocations — Surplus calls balance::withdraw_all which drains the balance. For monthly payment scenarios, create multiple Allocators with time-based Guards + Amount mode sharing items.",
1016
1016
  "anyOf": [
1017
1017
  {
1018
1018
  "type": "object",