@wowok/agent-mcp 3.2.9 → 3.3.0

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 (200) hide show
  1. package/README.md +2 -2
  2. package/dist/chain-semantics/field-capability.js +1 -1
  3. package/dist/chain-semantics/freeze-map.js +1 -1
  4. package/dist/chain-semantics/fund-flow.js +1 -1
  5. package/dist/chain-semantics/object-graph.js +1 -1
  6. package/dist/composition/audit.js +1 -1
  7. package/dist/composition/compile.d.ts +10 -1
  8. package/dist/composition/compile.js +1 -1
  9. package/dist/composition/inflight.js +1 -1
  10. package/dist/extensions/capability-manifest.js +1 -1
  11. package/dist/extensions/industry-audit.spec.js +1 -1
  12. package/dist/extensions/industry-pack.js +1 -1
  13. package/dist/graph/onchain/facts.spec.js +1 -1
  14. package/dist/graph/onchain/field-manifest.js +1 -1
  15. package/dist/harness/recover.js +1 -1
  16. package/dist/intent/types.d.ts +1 -1
  17. package/dist/intent/types.js +1 -1
  18. package/dist/keeper/KeeperScan.d.ts +2 -1
  19. package/dist/keeper/KeeperScan.js +1 -1
  20. package/dist/keeper/keeper.spec.js +1 -1
  21. package/dist/keeper/types.d.ts +3 -0
  22. package/dist/keeper/types.js +1 -1
  23. package/dist/knowledge/allocator-rail-verifier.d.ts +34 -0
  24. package/dist/knowledge/allocator-rail-verifier.js +1 -0
  25. package/dist/knowledge/arbitration-ledger.js +1 -1
  26. package/dist/knowledge/arbitration-templates.js +1 -1
  27. package/dist/knowledge/arbitration-venue-order.js +1 -1
  28. package/dist/knowledge/audit-rules.d.ts +19 -1
  29. package/dist/knowledge/audit-rules.js +1 -1
  30. package/dist/knowledge/baselines/rules/alloc_audit.json +1 -1
  31. package/dist/knowledge/baselines/rules/arb.json +1 -1
  32. package/dist/knowledge/baselines/rules/guard.json +15 -5
  33. package/dist/knowledge/baselines/rules/machine.json +9 -6
  34. package/dist/knowledge/baselines/rules/plan.json +12 -12
  35. package/dist/knowledge/baselines/semantic-facts.js +1 -1
  36. package/dist/knowledge/builtin-templates.d.ts +1 -1
  37. package/dist/knowledge/builtin-templates.js +1 -1
  38. package/dist/knowledge/contract-invariants.js +1 -1
  39. package/dist/knowledge/event-semantics.js +1 -1
  40. package/dist/knowledge/fund-layer.js +1 -1
  41. package/dist/knowledge/getting-started.js +1 -1
  42. package/dist/knowledge/guard-anchor-reach.d.ts +1 -1
  43. package/dist/knowledge/guard-anchor-reach.js +1 -1
  44. package/dist/knowledge/guard-bindings.js +1 -1
  45. package/dist/knowledge/guard-design-patterns.d.ts +1 -1
  46. package/dist/knowledge/guard-design-patterns.js +1 -1
  47. package/dist/knowledge/guard-field-cognition.js +1 -1
  48. package/dist/knowledge/guard-render.js +1 -1
  49. package/dist/knowledge/guard-risk.js +1 -1
  50. package/dist/knowledge/guard-templates.d.ts +1 -1
  51. package/dist/knowledge/guard-templates.js +1 -1
  52. package/dist/knowledge/index.js +1 -1
  53. package/dist/knowledge/industry-registry.js +1 -1
  54. package/dist/knowledge/industry-strategy.js +1 -1
  55. package/dist/knowledge/jsonrpc-enum.js +1 -1
  56. package/dist/knowledge/machine-ledger.js +1 -1
  57. package/dist/knowledge/machine-puzzle.d.ts +1 -1
  58. package/dist/knowledge/machine-puzzle.js +1 -1
  59. package/dist/knowledge/machine-risk.js +1 -1
  60. package/dist/knowledge/machine-templates.js +1 -1
  61. package/dist/knowledge/machine-topology.d.ts +8 -0
  62. package/dist/knowledge/machine-topology.js +1 -1
  63. package/dist/knowledge/machine-translation.js +1 -1
  64. package/dist/knowledge/permission-ledger.js +1 -1
  65. package/dist/knowledge/protocol-facts.d.ts +16 -0
  66. package/dist/knowledge/protocol-facts.js +1 -0
  67. package/dist/knowledge/recipient-constraint.js +1 -1
  68. package/dist/knowledge/reward-ledger.d.ts +2 -1
  69. package/dist/knowledge/reward-ledger.js +1 -1
  70. package/dist/knowledge/reward-templates.js +1 -1
  71. package/dist/knowledge/safety-rules.d.ts +0 -2
  72. package/dist/knowledge/safety-rules.js +1 -1
  73. package/dist/knowledge/scenario-modes.d.ts +7 -0
  74. package/dist/knowledge/scenario-modes.js +1 -1
  75. package/dist/knowledge/strategy-manuals.js +1 -1
  76. package/dist/knowledge/template-loader.d.ts +13 -1
  77. package/dist/knowledge/template-loader.js +1 -1
  78. package/dist/knowledge/template-registry.js +1 -1
  79. package/dist/knowledge/template-scanner.js +1 -1
  80. package/dist/knowledge/tool-constraints.js +1 -1
  81. package/dist/knowledge/tools-reference.js +1 -1
  82. package/dist/monitor/MonitorLoop.js +1 -1
  83. package/dist/monitor/normalize.d.ts +1 -1
  84. package/dist/monitor/normalize.js +1 -1
  85. package/dist/monitor/types.d.ts +1 -1
  86. package/dist/monitor/types.js +1 -1
  87. package/dist/playbooks/service-build/business-puzzle.js +1 -1
  88. package/dist/playbooks/service-build/game-theory.d.ts +1 -0
  89. package/dist/playbooks/service-build/game-theory.js +1 -1
  90. package/dist/playbooks/service-build/intent-analyzer.js +1 -1
  91. package/dist/playbooks/service-build/machine-panorama.js +1 -1
  92. package/dist/playbooks/service-build/merchant-guide.js +1 -1
  93. package/dist/playbooks/service-build/object-panorama.js +1 -1
  94. package/dist/playbooks/service-build/participation-radar.js +1 -1
  95. package/dist/playbooks/service-build/relationship-profile.js +1 -1
  96. package/dist/playbooks/service-build/service-panorama.js +1 -1
  97. package/dist/playbooks/service-build/service-quote.js +1 -1
  98. package/dist/playbooks/service-build/service-quote.spec.js +1 -1
  99. package/dist/relationship/registry.js +1 -1
  100. package/dist/review/index.js +1 -1
  101. package/dist/role/profiles.js +1 -1
  102. package/dist/safety/confirm-gate.js +1 -1
  103. package/dist/schema/benchmark-migration/index.d.ts +5 -1
  104. package/dist/schema/benchmark-migration/index.js +1 -1
  105. package/dist/schema/call/arbitration.d.ts +4 -4
  106. package/dist/schema/call/arbitration.js +1 -1
  107. package/dist/schema/call/base.d.ts +39 -0
  108. package/dist/schema/call/base.js +1 -1
  109. package/dist/schema/call/bridge.d.ts +1 -0
  110. package/dist/schema/call/contact.d.ts +4 -4
  111. package/dist/schema/call/demand.d.ts +4 -4
  112. package/dist/schema/call/error-codes.d.ts +1 -1
  113. package/dist/schema/call/error-codes.js +1 -1
  114. package/dist/schema/call/handler.js +1 -1
  115. package/dist/schema/call/machine.d.ts +12 -4
  116. package/dist/schema/call/order.d.ts +4 -4
  117. package/dist/schema/call/permission.d.ts +4 -4
  118. package/dist/schema/call/progress.d.ts +4 -4
  119. package/dist/schema/call/receipt.d.ts +8 -0
  120. package/dist/schema/call/receipt.js +1 -1
  121. package/dist/schema/call/repository.d.ts +4 -4
  122. package/dist/schema/call/reward.d.ts +24 -4
  123. package/dist/schema/call/reward.js +1 -1
  124. package/dist/schema/call/semantic.js +1 -1
  125. package/dist/schema/call/service.d.ts +6 -4
  126. package/dist/schema/call/service.js +1 -1
  127. package/dist/schema/call/treasury.d.ts +4 -4
  128. package/dist/schema/common/index.d.ts +2 -2
  129. package/dist/schema/common/index.js +1 -1
  130. package/dist/schema/goal/index.d.ts +5 -1
  131. package/dist/schema/goal/planning.d.ts +10 -2
  132. package/dist/schema/goal/planning.js +1 -1
  133. package/dist/schema/industry-pack/index.d.ts +3 -0
  134. package/dist/schema/industry-pack/index.js +1 -1
  135. package/dist/schema/intent-radar/index.d.ts +9 -0
  136. package/dist/schema/intent-radar/index.js +1 -1
  137. package/dist/schema/local/index.d.ts +10 -0
  138. package/dist/schema/local/index.js +1 -1
  139. package/dist/schema/operations.d.ts +35 -22
  140. package/dist/schema/operations.js +1 -1
  141. package/dist/schema/query/bi.d.ts +16 -0
  142. package/dist/schema/query/bi.js +1 -1
  143. package/dist/schema/query/index.d.ts +52 -48
  144. package/dist/schema/query/index.js +1 -1
  145. package/dist/schema/schema-query/index.d.ts +1 -0
  146. package/dist/schema/schema-query/index.js +1 -1
  147. package/dist/schema/schema-version.js +1 -1
  148. package/dist/schema-query-impl/index.d.ts +1 -1
  149. package/dist/schema-query-impl/index.js +1 -1
  150. package/dist/schemas/account_operation.output.json +1 -0
  151. package/dist/schemas/account_operation.schema.json +1 -1
  152. package/dist/schemas/benchmark_migration_operation.schema.json +27 -3
  153. package/dist/schemas/bridge_operation.output.json +1 -0
  154. package/dist/schemas/goal_operation.schema.json +26 -2
  155. package/dist/schemas/index.json +1 -1
  156. package/dist/schemas/industry_pack_operation.output.json +8 -0
  157. package/dist/schemas/industry_pack_operation.schema.json +9 -0
  158. package/dist/schemas/intent_radar.output.json +8 -2
  159. package/dist/schemas/intent_radar.schema.json +4 -1
  160. package/dist/schemas/local_cache_operation.output.json +1 -0
  161. package/dist/schemas/local_history_operation.output.json +1 -0
  162. package/dist/schemas/local_info_operation.output.json +1 -0
  163. package/dist/schemas/local_mark_operation.output.json +1 -0
  164. package/dist/schemas/monitor_events.schema.json +3 -1
  165. package/dist/schemas/onchain_events.output.json +275 -11
  166. package/dist/schemas/onchain_events.schema.json +25 -1
  167. package/dist/schemas/onchain_operations.output.json +40 -0
  168. package/dist/schemas/onchain_operations.schema.json +573 -104
  169. package/dist/schemas/onchain_operations_allocation.schema.json +2 -2
  170. package/dist/schemas/onchain_operations_arbitration.schema.json +11 -7
  171. package/dist/schemas/onchain_operations_contact.schema.json +9 -5
  172. package/dist/schemas/onchain_operations_demand.schema.json +9 -5
  173. package/dist/schemas/onchain_operations_guard.schema.json +342 -4
  174. package/dist/schemas/onchain_operations_machine.schema.json +17 -5
  175. package/dist/schemas/onchain_operations_order.schema.json +9 -5
  176. package/dist/schemas/onchain_operations_permission.schema.json +9 -5
  177. package/dist/schemas/onchain_operations_progress.schema.json +9 -5
  178. package/dist/schemas/onchain_operations_repository.schema.json +9 -5
  179. package/dist/schemas/onchain_operations_reward.schema.json +89 -9
  180. package/dist/schemas/onchain_operations_service.schema.json +18 -11
  181. package/dist/schemas/onchain_operations_treasury.schema.json +9 -5
  182. package/dist/schemas/query_toolkit.output.json +237 -14
  183. package/dist/schemas/schema_query.schema.json +3 -2
  184. package/dist/tools/handlers/benchmark-migration.d.ts +45 -1
  185. package/dist/tools/handlers/benchmark-migration.js +1 -1
  186. package/dist/tools/handlers/config.js +1 -1
  187. package/dist/tools/handlers/industry-pack.js +1 -1
  188. package/dist/tools/handlers/intent-radar.js +1 -1
  189. package/dist/tools/handlers/keeper.d.ts +1 -1
  190. package/dist/tools/handlers/onchain.d.ts +12 -0
  191. package/dist/tools/handlers/onchain.js +1 -1
  192. package/dist/tools/handlers/schema-query.js +1 -1
  193. package/dist/tools/handlers/workflow.js +1 -1
  194. package/dist/tools/index.js +1 -1
  195. package/dist/tools/registry/agent.js +1 -1
  196. package/dist/tools/registry/business.js +1 -1
  197. package/dist/tools/registry/query.js +1 -1
  198. package/dist/tools/rules-hook.js +1 -1
  199. package/dist/tools/wrap.js +1 -1
  200. package/package.json +2 -2
@@ -1 +1 @@
1
- import{readdirSync,readFileSync,writeFileSync,existsSync,mkdirSync,statSync,cpSync,renameSync,rmSync}from'node:fs';import{join,relative,resolve,sep,dirname,basename}from'node:path';import{strictParse}from'../../schema/index.js';import{IndustryPackOperationInputSchema}from'../../schema/industry-pack/index.js';import{validateJudgmentFragment}from'../../config/judgment.js';import{scaffoldIndustryPack,listRegisteredPacks,getRegisteredPack,packKind,scanDefaultIndustryPacks,seedBuiltinIndustryTemplates,seedBuiltinStrategyManuals,ensureIndustryReadme,resolveIndustryPackDir,rescanPack,resolveDisputeRules,resolveComplianceRules,resolveSupplyRules,resolveIndustryRules,resolveIndustryPlaybook,diffIndustryPack,resetIndustryPath}from'../../extensions/index.js';import{getIndustryModeRegistry}from'../../extensions/registry.js';import{getBuiltinTemplate,listBuiltinTemplates}from'../../knowledge/builtin-templates.js';import{handleRecommendIndustry,handleListModes,handleDeriveUserMode,handleEvolveUserMode,handleRegisterUserMode,handleUnregisterUserMode,handleRegisterCustomMetric,handleUnregisterCustomMetric,handleRegisterCustomConstraint,handleUnregisterCustomConstraint,handleListMetricsConstraints}from'../../playbooks/service-build/mode-actions.js';import{repairBuiltinTemplates,builtinTemplateDrift,resolveTemplatesDir,parseTemplateFile,TemplateFrontmatterSchema}from'../../knowledge/template-loader.js';const INDUSTRY_ROOT=resolveIndustryPackDir(),resolveTemplatesDirSafe=resolveTemplatesDir;function resolveIndustryPath(a){const b=resolve(INDUSTRY_ROOT,a);if(b!==INDUSTRY_ROOT&&!b['startsWith'](INDUSTRY_ROOT+sep))throw new Error('path\x20\x27'+a+'\x27\x20escapes\x20the\x20industry\x20root');return b;}function isTemplateTreePath(a){const b=a['split'](/[\\/]+/)['filter'](c=>c['length']>0x0);return b['length']>=0x2&&b[0x1]==='templates';}function assertTemplateWriteAuthorized(a,b,c){if(c===!![])return;const d=b['find'](e=>e!==undefined&&isTemplateTreePath(e));if(!d)return;throw new Error('action=\x27'+a+'\x27\x20modifies\x20the\x20user-editable\x20template\x20file\x20\x27'+d+'\x27.\x20'+'Present\x20the\x20intended\x20change\x20to\x20the\x20user\x20first;\x20after\x20the\x20user\x20explicitly\x20confirms,\x20'+'re-call\x20with\x20authorize=true\x20(C5).');}function rescanAffectedPack(a){const b=a['split'](/[\\/]+/)['find'](c=>c['length']>0x0);if(!b)return;rescanPack(b);}const BASELINES_FILENAME='baselines.json',PACK_FILENAME='pack.json';function assertBaselinesContentValid(a,b){const c=a['split'](/[\\/]+/)['pop']()??'';if(c!==BASELINES_FILENAME&&c!==PACK_FILENAME)return;let d;try{d=JSON['parse'](b);}catch{return;}if(!d||typeof d!=='object'||Array['isArray'](d))return;const e=d,f=c===BASELINES_FILENAME?d:e['baselines'];if(f===undefined||f===null)return;const g=validateJudgmentFragment(f,a+'\x20baselines');if(g)throw new Error('write\x20rejected\x20—\x20the\x20baselines\x20fragment\x20in\x20\x27'+a+'\x27\x20is\x20not\x20a\x20valid\x20judgment\x20fragment:\x20'+g);}function assertTemplateContentValid(a,b){if(!isTemplateTreePath(a)||!a['endsWith']('.md'))return;let c;try{({frontmatter:c}=parseTemplateFile(b));}catch(e){throw new Error('write\x20rejected\x20—\x20\x27'+a+'\x27\x20is\x20a\x20template\x20file\x20but\x20the\x20frontmatter\x20block\x20is\x20malformed:\x20'+e['message']);}const d=TemplateFrontmatterSchema['safeParse'](c);if(!d['success']){const f=d['error']['issues']['map'](g=>'\x20\x20'+g['path']['join']('.')+':\x20'+g['message'])['join']('\x0a');throw new Error('write\x20rejected\x20—\x20the\x20template\x20frontmatter\x20in\x20\x27'+a+'\x27\x20violates\x20the\x20schema\x20(the\x20editor\x20whitelist\x20IS\x20the\x20zod\x20schema):\x0a'+f);}}function listRecursive(a,b,c,d=0x0){if(d>0x8)return;let f;try{f=readdirSync(a,{'withFileTypes':!![]});}catch{return;}for(const g of f){const h=join(a,g['name']),i=relative(b,h)['split'](sep)['join']('/');let j=0x0,k=0x0;try{const l=statSync(h);k=l['size'],j=l['mtimeMs'];}catch{}g['isDirectory']()?(c['push']({'path':i,'is_dir':!![],'size':0x0,'mtime':j}),listRecursive(h,b,c,d+0x1)):c['push']({'path':i,'is_dir':![],'size':k,'mtime':j});}}export async function handleIndustryPackOperation(a){const b=strictParse(IndustryPackOperationInputSchema,a,'industry_pack_operation\x20input');mkdirSync(INDUSTRY_ROOT,{'recursive':!![]}),seedBuiltinIndustryTemplates(),seedBuiltinStrategyManuals(),ensureIndustryReadme();let c;switch(b['action']){case'scaffold':{if(!b['name'])throw new Error('\x27name\x27\x20is\x20required\x20for\x20action=\x27scaffold\x27');const d=scaffoldIndustryPack(b['name']);c={'action':'scaffold','ok':d['ok'],'dir':d['dir'],'files':d['files'],'errors':d['errors']};if(d['ok'])rescanPack(b['name']);break;}case'list':{c={'action':'list','packs':listRegisteredPacks()};break;}case'scan':{c={'action':'scan','results':scanDefaultIndustryPacks()};break;}case'repair_builtin_templates':{if(b['authorize']!==!![]){const g=repairBuiltinTemplates({'backup':!![],'dryRun':!![]}),h=g['filter'](i=>i['status']==='would_update');c={'action':'repair_builtin_templates','dir':resolveTemplatesDirSafe(),'reseeded_count':0x0,'requires_authorization':!![],'results':g,'note':h['length']?'PLAN\x20ONLY\x20(no\x20writes)\x20—\x20'+h['length']+'\x20builtin\x20file(s)\x20differ\x20from\x20the\x20in-code\x20catalog\x20and\x20would\x20be\x20reseeded\x20(each\x20result\x20carries\x20a\x20field-level\x20diff;\x20previous\x20bodies\x20preserved\x20as\x20<file>.bak).\x20Present\x20this\x20plan\x20to\x20the\x20user;\x20after\x20the\x20user\x20explicitly\x20confirms,\x20re-call\x20with\x20authorize=true\x20to\x20execute.':'Nothing\x20to\x20repair\x20—\x20every\x20on-disk\x20builtin\x20template\x20either\x20matches\x20the\x20in-code\x20catalog\x20or\x20carries\x20user\x20edits\x20(which\x20are\x20never\x20overwritten).'};break;}const e=repairBuiltinTemplates({'backup':!![]}),f=e['filter'](i=>i['status']==='updated');c={'action':'repair_builtin_templates','dir':resolveTemplatesDirSafe(),'reseeded_count':f['length'],'results':e,'note':f['length']?'Diverging\x20builtin\x20files\x20were\x20reseeded\x20from\x20the\x20in-code\x20catalog.\x20Each\x20previous\x20body\x20is\x20preserved\x20as\x20<file>.bak.':'Nothing\x20repaired\x20—\x20every\x20on-disk\x20builtin\x20template\x20either\x20matches\x20the\x20in-code\x20catalog\x20or\x20carries\x20user\x20edits\x20(which\x20are\x20never\x20overwritten).'};break;}case'template_drift':{const i=builtinTemplateDrift(),j=i['filter'](k=>k['repairable'])['length'];c={'action':'template_drift','dir':resolveTemplatesDirSafe(),'drift_count':i['length'],'repairable_count':j,'drift':i,'note':i['length']?j>0x0?j+'\x20of\x20'+i['length']+'\x20diverging\x20builtin\x20template(s)\x20can\x20be\x20reseeded\x20without\x20losing\x20user\x20work\x20—\x20run\x20action=\x27repair_builtin_templates\x27\x20(plan-only\x20preview\x20first,\x20then\x20authorize=true\x20after\x20the\x20user\x20confirms).\x20The\x20rest\x20carry\x20user\x20edits\x20and\x20are\x20never\x20overwritten.':'All\x20diverging\x20builtin\x20templates\x20carry\x20user\x20edits\x20—\x20never\x20overwritten\x20automatically;\x20resolve\x20by\x20hand\x20or\x20via\x20an\x20authorized\x20write.':'Every\x20builtin\x20template\x20on\x20disk\x20matches\x20the\x20in-code\x20catalog.'};break;}case'resolve':{c={'action':'resolve','dir':INDUSTRY_ROOT};break;}case'list_files':{const k=[];listRecursive(INDUSTRY_ROOT,INDUSTRY_ROOT,k),c={'action':'list_files','dir':INDUSTRY_ROOT,'files':k};break;}case'read_file':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27read_file\x27');const l=resolveIndustryPath(b['path']);if(!existsSync(l))throw new Error('file\x20not\x20found:\x20'+b['path']);c={'action':'read_file','path':l,'content':readFileSync(l,'utf-8')};break;}case'write_file':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27write_file\x27');if(b['content']===undefined)throw new Error('\x27content\x27\x20is\x20required\x20for\x20action=\x27write_file\x27');assertTemplateWriteAuthorized('write_file',[b['path']],b['authorize']);const m=resolveIndustryPath(b['path']);assertBaselinesContentValid(b['path'],b['content']),assertTemplateContentValid(b['path'],b['content']),mkdirSync(dirname(m),{'recursive':!![]}),writeFileSync(m,b['content'],'utf-8'),c={'action':'write_file','path':m,'ok':!![]},rescanAffectedPack(b['path']);break;}case'get':{if(!b['name'])throw new Error('\x27name\x27\x20is\x20required\x20for\x20action=\x27get\x27');const n=b['name'],o=getRegisteredPack(n),p=o?.['layers']??[],q=()=>o?{'kind':packKind(p),'layers':p}:{},u=()=>{const x=getIndustryModeRegistry()['getMode'](n);return x?{'name':x['name'],'display_name':x['display_name'],'key_risk':x['key_risk'],'needs':x['needs']['map'](y=>y['description']),...x['analyze']?.['key_questions']?.['length']?{'analyze_questions':x['analyze']['key_questions']['slice'](0x0,0x2)}:{}}:undefined;};if(b['layer']==='template'){if(b['template']){const x=getBuiltinTemplate(b['template']);if(!x)throw new Error('template\x20\x27'+b['template']+'\x27\x20is\x20not\x20in\x20the\x20builtin\x20catalog\x20'+('(available:\x20'+listBuiltinTemplates()['map'](y=>y['id'])['join'](',\x20')+')'));if(x['industry']!==n)throw new Error('template\x20\x27'+x['id']+'\x27\x20belongs\x20to\x20industry\x20\x27'+x['industry']+'\x27,\x20not\x20\x27'+n+'\x27\x20—\x20'+'set\x20\x27name\x27\x20to\x20the\x20template\x27s\x20industry');c={'action':'get','category':n,'layer':'template','template':JSON['parse'](JSON['stringify'](x))};}else{const y=listBuiltinTemplates()['filter'](z=>z['industry']===n)['map'](z=>({'id':z['id'],'variant':z['variant'],'product_ref':z['product_ref'],'key_risk':z['key_risk']}));if(!y['length'])throw new Error('industry\x20\x27'+n+'\x27\x20has\x20no\x20builtin\x20templates\x20(ids\x20use\x20\x27<industry>/<variant>\x27)');c={'action':'get','category':n,'layer':'template','templates':y,'note':'Re-call\x20with\x20layer=\x27template\x27\x20+\x20template=\x27<id>\x27\x20for\x20the\x20full\x20projection\x20'+'(machine_shape/guards/allocator\x20rows/fee_params/build_notes).'};}break;}if(b['layer']){const z=b['layer'];if(z==='match')throw new Error('layer\x20\x27match\x27\x20is\x20consumed\x20internally\x20by\x20the\x20recommend\x20matching\x20flow\x20—\x20not\x20exposed\x20via\x20get');if(!p['includes'](z))throw new Error('pack\x20\x27'+n+'\x27\x20does\x20not\x20register\x20layer\x20\x27'+z+'\x27'+(o?'\x20(kind='+packKind(p)+',\x20layers=['+p['join'](',\x20')+'])':'\x20(the\x20pack\x20is\x20not\x20registered)')+(z!=='mode'?';\x20layer=\x27template\x27\x20reads\x20the\x20builtin\x20catalog\x20instead\x20if\x20that\x20is\x20what\x20you\x20need':''));const A=z==='mode'?u():z==='dispute'?resolveDisputeRules(n):z==='compliance'?resolveComplianceRules(n):z==='supply'?resolveSupplyRules(n):z==='rules'?resolveIndustryRules(n):resolveIndustryPlaybook(n);if(A===undefined)throw new Error('layer\x20\x27'+z+'\x27\x20is\x20registered\x20for\x20pack\x20\x27'+n+'\x27\x20but\x20resolved\x20to\x20no\x20data');c={'action':'get','category':n,'layer':z,[z]:A,...q()};break;}const v=u(),w=['dispute','compliance','supply','rules','playbook']['filter'](B=>!p['includes'](B));c={'action':'get','category':n,...q(),...v?{'mode':v}:{},...resolveDisputeRules(n)?{'dispute':resolveDisputeRules(n)}:{},...resolveComplianceRules(n)?{'compliance':resolveComplianceRules(n)}:{},...resolveSupplyRules(n)?{'supply':resolveSupplyRules(n)}:{},...resolveIndustryRules(n)?{'rules':resolveIndustryRules(n)}:{},...resolveIndustryPlaybook(n)?{'playbook':resolveIndustryPlaybook(n)}:{},...w['length']?{'missing_layers':w,'note':'pack\x20\x27'+n+'\x27\x20('+(o?packKind(p):'unregistered')+')\x20does\x20not\x20register\x20'+('['+w['join'](',\x20')+']\x20—\x20stub\x20packs\x20(builtin-mode\x20aliases)\x20carry\x20only\x20mode/match\x20')+'data;\x20scaffold\x20a\x20pack\x20or\x20place\x20a\x20pack.json\x20to\x20add\x20business\x20layers.'}:{}};break;}case'diff':{if(!b['name'])throw new Error('\x27name\x27\x20is\x20required\x20for\x20action=\x27diff\x27');c={'action':'diff',...diffIndustryPack(b['name'])};break;}case'reset':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27reset\x27');assertTemplateWriteAuthorized('reset',[b['path']],b['authorize']);const B=resetIndustryPath(b['path']);c={'action':'reset','ok':B['ok'],'layout':B['layout'],'target':B['target'],'restored_files':B['restored_files'],'errors':B['errors']},rescanAffectedPack(b['path']);break;}case'delete_file':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27delete_file\x27');assertTemplateWriteAuthorized('delete_file',[b['path']],b['authorize']);const C=resolveIndustryPath(b['path']);if(!existsSync(C))throw new Error('file\x20not\x20found:\x20'+b['path']);rmSync(C,{'recursive':!![],'force':!![]}),c={'action':'delete_file','path':C,'ok':!![]},rescanAffectedPack(b['path']);break;}case'create_file':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27create_file\x27');const D=resolveIndustryPath(b['path']);if(existsSync(D))throw new Error('file\x20already\x20exists:\x20'+b['path']);if(b['content']!==undefined)assertBaselinesContentValid(b['path'],b['content']);mkdirSync(dirname(D),{'recursive':!![]}),writeFileSync(D,b['content']??'','utf-8'),c={'action':'create_file','path':D,'ok':!![]},rescanAffectedPack(b['path']);break;}case'create_dir':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27create_dir\x27');const E=resolveIndustryPath(b['path']);mkdirSync(E,{'recursive':!![]}),c={'action':'create_dir','path':E,'ok':!![]},rescanAffectedPack(b['path']);break;}case'copy':{if(!b['from'])throw new Error('\x27from\x27\x20is\x20required\x20for\x20action=\x27copy\x27');if(!b['to'])throw new Error('\x27to\x27\x20is\x20required\x20for\x20action=\x27copy\x27');const F=resolveIndustryPath(b['from']);let G=resolveIndustryPath(b['to']);if(!existsSync(F))throw new Error('source\x20not\x20found:\x20'+b['from']);try{existsSync(G)&&statSync(G)['isDirectory']()&&(G=join(G,basename(F)));}catch{}if(G===F)throw new Error('\x27copy\x27\x20cannot\x20copy\x20a\x20file\x20onto\x20itself');existsSync(G)&&isTemplateTreePath(b['to'])&&assertTemplateWriteAuthorized('copy',[b['to']],b['authorize']);mkdirSync(dirname(G),{'recursive':!![]}),cpSync(F,G,{'recursive':!![],'force':!![]}),c={'action':'copy','from':F,'to':G,'ok':!![]},rescanAffectedPack(b['to']);break;}case'move':case'rename':{if(!b['from'])throw new Error('\x27from\x27\x20is\x20required\x20for\x20action=\x27'+b['action']+'\x27');if(!b['to'])throw new Error('\x27to\x27\x20is\x20required\x20for\x20action=\x27'+b['action']+'\x27');assertTemplateWriteAuthorized(b['action'],[b['from'],b['to']],b['authorize']);const H=resolveIndustryPath(b['from']);let I=resolveIndustryPath(b['to']);if(!existsSync(H))throw new Error('source\x20not\x20found:\x20'+b['from']);try{existsSync(I)&&statSync(I)['isDirectory']()&&(I=join(I,basename(H)));}catch{}if(I===H)throw new Error('\x27'+b['action']+'\x27\x20cannot\x20move\x20onto\x20itself');mkdirSync(dirname(I),{'recursive':!![]}),renameSync(H,I),c={'action':b['action'],'from':H,'to':I,'ok':!![]},rescanAffectedPack(b['from']),rescanAffectedPack(b['to']);break;}case'recommend_industry':c=await handleRecommendIndustry(b);break;case'list_modes':c=await handleListModes();break;case'derive_user_mode':c=await handleDeriveUserMode(b);break;case'evolve_user_mode':c=await handleEvolveUserMode(b);break;case'register_user_mode':c=await handleRegisterUserMode(b);break;case'unregister_user_mode':c=await handleUnregisterUserMode(b);break;case'register_custom_metric':c=await handleRegisterCustomMetric(b);break;case'unregister_custom_metric':c=await handleUnregisterCustomMetric(b);break;case'register_custom_constraint':c=await handleRegisterCustomConstraint(b);break;case'unregister_custom_constraint':c=await handleUnregisterCustomConstraint(b);break;case'list_metrics_constraints':c=await handleListMetricsConstraints(b);break;default:throw new Error('Unknown\x20industry_pack_operation\x20action:\x20'+String(b['action']));}return{'content':[{'type':'text','text':JSON['stringify']({'result':c})}],'structuredContent':{'result':c}};}
1
+ import{readdirSync,readFileSync,writeFileSync,existsSync,mkdirSync,statSync,cpSync,renameSync,rmSync}from'node:fs';import{join,relative,resolve,sep,dirname,basename}from'node:path';import{strictParse}from'../../schema/index.js';import{IndustryPackOperationInputSchema}from'../../schema/industry-pack/index.js';import{validateJudgmentFragment}from'../../config/judgment.js';import{scaffoldIndustryPack,listRegisteredPacks,getRegisteredPack,packKind,scanDefaultIndustryPacks,seedBuiltinIndustryTemplates,seedBuiltinStrategyManuals,ensureIndustryReadme,resolveIndustryPackDir,rescanPack,resolveDisputeRules,resolveComplianceRules,resolveSupplyRules,resolveIndustryRules,resolveIndustryPlaybook,diffIndustryPack,resetIndustryPath}from'../../extensions/index.js';import{getIndustryModeRegistry}from'../../extensions/registry.js';import{getBuiltinTemplate,listBuiltinTemplates}from'../../knowledge/builtin-templates.js';import{handleRecommendIndustry,handleListModes,handleDeriveUserMode,handleEvolveUserMode,handleRegisterUserMode,handleUnregisterUserMode,handleRegisterCustomMetric,handleUnregisterCustomMetric,handleRegisterCustomConstraint,handleUnregisterCustomConstraint,handleListMetricsConstraints}from'../../playbooks/service-build/mode-actions.js';import{repairBuiltinTemplates,builtinTemplateDrift,resolveTemplatesDir,parseTemplateFile,TemplateFrontmatterSchema,canonicalTemplateContent,renderTemplateFile,matchBuiltinTemplateFile,TEMPLATE_SENTINEL_KIND}from'../../knowledge/template-loader.js';import{stripReleaseSentinel}from'../../knowledge/release-sentinel.js';import{BUILTIN_TEMPLATES_VERSION}from'../../knowledge/builtin-templates.js';const INDUSTRY_ROOT=resolveIndustryPackDir(),resolveTemplatesDirSafe=resolveTemplatesDir;function resolveIndustryPath(a){const b=resolve(INDUSTRY_ROOT,a);if(b!==INDUSTRY_ROOT&&!b['startsWith'](INDUSTRY_ROOT+sep))throw new Error('path\x20\x27'+a+'\x27\x20escapes\x20the\x20industry\x20root');return b;}function isTemplateTreePath(a){const b=a['split'](/[\\/]+/)['filter'](c=>c['length']>0x0);return b['length']>=0x2&&b[0x1]==='templates';}function assertTemplateWriteAuthorized(a,b,c){if(c===!![])return;const d=b['find'](e=>e!==undefined&&isTemplateTreePath(e));if(!d)return;throw new Error('action=\x27'+a+'\x27\x20modifies\x20the\x20user-editable\x20template\x20file\x20\x27'+d+'\x27.\x20'+'Present\x20the\x20intended\x20change\x20to\x20the\x20user\x20first;\x20after\x20the\x20user\x20explicitly\x20confirms,\x20'+'re-call\x20with\x20authorize=true\x20(C5).');}function rescanAffectedPack(a){const b=a['split'](/[\\/]+/)['find'](c=>c['length']>0x0);if(!b)return;rescanPack(b);}const BASELINES_FILENAME='baselines.json',PACK_FILENAME='pack.json';function assertBaselinesContentValid(a,b){const c=a['split'](/[\\/]+/)['pop']()??'';if(c!==BASELINES_FILENAME&&c!==PACK_FILENAME)return;let d;try{d=JSON['parse'](b);}catch{return;}if(!d||typeof d!=='object'||Array['isArray'](d))return;const e=d,f=c===BASELINES_FILENAME?d:e['baselines'];if(f===undefined||f===null)return;const g=validateJudgmentFragment(f,a+'\x20baselines');if(g)throw new Error('write\x20rejected\x20—\x20the\x20baselines\x20fragment\x20in\x20\x27'+a+'\x27\x20is\x20not\x20a\x20valid\x20judgment\x20fragment:\x20'+g);}function assertTemplateContentValid(a,b){if(!isTemplateTreePath(a)||!a['endsWith']('.md'))return;let c;try{({frontmatter:c}=parseTemplateFile(b));}catch(e){throw new Error('write\x20rejected\x20—\x20\x27'+a+'\x27\x20is\x20a\x20template\x20file\x20but\x20the\x20frontmatter\x20block\x20is\x20malformed:\x20'+e['message']);}const d=TemplateFrontmatterSchema['safeParse'](c);if(!d['success']){const f=d['error']['issues']['map'](g=>'\x20\x20'+g['path']['join']('.')+':\x20'+g['message'])['join']('\x0a');throw new Error('write\x20rejected\x20—\x20the\x20template\x20frontmatter\x20in\x20\x27'+a+'\x27\x20violates\x20the\x20schema\x20(the\x20editor\x20whitelist\x20IS\x20the\x20zod\x20schema):\x0a'+f);}}function listRecursive(a,b,c,d=0x0){if(d>0x8)return;let f;try{f=readdirSync(a,{'withFileTypes':!![]});}catch{return;}for(const g of f){const h=join(a,g['name']),i=relative(b,h)['split'](sep)['join']('/');let j=0x0,k=0x0;try{const l=statSync(h);k=l['size'],j=l['mtimeMs'];}catch{}g['isDirectory']()?(c['push']({'path':i,'is_dir':!![],'size':0x0,'mtime':j}),listRecursive(h,b,c,d+0x1)):c['push']({'path':i,'is_dir':![],'size':k,'mtime':j});}}export async function handleIndustryPackOperation(a){const b=strictParse(IndustryPackOperationInputSchema,a,'industry_pack_operation\x20input');mkdirSync(INDUSTRY_ROOT,{'recursive':!![]}),seedBuiltinIndustryTemplates(),seedBuiltinStrategyManuals(),ensureIndustryReadme();let c;switch(b['action']){case'scaffold':{if(!b['name'])throw new Error('\x27name\x27\x20is\x20required\x20for\x20action=\x27scaffold\x27');const d=scaffoldIndustryPack(b['name']);c={'action':'scaffold','ok':d['ok'],'dir':d['dir'],'files':d['files'],'errors':d['errors']};if(d['ok'])rescanPack(b['name']);break;}case'list':{c={'action':'list','packs':listRegisteredPacks()};break;}case'scan':{c={'action':'scan','results':scanDefaultIndustryPacks()};break;}case'repair_builtin_templates':{const e=b['include_user_edited'];if(b['authorize']!==!![]){const h=repairBuiltinTemplates({'backup':!![],'dryRun':!![],'includeUserEdited':e}),i=h['filter'](j=>j['status']==='would_update');c={'action':'repair_builtin_templates','dir':resolveTemplatesDirSafe(),'reseeded_count':0x0,'requires_authorization':!![],'results':h,'note':i['length']?'PLAN\x20ONLY\x20(no\x20writes)\x20—\x20'+i['length']+'\x20builtin\x20file(s)\x20differ\x20from\x20the\x20in-code\x20catalog\x20and\x20would\x20be\x20reseeded\x20(each\x20result\x20carries\x20a\x20field-level\x20diff;\x20previous\x20bodies\x20preserved\x20as\x20<file>.bak).\x20Present\x20this\x20plan\x20to\x20the\x20user;\x20after\x20the\x20user\x20explicitly\x20confirms,\x20re-call\x20with\x20authorize=true\x20to\x20execute'+(e?.['length']?'\x20(keep\x20include_user_edited\x20on\x20the\x20execute\x20call)':'')+'.':'Nothing\x20to\x20repair\x20—\x20every\x20on-disk\x20builtin\x20template\x20either\x20matches\x20the\x20in-code\x20catalog\x20or\x20carries\x20user\x20edits\x20(which\x20are\x20never\x20overwritten\x20without\x20an\x20explicit\x20include_user_edited\x20authorization).'};break;}const f=repairBuiltinTemplates({'backup':!![],'includeUserEdited':e}),g=f['filter'](j=>j['status']==='updated');c={'action':'repair_builtin_templates','dir':resolveTemplatesDirSafe(),'reseeded_count':g['length'],'results':f,'note':g['length']?'Diverging\x20builtin\x20files\x20were\x20reseeded\x20from\x20the\x20in-code\x20catalog.\x20Each\x20previous\x20body\x20is\x20preserved\x20as\x20<file>.bak.':'Nothing\x20repaired\x20—\x20every\x20on-disk\x20builtin\x20template\x20either\x20matches\x20the\x20in-code\x20catalog\x20or\x20carries\x20user\x20edits\x20(which\x20are\x20never\x20overwritten\x20without\x20an\x20explicit\x20include_user_edited\x20authorization).'};break;}case'template_drift':{const j=builtinTemplateDrift({'includeUserEdited':b['include_user_edited']}),k=j['filter'](l=>l['repairable'])['length'];c={'action':'template_drift','dir':resolveTemplatesDirSafe(),'drift_count':j['length'],'repairable_count':k,'drift':j,'note':j['length']?k>0x0?k+'\x20of\x20'+j['length']+'\x20diverging\x20builtin\x20template(s)\x20can\x20be\x20reseeded\x20without\x20losing\x20user\x20work\x20(including\x20ids\x20listed\x20in\x20include_user_edited)\x20—\x20run\x20action=\x27repair_builtin_templates\x27\x20(plan-only\x20preview\x20first,\x20then\x20authorize=true\x20after\x20the\x20user\x20confirms,\x20keeping\x20include_user_edited\x20on\x20both\x20calls).\x20The\x20rest\x20carry\x20user\x20edits\x20and\x20are\x20never\x20overwritten.':'All\x20diverging\x20builtin\x20templates\x20carry\x20user\x20edits\x20—\x20never\x20overwritten\x20automatically;\x20pass\x20include_user_edited\x20with\x20the\x20explicitly\x20authorized\x20ids\x20to\x20make\x20them\x20reseedable,\x20or\x20resolve\x20by\x20hand.':'Every\x20builtin\x20template\x20on\x20disk\x20matches\x20the\x20in-code\x20catalog.'};break;}case'resolve':{c={'action':'resolve','dir':INDUSTRY_ROOT};break;}case'list_files':{const l=[];listRecursive(INDUSTRY_ROOT,INDUSTRY_ROOT,l),c={'action':'list_files','dir':INDUSTRY_ROOT,'files':l};break;}case'read_file':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27read_file\x27');const m=resolveIndustryPath(b['path']);if(!existsSync(m))throw new Error('file\x20not\x20found:\x20'+b['path']);c={'action':'read_file','path':m,'content':readFileSync(m,'utf-8')};break;}case'write_file':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27write_file\x27');if(b['content']===undefined)throw new Error('\x27content\x27\x20is\x20required\x20for\x20action=\x27write_file\x27');assertTemplateWriteAuthorized('write_file',[b['path']],b['authorize']);const n=resolveIndustryPath(b['path']);assertBaselinesContentValid(b['path'],b['content']),assertTemplateContentValid(b['path'],b['content']);let o=b['content'],p=![];const q=matchBuiltinTemplateFile(n);if(q){const u=stripReleaseSentinel(o,TEMPLATE_SENTINEL_KIND)['content'];u===canonicalTemplateContent(q)&&(o=renderTemplateFile(q),p=!![]);}mkdirSync(dirname(n),{'recursive':!![]}),writeFileSync(n,o,'utf-8'),c={'action':'write_file','path':n,'ok':!![],...p?{'restamped':!![],'note':'content\x20equals\x20the\x20canonical\x20body\x20of\x20builtin\x20template\x20\x27'+q['id']+'\x27\x20—\x20written\x20with\x20the\x20current\x20release\x20stamp\x20(v'+BUILTIN_TEMPLATES_VERSION+')\x20so\x20the\x20sentinel\x20hash\x20binds\x20again'}:{}},rescanAffectedPack(b['path']);break;}case'get':{if(!b['name'])throw new Error('\x27name\x27\x20is\x20required\x20for\x20action=\x27get\x27');const v=b['name'],w=getRegisteredPack(v),x=w?.['layers']??[],y=()=>w?{'kind':packKind(x),'layers':x}:{},z=()=>{const C=getIndustryModeRegistry()['getMode'](v);return C?{'name':C['name'],'display_name':C['display_name'],'key_risk':C['key_risk'],'needs':C['needs']['map'](D=>D['description']),...C['analyze']?.['key_questions']?.['length']?{'analyze_questions':C['analyze']['key_questions']['slice'](0x0,0x2)}:{}}:undefined;};if(b['layer']==='template'){if(b['template']){const C=getBuiltinTemplate(b['template']);if(!C)throw new Error('template\x20\x27'+b['template']+'\x27\x20is\x20not\x20in\x20the\x20builtin\x20catalog\x20'+('(available:\x20'+listBuiltinTemplates()['map'](D=>D['id'])['join'](',\x20')+')'));if(C['industry']!==v)throw new Error('template\x20\x27'+C['id']+'\x27\x20belongs\x20to\x20industry\x20\x27'+C['industry']+'\x27,\x20not\x20\x27'+v+'\x27\x20—\x20'+'set\x20\x27name\x27\x20to\x20the\x20template\x27s\x20industry');c={'action':'get','category':v,'layer':'template','template':JSON['parse'](JSON['stringify'](C))};}else{const D=listBuiltinTemplates()['filter'](E=>E['industry']===v)['map'](E=>({'id':E['id'],'variant':E['variant'],'product_ref':E['product_ref'],'key_risk':E['key_risk']}));if(!D['length'])throw new Error('industry\x20\x27'+v+'\x27\x20has\x20no\x20builtin\x20templates\x20(ids\x20use\x20\x27<industry>/<variant>\x27)');c={'action':'get','category':v,'layer':'template','templates':D,'note':'Re-call\x20with\x20layer=\x27template\x27\x20+\x20template=\x27<id>\x27\x20for\x20the\x20full\x20projection\x20'+'(machine_shape/guards/allocator\x20rows/fee_params/build_notes).'};}break;}if(b['layer']){const E=b['layer'];if(E==='match')throw new Error('layer\x20\x27match\x27\x20is\x20consumed\x20internally\x20by\x20the\x20recommend\x20matching\x20flow\x20—\x20not\x20exposed\x20via\x20get');if(!x['includes'](E))throw new Error('pack\x20\x27'+v+'\x27\x20does\x20not\x20register\x20layer\x20\x27'+E+'\x27'+(w?'\x20(kind='+packKind(x)+',\x20layers=['+x['join'](',\x20')+'])':'\x20(the\x20pack\x20is\x20not\x20registered)')+(E!=='mode'?';\x20layer=\x27template\x27\x20reads\x20the\x20builtin\x20catalog\x20instead\x20if\x20that\x20is\x20what\x20you\x20need':''));const F=E==='mode'?z():E==='dispute'?resolveDisputeRules(v):E==='compliance'?resolveComplianceRules(v):E==='supply'?resolveSupplyRules(v):E==='rules'?resolveIndustryRules(v):resolveIndustryPlaybook(v);if(F===undefined)throw new Error('layer\x20\x27'+E+'\x27\x20is\x20registered\x20for\x20pack\x20\x27'+v+'\x27\x20but\x20resolved\x20to\x20no\x20data');c={'action':'get','category':v,'layer':E,[E]:F,...y()};break;}const A=z(),B=['dispute','compliance','supply','rules','playbook']['filter'](G=>!x['includes'](G));c={'action':'get','category':v,...y(),...A?{'mode':A}:{},...resolveDisputeRules(v)?{'dispute':resolveDisputeRules(v)}:{},...resolveComplianceRules(v)?{'compliance':resolveComplianceRules(v)}:{},...resolveSupplyRules(v)?{'supply':resolveSupplyRules(v)}:{},...resolveIndustryRules(v)?{'rules':resolveIndustryRules(v)}:{},...resolveIndustryPlaybook(v)?{'playbook':resolveIndustryPlaybook(v)}:{},...B['length']?{'missing_layers':B,'note':'pack\x20\x27'+v+'\x27\x20('+(w?packKind(x):'unregistered')+')\x20does\x20not\x20register\x20'+('['+B['join'](',\x20')+']\x20—\x20stub\x20packs\x20(builtin-mode\x20aliases)\x20carry\x20only\x20mode/match\x20')+'data;\x20scaffold\x20a\x20pack\x20or\x20place\x20a\x20pack.json\x20to\x20add\x20business\x20layers.'}:{}};break;}case'diff':{if(!b['name'])throw new Error('\x27name\x27\x20is\x20required\x20for\x20action=\x27diff\x27');c={'action':'diff',...diffIndustryPack(b['name'])};break;}case'reset':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27reset\x27');assertTemplateWriteAuthorized('reset',[b['path']],b['authorize']);const G=resetIndustryPath(b['path']);c={'action':'reset','ok':G['ok'],'layout':G['layout'],'target':G['target'],'restored_files':G['restored_files'],'errors':G['errors']},rescanAffectedPack(b['path']);break;}case'delete_file':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27delete_file\x27');assertTemplateWriteAuthorized('delete_file',[b['path']],b['authorize']);const H=resolveIndustryPath(b['path']);if(!existsSync(H))throw new Error('file\x20not\x20found:\x20'+b['path']);rmSync(H,{'recursive':!![],'force':!![]}),c={'action':'delete_file','path':H,'ok':!![]},rescanAffectedPack(b['path']);break;}case'create_file':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27create_file\x27');const I=resolveIndustryPath(b['path']);if(existsSync(I))throw new Error('file\x20already\x20exists:\x20'+b['path']);if(b['content']!==undefined)assertBaselinesContentValid(b['path'],b['content']);mkdirSync(dirname(I),{'recursive':!![]}),writeFileSync(I,b['content']??'','utf-8'),c={'action':'create_file','path':I,'ok':!![]},rescanAffectedPack(b['path']);break;}case'create_dir':{if(!b['path'])throw new Error('\x27path\x27\x20is\x20required\x20for\x20action=\x27create_dir\x27');const J=resolveIndustryPath(b['path']);mkdirSync(J,{'recursive':!![]}),c={'action':'create_dir','path':J,'ok':!![]},rescanAffectedPack(b['path']);break;}case'copy':{if(!b['from'])throw new Error('\x27from\x27\x20is\x20required\x20for\x20action=\x27copy\x27');if(!b['to'])throw new Error('\x27to\x27\x20is\x20required\x20for\x20action=\x27copy\x27');const K=resolveIndustryPath(b['from']);let L=resolveIndustryPath(b['to']);if(!existsSync(K))throw new Error('source\x20not\x20found:\x20'+b['from']);try{existsSync(L)&&statSync(L)['isDirectory']()&&(L=join(L,basename(K)));}catch{}if(L===K)throw new Error('\x27copy\x27\x20cannot\x20copy\x20a\x20file\x20onto\x20itself');existsSync(L)&&isTemplateTreePath(b['to'])&&assertTemplateWriteAuthorized('copy',[b['to']],b['authorize']);mkdirSync(dirname(L),{'recursive':!![]}),cpSync(K,L,{'recursive':!![],'force':!![]}),c={'action':'copy','from':K,'to':L,'ok':!![]},rescanAffectedPack(b['to']);break;}case'move':case'rename':{if(!b['from'])throw new Error('\x27from\x27\x20is\x20required\x20for\x20action=\x27'+b['action']+'\x27');if(!b['to'])throw new Error('\x27to\x27\x20is\x20required\x20for\x20action=\x27'+b['action']+'\x27');assertTemplateWriteAuthorized(b['action'],[b['from'],b['to']],b['authorize']);const M=resolveIndustryPath(b['from']);let N=resolveIndustryPath(b['to']);if(!existsSync(M))throw new Error('source\x20not\x20found:\x20'+b['from']);try{existsSync(N)&&statSync(N)['isDirectory']()&&(N=join(N,basename(M)));}catch{}if(N===M)throw new Error('\x27'+b['action']+'\x27\x20cannot\x20move\x20onto\x20itself');mkdirSync(dirname(N),{'recursive':!![]}),renameSync(M,N),c={'action':b['action'],'from':M,'to':N,'ok':!![]},rescanAffectedPack(b['from']),rescanAffectedPack(b['to']);break;}case'recommend_industry':c=await handleRecommendIndustry(b);break;case'list_modes':c=await handleListModes();break;case'derive_user_mode':c=await handleDeriveUserMode(b);break;case'evolve_user_mode':c=await handleEvolveUserMode(b);break;case'register_user_mode':c=await handleRegisterUserMode(b);break;case'unregister_user_mode':c=await handleUnregisterUserMode(b);break;case'register_custom_metric':c=await handleRegisterCustomMetric(b);break;case'unregister_custom_metric':c=await handleUnregisterCustomMetric(b);break;case'register_custom_constraint':c=await handleRegisterCustomConstraint(b);break;case'unregister_custom_constraint':c=await handleUnregisterCustomConstraint(b);break;case'list_metrics_constraints':c=await handleListMetricsConstraints(b);break;default:throw new Error('Unknown\x20industry_pack_operation\x20action:\x20'+String(b['action']));}return{'content':[{'type':'text','text':JSON['stringify']({'result':c})}],'structuredContent':{'result':c}};}
@@ -1 +1 @@
1
- import{strictParse}from'../../schema/index.js';import{IntentRadarInputSchema}from'../../schema/intent-radar/index.js';import{createIntent,listIntents,matchAllIntents,matchIntent,removeIntent}from'../../intent/index.js';import{enrichEventsWithObjectText}from'../../intent/enrich.js';import{query_events}from'@wowok/wowok';const AUTO_PULL_TYPES=['ServiceEvent','ArbitrationEvent','DemandChangedEvent','DemandPresentEvent','NewOrderEvent','ProgressEvent','ArbEvent','VoteEvent','DemandFeedbackEvent','NewEntityEvent','NewPaymentEvent','AllocationEvent','TreasuryEvent','RewardClaimEvent','RewardFundEvent'];async function pullRecentEvents(a,b){const c=[];for(const d of AUTO_PULL_TYPES){try{const e=await query_events({'type':d,'cursor':null,'limit':b,'order':'descending','no_cache':![],'network':a}),f=e?.['data'];if(Array['isArray'](f))c['push'](...f);}catch{}}return c;}export async function handleIntentRadar(a){const b=strictParse(IntentRadarInputSchema,a,'intent_radar\x20input');let c;switch(b['action']){case'save':{const d=await createIntent({'intent':b['intent'],'account':b['account'],'role':b['role'],'target_types':b['target_types']});c={'action':'save','intent':d};break;}case'list':{c={'action':'list','intents':await listIntents(b['account'])};break;}case'remove':{c={'action':'remove','removed':await removeIntent(b['id'])};break;}case'match':{let e=b['events']??[];e['length']===0x0&&(e=await pullRecentEvents(b['network'],b['limit']??0x5));e=await enrichEventsWithObjectText(e,b['network']);const f=b['intent_id']?[await matchIntent(b['intent_id'],e)]['filter'](g=>g!==null):await matchAllIntents(e,b['account']);c={'action':'match','results':f};break;}default:throw new Error('Unknown\x20intent_radar\x20action');}return{'content':[{'type':'text','text':JSON['stringify']({'result':c})}],'structuredContent':{'result':c}};}
1
+ import{strictParse}from'../../schema/index.js';import{IntentRadarInputSchema}from'../../schema/intent-radar/index.js';import{createIntent,listIntents,matchAllIntents,matchIntent,removeIntent}from'../../intent/index.js';import{enrichEventsWithObjectText}from'../../intent/enrich.js';import{query_events}from'@wowok/wowok';const AUTO_PULL_TYPES=['ServiceEvent','ArbitrationEvent','DemandChangedEvent','DemandPresentEvent','NewOrderEvent','ProgressEvent','ArbEvent','VoteEvent','DemandFeedbackEvent','NewEntityEvent','NewPaymentEvent','AllocationEvent','TreasuryEvent','RewardClaimEvent','RewardFundEvent','RewardWithdrawEvent','PermissionChangedEvent','RepositoryDataOverwriteEvent'];async function pullRecentEvents(a,b){const c=[];for(const d of AUTO_PULL_TYPES){try{const e=await query_events({'type':d,'cursor':null,'limit':b,'order':'descending','no_cache':![],'network':a}),f=e?.['data'];if(Array['isArray'](f))c['push'](...f);}catch{}}return c;}export async function handleIntentRadar(a){const b=strictParse(IntentRadarInputSchema,a,'intent_radar\x20input');let c;switch(b['action']){case'save':{const d=await createIntent({'intent':b['intent'],'account':b['account'],'role':b['role'],'target_types':b['target_types']});c={'action':'save','intent':d};break;}case'list':{c={'action':'list','intents':await listIntents(b['account'])};break;}case'remove':{c={'action':'remove','removed':await removeIntent(b['id'])};break;}case'match':{let e=b['events']??[];e['length']===0x0&&(e=await pullRecentEvents(b['network'],b['limit']??0x5));e=await enrichEventsWithObjectText(e,b['network']);const f=b['intent_id']?[await matchIntent(b['intent_id'],e)]['filter'](g=>g!==null):await matchAllIntents(e,b['account']);c={'action':'match','results':f};break;}default:throw new Error('Unknown\x20intent_radar\x20action');}return{'content':[{'type':'text','text':JSON['stringify']({'result':c})}],'structuredContent':{'result':c}};}
@@ -4,7 +4,7 @@ import { type KeeperScanDeps } from "../../keeper/KeeperScan.js";
4
4
  import type { ScopeSnapshot } from "../../monitor/types.js";
5
5
  export interface KeeperOperationDeps {
6
6
  store: KeeperStore;
7
- scan: Pick<KeeperScanDeps, "payment" | "progress" | "settlement" | "execute" | "now" | "logger">;
7
+ scan: Pick<KeeperScanDeps, "payment" | "progress" | "settlement" | "timeout" | "execute" | "now" | "logger">;
8
8
  loadScope(network: string): Promise<ScopeSnapshot | undefined>;
9
9
  resolveScope(network: string): Promise<ScopeSnapshot>;
10
10
  }
@@ -1,3 +1,15 @@
1
1
  import type { ToolDispatchResult } from "../types.js";
2
+ export declare function assertRewardReplayStamp(entries: unknown, network?: string, warnings?: string[]): Promise<void>;
3
+ export declare function warnMerchantCompensationFundLow(data: any, network: string | undefined, constraintWarnings: string[]): Promise<{
4
+ content: Array<{
5
+ type: "text";
6
+ text: string;
7
+ }>;
8
+ structuredContent: Record<string, unknown>;
9
+ } | undefined>;
10
+ export declare function deriveTotalPayIfOmitted(data: any, network: unknown): Promise<string | undefined>;
11
+ export declare function gateOrderNewFundCoverage(data: any, network: unknown): Promise<ToolDispatchResult | null>;
12
+ export declare function gateOrderNewAmountLegCoverage(data: any, network: unknown): Promise<ToolDispatchResult | null>;
13
+ export declare function gateServicePublishPreflight(data: any): ToolDispatchResult | null;
2
14
  export declare function invalidateResolvedNameCache(): void;
3
15
  export declare function handleOnchainOperations(args: unknown): Promise<ToolDispatchResult>;