@wowok/agent-mcp 3.4.4 → 3.4.5

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 (191) hide show
  1. package/dist/.build-stamp.json +3 -3
  2. package/dist/chain-semantics/composition-truth.js +1 -1
  3. package/dist/composition/audit.js +1 -1
  4. package/dist/composition/compile.js +1 -1
  5. package/dist/composition/emit-phases.js +1 -1
  6. package/dist/composition/guard-fill.js +1 -1
  7. package/dist/composition/input-normalize.js +1 -1
  8. package/dist/composition/materialize.js +1 -1
  9. package/dist/composition/mode-gates.js +1 -1
  10. package/dist/composition/param-disclosure.js +1 -1
  11. package/dist/composition/plan-run-store.js +1 -0
  12. package/dist/composition/reflux.js +1 -1
  13. package/dist/composition/role-bindings.js +1 -0
  14. package/dist/composition/shape-expand.js +1 -1
  15. package/dist/composition/supply-chain-emit.js +1 -1
  16. package/dist/config/judgment.d.ts +13 -25
  17. package/dist/config/judgment.js +1 -1
  18. package/dist/config/match-policy-file.js +1 -1
  19. package/dist/config/rule-engine.d.ts +4 -10
  20. package/dist/config/rule-engine.js +1 -1
  21. package/dist/config/template-params.js +1 -1
  22. package/dist/evaluation/engine.js +1 -1
  23. package/dist/experience/realtime-feedback.js +1 -1
  24. package/dist/extensions/capability.js +1 -1
  25. package/dist/graph/onchain/expand.js +1 -1
  26. package/dist/graph/onchain/exposure.js +1 -1
  27. package/dist/harness/forward-roster-preflight.js +1 -0
  28. package/dist/keeper/detectors.js +1 -1
  29. package/dist/knowledge/allocator-rail-verifier.js +1 -1
  30. package/dist/knowledge/arb-operation-face.js +1 -1
  31. package/dist/knowledge/arbitration-rail-verifier.js +1 -1
  32. package/dist/knowledge/audit-rules.d.ts +17 -1
  33. package/dist/knowledge/audit-rules.js +1 -1
  34. package/dist/knowledge/baselines/rules/alloc_audit.json.good.sha256 +1 -0
  35. package/dist/knowledge/baselines/rules/allocation.json.good.sha256 +1 -0
  36. package/dist/knowledge/baselines/rules/arb.json.good.sha256 +1 -0
  37. package/dist/knowledge/baselines/rules/arbitration.json.good.sha256 +1 -0
  38. package/dist/knowledge/baselines/rules/bridge.json.good.sha256 +1 -0
  39. package/dist/knowledge/baselines/rules/contact.json.good.sha256 +1 -0
  40. package/dist/knowledge/baselines/rules/demand.json.good.sha256 +1 -0
  41. package/dist/knowledge/baselines/rules/graph.json.good.sha256 +1 -0
  42. package/dist/knowledge/baselines/rules/guard.json.good.sha256 +1 -0
  43. package/dist/knowledge/baselines/rules/machine.json.good.sha256 +1 -0
  44. package/dist/knowledge/baselines/rules/oracle.json.good.sha256 +1 -0
  45. package/dist/knowledge/baselines/rules/order.json.good.sha256 +1 -0
  46. package/dist/knowledge/baselines/rules/payment.json.good.sha256 +1 -0
  47. package/dist/knowledge/baselines/rules/permission.json.good.sha256 +1 -0
  48. package/dist/knowledge/baselines/rules/personal.json.good.sha256 +1 -0
  49. package/dist/knowledge/baselines/rules/plan.json +153 -33
  50. package/dist/knowledge/baselines/rules/plan.json.good +153 -33
  51. package/dist/knowledge/baselines/rules/plan.json.good.sha256 +1 -0
  52. package/dist/knowledge/baselines/rules/progress.json.good.sha256 +1 -0
  53. package/dist/knowledge/baselines/rules/proof.json.good.sha256 +1 -0
  54. package/dist/knowledge/baselines/rules/registrar.json.good.sha256 +1 -0
  55. package/dist/knowledge/baselines/rules/repository.json.good.sha256 +1 -0
  56. package/dist/knowledge/baselines/rules/resource.json.good.sha256 +1 -0
  57. package/dist/knowledge/baselines/rules/reward.json.good.sha256 +1 -0
  58. package/dist/knowledge/baselines/rules/service.json.good.sha256 +1 -0
  59. package/dist/knowledge/baselines/rules/treasury.json.good.sha256 +1 -0
  60. package/dist/knowledge/baselines/rules/util.json.good.sha256 +1 -0
  61. package/dist/knowledge/builtin-templates.d.ts +1 -1
  62. package/dist/knowledge/builtin-templates.js +1 -1
  63. package/dist/knowledge/discount-threshold.js +1 -1
  64. package/dist/knowledge/fee-param-bindings.js +1 -1
  65. package/dist/knowledge/getting-started.js +1 -1
  66. package/dist/knowledge/guard-binding-table.js +1 -1
  67. package/dist/knowledge/guard-design-patterns.js +1 -1
  68. package/dist/knowledge/guard-templates.d.ts +3 -2
  69. package/dist/knowledge/guard-templates.js +1 -1
  70. package/dist/knowledge/index.js +1 -1
  71. package/dist/knowledge/industry-registry.js +1 -1
  72. package/dist/knowledge/jsonrpc-enum.js +1 -1
  73. package/dist/knowledge/knob-docs.js +1 -1
  74. package/dist/knowledge/machine-topology.js +1 -1
  75. package/dist/knowledge/param-schema.js +1 -1
  76. package/dist/knowledge/param-tiers.js +1 -1
  77. package/dist/knowledge/path-oracle/products/alibaba-1688.js +1 -1
  78. package/dist/knowledge/path-oracle/products/amazon.js +1 -1
  79. package/dist/knowledge/path-oracle/products/booking-com.js +1 -1
  80. package/dist/knowledge/path-oracle/products/contra.js +1 -1
  81. package/dist/knowledge/path-oracle/products/costco.js +1 -1
  82. package/dist/knowledge/path-oracle/products/duoduo-maicai.js +1 -1
  83. package/dist/knowledge/path-oracle/products/etsy.js +1 -1
  84. package/dist/knowledge/path-oracle/products/gamefound.js +1 -1
  85. package/dist/knowledge/path-oracle/products/gofundme.js +1 -1
  86. package/dist/knowledge/path-oracle/products/klook.js +1 -1
  87. package/dist/knowledge/path-oracle/products/ninety-nine-designs.js +1 -1
  88. package/dist/knowledge/path-oracle/products/pinduoduo-kuaituantuan.js +1 -1
  89. package/dist/knowledge/path-oracle/products/shansong.js +1 -1
  90. package/dist/knowledge/path-oracle/products/taobao-presale.js +1 -1
  91. package/dist/knowledge/path-oracle/products/upwork-catalog.js +1 -1
  92. package/dist/knowledge/path-oracle/products/upwork.js +1 -1
  93. package/dist/knowledge/pattern-resolutions.js +1 -1
  94. package/dist/knowledge/protocol-facts.js +1 -1
  95. package/dist/knowledge/publish-gate.js +1 -1
  96. package/dist/knowledge/publish-surface-contract.js +1 -1
  97. package/dist/knowledge/template-loader.js +1 -1
  98. package/dist/knowledge/template-registry.js +1 -1
  99. package/dist/knowledge/template-scanner.js +1 -1
  100. package/dist/knowledge/time-units.js +1 -0
  101. package/dist/knowledge/tools-reference.js +1 -1
  102. package/dist/knowledge/workflow-guidance.js +1 -1
  103. package/dist/monitor/MonitorLoop.js +1 -1
  104. package/dist/participation/radar-core.js +1 -1
  105. package/dist/playbooks/service-build/business-puzzle.js +1 -1
  106. package/dist/playbooks/service-build/machine-panorama.js +1 -1
  107. package/dist/playbooks/service-build/merchant-guide.js +1 -1
  108. package/dist/playbooks/service-build/migration-planner.js +1 -1
  109. package/dist/playbooks/service-build/object-panorama.js +1 -1
  110. package/dist/playbooks/service-build/participation-radar.js +1 -1
  111. package/dist/playbooks/service-build/relationship-profile.js +1 -1
  112. package/dist/playbooks/service-build/service-panorama.js +1 -1
  113. package/dist/playbooks/service-build/service-quote.js +1 -1
  114. package/dist/review/index.js +1 -1
  115. package/dist/safety/confirm-gate.js +1 -1
  116. package/dist/schema/benchmark-migration/index.d.ts +110 -2
  117. package/dist/schema/benchmark-migration/index.js +1 -1
  118. package/dist/schema/boundary-coercion.js +1 -0
  119. package/dist/schema/call/arbitration.js +1 -1
  120. package/dist/schema/call/base.js +1 -1
  121. package/dist/schema/call/handler.js +1 -1
  122. package/dist/schema/call/machine.d.ts +56 -8
  123. package/dist/schema/call/order.d.ts +37 -10
  124. package/dist/schema/call/order.js +1 -1
  125. package/dist/schema/call/permission.d.ts +210 -30
  126. package/dist/schema/call/personal.d.ts +56 -8
  127. package/dist/schema/call/progress.d.ts +28 -4
  128. package/dist/schema/call/semantic.js +1 -1
  129. package/dist/schema/call/service.d.ts +84 -12
  130. package/dist/schema/common/index.d.ts +14 -2
  131. package/dist/schema/common/index.js +1 -1
  132. package/dist/schema/evaluation/index.js +1 -1
  133. package/dist/schema/goal/index.d.ts +1 -1
  134. package/dist/schema/goal/planning.js +1 -1
  135. package/dist/schema/local/index.js +1 -1
  136. package/dist/schema/messenger/index.d.ts +168 -24
  137. package/dist/schema/messenger/index.js +1 -1
  138. package/dist/schema/operations.d.ts +655 -22
  139. package/dist/schema/operations.js +1 -1
  140. package/dist/schema/persona/index.d.ts +22 -110
  141. package/dist/schema/query/index.js +1 -1
  142. package/dist/schema/schema-version.js +1 -1
  143. package/dist/schema/workflow/index.d.ts +4 -0
  144. package/dist/schema/workflow/index.js +1 -1
  145. package/dist/schema-query-impl/index.js +1 -1
  146. package/dist/schemas/benchmark_migration_operation.schema.json +1 -1
  147. package/dist/schemas/evaluation_operation.schema.json +1 -1
  148. package/dist/schemas/goal_operation.schema.json +1 -1
  149. package/dist/schemas/guard_rebind_replacement.schema.json +1 -0
  150. package/dist/schemas/index.json +1 -1
  151. package/dist/schemas/messenger_operation.schema.json +1 -1
  152. package/dist/schemas/onchain_operations.schema.json +1 -1
  153. package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
  154. package/dist/schemas/onchain_operations_arbitration.schema.json +1 -1
  155. package/dist/schemas/onchain_operations_contact.schema.json +1 -1
  156. package/dist/schemas/onchain_operations_demand.schema.json +1 -1
  157. package/dist/schemas/onchain_operations_gen_passport.schema.json +1 -1
  158. package/dist/schemas/onchain_operations_machine.schema.json +1 -1
  159. package/dist/schemas/onchain_operations_order.schema.json +1 -1
  160. package/dist/schemas/onchain_operations_permission.schema.json +1 -1
  161. package/dist/schemas/onchain_operations_personal.schema.json +1 -1
  162. package/dist/schemas/onchain_operations_progress.schema.json +1 -1
  163. package/dist/schemas/onchain_operations_proof.schema.json +1 -1
  164. package/dist/schemas/onchain_operations_repository.schema.json +1 -1
  165. package/dist/schemas/onchain_operations_reward.schema.json +1 -1
  166. package/dist/schemas/onchain_operations_service.schema.json +1 -1
  167. package/dist/schemas/onchain_operations_treasury.schema.json +1 -1
  168. package/dist/schemas/persona_operation.schema.json +1 -1
  169. package/dist/schemas/time_convert.schema.json +1 -0
  170. package/dist/schemas/wip_file.schema.json +1 -1
  171. package/dist/schemas/workflow_operation.schema.json +1 -1
  172. package/dist/tools/handlers/benchmark-migration.js +1 -1
  173. package/dist/tools/handlers/config.js +1 -1
  174. package/dist/tools/handlers/fund-rail-recipe.js +1 -1
  175. package/dist/tools/handlers/guard-rebind-replacement.js +1 -0
  176. package/dist/tools/handlers/local.js +1 -1
  177. package/dist/tools/handlers/mark-namespace.js +1 -1
  178. package/dist/tools/handlers/onchain.js +1 -1
  179. package/dist/tools/handlers/query.js +1 -1
  180. package/dist/tools/handlers/settle-sweep.js +1 -1
  181. package/dist/tools/handlers/time-convert.js +1 -0
  182. package/dist/tools/handlers/wip.js +1 -1
  183. package/dist/tools/handlers/workflow.js +1 -1
  184. package/dist/tools/index.d.ts +1 -0
  185. package/dist/tools/index.js +1 -1
  186. package/dist/tools/registry/business.js +1 -1
  187. package/dist/tools/registry/local.js +1 -1
  188. package/dist/tools/registry/onchain.js +1 -1
  189. package/dist/tools/wip-verify-ledger.js +1 -1
  190. package/dist/tools/wrap.js +1 -1
  191. package/package.json +6 -5
@@ -1 +1 @@
1
- import{z}from'zod';import{SEVERITY_ORDER}from'./severity.js';import{ExposureFragmentSchema,FactRefSchema,applyExposureGate,parseFactRef,resolveExposureFragment}from'./exposure.js';const LEAF_OPS=['present','missing','truthy','falsy','eq','neq','gt','gte','lt','lte','in','nin','contains','matches','size'];export const RuleConditionSchema=z['lazy'](()=>z['union']([z['object']({'all':z['array'](RuleConditionSchema)})['strict'](),z['object']({'any':z['array'](RuleConditionSchema)})['strict'](),z['object']({'not':RuleConditionSchema})['strict'](),z['object']({'field':z['string'](),'op':z['enum'](LEAF_OPS),'value':z['unknown']()['optional'](),'flags':z['string']()['optional']()})['strict']()]));const CaseLevelSchema=z['union']([z['enum'](SEVERITY_ORDER),FactRefSchema]);export const RuleCaseSchema=z['object']({'when':RuleConditionSchema,'level':CaseLevelSchema,'title':z['string'](),'description':z['string'](),'scenario':z['string']()['optional'](),'mitigation':z['string']()['optional'](),'evidence':z['string']()['optional'](),'stakeholders':z['array'](z['string']())['optional'](),'exposure':ExposureFragmentSchema['optional']()})['strict']();export const RuleEntrySchema=z['object']({'rule_id':z['string'](),'dimension':z['string']()['optional'](),'trigger':z['string']()['optional'](),'cases':z['array'](RuleCaseSchema)['min'](0x1),'enabled':z['boolean']()['optional']()})['strict']();export const RuleDomainPackSchema=z['object']({'comment':z['string']()['optional'](),'facts':z['record'](z['string'](),z['string']())['optional'](),'rules':z['array'](RuleEntrySchema),'severity_overrides':z['record'](z['string'](),z['enum'](['error','warning','info']))['optional']()})['strict']();export const RuleEntryInputSchema=z['object']({'rule_id':z['string'](),'dimension':z['string']()['optional'](),'trigger':z['string']()['optional'](),'cases':z['array'](RuleCaseSchema)['optional'](),'enabled':z['boolean']()['optional']()})['strict']();export const RuleDomainPackInputSchema=z['object']({'comment':z['string']()['optional'](),'facts':z['record'](z['string'](),z['string']())['optional'](),'rules':z['array'](RuleEntryInputSchema)['optional'](),'severity_overrides':z['record'](z['string'](),z['enum'](['error','warning','info']))['optional']()})['strict']();function lookup(a,b){let c=a;for(const d of b['split']('.')){if(c===null||typeof c!=='object')return undefined;c=c[d];if(c===undefined)return undefined;}return c;}function toNumber(a){if(typeof a==='number'&&Number['isFinite'](a))return a;if(typeof a==='string'&&a['trim']()!==''&&Number['isFinite'](Number(a)))return Number(a);return null;}function matchesOp(c,d){const e=lookup(d,c['field']);switch(c['op']){case'present':return e!==undefined;case'missing':return e===undefined;case'truthy':return Array['isArray'](e)?e['length']>0x0:Boolean(e);case'falsy':return Array['isArray'](e)?e['length']===0x0:!e;case'eq':return e===c['value'];case'neq':return e!==c['value'];case'gt':case'gte':case'lt':case'lte':{const f=toNumber(e),g=toNumber(c['value']);if(f===null||g===null)return![];if(c['op']==='gt')return f>g;if(c['op']==='gte')return f>=g;if(c['op']==='lt')return f<g;return f<=g;}case'in':case'nin':{const h=Array['isArray'](c['value'])?c['value']:[],i=h['some'](j=>j===e);return c['op']==='in'?i:!i;}case'contains':if(Array['isArray'](e))return e['some'](j=>j===c['value']);if(typeof e==='string'&&typeof c['value']==='string')return e['includes'](c['value']);return![];case'matches':{if(typeof e!=='string'||typeof c['value']!=='string')return![];return new RegExp(c['value'],c['flags']??'i')['test'](e);}case'size':if(Array['isArray'](e))return e['length']===c['value'];if(typeof e==='string')return e['length']===c['value'];return![];}}export function evaluateCondition(a,b){if('all'in a)return a['all']['every'](d=>evaluateCondition(d,b));if('any'in a)return a['any']['some'](d=>evaluateCondition(d,b));if('not'in a)return!evaluateCondition(a['not'],b);return matchesOp(a,b);}export function interpolate(a,b){return a['replace'](/\$\{([^}]+)\}/g,(c,d)=>{const e=lookup(b,d['trim']());if(e===undefined)return c;if(typeof e==='object')return JSON['stringify'](e);return String(e);});}function resolveLevel(a,b){const c=parseFactRef(a);if(c===null)return a;const d=b[c];return SEVERITY_ORDER['includes'](String(d))?String(d):'info';}export function evaluateRuleBook(a,b){const d=[],e=[];for(const f of a){if(f['enabled']===![]){e['push'](f['rule_id']);continue;}for(const g of f['cases']){if(!evaluateCondition(g['when'],b))continue;const h=resolveLevel(g['level'],b),i=g['exposure']?resolveExposureFragment(g['exposure'],b,k=>interpolate(k,b)):undefined,j=i?applyExposureGate(h,i,{'downgradeExempt':i['downgradeExempt']}):undefined;d['push']({'rule_id':f['rule_id'],'dimension':f['dimension'],'level':j?j['severity']:h,'title':interpolate(g['title'],b),'description':interpolate(g['description'],b),'scenario':g['scenario']===undefined?undefined:interpolate(g['scenario'],b),'mitigation':g['mitigation']===undefined?undefined:interpolate(g['mitigation'],b),'evidence':g['evidence']===undefined?undefined:interpolate(g['evidence'],b),'stakeholders':g['stakeholders'],...j?{'exposure':j['exposure']}:{}});break;}}return{'findings':d,'disabled_traces':e};}
1
+ import{z}from'zod';import{SEVERITY_ORDER,normalizeSeverity}from'./severity.js';import{ExposureFragmentSchema,FactRefSchema,applyExposureGate,parseFactRef,resolveExposureFragment}from'./exposure.js';const LEAF_OPS=['present','missing','truthy','falsy','eq','neq','gt','gte','lt','lte','in','nin','contains','matches','size'];export const RuleConditionSchema=z['lazy'](()=>z['union']([z['object']({'all':z['array'](RuleConditionSchema)})['strict'](),z['object']({'any':z['array'](RuleConditionSchema)})['strict'](),z['object']({'not':RuleConditionSchema})['strict'](),z['object']({'field':z['string'](),'op':z['enum'](LEAF_OPS),'value':z['unknown']()['optional'](),'flags':z['string']()['optional']()})['strict']()]));const AUDIT_OVERRIDE_TIERS=['error','warning','info'];export function normalizeSeverityOverride(a){const b=a?.['toLowerCase']();if(AUDIT_OVERRIDE_TIERS['includes'](b))return b;switch(b){case'critical':case'high':case'warn':return'error';case'medium':return'warning';case'low':return'info';default:return null;}}const SeverityOverridesSchema=z['record'](z['string'](),z['string']())['transform'](a=>{const b={};for(const [c,d]of Object['entries'](a)){const e=normalizeSeverityOverride(d);if(e!==null)b[c]=e;}return b;}),CaseLevelSchema=z['union']([z['enum'](SEVERITY_ORDER),FactRefSchema,z['string']()['transform'](a=>normalizeSeverity(a))]);export const RuleCaseSchema=z['object']({'when':RuleConditionSchema,'level':CaseLevelSchema,'title':z['string'](),'description':z['string'](),'scenario':z['string']()['optional'](),'mitigation':z['string']()['optional'](),'evidence':z['string']()['optional'](),'stakeholders':z['array'](z['string']())['optional'](),'exposure':ExposureFragmentSchema['optional']()})['strict']();export const RuleEntrySchema=z['object']({'rule_id':z['string'](),'dimension':z['string']()['optional'](),'trigger':z['string']()['optional'](),'cases':z['array'](RuleCaseSchema)['min'](0x1),'enabled':z['boolean']()['optional']()})['strict']();export const RuleDomainPackSchema=z['object']({'comment':z['string']()['optional'](),'facts':z['record'](z['string'](),z['string']())['optional'](),'rules':z['array'](RuleEntrySchema),'severity_overrides':SeverityOverridesSchema['optional']()})['strict']();export const RuleEntryInputSchema=z['object']({'rule_id':z['string'](),'dimension':z['string']()['optional'](),'trigger':z['string']()['optional'](),'cases':z['array'](RuleCaseSchema)['optional'](),'enabled':z['boolean']()['optional']()})['strict']();export const RuleDomainPackInputSchema=z['object']({'comment':z['string']()['optional'](),'facts':z['record'](z['string'](),z['string']())['optional'](),'rules':z['array'](RuleEntryInputSchema)['optional'](),'severity_overrides':SeverityOverridesSchema['optional']()})['strict']();function lookup(a,b){let c=a;for(const d of b['split']('.')){if(c===null||typeof c!=='object')return undefined;c=c[d];if(c===undefined)return undefined;}return c;}function toNumber(a){if(typeof a==='number'&&Number['isFinite'](a))return a;if(typeof a==='string'&&a['trim']()!==''&&Number['isFinite'](Number(a)))return Number(a);return null;}function matchesOp(c,d){const e=lookup(d,c['field']);switch(c['op']){case'present':return e!==undefined;case'missing':return e===undefined;case'truthy':return Array['isArray'](e)?e['length']>0x0:Boolean(e);case'falsy':return Array['isArray'](e)?e['length']===0x0:!e;case'eq':return e===c['value'];case'neq':return e!==c['value'];case'gt':case'gte':case'lt':case'lte':{const f=toNumber(e),g=toNumber(c['value']);if(f===null||g===null)return![];if(c['op']==='gt')return f>g;if(c['op']==='gte')return f>=g;if(c['op']==='lt')return f<g;return f<=g;}case'in':case'nin':{const h=Array['isArray'](c['value'])?c['value']:[],i=h['some'](j=>j===e);return c['op']==='in'?i:!i;}case'contains':if(Array['isArray'](e))return e['some'](j=>j===c['value']);if(typeof e==='string'&&typeof c['value']==='string')return e['includes'](c['value']);return![];case'matches':{if(typeof e!=='string'||typeof c['value']!=='string')return![];return new RegExp(c['value'],c['flags']??'i')['test'](e);}case'size':if(Array['isArray'](e))return e['length']===c['value'];if(typeof e==='string')return e['length']===c['value'];return![];}}export function evaluateCondition(a,b){if('all'in a)return a['all']['every'](d=>evaluateCondition(d,b));if('any'in a)return a['any']['some'](d=>evaluateCondition(d,b));if('not'in a)return!evaluateCondition(a['not'],b);return matchesOp(a,b);}export function interpolate(a,b){return a['replace'](/\$\{([^}]+)\}/g,(c,d)=>{const e=lookup(b,d['trim']());if(e===undefined)return c;if(typeof e==='object')return JSON['stringify'](e);return String(e);});}function resolveLevel(a,b){const c=parseFactRef(a);if(c===null)return a;const d=b[c];return SEVERITY_ORDER['includes'](String(d))?String(d):'info';}export function evaluateRuleBook(a,b){const d=[],e=[];for(const f of a){if(f['enabled']===![]){e['push'](f['rule_id']);continue;}for(const g of f['cases']){if(!evaluateCondition(g['when'],b))continue;const h=resolveLevel(g['level'],b),i=g['exposure']?resolveExposureFragment(g['exposure'],b,k=>interpolate(k,b)):undefined,j=i?applyExposureGate(h,i,{'downgradeExempt':i['downgradeExempt']}):undefined;d['push']({'rule_id':f['rule_id'],'dimension':f['dimension'],'level':j?j['severity']:h,'title':interpolate(g['title'],b),'description':interpolate(g['description'],b),'scenario':g['scenario']===undefined?undefined:interpolate(g['scenario'],b),'mitigation':g['mitigation']===undefined?undefined:interpolate(g['mitigation'],b),'evidence':g['evidence']===undefined?undefined:interpolate(g['evidence'],b),'stakeholders':g['stakeholders'],...j?{'exposure':j['exposure']}:{}});break;}}return{'findings':d,'disabled_traces':e};}
@@ -1 +1 @@
1
- import*as a39a from'node:fs';import*as a39b from'node:path';import{z}from'zod';import{getWowMcpDir}from'@wowok/wowok';const FILE_NAME='template-params.json',ParamValueSchema=z['union']([z['number']()['finite']()['nonnegative'](),z['string']()['min'](0x1)]),TemplateParamsFileSchema=z['object']({'version':z['number']()['int']()['nonnegative']()['optional'](),'comment':z['string']()['optional'](),'defaults':z['record'](z['string'](),ParamValueSchema)['optional'](),'templates':z['record'](z['string'](),z['record'](z['string'](),ParamValueSchema))['optional']()})['strict']();export function templateParamsFilePath(){const a=process['env']['WOWOK_CONFIG_DIR']||getWowMcpDir();return a39b['join'](a,FILE_NAME);}let cache=null;function zodMessage(a){return a instanceof z['ZodError']?a['issues']['map'](b=>b['path']['join']('.')+':\x20'+b['message'])['join'](';\x20'):a instanceof Error?a['message']:String(a);}function readAndParse(a){let b;try{b=a39a['readFileSync'](a,'utf-8');}catch(c){return{'path':a,'exists':!![],'error':'unreadable:\x20'+(c instanceof Error?c['message']:String(c))};}try{const d=TemplateParamsFileSchema['parse'](JSON['parse'](b));return{'path':a,'exists':!![],'error':null,...d['comment']!==undefined?{'comment':d['comment']}:{},...d['defaults']!==undefined?{'defaults':d['defaults']}:{},...d['templates']!==undefined?{'templates':d['templates']}:{}};}catch(f){return{'path':a,'exists':!![],'error':zodMessage(f)};}}export function getTemplateParamFileState(){const a=templateParamsFilePath();try{const b=a39a['statSync'](a);if(cache&&cache['mtimeMs']===b['mtimeMs'])return cache['state'];const c=readAndParse(a);if(c['error']===null)cache={'mtimeMs':b['mtimeMs'],'state':c};return c;}catch{return{'path':a,'exists':![],'error':null};}}export function getTemplateParamFileLayer(a){const b=getTemplateParamFileState();if(b['error']!==null)return{};const c=b['templates']?.[a];return{...b['defaults']??{},...c??{}};}export function resetTemplateParamFileCache(){cache=null;}export const ARB_VOTING_WINDOW_DEFAULT_MS=0xf731400;export function arbVotingWindowMs(){const a=getTemplateParamFileState();if(a['error']!==null)return ARB_VOTING_WINDOW_DEFAULT_MS;const b=a['defaults']?.['arb_voting_window_ms'];return typeof b==='number'&&Number['isFinite'](b)&&b>0x0?b:ARB_VOTING_WINDOW_DEFAULT_MS;}function isPlainObject(a){return typeof a==='object'&&a!==null&&!Array['isArray'](a);}function deepMergeValues(a,b){if(isPlainObject(a)&&isPlainObject(b)){const c={...a};for(const [d,e]of Object['entries'](b)){c[d]=d in a?deepMergeValues(a[d],e):e;}return c;}return b;}function collectLeafChanges(a,c,d,e){if(isPlainObject(c)){const f=isPlainObject(a)?a:{};for(const [g,h]of Object['entries'](c)){collectLeafChanges(f[g],h,d?d+'.'+g:g,e);}return;}JSON['stringify'](a)!==JSON['stringify'](c)&&e['push']({'path':d||'(root)','old':a===undefined?null:a,'new':c});}export function patchTemplateParamFile(a){const b=templateParamsFilePath(),c=a39b['join'](a39b['dirname'](b),'template-params.backup.json');if(!isPlainObject(a))throw new Error('\x27patch\x27\x20must\x20be\x20an\x20object\x20like\x20{\x22defaults\x22:\x20{…},\x20\x22templates\x22:\x20{\x22<tpl-id>\x22:\x20{…}}}');const d=Object['keys'](a)['filter'](m=>m!=='defaults'&&m!=='templates'&&m!=='comment');if(d['length']>0x0)throw new Error('patch\x20rejected:\x20unknown\x20key(s)\x20'+d['map'](m=>'\x27'+m+'\x27')['join'](',\x20')+'\x20—\x20allowed:\x20defaults,\x20templates,\x20comment');let f={},g=![];try{const m=a39a['readFileSync'](b,'utf-8');g=!![],f=TemplateParamsFileSchema['parse'](JSON['parse'](m));}catch(n){if(g)throw new Error('the\x20current\x20template-params.json\x20is\x20not\x20a\x20valid\x20template-params\x20document\x20('+zodMessage(n)+')\x20—\x20fix\x20or\x20remove\x20'+b+'\x20by\x20hand\x20first');f={};}const h={...f},i=[];for(const o of['defaults','templates']){const p=a[o];if(p===undefined)continue;if(!isPlainObject(p))throw new Error('patch.'+o+'\x20must\x20be\x20an\x20object\x20(param\x20→\x20value'+(o==='templates'?',\x20keyed\x20by\x20template\x20id':'')+')');const q=deepMergeValues(f[o]??{},p);try{h[o]=TemplateParamsFileSchema['shape'][o]['parse'](q);}catch(r){throw new Error('patch.'+o+'\x20rejected:\x20'+zodMessage(r));}collectLeafChanges(f[o]??{},p,o,i);}if(a['comment']!==undefined){if(typeof a['comment']!=='string')throw new Error('patch.comment\x20must\x20be\x20a\x20string');h['comment']=a['comment'];}if(i['length']===0x0)return{'applied':!![],'path':b,'backup_path':null,'changed':i,'error':null};const j={'version':0x1,...h};TemplateParamsFileSchema['parse'](j);const k=JSON['stringify'](j,null,0x2)+'\x0a';a39a['mkdirSync'](a39b['dirname'](b),{'recursive':!![]});if(g)a39a['copyFileSync'](b,c);const l=b+'.tmp';return a39a['writeFileSync'](l,k,'utf-8'),a39a['renameSync'](l,b),cache={'mtimeMs':a39a['statSync'](b)['mtimeMs'],'state':readAndParse(b)},{'applied':!![],'path':b,'backup_path':g?c:null,'changed':i,'error':cache['state']['error']};}export function clearTemplateParamFile(a){const b=templateParamsFilePath(),c=a39b['join'](a39b['dirname'](b),'template-params.backup.json');try{a39a['statSync'](b);}catch{return{'cleared':![],'path':b,'scope':'file','backup_path':null};}a39a['copyFileSync'](b,c);if(!a)return a39a['rmSync'](b),cache=null,{'cleared':!![],'path':b,'scope':'file','backup_path':c};let d;try{d=JSON['parse'](a39a['readFileSync'](b,'utf-8'));}catch(g){throw new Error('template-params.json\x20is\x20unreadable\x20('+zodMessage(g)+')\x20—\x20clear\x20the\x20WHOLE\x20file\x20(omit\x20\x27template\x27)\x20or\x20remove\x20'+b+'\x20by\x20hand');}if(a==='defaults')delete d['defaults'];else{const h=isPlainObject(d['templates'])?{...d['templates']}:{};if(!(a in h))return{'cleared':![],'path':b,'scope':'template','template_id':a,'backup_path':null};delete h[a],d['templates']=h;}const f=isPlainObject(d['defaults'])&&Object['keys'](d['defaults'])['length']>0x0||isPlainObject(d['templates'])&&Object['keys'](d['templates'])['length']>0x0;if(f){const i=JSON['stringify'](d,null,0x2)+'\x0a',j=b+'.tmp';a39a['writeFileSync'](j,i,'utf-8'),a39a['renameSync'](j,b);}else a39a['rmSync'](b);return cache=null,{'cleared':!![],'path':b,'scope':a==='defaults'?'defaults':'template','template_id':a==='defaults'?undefined:a,'backup_path':c};}
1
+ import*as a41a from'node:fs';import*as a41b from'node:path';import{z}from'zod';import{getWowMcpDir}from'@wowok/wowok';const FILE_NAME='template-params.json',ParamValueSchema=z['union']([z['number']()['finite']()['nonnegative'](),z['string']()['min'](0x1)]),TemplateParamsFileSchema=z['object']({'version':z['number']()['int']()['nonnegative']()['optional'](),'comment':z['string']()['optional'](),'defaults':z['record'](z['string'](),ParamValueSchema)['optional'](),'templates':z['record'](z['string'](),z['record'](z['string'](),ParamValueSchema))['optional']()})['strict']();export function templateParamsFilePath(){const a=process['env']['WOWOK_CONFIG_DIR']||getWowMcpDir();return a41b['join'](a,FILE_NAME);}let cache=null;function zodMessage(a){return a instanceof z['ZodError']?a['issues']['map'](b=>b['path']['join']('.')+':\x20'+b['message'])['join'](';\x20'):a instanceof Error?a['message']:String(a);}function readAndParse(a){let b;try{b=a41a['readFileSync'](a,'utf-8');}catch(c){return{'path':a,'exists':!![],'error':'unreadable:\x20'+(c instanceof Error?c['message']:String(c))};}try{const d=TemplateParamsFileSchema['parse'](JSON['parse'](b));return{'path':a,'exists':!![],'error':null,...d['comment']!==undefined?{'comment':d['comment']}:{},...d['defaults']!==undefined?{'defaults':d['defaults']}:{},...d['templates']!==undefined?{'templates':d['templates']}:{}};}catch(f){return{'path':a,'exists':!![],'error':zodMessage(f)};}}export function getTemplateParamFileState(){const a=templateParamsFilePath();try{const b=a41a['statSync'](a);if(cache&&cache['mtimeMs']===b['mtimeMs'])return cache['state'];const c=readAndParse(a);if(c['error']===null)cache={'mtimeMs':b['mtimeMs'],'state':c};return c;}catch{return{'path':a,'exists':![],'error':null};}}export function getTemplateParamFileLayer(a){const b=getTemplateParamFileState();if(b['error']!==null)return{};const c=b['templates']?.[a];return{...b['defaults']??{},...c??{}};}export function resetTemplateParamFileCache(){cache=null;}export const ARB_VOTING_WINDOW_DEFAULT_MS=0xf731400;export function arbVotingWindowMs(){const a=getTemplateParamFileState();if(a['error']!==null)return ARB_VOTING_WINDOW_DEFAULT_MS;const b=a['defaults']?.['arb_voting_window_ms'];return typeof b==='number'&&Number['isFinite'](b)&&b>0x0?b:ARB_VOTING_WINDOW_DEFAULT_MS;}function isPlainObject(a){return typeof a==='object'&&a!==null&&!Array['isArray'](a);}function deepMergeValues(a,b){if(isPlainObject(a)&&isPlainObject(b)){const c={...a};for(const [d,e]of Object['entries'](b)){c[d]=d in a?deepMergeValues(a[d],e):e;}return c;}return b;}function collectLeafChanges(a,c,d,e){if(isPlainObject(c)){const f=isPlainObject(a)?a:{};for(const [g,h]of Object['entries'](c)){collectLeafChanges(f[g],h,d?d+'.'+g:g,e);}return;}JSON['stringify'](a)!==JSON['stringify'](c)&&e['push']({'path':d||'(root)','old':a===undefined?null:a,'new':c});}export function patchTemplateParamFile(a){const b=templateParamsFilePath(),c=a41b['join'](a41b['dirname'](b),'template-params.backup.json');if(!isPlainObject(a))throw new Error('\x27patch\x27\x20must\x20be\x20an\x20object\x20like\x20{\x22defaults\x22:\x20{…},\x20\x22templates\x22:\x20{\x22<tpl-id>\x22:\x20{…}}}');const d=Object['keys'](a)['filter'](m=>m!=='defaults'&&m!=='templates'&&m!=='comment');if(d['length']>0x0)throw new Error('patch\x20rejected:\x20unknown\x20key(s)\x20'+d['map'](m=>'\x27'+m+'\x27')['join'](',\x20')+'\x20—\x20allowed:\x20defaults,\x20templates,\x20comment');let f={},g=![];try{const m=a41a['readFileSync'](b,'utf-8');g=!![],f=TemplateParamsFileSchema['parse'](JSON['parse'](m));}catch(n){if(g)throw new Error('the\x20current\x20template-params.json\x20is\x20not\x20a\x20valid\x20template-params\x20document\x20('+zodMessage(n)+')\x20—\x20fix\x20or\x20remove\x20'+b+'\x20by\x20hand\x20first');f={};}const h={...f},i=[];for(const o of['defaults','templates']){const p=a[o];if(p===undefined)continue;if(!isPlainObject(p))throw new Error('patch.'+o+'\x20must\x20be\x20an\x20object\x20(param\x20→\x20value'+(o==='templates'?',\x20keyed\x20by\x20template\x20id':'')+')');const q=deepMergeValues(f[o]??{},p);try{h[o]=TemplateParamsFileSchema['shape'][o]['parse'](q);}catch(r){throw new Error('patch.'+o+'\x20rejected:\x20'+zodMessage(r));}collectLeafChanges(f[o]??{},p,o,i);}if(a['comment']!==undefined){if(typeof a['comment']!=='string')throw new Error('patch.comment\x20must\x20be\x20a\x20string');h['comment']=a['comment'];}if(i['length']===0x0)return{'applied':!![],'path':b,'backup_path':null,'changed':i,'error':null};const j={'version':0x1,...h};TemplateParamsFileSchema['parse'](j);const k=JSON['stringify'](j,null,0x2)+'\x0a';a41a['mkdirSync'](a41b['dirname'](b),{'recursive':!![]});if(g)a41a['copyFileSync'](b,c);const l=b+'.tmp';return a41a['writeFileSync'](l,k,'utf-8'),a41a['renameSync'](l,b),cache={'mtimeMs':a41a['statSync'](b)['mtimeMs'],'state':readAndParse(b)},{'applied':!![],'path':b,'backup_path':g?c:null,'changed':i,'error':cache['state']['error']};}export function clearTemplateParamFile(a){const b=templateParamsFilePath(),c=a41b['join'](a41b['dirname'](b),'template-params.backup.json');try{a41a['statSync'](b);}catch{return{'cleared':![],'path':b,'scope':'file','backup_path':null};}a41a['copyFileSync'](b,c);if(!a)return a41a['rmSync'](b),cache=null,{'cleared':!![],'path':b,'scope':'file','backup_path':c};let d;try{d=JSON['parse'](a41a['readFileSync'](b,'utf-8'));}catch(g){throw new Error('template-params.json\x20is\x20unreadable\x20('+zodMessage(g)+')\x20—\x20clear\x20the\x20WHOLE\x20file\x20(omit\x20\x27template\x27)\x20or\x20remove\x20'+b+'\x20by\x20hand');}if(a==='defaults')delete d['defaults'];else{const h=isPlainObject(d['templates'])?{...d['templates']}:{};if(!(a in h))return{'cleared':![],'path':b,'scope':'template','template_id':a,'backup_path':null};delete h[a],d['templates']=h;}const f=isPlainObject(d['defaults'])&&Object['keys'](d['defaults'])['length']>0x0||isPlainObject(d['templates'])&&Object['keys'](d['templates'])['length']>0x0;if(f){const i=JSON['stringify'](d,null,0x2)+'\x0a',j=b+'.tmp';a41a['writeFileSync'](j,i,'utf-8'),a41a['renameSync'](j,b);}else a41a['rmSync'](b);return cache=null,{'cleared':!![],'path':b,'scope':a==='defaults'?'defaults':'template','template_id':a==='defaults'?undefined:a,'backup_path':c};}
@@ -1 +1 @@
1
- import{REQUIREMENT_PASS_THRESHOLD,effectiveWeight,isDataSourceEnabled,isRuleEnabled,normalizeInjection}from'./user-injection.js';import{levelFromScore as a77a,concernLabel}from'./standards.js';export function levelFromScore(a){return a77a(a);}function appliesTo(a,b){if(!a||a['length']===0x0)return!![];return a['includes'](b);}export class EvaluationEngine{static ['instance']=null;['dataSources']=new Map();['rules']=new Map();static['Instance'](){return!EvaluationEngine['instance']&&(EvaluationEngine['instance']=new EvaluationEngine()),EvaluationEngine['instance'];}['registerDataSource'](a){if(!a['id']||this['dataSources']['has'](a['id']))return![];return this['dataSources']['set'](a['id'],a),!![];}['unregisterDataSource'](a){return this['dataSources']['delete'](a);}['registerRule'](a){if(!a['id']||this['rules']['has'](a['id']))return![];return this['rules']['set'](a['id'],a),!![];}['unregisterRule'](a){return this['rules']['delete'](a);}['getRule'](a){return this['rules']['get'](a);}['listRules'](){return Array['from'](this['rules']['values']());}['getDataSource'](a){return this['dataSources']['get'](a);}['listDataSources'](){return Array['from'](this['dataSources']['values']());}async['evaluate'](a,b,c){const d=normalizeInjection(c),e={'evaluation_id':a,'entities':b,'facts':{},'injection':d,'now':Date['now']()},f=[],g=[],h=Array['from'](this['dataSources']['values']())['filter'](n=>appliesTo(n['evaluation_ids'],a))['sort']((n,o)=>(n['priority']??0x0)-(o['priority']??0x0));for(const n of h){if(!isDataSourceEnabled(n['id'],d)){f['push']({'kind':'override','id':n['id'],'detail':'data\x20source\x20disabled\x20by\x20user\x20override'});continue;}if(n['isEnabled']&&!n['isEnabled'](e))continue;const o=await n['extract'](e);Object['assign'](e['facts'],o),f['push']({'kind':'data_source','id':n['id'],'detail':'extracted\x20'+Object['keys'](o)['length']+'\x20fact(s)'});}const i=[],j=[];for(const p of this['rules']['values']()){if(!appliesTo(p['evaluation_ids'],a))continue;if(!isRuleEnabled(p['id'],d)){f['push']({'kind':'override','id':p['id'],'detail':'rule\x20disabled\x20by\x20user\x20override'});continue;}if(p['isEnabled']&&!p['isEnabled'](e))continue;const q=p['evaluate'](e);if(!q){f['push']({'kind':'rule','id':p['id'],'detail':'not\x20applicable\x20—\x20excluded\x20from\x20weighted\x20aggregation'});continue;}const r=effectiveWeight(p,d);i['push']({'rule_id':p['id'],'dimension':p['dimension'],'score':q['score'],'weight':r,'weight_source':r!==p['weight']?'override':'default','reason':q['reason'],'matched':q['matched'],'mismatched':q['mismatched'],'finding_refs':q['finding_refs'],'red_flag':q['red_flag']});if(q['red_flag']){const s=q['reason']??p['id']+'\x20triggered\x20a\x20hard\x20block';j['push'](s),g['push']({'flag':s,'basis':'object_defect','rule_id':p['id']});}f['push']({'kind':'rule','id':p['id'],'detail':'score='+q['score']+'\x20weight='+r});}const k=aggregateScore(i);let l=j['length']>0x0;for(const t of d['requirements']??[]){const u=i['find'](v=>v['rule_id']===t['rule_id']);if(t['condition']==='require'){if(!u||u['score']<REQUIREMENT_PASS_THRESHOLD||u['red_flag']){l=!![];const v=t['note']??'Requirement\x20requires\x20rule\x20\x27'+t['rule_id']+'\x27\x20to\x20pass';j['push'](v),g['push']({'flag':v,'basis':'requirement_unmet','rule_id':t['rule_id']});}}else{if(t['condition']==='forbid'){if(u&&u['red_flag']){l=!![];const w=t['note']??'Requirement\x20forbids\x20rule\x20\x27'+t['rule_id']+'\x27\x20from\x20triggering';j['push'](w),g['push']({'flag':w,'basis':'requirement_unmet','rule_id':t['rule_id']});}}}}const m=e['facts']['summary']??buildSummary(a,k,i,j,l);return{'evaluation_id':a,'total':k,'level':levelFromScore(k),'level_label':concernLabel(k),'breakdown':i,'red_flags':j,'red_flag_basis':g,'blocked':l,'trace':f,'summary':m,'criterionScores':e['facts']['criterionScores'],'findings':e['facts']['findings'],'strengths':e['facts']['strengths'],'needsLlm':e['facts']['needsLlm'],'llmPrompt':e['facts']['llmPrompt']};}}function aggregateScore(a){if(a['length']===0x0)return 0x0;let c=0x0,d=0x0;for(const e of a){c+=e['score']*e['weight'],d+=e['weight'];}if(d<=0x0)return 0x0;return clamp(Math['round'](c/d),0x0,0x64);}function clamp(a,b,c){return Math['max'](b,Math['min'](c,a));}function buildSummary(a,b,c,d,e){const f=['Evaluation\x20\x27'+a+'\x27:\x20score\x20'+b+'/100'];return e?f['push']('BLOCKED\x20('+d['length']+'\x20red\x20flag(s))'):f['push'](c['length']+'\x20rule(s)\x20evaluated'),f['join']('\x20—\x20');}export function getEvaluationEngine(){return EvaluationEngine['Instance']();}
1
+ import{REQUIREMENT_PASS_THRESHOLD,effectiveWeight,isDataSourceEnabled,isRuleEnabled,normalizeInjection}from'./user-injection.js';import{levelFromScore as a79a,concernLabel}from'./standards.js';export function levelFromScore(a){return a79a(a);}function appliesTo(a,b){if(!a||a['length']===0x0)return!![];return a['includes'](b);}export class EvaluationEngine{static ['instance']=null;['dataSources']=new Map();['rules']=new Map();static['Instance'](){return!EvaluationEngine['instance']&&(EvaluationEngine['instance']=new EvaluationEngine()),EvaluationEngine['instance'];}['registerDataSource'](a){if(!a['id']||this['dataSources']['has'](a['id']))return![];return this['dataSources']['set'](a['id'],a),!![];}['unregisterDataSource'](a){return this['dataSources']['delete'](a);}['registerRule'](a){if(!a['id']||this['rules']['has'](a['id']))return![];return this['rules']['set'](a['id'],a),!![];}['unregisterRule'](a){return this['rules']['delete'](a);}['getRule'](a){return this['rules']['get'](a);}['listRules'](){return Array['from'](this['rules']['values']());}['getDataSource'](a){return this['dataSources']['get'](a);}['listDataSources'](){return Array['from'](this['dataSources']['values']());}async['evaluate'](a,b,c){const d=normalizeInjection(c),e={'evaluation_id':a,'entities':b,'facts':{},'injection':d,'now':Date['now']()},f=[],g=[],h=Array['from'](this['dataSources']['values']())['filter'](n=>appliesTo(n['evaluation_ids'],a))['sort']((n,o)=>(n['priority']??0x0)-(o['priority']??0x0));for(const n of h){if(!isDataSourceEnabled(n['id'],d)){f['push']({'kind':'override','id':n['id'],'detail':'data\x20source\x20disabled\x20by\x20user\x20override'});continue;}if(n['isEnabled']&&!n['isEnabled'](e))continue;const o=await n['extract'](e);Object['assign'](e['facts'],o),f['push']({'kind':'data_source','id':n['id'],'detail':'extracted\x20'+Object['keys'](o)['length']+'\x20fact(s)'});}const i=[],j=[];for(const p of this['rules']['values']()){if(!appliesTo(p['evaluation_ids'],a))continue;if(!isRuleEnabled(p['id'],d)){f['push']({'kind':'override','id':p['id'],'detail':'rule\x20disabled\x20by\x20user\x20override'});continue;}if(p['isEnabled']&&!p['isEnabled'](e))continue;const q=p['evaluate'](e);if(!q){f['push']({'kind':'rule','id':p['id'],'detail':'not\x20applicable\x20—\x20excluded\x20from\x20weighted\x20aggregation'});continue;}const r=effectiveWeight(p,d);i['push']({'rule_id':p['id'],'dimension':p['dimension'],'score':q['score'],'weight':r,'weight_source':r!==p['weight']?'override':'default','reason':q['reason'],'matched':q['matched'],'mismatched':q['mismatched'],'finding_refs':q['finding_refs'],'red_flag':q['red_flag']});if(q['red_flag']){const s=q['reason']??p['id']+'\x20triggered\x20a\x20hard\x20block';j['push'](s),g['push']({'flag':s,'basis':'object_defect','rule_id':p['id']});}f['push']({'kind':'rule','id':p['id'],'detail':'score='+q['score']+'\x20weight='+r});}const k=aggregateScore(i);let l=j['length']>0x0;for(const t of d['requirements']??[]){const u=i['find'](v=>v['rule_id']===t['rule_id']);if(t['condition']==='require'){if(!u||u['score']<REQUIREMENT_PASS_THRESHOLD||u['red_flag']){l=!![];const v=t['note']??'Requirement\x20requires\x20rule\x20\x27'+t['rule_id']+'\x27\x20to\x20pass';j['push'](v),g['push']({'flag':v,'basis':'requirement_unmet','rule_id':t['rule_id']});}}else{if(t['condition']==='forbid'){if(u&&u['red_flag']){l=!![];const w=t['note']??'Requirement\x20forbids\x20rule\x20\x27'+t['rule_id']+'\x27\x20from\x20triggering';j['push'](w),g['push']({'flag':w,'basis':'requirement_unmet','rule_id':t['rule_id']});}}}}const m=e['facts']['summary']??buildSummary(a,k,i,j,l);return{'evaluation_id':a,'total':k,'level':levelFromScore(k),'level_label':concernLabel(k),'breakdown':i,'red_flags':j,'red_flag_basis':g,'blocked':l,'trace':f,'summary':m,'criterionScores':e['facts']['criterionScores'],'findings':e['facts']['findings'],'strengths':e['facts']['strengths'],'needsLlm':e['facts']['needsLlm'],'llmPrompt':e['facts']['llmPrompt']};}}function aggregateScore(a){if(a['length']===0x0)return 0x0;let c=0x0,d=0x0;for(const e of a){c+=e['score']*e['weight'],d+=e['weight'];}if(d<=0x0)return 0x0;return clamp(Math['round'](c/d),0x0,0x64);}function clamp(a,b,c){return Math['max'](b,Math['min'](c,a));}function buildSummary(a,b,c,d,e){const f=['Evaluation\x20\x27'+a+'\x27:\x20score\x20'+b+'/100'];return e?f['push']('BLOCKED\x20('+d['length']+'\x20red\x20flag(s))'):f['push'](c['length']+'\x20rule(s)\x20evaluated'),f['join']('\x20—\x20');}export function getEvaluationEngine(){return EvaluationEngine['Instance']();}
@@ -1 +1 @@
1
- import{distillIntent,extractSignals}from'./intent-distill.js';import{getProfile,updateFromOperation}from'./user-profile.js';import{findMatches,recordSignature}from'./experience-reuse.js';import{EXPERIENCE_LAYER_VERSION}from'./types.js';import{isEnabled as a102a}from'../config/index.js';import{recordIndustrySignal}from'../knowledge/flywheel-loop.js';export{EXPERIENCE_LAYER_VERSION};export function getExperienceFeedback(a,b,c){try{const d=distillIntent(a,b,c),e=findMatches(d['primary_intent'],a,b,0x3);if(e['length']===0x0)return undefined;const f=e[0x0],g=getProfile();return formatFeedback(f,e,d['scenario'],g);}catch{return undefined;}}export function recordOperationOutcome(a,b,c,d,e,f=[]){try{const g=distillIntent(a,b,c),h=extractSignals(a,b);recordSignature({'intent':g['primary_intent'],'scenario':g['scenario'],'signals':h,'timestamp':Date['now'](),'outcome':d,'error_code':e}),updateFromOperation(g['primary_intent'],g['scenario'],d,e,f);try{if(a102a('industry_evolution')){const i=typeof b?.['industry']==='string'&&b['industry']['trim']()?b['industry']['trim']():undefined;if(i){const j=d==='success'?{'success':!![]}:{'success':![],'error_code':e};recordIndustrySignal(i,{'type':a,'data':b},j);}}}catch{}}catch{}}function formatFeedback(a,b,c,d){const e=buildAdviceText(a,b,d),f=collectAvoidList(b,d),g=a['relevance'],h=c??a['signature']['scenario'],i={};if(e)i['advice']=e;if(f['length']>0x0)i['avoid']=f;if(g>0x0)i['relevance']=Math['round'](g*0x64)/0x64;if(h)i['matched_scenario']=h;return i;}function buildAdviceText(a,b,c){const d=[];if(a['signature']['outcome']==='success')d['push']('Historically,\x20'+a['signature']['intent']+'\x20operation\x20succeeded');else a['signature']['outcome']==='failed'&&d['push']('Historically,\x20'+a['signature']['intent']+'\x20operation\x20failed\x20('+(a['signature']['error_code']??'unknown\x20error')+'),\x20pay\x20special\x20attention\x20to\x20parameters');return c['expertise_tier']==='novice'&&b['length']>0x0&&d['push']('It\x20is\x20recommended\x20to\x20carefully\x20check\x20parameters\x20before\x20executing'),d['join'](';\x20')||a['advice'];}function collectAvoidList(b,c){const d=new Set();for(const e of b){for(const f of e['avoid']){d['add'](f);}}for(const g of c['frequent_pitfalls']){d['add']('You\x20often\x20make\x20mistakes\x20at\x20the\x20'+g+'\x20step,\x20please\x20be\x20especially\x20careful');}return Array['from'](d)['slice'](0x0,0x5);}
1
+ import{distillIntent,extractSignals}from'./intent-distill.js';import{getProfile,updateFromOperation}from'./user-profile.js';import{findMatches,recordSignature}from'./experience-reuse.js';import{EXPERIENCE_LAYER_VERSION}from'./types.js';import{isEnabled as a104a}from'../config/index.js';import{recordIndustrySignal}from'../knowledge/flywheel-loop.js';export{EXPERIENCE_LAYER_VERSION};export function getExperienceFeedback(a,b,c){try{const d=distillIntent(a,b,c),e=findMatches(d['primary_intent'],a,b,0x3);if(e['length']===0x0)return undefined;const f=e[0x0],g=getProfile();return formatFeedback(f,e,d['scenario'],g);}catch{return undefined;}}export function recordOperationOutcome(a,b,c,d,e,f=[]){try{const g=distillIntent(a,b,c),h=extractSignals(a,b);recordSignature({'intent':g['primary_intent'],'scenario':g['scenario'],'signals':h,'timestamp':Date['now'](),'outcome':d,'error_code':e}),updateFromOperation(g['primary_intent'],g['scenario'],d,e,f);try{if(a104a('industry_evolution')){const i=typeof b?.['industry']==='string'&&b['industry']['trim']()?b['industry']['trim']():undefined;if(i){const j=d==='success'?{'success':!![]}:{'success':![],'error_code':e};recordIndustrySignal(i,{'type':a,'data':b},j);}}}catch{}}catch{}}function formatFeedback(a,b,c,d){const e=buildAdviceText(a,b,d),f=collectAvoidList(b,d),g=a['relevance'],h=c??a['signature']['scenario'],i={};if(e)i['advice']=e;if(f['length']>0x0)i['avoid']=f;if(g>0x0)i['relevance']=Math['round'](g*0x64)/0x64;if(h)i['matched_scenario']=h;return i;}function buildAdviceText(a,b,c){const d=[];if(a['signature']['outcome']==='success')d['push']('Historically,\x20'+a['signature']['intent']+'\x20operation\x20succeeded');else a['signature']['outcome']==='failed'&&d['push']('Historically,\x20'+a['signature']['intent']+'\x20operation\x20failed\x20('+(a['signature']['error_code']??'unknown\x20error')+'),\x20pay\x20special\x20attention\x20to\x20parameters');return c['expertise_tier']==='novice'&&b['length']>0x0&&d['push']('It\x20is\x20recommended\x20to\x20carefully\x20check\x20parameters\x20before\x20executing'),d['join'](';\x20')||a['advice'];}function collectAvoidList(b,c){const d=new Set();for(const e of b){for(const f of e['avoid']){d['add'](f);}}for(const g of c['frequent_pitfalls']){d['add']('You\x20often\x20make\x20mistakes\x20at\x20the\x20'+g+'\x20step,\x20please\x20be\x20especially\x20careful');}return Array['from'](d)['slice'](0x0,0x5);}