@wowok/agent-mcp 3.2.0 → 3.2.1

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 (164) hide show
  1. package/dist/config/exposure.d.ts +8 -8
  2. package/dist/config/judgment.d.ts +20 -20
  3. package/dist/config/rule-engine.d.ts +20 -20
  4. package/dist/extensions/industry-pack.js +1 -1
  5. package/dist/graph/onchain/facts.js +1 -1
  6. package/dist/graph/onchain/sdk-batch.d.ts +1 -0
  7. package/dist/graph/onchain/sdk-batch.js +1 -1
  8. package/dist/graph/onchain/sdk-dataplane.d.ts +1 -0
  9. package/dist/graph/onchain/sdk-dataplane.js +1 -1
  10. package/dist/knowledge/allocation-templates.d.ts +1 -1
  11. package/dist/knowledge/allocation-templates.js +1 -1
  12. package/dist/knowledge/arbitration-ledger.js +1 -1
  13. package/dist/knowledge/audit-rules.d.ts +1 -1
  14. package/dist/knowledge/audit-rules.js +1 -1
  15. package/dist/knowledge/builtin-templates.d.ts +1 -1
  16. package/dist/knowledge/builtin-templates.js +1 -1
  17. package/dist/knowledge/discount-threshold.d.ts +15 -0
  18. package/dist/knowledge/discount-threshold.js +1 -0
  19. package/dist/knowledge/getting-started.js +1 -1
  20. package/dist/knowledge/guard-design-patterns.js +1 -1
  21. package/dist/knowledge/guard-lint.js +1 -1
  22. package/dist/knowledge/guard-translation.js +1 -1
  23. package/dist/knowledge/index.d.ts +2 -2
  24. package/dist/knowledge/index.js +1 -1
  25. package/dist/knowledge/industry-generalizer.d.ts +38 -1
  26. package/dist/knowledge/industry-generalizer.js +1 -1
  27. package/dist/knowledge/industry-registry.js +1 -1
  28. package/dist/knowledge/industry-strategy.js +1 -1
  29. package/dist/knowledge/jsonrpc-enum.js +1 -1
  30. package/dist/knowledge/onchain-constants.d.ts +2 -2
  31. package/dist/knowledge/onchain-constants.js +1 -1
  32. package/dist/knowledge/scenario-modes.d.ts +10 -0
  33. package/dist/knowledge/strategy-manuals.d.ts +1 -1
  34. package/dist/knowledge/strategy-manuals.js +1 -1
  35. package/dist/knowledge/template-loader.d.ts +20 -0
  36. package/dist/knowledge/template-loader.js +1 -1
  37. package/dist/knowledge/template-registry.js +1 -1
  38. package/dist/knowledge/template-scanner.js +1 -1
  39. package/dist/knowledge/tools-reference.js +1 -1
  40. package/dist/monitor/MonitorLoop.js +1 -1
  41. package/dist/participation/arbitrator-interest.js +1 -1
  42. package/dist/participation/customer-interest.js +1 -1
  43. package/dist/participation/merchant-interest.js +1 -1
  44. package/dist/playbooks/service-build/business-puzzle.js +1 -1
  45. package/dist/playbooks/service-build/machine-panorama.js +1 -1
  46. package/dist/playbooks/service-build/merchant-guide.js +1 -1
  47. package/dist/playbooks/service-build/mode-actions.d.ts +12 -1
  48. package/dist/playbooks/service-build/mode-actions.js +1 -1
  49. package/dist/playbooks/service-build/object-panorama.js +1 -1
  50. package/dist/playbooks/service-build/participation-radar.js +1 -1
  51. package/dist/playbooks/service-build/relationship-profile.js +1 -1
  52. package/dist/playbooks/service-build/reverse-mapping-refund-p0-5.spec.d.ts +1 -0
  53. package/dist/playbooks/service-build/reverse-mapping-refund-p0-5.spec.js +1 -0
  54. package/dist/playbooks/service-build/reverse-mapping.js +1 -1
  55. package/dist/playbooks/service-build/semantic-graph.js +1 -1
  56. package/dist/playbooks/service-build/service-panorama.js +1 -1
  57. package/dist/playbooks/service-build/service-quote.js +1 -1
  58. package/dist/review/index.js +1 -1
  59. package/dist/role/profiles.js +1 -1
  60. package/dist/role/types.d.ts +2 -0
  61. package/dist/role/types.js +1 -1
  62. package/dist/safety/confirm-gate.js +1 -1
  63. package/dist/schema/call/allocation.d.ts +7 -7
  64. package/dist/schema/call/arbitration.d.ts +1 -1
  65. package/dist/schema/call/arbitration.js +1 -1
  66. package/dist/schema/call/base.d.ts +5 -5
  67. package/dist/schema/call/base.js +1 -1
  68. package/dist/schema/call/bridge.d.ts +5 -9
  69. package/dist/schema/call/bridge.js +1 -1
  70. package/dist/schema/call/contact.d.ts +1 -1
  71. package/dist/schema/call/demand.d.ts +1 -1
  72. package/dist/schema/call/guard.d.ts +11 -11
  73. package/dist/schema/call/handler.js +1 -1
  74. package/dist/schema/call/machine.d.ts +2 -2
  75. package/dist/schema/call/order.d.ts +1 -1
  76. package/dist/schema/call/payment.d.ts +1 -1
  77. package/dist/schema/call/permission.d.ts +1 -1
  78. package/dist/schema/call/personal.d.ts +1 -1
  79. package/dist/schema/call/progress.d.ts +1 -1
  80. package/dist/schema/call/proof.d.ts +2 -2
  81. package/dist/schema/call/repository.d.ts +1 -1
  82. package/dist/schema/call/reward.d.ts +1 -1
  83. package/dist/schema/call/semantic.js +1 -1
  84. package/dist/schema/call/service.d.ts +5 -5
  85. package/dist/schema/call/service.js +1 -1
  86. package/dist/schema/call/treasury.d.ts +1 -1
  87. package/dist/schema/common/index.js +1 -1
  88. package/dist/schema/evaluation/index.d.ts +6 -2
  89. package/dist/schema/evaluation/index.js +1 -1
  90. package/dist/schema/goal/index.d.ts +8 -8
  91. package/dist/schema/goal/planning.d.ts +15 -15
  92. package/dist/schema/industry-pack/index.d.ts +15 -0
  93. package/dist/schema/industry-pack/modes.d.ts +15 -0
  94. package/dist/schema/industry-pack/modes.js +1 -1
  95. package/dist/schema/intent-radar/index.d.ts +3 -0
  96. package/dist/schema/intent-radar/index.js +1 -1
  97. package/dist/schema/local/index.d.ts +577 -18
  98. package/dist/schema/local/index.js +1 -1
  99. package/dist/schema/messenger/index.d.ts +140 -20
  100. package/dist/schema/messenger/index.js +1 -1
  101. package/dist/schema/operations.d.ts +30 -28
  102. package/dist/schema/operations.js +1 -1
  103. package/dist/schema/persona/index.d.ts +708 -708
  104. package/dist/schema/persona/index.js +1 -1
  105. package/dist/schema/query/bi.d.ts +20 -6
  106. package/dist/schema/query/bi.js +1 -1
  107. package/dist/schema/query/index.d.ts +32 -32
  108. package/dist/schema/query/index.js +1 -1
  109. package/dist/schema/schema-query/index.d.ts +3 -3
  110. package/dist/schema/schema-version.js +1 -1
  111. package/dist/schema/watch/index.d.ts +2 -2
  112. package/dist/schema/workflow/index.d.ts +2 -2
  113. package/dist/schema-query-impl/index.js +1 -1
  114. package/dist/schemas/account_operation.output.json +6 -2
  115. package/dist/schemas/account_operation.schema.json +1 -1
  116. package/dist/schemas/bridge_operation.schema.json +2 -10
  117. package/dist/schemas/evaluation_operation.output.json +2 -0
  118. package/dist/schemas/evaluation_operation.schema.json +2 -0
  119. package/dist/schemas/index.json +7 -1
  120. package/dist/schemas/industry_pack_operation.output.json +87 -4
  121. package/dist/schemas/intent_radar.output.json +2 -0
  122. package/dist/schemas/intent_radar.schema.json +1 -0
  123. package/dist/schemas/local_cache_operation.output.json +1536 -0
  124. package/dist/schemas/local_cache_operation.schema.json +101 -0
  125. package/dist/schemas/local_mark_operation.output.json +51 -36
  126. package/dist/schemas/local_mark_operation.schema.json +1 -0
  127. package/dist/schemas/messenger_operation.schema.json +358 -35
  128. package/dist/schemas/onchain_operations.schema.json +10 -10
  129. package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
  130. package/dist/schemas/onchain_operations_arbitration.schema.json +3 -3
  131. package/dist/schemas/onchain_operations_payment.schema.json +1 -1
  132. package/dist/schemas/onchain_operations_reward.schema.json +1 -1
  133. package/dist/schemas/onchain_operations_service.schema.json +3 -3
  134. package/dist/schemas/onchain_operations_treasury.schema.json +1 -1
  135. package/dist/schemas/onchain_table_data.output.json +11 -0
  136. package/dist/schemas/query_toolkit.output.json +11 -4
  137. package/dist/schemas/query_toolkit.schema.json +13 -2
  138. package/dist/tools/handlers/benchmark-migration.js +1 -1
  139. package/dist/tools/handlers/bridge.js +1 -1
  140. package/dist/tools/handlers/config.js +1 -1
  141. package/dist/tools/handlers/local.d.ts +1 -0
  142. package/dist/tools/handlers/local.js +1 -1
  143. package/dist/tools/handlers/messenger.d.ts +9 -2
  144. package/dist/tools/handlers/messenger.js +1 -1
  145. package/dist/tools/handlers/name-resolution.d.ts +4 -0
  146. package/dist/tools/handlers/name-resolution.js +1 -0
  147. package/dist/tools/handlers/name-resolution.spec.d.ts +1 -0
  148. package/dist/tools/handlers/name-resolution.spec.js +1 -0
  149. package/dist/tools/handlers/onchain-name-registration.d.ts +37 -0
  150. package/dist/tools/handlers/onchain-name-registration.js +1 -0
  151. package/dist/tools/handlers/onchain-name-registration.spec.d.ts +1 -0
  152. package/dist/tools/handlers/onchain-name-registration.spec.js +1 -0
  153. package/dist/tools/handlers/onchain.d.ts +1 -0
  154. package/dist/tools/handlers/onchain.js +1 -1
  155. package/dist/tools/handlers/query.d.ts +1 -0
  156. package/dist/tools/handlers/query.js +1 -1
  157. package/dist/tools/index.js +1 -1
  158. package/dist/tools/registry/local.js +1 -1
  159. package/dist/tools/sanitize-description-roundtrip.spec.d.ts +1 -0
  160. package/dist/tools/sanitize-description-roundtrip.spec.js +1 -0
  161. package/dist/tools/sanitize-output.d.ts +1 -0
  162. package/dist/tools/sanitize-output.js +1 -1
  163. package/dist/tools/wrap.js +1 -1
  164. package/package.json +2 -2
@@ -1 +1 @@
1
- import{MOVE_FUNCTIONS,MOVE_MODULE_NAMES}from'./move-fn-index.gen.js';const PROTOCOL_MOVE_MODULES=['object_linker','entity_order','entity_permission','entity_contact','arbitration','allocation','repository','permission','progress','registrar','passport','treasury','contact','service','machine','payment','reward','demand','guard','order','proof','resource','bridge','common','arb'],INTERNAL_TS_FILES=['onchain-constants','guard-ins','error-codes'],LINE_ANCHOR=String['raw']`(?:\s*[#:]\s*|\s+)L?\d{1,4}(?:\s*[\-,–/]\s*L?\d{1,4})*`,FILE_TOKEN_SOURCE=String['raw']`(?<![A-Za-z0-9_-])(?:${PROTOCOL_MOVE_MODULES['join']('|')})\.move(?:${LINE_ANCHOR})?`+String['raw']`|(?<![A-Za-z0-9_-])[A-Za-z_][A-Za-z0-9_-]*\.(?:move|ts|rs)(?:${LINE_ANCHOR})`+String['raw']`|(?<![A-Za-z0-9_-])(?:${INTERNAL_TS_FILES['join']('|')})\.ts\b`;function fileTokenRegex(){return new RegExp(FILE_TOKEN_SOURCE,'g');}const ORPHAN_LINE_ANCHOR=/\bL\d{1,4}(?:\s*[\-,–/]\s*L?\d{1,4})*/g,DANGLING_LINE_ANCHOR=/[#,\s]L\d{2,4}(?:\s*[\-,–/]\s*L?\d{2,4})+/g;function hasFileToken(a){return fileTokenRegex()['test'](a);}function escapeRegExp(a){return a['replace'](/[.*+?^${}()|[\]\\]/g,'\x5c$&');}let moveFnRefRegex=null;function moveFnRefTokenRegex(){if(!moveFnRefRegex){const a=[...MOVE_MODULE_NAMES]['sort']((c,d)=>d['length']-c['length'])['map'](escapeRegExp),b=[...new Set(Object['values'](MOVE_FUNCTIONS)['flat']())]['sort']((c,d)=>d['length']-c['length'])['map'](escapeRegExp);moveFnRefRegex=new RegExp('\x5cb(?:'+a['join']('|')+')::(?:'+b['join']('|')+')\x5cb','g');}return moveFnRefRegex;}export function redactInternalSources(a){if(!hasFileToken(a)&&!a['includes']('::'))return a;let b=a;for(let c=0x0;c<0x3;c++){const d=b;b=b['replace'](/\(([^()]*)\)/g,(e,f)=>{if(!hasFileToken(f)&&!f['includes']('::'))return e;let g=f['replace'](fileTokenRegex(),'')['replace'](moveFnRefTokenRegex(),'')['replace'](ORPHAN_LINE_ANCHOR,'');return g=g['replace'](/\s+/g,'\x20')['trim']()['replace'](/^[\s,;:/·.\-–—]+|[\s,;:/·.\-–—]+$/g,'')['trim'](),g?'('+g+')':'';});if(b===d)break;}b=b['replace'](fileTokenRegex(),''),b=b['replace'](moveFnRefTokenRegex(),'');if(!hasFileToken(a)&&b===a)return a;return b=b['replace'](DANGLING_LINE_ANCHOR,''),b=b['replace'](/\s+[,;:]\s+/g,'\x20'),b=b['replace'](/\(\s+/g,'(')['replace'](/\s+\)/g,')')['replace'](/\(\s*[\s,;:/·.\-–—]*\)/g,'')['replace'](/([(\[])\s+/g,'$1')['replace'](/\s{2,}/g,'\x20')['replace'](/\s+([,.;:])/g,'$1'),b=b['replace'](/[\s,;:+\u00b7\-–—]+(\.\s*)$/,'$1')['replace'](/[\s,;:+\u00b7\-–—]+\s*$/,''),b!==a&&(b=b['replace'](/^ /,'')['replace'](/ $/,'')),b;}function sanitizeDeep(a,b){if(typeof a==='string')return redactInternalSources(a);if(Array['isArray'](a))return a['map'](c=>sanitizeDeep(c,b));if(a&&typeof a==='object'){if(b['has'](a))return a;b['add'](a);const c={};for(const [d,e]of Object['entries'](a)){c[d]=sanitizeDeep(e,b);}return c;}return a;}export function sanitizeToolDispatchResult(a){try{const b=a['content']?.['map'](d=>d['type']==='text'?{...d,'text':redactInternalSources(d['text'])}:d),c=a['structuredContent']?sanitizeDeep(a['structuredContent'],new WeakSet()):a['structuredContent'];return{...a,'content':b,'structuredContent':c};}catch{return a;}}
1
+ import{MOVE_FUNCTIONS,MOVE_MODULE_NAMES}from'./move-fn-index.gen.js';const PROTOCOL_MOVE_MODULES=['object_linker','entity_order','entity_permission','entity_contact','arbitration','allocation','repository','permission','progress','registrar','passport','treasury','contact','service','machine','payment','reward','demand','guard','order','proof','resource','bridge','common','arb'],INTERNAL_TS_FILES=['onchain-constants','guard-ins','error-codes'],LINE_ANCHOR=String['raw']`(?:\s*[#:]\s*|\s+)L?\d{1,4}(?:\s*[\-,–/]\s*L?\d{1,4})*`,FILE_TOKEN_SOURCE=String['raw']`(?<![A-Za-z0-9_-])(?:${PROTOCOL_MOVE_MODULES['join']('|')})\.move(?:${LINE_ANCHOR})?`+String['raw']`|(?<![A-Za-z0-9_-])[A-Za-z_][A-Za-z0-9_-]*\.(?:move|ts|rs)(?:${LINE_ANCHOR})`+String['raw']`|(?<![A-Za-z0-9_-])(?:${INTERNAL_TS_FILES['join']('|')})\.ts\b`;function fileTokenRegex(){return new RegExp(FILE_TOKEN_SOURCE,'g');}const ORPHAN_LINE_ANCHOR=/\bL\d{1,4}(?:\s*[\-,–/]\s*L?\d{1,4})*/g,DANGLING_LINE_ANCHOR=/[#,\s]L\d{2,4}(?:\s*[\-,–/]\s*L?\d{2,4})+/g;function hasFileToken(a){return fileTokenRegex()['test'](a);}function escapeRegExp(a){return a['replace'](/[.*+?^${}()|[\]\\]/g,'\x5c$&');}let moveFnRefRegex=null;function moveFnRefTokenRegex(){if(!moveFnRefRegex){const a=[...MOVE_MODULE_NAMES]['sort']((c,d)=>d['length']-c['length'])['map'](escapeRegExp),b=[...new Set(Object['values'](MOVE_FUNCTIONS)['flat']())]['sort']((c,d)=>d['length']-c['length'])['map'](escapeRegExp);moveFnRefRegex=new RegExp('\x5cb(?:'+a['join']('|')+')::(?:'+b['join']('|')+')\x5cb','g');}return moveFnRefRegex;}const VERBATIM_TEXT_FIELDS=new Set(['description']);export function isVerbatimTextField(a){return VERBATIM_TEXT_FIELDS['has'](a);}export function redactInternalSources(a){if(!hasFileToken(a)&&!a['includes']('::'))return a;let b=a;for(let c=0x0;c<0x3;c++){const d=b;b=b['replace'](/\(([^()]*)\)/g,(e,f)=>{if(!hasFileToken(f)&&!f['includes']('::'))return e;let g=f['replace'](fileTokenRegex(),'')['replace'](moveFnRefTokenRegex(),'')['replace'](ORPHAN_LINE_ANCHOR,'');return g=g['replace'](/\s+/g,'\x20')['trim']()['replace'](/^[\s,;:/·.\-–—]+|[\s,;:/·.\-–—]+$/g,'')['trim'](),g?'('+g+')':'';});if(b===d)break;}b=b['replace'](fileTokenRegex(),''),b=b['replace'](moveFnRefTokenRegex(),'');if(!hasFileToken(a)&&b===a)return a;return b=b['replace'](DANGLING_LINE_ANCHOR,''),b=b['replace'](/\s+[,;:]\s+/g,'\x20'),b=b['replace'](/\(\s+/g,'(')['replace'](/\s+\)/g,')')['replace'](/\(\s*[\s,;:/·.\-–—]*\)/g,'')['replace'](/([(\[])\s+/g,'$1')['replace'](/\s{2,}/g,'\x20')['replace'](/\s+([,.;:])/g,'$1'),b=b['replace'](/[\s,;:+\u00b7\-–—]+(\.\s*)$/,'$1')['replace'](/[\s,;:+\u00b7\-–—]+\s*$/,''),b!==a&&(b=b['replace'](/^ /,'')['replace'](/ $/,'')),b;}function sanitizeDeep(a,b){if(typeof a==='string')return redactInternalSources(a);if(Array['isArray'](a))return a['map'](c=>sanitizeDeep(c,b));if(a&&typeof a==='object'){if(b['has'](a))return a;b['add'](a);const c={};for(const [d,e]of Object['entries'](a)){c[d]=isVerbatimTextField(d)?e:sanitizeDeep(e,b);}return c;}return a;}function collectVerbatimStrings(a,b,c){if(Array['isArray'](a)){for(const e of a)collectVerbatimStrings(e,b,c);return;}if(!a||typeof a!=='object')return;if(c['has'](a))return;c['add'](a);const d=a;for(const [f,g]of Object['entries'](d)){if(isVerbatimTextField(f)){if(typeof g==='string'&&g['length']>0x0)b['push'](g);continue;}collectVerbatimStrings(g,b,c);}}const MASK_PREFIX='\x00wv',MASK_SUFFIX='\x00';function redactTextBlockPreservingVerbatim(a,b){if(b['length']===0x0)return redactInternalSources(a);const c=[];for(const g of b){c['push'](g);const h=JSON['stringify'](g)['slice'](0x1,-0x1);if(h!==g)c['push'](h);}c['sort']((j,k)=>k['length']-j['length']);const d=[];let e=a;for(let j=0x0;j<c['length'];j++){if(c[j]['length']===0x0||!e['includes'](c[j]))continue;const k=''+MASK_PREFIX+j+MASK_SUFFIX;e=e['split'](c[j])['join'](k),d['push']({'marker':k,'original':c[j]});}if(d['length']===0x0)return redactInternalSources(a);let f=redactInternalSources(e);for(const {marker:l,original:m}of d){f=f['split'](l)['join'](m);}return f;}export function sanitizeToolDispatchResult(a){try{const b=a['structuredContent']?sanitizeDeep(a['structuredContent'],new WeakSet()):a['structuredContent'],c=[];a['structuredContent']&&collectVerbatimStrings(a['structuredContent'],c,new WeakSet());const d=a['content']?.['map'](e=>e['type']==='text'?{...e,'text':redactTextBlockPreservingVerbatim(e['text'],c)}:e);return{...a,'content':d,'structuredContent':b};}catch{return a;}}
@@ -1 +1 @@
1
- import{classifyError,buildDataSemantic}from'../schema/call/semantic.js';import{buildClassifiedErrorResult}from'./shared.js';import{shouldRunLightHooks,shouldRunHeavyHooks,recordOperationFailure,recordCriticalRisk,recordCriticalOperation,recordSubstepFailure}from'../harness/auto-escalation.js';import{getHarnessTier,setHarnessTier,isEnabled}from'../config/runtime.js';import{getHarness}from'../harness/index.js';import{recover}from'../harness/recover.js';import{recordOperationOutcome}from'../experience/index.js';import{recordIndustrySignal}from'../knowledge/flywheel-loop.js';import{getStageCache}from'../playbooks/service-build/index.js';import{SERVICE_BUILD_STAGES}from'../playbooks/service-build/process.js';import{extractAmount,getAmountThreshold,getFundCoverageMin,formatAmount}from'../knowledge/safety-rules.js';import{auditMachineNodes}from'../knowledge/audit-rules.js';import{fetchMachineNodes}from'../graph/onchain/sdk-batch.js';function stageIndexOf(a){const b=SERVICE_BUILD_STAGES['indexOf'](a);return b>=0x0?b:0x0;}export function withTimeout(a,b=0x7530,c='operation'){let d;return Promise['race']([a['finally'](()=>{if(d)clearTimeout(d);}),new Promise((e,f)=>{d=setTimeout(()=>{let g='';if(c['includes']('messenger'))g='\x20This\x20is\x20a\x20messenger\x20network\x20operation.\x20Possible\x20causes:\x20'+'(1)\x20messenger\x20server\x20(https://messenger.wowok.net)\x20unreachable,\x20'+'(2)\x20no\x20messenger-enabled\x20account\x20configured\x20(use\x20account_operation\x20to\x20set\x20messenger\x20name),\x20'+'(3)\x20network\x20connectivity\x20issue.\x20'+'Ensure\x20you\x20have\x20a\x20messenger-enabled\x20account\x20and\x20the\x20server\x20is\x20reachable.';else(c['includes']('onchain')||c['includes']('account_operation')||c['includes']('bridge')||c['includes']('workflow')||c['includes']('keeper')||c['includes']('wowok'))&&(g='\x20This\x20tool\x20may\x20submit\x20an\x20ON-CHAIN\x20transaction.\x20The\x20transaction\x20was\x20NOT\x20cancelled\x20'+'by\x20this\x20timeout\x20—\x20it\x20may\x20already\x20be\x20submitted\x20and\x20still\x20finalize\x20on-chain.\x20'+'DO\x20NOT\x20blindly\x20retry\x20(risk\x20of\x20duplicate\x20operations).\x20First\x20verify:\x20'+'(1)\x20if\x20the\x20error\x20above\x20carries\x20a\x20tx\x20digest,\x20check\x20it\x20via\x20query_toolkit\x20'+'(query_type=\x27onchain_transaction\x27);\x20(2)\x20otherwise\x20verify\x20via\x20query_toolkit\x20'+'onchain_events\x20(or\x20the\x20account\x27s\x20recent\x20transactions).\x20Do\x20NOT\x20rely\x20on\x20an\x20'+'onchain_objects\x20read\x20alone:\x20it\x20may\x20serve\x20a\x20pre-transaction\x20cached\x20snapshot,\x20'+'so\x20an\x20unchanged\x20object\x20must\x20never\x20on\x20its\x20own\x20justify\x20a\x20retry.');f(new Error('Operation\x20\x27'+c+'\x27\x20timed\x20out\x20after\x20'+b+'ms.'+g));},b);})]);}export function wrapHandlerWithErrorShape(a,b,c,d){return async(e,f)=>{try{return await withTimeout(a(e,f),b,c);}catch(g){if(d){const h=g instanceof Error?g['message']:String(g),i=classifyError(h),j={'operation_type':c,'data':e},k=d(h,i,j);return{'content':[{'type':'text','text':'Error:\x20'+h}],'structuredContent':k};}throw g;}};}export const statusErrorShape=(a,b,c)=>({'result':buildClassifiedErrorResult({'status':'error'},a,b),'semantic':buildDataSemantic(undefined,c,!![],a)});export const operationErrorShape=(a,b,c)=>({'result':buildClassifiedErrorResult({'operation':'error'},a,b),'semantic':buildDataSemantic(undefined,c,!![],a)});export const strictStatusErrorShape=(a,b,c)=>({'result':{'status':'error','error':a}});function checkProjectStage(a,b,c){const d={'analyze_intent':'puzzle','aggregate_risks':'risk','trace_substeps':'substeps'},e=d[a];if(!e)return null;const f=getStageCache(b,c);if(!f){if(a==='analyze_intent')return null;return'project_stage:\x20calling\x20\x27'+a+'\x27\x20before\x20\x27analyze_intent\x27\x20—\x20recommend\x20calling\x20analyze_intent\x20first\x20for\x20project\x20\x27'+b+':'+c+'\x27';}if(stageIndexOf(f['stage'])<stageIndexOf(e)-0x1)return'project_stage:\x20calling\x20\x27'+a+'\x27\x20(stage\x20\x27'+e+'\x27)\x20but\x20project\x20is\x20at\x20stage\x20\x27'+f['stage']+'\x27\x20—\x20recommend\x20completing\x20prior\x20stages\x20first\x20for\x20\x27'+b+':'+c+'\x27';return null;}export function dispatchWithHarness(a,b){return async(d,f)=>{const g=[],h=getHarness(),i=shouldRunLightHooks(),j=shouldRunHeavyHooks(),k=isPublishOperation(b,d),l=isSignOperation(b,d),m=getHarnessTier();if(b==='goal_operation'&&i)try{const o=d,p=o?.['action'],q=o?.['project'],r=o?.['version'];if(p&&q&&r){const s=checkProjectStage(p,q,r);s&&g['push'](s);}}catch{}k&&m==='lightweight'&&(setHarnessTier('full'),g['push']('pre_publish:\x20tier\x20forced\x20to\x20full\x20for\x20publish-class\x20operation\x20(GLM5-21\x20§3.3)'));if(k&&m!=='off')try{const t=await runPrePublishChecks(b,d);g['push'](...t['warnings']);if(t['critical']['length']>0x0){for(const u of t['critical']){const v=recordCriticalRisk(u);if(v)g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+v['reason']);}return buildHarnessBlockResult('pre_publish','Publish\x20BLOCKED\x20by\x20Harness\x20pre-publish\x20gate\x20(GLM5-21\x20V6):\x20'+(t['critical']['length']+'\x20CRITICAL\x20risk(s)\x20must\x20be\x20resolved\x20before\x20publish.'),t['critical'],t['warnings'],'immutable_violation','Fix\x20the\x20CRITICAL\x20risks\x20listed\x20in\x20the\x20message\x20(e.g.\x20rename\x20dispute/refund\x20nodes\x20per\x20R-M1-11,\x20add\x20the\x20entry\x20pair\x20prev_node=\x22\x22),\x20then\x20retry\x20publish.\x20Nodes/pairs/forwards\x20are\x20immutable\x20after\x20publish\x20—\x20verify\x20via\x20machineNode2file\x20first.');}}catch(x){g['push']('pre_publish\x20hook\x20failed:\x20'+(x instanceof Error?x['message']:String(x)));}if(l&&j)try{const y=extractData(d),z=y?extractAmount(y,{'excludeConfigAmounts':!![]}):null;if(z!==null){const A=getAmountThreshold();let B=null;try{B=BigInt(z);}catch{B=null;}if(B!==null&&B>A)return buildHarnessBlockResult('pre_sign','Sign\x20BLOCKED\x20by\x20Harness\x20pre-sign\x20gate\x20(GLM5-21\x20V7):\x20amount\x20'+formatAmount(B)+'\x20WOW\x20exceeds\x20the\x20full-tier\x20threshold\x20'+formatAmount(A)+'\x20WOW.',['amount\x20'+z+'\x20(smallest\x20unit)\x20>\x20threshold\x20'+A['toString']()+'\x20(smallest\x20unit)'],[],'invalid_parameter','Raise\x20WOWOK_AMOUNT_THRESHOLD\x20to\x20match\x20the\x20intended\x20amount,\x20split\x20the\x20transaction,\x20or\x20reset\x20the\x20harness\x20tier\x20to\x20lightweight\x20(config_operation)\x20after\x20explicit\x20user\x20confirmation.');}}catch(C){g['push']('pre_sign\x20hook\x20failed:\x20'+(C instanceof Error?C['message']:String(C)));}let n;try{n=await a(d,f);}catch(D){const E=D instanceof Error?D['message']:String(D),F=recordOperationFailure(b,E);F&&g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+F['reason']);if(b==='onchain_operations')try{const G=classifyError(E,D);if(!G['retryable']&&G['error_code']!=='unknown'){const H=recordCriticalOperation(b,G['error_code']);if(H)g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+H['reason']);}}catch{}throw D;}if(b==='onchain_operations')try{if(classifyOutcome(n)==='failed'){const I=extractErrorCode(n)??'',J=classifyError(I);if(!J['retryable']&&J['error_code']!=='unknown'){const K=recordCriticalOperation(b,J['error_code']);if(K)g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+K['reason']);}}}catch{}if(i&&!isOutcomeDiscriminated(n)){const L=extractIntent(b,d)??b;try{const M=classifyOutcome(n);if(M==='failed'){const N=extractErrorCode(n)??'',O=classifyError(N),P=h['recover'](O['error_code'],L,{'operation_type':b,'data':extractData(d)});g['push']('Harness\x20recover:\x20strategy='+P['strategy']+('\x20(attempt\x20'+P['current_attempt']+'/'+P['max_attempts']+')')+(P['should_retry']?'\x20—\x20retryable':'\x20—\x20do\x20NOT\x20retry\x20blindly')+(P['user_prompt']?'\x20—\x20'+P['user_prompt']:'\x20—\x20'+P['detail']));}else M==='success'&&h['resetRecovery'](L);}catch(Q){g['push']('recover\x20hook\x20failed:\x20'+(Q instanceof Error?Q['message']:String(Q)));}}if(b==='goal_operation')try{const R=d?.['action'];if(R==='trace_substeps'){const S=extractCriticalFindingCount(n);if(S>0x0){const T=recordSubstepFailure(String(R)+':\x20'+S+'\x20critical\x20finding(s)');if(T)g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+T['reason']);}}}catch{}if(isWriteClassTool(b)&&!SEMANTIC_RECORDED_TOOLS['has'](b))try{const U=extractOperationType(b,d)??b,V=extractIntent(b,d)??b,W=extractData(d)??d,X=classifyOutcome(n),Y=extractErrorCode(n),Z=isEnabled('experience_layer');if(Z)recordOperationOutcome(U,W,V,X,Y);else{const a0=extractIndustry(d);a0&&isEnabled('industry_evolution')&&recordIndustrySignal(a0,{'type':U},{'success':X==='success','error_code':Y});}}catch(a1){g['push']('signal\x20collection\x20failed:\x20'+(a1 instanceof Error?a1['message']:String(a1)));}if(g['length']>0x0){if(n?.['structuredContent']){const a2=n['structuredContent'],a3=a2['semantic'];if(a3){const a4=Array['isArray'](a3['warnings'])?a3['warnings']:[];a3['warnings']=[...a4,...g];}else for(const a5 of g){console['warn']('[harness]\x20'+a5);}}else for(const a6 of g){console['warn']('[harness]\x20'+a6);}}return n;};}function isPublishOperation(a,b){if(a!=='onchain_operations')return![];const c=extractOperationType(a,b);if(c!=='service'&&c!=='machine')return![];const d=extractData(b);return d?.['publish']===!![]||d?.['bPublished']===!![];}function isSignOperation(a,b){if(a==='wip_file'){const c=b?.['operation_type'];return c==='sign';}return a==='onchain_operations';}function extractOperationType(a,b){if(!b||typeof b!=='object')return undefined;const c=b;if(a==='onchain_operations')return typeof c['operation_type']==='string'?c['operation_type']:undefined;if(a==='goal_operation'||a==='industry_pack_operation'||a==='strategy_review_operation')return typeof c['action']==='string'?c['action']:undefined;return typeof c['operation_type']==='string'?c['operation_type']:undefined;}function extractIntent(a,b){if(!b||typeof b!=='object')return undefined;const c=b;if((a==='goal_operation'||a==='industry_pack_operation'||a==='strategy_review_operation')&&typeof c['action']==='string')return a+':'+c['action'];const d=c['operation_type'];if(typeof d==='string')return a+':'+d;return a;}function extractData(a){if(!a||typeof a!=='object')return undefined;const b=a,c=b['data'];return c&&typeof c==='object'?c:undefined;}const WRITE_CLASS_TOOLS=new Set(['onchain_operations','goal_operation','industry_pack_operation','strategy_review_operation','wip_file','messenger_operation','bridge_operation']),SEMANTIC_RECORDED_TOOLS=new Set(['onchain_operations','bridge_operation']);function isWriteClassTool(a){return WRITE_CLASS_TOOLS['has'](a);}function classifyOutcome(a){if(!a?.['structuredContent'])return'failed';const b=a['structuredContent'];if(b['outcome']==='failed')return'failed';if(b['outcome']==='executed')return'success';if(b['outcome']==='pending_input')return'partial';const c=typeof b['status']==='string'?b['status']:typeof b['result_type']==='string'?b['result_type']:'';if(c==='error'||c==='failed')return'failed';if(c==='partial')return'partial';return'success';}function isOutcomeDiscriminated(a){const b=a?.['structuredContent'];return!!b&&typeof b==='object'&&'outcome'in b;}function extractErrorCode(a){if(!a?.['structuredContent'])return undefined;const b=a['structuredContent'];if(typeof b['error_code']==='string')return b['error_code'];const c=b['error'];if(typeof c==='string')return c;if(c&&typeof c==='object'){const d=c['code'];if(typeof d==='string')return d;}return undefined;}function extractIndustry(a){if(!a||typeof a!=='object')return undefined;const b=a;if(typeof b['industry']==='string')return b['industry'];const c=b['data'];if(c&&typeof c==='object'){const e=c;if(typeof e['industry']==='string')return e['industry'];}return undefined;}function numericBalance(a){if(typeof a==='number'&&Number['isFinite'](a))return a;if(typeof a==='string'&&a['trim']()!==''&&Number['isFinite'](Number(a)))return Number(a);return undefined;}async function runPrePublishChecks(a,b){const c=[],d=[],f=extractOperationType(a,b),g=extractData(b)??{};if(f==='machine'){const h=g['node'];let i=Array['isArray'](h)?h:Array['isArray'](h?.['nodes'])?h['nodes']:[];if(i['length']===0x0&&typeof g['object']==='string'){const j=g['object'],k=b?.['env']?.['network'];try{const l=await fetchMachineNodes(j,k,!![]);l['length']>0x0&&(i=l,d['push']('pre_publish:\x20machine\x20\x22'+j+'\x22\x20published\x20by\x20reference\x20—\x20audited\x20against\x20its\x20'+(l['length']+'\x20on-chain\x20node(s)\x20(effective-state\x20gate)')));}catch(m){d['push']('pre_publish:\x20could\x20not\x20fetch\x20on-chain\x20nodes\x20for\x20machine\x20\x22'+j+'\x22\x20'+('('+(m instanceof Error?m['message']:String(m))+')\x20—\x20topology\x20not\x20verifiable\x20in\x20this\x20call;\x20')+'verify\x20via\x20machineNode2file\x20BEFORE\x20publish\x20(immutable\x20after\x20publish,\x20IMMUT-001)');}}if(i['length']>0x0){const n=auditMachineNodes(i);c['push'](...n['critical']),d['push'](...n['warnings']);}else typeof g['object']!=='string'&&d['push']('pre_publish:\x20publishing\x20machine\x20without\x20inline\x20node\x20data\x20—\x20topology\x20not\x20verifiable\x20in\x20this\x20call;\x20'+'verify\x20nodes/pairs/forwards\x20via\x20machineNode2file\x20BEFORE\x20publish\x20(immutable\x20after\x20publish,\x20IMMUT-001)');d['push']('pre_publish:\x20machine\x20nodes/pairs/forwards\x20become\x20immutable\x20after\x20publish\x20(IMMUT-001)');}if(f==='service'){d['push']('pre_publish:\x20service\x20machine/order_allocators/arbitrations\x20become\x20immutable\x20after\x20publish\x20(IMMUT-002);\x20sales\x20remains\x20modifiable');g['machine']===undefined&&d['push']('pre_publish:\x20\x27machine\x27\x20not\x20set\x20in\x20this\x20call\x20—\x20if\x20the\x20service\x20was\x20never\x20bound\x20to\x20a\x20published\x20machine,\x20'+'it\x20cannot\x20process\x20orders\x20and\x20CANNOT\x20be\x20fixed\x20after\x20publish');g['order_allocators']===undefined&&d['push']('pre_publish:\x20\x27order_allocators\x27\x20not\x20set\x20in\x20this\x20call\x20—\x20immutable\x20after\x20publish;\x20'+'orders\x20will\x20have\x20no\x20fund\x20distribution\x20if\x20never\x20configured');const o=g,p=numericBalance(o['compensation_fund_add']?.['balance']);if(p!==undefined&&p>0x0){const q=o['sales'],r=(Array['isArray'](q?.['sales'])?q['sales']:[])['map'](s=>numericBalance(s?.['price']?.['balance']))['filter'](s=>s!==undefined);if(r['length']>0x0){const s=r['reduce']((u,v)=>u+v,0x0),t=s*0x3;if(t>0x0){const u=p/t,v=getFundCoverageMin(),w='fund='+p+',\x20max\x20single\x20order=Σ(price×1)='+s+'\x20(quantity\x20set\x20at\x20buy\x20time),\x20'+('award\x20cap=3×order='+t+'\x20(MAX_INDEMNITY_MULTIPLE),\x20coverage='+u['toFixed'](0x2));if(v>0x0&&u<v)d['push']('pre_publish:\x20G7\x20advisory\x20—\x20compensation-fund\x20coverage\x20below\x20the\x20configured\x20minimum\x20—\x20'+w+'\x20<\x20'+v+'.\x20'+'Awards\x20beyond\x20the\x20fund\x20draw\x20from\x20the\x20merchant\x20wallet.\x20'+'Consider\x20adding\x20funds\x20(compensation_fund_add),\x20or\x20set\x20WOWOK_FUND_COVERAGE_MIN\x20'+'(0\x20silences\x20this\x20advisory).\x20Informational\x20—\x20does\x20not\x20block\x20publish');else u<0x1&&d['push']('pre_publish:\x20compensation-fund\x20coverage\x20below\x20the\x20award\x20ceiling\x20—\x20'+w+'\x20<\x201\x20—\x20'+'awards\x20beyond\x20the\x20fund\x20draw\x20from\x20the\x20merchant\x20wallet.\x20Informational');}}else d['push']('pre_publish:\x20compensation_fund_add\x20present\x20but\x20sales\x20not\x20set\x20in\x20this\x20call\x20—\x20verify\x20coverage\x20manually:\x20'+'the\x20fund\x20must\x20cover\x203×\x20the\x20maximum\x20single-order\x20amount\x20(MAX_INDEMNITY_MULTIPLE=3)');}}return{'critical':c,'warnings':d};}function buildHarnessBlockResult(a,b,c,d,e,f){const g=[...c['map'](i=>'CRITICAL:\x20'+i),...d['map'](i=>'WARN:\x20'+i)]['join']('\x0a'),h='Error:\x20'+b+(g?'\x0a'+g:'')+'\x0aRecovery:\x20'+f;return{'content':[{'type':'text','text':h}],'structuredContent':{'outcome':'failed','result':{'type':'error','error':b+'\x20[gate='+a+']','error_code':e,'retryable':![],'recovery_hint':f},'message':h,'recovery':recover(e,'harness:'+a)}};}function extractCriticalFindingCount(a){const b=a?.['structuredContent'];if(!b)return 0x0;const c=b['semantic'],d=c?.['summary'];if(typeof d?.['critical_count']==='number'&&d['critical_count']>0x0)return d['critical_count'];const e=b['findings']??c?.['findings'];if(Array['isArray'](e))return e['filter'](h=>h?.['severity']==='error')['length'];const f=a?.['content']?.['map'](h=>'text'in h?h['text']:'')['join']('\x0a')??'',g=f['match'](/\[AUDIT ERROR\]/g);return g?g['length']:0x0;}
1
+ import{classifyError,buildDataSemantic}from'../schema/call/semantic.js';import{buildClassifiedErrorResult}from'./shared.js';import{shouldRunLightHooks,shouldRunHeavyHooks,recordOperationFailure,recordCriticalRisk,recordCriticalOperation,recordSubstepFailure}from'../harness/auto-escalation.js';import{getHarnessTier,setHarnessTier,isEnabled}from'../config/runtime.js';import{getHarness}from'../harness/index.js';import{recover}from'../harness/recover.js';import{recordOperationOutcome}from'../experience/index.js';import{recordIndustrySignal}from'../knowledge/flywheel-loop.js';import{getStageCache}from'../playbooks/service-build/index.js';import{SERVICE_BUILD_STAGES}from'../playbooks/service-build/process.js';import{extractAmount,getAmountThreshold,getFundCoverageMin,formatAmount}from'../knowledge/safety-rules.js';import{auditMachineNodes}from'../knowledge/audit-rules.js';import{fetchMachineNodes}from'../graph/onchain/sdk-batch.js';function stageIndexOf(a){const b=SERVICE_BUILD_STAGES['indexOf'](a);return b>=0x0?b:0x0;}export function withTimeout(a,b=0x7530,c='operation'){let d;return Promise['race']([a['finally'](()=>{if(d)clearTimeout(d);}),new Promise((e,f)=>{d=setTimeout(()=>{let g='';if(c['includes']('messenger'))g='\x20This\x20is\x20a\x20messenger\x20network\x20operation.\x20Possible\x20causes:\x20'+'(1)\x20messenger\x20server\x20(https://messenger.wowok.net)\x20unreachable,\x20'+'(2)\x20no\x20messenger-enabled\x20account\x20configured\x20(use\x20account_operation\x20to\x20set\x20messenger\x20name),\x20'+'(3)\x20network\x20connectivity\x20issue.\x20'+'Ensure\x20you\x20have\x20a\x20messenger-enabled\x20account\x20and\x20the\x20server\x20is\x20reachable.';else(c['includes']('onchain')||c['includes']('account_operation')||c['includes']('bridge')||c['includes']('workflow')||c['includes']('keeper')||c['includes']('wowok'))&&(g='\x20This\x20tool\x20may\x20submit\x20an\x20ON-CHAIN\x20transaction.\x20The\x20transaction\x20was\x20NOT\x20cancelled\x20'+'by\x20this\x20timeout\x20—\x20it\x20may\x20already\x20be\x20submitted\x20and\x20still\x20finalize\x20on-chain.\x20'+'DO\x20NOT\x20blindly\x20retry\x20(risk\x20of\x20duplicate\x20operations).\x20First\x20verify:\x20'+'(1)\x20if\x20the\x20error\x20above\x20carries\x20a\x20tx\x20digest,\x20check\x20it\x20via\x20query_toolkit\x20'+'(query_type=\x27onchain_transaction\x27);\x20(2)\x20otherwise\x20verify\x20via\x20query_toolkit\x20'+'onchain_events\x20(or\x20the\x20account\x27s\x20recent\x20transactions).\x20Do\x20NOT\x20rely\x20on\x20an\x20'+'onchain_objects\x20read\x20alone:\x20it\x20may\x20serve\x20a\x20pre-transaction\x20cached\x20snapshot,\x20'+'so\x20an\x20unchanged\x20object\x20must\x20never\x20on\x20its\x20own\x20justify\x20a\x20retry.');f(new Error('Operation\x20\x27'+c+'\x27\x20timed\x20out\x20after\x20'+b+'ms.'+g));},b);})]);}export function wrapHandlerWithErrorShape(a,b,c,d){return async(e,f)=>{try{return await withTimeout(a(e,f),b,c);}catch(g){if(d){const h=g instanceof Error?g['message']:String(g),i=classifyError(h),j={'operation_type':c,'data':e},k=d(h,i,j);return{'content':[{'type':'text','text':'Error:\x20'+h}],'structuredContent':k};}throw g;}};}export const statusErrorShape=(a,b,c)=>({'result':buildClassifiedErrorResult({'status':'error'},a,b),'semantic':buildDataSemantic(undefined,c,!![],a)});export const operationErrorShape=(a,b,c)=>({'result':buildClassifiedErrorResult({'operation':'error'},a,b),'semantic':buildDataSemantic(undefined,c,!![],a)});export const strictStatusErrorShape=(a,b,c)=>({'result':{'status':'error','error':a}});function checkProjectStage(a,b,c){const d={'analyze_intent':'puzzle','aggregate_risks':'risk','trace_substeps':'substeps'},e=d[a];if(!e)return null;const f=getStageCache(b,c);if(!f){if(a==='analyze_intent')return null;return'project_stage:\x20calling\x20\x27'+a+'\x27\x20before\x20\x27analyze_intent\x27\x20—\x20recommend\x20calling\x20analyze_intent\x20first\x20for\x20project\x20\x27'+b+':'+c+'\x27';}if(stageIndexOf(f['stage'])<stageIndexOf(e)-0x1)return'project_stage:\x20calling\x20\x27'+a+'\x27\x20(stage\x20\x27'+e+'\x27)\x20but\x20project\x20is\x20at\x20stage\x20\x27'+f['stage']+'\x27\x20—\x20recommend\x20completing\x20prior\x20stages\x20first\x20for\x20\x27'+b+':'+c+'\x27';return null;}export function dispatchWithHarness(a,b){return async(d,f)=>{const g=[],h=getHarness(),i=shouldRunLightHooks(),j=shouldRunHeavyHooks(),k=isPublishOperation(b,d),l=isSignOperation(b,d),m=getHarnessTier();if(b==='goal_operation'&&i)try{const o=d,p=o?.['action'],q=o?.['project'],r=o?.['version'];if(p&&q&&r){const s=checkProjectStage(p,q,r);s&&g['push'](s);}}catch{}k&&m==='lightweight'&&(setHarnessTier('full'),g['push']('pre_publish:\x20tier\x20forced\x20to\x20full\x20for\x20publish-class\x20operation\x20(GLM5-21\x20§3.3)'));if(k&&m!=='off')try{const t=await runPrePublishChecks(b,d);g['push'](...t['warnings']);if(t['critical']['length']>0x0){for(const u of t['critical']){const v=recordCriticalRisk(u);if(v)g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+v['reason']);}return buildHarnessBlockResult('pre_publish','Publish\x20BLOCKED\x20by\x20Harness\x20pre-publish\x20gate\x20(GLM5-21\x20V6):\x20'+(t['critical']['length']+'\x20CRITICAL\x20risk(s)\x20must\x20be\x20resolved\x20before\x20publish.'),t['critical'],t['warnings'],'immutable_violation','Fix\x20the\x20CRITICAL\x20risks\x20listed\x20in\x20the\x20message\x20(e.g.\x20rename\x20dispute/refund\x20nodes\x20per\x20R-M1-11,\x20add\x20the\x20entry\x20pair\x20prev_node=\x22\x22),\x20then\x20retry\x20publish.\x20Nodes/pairs/forwards\x20are\x20immutable\x20after\x20publish\x20—\x20verify\x20via\x20machineNode2file\x20first.');}}catch(x){g['push']('pre_publish\x20hook\x20failed:\x20'+(x instanceof Error?x['message']:String(x)));}if(l&&j)try{const y=extractData(d),z=y?extractAmount(y,{'excludeConfigAmounts':!![]}):null;if(z!==null){const A=getAmountThreshold();let B=null;try{B=BigInt(z);}catch{B=null;}if(B!==null&&B>A)return buildHarnessBlockResult('pre_sign','Sign\x20BLOCKED\x20by\x20Harness\x20pre-sign\x20gate\x20(GLM5-21\x20V7):\x20amount\x20'+formatAmount(B)+'\x20WOW\x20exceeds\x20the\x20full-tier\x20threshold\x20'+formatAmount(A)+'\x20WOW.',['amount\x20'+z+'\x20(smallest\x20unit)\x20>\x20threshold\x20'+A['toString']()+'\x20(smallest\x20unit)'],[],'invalid_parameter','Raise\x20WOWOK_AMOUNT_THRESHOLD\x20to\x20match\x20the\x20intended\x20amount,\x20split\x20the\x20transaction,\x20or\x20reset\x20the\x20harness\x20tier\x20to\x20lightweight\x20(config_operation)\x20after\x20explicit\x20user\x20confirmation.');}}catch(C){g['push']('pre_sign\x20hook\x20failed:\x20'+(C instanceof Error?C['message']:String(C)));}let n;try{n=await a(d,f);}catch(D){const E=D instanceof Error?D['message']:String(D),F=recordOperationFailure(b,E);F&&g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+F['reason']);if(b==='onchain_operations')try{const G=classifyError(E,D);if(!G['retryable']&&G['error_code']!=='unknown'){const H=recordCriticalOperation(b,G['error_code']);if(H)g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+H['reason']);}}catch{}throw D;}if(b==='onchain_operations')try{if(classifyOutcome(n)==='failed'){const I=extractErrorCode(n)??'',J=classifyError(I);if(!J['retryable']&&J['error_code']!=='unknown'){const K=recordCriticalOperation(b,J['error_code']);if(K)g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+K['reason']);}}}catch{}if(i&&!isOutcomeDiscriminated(n)){const L=extractIntent(b,d)??b;try{const M=classifyOutcome(n);if(M==='failed'){const N=extractErrorCode(n)??'',O=classifyError(N),P=h['recover'](O['error_code'],L,{'operation_type':b,'data':extractData(d)});g['push']('Harness\x20recover:\x20strategy='+P['strategy']+('\x20(attempt\x20'+P['current_attempt']+'/'+P['max_attempts']+')')+(P['should_retry']?'\x20—\x20retryable':'\x20—\x20do\x20NOT\x20retry\x20blindly')+(P['user_prompt']?'\x20—\x20'+P['user_prompt']:'\x20—\x20'+P['detail']));}else M==='success'&&h['resetRecovery'](L);}catch(Q){g['push']('recover\x20hook\x20failed:\x20'+(Q instanceof Error?Q['message']:String(Q)));}}if(b==='goal_operation')try{const R=d?.['action'];if(R==='trace_substeps'){const S=extractCriticalFindingCount(n);if(S>0x0){const T=recordSubstepFailure(String(R)+':\x20'+S+'\x20critical\x20finding(s)');if(T)g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+T['reason']);}}}catch{}if(isWriteClassTool(b)&&!SEMANTIC_RECORDED_TOOLS['has'](b))try{const U=extractOperationType(b,d)??b,V=extractIntent(b,d)??b,W=extractData(d)??d,X=classifyOutcome(n),Y=extractErrorCode(n),Z=isEnabled('experience_layer');if(Z)recordOperationOutcome(U,W,V,X,Y);else{const a0=extractIndustry(d);a0&&isEnabled('industry_evolution')&&recordIndustrySignal(a0,{'type':U},{'success':X==='success','error_code':Y});}}catch(a1){g['push']('signal\x20collection\x20failed:\x20'+(a1 instanceof Error?a1['message']:String(a1)));}if(g['length']>0x0){if(n?.['structuredContent']){const a2=n['structuredContent'],a3=a2['semantic'];if(a3){const a4=Array['isArray'](a3['warnings'])?a3['warnings']:[];a3['warnings']=[...a4,...g];}else for(const a5 of g){console['warn']('[harness]\x20'+a5);}}else for(const a6 of g){console['warn']('[harness]\x20'+a6);}}return n;};}function isPublishOperation(a,b){if(a!=='onchain_operations')return![];const c=extractOperationType(a,b);if(c!=='service'&&c!=='machine')return![];const d=extractData(b);return d?.['publish']===!![]||d?.['bPublished']===!![];}function isSignOperation(a,b){if(a==='wip_file'){const c=b?.['operation_type'];return c==='sign';}return a==='onchain_operations';}function extractOperationType(a,b){if(!b||typeof b!=='object')return undefined;const c=b;if(a==='onchain_operations')return typeof c['operation_type']==='string'?c['operation_type']:undefined;if(a==='goal_operation'||a==='industry_pack_operation'||a==='strategy_review_operation')return typeof c['action']==='string'?c['action']:undefined;return typeof c['operation_type']==='string'?c['operation_type']:undefined;}function extractIntent(a,b){if(!b||typeof b!=='object')return undefined;const c=b;if((a==='goal_operation'||a==='industry_pack_operation'||a==='strategy_review_operation')&&typeof c['action']==='string')return a+':'+c['action'];const d=c['operation_type'];if(typeof d==='string')return a+':'+d;return a;}function extractData(a){if(!a||typeof a!=='object')return undefined;const b=a,c=b['data'];return c&&typeof c==='object'?c:undefined;}const WRITE_CLASS_TOOLS=new Set(['onchain_operations','goal_operation','industry_pack_operation','strategy_review_operation','wip_file','messenger_operation','bridge_operation']),SEMANTIC_RECORDED_TOOLS=new Set(['onchain_operations','bridge_operation']);function isWriteClassTool(a){return WRITE_CLASS_TOOLS['has'](a);}function classifyOutcome(a){if(!a?.['structuredContent'])return'failed';const b=a['structuredContent'];if(b['outcome']==='failed')return'failed';if(b['outcome']==='executed')return'success';if(b['outcome']==='pending_input')return'partial';const c=typeof b['status']==='string'?b['status']:typeof b['result_type']==='string'?b['result_type']:'';if(c==='error'||c==='failed')return'failed';if(c==='partial')return'partial';return'success';}function isOutcomeDiscriminated(a){const b=a?.['structuredContent'];return!!b&&typeof b==='object'&&'outcome'in b;}function extractErrorCode(a){if(!a?.['structuredContent'])return undefined;const b=a['structuredContent'];if(typeof b['error_code']==='string')return b['error_code'];const c=b['error'];if(typeof c==='string')return c;if(c&&typeof c==='object'){const d=c['code'];if(typeof d==='string')return d;}return undefined;}function extractIndustry(a){if(!a||typeof a!=='object')return undefined;const b=a;if(typeof b['industry']==='string')return b['industry'];const c=b['data'];if(c&&typeof c==='object'){const e=c;if(typeof e['industry']==='string')return e['industry'];}return undefined;}function numericBalance(a){if(typeof a==='number'&&Number['isFinite'](a))return a;if(typeof a==='string'&&a['trim']()!==''&&Number['isFinite'](Number(a)))return Number(a);return undefined;}async function runPrePublishChecks(a,b){const c=[],d=[],f=extractOperationType(a,b),g=extractData(b)??{};if(f==='machine'){const h=g['node'];let i=Array['isArray'](h)?h:Array['isArray'](h?.['nodes'])?h['nodes']:[];if(i['length']===0x0&&typeof g['object']==='string'){const j=g['object'],k=b?.['env']?.['network'];try{const l=await fetchMachineNodes(j,k,!![]);l['length']>0x0&&(i=l,d['push']('pre_publish:\x20machine\x20\x22'+j+'\x22\x20published\x20by\x20reference\x20—\x20audited\x20against\x20its\x20'+(l['length']+'\x20on-chain\x20node(s)\x20(effective-state\x20gate)')));}catch(m){d['push']('pre_publish:\x20could\x20not\x20fetch\x20on-chain\x20nodes\x20for\x20machine\x20\x22'+j+'\x22\x20'+('('+(m instanceof Error?m['message']:String(m))+')\x20—\x20topology\x20not\x20verifiable\x20in\x20this\x20call;\x20')+'verify\x20via\x20machineNode2file\x20BEFORE\x20publish\x20(immutable\x20after\x20publish,\x20IMMUT-001)');}}if(i['length']>0x0){const n=auditMachineNodes(i);c['push'](...n['critical']),d['push'](...n['warnings']);}else typeof g['object']!=='string'&&d['push']('pre_publish:\x20publishing\x20machine\x20without\x20inline\x20node\x20data\x20—\x20topology\x20not\x20verifiable\x20in\x20this\x20call;\x20'+'verify\x20nodes/pairs/forwards\x20via\x20machineNode2file\x20BEFORE\x20publish\x20(immutable\x20after\x20publish,\x20IMMUT-001)');d['push']('pre_publish:\x20machine\x20nodes/pairs/forwards\x20become\x20immutable\x20after\x20publish\x20(IMMUT-001)');}if(f==='service'){d['push']('pre_publish:\x20service\x20machine/order_allocators/arbitrations\x20become\x20immutable\x20after\x20publish\x20(IMMUT-002);\x20sales\x20remains\x20modifiable');g['machine']===undefined&&d['push']('pre_publish:\x20\x27machine\x27\x20absent\x20from\x20THIS\x20call\x20(the\x20store\x20may\x20already\x20be\x20bound\x20—\x20verify\x20before\x20assuming\x20otherwise):\x20'+'query_toolkit\x20query_type=\x27service_panorama\x27\x20and\x20read\x20service.machine;\x20an\x20unset\x20machine\x20cannot\x20process\x20orders\x20and\x20CANNOT\x20be\x20fixed\x20after\x20publish\x20(IMMUT-002)');g['order_allocators']===undefined&&d['push']('pre_publish:\x20\x27order_allocators\x27\x20absent\x20from\x20THIS\x20call\x20(the\x20store\x20may\x20already\x20be\x20configured\x20—\x20verify\x20before\x20assuming\x20otherwise):\x20'+'query_toolkit\x20query_type=\x27service_panorama\x27\x20and\x20read\x20order_allocators;\x20immutable\x20after\x20publish,\x20so\x20orders\x20get\x20no\x20fund\x20distribution\x20if\x20never\x20configured\x20(IMMUT-002)');const o=g,p=numericBalance(o['compensation_fund_add']?.['balance']);if(p!==undefined&&p>0x0){const q=o['sales'],r=(Array['isArray'](q?.['sales'])?q['sales']:[])['map'](s=>numericBalance(s?.['price']?.['balance']))['filter'](s=>s!==undefined);if(r['length']>0x0){const s=r['reduce']((u,v)=>u+v,0x0),t=s*0x3;if(t>0x0){const u=p/t,v=getFundCoverageMin(),w='fund='+p+',\x20max\x20single\x20order=Σ(price×1)='+s+'\x20(quantity\x20set\x20at\x20buy\x20time),\x20'+('award\x20cap=3×order='+t+'\x20(MAX_INDEMNITY_MULTIPLE),\x20coverage='+u['toFixed'](0x2));if(v>0x0&&u<v)d['push']('pre_publish:\x20G7\x20advisory\x20—\x20compensation-fund\x20coverage\x20below\x20the\x20configured\x20minimum\x20—\x20'+w+'\x20<\x20'+v+'.\x20'+'Awards\x20beyond\x20the\x20fund\x20draw\x20from\x20the\x20merchant\x20wallet.\x20'+'Consider\x20adding\x20funds\x20(compensation_fund_add),\x20or\x20set\x20WOWOK_FUND_COVERAGE_MIN\x20'+'(0\x20silences\x20this\x20advisory).\x20Informational\x20—\x20does\x20not\x20block\x20publish');else u<0x1&&d['push']('pre_publish:\x20compensation-fund\x20coverage\x20below\x20the\x20award\x20ceiling\x20—\x20'+w+'\x20<\x201\x20—\x20'+'awards\x20beyond\x20the\x20fund\x20draw\x20from\x20the\x20merchant\x20wallet.\x20Informational');}}else d['push']('pre_publish:\x20compensation_fund_add\x20present\x20but\x20\x27sales\x27\x20absent\x20from\x20THIS\x20call\x20(sales\x20may\x20already\x20be\x20configured\x20—\x20verify,\x20do\x20not\x20assume):\x20'+'the\x20fund\x20should\x20cover\x203×\x20the\x20maximum\x20single-order\x20amount\x20(MAX_INDEMNITY_MULTIPLE=3).\x20'+'query_toolkit\x20query_type=\x27service_panorama\x27\x20to\x20read\x20the\x20current\x20sales\x20prices,\x20then\x20re-check\x20coverage');}}return{'critical':c,'warnings':d};}function buildHarnessBlockResult(a,b,c,d,e,f){const g=[...c['map'](i=>'CRITICAL:\x20'+i),...d['map'](i=>'WARN:\x20'+i)]['join']('\x0a'),h='Error:\x20'+b+(g?'\x0a'+g:'')+'\x0aRecovery:\x20'+f;return{'content':[{'type':'text','text':h}],'structuredContent':{'outcome':'failed','result':{'type':'error','error':b+'\x20[gate='+a+']','error_code':e,'retryable':![],'recovery_hint':f},'message':h,'recovery':recover(e,'harness:'+a)}};}function extractCriticalFindingCount(a){const b=a?.['structuredContent'];if(!b)return 0x0;const c=b['semantic'],d=c?.['summary'];if(typeof d?.['critical_count']==='number'&&d['critical_count']>0x0)return d['critical_count'];const e=b['findings']??c?.['findings'];if(Array['isArray'](e))return e['filter'](h=>h?.['severity']==='error')['length'];const f=a?.['content']?.['map'](h=>'text'in h?h['text']:'')['join']('\x0a')??'',g=f['match'](/\[AUDIT ERROR\]/g);return g?g['length']:0x0;}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wowok/agent-mcp",
3
- "version": "3.2.0",
3
+ "version": "3.2.1",
4
4
  "description": "Making It Easy for AI Agents to Communicate, Collaborate, Trade, and Trust.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -54,7 +54,7 @@
54
54
  "license": "Apache-2.0",
55
55
  "dependencies": {
56
56
  "@modelcontextprotocol/server": "^2.0.0",
57
- "@wowok/wowok": "3.2.0",
57
+ "@wowok/wowok": "3.2.1",
58
58
  "lodash": "^4.18.1",
59
59
  "zod": "^4.2.0"
60
60
  },