@wowok/agent-mcp 2.7.2 → 2.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (383) hide show
  1. package/dist/config/runtime.js +1 -1
  2. package/dist/customer/account-events.d.ts +32 -0
  3. package/dist/customer/account-events.js +1 -0
  4. package/dist/customer/customer-advice.d.ts +1 -0
  5. package/dist/customer/customer-advice.js +1 -1
  6. package/dist/customer/info-puzzle.js +1 -1
  7. package/dist/customer/order-strategy.d.ts +1 -1
  8. package/dist/customer/reminder-system.d.ts +2 -0
  9. package/dist/customer/reminder-system.js +1 -1
  10. package/dist/customer/risk-assessment.d.ts +1 -0
  11. package/dist/customer/risk-assessment.js +1 -1
  12. package/dist/customer/types.d.ts +2 -0
  13. package/dist/evaluation/builtins/arbitration-score.d.ts +41 -0
  14. package/dist/evaluation/builtins/arbitration-score.js +1 -0
  15. package/dist/evaluation/builtins/index.d.ts +1 -0
  16. package/dist/evaluation/builtins/index.js +1 -1
  17. package/dist/evaluation/category-match-rules.d.ts +30 -0
  18. package/dist/evaluation/category-match-rules.js +1 -0
  19. package/dist/evaluation/engine.js +1 -1
  20. package/dist/evaluation/extract.js +1 -1
  21. package/dist/evaluation/index.d.ts +1 -0
  22. package/dist/evaluation/index.js +1 -1
  23. package/dist/evaluation/location-match.d.ts +42 -0
  24. package/dist/evaluation/location-match.js +1 -0
  25. package/dist/evaluation/path-reasoning.d.ts +35 -0
  26. package/dist/evaluation/path-reasoning.js +1 -0
  27. package/dist/evaluation/region.d.ts +6 -0
  28. package/dist/evaluation/region.js +1 -1
  29. package/dist/evaluation/types.d.ts +17 -0
  30. package/dist/experience/realtime-feedback.js +1 -1
  31. package/dist/experience/user-profile.d.ts +1 -1
  32. package/dist/extensions/index.d.ts +6 -0
  33. package/dist/extensions/index.js +1 -1
  34. package/dist/extensions/industry-layers.d.ts +75 -0
  35. package/dist/extensions/industry-layers.js +1 -0
  36. package/dist/extensions/industry-pack.d.ts +105 -0
  37. package/dist/extensions/industry-pack.js +1 -0
  38. package/dist/extensions/metric-registry.js +1 -1
  39. package/dist/extensions/mode-evaluator.d.ts +1 -1
  40. package/dist/extensions/registry.d.ts +1 -0
  41. package/dist/extensions/registry.js +1 -1
  42. package/dist/graph/base.d.ts +8 -0
  43. package/dist/graph/base.js +1 -0
  44. package/dist/harness/index.d.ts +1 -0
  45. package/dist/harness/index.js +1 -1
  46. package/dist/harness/plan.d.ts +2 -0
  47. package/dist/harness/plan.js +1 -1
  48. package/dist/harness/recover.d.ts +1 -1
  49. package/dist/harness/types.d.ts +2 -3
  50. package/dist/index.js +1 -1
  51. package/dist/knowledge/allocation-confirm.js +1 -1
  52. package/dist/knowledge/anti-cheat.d.ts +37 -0
  53. package/dist/knowledge/anti-cheat.js +1 -0
  54. package/dist/knowledge/arb-confirm.d.ts +28 -0
  55. package/dist/knowledge/arb-confirm.js +1 -0
  56. package/dist/knowledge/arb-translation.d.ts +48 -0
  57. package/dist/knowledge/arb-translation.js +1 -0
  58. package/dist/knowledge/arbitration-context.js +1 -1
  59. package/dist/knowledge/arbitration-ledger.js +1 -1
  60. package/dist/knowledge/bridge-confirm.d.ts +26 -0
  61. package/dist/knowledge/bridge-confirm.js +1 -0
  62. package/dist/knowledge/bridge-translation.d.ts +37 -0
  63. package/dist/knowledge/bridge-translation.js +1 -0
  64. package/dist/knowledge/contact-confirm.d.ts +27 -0
  65. package/dist/knowledge/contact-confirm.js +1 -0
  66. package/dist/knowledge/contact-translation.d.ts +39 -0
  67. package/dist/knowledge/contact-translation.js +1 -0
  68. package/dist/knowledge/demand-confirm.js +1 -1
  69. package/dist/knowledge/demand-context.d.ts +17 -0
  70. package/dist/knowledge/demand-context.js +1 -0
  71. package/dist/knowledge/demand-ledger.d.ts +26 -0
  72. package/dist/knowledge/demand-ledger.js +1 -0
  73. package/dist/knowledge/demand-puzzle.d.ts +29 -0
  74. package/dist/knowledge/demand-puzzle.js +1 -0
  75. package/dist/knowledge/demand-risk.js +1 -1
  76. package/dist/knowledge/demand-templates.d.ts +12 -0
  77. package/dist/knowledge/demand-templates.js +1 -0
  78. package/dist/knowledge/demand-translation.js +1 -1
  79. package/dist/knowledge/deployment-scanner.js +1 -1
  80. package/dist/knowledge/evidence-review.d.ts +12 -0
  81. package/dist/knowledge/evidence-review.js +1 -0
  82. package/dist/knowledge/examples-scanner-cli.js +1 -1
  83. package/dist/knowledge/examples-scanner.js +1 -1
  84. package/dist/knowledge/flywheel-loop.d.ts +0 -1
  85. package/dist/knowledge/flywheel-loop.js +1 -1
  86. package/dist/knowledge/guard-design-patterns.js +1 -1
  87. package/dist/knowledge/guard-migration.d.ts +1 -1
  88. package/dist/knowledge/index.d.ts +71 -3
  89. package/dist/knowledge/index.js +1 -1
  90. package/dist/knowledge/industry-registry.js +1 -1
  91. package/dist/knowledge/machine-render.js +1 -1
  92. package/dist/knowledge/market-metrics.d.ts +12 -0
  93. package/dist/knowledge/market-metrics.js +1 -0
  94. package/dist/knowledge/market-operations.d.ts +46 -0
  95. package/dist/knowledge/market-operations.js +1 -0
  96. package/dist/knowledge/mcp-schema-audit-cli.js +1 -1
  97. package/dist/knowledge/mcp-schema-audit.d.ts +22 -22
  98. package/dist/knowledge/mcp-schema-audit.js +1 -1
  99. package/dist/knowledge/onchain-constants.d.ts +2 -2
  100. package/dist/knowledge/onchain-constants.js +1 -1
  101. package/dist/knowledge/payment-confirm.d.ts +26 -0
  102. package/dist/knowledge/payment-confirm.js +1 -0
  103. package/dist/knowledge/payment-risk.js +1 -1
  104. package/dist/knowledge/payment-translation.d.ts +37 -0
  105. package/dist/knowledge/payment-translation.js +1 -0
  106. package/dist/knowledge/permission-context.d.ts +11 -0
  107. package/dist/knowledge/permission-context.js +1 -1
  108. package/dist/knowledge/permission-ledger.d.ts +11 -0
  109. package/dist/knowledge/permission-ledger.js +1 -1
  110. package/dist/knowledge/personal-confirm.d.ts +29 -0
  111. package/dist/knowledge/personal-confirm.js +1 -0
  112. package/dist/knowledge/personal-risk.js +1 -1
  113. package/dist/knowledge/personal-translation.d.ts +37 -0
  114. package/dist/knowledge/personal-translation.js +1 -0
  115. package/dist/knowledge/process-model.d.ts +1 -11
  116. package/dist/knowledge/process-model.js +1 -1
  117. package/dist/knowledge/progress-ledger.js +1 -1
  118. package/dist/knowledge/progress-risk.js +1 -1
  119. package/dist/knowledge/progress-templates.js +1 -1
  120. package/dist/knowledge/progress-translation.js +1 -1
  121. package/dist/knowledge/proof-context.d.ts +17 -0
  122. package/dist/knowledge/proof-context.js +1 -0
  123. package/dist/knowledge/proof-ledger.d.ts +34 -0
  124. package/dist/knowledge/proof-ledger.js +1 -0
  125. package/dist/knowledge/proof-puzzle.d.ts +35 -0
  126. package/dist/knowledge/proof-puzzle.js +1 -0
  127. package/dist/knowledge/proof-templates.d.ts +22 -0
  128. package/dist/knowledge/proof-templates.js +1 -0
  129. package/dist/knowledge/registrar-confirm.d.ts +26 -0
  130. package/dist/knowledge/registrar-confirm.js +1 -0
  131. package/dist/knowledge/registrar-risk.js +1 -1
  132. package/dist/knowledge/registrar-translation.d.ts +37 -0
  133. package/dist/knowledge/registrar-translation.js +1 -0
  134. package/dist/knowledge/repository-context.d.ts +12 -0
  135. package/dist/knowledge/repository-context.js +1 -0
  136. package/dist/knowledge/repository-ledger.d.ts +25 -0
  137. package/dist/knowledge/repository-ledger.js +1 -0
  138. package/dist/knowledge/repository-puzzle.d.ts +30 -0
  139. package/dist/knowledge/repository-puzzle.js +1 -0
  140. package/dist/knowledge/repository-templates.d.ts +14 -0
  141. package/dist/knowledge/repository-templates.js +1 -0
  142. package/dist/knowledge/resource-confirm.d.ts +25 -0
  143. package/dist/knowledge/resource-confirm.js +1 -0
  144. package/dist/knowledge/resource-translation.d.ts +37 -0
  145. package/dist/knowledge/resource-translation.js +1 -0
  146. package/dist/knowledge/reward-context.d.ts +2 -2
  147. package/dist/knowledge/reward-ledger.js +1 -1
  148. package/dist/knowledge/reward-translation.js +1 -1
  149. package/dist/knowledge/safety-rules.d.ts +1 -0
  150. package/dist/knowledge/safety-rules.js +1 -1
  151. package/dist/knowledge/service-risk.d.ts +1 -1
  152. package/dist/knowledge/service-risk.js +1 -1
  153. package/dist/knowledge/template-registry.js +1 -1
  154. package/dist/knowledge/tools-reference.js +1 -1
  155. package/dist/knowledge/treasury-context.d.ts +1 -1
  156. package/dist/knowledge/treasury-context.js +1 -1
  157. package/dist/knowledge/treasury-ledger.js +1 -1
  158. package/dist/knowledge/treasury-risk.js +1 -1
  159. package/dist/knowledge/universal-template.d.ts +22 -0
  160. package/dist/knowledge/universal-template.js +1 -0
  161. package/dist/knowledge/util-confirm.d.ts +24 -0
  162. package/dist/knowledge/util-confirm.js +1 -0
  163. package/dist/knowledge/util-risk.js +1 -1
  164. package/dist/knowledge/util-translation.d.ts +39 -0
  165. package/dist/knowledge/util-translation.js +1 -0
  166. package/dist/knowledge/workflow-guidance.d.ts +180 -0
  167. package/dist/knowledge/workflow-guidance.js +1 -0
  168. package/dist/participation/employee-kpi.d.ts +25 -0
  169. package/dist/participation/employee-kpi.js +1 -0
  170. package/dist/participation/employee-store.d.ts +16 -0
  171. package/dist/participation/employee-store.js +1 -0
  172. package/dist/participation/index.d.ts +2 -0
  173. package/dist/participation/index.js +1 -0
  174. package/dist/persona/defaults.js +1 -1
  175. package/dist/persona/index.d.ts +9 -2
  176. package/dist/persona/index.js +1 -1
  177. package/dist/persona/local-region.d.ts +20 -0
  178. package/dist/persona/local-region.js +1 -0
  179. package/dist/persona/model.js +1 -1
  180. package/dist/persona/overrides.d.ts +10 -0
  181. package/dist/persona/overrides.js +1 -0
  182. package/dist/persona/pack-personae.d.ts +11 -0
  183. package/dist/persona/pack-personae.js +1 -0
  184. package/dist/persona/strategy-intent.d.ts +20 -0
  185. package/dist/persona/strategy-intent.js +1 -0
  186. package/dist/persona/types.d.ts +3 -1
  187. package/dist/project/business-puzzle.d.ts +1 -1
  188. package/dist/project/business-puzzle.js +1 -1
  189. package/dist/project/deployment-doc.js +1 -1
  190. package/dist/project/edit-planner.js +1 -1
  191. package/dist/project/evaluation.d.ts +37 -1
  192. package/dist/project/evaluation.js +1 -1
  193. package/dist/project/graph-builder.d.ts +2 -2
  194. package/dist/project/graph-builder.js +1 -1
  195. package/dist/project/graph.d.ts +3 -6
  196. package/dist/project/handlers.d.ts +33 -2
  197. package/dist/project/handlers.js +1 -1
  198. package/dist/project/index.d.ts +1 -0
  199. package/dist/project/index.js +1 -1
  200. package/dist/project/merchant-guide.d.ts +19 -0
  201. package/dist/project/merchant-guide.js +1 -1
  202. package/dist/project/mode-actions.js +1 -1
  203. package/dist/project/rollback-policy.js +1 -1
  204. package/dist/project/semantic-assembler.d.ts +2 -2
  205. package/dist/project/semantic-assembler.js +1 -1
  206. package/dist/project/semantic-graph.d.ts +3 -5
  207. package/dist/project/workflow-design-assessment.d.ts +24 -0
  208. package/dist/project/workflow-design-assessment.js +1 -0
  209. package/dist/safety/confirm-gate.d.ts +1 -1
  210. package/dist/safety/confirm-gate.js +1 -1
  211. package/dist/schema/call/allocation.d.ts +186 -1385
  212. package/dist/schema/call/arbitration.d.ts +272 -1871
  213. package/dist/schema/call/base.d.ts +1831 -9076
  214. package/dist/schema/call/base.js +1 -1
  215. package/dist/schema/call/bridge.d.ts +911 -3171
  216. package/dist/schema/call/contact.d.ts +135 -931
  217. package/dist/schema/call/demand.d.ts +164 -1194
  218. package/dist/schema/call/guard.d.ts +298 -1140
  219. package/dist/schema/call/guard.js +1 -1
  220. package/dist/schema/call/machine.d.ts +459 -5403
  221. package/dist/schema/call/machine.js +1 -1
  222. package/dist/schema/call/order.d.ts +137 -844
  223. package/dist/schema/call/payment.d.ts +74 -561
  224. package/dist/schema/call/permission.d.ts +335 -2791
  225. package/dist/schema/call/personal.d.ts +227 -1814
  226. package/dist/schema/call/progress.d.ts +140 -843
  227. package/dist/schema/call/proof.d.ts +42 -258
  228. package/dist/schema/call/repository.d.ts +324 -2222
  229. package/dist/schema/call/reward.d.ts +153 -1183
  230. package/dist/schema/call/semantic.js +1 -1
  231. package/dist/schema/call/service.d.ts +376 -3431
  232. package/dist/schema/call/treasury.d.ts +252 -2158
  233. package/dist/schema/common/index.d.ts +222 -697
  234. package/dist/schema/common/index.js +1 -1
  235. package/dist/schema/config/index.d.ts +18 -161
  236. package/dist/schema/employee/index.d.ts +99 -0
  237. package/dist/schema/employee/index.js +1 -0
  238. package/dist/schema/evaluation/index.d.ts +1035 -3918
  239. package/dist/schema/evaluation/index.js +1 -1
  240. package/dist/schema/index.d.ts +5 -0
  241. package/dist/schema/index.js +1 -1
  242. package/dist/schema/industry-pack/index.d.ts +132 -0
  243. package/dist/schema/industry-pack/index.js +1 -0
  244. package/dist/schema/intent-radar/index.d.ts +92 -245
  245. package/dist/schema/intent-radar/index.js +1 -1
  246. package/dist/schema/local/index.d.ts +2045 -18080
  247. package/dist/schema/local/index.js +1 -1
  248. package/dist/schema/local/wip.d.ts +61 -651
  249. package/dist/schema/local/wip.js +1 -1
  250. package/dist/schema/messenger/index.d.ts +949 -5557
  251. package/dist/schema/messenger/index.js +1 -1
  252. package/dist/schema/operations.d.ts +3168 -26468
  253. package/dist/schema/operations.js +1 -1
  254. package/dist/schema/permission/index.d.ts +121 -0
  255. package/dist/schema/permission/index.js +1 -0
  256. package/dist/schema/persona/index.d.ts +469 -1820
  257. package/dist/schema/persona/index.js +1 -1
  258. package/dist/schema/project/index.d.ts +1023 -8450
  259. package/dist/schema/project/index.js +1 -1
  260. package/dist/schema/query/index.d.ts +12121 -75556
  261. package/dist/schema/query/index.js +1 -1
  262. package/dist/schema/schema-query/index.d.ts +35 -98
  263. package/dist/schema/schema-query/index.js +1 -1
  264. package/dist/schema/schema-version.js +1 -1
  265. package/dist/schema/task-status.d.ts +26 -132
  266. package/dist/schema/trust/index.d.ts +194 -1290
  267. package/dist/schema/utils/guard-parser.js +1 -1
  268. package/dist/schema/utils/node-parser.js +1 -1
  269. package/dist/schema/utils/skills-recommendation.d.ts +1 -0
  270. package/dist/schema/utils/skills-recommendation.js +1 -1
  271. package/dist/schema/workflow/index.d.ts +161 -0
  272. package/dist/schema/workflow/index.js +1 -0
  273. package/dist/schema/workspace/index.d.ts +69 -0
  274. package/dist/schema/workspace/index.js +1 -0
  275. package/dist/{schema-query → schema-query-impl}/index.js +1 -1
  276. package/dist/schemas/account_operation.output.json +3147 -1655
  277. package/dist/schemas/account_operation.schema.json +225 -218
  278. package/dist/schemas/bridge_operation.output.json +1168 -653
  279. package/dist/schemas/bridge_operation.schema.json +736 -504
  280. package/dist/schemas/config_operation.output.json +185 -179
  281. package/dist/schemas/config_operation.schema.json +21 -26
  282. package/dist/schemas/employee_operation.output.json +207 -0
  283. package/dist/schemas/employee_operation.schema.json +176 -0
  284. package/dist/schemas/evaluation_operation.output.json +2268 -601
  285. package/dist/schemas/evaluation_operation.schema.json +2919 -787
  286. package/dist/schemas/guard2file.output.json +58 -64
  287. package/dist/schemas/guard2file.schema.json +79 -81
  288. package/dist/schemas/index.json +41 -11
  289. package/dist/schemas/industry_pack_operation.output.json +594 -0
  290. package/dist/schemas/industry_pack_operation.schema.json +55 -0
  291. package/dist/schemas/intent_radar.output.json +275 -203
  292. package/dist/schemas/intent_radar.schema.json +124 -126
  293. package/dist/schemas/local_info_operation.output.json +1174 -660
  294. package/dist/schemas/local_info_operation.schema.json +119 -125
  295. package/dist/schemas/local_mark_operation.output.json +1239 -692
  296. package/dist/schemas/local_mark_operation.schema.json +91 -96
  297. package/dist/schemas/machineNode2file.output.json +63 -69
  298. package/dist/schemas/machineNode2file.schema.json +79 -81
  299. package/dist/schemas/messenger_operation.output.json +2722 -1531
  300. package/dist/schemas/messenger_operation.schema.json +1482 -1264
  301. package/dist/schemas/onchain_events.output.json +2590 -978
  302. package/dist/schemas/onchain_events.schema.json +117 -99
  303. package/dist/schemas/onchain_operations.output.json +3957 -2312
  304. package/dist/schemas/onchain_operations.schema.json +20799 -9285
  305. package/dist/schemas/onchain_operations_allocation.schema.json +171 -107
  306. package/dist/schemas/onchain_operations_arbitration.schema.json +233 -146
  307. package/dist/schemas/onchain_operations_contact.schema.json +129 -90
  308. package/dist/schemas/onchain_operations_demand.schema.json +170 -112
  309. package/dist/schemas/onchain_operations_gen_passport.schema.json +61 -646
  310. package/dist/schemas/onchain_operations_gen_proof.schema.json +40 -172
  311. package/dist/schemas/onchain_operations_guard.schema.json +3765 -294
  312. package/dist/schemas/onchain_operations_machine.schema.json +536 -163
  313. package/dist/schemas/onchain_operations_order.schema.json +126 -96
  314. package/dist/schemas/onchain_operations_payment.schema.json +82 -67
  315. package/dist/schemas/onchain_operations_permission.schema.json +331 -93
  316. package/dist/schemas/onchain_operations_personal.schema.json +636 -96
  317. package/dist/schemas/onchain_operations_progress.schema.json +125 -92
  318. package/dist/schemas/onchain_operations_proof.schema.json +76 -69
  319. package/dist/schemas/onchain_operations_repository.schema.json +636 -249
  320. package/dist/schemas/onchain_operations_reward.schema.json +218 -108
  321. package/dist/schemas/onchain_operations_service.schema.json +678 -220
  322. package/dist/schemas/onchain_operations_treasury.schema.json +401 -135
  323. package/dist/schemas/onchain_table_data.output.json +6833 -2432
  324. package/dist/schemas/onchain_table_data.schema.json +684 -417
  325. package/dist/schemas/permission_operation.output.json +173 -0
  326. package/dist/schemas/permission_operation.schema.json +39 -0
  327. package/dist/schemas/persona_operation.output.json +1568 -268
  328. package/dist/schemas/persona_operation.schema.json +346 -205
  329. package/dist/schemas/project_operation.output.json +6922 -5132
  330. package/dist/schemas/project_operation.schema.json +1050 -1020
  331. package/dist/schemas/query_task_status.output.json +195 -99
  332. package/dist/schemas/query_task_status.schema.json +12 -18
  333. package/dist/schemas/query_toolkit.output.json +18862 -14561
  334. package/dist/schemas/query_toolkit.schema.json +614 -522
  335. package/dist/schemas/schema_query.output.json +127 -129
  336. package/dist/schemas/schema_query.schema.json +64 -69
  337. package/dist/schemas/trust_score.output.json +678 -587
  338. package/dist/schemas/trust_score.schema.json +289 -277
  339. package/dist/schemas/wip_file.output.json +116 -124
  340. package/dist/schemas/wip_file.schema.json +142 -143
  341. package/dist/schemas/workflow_operation.output.json +164 -0
  342. package/dist/schemas/workflow_operation.schema.json +116 -0
  343. package/dist/schemas/workspace_operation.output.json +277 -0
  344. package/dist/schemas/workspace_operation.schema.json +45 -0
  345. package/dist/schemas/wowok_buildin_info.output.json +1682 -844
  346. package/dist/schemas/wowok_buildin_info.schema.json +576 -526
  347. package/dist/tools/handlers/bridge.d.ts +8 -1
  348. package/dist/tools/handlers/bridge.js +1 -1
  349. package/dist/tools/handlers/config.js +1 -1
  350. package/dist/tools/handlers/employee.d.ts +2 -0
  351. package/dist/tools/handlers/employee.js +1 -0
  352. package/dist/tools/handlers/evaluation.js +1 -1
  353. package/dist/tools/handlers/file-export.js +1 -1
  354. package/dist/tools/handlers/industry-pack.d.ts +2 -0
  355. package/dist/tools/handlers/industry-pack.js +1 -0
  356. package/dist/tools/handlers/onchain.js +1 -1
  357. package/dist/tools/handlers/permission.d.ts +2 -0
  358. package/dist/tools/handlers/permission.js +1 -0
  359. package/dist/tools/handlers/persona.js +1 -1
  360. package/dist/tools/handlers/project.js +1 -1
  361. package/dist/tools/handlers/query.js +1 -1
  362. package/dist/tools/handlers/schema-query.js +1 -1
  363. package/dist/tools/handlers/trust.js +1 -1
  364. package/dist/tools/handlers/wip.js +1 -1
  365. package/dist/tools/handlers/workflow.d.ts +2 -0
  366. package/dist/tools/handlers/workflow.js +1 -0
  367. package/dist/tools/handlers/workspace.d.ts +4 -0
  368. package/dist/tools/handlers/workspace.js +1 -0
  369. package/dist/tools/index.d.ts +2 -1
  370. package/dist/tools/index.js +1 -1
  371. package/dist/tools/rules-hook.d.ts +1 -1
  372. package/dist/tools/rules-hook.js +1 -1
  373. package/dist/tools/shared.d.ts +1 -1
  374. package/dist/tools/shared.js +1 -1
  375. package/dist/tools/types.d.ts +2 -1
  376. package/package.json +4 -5
  377. package/dist/knowledge/arbitration-trust.d.ts +0 -24
  378. package/dist/knowledge/arbitration-trust.js +0 -1
  379. package/dist/schema/call/bridge-handler.d.ts +0 -8
  380. package/dist/schema/call/bridge-handler.js +0 -1
  381. package/dist/schema/sync-layer4.d.ts +0 -21
  382. package/dist/schema/sync-layer4.js +0 -1
  383. /package/dist/{schema-query → schema-query-impl}/index.d.ts +0 -0
@@ -0,0 +1 @@
1
+ export const CATEGORY_MATCH_RULES={'life_service':{'category':'life_service','hard_constraints':[{'field':'bPublished','kind':'truthy','description':'service\x20must\x20be\x20published'},{'field':'bPaused','kind':'falsy','description':'service\x20must\x20not\x20be\x20paused'}],'soft_weights':{'region':0x14,'industry':0xf,'price':0xa,'trust':0x19,'capabilities':0x19,'tags':0x5},'highlight_fields':['service_radius','slot_availability','credential'],'calendar_mode':'slot','geo_mode':'strict','pricing_rules':['time_slot','last_minute']},'retail':{'category':'retail','hard_constraints':[{'field':'bPublished','kind':'truthy','description':'service\x20must\x20be\x20published'},{'field':'bPaused','kind':'falsy','description':'service\x20must\x20not\x20be\x20paused'}],'soft_weights':{'region':0xa,'industry':0xf,'price':0x19,'trust':0xf,'capabilities':0x1e,'tags':0x5},'highlight_fields':['return_policy','logistics_sla','stock'],'calendar_mode':'none','geo_mode':'logistics','pricing_rules':['tiered_quantity','seasonal_float']}};export function resolveCategoryMatchRules(a){if(!a)return undefined;return CATEGORY_MATCH_RULES[a]??CATEGORY_MATCH_RULES[a['toLowerCase']()];}export function listCategoryMatchRules(){return Object['keys'](CATEGORY_MATCH_RULES);}export function registerCategoryMatchRules(a,b=![]){const c=a['category'];if(!c)return![];if(CATEGORY_MATCH_RULES[c]&&!b)return![];return CATEGORY_MATCH_RULES[c]=a,!![];}export function toSoftWeightInjection(a){const b={};for(const [c,d]of Object['entries'](a['soft_weights'])){b[c]={'weight':d};}return{'overrides':{'rules':b}};}export function applyHardConstraints(a,b){const c=[],d=[];for(const e of b){const f=e;let g=!![];for(const h of a['hard_constraints']){const i=f[h['field']];if(i===undefined||i===null)continue;const j=h['kind']==='truthy'?!!i:!i;if(!j){d['push']({'candidate':e,'constraint':h}),g=![];break;}}if(g)c['push'](e);}return{'passed':c,'dropped':d};}
@@ -1 +1 @@
1
- import{REQUIREMENT_PASS_THRESHOLD,effectiveWeight,isDataSourceEnabled,isRuleEnabled,normalizeInjection}from'./user-injection.js';const LEVELS=[{'min':0x55,'level':'low'},{'min':0x46,'level':'medium_low'},{'min':0x32,'level':'medium_high'},{'min':0x0,'level':'high'}];export function levelFromScore(a){for(const b of LEVELS){if(a>=b['min'])return b['level'];}return'high';}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=Array['from'](this['dataSources']['values']())['filter'](m=>appliesTo(m['evaluation_ids'],a))['sort']((m,n)=>(m['priority']??0x0)-(n['priority']??0x0));for(const m of g){if(!isDataSourceEnabled(m['id'],d)){f['push']({'kind':'override','id':m['id'],'detail':'data\x20source\x20disabled\x20by\x20user\x20override'});continue;}if(m['isEnabled']&&!m['isEnabled'](e))continue;const n=await m['extract'](e);Object['assign'](e['facts'],n),f['push']({'kind':'data_source','id':m['id'],'detail':'extracted\x20'+Object['keys'](n)['length']+'\x20fact(s)'});}const h=[],i=[];for(const o of this['rules']['values']()){if(!appliesTo(o['evaluation_ids'],a))continue;if(!isRuleEnabled(o['id'],d)){f['push']({'kind':'override','id':o['id'],'detail':'rule\x20disabled\x20by\x20user\x20override'});continue;}if(o['isEnabled']&&!o['isEnabled'](e))continue;const p=o['evaluate'](e);if(!p)continue;const q=effectiveWeight(o,d);h['push']({'rule_id':o['id'],'dimension':o['dimension'],'score':p['score'],'weight':q,'reason':p['reason'],'matched':p['matched'],'mismatched':p['mismatched'],'red_flag':p['red_flag']}),p['red_flag']&&i['push'](p['reason']??o['id']+'\x20triggered\x20a\x20hard\x20block'),f['push']({'kind':'rule','id':o['id'],'detail':'score='+p['score']+'\x20weight='+q});}const j=aggregateScore(h);let k=i['length']>0x0;for(const r of d['requirements']??[]){const s=h['find'](t=>t['rule_id']===r['rule_id']);if(r['condition']==='require')(!s||s['score']<REQUIREMENT_PASS_THRESHOLD||s['red_flag'])&&(k=!![],i['push'](r['note']??'Requirement\x20requires\x20rule\x20\x27'+r['rule_id']+'\x27\x20to\x20pass'));else r['condition']==='forbid'&&(s&&s['red_flag']&&(k=!![],i['push'](r['note']??'Requirement\x20forbids\x20rule\x20\x27'+r['rule_id']+'\x27\x20from\x20triggering')));}const l=buildSummary(a,j,h,i,k);return{'evaluation_id':a,'total':j,'level':levelFromScore(j),'breakdown':h,'red_flags':i,'blocked':k,'trace':f,'summary':l};}}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';const LEVELS=[{'min':0x55,'level':'low'},{'min':0x46,'level':'medium_low'},{'min':0x32,'level':'medium_high'},{'min':0x0,'level':'high'}];export function levelFromScore(a){for(const b of LEVELS){if(a>=b['min'])return b['level'];}return'high';}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=Array['from'](this['dataSources']['values']())['filter'](m=>appliesTo(m['evaluation_ids'],a))['sort']((m,n)=>(m['priority']??0x0)-(n['priority']??0x0));for(const m of g){if(!isDataSourceEnabled(m['id'],d)){f['push']({'kind':'override','id':m['id'],'detail':'data\x20source\x20disabled\x20by\x20user\x20override'});continue;}if(m['isEnabled']&&!m['isEnabled'](e))continue;const n=await m['extract'](e);Object['assign'](e['facts'],n),f['push']({'kind':'data_source','id':m['id'],'detail':'extracted\x20'+Object['keys'](n)['length']+'\x20fact(s)'});}const h=[],i=[];for(const o of this['rules']['values']()){if(!appliesTo(o['evaluation_ids'],a))continue;if(!isRuleEnabled(o['id'],d)){f['push']({'kind':'override','id':o['id'],'detail':'rule\x20disabled\x20by\x20user\x20override'});continue;}if(o['isEnabled']&&!o['isEnabled'](e))continue;const p=o['evaluate'](e);if(!p)continue;const q=effectiveWeight(o,d);h['push']({'rule_id':o['id'],'dimension':o['dimension'],'score':p['score'],'weight':q,'reason':p['reason'],'matched':p['matched'],'mismatched':p['mismatched'],'red_flag':p['red_flag']}),p['red_flag']&&i['push'](p['reason']??o['id']+'\x20triggered\x20a\x20hard\x20block'),f['push']({'kind':'rule','id':o['id'],'detail':'score='+p['score']+'\x20weight='+q});}const j=aggregateScore(h);let k=i['length']>0x0;for(const r of d['requirements']??[]){const s=h['find'](t=>t['rule_id']===r['rule_id']);if(r['condition']==='require')(!s||s['score']<REQUIREMENT_PASS_THRESHOLD||s['red_flag'])&&(k=!![],i['push'](r['note']??'Requirement\x20requires\x20rule\x20\x27'+r['rule_id']+'\x27\x20to\x20pass'));else r['condition']==='forbid'&&(s&&s['red_flag']&&(k=!![],i['push'](r['note']??'Requirement\x20forbids\x20rule\x20\x27'+r['rule_id']+'\x27\x20from\x20triggering')));}const l=e['facts']['summary']??buildSummary(a,j,h,i,k);return{'evaluation_id':a,'total':j,'level':levelFromScore(j),'breakdown':h,'red_flags':i,'blocked':k,'trace':f,'summary':l,'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{parseRegion}from'./region.js';import{findSimilarIndustries,inferTraitsFromDescription}from'../knowledge/industry-generalizer.js';const BUILTIN_SCENARIOS=['freelance','rental','education','travel','subscription','retail'];function enrichFromDescription(a){const b=a?.['trim']();if(!b)return{'industry':'general','industry_confidence':0x0,'tags':[],'keywords':[]};const {traits:c,confidence:d,matched_keywords:e}=inferTraitsFromDescription(b),f=findSimilarIndustries(c,0x3),g=f[0x0],h=g&&BUILTIN_SCENARIOS['includes'](g['industry'])?g['industry']:'general',i=e['length']>0x0||(g?.['similarity']??0x0)>0.2;return{'industry':i?h:'general','industry_confidence':i?Math['max'](d,g?.['similarity']??0x0):0x0,'tags':i?f['slice'](0x0,0x3)['map'](j=>j['industry']):[],'keywords':e};}export function extractServiceCapability(a,b){const c=a['sales']??[],d=c['map'](j=>toBigInt(j['price']))['filter'](j=>j!==undefined),e=a['arbitrations']??[],f=toBigInt(a['compensation_fund'])??0x0n,g=enrichFromDescription(a['description']),h={'has_arbitration':e['length']>0x0,'has_refund_path':e['length']>0x0&&f>0x0n,'has_milestone_nodes':![],'has_compensation_fund':f>0x0n,'has_wip_verification':c['some'](j=>!!j['wip_hash']),'has_messenger':a['um']!=null,'has_buy_guard':a['buy_guard']!=null,'has_dynamic_pricing':![],'is_published':a['bPublished']===!![],'is_paused':a['bPaused']===!![]},i={'id':a['object'],'kind':'service','owner':a['owner']??'','industry':g['industry'],'industry_confidence':g['industry_confidence'],'region':parseRegion(a['location']),'price_min':d['length']>0x0?minBigInt(d):undefined,'price_max':d['length']>0x0?maxBigInt(d):undefined,'token_type':'','ticket_size':'medium','trust_score':0x32,'reputation_like_ratio':0x1,'arbitration_independent':![],'merchant_history_count':0x0,'capabilities':h,'tags':g['tags'],'keywords':g['keywords']};return{...i,...b};}export function extractDemandCapability(a,b){const c=enrichFromDescription(a['description']),d={'id':a['object'],'kind':'demand','owner':a['owner']??'','industry':c['industry'],'industry_confidence':c['industry_confidence'],'region':parseRegion(a['location']),'price_min':undefined,'price_max':undefined,'token_type':'','ticket_size':'medium','trust_score':0x32,'reputation_like_ratio':0x1,'arbitration_independent':![],'merchant_history_count':0x0,'capabilities':{'has_arbitration':![],'has_refund_path':![],'has_milestone_nodes':![],'has_compensation_fund':![],'has_wip_verification':![],'has_messenger':a['um']!=null,'has_buy_guard':![],'has_dynamic_pricing':![],'is_published':!![],'is_paused':![]},'tags':c['tags'],'keywords':c['keywords']};return{...d,...b};}function toBigInt(a){if(a===undefined||a===null)return undefined;try{return BigInt(a);}catch{return undefined;}}function minBigInt(a){return a['reduce']((c,d)=>c<d?c:d);}function maxBigInt(a){return a['reduce']((c,d)=>c>d?c:d);}
1
+ import{parseRegion}from'./region.js';import{findSimilarIndustries,inferTraitsFromDescription}from'../knowledge/industry-generalizer.js';const BUILTIN_SCENARIOS=['freelance','rental','education','travel','subscription','retail'];function enrichFromDescription(a){const b=a?.['trim']();if(!b)return{'industry':'general','industry_confidence':0x0,'tags':[],'keywords':[]};const {traits:c,confidence:d,matched_keywords:e}=inferTraitsFromDescription(b),f=findSimilarIndustries(c,0x3),g=f[0x0],h=g&&BUILTIN_SCENARIOS['includes'](g['industry'])?g['industry']:'general',i=e['length']>0x0||(g?.['similarity']??0x0)>0.2;return{'industry':i?h:'general','industry_confidence':i?Math['max'](d,g?.['similarity']??0x0):0x0,'tags':i?f['slice'](0x0,0x3)['map'](j=>j['industry']):[],'keywords':e};}export function extractServiceCapability(a,b){const c=a['sales']??[],d=c['map'](j=>toBigInt(j['price']))['filter'](j=>j!==undefined),e=a['arbitrations']??[],f=toBigInt(a['compensation_fund'])??0x0n,g=enrichFromDescription(a['description']),h={'has_arbitration':e['length']>0x0,'has_refund_path':e['length']>0x0&&f>0x0n,'has_milestone_nodes':a['machine']!=null,'has_compensation_fund':f>0x0n,'has_wip_verification':c['some'](j=>!!j['wip_hash']),'has_messenger':a['um']!=null,'has_buy_guard':a['buy_guard']!=null,'has_dynamic_pricing':![],'is_published':a['bPublished']===!![],'is_paused':a['bPaused']===!![]},i={'id':a['object'],'kind':'service','owner':a['owner']??'','industry':g['industry'],'industry_confidence':g['industry_confidence'],'region':parseRegion(a['location']),'price_min':d['length']>0x0?minBigInt(d):undefined,'price_max':d['length']>0x0?maxBigInt(d):undefined,'token_type':'','ticket_size':'medium','trust_score':0x32,'reputation_like_ratio':0x1,'arbitration_independent':![],'merchant_history_count':0x0,'capabilities':h,'tags':g['tags'],'keywords':g['keywords']};return{...i,...b};}export function extractDemandCapability(a,b){const c=enrichFromDescription(a['description']),d={'id':a['object'],'kind':'demand','owner':a['owner']??'','industry':c['industry'],'industry_confidence':c['industry_confidence'],'region':parseRegion(a['location']),'price_min':undefined,'price_max':undefined,'token_type':'','ticket_size':'medium','trust_score':0x32,'reputation_like_ratio':0x1,'arbitration_independent':![],'merchant_history_count':0x0,'capabilities':{'has_arbitration':![],'has_refund_path':![],'has_milestone_nodes':![],'has_compensation_fund':![],'has_wip_verification':![],'has_messenger':a['um']!=null,'has_buy_guard':![],'has_dynamic_pricing':![],'is_published':!![],'is_paused':![]},'tags':c['tags'],'keywords':c['keywords']};return{...d,...b};}function toBigInt(a){if(a===undefined||a===null)return undefined;try{return BigInt(a);}catch{return undefined;}}function minBigInt(a){return a['reduce']((c,d)=>c<d?c:d);}function maxBigInt(a){return a['reduce']((c,d)=>c>d?c:d);}
@@ -8,5 +8,6 @@ export * from "./composer.js";
8
8
  export * from "./game-strategy.js";
9
9
  export * from "./node-game.js";
10
10
  export * from "./arbitration-game.js";
11
+ export * from "./path-reasoning.js";
11
12
  export * from "./builtins/index.js";
12
13
  export { EvaluationEngine, getEvaluationEngine, levelFromScore } from "./engine.js";
@@ -1 +1 @@
1
- export*from'./types.js';export*from'./user-injection.js';export*from'./region.js';export*from'./capability.js';export*from'./extract.js';export*from'./gap.js';export*from'./composer.js';export*from'./game-strategy.js';export*from'./node-game.js';export*from'./arbitration-game.js';export*from'./builtins/index.js';export{EvaluationEngine,getEvaluationEngine,levelFromScore}from'./engine.js';
1
+ export*from'./types.js';export*from'./user-injection.js';export*from'./region.js';export*from'./capability.js';export*from'./extract.js';export*from'./gap.js';export*from'./composer.js';export*from'./game-strategy.js';export*from'./node-game.js';export*from'./arbitration-game.js';export*from'./path-reasoning.js';export*from'./builtins/index.js';export{EvaluationEngine,getEvaluationEngine,levelFromScore}from'./engine.js';
@@ -0,0 +1,42 @@
1
+ import { type RegionRelation } from "./region.js";
2
+ export type LocationSensitivity = "strict" | "near" | "logistics";
3
+ export interface RegionEnrichment {
4
+ country?: string;
5
+ province?: string;
6
+ city?: string;
7
+ }
8
+ export type LocationInput = string | ({
9
+ raw: string;
10
+ } & RegionEnrichment);
11
+ export interface LocationGateResult {
12
+ relation: RegionRelation;
13
+ satisfied: boolean;
14
+ score: number;
15
+ reason: string;
16
+ }
17
+ export interface ServiceLocationInput {
18
+ id: string;
19
+ name?: string;
20
+ location?: LocationInput;
21
+ }
22
+ export interface RankedServiceLocation {
23
+ id: string;
24
+ name?: string;
25
+ location?: string;
26
+ relation: RegionRelation;
27
+ satisfied: boolean;
28
+ score: number;
29
+ reason: string;
30
+ }
31
+ export interface ScopeExpansionAdvice {
32
+ sensitivity: LocationSensitivity;
33
+ search_terms: string[];
34
+ ai_enrichment_note: string;
35
+ }
36
+ export declare function gateLocation(sensitivity: LocationSensitivity, demandLocation: LocationInput, serviceLocation: LocationInput | undefined): LocationGateResult;
37
+ export declare function rankByLocation(sensitivity: LocationSensitivity, demandLocation: LocationInput, services: ServiceLocationInput[]): RankedServiceLocation[];
38
+ export declare function expandSearchScope(sensitivity: LocationSensitivity, demandLocation: LocationInput): ScopeExpansionAdvice;
39
+ export declare function inferSensitivity(description: string): {
40
+ sensitivity: LocationSensitivity;
41
+ signals: string[];
42
+ };
@@ -0,0 +1 @@
1
+ import{parseRegion,relateRegion}from'./region.js';function toRegion(a){if(a===undefined)return parseRegion('');if(typeof a==='string')return parseRegion(a);const b=parseRegion(a['raw']);return{...b,'country':a['country']??b['country'],'province':a['province']??b['province'],'city':a['city']??b['city']};}export function gateLocation(a,b,c){const d=toRegion(b),e=toRegion(c);if(!d['raw']?.['trim']())return{'relation':'mismatch','satisfied':a!=='strict','score':0.5,'reason':'No\x20demand-side\x20location\x20stated\x20—\x20location\x20is\x20not\x20discriminating;\x20other\x20dimensions\x20decide.'};if(!e['raw']?.['trim']())return{'relation':'mismatch','satisfied':a!=='strict','score':a==='strict'?0x0:0.3,'reason':a==='strict'?'Service\x20has\x20NO\x20location\x20set\x20—\x20merchant\x20location\x20hygiene\x20issue;\x20excluded\x20under\x20strict\x20sensitivity.':'Service\x20has\x20no\x20location\x20set\x20—\x20kept\x20(soft\x20signal)\x20because\x20sensitivity\x20is\x20not\x20strict.'};const f=relateRegion(d,e),{satisfied:g,score:h,reason:i}=judge(a,f);return{'relation':f,'satisfied':g,'score':h,'reason':i};}function judge(a,b){switch(b){case'exact':return{'satisfied':!![],'score':0x1,'reason':'Location\x20exact\x20match.'};case'contains':return{'satisfied':!![],'score':0.9,'reason':'Location\x20containment\x20match\x20(one\x20region\x20covers\x20the\x20other).'};case'overlap':if(a==='strict')return{'satisfied':![],'score':0.4,'reason':'Same\x20province\x20but\x20different\x20city\x20—\x20fails\x20the\x20100%\x20location\x20gate\x20(strict).\x20Consider\x20\x27near\x27\x20sensitivity\x20to\x20accept\x20neighboring\x20cities.'};return{'satisfied':!![],'score':0.6,'reason':'Neighboring\x20city\x20within\x20the\x20same\x20province\x20—\x20accepted\x20(near/logistics).'};case'compatible':return{'satisfied':!![],'score':0.8,'reason':'Remote\x20service\x20serves\x20any\x20physical\x20region\x20(or\x20vice\x20versa).'};case'mismatch':default:return{'satisfied':a==='logistics','score':0x0,'reason':a==='logistics'?'Region\x20mismatch\x20—\x20soft\x20warning\x20only\x20(goods\x20can\x20ship\x20via\x20logistics).':'Region\x20mismatch\x20—\x20excluded\x20under\x20strict/near\x20sensitivity.'};}}export function rankByLocation(a,b,c){return c['map'](d=>{const e=gateLocation(a,b,d['location']);return{'id':d['id'],'name':d['name'],'location':typeof d['location']==='string'?d['location']:d['location']?.['raw'],'relation':e['relation'],'satisfied':e['satisfied'],'score':e['score'],'reason':e['reason']};})['sort']((d,e)=>{if(d['satisfied']!==e['satisfied'])return d['satisfied']?-0x1:0x1;if(e['score']!==d['score'])return e['score']-d['score'];return 0x0;});}export function expandSearchScope(a,b){const c=toRegion(b),d=c['city']?.['trim'](),e=c['province']?.['trim']();if(a==='strict')return{'sensitivity':a,'search_terms':d?[d]:[c['raw']]['filter'](Boolean),'ai_enrichment_note':'Strict:\x20do\x20NOT\x20widen\x20geographically.\x20If\x20nothing\x20matches,\x20report\x20honestly\x20and\x20suggest\x20switching\x20sensitivity\x20to\x20\x27near\x27\x20(user\x20decision)\x20instead\x20of\x20silently\x20expanding.'};if(a==='near'){const f=[c['raw'],d,e]['filter'](Boolean);return{'sensitivity':a,'search_terms':f,'ai_enrichment_note':'Near:\x20AI\x20enriches\x20neighboring\x20cities\x20of\x20the\x20demand\x20city\x20from\x20public\x20web\x20data\x20(authoritative\x20preferred),\x20confirms\x20the\x20list\x20with\x20the\x20user,\x20then\x20re-runs\x20discovery\x20with\x20the\x20expanded\x20terms.'};}return{'sensitivity':a,'search_terms':[c['raw'],e,'remote','online','nationwide','china','global']['filter'](Boolean),'ai_enrichment_note':'Logistics:\x20location\x20is\x20a\x20soft\x20signal.\x20Enumerate\x20broadly\x20(nationwide/remote\x20services),\x20rank\x20by\x20location\x20fit,\x20but\x20let\x20price/trust/tags\x20dominate\x20the\x20final\x20recommendation.'};}const ON_SITE_EN=/\b(hotel|accommodation|restaurant|dining|gym)\b/,ON_SITE_CJK=['民宿','酒店','餐厅','健身房'],LOGISTICS_EN=/\b(shipping|delivery|ship to home|mail)\b/,LOGISTICS_CJK=['快递','物流','邮寄','配送到家'],REMOTE_EN=/\b(online|remote)\b/,REMOTE_CJK=['在线','远程'],hits=(a,b,c)=>b['test'](a)||c['some'](d=>a['includes'](d));export function inferSensitivity(a){const b=(a??'')['toLowerCase'](),c=[];hits(b,ON_SITE_EN,ON_SITE_CJK)&&c['push']('on-site\x20consumption');hits(b,LOGISTICS_EN,LOGISTICS_CJK)&&c['push']('physical\x20logistics');hits(b,REMOTE_EN,REMOTE_CJK)&&c['push']('remote\x20service');if(c['includes']('on-site\x20consumption')&&!c['includes']('physical\x20logistics'))return{'sensitivity':'strict','signals':c};if(c['includes']('physical\x20logistics'))return{'sensitivity':'logistics','signals':c};if(c['includes']('remote\x20service'))return{'sensitivity':'near','signals':c};return{'sensitivity':'near','signals':c['length']?c:['no\x20explicit\x20signal\x20—\x20defaulted\x20to\x20near']};}
@@ -0,0 +1,35 @@
1
+ import type { CommercialRole } from "../role/types.js";
2
+ import type { RadarMachineNode, NodeAnnotations } from "../participation/radar-core.js";
3
+ import { type RiskAppetite } from "./game-strategy.js";
4
+ export interface WorkflowPath {
5
+ id: string;
6
+ nodes: string[];
7
+ forwards: string[];
8
+ terminal: "completed" | "refunded" | "open";
9
+ guard_gates: number;
10
+ length: number;
11
+ terminal_value: number;
12
+ gain_score: number;
13
+ risk_score: number;
14
+ score: number;
15
+ rationale: string;
16
+ }
17
+ export interface PathReasoningInput {
18
+ current_node: string;
19
+ perspective: CommercialRole;
20
+ machine_nodes: RadarMachineNode[];
21
+ node_annotations?: NodeAnnotations;
22
+ appetite?: RiskAppetite;
23
+ requirements?: string[];
24
+ order_amount?: string;
25
+ max_depth?: number;
26
+ }
27
+ export interface PathReasoningAdvice {
28
+ current_node: string;
29
+ perspective: CommercialRole;
30
+ ranked_paths: WorkflowPath[];
31
+ optimal_path?: WorkflowPath;
32
+ foregone_terminals: string[];
33
+ summary: string;
34
+ }
35
+ export declare function evaluatePathReasoning(input: PathReasoningInput): PathReasoningAdvice;
@@ -0,0 +1 @@
1
+ import{evaluateOutcome}from'./game-strategy.js';const DEFAULT_COMPLETED=['completed','done','finished','received','finalized','active','accepted'],DEFAULT_REFUNDED=['refunded','refund','cancelled','canceled','disputed','expired'];function terminalNames(a){return{'completed':a?.['completed']?.['length']?a['completed']:DEFAULT_COMPLETED,'refunded':a?.['refunded']?.['length']?a['refunded']:DEFAULT_REFUNDED};}function isTerminal(a,b,c){const d=a['toLowerCase']();if(b['some'](e=>d===e['toLowerCase']()||d['includes'](e['toLowerCase']())))return'completed';if(c['some'](e=>d===e['toLowerCase']()||d['includes'](e['toLowerCase']())))return'refunded';return null;}function buildAdjacency(a){const b=new Map();for(const c of a){for(const d of c['pairs']??[]){const e=d['prev_node']||'';if(!b['has'](e))b['set'](e,[]);b['get'](e)['push']({'to_node':c['name'],'threshold':d['threshold'],'forwards':(d['forwards']??[])['map'](g=>({'name':g['name'],'guard':g['guard'],'weight':g['weight']}))});}}return b;}function enumeratePaths(a,b,c,d,e){const f=[],g=(h,i,j)=>{if(i['length']>0x0){const l=isTerminal(h,c,d);if(l){f['push']({'nodes':i['map'](m=>m['node']),'forwards':i['map'](m=>m['forward']),'terminal':l,'guard_gates':i['filter'](m=>m['guard'])['length']});return;}}if(i['length']>=e){f['push']({'nodes':i['map'](m=>m['node']),'forwards':i['map'](m=>m['forward']),'terminal':'open','guard_gates':i['filter'](m=>m['guard'])['length']});return;}const k=a['get'](h)??[];if(k['length']===0x0&&i['length']>0x0){f['push']({'nodes':i['map'](m=>m['node']),'forwards':i['map'](m=>m['forward']),'terminal':'open','guard_gates':i['filter'](m=>m['guard'])['length']});return;}for(const m of k){if(j['has'](m['to_node']))continue;for(const n of m['forwards']){const o=new Set(j);o['add'](m['to_node']),g(m['to_node'],[...i,{'node':m['to_node'],'forward':n['name'],'guard':!!n['guard']}],o);}}};return g(b,[],new Set([b])),f;}function terminalScore(a,b,c){const d=a==='refunded'?'refund':a==='completed'?'completion':'advance',e=evaluateOutcome(d,b,c);return{'net':e['net_score'],'gain':e['gain_score'],'risk':e['risk_score']};}const LENGTH_COST=0x4,GATE_COST=0x5;export function evaluatePathReasoning(a){const {current_node:b,perspective:c,machine_nodes:d,node_annotations:e,appetite:f,requirements:g}=a,h=a['max_depth']??0xc,{completed:i,refunded:j}=terminalNames(e),k=buildAdjacency(d),l=f||g?.['length']?{'risk_appetite':f,'requirements':g}:undefined,m=enumeratePaths(k,b,i,j,h),n=m['map'](u=>{const v=terminalScore(u['terminal'],c,l),w=u['forwards']['length'],x=w*LENGTH_COST,y=u['guard_gates']*GATE_COST,z=Math['max'](0x0,Math['min'](0x64,v['net']-x-y));return{'id':[b,...u['nodes']]['join']('→'),'nodes':u['nodes'],'forwards':u['forwards'],'terminal':u['terminal'],'guard_gates':u['guard_gates'],'length':w,'terminal_value':v['net'],'gain_score':v['gain'],'risk_score':v['risk'],'score':z,'rationale':'terminal='+u['terminal']+'\x20value='+v['net']+'/100;\x20'+w+'\x20step(s),\x20'+u['guard_gates']+'\x20guard\x20gate(s)\x20(−'+(x+y)+')'};});n['sort']((t,u)=>{const v=t['terminal']==='open'?0x1:0x0,w=u['terminal']==='open'?0x1:0x0;if(v!==w)return v-w;return u['score']-t['score'];});const o=n['length']>0x0&&n[0x0]['terminal']!=='open'?n[0x0]:undefined,p=o?.['terminal'],q=new Set(n['filter'](t=>t['terminal']!=='open')['map'](t=>t['terminal']));q['delete'](p);const r=o?Array['from'](q):[];let s;return!o?s='No\x20terminal\x20path\x20reachable\x20from\x20\x27'+(b||'(entry)')+'\x27\x20—\x20workflow\x20may\x20be\x20stuck\x20or\x20unannotated.':(s='Optimal\x20path\x20for\x20'+c+':\x20'+o['id']+'\x20→\x20'+o['terminal']+'\x20(score\x20'+o['score']+'/100,\x20'+o['length']+'\x20step(s),\x20'+o['guard_gates']+'\x20guard\x20gate(s))',r['length']>0x0&&(s+='\x20—\x20choosing\x20it\x20foregoes\x20'+r['join']('/')+'\x20(opportunity\x20competition:\x20your\x20gain\x20may\x20close\x20another\x20outcome).')),{'current_node':b,'perspective':c,'ranked_paths':n,'optimal_path':o,'foregone_terminals':r,'summary':s};}
@@ -7,4 +7,10 @@ export interface Region {
7
7
  }
8
8
  export type RegionRelation = "exact" | "contains" | "overlap" | "compatible" | "mismatch";
9
9
  export declare function parseRegion(raw: string): Region;
10
+ export interface RegionValidation {
11
+ region: Region;
12
+ valid: boolean;
13
+ reminder?: string;
14
+ }
15
+ export declare function validateRegionInput(raw: string): RegionValidation;
10
16
  export declare function relateRegion(a: Region, b: Region): RegionRelation;
@@ -1 +1 @@
1
- const REMOTE_KEYWORDS=['remote','online','anywhere'];export function parseRegion(a){const b=a?.['trim']()??'',c=b['toLowerCase'](),d=REMOTE_KEYWORDS['some'](e=>c['includes'](e));if(d)return{'mode':'remote','raw':b};return{'mode':'physical','raw':b};}export function relateRegion(c,d){if(c['mode']==='remote'||d['mode']==='remote')return'compatible';const e=normalizePhysical(c['raw']),f=normalizePhysical(d['raw']);if(!e||!f)return'mismatch';if(e===f)return'exact';if(e['includes'](f)||f['includes'](e))return'contains';if(c['province']&&d['province']&&c['province']===d['province'])return'overlap';return'mismatch';}function normalizePhysical(a){return a['trim']()['toLowerCase']()['replace'](/\s+/g,'');}
1
+ const REMOTE_KEYWORDS=['remote','online','anywhere'];export function parseRegion(a){const b=a?.['trim']()??'',c=b['toLowerCase'](),d=REMOTE_KEYWORDS['some'](e=>c['includes'](e));if(d)return{'mode':'remote','raw':b};return{'mode':'physical','raw':b};}export function validateRegionInput(a){const b=parseRegion(a),c=a?.['trim']()??'';if(!c)return{'region':b,'valid':![],'reminder':'Location\x20is\x20empty\x20—\x20provide\x20a\x20city/region\x20or\x20\x27remote\x27.'};if(b['mode']==='physical'&&!b['country']&&!b['city'])return{'region':b,'valid':!![],'reminder':'Physical\x20location\x20not\x20yet\x20resolved\x20to\x20country/city\x20—\x20AI\x20enrichment\x20will\x20resolve\x20it;\x20confirm\x20or\x20add\x20a\x20city.'};return{'region':b,'valid':!![]};}export function relateRegion(c,d){if(c['mode']==='remote'||d['mode']==='remote')return'compatible';const e=normalizePhysical(c['raw']),f=normalizePhysical(d['raw']);if(!e||!f)return'mismatch';if(e===f)return'exact';if(e['includes'](f)||f['includes'](e))return'contains';if(c['province']&&d['province']&&c['province']===d['province'])return'overlap';return'mismatch';}function normalizePhysical(a){return a['trim']()['toLowerCase']()['replace'](/\s+/g,'');}
@@ -65,6 +65,18 @@ export interface EvaluationTraceEntry {
65
65
  id: string;
66
66
  detail: string;
67
67
  }
68
+ export interface CriterionScore {
69
+ name: string;
70
+ score: number;
71
+ weight: number;
72
+ rationale: string;
73
+ }
74
+ export interface EvaluationFinding {
75
+ criterion: string;
76
+ severity: "critical" | "warning" | "info";
77
+ message: string;
78
+ deduction: number;
79
+ }
68
80
  export interface EvaluationResult {
69
81
  evaluation_id: string;
70
82
  total: number;
@@ -74,4 +86,9 @@ export interface EvaluationResult {
74
86
  blocked: boolean;
75
87
  trace: EvaluationTraceEntry[];
76
88
  summary: string;
89
+ criterionScores?: CriterionScore[];
90
+ findings?: EvaluationFinding[];
91
+ strengths?: string[];
92
+ needsLlm?: boolean;
93
+ llmPrompt?: string;
77
94
  }
@@ -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 a32a}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(a32a('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 a37a}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(a37a('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);}
@@ -9,7 +9,7 @@ export interface PurchaseOutcomeInput {
9
9
  }
10
10
  export declare function recordPurchaseOutcome(input: PurchaseOutcomeInput): void;
11
11
  export declare function getBuyerSignals(): BuyerSignals;
12
- export declare function updateFromOperation(intent: string, scenario: string | undefined, outcome: "success" | "failed" | "partial", errorCode: string | undefined, referencedObjects: string[]): void;
12
+ export declare function updateFromOperation(_intent: string, scenario: string | undefined, outcome: "success" | "failed" | "partial", errorCode: string | undefined, referencedObjects: string[]): void;
13
13
  export declare function resetProfile(): void;
14
14
  export declare function getProfileStats(): {
15
15
  total_operations: number;
@@ -10,3 +10,9 @@ export { MetricRegistry, getMetricRegistry, BUILTIN_METRICS_COUNT, } from "./met
10
10
  export { ConstraintRegistry, getConstraintRegistry, BUILTIN_CONSTRAINTS_COUNT, } from "./constraint-registry.js";
11
11
  export { ModeEvaluator } from "./mode-evaluator.js";
12
12
  export { BUILTIN_MODES } from "./modes.js";
13
+ export { registerIndustryPack, validatePackManifest, listRegisteredPacks, unregisterIndustryPack, scanPacks, rescanPack, resolveIndustryPackDir, scanDefaultIndustryPacks, scaffoldIndustryPack, seedBuiltinIndustryTemplates, diffIndustryPack, resetIndustryPath, readMergedPackIfPresent, buildPristineMergedPack, locatePackAndRemainder, ensureIndustryReadme, industryReadmeContent, } from "./industry-pack.js";
14
+ export type { IndustryPackManifest, IndustryPack, IndustryPackLayout, MergedIndustryPack, PackValidation, PackRegistrationResult, PackRecord, ScaffoldResult, PackDiffResult, ResetResult, } from "./industry-pack.js";
15
+ export { registerDisputeRules, registerComplianceRules, registerSupplyRules, registerIndustryRules, registerIndustryPlaybook, resolveDisputeRules, resolveComplianceRules, resolveSupplyRules, resolveIndustryRules, resolveIndustryPlaybook, listRegisteredDisputeCategories, listRegisteredComplianceCategories, listRegisteredSupplyCategories, listRegisteredIndustryRuleCategories, listRegisteredPlaybookCategories, compileIndustryRule, compileIndustryRules, registerIndustryRulesToEngine, unregisterIndustryRulesFromEngine, } from "./industry-layers.js";
16
+ export type { DisputeSlaTier, IndustryDisputeRules, ComplianceRules, SupplyRules, IndustryRule, IndustryRuleCondition, IndustryRuleOperator, IndustryRules, IndustryPlaybook, } from "./industry-layers.js";
17
+ export { registerIndustryPersonae, getIndustryPersona, listPersonaeIndustries, unregisterIndustryPersonae, } from "../persona/pack-personae.js";
18
+ export type { IndustryPersona } from "../persona/pack-personae.js";
@@ -1 +1 @@
1
- export{CapabilityRegistry,getCapabilityRegistry,recordCapabilitiesUsed,CAPABILITY_MANIFEST_VERSION}from'./capability-manifest.js';export{IndustryModeRegistry,getIndustryModeRegistry,INDUSTRY_MODE_REGISTRY_VERSION}from'./registry.js';export{MetricRegistry,getMetricRegistry,BUILTIN_METRICS_COUNT}from'./metric-registry.js';export{ConstraintRegistry,getConstraintRegistry,BUILTIN_CONSTRAINTS_COUNT}from'./constraint-registry.js';export{ModeEvaluator}from'./mode-evaluator.js';export{BUILTIN_MODES}from'./modes.js';
1
+ export{CapabilityRegistry,getCapabilityRegistry,recordCapabilitiesUsed,CAPABILITY_MANIFEST_VERSION}from'./capability-manifest.js';export{IndustryModeRegistry,getIndustryModeRegistry,INDUSTRY_MODE_REGISTRY_VERSION}from'./registry.js';export{MetricRegistry,getMetricRegistry,BUILTIN_METRICS_COUNT}from'./metric-registry.js';export{ConstraintRegistry,getConstraintRegistry,BUILTIN_CONSTRAINTS_COUNT}from'./constraint-registry.js';export{ModeEvaluator}from'./mode-evaluator.js';export{BUILTIN_MODES}from'./modes.js';export{registerIndustryPack,validatePackManifest,listRegisteredPacks,unregisterIndustryPack,scanPacks,rescanPack,resolveIndustryPackDir,scanDefaultIndustryPacks,scaffoldIndustryPack,seedBuiltinIndustryTemplates,diffIndustryPack,resetIndustryPath,readMergedPackIfPresent,buildPristineMergedPack,locatePackAndRemainder,ensureIndustryReadme,industryReadmeContent}from'./industry-pack.js';export{registerDisputeRules,registerComplianceRules,registerSupplyRules,registerIndustryRules,registerIndustryPlaybook,resolveDisputeRules,resolveComplianceRules,resolveSupplyRules,resolveIndustryRules,resolveIndustryPlaybook,listRegisteredDisputeCategories,listRegisteredComplianceCategories,listRegisteredSupplyCategories,listRegisteredIndustryRuleCategories,listRegisteredPlaybookCategories,compileIndustryRule,compileIndustryRules,registerIndustryRulesToEngine,unregisterIndustryRulesFromEngine}from'./industry-layers.js';export{registerIndustryPersonae,getIndustryPersona,listPersonaeIndustries,unregisterIndustryPersonae}from'../persona/pack-personae.js';
@@ -0,0 +1,75 @@
1
+ import type { EvaluationRule } from "../evaluation/types.js";
2
+ export interface DisputeSlaTier {
3
+ level: string;
4
+ timeout?: string;
5
+ description?: string;
6
+ }
7
+ export interface IndustryDisputeRules {
8
+ category: string;
9
+ sla_tiers?: DisputeSlaTier[];
10
+ expert_sla?: {
11
+ qualification_required?: boolean;
12
+ description?: string;
13
+ };
14
+ fault_rules?: string[];
15
+ }
16
+ export interface ComplianceRules {
17
+ jurisdiction?: string;
18
+ category: string;
19
+ refund_window?: {
20
+ days?: number;
21
+ not_applicable?: boolean;
22
+ description?: string;
23
+ };
24
+ prepay_mode?: string;
25
+ qualification?: string[];
26
+ disclosure?: string[];
27
+ }
28
+ export interface SupplyRules {
29
+ category: string;
30
+ supplier_qualification?: string[];
31
+ first_order_policy?: string;
32
+ redundancy_required?: boolean;
33
+ }
34
+ export interface IndustryRule {
35
+ rule_id: string;
36
+ dimension?: string;
37
+ description: string;
38
+ severity?: "hard" | "soft";
39
+ red_flag?: boolean;
40
+ condition_hint?: string;
41
+ condition?: IndustryRuleCondition;
42
+ }
43
+ export type IndustryRuleOperator = "truthy" | "falsy" | "missing" | "present" | "eq" | "neq";
44
+ export interface IndustryRuleCondition {
45
+ field: string;
46
+ op: IndustryRuleOperator;
47
+ value?: unknown;
48
+ }
49
+ export interface IndustryRules {
50
+ category: string;
51
+ rules: IndustryRule[];
52
+ }
53
+ export interface IndustryPlaybook {
54
+ category: string;
55
+ content: string;
56
+ }
57
+ export declare function registerDisputeRules(rules: IndustryDisputeRules, replace?: boolean): boolean;
58
+ export declare function registerComplianceRules(rules: ComplianceRules, replace?: boolean): boolean;
59
+ export declare function registerSupplyRules(rules: SupplyRules, replace?: boolean): boolean;
60
+ export declare function registerIndustryRules(rules: IndustryRules, replace?: boolean): boolean;
61
+ export declare function registerIndustryPlaybook(playbook: IndustryPlaybook, replace?: boolean): boolean;
62
+ export declare function resolveDisputeRules(category?: string): IndustryDisputeRules | undefined;
63
+ export declare function resolveComplianceRules(category?: string): ComplianceRules | undefined;
64
+ export declare function resolveSupplyRules(category?: string): SupplyRules | undefined;
65
+ export declare function resolveIndustryRules(category?: string): IndustryRules | undefined;
66
+ export declare function resolveIndustryPlaybook(category?: string): IndustryPlaybook | undefined;
67
+ export declare function listRegisteredDisputeCategories(): string[];
68
+ export declare function listRegisteredComplianceCategories(): string[];
69
+ export declare function listRegisteredSupplyCategories(): string[];
70
+ export declare function listRegisteredIndustryRuleCategories(): string[];
71
+ export declare function listRegisteredPlaybookCategories(): string[];
72
+ export declare function compileIndustryRule(category: string, rule: IndustryRule): EvaluationRule | null;
73
+ export declare function compileIndustryRules(rules: IndustryRules): EvaluationRule[];
74
+ export declare function registerIndustryRulesToEngine(rules: IndustryRules): number;
75
+ export declare function unregisterIndustryRulesFromEngine(category: string): number;
@@ -0,0 +1 @@
1
+ import{getEvaluationEngine}from'../evaluation/engine.js';const disputeRules=new Map(),complianceRules=new Map(),supplyRules=new Map(),industryRules=new Map(),playbooks=new Map();function keyOf(a){return a['toLowerCase']();}export function registerDisputeRules(a,b=![]){const c=keyOf(a['category']);if(!c)return![];if(disputeRules['has'](c)&&!b)return![];return disputeRules['set'](c,a),!![];}export function registerComplianceRules(a,b=![]){const c=keyOf(a['category']);if(!c)return![];if(complianceRules['has'](c)&&!b)return![];return complianceRules['set'](c,a),!![];}export function registerSupplyRules(a,b=![]){const c=keyOf(a['category']);if(!c)return![];if(supplyRules['has'](c)&&!b)return![];return supplyRules['set'](c,a),!![];}export function registerIndustryRules(a,b=![]){const c=keyOf(a['category']);if(!c)return![];if(industryRules['has'](c)&&!b)return![];return industryRules['set'](c,a),!![];}export function registerIndustryPlaybook(a,b=![]){const c=keyOf(a['category']);if(!c)return![];if(playbooks['has'](c)&&!b)return![];return playbooks['set'](c,a),!![];}export function resolveDisputeRules(a){if(!a)return undefined;return disputeRules['get'](keyOf(a));}export function resolveComplianceRules(a){if(!a)return undefined;return complianceRules['get'](keyOf(a));}export function resolveSupplyRules(a){if(!a)return undefined;return supplyRules['get'](keyOf(a));}export function resolveIndustryRules(a){if(!a)return undefined;return industryRules['get'](keyOf(a));}export function resolveIndustryPlaybook(a){if(!a)return undefined;return playbooks['get'](keyOf(a));}export function listRegisteredDisputeCategories(){return Array['from'](disputeRules['keys']());}export function listRegisteredComplianceCategories(){return Array['from'](complianceRules['keys']());}export function listRegisteredSupplyCategories(){return Array['from'](supplyRules['keys']());}export function listRegisteredIndustryRuleCategories(){return Array['from'](industryRules['keys']());}export function listRegisteredPlaybookCategories(){return Array['from'](playbooks['keys']());}function lookupFact(a,b){if(b in a['facts'])return a['facts'][b];if(b in a['entities'])return a['entities'][b];return undefined;}function evaluateCondition(a,b){const c=lookupFact(b,a['field']);switch(a['op']){case'truthy':return!!c;case'falsy':return!c;case'missing':return c===undefined||c===null;case'present':return c!==undefined&&c!==null;case'eq':return c===a['value'];case'neq':return c!==a['value'];default:return![];}}export function compileIndustryRule(a,b){if(!b['condition'])return null;const c='pack.'+a+'.'+b['rule_id'],d=b['severity']==='hard'?0xa:0x5,e=b['condition'];return{'id':c,'description':b['description'],'dimension':b['dimension']??'industry','weight':d,'evaluate'(f){const g=evaluateCondition(e,f);if(g)return{'score':0x64,'weight':d,'reason':b['description'],'matched':[b['description']]};return{'score':0x0,'weight':d,'reason':b['description'],'mismatched':[b['description']],'red_flag':b['red_flag']===!![]};}};}export function compileIndustryRules(a){const b=[];for(const c of a['rules']){const d=compileIndustryRule(a['category'],c);if(d)b['push'](d);}return b;}export function registerIndustryRulesToEngine(a){const b=getEvaluationEngine();let c=0x0;for(const d of compileIndustryRules(a)){b['unregisterRule'](d['id']);if(b['registerRule'](d))c++;}return c;}export function unregisterIndustryRulesFromEngine(a){const b=getEvaluationEngine(),c='pack.'+a+'.';let d=0x0;for(const e of b['listRules']()){e['id']['startsWith'](c)&&b['unregisterRule'](e['id'])&&d++;}return d;}
@@ -0,0 +1,105 @@
1
+ import type { IndustryMode } from "./types.js";
2
+ import type { CategoryMatchRules } from "../evaluation/category-match-rules.js";
3
+ import { type IndustryPersona } from "../persona/pack-personae.js";
4
+ import { type IndustryDisputeRules, type ComplianceRules, type SupplyRules, type IndustryRules, type IndustryPlaybook } from "./industry-layers.js";
5
+ export type IndustryPackLayout = "merged" | "legacy";
6
+ export interface IndustryPackManifest {
7
+ pack: "industry-pack";
8
+ name: string;
9
+ display_name: string;
10
+ version: string;
11
+ author?: string;
12
+ traits?: Record<string, unknown>;
13
+ depends_on?: string[];
14
+ layers: string[];
15
+ }
16
+ export interface MergedIndustryPack {
17
+ manifest: IndustryPackManifest;
18
+ mode?: IndustryMode | null;
19
+ match?: CategoryMatchRules | null;
20
+ personae?: IndustryPersona[] | null;
21
+ dispute?: IndustryDisputeRules | null;
22
+ compliance?: ComplianceRules | null;
23
+ supply?: SupplyRules | null;
24
+ rules?: IndustryRules | null;
25
+ }
26
+ export interface IndustryPack {
27
+ layout?: IndustryPackLayout;
28
+ manifest: IndustryPackManifest;
29
+ mode?: IndustryMode;
30
+ match?: CategoryMatchRules;
31
+ personae?: IndustryPersona[];
32
+ dispute?: IndustryDisputeRules;
33
+ compliance?: ComplianceRules;
34
+ supply?: SupplyRules;
35
+ rules?: IndustryRules;
36
+ playbook?: IndustryPlaybook;
37
+ }
38
+ export interface PackValidation {
39
+ valid: boolean;
40
+ errors: string[];
41
+ }
42
+ export interface PackRegistrationResult {
43
+ ok: boolean;
44
+ errors: string[];
45
+ registered: string[];
46
+ }
47
+ export interface PackRecord {
48
+ version: string;
49
+ layers: string[];
50
+ registered_at: number;
51
+ }
52
+ export declare function validatePackManifest(manifest: IndustryPackManifest): PackValidation;
53
+ export declare function registerIndustryPack(pack: IndustryPack, force?: boolean): PackRegistrationResult;
54
+ export declare function listRegisteredPacks(): Array<PackRecord & {
55
+ name: string;
56
+ }>;
57
+ export declare function unregisterIndustryPack(name: string): boolean;
58
+ export interface PackDiffResult {
59
+ name: string;
60
+ registered: {
61
+ version: string;
62
+ layers: string[];
63
+ registered_at: number;
64
+ } | null;
65
+ disk: {
66
+ version: string;
67
+ layers: string[];
68
+ } | null;
69
+ upgradable: boolean;
70
+ layer_diff: {
71
+ added: string[];
72
+ removed: string[];
73
+ };
74
+ }
75
+ export declare function diffIndustryPack(name: string): PackDiffResult;
76
+ export declare function scanPacks(dir: string): PackRegistrationResult[];
77
+ export declare function rescanPack(name: string): PackRegistrationResult;
78
+ export declare function resolveIndustryPackDir(): string;
79
+ export declare function scanDefaultIndustryPacks(): PackRegistrationResult[];
80
+ export declare function seedBuiltinIndustryTemplates(names?: string[]): string[];
81
+ export interface ScaffoldResult {
82
+ ok: boolean;
83
+ dir: string;
84
+ files: string[];
85
+ errors: string[];
86
+ }
87
+ export declare const LAYER_FILE_SECTION: Record<string, keyof Omit<MergedIndustryPack, "manifest" | "personae">>;
88
+ export declare const PERSONAE_DIR = "personae";
89
+ export declare function buildPristineMergedPack(name: string): MergedIndustryPack;
90
+ export declare function industryReadmeContent(): string;
91
+ export declare function ensureIndustryReadme(): string;
92
+ export declare function scaffoldIndustryPack(name: string, dir?: string): ScaffoldResult;
93
+ export declare function readMergedPackIfPresent(packDir: string): MergedIndustryPack | null;
94
+ export interface ResetResult {
95
+ ok: boolean;
96
+ layout: IndustryPackLayout;
97
+ target: string;
98
+ restored_files: string[];
99
+ errors: string[];
100
+ }
101
+ export declare function locatePackAndRemainder(relPath: string): {
102
+ packName: string;
103
+ remainder: string;
104
+ } | null;
105
+ export declare function resetIndustryPath(relPath: string, dir?: string): ResetResult;
@@ -0,0 +1 @@
1
+ import{readdirSync,readFileSync,existsSync,mkdirSync,writeFileSync}from'node:fs';import{join}from'node:path';import{getWowokIndustryDir}from'@wowok/wowok';import{getIndustryModeRegistry}from'./registry.js';import{BUILTIN_MODES}from'./modes.js';import{registerCategoryMatchRules}from'../evaluation/category-match-rules.js';import{registerIndustryPersonae,unregisterIndustryPersonae}from'../persona/pack-personae.js';import{PERSONA_ROLES,SUPPORTED_INDUSTRIES}from'../persona/types.js';import{UNIVERSAL_TEMPLATE}from'../knowledge/universal-template.js';import{registerDisputeRules,registerComplianceRules,registerSupplyRules,registerIndustryRules,registerIndustryPlaybook,registerIndustryRulesToEngine}from'./industry-layers.js';const FORBIDDEN_PRICING_MODES=new Set(UNIVERSAL_TEMPLATE['pricing_redlines']),packRegistry=new Map();export function validatePackManifest(a){const b=[];return(!a||a['pack']!=='industry-pack')&&b['push']('manifest.pack\x20must\x20be\x20\x27industry-pack\x27'),(!a['name']||typeof a['name']!=='string')&&b['push']('manifest.name\x20is\x20required'),(!a['version']||typeof a['version']!=='string')&&b['push']('manifest.version\x20is\x20required'),(!Array['isArray'](a['layers'])||a['layers']['length']===0x0)&&b['push']('manifest.layers\x20must\x20be\x20a\x20non-empty\x20array'),{'valid':b['length']===0x0,'errors':b};}function isMeaningfulMatch(a){if(!a)return![];return(a['hard_constraints']?.['length']??0x0)>0x0||Object['keys'](a['soft_weights']??{})['length']>0x0||(a['pricing_rules']?.['length']??0x0)>0x0||(a['highlight_fields']?.['length']??0x0)>0x0;}function isMeaningfulPersona(a){const b=a['long_term']??{},c=a['current']??{};return(c['strategy']?.['length']??0x0)>0x0||(c['requirements']?.['length']??0x0)>0x0||(c['rules']?.['length']??0x0)>0x0||(c['spec']?.['length']??0x0)>0x0||Object['keys'](c['preferences']??{})['length']>0x0||Object['keys'](b['preferences']??{})['length']>0x0||(b['identity']?.['region']?.['length']??0x0)>0x0||(b['identity']?.['languages']?.['length']??0x0)>0x0;}function isMeaningfulDispute(a){return(a?.['sla_tiers']?.['length']??0x0)>0x0||(a?.['fault_rules']?.['length']??0x0)>0x0;}function isMeaningfulCompliance(a){return!!a?.['prepay_mode']||(a?.['qualification']?.['length']??0x0)>0x0||(a?.['disclosure']?.['length']??0x0)>0x0||a?.['refund_window']?.['days']!==undefined&&!a?.['refund_window']?.['not_applicable'];}function isMeaningfulSupply(a){return(a?.['supplier_qualification']?.['length']??0x0)>0x0||!!a?.['first_order_policy']||a?.['redundancy_required']===!![];}function isMeaningfulRules(a){return(a?.['rules']?.['length']??0x0)>0x0;}function isMeaningfulPlaybook(a){if(!a)return![];const b=a['content']??'',c=b['replace'](/# .*Industry Playbook/g,'')['replace'](/> .*/g,'')['replace'](/## (Experience|Strategy|Personalization)/g,'')['replace'](/- \(Add .*\)/g,'')['trim']();return c['length']>0x0;}export function registerIndustryPack(a,b=![]){const c=[],d=[],e=a['manifest'],f=validatePackManifest(e);c['push'](...f['errors']);if(!f['valid'])return{'ok':![],'errors':c,'registered':d};const g=packRegistry['get'](e['name']),h=g!==undefined&&g['version']!==e['version'],i=h||b;if(e['layers']['includes']('mode')){if(!a['mode'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27mode\x27\x20but\x20mode.json\x20is\x20missing');else{const j=getIndustryModeRegistry();i&&j['hasMode'](a['mode']['name'])&&j['unregisterMode'](a['mode']['name']),!j['registerMode'](a['mode'])?c['push']('mode\x20\x27'+a['mode']['name']+'\x27\x20failed\x20to\x20register\x20(already\x20registered?).\x20'+'Unregister\x20first\x20or\x20upgrade\x20with\x20a\x20different\x20version.'):d['push']('mode');}}if(e['layers']['includes']('match')){if(!a['match'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27match\x27\x20but\x20match.json\x20is\x20missing');else{if(!isMeaningfulMatch(a['match'])){}else{const k=a['match']['pricing_rules']['filter'](l=>FORBIDDEN_PRICING_MODES['has'](l));if(k['length']>0x0)c['push']('match.pricing_rules\x20contains\x20forbidden\x20modes:\x20'+k['join'](',\x20')+'\x20'+'(violates\x20upper-layer\x20pricing\x20red\x20lines,\x20K3\x2015\x20§4.2)');else!registerCategoryMatchRules(a['match'],i)?c['push']('match\x20rules\x20for\x20\x27'+a['match']['category']+'\x27\x20already\x20registered'):d['push']('match');}}}if(e['layers']['includes']('personae')){if(!a['personae']||a['personae']['length']===0x0)c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27personae\x27\x20but\x20personae\x20are\x20missing');else{const l=a['personae']['filter'](isMeaningfulPersona);if(l['length']===0x0){}else registerIndustryPersonae(e['name'],l),d['push']('personae');}}if(e['layers']['includes']('dispute')){if(!a['dispute'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27dispute\x27\x20but\x20dispute.json\x20is\x20missing');else{if(!isMeaningfulDispute(a['dispute'])){}else!registerDisputeRules(a['dispute'],i)?c['push']('dispute\x20rules\x20for\x20\x27'+a['dispute']['category']+'\x27\x20already\x20registered'):d['push']('dispute');}}if(e['layers']['includes']('compliance')){if(!a['compliance'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27compliance\x27\x20but\x20compliance.json\x20is\x20missing');else{if(!isMeaningfulCompliance(a['compliance'])){}else!registerComplianceRules(a['compliance'],i)?c['push']('compliance\x20rules\x20for\x20\x27'+a['compliance']['category']+'\x27\x20already\x20registered'):d['push']('compliance');}}if(e['layers']['includes']('supply')){if(!a['supply'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27supply\x27\x20but\x20supply.json\x20is\x20missing');else{if(!isMeaningfulSupply(a['supply'])){}else!registerSupplyRules(a['supply'],i)?c['push']('supply\x20rules\x20for\x20\x27'+a['supply']['category']+'\x27\x20already\x20registered'):d['push']('supply');}}if(e['layers']['includes']('rules')){if(!a['rules'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27rules\x27\x20but\x20rules.json\x20is\x20missing');else{if(!isMeaningfulRules(a['rules'])){}else!registerIndustryRules(a['rules'],i)?c['push']('industry\x20rules\x20for\x20\x27'+a['rules']['category']+'\x27\x20already\x20registered'):(d['push']('rules'),registerIndustryRulesToEngine(a['rules']));}}if(e['layers']['includes']('playbook')){if(!a['playbook'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27playbook\x27\x20but\x20playbook.md\x20is\x20missing');else{if(!isMeaningfulPlaybook(a['playbook'])){}else!registerIndustryPlaybook(a['playbook'],i)?c['push']('playbook\x20for\x20\x27'+a['playbook']['category']+'\x27\x20already\x20registered'):d['push']('playbook');}}return c['length']===0x0&&packRegistry['set'](e['name'],{'version':e['version'],'layers':[...e['layers']],'registered_at':Date['now']()}),{'ok':c['length']===0x0,'errors':c,'registered':d};}let builtinModesAsPacksRegistered=![];function ensureBuiltinModesAsPacks(){if(builtinModesAsPacksRegistered)return;builtinModesAsPacksRegistered=!![];for(const a of BUILTIN_MODES){if(packRegistry['has'](a['name']))continue;packRegistry['set'](a['name'],{'version':a['version'],'layers':['mode','match'],'registered_at':Date['now']()});}}export function listRegisteredPacks(){return ensureBuiltinModesAsPacks(),Array['from'](packRegistry['entries']())['map'](([a,b])=>({'name':a,...b}));}export function unregisterIndustryPack(a){const b=new Set(BUILTIN_MODES['map'](c=>c['name']));if(b['has'](a))return![];if(!packRegistry['has'](a))return![];return packRegistry['delete'](a),unregisterIndustryPersonae(a),!![];}export function diffIndustryPack(a){const b=packRegistry['get'](a)??null,c=resolveIndustryPackDir(),d=join(c,a),e=readMergedPackIfPresent(d);let f=null;try{if(e&&e['manifest'])f={'version':e['manifest']['version'],'layers':e['manifest']['layers']??[]};else{const l=join(d,'manifest.json');if(existsSync(l)){const m=JSON['parse'](readFileSync(l,'utf-8'));f={'version':m['version'],'layers':m['layers']??[]};}}}catch{f=null;}const g=b?.['layers']??[],h=f?.['layers']??[],i=h['filter'](n=>!g['includes'](n)),j=g['filter'](n=>!h['includes'](n)),k=!!b&&!!f&&(b['version']!==f['version']||i['length']>0x0||j['length']>0x0);return{'name':a,'registered':b?{...b,'layers':[...b['layers']]}:null,'disk':f,'upgradable':k,'layer_diff':{'added':i,'removed':j}};}export function scanPacks(a){const b=[];if(!existsSync(a))return b;for(const c of readdirSync(a,{'withFileTypes':!![]})){if(!c['isDirectory']())continue;const d=join(a,c['name']);try{const e=loadPackFromDir(d);if(!e)continue;b['push'](registerIndustryPack(e));}catch(f){b['push']({'ok':![],'errors':['failed\x20to\x20load\x20pack\x20\x27'+c['name']+'\x27:\x20'+f['message']],'registered':[]});}}return b;}function loadPackFromDir(a){const b=readMergedPackIfPresent(a),c=join(a,'manifest.json'),d=existsSync(c);if(!b&&!d)return null;if(b){const p=b['manifest'],q={'layout':'merged','manifest':p};if(b['mode'])q['mode']=b['mode'];if(b['match'])q['match']=b['match'];b['personae']&&Array['isArray'](b['personae'])&&(q['personae']=b['personae']);if(b['dispute'])q['dispute']=b['dispute'];if(b['compliance'])q['compliance']=b['compliance'];if(b['supply'])q['supply']=b['supply'];if(b['rules'])q['rules']=b['rules'];const r=join(a,'playbook.md');return existsSync(r)&&(q['playbook']={'category':p['name'],'content':readFileSync(r,'utf-8')}),q;}const e=JSON['parse'](readFileSync(c,'utf-8')),g={'layout':'legacy','manifest':e},h=join(a,'mode.json'),i=join(a,'match.json');existsSync(h)&&(g['mode']=JSON['parse'](readFileSync(h,'utf-8')));existsSync(i)&&(g['match']=JSON['parse'](readFileSync(i,'utf-8')));const j=join(a,'personae');if(existsSync(j)){const s=[];for(const t of readdirSync(j)){if(!t['endsWith']('.json'))continue;s['push'](JSON['parse'](readFileSync(join(j,t),'utf-8')));}if(s['length']>0x0)g['personae']=s;}const k=join(a,'dispute.json');existsSync(k)&&(g['dispute']=JSON['parse'](readFileSync(k,'utf-8')));const l=join(a,'compliance.json');existsSync(l)&&(g['compliance']=JSON['parse'](readFileSync(l,'utf-8')));const m=join(a,'supply.json');existsSync(m)&&(g['supply']=JSON['parse'](readFileSync(m,'utf-8')));const n=join(a,'rules.json');existsSync(n)&&(g['rules']=JSON['parse'](readFileSync(n,'utf-8')));const o=join(a,'playbook.md');return existsSync(o)&&(g['playbook']={'category':e['name'],'content':readFileSync(o,'utf-8')}),g;}export function rescanPack(a){const b=join(resolveIndustryPackDir(),a);try{const c=loadPackFromDir(b);if(!c)return{'ok':![],'errors':['no\x20pack\x20found\x20for\x20\x27'+a+'\x27'],'registered':[]};return registerIndustryPack(c,!![]);}catch(d){return{'ok':![],'errors':['failed\x20to\x20rescan\x20pack\x20\x27'+a+'\x27:\x20'+d['message']],'registered':[]};}}export function resolveIndustryPackDir(){return process['env']['WOWOK_INDUSTRY_DIR']||getWowokIndustryDir();}export function scanDefaultIndustryPacks(){return seedBuiltinIndustryTemplates(),ensureIndustryReadme(),ensureBuiltinModesAsPacks(),scanPacks(resolveIndustryPackDir());}export function seedBuiltinIndustryTemplates(a=SUPPORTED_INDUSTRIES){const b=[],c=resolveIndustryPackDir();mkdirSync(c,{'recursive':!![]}),ensureIndustryReadme();for(const d of a){const e=join(c,d);if(existsSync(join(e,'manifest.json'))||existsSync(join(e,'pack.json')))continue;const f=scaffoldIndustryPack(d,c);if(f['ok'])b['push'](d);}return b;}export const LAYER_FILE_SECTION={'match.json':'match','dispute.json':'dispute','compliance.json':'compliance','supply.json':'supply','rules.json':'rules','mode.json':'mode'};export const PERSONAE_DIR='personae';function manifestSection(a){return{'pack':'industry-pack','name':a,'display_name':a,'version':'0.1.0','layers':['match','personae','dispute','compliance','supply','rules','playbook']};}function matchSection(a){return{'category':a,'hard_constraints':[],'soft_weights':{},'highlight_fields':[],'calendar_mode':'none','geo_mode':'strict','pricing_rules':[]};}function personaPerRole(a,b){return{'role':a,'industry':b,'long_term':{'identity':{'self_description':b+'\x20'+a},'preferences':{}},'current':{'strategy':[],'requirements':[],'rules':[],'spec':'','preferences':{}}};}function disputeSection(a){return{'category':a,'sla_tiers':[],'fault_rules':[]};}function complianceSection(a){return{'category':a,'prepay_mode':'','qualification':[],'disclosure':[],'refund_window':{'days':0x7,'not_applicable':![]}};}function supplySection(a){return{'category':a,'supplier_qualification':[],'first_order_policy':'','redundancy_required':![]};}function rulesSection(a){return{'category':a,'rules':[]};}export function buildPristineMergedPack(a){const b=PERSONA_ROLES['map'](c=>personaPerRole(c,a));return{'manifest':manifestSection(a),'match':matchSection(a),'personae':b,'dispute':disputeSection(a),'compliance':complianceSection(a),'supply':supplySection(a),'rules':rulesSection(a),'mode':null};}export function industryReadmeContent(){return['#\x20WoWok\x20Industry\x20Packs','','>\x20This\x20folder\x20is\x20the\x20WoWok\x20industry\x20knowledge\x20root.\x20Each\x20sub-folder\x20is\x20one','>\x20industry\x20pack.\x20The\x20AI\x20reads\x20pack\x20data\x20as\x20context\x20on\x20every\x20chat\x20turn.','','##\x20Pack\x20structure\x20(unified\x20layout)','','Every\x20pack\x20is\x20exactly\x20two\x20files:','','-\x20**`<pack>/pack.json`**\x20—\x20machine-checkable\x20**settings\x20only**.\x20No\x20comments,','\x20\x20no\x20documentation.\x20One\x20section\x20per\x20layer\x20(see\x20below).','-\x20**`<pack>/playbook.md`**\x20—\x20human\x20strategy,\x20tone\x20and\x20field-tested\x20experience.','\x20\x20The\x20AI\x20reads\x20it\x20as\x20context\x20and\x20it\x20OVERRIDES\x20built-in\x20industry\x20data\x20for','\x20\x20this\x20account.','','All\x20field\x20explanations\x20live\x20in\x20THIS\x20file,\x20so\x20pack.json\x20stays\x20small\x20and\x20you','can\x20focus\x20on\x20configuration.\x20The\x20editor\x20also\x20validates\x20JSON\x20on\x20save\x20—\x20a\x20file','that\x20fails\x20to\x20parse\x20(or\x20a\x20pack.json\x20missing\x20its\x20manifest)\x20is\x20blocked.','','##\x20How\x20changes\x20take\x20effect','','1.\x20**Save**\x20in\x20the\x20Editor\x20writes\x20bytes\x20to\x20disk.','2.\x20**Scan**\x20(Industry\x20drawer)\x20re-registers\x20each\x20pack\x20into\x20the\x20runtime\x20AI','\x20\x20\x20registry\x20(and\x20SQLite\x20cache).\x20A\x20save\x20of\x20an\x20industry\x20file\x20already\x20runs','\x20\x20\x20Scan\x20automatically.','3.\x20**Next\x20AI\x20chat\x20turn**\x20the\x20L1\x20prompt\x20builder\x20reads\x20the\x20registered\x20layers,','\x20\x20\x20so\x20the\x20AI\x20reasons\x20against\x20your\x20edited\x20rules\x20from\x20that\x20point\x20onward.','','##\x20manifest\x20—\x20pack\x20metadata\x20+\x20layer\x20ENABLE\x20flags','','-\x20`name`:\x20snake_case\x20identifier,\x20must\x20match\x20the\x20folder\x20name.','-\x20`version`:\x20bump\x20after\x20editing\x20content\x20so\x20the\x20registry\x20treats\x20it\x20as\x20an\x20upgrade.','-\x20`display_name`:\x20user-visible\x20label.','-\x20`layers`:\x20which\x20sections\x20are\x20validated\x20and\x20registered\x20on\x20scan.\x20Remove\x20a','\x20\x20layer\x20name\x20to\x20DISABLE\x20it\x20(the\x20section\x20stays\x20in\x20pack.json\x20but\x20is\x20ignored).','','##\x20match\x20—\x20category-match\x20rules','','Decides\x20whether\x20an\x20order/service/account\x20belongs\x20to\x20this\x20industry\x20pack:','-\x20`hard_constraints`:\x20array\x20of\x20REQUIRED\x20predicates;\x20ALL\x20must\x20match\x20before\x20the','\x20\x20pack\x20is\x20considered.\x20Example:','\x20\x20`[{\x20key:\x20\x27order.metadata.service_kind\x27,\x20equals:\x20\x27food_onsite\x27\x20}]`','-\x20`soft_weights`:\x20dict\x20`<heuristic_key:\x20number\x200..1>`;\x20higher\x20=\x20stronger\x20signal.','-\x20`pricing_rules`:\x20pricing\x20modes\x20this\x20industry\x20requires.','-\x20`highlight_fields`:\x20dot-paths\x20surfaced\x20in\x20the\x20UI\x20as\x20important\x20info.','-\x20`geo_mode`:\x20`\x27strict\x27`\x20(region\x20must\x20match)\x20|\x20`\x27none\x27`\x20(ignore\x20region).','-\x20`calendar_mode`:\x20`\x27seasonal\x27`\x20|\x20`\x27weekday\x27`\x20|\x20`\x27none\x27`.','','##\x20personae\x20—\x20per-role\x20AI\x20personas','','One\x20persona\x20per\x20role\x20(`merchant`,\x20`customer`,\x20`supplier`,\x20`collaborator`,','`arbitrator`,\x20`prospect`).\x20The\x20AI\x20uses\x20them\x20to\x20role-play\x20negotiation\x20posture:','-\x20`long_term`:\x20stable\x20properties\x20—\x20`identity.self_description`\x20(free-text\x20bio),','\x20\x20`identity.region/languages`,\x20`preferences`\x20(`<key:\x20string[]>`).','-\x20`current`:\x20per-negotiation\x20posture\x20—\x20`strategy`\x20(moves\x20to\x20make),','\x20\x20`requirements`\x20(non-negotiable\x20demands),\x20`rules`\x20(constraints/axioms),','\x20\x20`spec`\x20(free-form\x20text),\x20`preferences`\x20(per-turn\x20overrides).','','##\x20dispute\x20—\x20SLA\x20tiers\x20+\x20fault\x20assignment','','-\x20`sla_tiers[]`:\x20response/remedy\x20windows\x20per\x20severity\x20level.','\x20\x20Example:\x20`{\x20level:\x20\x27L1\x27,\x20response_hours:\x2024,\x20remedy:\x20\x27reply\x27\x20}`','-\x20`fault_rules[]`:\x20automatic\x20fault\x20attribution\x20—\x20a\x20condition\x20plus\x20the\x20side','\x20\x20that\x20bears\x20fault\x20(`merchant`/`customer`/`supplier`/`operator`/`shared`).','\x20\x20Example:\x20`{\x20when:\x20{\x20evidence_has:\x20[\x27late\x20delivery\x20photo\x27]\x20},\x20assign_to:\x20\x27merchant\x27,\x20weight:\x201.0\x20}`','','##\x20compliance\x20—\x20hard\x20requirements\x20before\x20checkout','','-\x20`prepay_mode`:\x20`\x27\x27`\x20|\x20`\x27full\x27`\x20|\x20`\x27partial\x27`\x20|\x20`\x27deposit\x27`.','-\x20`qualification[]`:\x20licenses/certifications\x20a\x20merchant\x20must\x20hold.','\x20\x20Example:\x20`{\x20label:\x20\x27Food\x20Service\x20License\x27,\x20required:\x20true,\x20region:\x20\x27CN\x27\x20}`','-\x20`disclosure[]`:\x20text\x20the\x20merchant\x20MUST\x20show\x20buyers\x20up-front.','-\x20`refund_window`:\x20`{\x20days:\x20number,\x20not_applicable:\x20boolean,\x20exceptions:\x20[...]\x20}`','','##\x20supply\x20—\x20supply-chain\x20/\x20supplier\x20qualification','','-\x20`supplier_qualification[]`:\x20same\x20shape\x20as\x20compliance\x20qualifications,\x20but','\x20\x20evaluated\x20on\x20the\x20SUPPLIER\x20side\x20(multi-party\x20orders).','-\x20`first_order_policy`:\x20policy\x20string\x20on\x20the\x20first\x20order\x20from\x20a\x20new\x20supplier','\x20\x20(e.g.\x20`\x27sample-only\x27`,\x20`\x27reduced-quantity\x27`).','-\x20`redundancy_required`:\x20true\x20=\x20require\x20≥2\x20eligible\x20suppliers\x20before\x20accepting','\x20\x20an\x20order\x20(mitigates\x20single-sourcing).','','##\x20rules\x20—\x20declarative\x20machine-checked\x20rules','','Each\x20rule\x20is\x20an\x20AST\x20node\x20compiled\x20into\x20the\x20evaluation\x20engine:','`{\x20id:\x20\x27rule_...\x27,\x20when:\x20<bool-condition>,\x20then:\x20\x27reject\x27\x20|\x20\x27warn\x27\x20|\x20\x27flag\x27,\x20message:\x20\x27Text\x27\x20}`','Use\x20`rules`\x20for\x20rules\x20that\x20must\x20be\x20machine-checked;\x20put\x20human\x20strategy\x20in','`playbook.md`.','','##\x20mode\x20—\x20IndustryMode\x20(deep\x20shape)','','Not\x20scaffolded\x20by\x20default.\x20Add\x20it\x20when\x20you\x20need\x20a\x20full\x20driving\x20mode\x20for\x20the','industry,\x20or\x20ask\x20the\x20AI:\x20\x22help\x20me\x20fill\x20mode\x20for\x20<industry>\x22.','','##\x20Reset','','Right-click\x20any\x20file/pack\x20folder\x20in\x20the\x20Industry\x20drawer\x20and\x20choose\x20*Reset*','to\x20restore\x20the\x20pristine\x20template\x20at\x20any\x20time.','']['join']('\x0a');}export function ensureIndustryReadme(){const a=resolveIndustryPackDir();mkdirSync(a,{'recursive':!![]});const b=join(a,'README.md');return writeFileSync(b,industryReadmeContent(),'utf-8'),b;}export function scaffoldIndustryPack(a,b){const c=join(b??resolveIndustryPackDir(),a),d=[],e=[];if(!/^[a-z][a-z0-9_]*$/['test'](a))return{'ok':![],'dir':c,'files':d,'errors':['industry\x20name\x20\x27'+a+'\x27\x20must\x20be\x20lowercase\x20snake_case\x20(a-z,\x200-9,\x20_)']};try{mkdirSync(c,{'recursive':!![]}),ensureIndustryReadme();const f=buildPristineMergedPack(a);return writeFileSync(join(c,'pack.json'),JSON['stringify'](f,null,0x2)+'\x0a'),d['push']('pack.json'),writeFileSync(join(c,'playbook.md'),playbookTemplate(a)),d['push']('playbook.md'),{'ok':!![],'dir':c,'files':d,'errors':e};}catch(g){return{'ok':![],'dir':c,'files':d,'errors':['scaffold\x20failed:\x20'+g['message']]};}}export function readMergedPackIfPresent(a){const b=join(a,'pack.json');if(!existsSync(b))return null;try{const c=readFileSync(b,'utf-8');return JSON['parse'](c);}catch{return null;}}function playbookTemplate(a){return['#\x20'+a+'\x20—\x20Industry\x20Playbook','','>\x20📘\x20This\x20file\x20captures\x20human\x20business\x20intelligence\x20for\x20the\x20`'+a+'`','>\x20industry.\x20Content\x20here\x20is\x20READ\x20BY\x20THE\x20AI\x20AS\x20CONTEXT\x20on\x20every\x20turn,','>\x20and\x20OVERRIDES\x20WoWok\x27s\x20generic\x20built-in\x20industry\x20data/rules\x20for\x20this','>\x20account.\x20The\x20companion\x20`pack.json`\x20file\x20stores\x20machine-checkable','>\x20rules;\x20THIS\x20file\x20stores\x20human\x20strategy,\x20tone,\x20experience,\x20and\x20ethics.','','>\x20💡\x20Hint\x20for\x20the\x20AI:\x20when\x20the\x20user\x20asks\x20a\x20question\x20about\x20\x22how\x20to','>\x20handle\x20'+a+'\x22\x20or\x20\x22what\x20should\x20I\x20do?\x22,\x20check\x20this\x20file\x20first\x20for\x20the','>\x20merchant/customer\x20voice,\x20then\x20fall\x20back\x20to\x20your\x20built-in\x20data.\x20Cite','>\x20section\x20titles\x20in\x20your\x20reply\x20so\x20the\x20user\x20knows\x20where\x20advice\x20comes\x20from.','','##\x20Experience\x20(Field-Tested\x20Rules\x20of\x20Thumb)','','>\x20Write\x20what\x20actually\x20works\x20in\x20this\x20industry\x20—\x20not\x20what\x20textbooks\x20say.','>\x20Short\x20bullet\x20points\x20preferred;\x20the\x20AI\x20reads\x20them\x20as\x20axioms.\x20Include','>\x20specific\x20numbers\x20when\x20you\x20have\x20them.','','-\x20(Example)\x20\x22Catering:\x20if\x20the\x20event\x20starts\x20before\x2010:00,\x20always\x20assume','\x20\x20the\x20customer\x20wants\x20breakfast\x20service\x20too\x20—\x20upsell\x20it\x20proactively.\x22','-\x20(Example)\x20\x22Common\x20pitfall:\x20last-minute\x20menu\x20swaps\x20on\x20Fridays\x20—\x20require','\x20\x20a\x20written\x20change\x20request\x2048\x20h\x20before\x20the\x20event\x20or\x20charge\x20a\x2015%\x20fee.\x22','-\x20(Add\x20more\x20below\x20—\x20delete\x20the\x20examples\x20above\x20when\x20you\x20have\x20real\x20ones.)','','##\x20Strategy\x20(Competitive\x20/\x20Game-Theory)','','>\x20How\x20should\x20each\x20role\x20act\x20in\x20a\x20negotiation\x20/\x20dispute\x20/\x20supplier','>\x20relationship?\x20Think\x20in\x20\x22always\x20/\x20never\x20/\x20depends-on-X\x22\x20rules,\x20and\x20call','>\x20out\x20the\x20trade-offs.','','-\x20Merchant\x20strategy:\x20(Add\x20how\x20a\x20merchant\x20in\x20this\x20industry\x20should\x20act\x20—','\x20\x20price\x20anchoring,\x20which\x20concessions\x20to\x20give\x20early\x20vs\x20late,\x20what\x20to','\x20\x20never\x20concede\x20on,\x20etc.)','-\x20Customer\x20strategy:\x20(Add\x20what\x20a\x20smart\x20customer\x20should\x20push\x20for.)','-\x20Dispute\x20strategy:\x20(When\x20to\x20settle\x20fast\x20vs\x20when\x20to\x20fight\x20for\x20full','\x20\x20evidence\x20+\x20arbitration.\x20Call\x20out\x20the\x20escalation\x20thresholds.)','','##\x20Personalization\x20(Tone,\x20Brand,\x20Ethics,\x20Red\x20Lines)','','-\x20Tone\x20/\x20voice:\x20(Write\x20one\x20sentence\x20describing\x20the\x20exact\x20conversational','\x20\x20voice\x20this\x20account\x20should\x20use\x20—\x20casual,\x20formal,\x20technical,\x20etc.)','-\x20Brand\x20rules:\x20(Logo,\x20link-out\x20style,\x20forbidden\x20terminology,','\x20\x20always-include\x20phrases,\x20etc.)','-\x20Red\x20lines:\x20(Non-negotiable.\x20Example:\x20\x22Never\x20make\x20a\x20refund\x20promise','\x20\x20larger\x20than\x2030%\x20without\x20arbitration\x20evidence.\x22)','-\x20Ethics:\x20(Example:\x20\x22If\x20customer\x20appears\x20intoxicated,\x20refuse\x20service','\x20\x20and\x20refer\x20to\x20supervisor;\x20never\x20take\x20the\x20order\x20for\x20profit.\x22)','','##\x20Playbook\x20Maintenance','','>\x20You\x20don\x27t\x20need\x20to\x20be\x20perfect\x20on\x20day\x20one.\x20After\x20every\x20real\x20deal,\x20add\x20a','>\x20bullet\x20to\x20the\x20above\x20sections\x20with\x20what\x20worked\x20/\x20what\x20failed.\x20Every','>\x20entry\x20improves\x20the\x20AI\x27s\x20future\x20decisions.','','>\x20Right-click\x20the\x20file\x20or\x20this\x20pack\x20folder\x20in\x20the\x20Industry\x20drawer\x20at','>\x20any\x20time\x20and\x20choose\x20\x22Reset\x22\x20to\x20restore\x20this\x20annotated\x20template.','']['join']('\x0a');}export function locatePackAndRemainder(a){const b=a['replace'](/^[\\/]+/,'')['replace'](/[\\/]+$/,'');if(!b)return null;const [c,...d]=b['split'](/[\\/]+/);if(!c)return null;return{'packName':c,'remainder':d['join']('/')};}export function resetIndustryPath(a,b){const c=[],d=[],f=b??resolveIndustryPackDir(),g=locatePackAndRemainder(a),h=a;if(!g)return{'ok':![],'layout':'merged','target':h,'restored_files':[],'errors':['invalid\x20reset\x20path\x20\x27'+a+'\x27']};const {packName:i,remainder:j}=g,k=join(f,i);if(!existsSync(k))return{'ok':![],'layout':'merged','target':h,'restored_files':[],'errors':['pack\x20directory\x20\x27'+i+'\x27\x20does\x20not\x20exist']};if(!/^[a-z][a-z0-9_]*$/['test'](i))return{'ok':![],'layout':'merged','target':h,'restored_files':[],'errors':['pack\x20name\x20\x27'+i+'\x27\x20is\x20not\x20a\x20valid\x20snake_case\x20identifier']};const l=readMergedPackIfPresent(k),n=l?'merged':'legacy';if(j==='')try{mkdirSync(k,{'recursive':!![]});const s=buildPristineMergedPack(i);return writeFileSync(join(k,'pack.json'),JSON['stringify'](s,null,0x2)+'\x0a'),d['push']('pack.json'),writeFileSync(join(k,'playbook.md'),playbookTemplate(i)),d['push']('playbook.md'),{'ok':!![],'layout':'merged','target':h,'restored_files':d,'errors':c};}catch(t){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['pack\x20reset\x20failed:\x20'+t['message']]};}const o=j['split']('/')['slice'](-0x1)[0x0],p=j==='playbook.md',q=j['startsWith'](PERSONAE_DIR+'/')&&o['endsWith']('.json');if(n==='merged'){if(p)try{return writeFileSync(join(k,'playbook.md'),playbookTemplate(i)),d['push']('playbook.md'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(v){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['playbook\x20reset\x20failed:\x20'+v['message']]};}const u=LAYER_FILE_SECTION[j];if(u)try{const w=readMergedPackIfPresent(k)??buildPristineMergedPack(i);switch(u){case'match':w['match']=matchSection(i);break;case'dispute':w['dispute']=disputeSection(i);break;case'compliance':w['compliance']=complianceSection(i);break;case'supply':w['supply']=supplySection(i);break;case'rules':w['rules']=rulesSection(i);break;case'mode':w['mode']=null;break;}return writeFileSync(join(k,'pack.json'),JSON['stringify'](w,null,0x2)+'\x0a'),d['push']('pack.json'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(x){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['section\x20reset\x20failed:\x20'+x['message']]};}if(q){const y=o['replace'](/\.json$/,'');if(!PERSONA_ROLES['includes'](y))return{'ok':![],'layout':n,'target':h,'restored_files':[],'errors':['unknown\x20persona\x20role\x20\x27'+y+'\x27']};try{const z=readMergedPackIfPresent(k)??buildPristineMergedPack(i),A=z['personae']&&Array['isArray'](z['personae'])?[...z['personae']]:[],B=A['findIndex'](D=>D['role']===y),C=personaPerRole(y,i);if(B>=0x0)A[B]=C;else A['push'](C);return z['personae']=A,writeFileSync(join(k,'pack.json'),JSON['stringify'](z,null,0x2)+'\x0a'),d['push']('pack.json'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(D){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['persona\x20reset\x20failed:\x20'+D['message']]};}}if(j==='manifest.json'||j==='manifest')try{const E=readMergedPackIfPresent(k)??buildPristineMergedPack(i);return E['manifest']=manifestSection(i),writeFileSync(join(k,'pack.json'),JSON['stringify'](E,null,0x2)+'\x0a'),d['push']('pack.json'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(F){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['manifest\x20reset\x20failed:\x20'+F['message']]};}return{'ok':![],'layout':n,'target':h,'restored_files':[],'errors':['path\x20\x27'+j+'\x27\x20is\x20not\x20a\x20standard\x20section\x20file\x20of\x20pack\x20\x27'+i+'\x27.\x20Reset\x20is\x20only\x20provided\x20for\x20pack.json\x20standard\x20sections\x20and\x20playbook.md.']};}if(p)try{return writeFileSync(join(k,'playbook.md'),playbookTemplate(i)),d['push']('playbook.md'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(G){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['legacy\x20playbook\x20reset\x20failed:\x20'+G['message']]};}if(j==='manifest.json')try{const H=manifestSection(i);return writeFileSync(join(k,'manifest.json'),JSON['stringify'](H,null,0x2)+'\x0a'),d['push']('manifest.json'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(I){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['legacy\x20manifest\x20reset\x20failed:\x20'+I['message']]};}const r=LAYER_FILE_SECTION[j];if(r)try{let J='';switch(r){case'match':J=JSON['stringify'](matchSection(i),null,0x2)+'\x0a';break;case'dispute':J=JSON['stringify'](disputeSection(i),null,0x2)+'\x0a';break;case'compliance':J=JSON['stringify'](complianceSection(i),null,0x2)+'\x0a';break;case'supply':J=JSON['stringify'](supplySection(i),null,0x2)+'\x0a';break;case'rules':J=JSON['stringify'](rulesSection(i),null,0x2)+'\x0a';break;case'mode':J=JSON['stringify']({},null,0x2)+'\x0a';break;}return writeFileSync(join(k,j),J),d['push'](j),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(K){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['legacy\x20section\x20reset\x20failed:\x20'+K['message']]};}if(q){const L=o['replace'](/\.json$/,'');if(!PERSONA_ROLES['includes'](L))return{'ok':![],'layout':n,'target':h,'restored_files':[],'errors':['unknown\x20persona\x20\x27'+L+'\x27']};try{return writeFileSync(join(k,j),JSON['stringify'](personaPerRole(L,i),null,0x2)+'\x0a'),d['push'](j),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(M){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['legacy\x20persona\x20reset\x20failed:\x20'+M['message']]};}}return{'ok':![],'layout':n,'target':h,'restored_files':[],'errors':['cannot\x20reset\x20non-standard\x20file\x20\x27'+j+'\x27\x20in\x20legacy\x20layout.\x20Only\x20standard\x20layer\x20files,\x20personae/*.json,\x20manifest.json,\x20and\x20playbook.md\x20can\x20be\x20reset.']};}
@@ -1 +1 @@
1
- const LEVEL_WEIGHT={'high':0x1,'medium':0.6,'low':0.3},BUILTIN_RISK_METRICS=[{'metric_id':'funds_risk','display_name':'Funds\x20Risk','description':'Directly\x20operates\x20funds\x20/\x20affects\x20fund\x20flow\x20/\x20no\x20fund\x20risk','type':'risk','scale':'level','weight':0x1,'scope':'builtin'},{'metric_id':'trust_risk','display_name':'Trust\x20Risk','description':'Degree\x20of\x20impact\x20on\x20trust\x20mechanism','type':'risk','scale':'level','weight':0x1,'scope':'builtin'},{'metric_id':'delivery_risk','display_name':'Delivery\x20Risk','description':'Degree\x20of\x20impact\x20on\x20order\x20fulfillment','type':'risk','scale':'level','weight':0x1,'scope':'builtin'},{'metric_id':'compliance_risk','display_name':'Compliance\x20Risk','description':'Degree\x20of\x20regulatory\x20involvement','type':'risk','scale':'level','weight':0x1,'scope':'builtin'}],BUILTIN_BENEFIT_METRICS=[{'metric_id':'automation_level','display_name':'Automation\x20Level','description':'Fully\x20automated\x20/\x20semi-automated\x20/\x20manual','type':'benefit','scale':'level','weight':0x1,'scope':'builtin'},{'metric_id':'trust_boost','display_name':'Trust\x20Boost','description':'Degree\x20of\x20enhancement\x20to\x20trust\x20mechanism','type':'benefit','scale':'level','weight':0x1,'scope':'builtin'},{'metric_id':'efficiency_gain','display_name':'Efficiency\x20Gain','description':'Degree\x20of\x20efficiency\x20improvement','type':'benefit','scale':'level','weight':0x1,'scope':'builtin'}];export class MetricRegistry{static ['instance'];['metrics']=new Map();['initialized']=![];static['Instance'](){return!MetricRegistry['instance']&&(MetricRegistry['instance']=new MetricRegistry()),MetricRegistry['instance'];}constructor(){this['registerBuiltinMetrics'](),this['initialized']=!![];}['registerMetric'](a){if(!a['metric_id']||!a['type']||!a['scale'])return![];if(this['metrics']['has'](a['metric_id']))return![];return this['metrics']['set'](a['metric_id'],a),!![];}['registerCustomMetric'](a,b,c,d,e,f,g){return this['registerMetric']({'metric_id':a,'display_name':b,'description':c,'type':d,'scale':e,'weight':g??0x1,'scope':'custom','owner':f});}['getMetric'](a){return this['metrics']['get'](a);}['listMetrics'](a){let b=Array['from'](this['metrics']['values']());if(!a)return b;if(a['type'])b=b['filter'](c=>c['type']===a['type']);if(a['scope'])b=b['filter'](c=>c['scope']===a['scope']);if(a['owner'])b=b['filter'](c=>c['owner']===a['owner']);return b;}['unregisterMetric'](a,b){const c=this['metrics']['get'](a);if(!c||c['scope']!=='custom'||c['owner']!==b)return![];return this['metrics']['delete'](a);}['evaluateMode'](a,b,c){const d=[...this['metrics']['values']()];if(c)for(const l of c){!d['some'](n=>n['metric_id']===l['metric_id'])&&d['push'](l);}const e=d['filter'](n=>n['type']==='risk'),f=d['filter'](n=>n['type']==='benefit'),g=[];for(const n of a['capabilities_used']){const o=b['getCard'](n);if(o)g['push'](o);}const h=this['evaluateMetricGroup'](g,e,'risk'),i=this['evaluateMetricGroup'](g,f,'benefit'),j=this['aggregateScore'](h),k=this['aggregateScore'](i);return{'risk_score':j,'benefit_score':k,'metric_details':[...h,...i]};}['evaluateMetricGroup'](a,b,c){const d=[];for(const e of b){const f=[];for(const h of a){const i=c==='risk'?h['risk_profile']:h['benefit_profile'];if(!i)continue;const j=i[e['metric_id']];j!==undefined&&f['push']({'value':j,'weight':0x1});}if(f['length']===0x0)continue;const g=this['computeAverageScore'](f,e['scale']);d['push']({'metric_id':e['metric_id'],'display_name':e['display_name'],'value':this['aggregateValue'](f,e['scale']),'normalized_score':g,'weight':e['weight']??0x1});}return d;}['computeAverageScore'](a,b){if(a['length']===0x0)return 0x0;if(b==='level'){const c={'high':0x64,'medium':0x3c,'low':0x1e};let d=0x0,e=0x0;for(const f of a){const g=c[String(f['value'])]??0x32;d+=g*f['weight'],e+=f['weight'];}return Math['round'](d/Math['max'](e,0x1));}if(b==='numeric'){let h=0x0,i=0x0;for(const j of a){const k=typeof j['value']==='number'?j['value']:0x32;h+=k*j['weight'],i+=j['weight'];}return Math['round'](h/Math['max'](i,0x1));}if(b==='percentage'){let l=0x0,m=0x0;for(const n of a){const o=typeof n['value']==='number'?n['value']:0x32;l+=o*n['weight'],m+=n['weight'];}return Math['round'](l/Math['max'](m,0x1));}return 0x0;}['aggregateValue'](a,b){if(b==='level'){const d={'high':0x0,'medium':0x0,'low':0x0};for(const f of a){const g=String(f['value']);if(d[g]!==undefined)d[g]++;}const e=Object['entries'](d)['sort']((h,i)=>i[0x1]-h[0x1])[0x0]?.[0x0];return e??'medium';}const c=a['reduce']((h,i)=>h+(typeof i['value']==='number'?i['value']:0x0),0x0);return Math['round'](c/a['length']);}['aggregateScore'](a){if(a['length']===0x0)return 0x0;let b=0x0,c=0x0;for(const e of a){b+=e['normalized_score']*e['weight'],c+=e['weight'];}return Math['round'](b/Math['max'](c,0x1));}['registerBuiltinMetrics'](){for(const a of BUILTIN_RISK_METRICS){this['registerMetric'](a);}for(const b of BUILTIN_BENEFIT_METRICS){this['registerMetric'](b);}}}export function getMetricRegistry(){return MetricRegistry['Instance']();}export const BUILTIN_METRICS_COUNT=BUILTIN_RISK_METRICS['length']+BUILTIN_BENEFIT_METRICS['length'];
1
+ const BUILTIN_RISK_METRICS=[{'metric_id':'funds_risk','display_name':'Funds\x20Risk','description':'Directly\x20operates\x20funds\x20/\x20affects\x20fund\x20flow\x20/\x20no\x20fund\x20risk','type':'risk','scale':'level','weight':0x1,'scope':'builtin'},{'metric_id':'trust_risk','display_name':'Trust\x20Risk','description':'Degree\x20of\x20impact\x20on\x20trust\x20mechanism','type':'risk','scale':'level','weight':0x1,'scope':'builtin'},{'metric_id':'delivery_risk','display_name':'Delivery\x20Risk','description':'Degree\x20of\x20impact\x20on\x20order\x20fulfillment','type':'risk','scale':'level','weight':0x1,'scope':'builtin'},{'metric_id':'compliance_risk','display_name':'Compliance\x20Risk','description':'Degree\x20of\x20regulatory\x20involvement','type':'risk','scale':'level','weight':0x1,'scope':'builtin'}],BUILTIN_BENEFIT_METRICS=[{'metric_id':'automation_level','display_name':'Automation\x20Level','description':'Fully\x20automated\x20/\x20semi-automated\x20/\x20manual','type':'benefit','scale':'level','weight':0x1,'scope':'builtin'},{'metric_id':'trust_boost','display_name':'Trust\x20Boost','description':'Degree\x20of\x20enhancement\x20to\x20trust\x20mechanism','type':'benefit','scale':'level','weight':0x1,'scope':'builtin'},{'metric_id':'efficiency_gain','display_name':'Efficiency\x20Gain','description':'Degree\x20of\x20efficiency\x20improvement','type':'benefit','scale':'level','weight':0x1,'scope':'builtin'}];export class MetricRegistry{static ['instance'];['metrics']=new Map();['initialized']=![];static['Instance'](){return!MetricRegistry['instance']&&(MetricRegistry['instance']=new MetricRegistry()),MetricRegistry['instance'];}constructor(){this['registerBuiltinMetrics'](),this['initialized']=!![];}['registerMetric'](a){if(!a['metric_id']||!a['type']||!a['scale'])return![];if(this['metrics']['has'](a['metric_id']))return![];return this['metrics']['set'](a['metric_id'],a),!![];}['registerCustomMetric'](a,b,c,d,e,f,g){return this['registerMetric']({'metric_id':a,'display_name':b,'description':c,'type':d,'scale':e,'weight':g??0x1,'scope':'custom','owner':f});}['getMetric'](a){return this['metrics']['get'](a);}['listMetrics'](a){let b=Array['from'](this['metrics']['values']());if(!a)return b;if(a['type'])b=b['filter'](c=>c['type']===a['type']);if(a['scope'])b=b['filter'](c=>c['scope']===a['scope']);if(a['owner'])b=b['filter'](c=>c['owner']===a['owner']);return b;}['unregisterMetric'](a,b){const c=this['metrics']['get'](a);if(!c||c['scope']!=='custom'||c['owner']!==b)return![];return this['metrics']['delete'](a);}['evaluateMode'](a,b,c){const d=[...this['metrics']['values']()];if(c)for(const l of c){!d['some'](n=>n['metric_id']===l['metric_id'])&&d['push'](l);}const e=d['filter'](n=>n['type']==='risk'),f=d['filter'](n=>n['type']==='benefit'),g=[];for(const n of a['capabilities_used']){const o=b['getCard'](n);if(o)g['push'](o);}const h=this['evaluateMetricGroup'](g,e,'risk'),i=this['evaluateMetricGroup'](g,f,'benefit'),j=this['aggregateScore'](h),k=this['aggregateScore'](i);return{'risk_score':j,'benefit_score':k,'metric_details':[...h,...i]};}['evaluateMetricGroup'](a,b,c){const d=[];for(const e of b){const f=[];for(const h of a){const i=c==='risk'?h['risk_profile']:h['benefit_profile'];if(!i)continue;const j=i[e['metric_id']];j!==undefined&&f['push']({'value':j,'weight':0x1});}if(f['length']===0x0)continue;const g=this['computeAverageScore'](f,e['scale']);d['push']({'metric_id':e['metric_id'],'display_name':e['display_name'],'value':this['aggregateValue'](f,e['scale']),'normalized_score':g,'weight':e['weight']??0x1});}return d;}['computeAverageScore'](a,b){if(a['length']===0x0)return 0x0;if(b==='level'){const c={'high':0x64,'medium':0x3c,'low':0x1e};let d=0x0,e=0x0;for(const f of a){const g=c[String(f['value'])]??0x32;d+=g*f['weight'],e+=f['weight'];}return Math['round'](d/Math['max'](e,0x1));}if(b==='numeric'){let h=0x0,i=0x0;for(const j of a){const k=typeof j['value']==='number'?j['value']:0x32;h+=k*j['weight'],i+=j['weight'];}return Math['round'](h/Math['max'](i,0x1));}if(b==='percentage'){let l=0x0,m=0x0;for(const n of a){const o=typeof n['value']==='number'?n['value']:0x32;l+=o*n['weight'],m+=n['weight'];}return Math['round'](l/Math['max'](m,0x1));}return 0x0;}['aggregateValue'](a,b){if(b==='level'){const d={'high':0x0,'medium':0x0,'low':0x0};for(const f of a){const g=String(f['value']);if(d[g]!==undefined)d[g]++;}const e=Object['entries'](d)['sort']((h,i)=>i[0x1]-h[0x1])[0x0]?.[0x0];return e??'medium';}const c=a['reduce']((h,i)=>h+(typeof i['value']==='number'?i['value']:0x0),0x0);return Math['round'](c/a['length']);}['aggregateScore'](a){if(a['length']===0x0)return 0x0;let b=0x0,c=0x0;for(const e of a){b+=e['normalized_score']*e['weight'],c+=e['weight'];}return Math['round'](b/Math['max'](c,0x1));}['registerBuiltinMetrics'](){for(const a of BUILTIN_RISK_METRICS){this['registerMetric'](a);}for(const b of BUILTIN_BENEFIT_METRICS){this['registerMetric'](b);}}}export function getMetricRegistry(){return MetricRegistry['Instance']();}export const BUILTIN_METRICS_COUNT=BUILTIN_RISK_METRICS['length']+BUILTIN_BENEFIT_METRICS['length'];