@wowok/agent-mcp 3.1.0 → 3.1.3

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 (337) hide show
  1. package/dist/config/runtime.js +1 -1
  2. package/dist/customer/index.d.ts +3 -9
  3. package/dist/customer/index.js +1 -1
  4. package/dist/customer/industry-risks.d.ts +3 -17
  5. package/dist/customer/industry-risks.js +1 -1
  6. package/dist/customer/types.d.ts +1 -165
  7. package/dist/customer/types.js +1 -1
  8. package/dist/customer/user-preferences.d.ts +0 -49
  9. package/dist/customer/user-preferences.js +1 -1
  10. package/dist/evaluation/arbitration-game.js +1 -1
  11. package/dist/evaluation/architecture.spec.d.ts +1 -0
  12. package/dist/evaluation/architecture.spec.js +1 -0
  13. package/dist/evaluation/builtins/graph-service.d.ts +16 -0
  14. package/dist/evaluation/builtins/graph-service.js +1 -0
  15. package/dist/evaluation/builtins/graph-service.spec.d.ts +1 -0
  16. package/dist/evaluation/builtins/graph-service.spec.js +1 -0
  17. package/dist/evaluation/builtins/index.d.ts +1 -1
  18. package/dist/evaluation/builtins/index.js +1 -1
  19. package/dist/evaluation/builtins/purity.spec.d.ts +1 -0
  20. package/dist/evaluation/builtins/purity.spec.js +1 -0
  21. package/dist/evaluation/engine.js +1 -1
  22. package/dist/evaluation/facets/catalog.d.ts +19 -0
  23. package/dist/evaluation/facets/catalog.js +1 -0
  24. package/dist/evaluation/guard-scan.d.ts +10 -0
  25. package/dist/evaluation/guard-scan.js +1 -0
  26. package/dist/evaluation/location-match.js +1 -1
  27. package/dist/evaluation/standards.d.ts +31 -0
  28. package/dist/evaluation/standards.js +1 -0
  29. package/dist/evaluation/standards.spec.d.ts +1 -0
  30. package/dist/evaluation/standards.spec.js +1 -0
  31. package/dist/evaluation/types.d.ts +9 -0
  32. package/dist/experience/realtime-feedback.js +1 -1
  33. package/dist/extensions/index.d.ts +1 -1
  34. package/dist/extensions/index.js +1 -1
  35. package/dist/extensions/industry-layers.d.ts +6 -5
  36. package/dist/extensions/industry-layers.js +1 -1
  37. package/dist/extensions/industry-pack.js +1 -1
  38. package/dist/goal/GoalClassifier.js +1 -1
  39. package/dist/graph/onchain/analyze.d.ts +16 -3
  40. package/dist/graph/onchain/analyze.js +1 -1
  41. package/dist/graph/onchain/analyze.spec.js +1 -1
  42. package/dist/graph/onchain/dataplane.d.ts +1 -1
  43. package/dist/graph/onchain/dataplane.js +1 -1
  44. package/dist/graph/onchain/edge-batch.spec.d.ts +1 -0
  45. package/dist/graph/onchain/edge-batch.spec.js +1 -0
  46. package/dist/graph/onchain/edge-schema.d.ts +11 -3
  47. package/dist/graph/onchain/edge-schema.js +1 -1
  48. package/dist/graph/onchain/entity-profile.spec.d.ts +1 -0
  49. package/dist/graph/onchain/entity-profile.spec.js +1 -0
  50. package/dist/graph/onchain/event-history.spec.d.ts +1 -0
  51. package/dist/graph/onchain/event-history.spec.js +1 -0
  52. package/dist/graph/onchain/expand.js +1 -1
  53. package/dist/graph/onchain/extract-deep.spec.d.ts +1 -0
  54. package/dist/graph/onchain/extract-deep.spec.js +1 -0
  55. package/dist/graph/onchain/extract.d.ts +11 -3
  56. package/dist/graph/onchain/extract.js +1 -1
  57. package/dist/graph/onchain/facet-projection.d.ts +99 -0
  58. package/dist/graph/onchain/facet-projection.js +1 -0
  59. package/dist/graph/onchain/facet-projection.spec.d.ts +1 -0
  60. package/dist/graph/onchain/facet-projection.spec.js +1 -0
  61. package/dist/graph/onchain/facts.d.ts +103 -0
  62. package/dist/graph/onchain/facts.js +1 -0
  63. package/dist/graph/onchain/facts.spec.d.ts +1 -0
  64. package/dist/graph/onchain/facts.spec.js +1 -0
  65. package/dist/graph/onchain/field-manifest.d.ts +29 -0
  66. package/dist/graph/onchain/field-manifest.js +1 -0
  67. package/dist/graph/onchain/field-manifest.spec.d.ts +1 -0
  68. package/dist/graph/onchain/field-manifest.spec.js +1 -0
  69. package/dist/graph/onchain/fixtures.d.ts +80 -0
  70. package/dist/graph/onchain/fixtures.js +1 -0
  71. package/dist/graph/onchain/fixtures.spec.d.ts +1 -0
  72. package/dist/graph/onchain/fixtures.spec.js +1 -0
  73. package/dist/graph/onchain/index.d.ts +8 -2
  74. package/dist/graph/onchain/index.js +1 -1
  75. package/dist/graph/onchain/interest.js +1 -1
  76. package/dist/graph/onchain/label-lint.spec.d.ts +1 -0
  77. package/dist/graph/onchain/label-lint.spec.js +1 -0
  78. package/dist/graph/onchain/names.d.ts +23 -0
  79. package/dist/graph/onchain/names.js +1 -0
  80. package/dist/graph/onchain/names.spec.d.ts +1 -0
  81. package/dist/graph/onchain/names.spec.js +1 -0
  82. package/dist/graph/onchain/onchain.spec.js +1 -1
  83. package/dist/graph/onchain/proposal-graph.d.ts +11 -0
  84. package/dist/graph/onchain/proposal-graph.js +1 -0
  85. package/dist/graph/onchain/proposal-graph.spec.d.ts +1 -0
  86. package/dist/graph/onchain/proposal-graph.spec.js +1 -0
  87. package/dist/graph/onchain/sdk-batch.d.ts +5 -1
  88. package/dist/graph/onchain/sdk-batch.js +1 -1
  89. package/dist/graph/onchain/sdk-dataplane.js +1 -1
  90. package/dist/graph/onchain/strategy.d.ts +16 -0
  91. package/dist/graph/onchain/strategy.js +1 -1
  92. package/dist/graph/onchain/strategy.spec.js +1 -1
  93. package/dist/graph/onchain/table-ledger.spec.d.ts +1 -0
  94. package/dist/graph/onchain/table-ledger.spec.js +1 -0
  95. package/dist/graph/onchain/types.d.ts +51 -11
  96. package/dist/graph/onchain/viewport.d.ts +1 -0
  97. package/dist/graph/onchain/viewport.js +1 -1
  98. package/dist/harness/index.d.ts +1 -5
  99. package/dist/harness/index.js +1 -1
  100. package/dist/harness/verify.d.ts +6 -1
  101. package/dist/harness/verify.js +1 -1
  102. package/dist/index.js +1 -1
  103. package/dist/knowledge/allocation-ledger.d.ts +2 -0
  104. package/dist/knowledge/allocation-ledger.js +1 -1
  105. package/dist/knowledge/allocation-puzzle.js +1 -1
  106. package/dist/knowledge/allocation-risk.d.ts +2 -3
  107. package/dist/knowledge/allocation-risk.js +1 -1
  108. package/dist/knowledge/arb-risk.d.ts +0 -1
  109. package/dist/knowledge/arb-risk.js +1 -1
  110. package/dist/knowledge/arbitration-risk.d.ts +0 -2
  111. package/dist/knowledge/arbitration-risk.js +1 -1
  112. package/dist/knowledge/baselines/evaluation-baselines.json +79 -0
  113. package/dist/knowledge/baselines/guard-lint-baseline.spec.d.ts +1 -0
  114. package/dist/knowledge/baselines/guard-lint-baseline.spec.js +1 -0
  115. package/dist/knowledge/baselines/risk-baselines.spec.d.ts +1 -0
  116. package/dist/knowledge/baselines/risk-baselines.spec.js +1 -0
  117. package/dist/knowledge/baselines/risk-cases.d.ts +8 -0
  118. package/dist/knowledge/baselines/risk-cases.js +1 -0
  119. package/dist/knowledge/bridge-risk.d.ts +0 -1
  120. package/dist/knowledge/bridge-risk.js +1 -1
  121. package/dist/knowledge/contact-risk.d.ts +0 -1
  122. package/dist/knowledge/contact-risk.js +1 -1
  123. package/dist/knowledge/contract-invariants.d.ts +1 -0
  124. package/dist/knowledge/contract-invariants.js +1 -1
  125. package/dist/knowledge/demand-risk.d.ts +0 -1
  126. package/dist/knowledge/demand-risk.js +1 -1
  127. package/dist/knowledge/getting-started.js +1 -1
  128. package/dist/knowledge/guard-design-patterns.js +1 -1
  129. package/dist/knowledge/guard-eval.d.ts +15 -0
  130. package/dist/knowledge/guard-eval.js +1 -0
  131. package/dist/knowledge/guard-eval.spec.d.ts +1 -0
  132. package/dist/knowledge/guard-eval.spec.js +1 -0
  133. package/dist/knowledge/guard-field-cognition.d.ts +48 -0
  134. package/dist/knowledge/guard-field-cognition.js +1 -0
  135. package/dist/knowledge/guard-lint.d.ts +1 -1
  136. package/dist/knowledge/guard-lint.js +1 -1
  137. package/dist/knowledge/guard-risk.d.ts +4 -19
  138. package/dist/knowledge/guard-risk.js +1 -1
  139. package/dist/knowledge/index.d.ts +42 -43
  140. package/dist/knowledge/index.js +1 -1
  141. package/dist/knowledge/industry-registry.js +1 -1
  142. package/dist/knowledge/industry-rule-node.d.ts +7 -0
  143. package/dist/knowledge/industry-rule-node.js +1 -0
  144. package/dist/knowledge/industry-strategy.js +1 -1
  145. package/dist/knowledge/jsonrpc-enum.js +1 -1
  146. package/dist/knowledge/machine-risk.d.ts +0 -6
  147. package/dist/knowledge/machine-risk.js +1 -1
  148. package/dist/knowledge/order-risk.d.ts +1 -9
  149. package/dist/knowledge/order-risk.js +1 -1
  150. package/dist/knowledge/payment-risk.d.ts +0 -1
  151. package/dist/knowledge/payment-risk.js +1 -1
  152. package/dist/knowledge/permission-risk.d.ts +0 -3
  153. package/dist/knowledge/permission-risk.js +1 -1
  154. package/dist/knowledge/personal-risk.d.ts +0 -1
  155. package/dist/knowledge/personal-risk.js +1 -1
  156. package/dist/knowledge/progress-risk.d.ts +0 -2
  157. package/dist/knowledge/progress-risk.js +1 -1
  158. package/dist/knowledge/proof-risk.d.ts +0 -1
  159. package/dist/knowledge/proof-risk.js +1 -1
  160. package/dist/knowledge/puzzle-projections.d.ts +11 -0
  161. package/dist/knowledge/puzzle-projections.js +1 -0
  162. package/dist/knowledge/recipient-constraint.d.ts +6 -1
  163. package/dist/knowledge/recipient-constraint.js +1 -1
  164. package/dist/knowledge/registrar-risk.d.ts +0 -1
  165. package/dist/knowledge/registrar-risk.js +1 -1
  166. package/dist/knowledge/repository-risk.d.ts +0 -1
  167. package/dist/knowledge/repository-risk.js +1 -1
  168. package/dist/knowledge/resource-risk.d.ts +0 -1
  169. package/dist/knowledge/resource-risk.js +1 -1
  170. package/dist/knowledge/reward-risk.d.ts +1 -5
  171. package/dist/knowledge/reward-risk.js +1 -1
  172. package/dist/knowledge/rule-node-analyzers.d.ts +43 -0
  173. package/dist/knowledge/rule-node-analyzers.js +1 -0
  174. package/dist/knowledge/rule-node-analyzers.spec.d.ts +1 -0
  175. package/dist/knowledge/rule-node-analyzers.spec.js +1 -0
  176. package/dist/knowledge/rule-outcome.d.ts +5 -0
  177. package/dist/knowledge/rule-outcome.js +1 -0
  178. package/dist/knowledge/safety-rules.js +1 -1
  179. package/dist/knowledge/scenario-topology.js +1 -1
  180. package/dist/knowledge/service-allocator-audit-node.d.ts +3 -0
  181. package/dist/knowledge/service-allocator-audit-node.js +1 -0
  182. package/dist/knowledge/service-risk-node.js +1 -1
  183. package/dist/knowledge/service-risk.d.ts +0 -3
  184. package/dist/knowledge/service-risk.js +1 -1
  185. package/dist/knowledge/template-registry.js +1 -1
  186. package/dist/knowledge/tools-reference.js +1 -1
  187. package/dist/knowledge/treasury-risk.d.ts +2 -3
  188. package/dist/knowledge/treasury-risk.js +1 -1
  189. package/dist/knowledge/util-risk.d.ts +0 -1
  190. package/dist/knowledge/util-risk.js +1 -1
  191. package/dist/knowledge/workflow-guidance.d.ts +2 -0
  192. package/dist/knowledge/workflow-guidance.js +1 -1
  193. package/dist/monitor/MonitorLoop.js +1 -1
  194. package/dist/persona/bridge.js +1 -1
  195. package/dist/persona/facet-profile.d.ts +33 -0
  196. package/dist/persona/facet-profile.js +1 -0
  197. package/dist/persona/model.d.ts +2 -1
  198. package/dist/persona/model.js +1 -1
  199. package/dist/persona/strategy-intent.js +1 -1
  200. package/dist/persona/topology-focus.d.ts +2 -2
  201. package/dist/persona/topology-focus.js +1 -1
  202. package/dist/persona/types.d.ts +12 -0
  203. package/dist/playbooks/service-build/business-puzzle.js +1 -1
  204. package/dist/playbooks/service-build/facet-money.d.ts +22 -0
  205. package/dist/playbooks/service-build/facet-money.js +1 -0
  206. package/dist/playbooks/service-build/facet-money.spec.d.ts +1 -0
  207. package/dist/playbooks/service-build/facet-money.spec.js +1 -0
  208. package/dist/playbooks/service-build/intent-analyzer.js +1 -1
  209. package/dist/playbooks/service-build/machine-panorama.d.ts +3 -0
  210. package/dist/playbooks/service-build/machine-panorama.js +1 -1
  211. package/dist/playbooks/service-build/object-panorama.d.ts +27 -27
  212. package/dist/playbooks/service-build/object-panorama.js +1 -1
  213. package/dist/playbooks/service-build/pipeline-actions.d.ts +2 -2
  214. package/dist/playbooks/service-build/pipeline-actions.js +1 -1
  215. package/dist/playbooks/service-build/risk-aggregator.d.ts +2 -1
  216. package/dist/playbooks/service-build/risk-aggregator.js +1 -1
  217. package/dist/playbooks/service-build/service-panorama.d.ts +4 -9
  218. package/dist/playbooks/service-build/service-panorama.js +1 -1
  219. package/dist/playbooks/service-build/topology-evaluation.spec.d.ts +1 -0
  220. package/dist/playbooks/service-build/topology-evaluation.spec.js +1 -0
  221. package/dist/playbooks/service-build/topology-query.d.ts +13 -2
  222. package/dist/playbooks/service-build/topology-query.js +1 -1
  223. package/dist/review/arb.d.ts +0 -2
  224. package/dist/review/arb.js +1 -1
  225. package/dist/review/order.d.ts +0 -1
  226. package/dist/review/order.js +1 -1
  227. package/dist/role/profiles.js +1 -1
  228. package/dist/rules.d.ts +1 -2
  229. package/dist/rules.js +1 -1
  230. package/dist/safety/confirm-gate.js +1 -1
  231. package/dist/safety/preview.js +1 -1
  232. package/dist/schema/call/base.d.ts +3372 -668
  233. package/dist/schema/call/base.js +1 -1
  234. package/dist/schema/call/handler.js +1 -1
  235. package/dist/schema/call/receipt.d.ts +28 -0
  236. package/dist/schema/call/receipt.js +1 -0
  237. package/dist/schema/call/semantic-customer-advice.spec.d.ts +1 -0
  238. package/dist/schema/call/semantic-customer-advice.spec.js +1 -0
  239. package/dist/schema/call/semantic.d.ts +5 -2
  240. package/dist/schema/call/semantic.js +1 -1
  241. package/dist/schema/call/treasury.js +1 -1
  242. package/dist/schema/common/index.js +1 -1
  243. package/dist/schema/evaluation/index.d.ts +289 -211
  244. package/dist/schema/evaluation/index.js +1 -1
  245. package/dist/schema/goal/index.d.ts +1 -1
  246. package/dist/schema/goal/planning.d.ts +2 -2
  247. package/dist/schema/index.d.ts +0 -1
  248. package/dist/schema/index.js +1 -1
  249. package/dist/schema/industry-pack/index.d.ts +1 -1
  250. package/dist/schema/keeper/index.d.ts +1 -1
  251. package/dist/schema/local/index.js +1 -1
  252. package/dist/schema/operations.d.ts +28 -10
  253. package/dist/schema/operations.js +1 -1
  254. package/dist/schema/persona/index.d.ts +24 -24
  255. package/dist/schema/query/bi.d.ts +629 -14
  256. package/dist/schema/query/bi.js +1 -1
  257. package/dist/schema/query/index.d.ts +9 -9
  258. package/dist/schema/query/index.js +1 -1
  259. package/dist/schema/schema-version.js +1 -1
  260. package/dist/schema/workspace/index.d.ts +2 -2
  261. package/dist/schema-query-impl/index.js +1 -1
  262. package/dist/schemas/account_operation.output.json +10 -10
  263. package/dist/schemas/account_operation.schema.json +3 -3
  264. package/dist/schemas/bridge_operation.output.json +10 -10
  265. package/dist/schemas/evaluation_operation.output.json +697 -169
  266. package/dist/schemas/evaluation_operation.schema.json +5 -434
  267. package/dist/schemas/index.json +1 -7
  268. package/dist/schemas/keeper_operation.output.json +10 -10
  269. package/dist/schemas/local_history_operation.output.json +10 -10
  270. package/dist/schemas/local_info_operation.output.json +10 -10
  271. package/dist/schemas/local_mark_operation.output.json +10 -10
  272. package/dist/schemas/messenger_operation.output.json +10 -10
  273. package/dist/schemas/monitor_events.output.json +10 -10
  274. package/dist/schemas/monitor_subscription.output.json +10 -10
  275. package/dist/schemas/onchain_events.output.json +11 -11
  276. package/dist/schemas/onchain_operations.output.json +6369 -3736
  277. package/dist/schemas/onchain_operations.schema.json +48 -48
  278. package/dist/schemas/onchain_operations_allocation.schema.json +5 -5
  279. package/dist/schemas/onchain_operations_arbitration.schema.json +3 -3
  280. package/dist/schemas/onchain_operations_contact.schema.json +2 -2
  281. package/dist/schemas/onchain_operations_demand.schema.json +2 -2
  282. package/dist/schemas/onchain_operations_machine.schema.json +2 -2
  283. package/dist/schemas/onchain_operations_order.schema.json +2 -2
  284. package/dist/schemas/onchain_operations_payment.schema.json +2 -2
  285. package/dist/schemas/onchain_operations_permission.schema.json +2 -2
  286. package/dist/schemas/onchain_operations_progress.schema.json +2 -2
  287. package/dist/schemas/onchain_operations_repository.schema.json +2 -2
  288. package/dist/schemas/onchain_operations_reward.schema.json +6 -6
  289. package/dist/schemas/onchain_operations_service.schema.json +8 -8
  290. package/dist/schemas/onchain_operations_treasury.schema.json +10 -10
  291. package/dist/schemas/onchain_table_data.output.json +78 -84
  292. package/dist/schemas/query_toolkit.output.json +1087 -254
  293. package/dist/schemas/query_toolkit.schema.json +65 -3
  294. package/dist/strategy/collectors.js +1 -1
  295. package/dist/strategy/metrics.js +1 -1
  296. package/dist/task/playbook.js +1 -1
  297. package/dist/tools/handlers/bridge.js +1 -1
  298. package/dist/tools/handlers/config.js +1 -1
  299. package/dist/tools/handlers/dispatch-expectations.d.ts +3 -0
  300. package/dist/tools/handlers/dispatch-expectations.js +1 -0
  301. package/dist/tools/handlers/evaluation.js +1 -1
  302. package/dist/tools/handlers/evaluation.spec.js +1 -1
  303. package/dist/tools/handlers/onchain.js +1 -1
  304. package/dist/tools/handlers/query.js +1 -1
  305. package/dist/tools/index.js +1 -1
  306. package/dist/tools/registry/evaluation.d.ts +2 -0
  307. package/dist/tools/registry/evaluation.js +1 -0
  308. package/dist/tools/registry/monitor.js +1 -1
  309. package/dist/tools/registry/query.js +1 -1
  310. package/dist/tools/shared.d.ts +0 -1
  311. package/dist/tools/shared.js +1 -1
  312. package/dist/tools/wrap.js +1 -1
  313. package/package.json +4 -3
  314. package/dist/customer/customer-advice.d.ts +0 -32
  315. package/dist/customer/customer-advice.js +0 -1
  316. package/dist/customer/info-puzzle.d.ts +0 -146
  317. package/dist/customer/info-puzzle.js +0 -1
  318. package/dist/customer/order-strategy.d.ts +0 -17
  319. package/dist/customer/order-strategy.js +0 -1
  320. package/dist/customer/preorder-compare.d.ts +0 -24
  321. package/dist/customer/preorder-compare.js +0 -1
  322. package/dist/customer/reminder-system.d.ts +0 -42
  323. package/dist/customer/reminder-system.js +0 -1
  324. package/dist/customer/risk-assessment.d.ts +0 -13
  325. package/dist/customer/risk-assessment.js +0 -1
  326. package/dist/evaluation/builtins/service-risk.d.ts +0 -7
  327. package/dist/evaluation/builtins/service-risk.js +0 -1
  328. package/dist/knowledge/trust-metrics.d.ts +0 -66
  329. package/dist/knowledge/trust-metrics.js +0 -1
  330. package/dist/schema/trust/index.d.ts +0 -334
  331. package/dist/schema/trust/index.js +0 -1
  332. package/dist/schemas/trust_score.output.json +0 -847
  333. package/dist/schemas/trust_score.schema.json +0 -364
  334. package/dist/tools/handlers/trust.d.ts +0 -16
  335. package/dist/tools/handlers/trust.js +0 -1
  336. package/dist/tools/registry/trust.d.ts +0 -2
  337. package/dist/tools/registry/trust.js +0 -1
@@ -1 +1 @@
1
- import{classifyError,buildDataSemantic}from'../schema/call/semantic.js';import{buildClassifiedErrorResult}from'./shared.js';import{shouldRunLightHooks,shouldRunHeavyHooks,recordOperationFailure,recordCriticalRisk,recordCriticalOperation,recordSubstepFailure}from'../harness/auto-escalation.js';import{getHarnessTier,setHarnessTier,isEnabled}from'../config/runtime.js';import{getHarness}from'../harness/index.js';import{recordOperationOutcome}from'../experience/index.js';import{recordIndustrySignal}from'../knowledge/flywheel-loop.js';import{getStageCache}from'../playbooks/service-build/index.js';import{SERVICE_BUILD_STAGES}from'../playbooks/service-build/process.js';import{extractAmount,getAmountThreshold,formatAmount}from'../knowledge/safety-rules.js';function stageIndexOf(a){const b=SERVICE_BUILD_STAGES['indexOf'](a);return b>=0x0?b:0x0;}export function withTimeout(a,b=0x7530,c='operation'){let d;return Promise['race']([a['finally'](()=>{if(d)clearTimeout(d);}),new Promise((e,f)=>{d=setTimeout(()=>{let g='';if(c['includes']('messenger'))g='\x20This\x20is\x20a\x20messenger\x20network\x20operation.\x20Possible\x20causes:\x20'+'(1)\x20messenger\x20server\x20(https://messenger.wowok.net)\x20unreachable,\x20'+'(2)\x20no\x20messenger-enabled\x20account\x20configured\x20(use\x20account_operation\x20to\x20set\x20messenger\x20name),\x20'+'(3)\x20network\x20connectivity\x20issue.\x20'+'Ensure\x20you\x20have\x20a\x20messenger-enabled\x20account\x20and\x20the\x20server\x20is\x20reachable.';else(c['includes']('onchain')||c['includes']('account_operation')||c['includes']('bridge')||c['includes']('workflow')||c['includes']('keeper')||c['includes']('wowok'))&&(g='\x20This\x20tool\x20may\x20submit\x20an\x20ON-CHAIN\x20transaction.\x20The\x20transaction\x20was\x20NOT\x20cancelled\x20'+'by\x20this\x20timeout\x20—\x20it\x20may\x20already\x20be\x20submitted\x20and\x20still\x20finalize\x20on-chain.\x20'+'DO\x20NOT\x20blindly\x20retry\x20(risk\x20of\x20duplicate\x20operations).\x20First\x20verify:\x20'+'(1)\x20if\x20the\x20error\x20above\x20carries\x20a\x20tx\x20digest,\x20check\x20it\x20via\x20query_toolkit\x20'+'(query_type=\x27onchain_transaction\x27);\x20(2)\x20otherwise\x20re-query\x20the\x20target\x20object\x20state\x20'+'(query_toolkit\x20onchain_objects)\x20and\x20only\x20retry\x20if\x20the\x20operation\x20truly\x20did\x20not\x20land.');f(new Error('Operation\x20\x27'+c+'\x27\x20timed\x20out\x20after\x20'+b+'ms.'+g));},b);})]);}export function wrapHandlerWithErrorShape(a,b,c,d){return async(e,f)=>{try{return await withTimeout(a(e,f),b,c);}catch(g){if(d){const h=g instanceof Error?g['message']:String(g),i=classifyError(h),j={'operation_type':c,'data':e},k=d(h,i,j);return{'content':[{'type':'text','text':'Error:\x20'+h}],'structuredContent':k};}throw g;}};}export const statusErrorShape=(a,b,c)=>({'result':buildClassifiedErrorResult({'status':'error'},a,b),'semantic':buildDataSemantic(undefined,c,!![],a)});export const operationErrorShape=(a,b,c)=>({'result':buildClassifiedErrorResult({'operation':'error'},a,b),'semantic':buildDataSemantic(undefined,c,!![],a)});export const strictStatusErrorShape=(a,b,c)=>({'result':{'status':'error','error':a}});function checkProjectStage(a,b,c){const d={'analyze_intent':'puzzle','aggregate_risks':'risk','trace_substeps':'substeps'},e=d[a];if(!e)return null;const f=getStageCache(b,c);if(!f){if(a==='analyze_intent')return null;return'project_stage:\x20calling\x20\x27'+a+'\x27\x20before\x20\x27analyze_intent\x27\x20—\x20recommend\x20calling\x20analyze_intent\x20first\x20for\x20project\x20\x27'+b+':'+c+'\x27';}if(stageIndexOf(f['stage'])<stageIndexOf(e)-0x1)return'project_stage:\x20calling\x20\x27'+a+'\x27\x20(stage\x20\x27'+e+'\x27)\x20but\x20project\x20is\x20at\x20stage\x20\x27'+f['stage']+'\x27\x20—\x20recommend\x20completing\x20prior\x20stages\x20first\x20for\x20\x27'+b+':'+c+'\x27';return null;}export function dispatchWithHarness(a,b){return async(d,f)=>{const g=[],h=getHarness(),i=shouldRunLightHooks(),j=shouldRunHeavyHooks(),k=isPublishOperation(b,d),l=isSignOperation(b,d),m=getHarnessTier();let n;if(i)try{const p=extractOperationType(b,d),q=extractIntent(b,d);p&&q&&(n=h['expect'](b,q,p,extractData(d)));}catch(r){g['push']('pre_call\x20hook\x20failed:\x20'+(r instanceof Error?r['message']:String(r)));}if(b==='goal_operation'&&i)try{const s=d,t=s?.['action'],u=s?.['project'],v=s?.['version'];if(t&&u&&v){const x=checkProjectStage(t,u,v);x&&g['push'](x);}}catch{}k&&m==='lightweight'&&(setHarnessTier('full'),g['push']('pre_publish:\x20tier\x20forced\x20to\x20full\x20for\x20publish-class\x20operation\x20(GLM5-21\x20§3.3)'));if(k&&m!=='off')try{const y=runPrePublishChecks(b,d);g['push'](...y['warnings']);if(y['critical']['length']>0x0){for(const z of y['critical']){const A=recordCriticalRisk(z);if(A)g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+A['reason']);}return buildHarnessBlockResult('pre_publish','Publish\x20BLOCKED\x20by\x20Harness\x20pre-publish\x20gate\x20(GLM5-21\x20V6):\x20'+(y['critical']['length']+'\x20CRITICAL\x20risk(s)\x20must\x20be\x20resolved\x20before\x20publish.'),y['critical'],y['warnings'],'immutable_violation','Fix\x20the\x20CRITICAL\x20risks\x20listed\x20in\x20the\x20message\x20(e.g.\x20rename\x20dispute/refund\x20nodes\x20per\x20R-M1-11,\x20add\x20the\x20entry\x20pair\x20prev_node=\x22\x22),\x20then\x20retry\x20publish.\x20Nodes/pairs/forwards\x20are\x20immutable\x20after\x20publish\x20—\x20verify\x20via\x20machineNode2file\x20first.');}}catch(B){g['push']('pre_publish\x20hook\x20failed:\x20'+(B instanceof Error?B['message']:String(B)));}if(l&&j)try{const C=extractData(d),D=C?extractAmount(C):null;if(D!==null){const E=getAmountThreshold();let F=null;try{F=BigInt(D);}catch{F=null;}if(F!==null&&F>E)return buildHarnessBlockResult('pre_sign','Sign\x20BLOCKED\x20by\x20Harness\x20pre-sign\x20gate\x20(GLM5-21\x20V7):\x20amount\x20'+formatAmount(F)+'\x20WOW\x20exceeds\x20the\x20full-tier\x20threshold\x20'+formatAmount(E)+'\x20WOW.',['amount\x20'+D+'\x20(smallest\x20unit)\x20>\x20threshold\x20'+E['toString']()+'\x20(smallest\x20unit)'],[],'invalid_parameter','Raise\x20WOWOK_AMOUNT_THRESHOLD\x20to\x20match\x20the\x20intended\x20amount,\x20split\x20the\x20transaction,\x20or\x20reset\x20the\x20harness\x20tier\x20to\x20lightweight\x20(config_operation)\x20after\x20explicit\x20user\x20confirmation.');}}catch(G){g['push']('pre_sign\x20hook\x20failed:\x20'+(G instanceof Error?G['message']:String(G)));}let o;try{o=await a(d,f);}catch(H){const I=H instanceof Error?H['message']:String(H),J=recordOperationFailure(b,I);J&&g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+J['reason']);if(b==='onchain_operations')try{const K=classifyError(I,H);if(!K['retryable']&&K['error_code']!=='unknown'){const L=recordCriticalOperation(b,K['error_code']);if(L)g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+L['reason']);}}catch{}throw H;}if(i&&n)try{if(o?.['structuredContent']){const M=buildVerifyInput(n,o),N=h['verify'](M);if(N['status']==='fail')g['push']('Harness\x20verify\x20FAIL:\x20'+N['summary']);else N['status']==='warn'&&g['push']('Harness\x20verify\x20WARN:\x20'+N['summary']);}}catch(O){g['push']('post_call\x20hook\x20failed:\x20'+(O instanceof Error?O['message']:String(O)));}if(b==='onchain_operations')try{if(classifyOutcome(o)==='failed'){const P=extractErrorCode(o)??'',Q=classifyError(P);if(!Q['retryable']&&Q['error_code']!=='unknown'){const R=recordCriticalOperation(b,Q['error_code']);if(R)g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+R['reason']);}}}catch{}if(i){const S=extractIntent(b,d)??b;try{const T=classifyOutcome(o);if(T==='failed'){const U=extractErrorCode(o)??'',V=classifyError(U),W=h['recover'](V['error_code'],S,{'operation_type':b,'data':extractData(d)});g['push']('Harness\x20recover:\x20strategy='+W['strategy']+('\x20(attempt\x20'+W['current_attempt']+'/'+W['max_attempts']+')')+(W['should_retry']?'\x20—\x20retryable':'\x20—\x20do\x20NOT\x20retry\x20blindly')+(W['user_prompt']?'\x20—\x20'+W['user_prompt']:'\x20—\x20'+W['detail']));}else T==='success'&&h['resetRecovery'](S);}catch(X){g['push']('recover\x20hook\x20failed:\x20'+(X instanceof Error?X['message']:String(X)));}}if(b==='goal_operation')try{const Y=d?.['action'];if(Y==='trace_substeps'){const Z=extractCriticalFindingCount(o);if(Z>0x0){const a0=recordSubstepFailure(String(Y)+':\x20'+Z+'\x20critical\x20finding(s)');if(a0)g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+a0['reason']);}}}catch{}if(isWriteClassTool(b)&&!SEMANTIC_RECORDED_TOOLS['has'](b))try{const a1=extractOperationType(b,d)??b,a2=extractIntent(b,d)??b,a3=extractData(d)??d,a4=classifyOutcome(o),a5=extractErrorCode(o),a6=isEnabled('experience_layer');if(a6)recordOperationOutcome(a1,a3,a2,a4,a5);else{const a7=extractIndustry(d);a7&&isEnabled('industry_evolution')&&recordIndustrySignal(a7,{'type':a1},{'success':a4==='success','error_code':a5});}}catch(a8){g['push']('signal\x20collection\x20failed:\x20'+(a8 instanceof Error?a8['message']:String(a8)));}if(g['length']>0x0){if(o?.['structuredContent']){const a9=o['structuredContent'],aa=a9['semantic'];if(aa){const ab=Array['isArray'](aa['warnings'])?aa['warnings']:[];aa['warnings']=[...ab,...g];}else for(const ac of g){console['warn']('[harness]\x20'+ac);}}else for(const ad of g){console['warn']('[harness]\x20'+ad);}}return o;};}function isPublishOperation(a,b){if(a!=='onchain_operations')return![];const c=extractOperationType(a,b);if(c!=='service'&&c!=='machine')return![];const d=extractData(b);return d?.['publish']===!![]||d?.['bPublished']===!![];}function isSignOperation(a,b){if(a==='wip_file'){const c=b?.['operation_type'];return c==='sign';}return a==='onchain_operations';}function extractOperationType(a,b){if(!b||typeof b!=='object')return undefined;const c=b;if(a==='onchain_operations')return typeof c['operation_type']==='string'?c['operation_type']:undefined;if(a==='goal_operation'||a==='industry_pack_operation'||a==='strategy_review_operation')return typeof c['action']==='string'?c['action']:undefined;return typeof c['operation_type']==='string'?c['operation_type']:undefined;}function extractIntent(a,b){if(!b||typeof b!=='object')return undefined;const c=b;if((a==='goal_operation'||a==='industry_pack_operation'||a==='strategy_review_operation')&&typeof c['action']==='string')return a+':'+c['action'];const d=c['operation_type'];if(typeof d==='string')return a+':'+d;return a;}function extractData(a){if(!a||typeof a!=='object')return undefined;const b=a,c=b['data'];return c&&typeof c==='object'?c:undefined;}function buildVerifyInput(a,b){const c=b['structuredContent']??{},d=c['semantic'];return{'expected':a,'actual':{'result_type':typeof c['result_type']==='string'?c['result_type']:undefined,'semantic':d,'error_code':typeof c['error_code']==='string'?c['error_code']:undefined,'error':typeof c['error']==='string'?c['error']:undefined}};}const WRITE_CLASS_TOOLS=new Set(['onchain_operations','goal_operation','industry_pack_operation','strategy_review_operation','wip_file','messenger_operation','bridge_operation']),SEMANTIC_RECORDED_TOOLS=new Set(['onchain_operations','bridge_operation']);function isWriteClassTool(a){return WRITE_CLASS_TOOLS['has'](a);}function classifyOutcome(a){if(!a?.['structuredContent'])return'failed';const b=a['structuredContent'],c=typeof b['status']==='string'?b['status']:typeof b['result_type']==='string'?b['result_type']:'';if(c==='error'||c==='failed')return'failed';if(c==='partial')return'partial';return'success';}function extractErrorCode(a){if(!a?.['structuredContent'])return undefined;const b=a['structuredContent'];if(typeof b['error_code']==='string')return b['error_code'];const c=b['error'];if(typeof c==='string')return c;if(c&&typeof c==='object'){const d=c['code'];if(typeof d==='string')return d;}return undefined;}function extractIndustry(a){if(!a||typeof a!=='object')return undefined;const b=a;if(typeof b['industry']==='string')return b['industry'];const c=b['data'];if(c&&typeof c==='object'){const e=c;if(typeof e['industry']==='string')return e['industry'];}return undefined;}const ANTI_PATTERN_NODE_REGEX=/(^|_)(disputed?|refund(?:ed)?|arbitration|arb)(_|$)/i;function runPrePublishChecks(a,b){const c=[],d=[],e=extractOperationType(a,b),g=extractData(b)??{};if(e==='machine'){const h=g['node'],i=Array['isArray'](h)?h:Array['isArray'](h?.['nodes'])?h['nodes']:[];if(i['length']>0x0){for(const l of i){const m=typeof l?.['name']==='string'?l['name']:'';m&&ANTI_PATTERN_NODE_REGEX['test'](m)&&c['push']('R-M1-11:\x20machine\x20node\x20\x22'+m+'\x22\x20models\x20dispute/refund\x20flow\x20—\x20'+'refunds\x20must\x20route\x20via\x20an\x20Allocator\x20triggered\x20by\x20business\x20states,\x20'+'disputes\x20via\x20the\x20separate\x20Arbitration\x20object\x20(off-Machine)');}const j=new Set();for(const o of i){const q=typeof o?.['name']==='string'?o['name']:'';if(!q)continue;j['has'](q)&&c['push']('MC-C-04:\x20duplicate\x20machine\x20node\x20name\x20\x22'+q+'\x22\x20—\x20on-chain\x20will\x20reject\x20the\x20publish\x20transaction'),j['add'](q);}const k=i['some'](r=>Array['isArray'](r?.['pairs'])&&r['pairs']['some'](s=>s?.['prev_node']===''));!k&&c['push']('Machine\x20has\x20no\x20entry\x20pair\x20(prev_node=\x22\x22)\x20—\x20Progress\x20can\x20never\x20advance\x20'+'from\x20the\x20initial\x20state;\x20orders\x20are\x20permanently\x20stuck');for(const r of i){const s=typeof r?.['name']==='string'?r['name']:'?';for(const t of r?.['pairs']??[]){for(const u of t?.['forwards']??[]){const v=u?.['namedOperator']!==undefined&&u?.['namedOperator']!==null,w=u?.['permissionIndex']!==undefined&&u?.['permissionIndex']!==null;!v&&!w&&d['push']('pre_publish:\x20node\x20\x22'+s+'\x22\x20forward\x20\x22'+String(u?.['name']??'?')+'\x22\x20has\x20neither\x20namedOperator\x20nor\x20permissionIndex\x20—\x20no\x20one\x20can\x20advance\x20it');}}}}else d['push']('pre_publish:\x20publishing\x20machine\x20without\x20inline\x20node\x20data\x20—\x20topology\x20not\x20verifiable\x20in\x20this\x20call;\x20'+'verify\x20nodes/pairs/forwards\x20via\x20machineNode2file\x20BEFORE\x20publish\x20(immutable\x20after\x20publish,\x20IMMUT-001)');d['push']('pre_publish:\x20machine\x20nodes/pairs/forwards\x20become\x20immutable\x20after\x20publish\x20(IMMUT-001)');}return e==='service'&&(d['push']('pre_publish:\x20service\x20machine/order_allocators/arbitrations\x20become\x20immutable\x20after\x20publish\x20(IMMUT-002);\x20sales\x20remains\x20modifiable'),g['machine']===undefined&&d['push']('pre_publish:\x20\x27machine\x27\x20not\x20set\x20in\x20this\x20call\x20—\x20if\x20the\x20service\x20was\x20never\x20bound\x20to\x20a\x20published\x20machine,\x20'+'it\x20cannot\x20process\x20orders\x20and\x20CANNOT\x20be\x20fixed\x20after\x20publish'),g['order_allocators']===undefined&&d['push']('pre_publish:\x20\x27order_allocators\x27\x20not\x20set\x20in\x20this\x20call\x20—\x20immutable\x20after\x20publish;\x20'+'orders\x20will\x20have\x20no\x20fund\x20distribution\x20if\x20never\x20configured')),{'critical':c,'warnings':d};}function buildHarnessBlockResult(a,b,c,d,e,f){const g=[...c['map'](i=>'CRITICAL:\x20'+i),...d['map'](i=>'WARN:\x20'+i)]['join']('\x0a'),h='Error:\x20'+b+(g?'\x0a'+g:'')+'\x0aRecovery:\x20'+f;return{'content':[{'type':'text','text':h}],'structuredContent':{'result':{'type':'error','error':b+'\x20[gate='+a+']','error_code':e,'retryable':![],'recovery_hint':f},'message':h}};}function extractCriticalFindingCount(a){const b=a?.['structuredContent'];if(!b)return 0x0;const c=b['semantic'],d=c?.['summary'];if(typeof d?.['critical_count']==='number'&&d['critical_count']>0x0)return d['critical_count'];const e=b['findings']??c?.['findings'];if(Array['isArray'](e))return e['filter'](h=>h?.['severity']==='error')['length'];const f=a?.['content']?.['map'](h=>'text'in h?h['text']:'')['join']('\x0a')??'',g=f['match'](/\[AUDIT ERROR\]/g);return g?g['length']:0x0;}
1
+ import{classifyError,buildDataSemantic}from'../schema/call/semantic.js';import{buildClassifiedErrorResult}from'./shared.js';import{shouldRunLightHooks,shouldRunHeavyHooks,recordOperationFailure,recordCriticalRisk,recordCriticalOperation,recordSubstepFailure}from'../harness/auto-escalation.js';import{getHarnessTier,setHarnessTier,isEnabled}from'../config/runtime.js';import{getHarness}from'../harness/index.js';import{recover}from'../harness/recover.js';import{recordOperationOutcome}from'../experience/index.js';import{recordIndustrySignal}from'../knowledge/flywheel-loop.js';import{getStageCache}from'../playbooks/service-build/index.js';import{SERVICE_BUILD_STAGES}from'../playbooks/service-build/process.js';import{extractAmount,getAmountThreshold,formatAmount}from'../knowledge/safety-rules.js';function stageIndexOf(a){const b=SERVICE_BUILD_STAGES['indexOf'](a);return b>=0x0?b:0x0;}export function withTimeout(a,b=0x7530,c='operation'){let d;return Promise['race']([a['finally'](()=>{if(d)clearTimeout(d);}),new Promise((e,f)=>{d=setTimeout(()=>{let g='';if(c['includes']('messenger'))g='\x20This\x20is\x20a\x20messenger\x20network\x20operation.\x20Possible\x20causes:\x20'+'(1)\x20messenger\x20server\x20(https://messenger.wowok.net)\x20unreachable,\x20'+'(2)\x20no\x20messenger-enabled\x20account\x20configured\x20(use\x20account_operation\x20to\x20set\x20messenger\x20name),\x20'+'(3)\x20network\x20connectivity\x20issue.\x20'+'Ensure\x20you\x20have\x20a\x20messenger-enabled\x20account\x20and\x20the\x20server\x20is\x20reachable.';else(c['includes']('onchain')||c['includes']('account_operation')||c['includes']('bridge')||c['includes']('workflow')||c['includes']('keeper')||c['includes']('wowok'))&&(g='\x20This\x20tool\x20may\x20submit\x20an\x20ON-CHAIN\x20transaction.\x20The\x20transaction\x20was\x20NOT\x20cancelled\x20'+'by\x20this\x20timeout\x20—\x20it\x20may\x20already\x20be\x20submitted\x20and\x20still\x20finalize\x20on-chain.\x20'+'DO\x20NOT\x20blindly\x20retry\x20(risk\x20of\x20duplicate\x20operations).\x20First\x20verify:\x20'+'(1)\x20if\x20the\x20error\x20above\x20carries\x20a\x20tx\x20digest,\x20check\x20it\x20via\x20query_toolkit\x20'+'(query_type=\x27onchain_transaction\x27);\x20(2)\x20otherwise\x20verify\x20via\x20query_toolkit\x20'+'onchain_events\x20(or\x20the\x20account\x27s\x20recent\x20transactions).\x20Do\x20NOT\x20rely\x20on\x20an\x20'+'onchain_objects\x20read\x20alone:\x20it\x20may\x20serve\x20a\x20pre-transaction\x20cached\x20snapshot,\x20'+'so\x20an\x20unchanged\x20object\x20must\x20never\x20on\x20its\x20own\x20justify\x20a\x20retry.');f(new Error('Operation\x20\x27'+c+'\x27\x20timed\x20out\x20after\x20'+b+'ms.'+g));},b);})]);}export function wrapHandlerWithErrorShape(a,b,c,d){return async(e,f)=>{try{return await withTimeout(a(e,f),b,c);}catch(g){if(d){const h=g instanceof Error?g['message']:String(g),i=classifyError(h),j={'operation_type':c,'data':e},k=d(h,i,j);return{'content':[{'type':'text','text':'Error:\x20'+h}],'structuredContent':k};}throw g;}};}export const statusErrorShape=(a,b,c)=>({'result':buildClassifiedErrorResult({'status':'error'},a,b),'semantic':buildDataSemantic(undefined,c,!![],a)});export const operationErrorShape=(a,b,c)=>({'result':buildClassifiedErrorResult({'operation':'error'},a,b),'semantic':buildDataSemantic(undefined,c,!![],a)});export const strictStatusErrorShape=(a,b,c)=>({'result':{'status':'error','error':a}});function checkProjectStage(a,b,c){const d={'analyze_intent':'puzzle','aggregate_risks':'risk','trace_substeps':'substeps'},e=d[a];if(!e)return null;const f=getStageCache(b,c);if(!f){if(a==='analyze_intent')return null;return'project_stage:\x20calling\x20\x27'+a+'\x27\x20before\x20\x27analyze_intent\x27\x20—\x20recommend\x20calling\x20analyze_intent\x20first\x20for\x20project\x20\x27'+b+':'+c+'\x27';}if(stageIndexOf(f['stage'])<stageIndexOf(e)-0x1)return'project_stage:\x20calling\x20\x27'+a+'\x27\x20(stage\x20\x27'+e+'\x27)\x20but\x20project\x20is\x20at\x20stage\x20\x27'+f['stage']+'\x27\x20—\x20recommend\x20completing\x20prior\x20stages\x20first\x20for\x20\x27'+b+':'+c+'\x27';return null;}export function dispatchWithHarness(a,b){return async(d,f)=>{const g=[],h=getHarness(),i=shouldRunLightHooks(),j=shouldRunHeavyHooks(),k=isPublishOperation(b,d),l=isSignOperation(b,d),m=getHarnessTier();if(b==='goal_operation'&&i)try{const o=d,p=o?.['action'],q=o?.['project'],r=o?.['version'];if(p&&q&&r){const s=checkProjectStage(p,q,r);s&&g['push'](s);}}catch{}k&&m==='lightweight'&&(setHarnessTier('full'),g['push']('pre_publish:\x20tier\x20forced\x20to\x20full\x20for\x20publish-class\x20operation\x20(GLM5-21\x20§3.3)'));if(k&&m!=='off')try{const t=runPrePublishChecks(b,d);g['push'](...t['warnings']);if(t['critical']['length']>0x0){for(const u of t['critical']){const v=recordCriticalRisk(u);if(v)g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+v['reason']);}return buildHarnessBlockResult('pre_publish','Publish\x20BLOCKED\x20by\x20Harness\x20pre-publish\x20gate\x20(GLM5-21\x20V6):\x20'+(t['critical']['length']+'\x20CRITICAL\x20risk(s)\x20must\x20be\x20resolved\x20before\x20publish.'),t['critical'],t['warnings'],'immutable_violation','Fix\x20the\x20CRITICAL\x20risks\x20listed\x20in\x20the\x20message\x20(e.g.\x20rename\x20dispute/refund\x20nodes\x20per\x20R-M1-11,\x20add\x20the\x20entry\x20pair\x20prev_node=\x22\x22),\x20then\x20retry\x20publish.\x20Nodes/pairs/forwards\x20are\x20immutable\x20after\x20publish\x20—\x20verify\x20via\x20machineNode2file\x20first.');}}catch(x){g['push']('pre_publish\x20hook\x20failed:\x20'+(x instanceof Error?x['message']:String(x)));}if(l&&j)try{const y=extractData(d),z=y?extractAmount(y):null;if(z!==null){const A=getAmountThreshold();let B=null;try{B=BigInt(z);}catch{B=null;}if(B!==null&&B>A)return buildHarnessBlockResult('pre_sign','Sign\x20BLOCKED\x20by\x20Harness\x20pre-sign\x20gate\x20(GLM5-21\x20V7):\x20amount\x20'+formatAmount(B)+'\x20WOW\x20exceeds\x20the\x20full-tier\x20threshold\x20'+formatAmount(A)+'\x20WOW.',['amount\x20'+z+'\x20(smallest\x20unit)\x20>\x20threshold\x20'+A['toString']()+'\x20(smallest\x20unit)'],[],'invalid_parameter','Raise\x20WOWOK_AMOUNT_THRESHOLD\x20to\x20match\x20the\x20intended\x20amount,\x20split\x20the\x20transaction,\x20or\x20reset\x20the\x20harness\x20tier\x20to\x20lightweight\x20(config_operation)\x20after\x20explicit\x20user\x20confirmation.');}}catch(C){g['push']('pre_sign\x20hook\x20failed:\x20'+(C instanceof Error?C['message']:String(C)));}let n;try{n=await a(d,f);}catch(D){const E=D instanceof Error?D['message']:String(D),F=recordOperationFailure(b,E);F&&g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+F['reason']);if(b==='onchain_operations')try{const G=classifyError(E,D);if(!G['retryable']&&G['error_code']!=='unknown'){const H=recordCriticalOperation(b,G['error_code']);if(H)g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+H['reason']);}}catch{}throw D;}if(b==='onchain_operations')try{if(classifyOutcome(n)==='failed'){const I=extractErrorCode(n)??'',J=classifyError(I);if(!J['retryable']&&J['error_code']!=='unknown'){const K=recordCriticalOperation(b,J['error_code']);if(K)g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+K['reason']);}}}catch{}if(i&&!isOutcomeDiscriminated(n)){const L=extractIntent(b,d)??b;try{const M=classifyOutcome(n);if(M==='failed'){const N=extractErrorCode(n)??'',O=classifyError(N),P=h['recover'](O['error_code'],L,{'operation_type':b,'data':extractData(d)});g['push']('Harness\x20recover:\x20strategy='+P['strategy']+('\x20(attempt\x20'+P['current_attempt']+'/'+P['max_attempts']+')')+(P['should_retry']?'\x20—\x20retryable':'\x20—\x20do\x20NOT\x20retry\x20blindly')+(P['user_prompt']?'\x20—\x20'+P['user_prompt']:'\x20—\x20'+P['detail']));}else M==='success'&&h['resetRecovery'](L);}catch(Q){g['push']('recover\x20hook\x20failed:\x20'+(Q instanceof Error?Q['message']:String(Q)));}}if(b==='goal_operation')try{const R=d?.['action'];if(R==='trace_substeps'){const S=extractCriticalFindingCount(n);if(S>0x0){const T=recordSubstepFailure(String(R)+':\x20'+S+'\x20critical\x20finding(s)');if(T)g['push']('Harness\x20escalated\x20to\x20full\x20tier:\x20'+T['reason']);}}}catch{}if(isWriteClassTool(b)&&!SEMANTIC_RECORDED_TOOLS['has'](b))try{const U=extractOperationType(b,d)??b,V=extractIntent(b,d)??b,W=extractData(d)??d,X=classifyOutcome(n),Y=extractErrorCode(n),Z=isEnabled('experience_layer');if(Z)recordOperationOutcome(U,W,V,X,Y);else{const a0=extractIndustry(d);a0&&isEnabled('industry_evolution')&&recordIndustrySignal(a0,{'type':U},{'success':X==='success','error_code':Y});}}catch(a1){g['push']('signal\x20collection\x20failed:\x20'+(a1 instanceof Error?a1['message']:String(a1)));}if(g['length']>0x0){if(n?.['structuredContent']){const a2=n['structuredContent'],a3=a2['semantic'];if(a3){const a4=Array['isArray'](a3['warnings'])?a3['warnings']:[];a3['warnings']=[...a4,...g];}else for(const a5 of g){console['warn']('[harness]\x20'+a5);}}else for(const a6 of g){console['warn']('[harness]\x20'+a6);}}return n;};}function isPublishOperation(a,b){if(a!=='onchain_operations')return![];const c=extractOperationType(a,b);if(c!=='service'&&c!=='machine')return![];const d=extractData(b);return d?.['publish']===!![]||d?.['bPublished']===!![];}function isSignOperation(a,b){if(a==='wip_file'){const c=b?.['operation_type'];return c==='sign';}return a==='onchain_operations';}function extractOperationType(a,b){if(!b||typeof b!=='object')return undefined;const c=b;if(a==='onchain_operations')return typeof c['operation_type']==='string'?c['operation_type']:undefined;if(a==='goal_operation'||a==='industry_pack_operation'||a==='strategy_review_operation')return typeof c['action']==='string'?c['action']:undefined;return typeof c['operation_type']==='string'?c['operation_type']:undefined;}function extractIntent(a,b){if(!b||typeof b!=='object')return undefined;const c=b;if((a==='goal_operation'||a==='industry_pack_operation'||a==='strategy_review_operation')&&typeof c['action']==='string')return a+':'+c['action'];const d=c['operation_type'];if(typeof d==='string')return a+':'+d;return a;}function extractData(a){if(!a||typeof a!=='object')return undefined;const b=a,c=b['data'];return c&&typeof c==='object'?c:undefined;}const WRITE_CLASS_TOOLS=new Set(['onchain_operations','goal_operation','industry_pack_operation','strategy_review_operation','wip_file','messenger_operation','bridge_operation']),SEMANTIC_RECORDED_TOOLS=new Set(['onchain_operations','bridge_operation']);function isWriteClassTool(a){return WRITE_CLASS_TOOLS['has'](a);}function classifyOutcome(a){if(!a?.['structuredContent'])return'failed';const b=a['structuredContent'];if(b['outcome']==='failed')return'failed';if(b['outcome']==='executed')return'success';if(b['outcome']==='pending_input')return'partial';const c=typeof b['status']==='string'?b['status']:typeof b['result_type']==='string'?b['result_type']:'';if(c==='error'||c==='failed')return'failed';if(c==='partial')return'partial';return'success';}function isOutcomeDiscriminated(a){const b=a?.['structuredContent'];return!!b&&typeof b==='object'&&'outcome'in b;}function extractErrorCode(a){if(!a?.['structuredContent'])return undefined;const b=a['structuredContent'];if(typeof b['error_code']==='string')return b['error_code'];const c=b['error'];if(typeof c==='string')return c;if(c&&typeof c==='object'){const d=c['code'];if(typeof d==='string')return d;}return undefined;}function extractIndustry(a){if(!a||typeof a!=='object')return undefined;const b=a;if(typeof b['industry']==='string')return b['industry'];const c=b['data'];if(c&&typeof c==='object'){const e=c;if(typeof e['industry']==='string')return e['industry'];}return undefined;}const ANTI_PATTERN_NODE_REGEX=/(^|_)(disputed?|refund(?:ed)?|arbitration|arb)(_|$)/i;function runPrePublishChecks(a,b){const c=[],d=[],e=extractOperationType(a,b),g=extractData(b)??{};if(e==='machine'){const h=g['node'],i=Array['isArray'](h)?h:Array['isArray'](h?.['nodes'])?h['nodes']:[];if(i['length']>0x0){for(const l of i){const m=typeof l?.['name']==='string'?l['name']:'';m&&ANTI_PATTERN_NODE_REGEX['test'](m)&&c['push']('R-M1-11:\x20machine\x20node\x20\x22'+m+'\x22\x20models\x20dispute/refund\x20flow\x20—\x20'+'refunds\x20must\x20route\x20via\x20an\x20Allocator\x20triggered\x20by\x20business\x20states,\x20'+'disputes\x20via\x20the\x20separate\x20Arbitration\x20object\x20(off-Machine)');}const j=new Set();for(const o of i){const q=typeof o?.['name']==='string'?o['name']:'';if(!q)continue;j['has'](q)&&c['push']('MC-C-04:\x20duplicate\x20machine\x20node\x20name\x20\x22'+q+'\x22\x20—\x20on-chain\x20will\x20reject\x20the\x20publish\x20transaction'),j['add'](q);}const k=i['some'](r=>Array['isArray'](r?.['pairs'])&&r['pairs']['some'](s=>s?.['prev_node']===''));!k&&c['push']('Machine\x20has\x20no\x20entry\x20pair\x20(prev_node=\x22\x22)\x20—\x20Progress\x20can\x20never\x20advance\x20'+'from\x20the\x20initial\x20state;\x20orders\x20are\x20permanently\x20stuck');for(const r of i){const s=typeof r?.['name']==='string'?r['name']:'?';for(const t of r?.['pairs']??[]){for(const u of t?.['forwards']??[]){const v=u?.['namedOperator']!==undefined&&u?.['namedOperator']!==null,w=u?.['permissionIndex']!==undefined&&u?.['permissionIndex']!==null;!v&&!w&&d['push']('pre_publish:\x20node\x20\x22'+s+'\x22\x20forward\x20\x22'+String(u?.['name']??'?')+'\x22\x20has\x20neither\x20namedOperator\x20nor\x20permissionIndex\x20—\x20no\x20one\x20can\x20advance\x20it');}}}}else d['push']('pre_publish:\x20publishing\x20machine\x20without\x20inline\x20node\x20data\x20—\x20topology\x20not\x20verifiable\x20in\x20this\x20call;\x20'+'verify\x20nodes/pairs/forwards\x20via\x20machineNode2file\x20BEFORE\x20publish\x20(immutable\x20after\x20publish,\x20IMMUT-001)');d['push']('pre_publish:\x20machine\x20nodes/pairs/forwards\x20become\x20immutable\x20after\x20publish\x20(IMMUT-001)');}return e==='service'&&(d['push']('pre_publish:\x20service\x20machine/order_allocators/arbitrations\x20become\x20immutable\x20after\x20publish\x20(IMMUT-002);\x20sales\x20remains\x20modifiable'),g['machine']===undefined&&d['push']('pre_publish:\x20\x27machine\x27\x20not\x20set\x20in\x20this\x20call\x20—\x20if\x20the\x20service\x20was\x20never\x20bound\x20to\x20a\x20published\x20machine,\x20'+'it\x20cannot\x20process\x20orders\x20and\x20CANNOT\x20be\x20fixed\x20after\x20publish'),g['order_allocators']===undefined&&d['push']('pre_publish:\x20\x27order_allocators\x27\x20not\x20set\x20in\x20this\x20call\x20—\x20immutable\x20after\x20publish;\x20'+'orders\x20will\x20have\x20no\x20fund\x20distribution\x20if\x20never\x20configured')),{'critical':c,'warnings':d};}function buildHarnessBlockResult(a,b,c,d,e,f){const g=[...c['map'](i=>'CRITICAL:\x20'+i),...d['map'](i=>'WARN:\x20'+i)]['join']('\x0a'),h='Error:\x20'+b+(g?'\x0a'+g:'')+'\x0aRecovery:\x20'+f;return{'content':[{'type':'text','text':h}],'structuredContent':{'outcome':'failed','result':{'type':'error','error':b+'\x20[gate='+a+']','error_code':e,'retryable':![],'recovery_hint':f},'message':h,'recovery':recover(e,'harness:'+a)}};}function extractCriticalFindingCount(a){const b=a?.['structuredContent'];if(!b)return 0x0;const c=b['semantic'],d=c?.['summary'];if(typeof d?.['critical_count']==='number'&&d['critical_count']>0x0)return d['critical_count'];const e=b['findings']??c?.['findings'];if(Array['isArray'](e))return e['filter'](h=>h?.['severity']==='error')['length'];const f=a?.['content']?.['map'](h=>'text'in h?h['text']:'')['join']('\x0a')??'',g=f['match'](/\[AUDIT ERROR\]/g);return g?g['length']:0x0;}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wowok/agent-mcp",
3
- "version": "3.1.0",
3
+ "version": "3.1.3",
4
4
  "description": "Making It Easy for AI Agents to Communicate, Collaborate, Trade, and Trust.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -50,7 +50,7 @@
50
50
  "license": "Apache-2.0",
51
51
  "dependencies": {
52
52
  "@modelcontextprotocol/server": "^2.0.0",
53
- "@wowok/wowok": "3.1.0",
53
+ "@wowok/wowok": "3.1.3",
54
54
  "lodash": "^4.18.1",
55
55
  "zod": "^4.2.0"
56
56
  },
@@ -63,8 +63,9 @@
63
63
  },
64
64
  "scripts": {
65
65
  "clean": "node -e \"fs.rmSync('dist',{recursive:true,force:true})\"",
66
- "build": "pnpm clean && pnpm check:hygiene && tsc && pnpm generate:schemas && pnpm obfuscate",
66
+ "build": "pnpm clean && pnpm check:hygiene && tsc && pnpm copy:standards && pnpm generate:schemas && pnpm obfuscate",
67
67
  "check:hygiene": "node --import tsx/esm scripts/check-hygiene.ts",
68
+ "copy:standards": "node -e \"const fs=require('fs');fs.mkdirSync('dist/knowledge/baselines',{recursive:true});fs.copyFileSync('src/knowledge/baselines/evaluation-baselines.json','dist/knowledge/baselines/evaluation-baselines.json')\"",
68
69
  "obfuscate": "javascript-obfuscator dist --output dist --config obfuscator.json",
69
70
  "watch": "tsc --watch",
70
71
  "start": "tsx src/index.ts",
@@ -1,32 +0,0 @@
1
- import { type InfoPuzzle, type RiskScore, type UserPreferences, type Industry, type StrategyRecommendation, type PreferenceMatchResult, type ServiceForMatching, type IndustryRiskResult, type Reminder, type ReminderContext } from "./index.js";
2
- export interface PreorderAdviceInput {
3
- puzzle: InfoPuzzle;
4
- risk?: RiskScore;
5
- preferences?: UserPreferences;
6
- industry?: Industry;
7
- matching_overrides?: Partial<ServiceForMatching>;
8
- reminder_overrides?: Partial<ReminderContext>;
9
- overrides?: Record<string, string>;
10
- max_strategies?: number;
11
- max_reminders?: number;
12
- }
13
- export interface ConfidenceScore {
14
- score: number;
15
- base: number;
16
- user_adjustment: number;
17
- preference_nudge: number;
18
- explanation: string;
19
- }
20
- export interface PreorderAdvice {
21
- service_id: string;
22
- risk: RiskScore;
23
- industry?: Industry;
24
- strategies: StrategyRecommendation[];
25
- preference_match?: PreferenceMatchResult;
26
- industry_risks?: IndustryRiskResult;
27
- reminders: Reminder[];
28
- blocking_reminders: Reminder[];
29
- confidence: ConfidenceScore;
30
- summary: string;
31
- }
32
- export declare function assemblePreorderAdvice(input: PreorderAdviceInput): PreorderAdvice;
@@ -1 +0,0 @@
1
- import{assessRisk,detectScenarios,recommendStrategy,matchServiceToPreferences,assessIndustryRisks,inferIndustry,generateReminders,getBlockingReminders,sortAndCapReminders}from'./index.js';import{registryDisplayHint}from'../knowledge/fund-layer.js';export function assemblePreorderAdvice(a){const {puzzle:b}=a,c=a['risk']??assessRisk(b),d=a['industry']??inferIndustry(b),e=detectScenarios(b),f=e['slice'](0x0,a['max_strategies']??0x3)['map'](m=>recommendStrategy(m,{'puzzle':b,'prefs':a['preferences']}));let g;if(a['preferences']){const m=toMatchingService(b,c,a['matching_overrides']);g=matchServiceToPreferences(m,a['preferences']);}let h;d&&(h=assessIndustryRisks(b,d));const i=buildReminderContext(b,c,a['reminder_overrides']),j=applyMissingArbitrationOverride(sortAndCapReminders(generateReminders(i))['slice'](0x0,a['max_reminders']??0x8),a['overrides']),k=getBlockingReminders(j),l=computeConfidence(b,c,g);return{'service_id':b['service_id'],'risk':c,'industry':d,'strategies':f,'preference_match':g,'industry_risks':h,'reminders':j,'blocking_reminders':k,'confidence':l,'summary':buildSummary(b,c,d,f,g,k,l)};}function toMatchingService(a,b,c){const d=a['service_basics'],e=a['fund_safety'],f=a['trust_signals'],g=a['merchant_behavior'];return{'service_id':a['service_id'],'price':d['price_raw'],'token_type':d['token_type']??'','avg_market_price':a['market_context']?.['avg_price'],'merchant_order_history_count':g?.['total_orders']??0x0,'merchant_age':g?g['total_orders']>=0x32?'established':'emerging':'unknown','has_arbitration':(f?.['arbitration_count']??0x0)>0x0,'has_compensation_fund':e?e['compensation_ratio']>0x0:![],'has_reward_activity':![],'has_discount':![],'risk_score':b['total'],'trust_score':f?.['trust_score']??0x32,'requires_messenger':![],'after_sales_support_level':f?.['has_messenger']?'full':'minimal',...c};}function applyMissingArbitrationOverride(a,b){if(b?.['risk.missing_arbitration']!=='block')return a;return a['map'](c=>c['id']==='browse_no_arbitration'?{...c,'priority':'required'}:c);}function buildReminderContext(a,b,c){const d=a['trust_signals'],e=a['fund_safety'],f=a['workflow_analysis'];return{'stage':'preorder','service_id':a['service_id'],'review_count':d?.['review_total'],'like_rate':d?.['like_rate'],'avg_market_price':a['market_context']?.['avg_price'],'service_price':a['service_basics']['price_raw'],'token':registryDisplayHint(a['service_basics']['token_type']),'has_arbitration':(d?.['arbitration_count']??0x0)>0x0,'has_compensation':e?e['compensation_ratio']>0x0:undefined,'compensation_ratio':e?.['compensation_ratio'],'risk_score':b['total'],'risk_level':b['level'],'has_refund_path':f?.['has_refund_path'],'has_arb_refund_path':f?.['has_arb_refund_path'],'has_refund_allocator':f?.['has_refund_allocator'],'has_messenger':d?.['has_messenger'],'customer_required':a['service_basics']['customer_required'],...c};}function computeConfidence(a,b,c){const d=Math['max'](0x0,Math['min'](0x64,0x64-b['total'])),e=a['user_metrics']?.['adjustment']??0x0,f=c?Math['round']((c['score']-0x32)/0xa):0x0,g=Math['max'](0x0,Math['min'](0x64,d+e+f)),h=['base\x20'+d+'\x20(=\x20100\x20-\x20risk\x20'+b['total']+')'];if(e!==0x0)h['push']('your\x20custom\x20metrics\x20'+(e>0x0?'+':'')+e);if(f!==0x0)h['push']('preference\x20fit\x20'+(f>0x0?'+':'')+f);return{'score':g,'base':d,'user_adjustment':e,'preference_nudge':f,'explanation':'Confidence\x20'+g+'/100\x20=\x20'+h['join']('\x20')+'.\x20'+'This\x20is\x20evidence\x20aggregation,\x20not\x20advice\x20—\x20the\x20decision\x20is\x20yours.'};}function buildSummary(a,b,c,d,e,f,g){const h=['Order\x20confidence\x20'+g['score']+'/100\x20(risk\x20'+b['total']+'/100,\x20level\x20'+b['level']+')'+(c?'\x20for\x20'+c+'\x20service':'')+('.\x20Information\x20completeness\x20'+Math['round'](a['completeness']*0x64)+'%.')];f['length']>0x0&&h['push']('⚠️\x20'+f['length']+'\x20blocking\x20concern(s):\x20'+f['map'](i=>i['message'])['join'](';\x20'));b['red_flags']['length']>0x0&&h['push']('Red\x20flags:\x20'+b['red_flags']['slice'](0x0,0x3)['join'](';\x20')+'.');if(d['length']>0x0){const i=d[0x0];h['push']('Key\x20protection\x20('+i['scenario']+'):\x20'+i['strategy']['user_strategy']);}return e&&h['push'](e['mismatches']['length']>0x0?'Preference\x20mismatches:\x20'+e['mismatches']['slice'](0x0,0x2)['join'](';\x20')+'.':'Service\x20matches\x20your\x20preferences\x20(score\x20'+e['score']+'/100).'),a['gaps']['length']>0x0&&h['push']('Missing\x20information:\x20'+a['gaps']['join'](',\x20')+'\x20—\x20consider\x20asking\x20the\x20merchant\x20via\x20Messenger\x20before\x20ordering.'),h['join']('\x20');}
@@ -1,146 +0,0 @@
1
- import type { InfoPuzzle, ServiceBasics, WorkflowAnalysis, FundSafety, TrustSignals, MerchantBehavior, MarketContext, PuzzleDepth, UserMetricsConfig, UserMetricsResult, ServiceNestingEvaluation } from "./types.js";
2
- import { CUSTOMER_INTELLIGENCE_VERSION } from "./types.js";
3
- export interface ServiceRawData {
4
- name?: string;
5
- bPublished?: boolean;
6
- bPaused?: boolean;
7
- price?: string;
8
- priceRaw?: bigint;
9
- token_type?: string;
10
- sales?: Array<{
11
- suspension?: boolean;
12
- wip_url?: string;
13
- wip_hash?: string;
14
- }>;
15
- machine?: string;
16
- buy_guard?: string;
17
- customer_required?: unknown[];
18
- arbitrations?: string[];
19
- compensation_fund?: {
20
- balance?: bigint;
21
- };
22
- compensation_lock_duration?: number;
23
- um?: string;
24
- order_allocators?: Array<{
25
- allocators?: Array<{
26
- amount?: {
27
- type?: string;
28
- value?: bigint;
29
- };
30
- surplus_to?: string;
31
- guard?: string;
32
- marker?: {
33
- node?: string;
34
- };
35
- }>;
36
- }>;
37
- }
38
- export interface MachineNodeRaw {
39
- name: string;
40
- forwards?: Array<{
41
- name?: string;
42
- weight?: number;
43
- namedOperator?: string | null;
44
- guard?: string | null;
45
- to?: string;
46
- }>;
47
- is_pair_done?: boolean;
48
- }
49
- export interface ReviewRaw {
50
- rating?: "like" | "dislike" | string;
51
- reviewer?: string;
52
- verified?: boolean;
53
- has_evidence?: boolean;
54
- timestamp?: number;
55
- }
56
- export interface EventRaw {
57
- type: string;
58
- timestamp?: number;
59
- address?: string;
60
- data?: Record<string, unknown>;
61
- }
62
- export declare function assembleServiceBasics(serviceId: string, raw: ServiceRawData, wipVerified?: boolean): ServiceBasics;
63
- export declare function assembleWorkflowAnalysis(nodes: MachineNodeRaw[], isPublished: boolean, isPaused: boolean, serviceRaw?: ServiceRawData): WorkflowAnalysis;
64
- export declare function assembleFundSafety(raw: ServiceRawData, orderAmount: bigint): FundSafety;
65
- export declare function assembleTrustSignals(service: ServiceRawData, reviews: ReviewRaw[], trustScore: {
66
- score: number;
67
- level: string;
68
- }, arbitrationOwner?: string, serviceOwner?: string, permissionShared?: boolean, permissionOverlap?: boolean): TrustSignals;
69
- export declare function assembleMerchantBehavior(events: EventRaw[], orderHistory?: Array<{
70
- status: string;
71
- has_dispute: boolean;
72
- is_repeat: boolean;
73
- }>, reputation?: {
74
- likes: number;
75
- dislikes: number;
76
- }): MerchantBehavior;
77
- export declare function assembleMarketContext(similarServices: Array<{
78
- price: bigint;
79
- }>, currentPrice: bigint): MarketContext;
80
- export interface PuzzleRawData {
81
- service: ServiceRawData;
82
- machine_nodes?: MachineNodeRaw[];
83
- machine_published?: boolean;
84
- machine_paused?: boolean;
85
- reviews?: ReviewRaw[];
86
- events?: EventRaw[];
87
- similar_services?: Array<{
88
- price: bigint;
89
- }>;
90
- order_amount?: bigint;
91
- trust_score?: {
92
- score: number;
93
- level: string;
94
- };
95
- arbitration_owner?: string;
96
- service_owner?: string;
97
- wip_verified?: boolean;
98
- order_history?: Array<{
99
- status: string;
100
- has_dispute: boolean;
101
- is_repeat: boolean;
102
- }>;
103
- merchant_reputation?: {
104
- likes: number;
105
- dislikes: number;
106
- };
107
- user_metrics_config?: UserMetricsConfig;
108
- user_metrics_context?: Record<string, unknown>;
109
- service_nesting_raw?: ServiceNestingRawData;
110
- service_nesting?: ServiceNestingEvaluation;
111
- }
112
- export declare function assembleInfoPuzzle(serviceId: string, raw: PuzzleRawData, depth?: PuzzleDepth): InfoPuzzle;
113
- export declare function assembleUserMetrics(config: UserMetricsConfig, context: Record<string, unknown>): UserMetricsResult;
114
- export interface ServiceNestingRawData {
115
- service_id: string;
116
- depth?: number;
117
- maxDepth?: number;
118
- machine?: {
119
- object_id: string;
120
- published: boolean;
121
- paused: boolean;
122
- has_dispute_anti_pattern?: boolean;
123
- has_no_entry?: boolean;
124
- has_no_terminal?: boolean;
125
- structural_issue_count?: number;
126
- };
127
- arbitrations?: Array<{
128
- object_id: string;
129
- voting_guard_count: number;
130
- fee_balance: bigint;
131
- paused: boolean;
132
- }>;
133
- rewards?: Array<{
134
- object_id: string;
135
- balance: bigint;
136
- guard_count: number;
137
- expiration_time?: number;
138
- }>;
139
- repositories?: Array<{
140
- object_id: string;
141
- has_write_guard: boolean;
142
- is_empty: boolean;
143
- }>;
144
- }
145
- export declare function evaluateServiceNesting(raw: ServiceNestingRawData): ServiceNestingEvaluation | undefined;
146
- export { CUSTOMER_INTELLIGENCE_VERSION };
@@ -1 +0,0 @@
1
- import{CUSTOMER_INTELLIGENCE_VERSION}from'./types.js';export function assembleServiceBasics(a,b,c=![]){const d=(b['sales']??[])['filter'](f=>!f['suspension']),e=d['some'](f=>f['wip_hash']&&f['wip_hash']['length']>0x0);return{'service_id':a,'name':b['name']??a,'bPublished':b['bPublished']??![],'bPaused':b['bPaused']??![],'price':b['price']??'0','price_raw':b['priceRaw']??0x0n,'token_type':b['token_type']??'0x2::wow::WOW','sales_count':d['length'],'machine_id':b['machine'],'buy_guard_id':b['buy_guard'],'customer_required_count':b['customer_required']?.['length']??0x0,'customer_required':(b['customer_required']??[])['filter'](f=>typeof f==='string'),'arbitrations_count':b['arbitrations']?.['length']??0x0,'compensation_fund_balance':b['compensation_fund']?.['balance']??0x0n,'compensation_lock_duration':b['compensation_lock_duration']??0x0,'um_id':b['um'],'has_wip':e,'wip_verified':c};}export function assembleWorkflowAnalysis(a,b,c,d){const e=[],f=[],g=[];let h=0x0,i=0x0,j=0x0,k=![],l=![],m=![];const n=/(^|_)(disputed?|refund(?:ed)?|arbitration|arb)(_|$)/i,o=/^(wonder|no_wonder|praise|complain|thumbs_up|thumbs_down|positive_review|negative_review)$/i,p=a['reduce']((w,x)=>w+(x['forwards']?.['length']??0x0),0x0);for(const w of a){n['test'](w['name']['trim']())&&(m=!![]);}for(const x of a){const y=x['forwards']??[];y['length']===0x0&&f['push'](x['name']);for(const z of y){const A=z['namedOperator'],B=z['guard'];if(A==='')B?j++:h++;else A===null||A===undefined?i++:i++;const C=(z['to']??'')['trim']()['toLowerCase']();o['test'](C)&&(l=!![]),C['includes']('milestone')&&(k=!![]);}}for(const D of a){const E=D['forwards']??[];if(E['length']>0x0&&!f['includes'](D['name'])){const F=E['every'](G=>G['namedOperator']!==''&&G['namedOperator']!==null);F&&h===0x0&&g['push'](D['name']);}}const q=(d?.['arbitrations']?.['length']??0x0)>0x0,r=d?.['compensation_fund']?.['balance']??0x0n,s=q&&r>0x0n,t=d?.['order_allocators']?.[0x0]?.['allocators']??[],u=t['some'](G=>G['surplus_to']==='order'||G['surplus_to']==='Order'),v=s||u;if(!v)e['push']('no_refund_path');if(!q)e['push']('no_arbitration_binding');if(m)e['push']('dispute_anti_pattern');if(h===0x0)e['push']('no_user_operable_path');if(g['length']>0x0)e['push']('potential_dead_ends');return{'machine_published':b,'machine_paused':c,'total_nodes':a['length'],'total_forwards':p,'user_operable_forwards':h,'provider_only_forwards':i,'guard_gated_forwards':j,'has_refund_path':v,'has_arb_refund_path':s,'has_refund_allocator':u,'has_arbitration_path':q,'has_arbitration_binding':q,'has_wonder_node':l,'has_dispute_anti_pattern':m,'has_milestone_nodes':k,'dead_end_nodes':g,'terminal_nodes':f,'risk_signals':e};}export function assembleFundSafety(a,b){const c=a['order_allocators']?.[0x0]?.['allocators']??[],d=a['compensation_fund']?.['balance']??0x0n,e=a['compensation_lock_duration']??0x0,f=c['find'](j=>{const k=j['amount'];return k?.['type']==='FixedValue'&&k['value']===b;}),g=c['some'](j=>j['surplus_to']==='order'||j['surplus_to']==='Order');let h='none';b>0x0n&&(d>0x0n&&b>d*0x3n&&(h='low'));const i=e===0x0||e>0x7;return{'has_order_allocator':c['length']>0x0,'has_refund_allocator':!!f||g,'allocator_count':c['length'],'refund_allocator_exists':g,'surplus_to_provider':c['some'](j=>j['surplus_to']!=='order'&&j['surplus_to']!=='Order'),'user_path_has_allocator':c['length']>0x0,'compensation_covers_order':d>=b,'compensation_ratio':b>0x0n?Math['min'](0x1,Number(d*0x64n/b)/0x64):0x0,'lock_duration_safe':i,'price_anomaly':h};}export function assembleTrustSignals(a,b,c,d,e,f,g){const h=b['filter'](n=>n['rating']==='like')['length'],i=b['filter'](n=>n['rating']==='dislike')['length'],j=b['filter'](n=>n['verified']||n['has_evidence'])['length'],k=b['length'],l=k>0x0?h/k:0x0,m=d!==undefined&&e!==undefined?d!==e:!![];return{'arbitration_independent':m,'arbitration_count':a['arbitrations']?.['length']??0x0,'arbitration_paused':![],'review_likes':h,'review_dislikes':i,'review_verified_count':j,'review_total':k,'like_rate':l,'trust_score':c['score'],'trust_level':c['level'],'has_contact':!!a['um'],'has_messenger':!!a['um'],'arbitration_permission_shared':f,'arbitration_permission_overlap':g};}const REPUTATION_MIN_VOTES=0x3;function toReputation(a){const b=a['likes']+a['dislikes'];return{'likes':a['likes'],'dislikes':a['dislikes'],'like_ratio':b>0x0?a['likes']/b:0x1};}function reputationRedFlags(a){if(!a)return[];const b=a['likes']+a['dislikes'];if(b>=REPUTATION_MIN_VOTES&&a['like_ratio']<0.5)return['reputation_negative'];return[];}export function assembleMerchantBehavior(a,b,c){const d=c?toReputation(c):undefined,e=reputationRedFlags(d);if(b&&b['length']>0x0){const l=b['length'],m=b['filter'](v=>v['status']==='completed')['length'],n=b['filter'](v=>v['has_dispute'])['length'],o=b['filter'](v=>v['is_repeat'])['length'],p=l>0x0?m/l:0x0,q=l>0x0?n/l:0x0,r=l>0x0?o/l:0x0,s=Math['floor'](l/0x2);let t='stable';if(l>=0x4&&s>0x0){const v=b['slice'](0x0,s)['filter'](z=>z['has_dispute'])['length'],w=b['slice'](s)['filter'](z=>z['has_dispute'])['length'],x=v/s,y=w/(l-s);if(y<x*0.85)t='improving';else{if(y>x*1.15)t='declining';}}const u=[...e];if(q>0.1)u['push']('dispute_rate_high');if(t==='declining')u['push']('declining_trend');return{'total_orders':l,'completed_rate':p,'dispute_rate':q,'refund_rate':0x0,'arb_loss_rate':0x0,'repeat_buyer_rate':r,'recent_trend':t,'red_flags':u,'reputation':d};}const f=a['filter'](z=>z['type']['includes']('Order')||z['type']['includes']('order')),g=a['filter'](z=>z['type']['includes']('Dispute')||z['type']['includes']('Arb')),h=f['length'],i=g['length'],j=h>0x0?i/h:0x0,k=[...e];if(j>0.1)k['push']('dispute_rate_high');return{'total_orders':h,'completed_rate':h>0x0?Math['max'](0x0,0x1-j):0x0,'dispute_rate':j,'refund_rate':0x0,'arb_loss_rate':0x0,'repeat_buyer_rate':0x0,'recent_trend':'stable','red_flags':k,'reputation':d};}export function assembleMarketContext(a,b){if(a['length']===0x0)return{'similar_services_count':0x0,'avg_price':0x0n,'min_price':0x0n,'max_price':0x0n,'price_percentile':0x0,'supply_demand_ratio':0x0};const c=a['map'](j=>j['price'])['sort']((j,k)=>j<k?-0x1:j>k?0x1:0x0),d=c['reduce']((j,k)=>j+k,0x0n),e=d/BigInt(c['length']),f=c[0x0],g=c[c['length']-0x1];let h=0x0;for(const j of c){if(j<b)h++;}const i=c['length']>0x0?h/c['length']:0x0;return{'similar_services_count':a['length'],'avg_price':e,'min_price':f,'max_price':g,'price_percentile':i,'supply_demand_ratio':0x0};}export function assembleInfoPuzzle(a,b,c='evaluate'){const d=[],e=assembleServiceBasics(a,b['service'],b['wip_verified']??![]);let f,g,h;if(c==='evaluate'||c==='preorder'||c==='monitor'){b['machine_nodes']?f=assembleWorkflowAnalysis(b['machine_nodes'],b['machine_published']??![],b['machine_paused']??![],b['service']):d['push']('machine_workflow');const m=b['order_amount']??e['price_raw'];g=assembleFundSafety(b['service'],m),b['reviews']&&b['trust_score']?h=assembleTrustSignals(b['service'],b['reviews'],b['trust_score'],b['arbitration_owner'],b['service_owner']):d['push']('reviews_or_trust_score');}let i;if(c==='preorder'||c==='monitor'){if(b['events']||b['order_history'])i=assembleMerchantBehavior(b['events']??[],b['order_history'],b['merchant_reputation']);else b['merchant_reputation']?i=assembleMerchantBehavior([],undefined,b['merchant_reputation']):d['push']('merchant_behavior');}let j;(c==='evaluate'||c==='preorder')&&(b['similar_services']?j=assembleMarketContext(b['similar_services'],e['price_raw']):d['push']('market_context'));let k;b['user_metrics_config']&&b['user_metrics_config']['metrics']['length']>0x0&&(k=assembleUserMetrics(b['user_metrics_config'],b['user_metrics_context']??{}));let l=b['service_nesting'];return!l&&b['service_nesting_raw']&&(l=evaluateServiceNesting(b['service_nesting_raw'])),{'service_id':a,'service_basics':e,'workflow_analysis':f,'fund_safety':g,'trust_signals':h,'merchant_behavior':i,'market_context':j,'user_metrics':k,'service_nesting':l,'completeness':computeCompleteness(c,[e,f,g,h,i,j,k,l]),'gaps':d,'assembled_at':Date['now']()};}export function assembleUserMetrics(a,b){const c=a['adjustment_cap']??0xa,d=[],e=a['metrics']['reduce']((i,j)=>i+Math['max'](0x0,j['weight']),0x0);for(const i of a['metrics']){const j=e>0x0?Math['max'](0x0,i['weight'])/e:0x0,k=resolvePath(b,i['params']['path']??i['name']),{passed:l,score:m,observed_value:n}=evaluateMetric(i,k);d['push']({'name':i['name'],'label':i['label'],'passed':l,'score':m,'observed_value':formatObservedValue(k),'weight':j,'advice':l?i['advice_on_pass']:i['advice_on_fail']});}const f=d['reduce']((o,p)=>o+p['score']*p['weight'],0x0),g=Math['round'](f*0x64),h=Math['round']((g-0x32)/0x32*c);return{'metrics':d,'score':g,'adjustment':h,'source_file':a['source_file'],'evaluated_at':Date['now']()};}function resolvePath(a,b){if(!b)return undefined;const c=b['split']('.');let d=a;for(const e of c){if(d===null||d===undefined)return undefined;if(typeof d!=='object')return undefined;d=d[e];}return d;}function evaluateMetric(a,b){const c=a['params'];switch(a['evaluator']){case'threshold':{const d=typeof b==='number'?b:typeof b==='string'?Number(b):typeof b==='bigint'?Number(b):NaN,e=typeof c['threshold']==='number'?c['threshold']:typeof c['threshold']==='string'?Number(c['threshold']):NaN;if(isNaN(d)||isNaN(e))return{'passed':![],'score':0x0,'observed_value':b};const f=c['invert']?d<=e:d>=e,g=Math['abs'](e)*0.5||0x1,h=c['invert']?(e-d)/g+0x1:(d-e)/g+0x1,i=Math['max'](0x0,Math['min'](0x1,h));return{'passed':f,'score':i,'observed_value':b};}case'ratio':{const j=typeof b==='number'?b:typeof b==='string'?Number(b):NaN,k=c['min']??0x0,l=c['max']??0x1;if(isNaN(j))return{'passed':![],'score':0x0,'observed_value':b};const m=j>=k&&j<=l,n=l-k,o=(k+l)/0x2,q=n>0x0?Math['max'](0x0,0x1-Math['abs'](j-o)/(n/0x2)):0x1;return{'passed':m,'score':q,'observed_value':b};}case'boolean':{const r=!!b;return{'passed':r,'score':r?0x1:0x0,'observed_value':b};}case'presence':{const s=b!==undefined&&b!==null&&b!=='';return{'passed':s,'score':s?0x1:0x0,'observed_value':b};}case'regex_match':{if(typeof b!=='string'||!c['pattern'])return{'passed':![],'score':0x0,'observed_value':b};try{const t=new RegExp(c['pattern']),u=t['test'](b);return{'passed':u,'score':u?0x1:0x0,'observed_value':b};}catch{return{'passed':![],'score':0x0,'observed_value':b};}}case'custom_query':{return{'passed':![],'score':0.5,'observed_value':b};}default:return{'passed':![],'score':0x0,'observed_value':b};}}function formatObservedValue(a){if(typeof a==='string'||typeof a==='number'||typeof a==='boolean')return a;if(typeof a==='bigint')return a['toString']();if(a===undefined||a===null)return undefined;try{return JSON['stringify'](a);}catch{return String(a);}}function computeCompleteness(a,b){const c=a==='browse'?0x1:a==='evaluate'?0x4:a==='preorder'?0x6:0x5,d=b['slice'](0x0,c),e=d['filter'](f=>f!==undefined&&f!==null)['length'];return Math['min'](0x1,e/c);}export function evaluateServiceNesting(b){const c=b['depth']??0x0,d=b['maxDepth']??0x3,e=c>=d,f={'arbitrations':[],'rewards':[],'repositories':[]};let g=0x0;if(b['machine']){const v=b['machine'],w=[];let x=0x0;if(v['published'])x+=0xa;else w['push']('Machine\x20not\x20published');v['paused']&&(x+=0x28,w['push']('Machine\x20paused'));v['has_no_entry']&&(x+=0x32,w['push']('No\x20entry\x20point\x20(R-M1-01)'));v['has_no_terminal']&&(x+=0x32,w['push']('No\x20terminal\x20node\x20(R-M1-02)'));v['has_dispute_anti_pattern']&&(x+=0x3c,w['push']('Dispute\x20anti-pattern\x20(R-M1-11):\x20machine\x20illegally\x20models\x20dispute\x20flow'));const y=v['structural_issue_count']??0x0;y>0x0&&(x+=y*0xf,w['push'](y+'\x20structural\x20issue(s)\x20detected\x20(cycles/dead-ends/orphans)')),x=Math['min'](0x64,x),f['machine']={'object_id':v['object_id'],'published':v['published'],'risk_level':scoreToNestingLevel(x),'issues':w},g++;}for(const z of b['arbitrations']??[]){const A=[];let B=0x0;if(z['voting_guard_count']===0x0)B+=0x32,A['push']('No\x20voting_guard\x20configured\x20—\x20no\x20arbitrators\x20can\x20vote');else z['voting_guard_count']<=0x2?(B+=0x1e,A['push']('Few\x20arbitrators\x20(<=2)\x20—\x20limited\x20dispute\x20resolution\x20capacity')):B+=0xa;z['paused']&&(B+=0x28,A['push']('Arbitration\x20paused\x20—\x20disputes\x20cannot\x20be\x20filed')),z['fee_balance']===0x0n&&(B+=0x1e,A['push']('No\x20compensation\x20fund\x20balance\x20—\x20rulings\x20cannot\x20pay\x20out')),B=Math['min'](0x64,B),f['arbitrations']['push']({'object_id':z['object_id'],'voting_guard_count':z['voting_guard_count'],'fee_balance':z['fee_balance']['toString'](),'paused':z['paused'],'risk_level':scoreToNestingLevel(B),'issues':A}),g++;}for(const C of b['rewards']??[]){const D=[];let E=0x0;C['balance']===0x0n&&(E+=0x3c,D['push']('Reward\x20fund\x20empty\x20—\x20claims\x20will\x20fail')),C['guard_count']===0x0&&(E+=0x32,D['push']('No\x20claim_guard\x20—\x20anyone\x20could\x20claim\x20(or\x20no\x20one\x20can,\x20depending\x20on\x20default)')),C['expiration_time']&&C['expiration_time']>0x0&&C['expiration_time']<Date['now']()&&(E+=0x28,D['push']('Reward\x20expired\x20—\x20claims\x20no\x20longer\x20possible')),E=Math['min'](0x64,E),f['rewards']['push']({'object_id':C['object_id'],'balance':C['balance']['toString'](),'guard_count':C['guard_count'],'risk_level':scoreToNestingLevel(E),'issues':D}),g++;}for(const F of b['repositories']??[]){const G=[];let H=0x0;!F['has_write_guard']&&(H+=0x28,G['push']('No\x20write_guard\x20—\x20Repository\x20is\x20open\x20to\x20arbitrary\x20writes')),F['is_empty']&&(H+=0x14,G['push']('Repository\x20empty\x20—\x20no\x20historical\x20data\x20for\x20evaluation')),H=Math['min'](0x64,H),f['repositories']['push']({'object_id':F['object_id'],'risk_level':scoreToNestingLevel(H),'issues':G}),g++;}if(g===0x0)return undefined;const h=f['machine']?nestingLevelToScore(f['machine']['risk_level']):0x0,i=f['machine']?0x23:0x0,j=f['arbitrations']['length']>0x0?Math['max'](...f['arbitrations']['map'](I=>nestingLevelToScore(I['risk_level']))):0x0,k=f['arbitrations']['length']>0x0?0x1e:0x0,l=f['rewards']['length']>0x0?Math['max'](...f['rewards']['map'](I=>nestingLevelToScore(I['risk_level']))):0x0,n=f['rewards']['length']>0x0?0x14:0x0,o=f['repositories']['length']>0x0?Math['max'](...f['repositories']['map'](I=>nestingLevelToScore(I['risk_level']))):0x0,p=f['repositories']['length']>0x0?0xf:0x0,q=i+k+n+p,s=q>0x0?Math['round']((h*i+j*k+l*n+o*p)/q):0x0,t=[];if(f['machine'])t['push'](f['machine']['risk_level']);for(const I of f['arbitrations'])t['push'](I['risk_level']);for(const J of f['rewards'])t['push'](J['risk_level']);for(const K of f['repositories'])t['push'](K['risk_level']);const u=t['reduce'](highestLevel,'low');return{'depth_reached':c,'truncated':e,'bindings':f,'overall_risk_level':u,'overall_risk_score':s,'total_bindings_evaluated':g,'evaluated_at':Date['now']()};}function scoreToNestingLevel(a){if(a>=0x4b)return'critical';if(a>=0x32)return'high';if(a>=0x19)return'medium';return'low';}function nestingLevelToScore(a){switch(a){case'critical':return 0x5a;case'high':return 0x41;case'medium':return 0x28;case'low':return 0xa;}}function highestLevel(c,d){const e={'low':0x0,'medium':0x1,'high':0x2,'critical':0x3};return e[c]>=e[d]?c:d;}export{CUSTOMER_INTELLIGENCE_VERSION};
@@ -1,17 +0,0 @@
1
- import type { InfoPuzzle, UserPreferences, GameStrategy, GameScenario } from "./types.js";
2
- import { CUSTOMER_INTELLIGENCE_VERSION } from "./types.js";
3
- export interface StrategyContext {
4
- puzzle: InfoPuzzle;
5
- prefs?: UserPreferences;
6
- merchant_signals?: string[];
7
- }
8
- export interface StrategyRecommendation {
9
- scenario: GameScenario;
10
- strategy: GameStrategy;
11
- confidence: number;
12
- fallback?: string;
13
- rationale: string;
14
- }
15
- export declare function recommendStrategy(scenario: GameScenario, ctx: StrategyContext): StrategyRecommendation;
16
- export declare function detectScenarios(puzzle: InfoPuzzle): GameScenario[];
17
- export { CUSTOMER_INTELLIGENCE_VERSION };
@@ -1 +0,0 @@
1
- import{CUSTOMER_INTELLIGENCE_VERSION}from'./types.js';const SCENARIO_SPECS={'info_asymmetry':{'scenario':'info_asymmetry','merchant_tactic':'Hides\x20key\x20workflow\x20information;\x20Machine\x20is\x20not\x20public','user_strategy':'Request\x20machineNode2file\x20export\x20+\x20Guard\x20configuration;\x20ask\x20about\x20key\x20nodes\x20via\x20Messenger','nash_equilibrium':'Merchant\x20becomes\x20transparent\x20(provides\x20full\x20Machine\x20docs)\x20↔\x20User\x20purchases','fallback':'Abandon\x20purchase','confidence':a=>{if(a['workflow_analysis']===undefined)return 0.9;if(a['completeness']<0.5)return 0.9;return 0.5;},'rationale':a=>{if(a['workflow_analysis']===undefined)return'Workflow\x20structure\x20analysis\x20missing;\x20severe\x20information\x20asymmetry';if(a['completeness']<0.5)return'Information\x20completeness\x20is\x20only\x20'+Math['round'](a['completeness']*0x64)+'%;\x20key\x20puzzle\x20pieces\x20missing';return'Information\x20completeness\x20is\x20acceptable,\x20but\x20still\x20recommend\x20requesting\x20Machine\x20docs';}},'fund_safety':{'scenario':'fund_safety','merchant_tactic':'No\x20compensation\x20fund\x20or\x20insufficient\x20compensation\x20fund','user_strategy':'Require\x20merchant\x20to\x20top\x20up\x20compensation_fund\x20to\x20100%\x20of\x20order\x20amount;\x20write\x20into\x20WTS\x20agreement','nash_equilibrium':'Merchant\x20tops\x20up\x20compensation\x20fund\x20↔\x20User\x20purchases','fallback':'Choose\x20another\x20merchant\x20or\x20require\x20arbitration\x20upfront','confidence':a=>{const b=a['fund_safety'];if(!b)return 0.6;if(b['compensation_covers_order']===![])return 0.95;return 0.4;},'rationale':a=>{const b=a['fund_safety'];if(!b)return'Fund\x20safety\x20analysis\x20missing';if(b['compensation_covers_order']===![])return'Compensation\x20fund\x20covers\x20only\x20'+Math['round'](b['compensation_ratio']*0x64)+'%\x20of\x20order\x20amount';return'Compensation\x20fund\x20covers\x20the\x20order\x20amount';}},'refund_dispute':{'scenario':'refund_dispute','merchant_tactic':'No\x20refund\x20path\x20or\x20unfair\x20refund\x20Allocator\x20configuration','user_strategy':'Negotiate\x20refund\x20terms\x20via\x20Messenger\x20+\x20require\x20100%→Order\x20Allocator','nash_equilibrium':'Merchant\x20configures\x20refund\x20Allocator\x20↔\x20User\x20purchases','fallback':'Arbitration','confidence':a=>{const b=a['workflow_analysis'];if(!b)return 0.5;if(b['has_refund_path']===![])return 0.85;return 0.4;},'rationale':a=>{const b=a['workflow_analysis'];if(!b)return'Workflow\x20structure\x20missing;\x20cannot\x20confirm\x20refund\x20path';if(b['has_refund_path']===![])return'No\x20refund\x20path\x20detected\x20in\x20the\x20workflow';return'Refund\x20path\x20exists';}},'arbitration_fairness':{'scenario':'arbitration_fairness','merchant_tactic':'Self-built\x20arbitration\x20(owner=service\x20owner)','user_strategy':'Require\x20third-party\x20arbitration;\x20verify\x20arb\x20owner\x20via\x20query_toolkit','nash_equilibrium':'Third-party\x20arbitration\x20↔\x20User\x20purchases','fallback':'Do\x20not\x20purchase','confidence':a=>{const b=a['trust_signals'];if(!b)return 0.6;if(b['arbitration_independent']===![])return 0.9;return 0.3;},'rationale':a=>{const b=a['trust_signals'];if(!b)return'Trust\x20signals\x20missing;\x20cannot\x20judge\x20arbitration\x20independence';if(b['arbitration_independent']===![])return'Arbitrator\x20and\x20merchant\x20are\x20the\x20same\x20address;\x20fairness\x20is\x20questionable';return'Arbitration\x20is\x20independent;\x20fairness\x20is\x20assured';}},'pricing':{'scenario':'pricing','merchant_tactic':'Price\x20is\x2020%+\x20above\x20market\x20average','user_strategy':'Cite\x20puzzle.market_context.avg_price\x20in\x20negotiation;\x20request\x20discount\x20or\x20Reward','nash_equilibrium':'Merchant\x20lowers\x20price\x20or\x20provides\x20Reward\x20↔\x20User\x20purchases','fallback':'Accept\x20current\x20price\x20but\x20request\x20additional\x20benefits','confidence':a=>{const b=a['market_context'];if(!b)return 0.4;if(b['price_percentile']>0.8)return 0.7;return 0.3;},'rationale':a=>{const b=a['market_context'];if(!b)return'Market\x20context\x20data\x20missing';return'Price\x20is\x20at\x20the\x20'+Math['round'](b['price_percentile']*0x64)+'th\x20market\x20percentile';}},'delivery_sla':{'scenario':'delivery_sla','merchant_tactic':'No\x20milestone\x20nodes\x20/\x20no\x20delivery\x20time\x20commitment','user_strategy':'Require\x20milestone\x20nodes\x20+\x20write\x20time\x20commitment\x20into\x20WTS','nash_equilibrium':'Merchant\x20configures\x20SLA\x20↔\x20User\x20purchases','fallback':'Accept\x20but\x20agree\x20on\x20timeline\x20in\x20writing\x20via\x20Messenger','confidence':a=>{const b=a['workflow_analysis'];if(!b)return 0.5;if(b['has_milestone_nodes']===![])return 0.8;return 0.3;},'rationale':a=>{const b=a['workflow_analysis'];if(!b)return'Workflow\x20structure\x20missing;\x20cannot\x20assess\x20milestones';if(b['has_milestone_nodes']===![])return'No\x20milestone\x20nodes\x20detected';return'Milestone\x20nodes\x20are\x20configured';}},'quality_verification':{'scenario':'quality_verification','merchant_tactic':'WIP\x20hash\x20not\x20verified','user_strategy':'Require\x20WIP\x20hash\x20verification;\x20request\x20samples\x20or\x20phased\x20delivery\x20evidence','nash_equilibrium':'Merchant\x20provides\x20WIP\x20verification\x20↔\x20User\x20purchases','fallback':'Request\x20samples\x20via\x20Messenger','confidence':a=>{const b=a['service_basics'];if(b['wip_verified']===![])return 0.85;return 0.3;},'rationale':a=>{const b=a['service_basics'];if(b['wip_verified']===![])return'WIP\x20hash\x20is\x20unverified;\x20deliverables\x20may\x20have\x20been\x20tampered\x20with';return'WIP\x20hash\x20is\x20verified';}},'after_sales':{'scenario':'after_sales','merchant_tactic':'No\x20Messenger\x20or\x20post-sale\x20support','user_strategy':'Require\x20Messenger\x20to\x20be\x20configured;\x20require\x20post-sale\x20terms\x20to\x20be\x20written\x20down','nash_equilibrium':'Merchant\x20provides\x20post-sale\x20channel\x20↔\x20User\x20purchases','fallback':'Use\x20Contact\x20channel\x20as\x20a\x20substitute','confidence':a=>{const b=a['trust_signals'];if(!b)return 0.5;if(b['has_messenger']===![])return 0.75;return 0.3;},'rationale':a=>{const b=a['trust_signals'];if(!b)return'Trust\x20signals\x20missing;\x20cannot\x20confirm\x20Messenger';if(b['has_messenger']===![])return'Messenger\x20is\x20not\x20configured;\x20no\x20post-sale\x20channel';return'Messenger\x20is\x20configured';}}};export function recommendStrategy(a,b){const c=SCENARIO_SPECS[a],{puzzle:d,prefs:e}=b,f={'scenario':c['scenario'],'merchant_tactic':c['merchant_tactic'],'user_strategy':c['user_strategy'],'nash_equilibrium':c['nash_equilibrium']},g=clampConfidence(c['confidence'](d)),h=applyPrefsToFallback(a,c['fallback'],e),i=c['rationale'](d);return{'scenario':c['scenario'],'strategy':f,'confidence':g,'fallback':h,'rationale':i};}export function detectScenarios(a){const b=[];return(a['workflow_analysis']===undefined||a['completeness']<0.5)&&b['push']('info_asymmetry'),a['fund_safety']?.['compensation_covers_order']===![]&&b['push']('fund_safety'),a['workflow_analysis']?.['has_refund_path']===![]&&b['push']('refund_dispute'),a['trust_signals']?.['arbitration_independent']===![]&&b['push']('arbitration_fairness'),a['market_context']&&a['market_context']['price_percentile']>0.8&&b['push']('pricing'),a['workflow_analysis']?.['has_milestone_nodes']===![]&&b['push']('delivery_sla'),a['service_basics']['wip_verified']===![]&&b['push']('quality_verification'),a['trust_signals']?.['has_messenger']===![]&&b['push']('after_sales'),b['slice'](0x0,0x3);}function clampConfidence(a){if(a<0x0)return 0x0;if(a>0x1)return 0x1;return a;}function applyPrefsToFallback(a,b,c){if(!c)return b;if(c['risk_appetite']==='conservative'){if(a==='arbitration_fairness'||a==='fund_safety')return'Abandon\x20purchase\x20(conservative\x20user)';}if(c['risk_appetite']==='aggressive'){if(a==='pricing')return'Accept\x20current\x20price\x20but\x20request\x20additional\x20Reward\x20or\x20discount';}return b;}export{CUSTOMER_INTELLIGENCE_VERSION};
@@ -1,24 +0,0 @@
1
- export interface PreorderCompareRow {
2
- service_id: string;
3
- service_name: string;
4
- error?: string;
5
- industry?: string;
6
- confidence?: number;
7
- risk_total?: number;
8
- risk_level?: string;
9
- trust_score?: number;
10
- trust_level?: string;
11
- preference_match?: number;
12
- reputation_like_ratio?: number;
13
- reputation_votes?: number;
14
- red_flags_count?: number;
15
- blocking_reminders_count?: number;
16
- info_gaps_count?: number;
17
- }
18
- export interface PreorderComparison {
19
- rows: PreorderCompareRow[];
20
- best_per_metric: Record<string, string[]>;
21
- evaluated_metrics: string[];
22
- note: string;
23
- }
24
- export declare function buildPreorderComparison(rows: PreorderCompareRow[]): PreorderComparison;
@@ -1 +0,0 @@
1
- const METRICS=[{'key':'confidence','name':'confidence','direction':'high'},{'key':'risk_total','name':'risk_total','direction':'low'},{'key':'trust_score','name':'trust_score','direction':'high'},{'key':'preference_match','name':'preference_match','direction':'high'},{'key':'reputation_like_ratio','name':'reputation_like_ratio','direction':'high'},{'key':'red_flags_count','name':'red_flags_count','direction':'low'},{'key':'blocking_reminders_count','name':'blocking_reminders_count','direction':'low'},{'key':'info_gaps_count','name':'info_gaps_count','direction':'low'}],NEUTRALITY_NOTE='Per-metric\x20bests\x20only\x20—\x20NO\x20overall\x20ranking\x20is\x20computed.\x20'+'Metric\x20weights\x20are\x20the\x20buyer\x27s\x20own:\x20re-run\x20with\x20user_metrics\x20to\x20change\x20what\x20matters.\x20'+'A\x20service\x20\x27best\x27\x20on\x20one\x20metric\x20may\x20be\x20worst\x20on\x20another;\x20the\x20decision\x20is\x20yours.';export function buildPreorderComparison(a){const b={},c=[];for(const d of METRICS){const e=a['filter'](h=>!h['error']&&typeof h[d['key']]==='number');if(e['length']<0x2)continue;const f=e['map'](h=>h[d['key']]),g=d['direction']==='high'?Math['max'](...f):Math['min'](...f);b[d['name']]=e['filter'](h=>h[d['key']]===g)['map'](h=>h['service_id']),c['push'](d['name']);}return{'rows':a,'best_per_metric':b,'evaluated_metrics':c,'note':NEUTRALITY_NOTE};}
@@ -1,42 +0,0 @@
1
- import type { Reminder, RiskLevel } from "./types.js";
2
- import { CUSTOMER_INTELLIGENCE_VERSION } from "./types.js";
3
- import { type TokenDisplayHint } from "../knowledge/fund-layer.js";
4
- export type ReminderStage = "browse" | "evaluate" | "preorder" | "in_progress" | "complete" | "after_sale";
5
- export interface ReminderContext {
6
- stage: ReminderStage;
7
- service_id?: string;
8
- order_id?: string;
9
- review_count?: number;
10
- like_rate?: number;
11
- avg_market_price?: bigint;
12
- service_price?: bigint;
13
- has_arbitration?: boolean;
14
- has_compensation?: boolean;
15
- compensation_balance?: bigint;
16
- compensation_ratio?: number;
17
- token?: TokenDisplayHint;
18
- risk_score?: number;
19
- risk_level?: RiskLevel;
20
- has_refund_path?: boolean;
21
- has_arb_refund_path?: boolean;
22
- has_refund_allocator?: boolean;
23
- has_user_operable?: boolean;
24
- has_messenger?: boolean;
25
- customer_required?: string[];
26
- ambiguous_guards?: string[];
27
- current_node?: string;
28
- expected_progress_hours?: number;
29
- hours_since_last_progress?: number;
30
- hours_since_messenger_reply?: number;
31
- completed_at?: number;
32
- review_window_days?: number;
33
- arb_window_days?: number;
34
- user_min_trust_score?: number;
35
- user_require_arbitration?: boolean;
36
- user_require_compensation?: boolean;
37
- }
38
- export declare function generateReminders(ctx: ReminderContext): Reminder[];
39
- export declare function sortAndCapReminders(reminders: Reminder[]): Reminder[];
40
- export declare function isBlocking(reminder: Reminder): boolean;
41
- export declare function getBlockingReminders(reminders: Reminder[]): Reminder[];
42
- export { CUSTOMER_INTELLIGENCE_VERSION };
@@ -1 +0,0 @@
1
- import{CUSTOMER_INTELLIGENCE_VERSION}from'./types.js';import{formatAmountText}from'../knowledge/fund-layer.js';const REMINDER_RULES=[{'id':'browse_reviews_summary','stage':'browse','priority':'info','message':a=>'This\x20Service\x20has\x20'+a['review_count']+'\x20reviews,\x20like\x20rate\x20'+Math['round']((a['like_rate']??0x0)*0x64)+'%','applies':a=>(a['review_count']??0x0)>0x0,'dedup_key':'reviews_summary'},{'id':'browse_price_anomaly_low','stage':'browse','priority':'recommended','message':a=>{if(!a['avg_market_price']||!a['service_price']||a['avg_market_price']===0x0n)return'⚠️\x20Price\x20is\x20abnormally\x20low,\x20beware\x20of\x20quality\x20risk';const b=Number(a['service_price']*0x64n/a['avg_market_price'])/0x64,c=Math['round']((0x1-b)*0x64);return'⚠️\x20Price\x20is\x20'+c+'%\x20below\x20the\x20average\x20for\x20similar\x20services,\x20beware\x20of\x20quality\x20risk';},'applies':a=>{if(!a['avg_market_price']||!a['service_price'])return![];if(a['avg_market_price']===0x0n)return![];const b=Number(a['service_price']*0x64n/a['avg_market_price'])/0x64;return b<0.6;},'dedup_key':'price_anomaly'},{'id':'browse_no_arbitration','stage':'browse','priority':'recommended','message':'⚠️\x20This\x20Service\x20has\x20no\x20arbitration\x20configured;\x20disputes\x20have\x20no\x20resolution\x20channel','applies':a=>a['has_arbitration']===![],'dedup_key':'no_arbitration'},{'id':'browse_no_compensation','stage':'browse','priority':'recommended','message':'⚠️\x20This\x20Service\x20has\x20no\x20compensation\x20fund;\x20no\x20automatic\x20payout\x20source\x20if\x20the\x20order\x20fails','applies':a=>a['has_compensation']===![],'dedup_key':'no_compensation'},{'id':'evaluate_checklist','stage':'evaluate','priority':'info','message':'📋\x20Running\x204-dimension\x20risk\x20check\x20(workflow/fund/trust/behavior)...','applies':()=>!![],'dedup_key':'checklist_start'},{'id':'evaluate_high_risk','stage':'evaluate','priority':'required','message':a=>'🔴\x20Composite\x20risk\x20score\x20'+a['risk_score']+'/100,\x20strongly\x20recommend\x20not\x20purchasing','applies':a=>(a['risk_level']??'low')==='high','dedup_key':'high_risk_score'},{'id':'evaluate_medium_high_risk','stage':'evaluate','priority':'recommended','message':a=>'🟠\x20Composite\x20risk\x20score\x20'+a['risk_score']+'/100,\x20purchase\x20with\x20caution\x20and\x20focus\x20on\x202-3\x20key\x20risks','applies':a=>(a['risk_level']??'low')==='medium_high','dedup_key':'medium_high_risk'},{'id':'evaluate_ambiguous_guard','stage':'evaluate','priority':'required','message':a=>'🔴\x20Detected\x20'+(a['ambiguous_guards']?.['length']??0x0)+'\x20ambiguous\x20Guard(s);\x20manual\x20review\x20is\x20required\x20before\x20proceeding:\x20'+(a['ambiguous_guards']?.['join'](',\x20')??''),'applies':a=>(a['ambiguous_guards']?.['length']??0x0)>0x0,'dedup_key':'ambiguous_guard'},{'id':'evaluate_no_refund_path','stage':'evaluate','priority':'recommended','message':'⚠️\x20No\x20refund\x20path:\x20if\x20delivery\x20fails,\x20funds\x20may\x20be\x20unrecoverable.\x20Recommend\x20negotiating\x20refund\x20terms\x20via\x20Messenger','applies':a=>a['has_refund_path']===![],'dedup_key':'no_refund_path'},{'id':'evaluate_refund_conditions','stage':'evaluate','priority':'info','message':a=>{const b=[];a['has_arb_refund_path']&&b['push']('Arbitration-backed\x20(dispute\x20→\x20ruling\x20→\x20compensation\x20payout)');a['has_refund_allocator']&&b['push']('refund-to-order\x20Allocator\x20(cancel/refund\x20returns\x20funds)');if(b['length']===0x0)return'';return'Refund\x20conditions:\x20'+b['join'](';\x20')+'.';},'applies':a=>a['has_refund_path']===!![]&&(a['has_arb_refund_path']===!![]||a['has_refund_allocator']===!![]),'dedup_key':'refund_conditions'},{'id':'evaluate_no_user_operable','stage':'evaluate','priority':'required','message':'🔴\x20No\x20user-operable\x20steps\x20in\x20the\x20workflow:\x20order\x20progress\x20depends\x20entirely\x20on\x20the\x20merchant','applies':a=>a['has_user_operable']===![],'dedup_key':'no_user_operable'},{'id':'evaluate_below_min_trust','stage':'evaluate','priority':'required','message':a=>'🔴\x20Risk\x20score\x20'+a['risk_score']+'\x20is\x20below\x20your\x20minimum\x20requirement\x20of\x20'+a['user_min_trust_score'],'applies':a=>a['user_min_trust_score']!==undefined&&a['risk_score']!==undefined&&a['risk_score']<a['user_min_trust_score'],'dedup_key':'below_min_trust'},{'id':'preorder_payment_confirm','stage':'preorder','priority':'required','message':a=>'🔔\x20About\x20to\x20pay\x20'+formatAmountText(a['service_price']??0x0n,a['token']?.['decimals'],a['token']?.['symbol'])+'\x20to\x20the\x20escrow\x20account,\x20please\x20confirm','applies':a=>a['service_price']!==undefined,'dedup_key':'payment_confirm'},{'id':'preorder_compensation_insufficient','stage':'preorder','priority':'recommended','message':a=>'⚠️\x20Compensation\x20balance\x20only\x20covers\x20'+Math['round']((a['compensation_ratio']??0x0)*0x64)+'%\x20of\x20the\x20order\x20amount','applies':a=>(a['compensation_ratio']??0x1)<0x1,'dedup_key':'compensation_insufficient'},{'id':'preorder_user_require_arb_missing','stage':'preorder','priority':'required','message':'🔴\x20Your\x20preferences\x20require\x20arbitration,\x20but\x20this\x20Service\x20does\x20not\x20have\x20it\x20configured','applies':a=>a['user_require_arbitration']===!![]&&a['has_arbitration']===![],'dedup_key':'user_require_arb_missing'},{'id':'preorder_user_require_comp_missing','stage':'preorder','priority':'required','message':'🔴\x20Your\x20preferences\x20require\x20a\x20compensation\x20fund,\x20but\x20this\x20Service\x20has\x20none','applies':a=>a['user_require_compensation']===!![]&&a['has_compensation']===![],'dedup_key':'user_require_comp_missing'},{'id':'preorder_no_messenger','stage':'preorder','priority':'recommended','message':'⚠️\x20Merchant\x20has\x20no\x20Messenger\x20channel;\x20no\x20way\x20to\x20negotiate\x20or\x20get\x20post-sale\x20support\x20after\x20ordering','applies':a=>a['has_messenger']===![],'dedup_key':'no_messenger'},{'id':'preorder_customer_required_no_contact','stage':'preorder','priority':'required','message':a=>'🔴\x20This\x20Service\x20requires\x20private\x20information\x20('+(a['customer_required']??[])['join'](',\x20')+'),\x20'+'but\x20it\x20has\x20NO\x20Contact/Messenger\x20channel\x20configured.\x20Your\x20private\x20information\x20cannot\x20be\x20delivered\x20securely\x20'+'—\x20do\x20NOT\x20order\x20until\x20the\x20merchant\x20binds\x20a\x20Contact\x20(um)\x20so\x20the\x20info\x20can\x20be\x20sent\x20end-to-end\x20encrypted.','action':'BLOCK\x20ordering\x20until\x20the\x20merchant\x20binds\x20a\x20Contact\x20(Service.um)\x20and\x20adds\x20a\x20customer-service\x20IM\x20(Contact.ims).\x20'+'Then\x20use\x20assembleRequiredInfoDeliveryPlan\x20to\x20deliver\x20the\x20info.','applies':a=>(a['customer_required']?.['length']??0x0)>0x0&&a['has_messenger']===![],'dedup_key':'customer_required_no_contact'},{'id':'preorder_customer_required_send_info','stage':'preorder','priority':'recommended','message':a=>'🔐\x20After\x20ordering\x20you\x20MUST\x20send\x20your\x20private\x20information\x20('+(a['customer_required']??[])['join'](',\x20')+')\x20'+'to\x20the\x20merchant\x27s\x20Contact\x20via\x20end-to-end\x20encrypted\x20Messenger,\x20and\x20obtain\x20a\x20confirmation\x20reply.\x20'+'Your\x20private\x20information\x20is\x20encrypted\x20end-to-end\x20and\x20never\x20stored\x20in\x20plaintext\x20by\x20the\x20service.','action':'assembleRequiredInfoDeliveryPlan:\x20(1)\x20query\x20Contact.ims;\x20(2)\x20collect\x20fields\x20via\x20local_info_operation;\x20'+'(3)\x20messenger_operation\x20send_message\x20to\x20the\x20Contact\x20IM;\x20(4)\x20wait\x20for\x20ARK/reply;\x20'+'(5)\x20write\x20Order.required_info\x20back\x20via\x20onchain_operations.','applies':a=>(a['customer_required']?.['length']??0x0)>0x0&&a['has_messenger']===!![],'dedup_key':'customer_required_send_info'},{'id':'in_progress_progress_stalled','stage':'in_progress','priority':'recommended','message':a=>'⚠️\x20Order\x20has\x20been\x20stuck\x20at\x20node\x20'+a['current_node']+'\x20for\x20over\x20'+a['hours_since_last_progress']+'\x20hours,\x20suggest\x20contacting\x20the\x20merchant','applies':a=>{const b=a['hours_since_last_progress']??0x0,c=a['expected_progress_hours']??0x18;return b>c*0x2;},'dedup_key':'progress_stalled'},{'id':'in_progress_compensation_drop','stage':'in_progress','priority':'recommended','message':'⚠️\x20Merchant\x20compensation\x20fund\x20balance\x20dropped\x2030%,\x20please\x20note','applies':()=>![],'dedup_key':'compensation_drop'},{'id':'in_progress_user_action_required','stage':'in_progress','priority':'reminder','message':a=>'🔔\x20Order\x20advanced\x20to\x20node\x20'+a['current_node']+',\x20your\x20action\x20is\x20required','applies':a=>a['current_node']!==undefined&&a['current_node']!=='','dedup_key':'user_action_required'},{'id':'in_progress_messenger_unanswered','stage':'in_progress','priority':'recommended','message':a=>'⚠️\x20Merchant\x20has\x20not\x20replied\x20on\x20Messenger\x20for\x20'+a['hours_since_messenger_reply']+'\x20hours;\x20consider\x20initiating\x20arbitration','applies':a=>(a['hours_since_messenger_reply']??0x0)>0x18,'dedup_key':'messenger_unanswered'},{'id':'complete_review_reminder','stage':'complete','priority':'info','message':'💡\x20Order\x20completed,\x20would\x20you\x20like\x20to\x20submit\x20a\x20review?','applies':()=>!![],'dedup_key':'review_reminder'},{'id':'complete_review_window','stage':'complete','priority':'reminder','message':a=>'⏰\x20The\x20review\x20window\x20will\x20close\x20in\x20'+a['review_window_days']+'\x20days','applies':a=>(a['review_window_days']??0x0)>0x0,'dedup_key':'review_window'},{'id':'after_sale_arb_window','stage':'after_sale','priority':'reminder','message':a=>'⏰\x20The\x20arbitration\x20application\x20window\x20will\x20close\x20in\x20'+a['arb_window_days']+'\x20day(s)','applies':a=>(a['arb_window_days']??0x0)>0x0,'dedup_key':'arb_window'},{'id':'after_sale_refund_received','stage':'after_sale','priority':'info','message':'✅\x20Refund\x20received','applies':()=>![],'dedup_key':'refund_received'}];export function generateReminders(a){const b=REMINDER_RULES['filter'](e=>e['stage']===a['stage']),c=new Map();for(const e of b){if(!e['applies'](a))continue;const f=c['get'](e['dedup_key']);(!f||priorityRank(e['priority'])>priorityRank(f['priority']))&&c['set'](e['dedup_key'],e);}const d=Array['from'](c['values']())['map'](g=>({'id':g['id'],'stage':g['stage'],'priority':g['priority'],'message':typeof g['message']==='function'?g['message'](a):g['message'],'action':g['action']}));return sortAndCapReminders(d);}export function sortAndCapReminders(a){const b=[...a]['sort']((f,g)=>priorityRank(g['priority'])-priorityRank(f['priority'])),c=b['filter'](f=>f['priority']==='required'||f['priority']==='recommended'),d=b['filter'](f=>f['priority']==='info'||f['priority']==='reminder'),e=c['slice'](0x0,0x3);return[...e,...d];}function priorityRank(a){switch(a){case'required':return 0x4;case'recommended':return 0x3;case'info':return 0x2;case'reminder':return 0x1;}}export function isBlocking(a){return a['priority']==='required';}export function getBlockingReminders(a){return a['filter'](isBlocking);}export{CUSTOMER_INTELLIGENCE_VERSION};
@@ -1,13 +0,0 @@
1
- import type { InfoPuzzle, RiskScore, RiskLevel, RiskDimensionScore } from "./types.js";
2
- import { CUSTOMER_INTELLIGENCE_VERSION } from "./types.js";
3
- export declare function riskLevelFromScore(score: number): RiskLevel;
4
- export declare function riskLevelLabel(level: RiskLevel): string;
5
- export declare function riskLevelEmoji(level: RiskLevel): string;
6
- export declare function assessWorkflowRisk(puzzle: InfoPuzzle): RiskDimensionScore;
7
- export declare function assessFundRisk(puzzle: InfoPuzzle): RiskDimensionScore;
8
- export declare function assessTrustRisk(puzzle: InfoPuzzle): RiskDimensionScore;
9
- export declare function assessBehaviorRisk(puzzle: InfoPuzzle): RiskDimensionScore;
10
- export declare function knowledgeServiceRisks(puzzle: InfoPuzzle): import("../knowledge/service-risk.js").ServiceRisk[];
11
- export declare function assessRisk(puzzle: InfoPuzzle): RiskScore;
12
- export declare function passesRiskThreshold(score: RiskScore, minLevel?: RiskLevel): boolean;
13
- export { CUSTOMER_INTELLIGENCE_VERSION };
@@ -1 +0,0 @@
1
- import{RISK_LEVELS,RISK_DIMENSION_MAX,CUSTOMER_INTELLIGENCE_VERSION}from'./types.js';import{assessServiceRisks}from'../knowledge/service-risk.js';export function riskLevelFromScore(a){const b=RISK_LEVELS['find'](c=>a>=c['min']);return b?.['level']??'high';}export function riskLevelLabel(a){const b=RISK_LEVELS['find'](c=>c['level']===a);return b?b['color']+'\x20'+b['label']:'🔴\x20High\x20risk';}export function riskLevelEmoji(a){const b=RISK_LEVELS['find'](c=>c['level']===a);return b?.['color']??'🔴';}export function assessWorkflowRisk(a){const b=a['workflow_analysis'],c=[],d=b?.['has_arbitration_binding']??b?.['has_arbitration_path']??![];c['push']({'id':'wf_arbitration_binding','dimension':'workflow','description':'Service\x20has\x20Arbitration\x20object\x20bound\x20(dispute\x20independence)','weight':0xa,'passed':d,'advice':d?undefined:'⚠️\x20No\x20Arbitration\x20binding:\x20disputes\x20cannot\x20be\x20escalated\x20to\x20third-party\x20arbitration.\x20Recommend\x20requiring\x20the\x20merchant\x20to\x20bind\x20an\x20Arbitration\x20service\x20(with\x20voting_guard\x20config)\x20before\x20ordering.\x20Dispute\x20is\x20filed\x20via\x20arbitration::dispute(order,\x20arbitration),\x20independent\x20of\x20the\x20machine\x20workflow.'});const e=b?.['has_refund_path']??![];c['push']({'id':'wf_refund_path','dimension':'workflow','description':'Refund\x20path\x20exists\x20(Arbitration+compensation_fund\x20OR\x20refund\x20Allocator)','weight':0xa,'passed':e,'advice':e?undefined:'⚠️\x20No\x20refund\x20path:\x20if\x20delivery\x20fails,\x20funds\x20may\x20not\x20be\x20recoverable.\x20Either\x20(a)\x20bind\x20Arbitration\x20AND\x20deposit\x20compensation_fund,\x20or\x20(b)\x20configure\x20a\x20refund-to-order\x20Allocator.\x20Refund\x20via\x20arbitration\x20flows:\x20dispute\x20→\x20arbitration()\x20ruling\x20with\x20indemnity\x20→\x20arb_withdraw\x20by\x20order\x20holder.'});const f=b?.['user_operable_forwards']??0x0;c['push']({'id':'wf_user_operable','dimension':'workflow','description':'At\x20least\x201\x20user-operable\x20Forward','weight':0x8,'passed':f>0x0,'advice':f>0x0?undefined:'🔴\x20No\x20user-operable\x20steps\x20in\x20the\x20workflow:\x20order\x20progress\x20depends\x20entirely\x20on\x20the\x20merchant,\x20leaving\x20you\x20in\x20a\x20passive\x20position.'});const g=b?.['dead_end_nodes']??[],h=g['length']===0x0;c['push']({'id':'wf_no_dead_ends','dimension':'workflow','description':'No\x20potential\x20dead-end\x20nodes','weight':0x4,'passed':h,'advice':h?undefined:'⚠️\x20Detected\x20'+g['length']+'\x20potential\x20dead-end\x20node(s):\x20'+g['join'](',\x20')+'.\x20All\x20exits\x20of\x20these\x20nodes\x20depend\x20on\x20merchant\x20action.'});const i=b?b['machine_published']&&!b['machine_paused']&&!b['has_dispute_anti_pattern']:![];c['push']({'id':'wf_machine_usable','dimension':'workflow','description':'Machine\x20published,\x20not\x20paused,\x20no\x20dispute\x20anti-pattern','weight':0x3,'passed':i,'advice':i?undefined:b?.['has_dispute_anti_pattern']?'🔴\x20Machine\x20contains\x20dispute\x20anti-pattern\x20nodes\x20(disputed/refunded/arb/arbitration).\x20Dispute\x20is\x20INDEPENDENT\x20of\x20machine\x20—\x20these\x20nodes\x20create\x20dead-end\x20paths\x20because\x20arbitrators\x20are\x20in\x20Arbitration.voting_guard,\x20not\x20Permission.\x20Recommend\x20removing\x20these\x20nodes\x20and\x20binding\x20an\x20Arbitration\x20object\x20to\x20the\x20Service\x20instead.':'⚠️\x20Machine\x20is\x20not\x20published\x20or\x20is\x20paused:\x20the\x20workflow\x20may\x20not\x20be\x20in\x20effect\x20or\x20has\x20been\x20actively\x20paused\x20by\x20the\x20merchant.'});const j=c['reduce']((k,l)=>k+(l['passed']?l['weight']:0x0),0x0);return{'name':'workflow','score':j,'max_score':RISK_DIMENSION_MAX['workflow'],'checks':c};}export function assessFundRisk(a){const b=a['fund_safety'],c=[];let d=0x0,e;if(b){if(b['compensation_covers_order'])d=0xa;else b['compensation_ratio']>0x0?(d=Math['round'](b['compensation_ratio']*0xa),e='⚠️\x20Compensation\x20fund\x20covers\x20only\x20'+Math['round'](b['compensation_ratio']*0x64)+'%\x20of\x20the\x20order\x20amount;\x20insufficient\x20for\x20a\x20full\x20payout.'):(d=0x0,e='🔴\x20No\x20compensation\x20fund:\x20the\x20merchant\x20has\x20not\x20set\x20up\x20a\x20compensation_fund;\x20no\x20automatic\x20payout\x20source\x20if\x20the\x20order\x20fails.');}else d=0x5;c['push']({'id':'fund_compensation','dimension':'fund','description':'Compensation\x20fund\x20adequacy\x20(covers\x20the\x20order\x20amount)','weight':0xa,'passed':d>=0x7,'advice':e});const f=b?.['refund_allocator_exists']??![];c['push']({'id':'fund_refund_allocator','dimension':'fund','description':'100%→Order\x20refund\x20Allocator\x20exists','weight':0x8,'passed':f,'advice':f?undefined:'⚠️\x20No\x20100%→Order\x20Allocator\x20detected:\x20refunds\x20require\x20manual\x20merchant\x20action\x20or\x20arbitration\x20ruling.'});const g=b?b['price_anomaly']==='none':!![];c['push']({'id':'fund_price_normal','dimension':'fund','description':'No\x20price\x20anomaly\x20(compared\x20with\x20compensation\x20fund\x20and\x20market\x20price)','weight':0x4,'passed':g,'advice':g?undefined:'⚠️\x20Price\x20anomaly\x20('+b?.['price_anomaly']+'):\x20possible\x20fraudulent\x20pricing\x20or\x20abnormally-low-price\x20lure.'});const h=b?.['lock_duration_safe']??!![];c['push']({'id':'fund_lock_safe','dimension':'fund','description':'Compensation\x20fund\x20lock\x20period\x20is\x20reasonable\x20(≥7\x20days\x20or\x20no\x20lock)','weight':0x3,'passed':h,'advice':h?undefined:'⚠️\x20Compensation\x20fund\x20lock\x20period\x20is\x20too\x20short:\x20the\x20merchant\x20may\x20withdraw\x20funds\x20at\x20any\x20time.'});const i=c['reduce']((k,l)=>k+(l['passed']?l['weight']:0x0),0x0),j=b&&!b['compensation_covers_order']&&b['compensation_ratio']>0x0?Math['min'](RISK_DIMENSION_MAX['fund'],i+d-(d>=0x7?0xa:0x0)):i;return{'name':'fund','score':j,'max_score':RISK_DIMENSION_MAX['fund'],'checks':c};}export function assessTrustRisk(a){const b=a['trust_signals'],c=[],d=b?.['arbitration_independent']??!![],e=b?.['arbitration_permission_shared']===!![],f=b?.['arbitration_permission_overlap']===!![];let g=d,h,i=0x6;if(e)g=![],h='🔴\x20CRITICAL:\x20Arbitration\x20and\x20Service\x20share\x20the\x20SAME\x20Permission\x20object.\x20'+'The\x20merchant\x20fully\x20controls\x20arbitration\x20operations\x20(vote,\x20confirm,\x20execute\x20rulings).\x20'+'Dispute\x20fairness\x20cannot\x20be\x20guaranteed.\x20Require\x20the\x20merchant\x20to\x20use\x20a\x20separate,\x20'+'independent\x20Permission\x20object\x20for\x20Arbitration\x20before\x20ordering.';else{if(f)g=![],h='🔴\x20WARNING:\x20Arbitration\x20and\x20Service\x20have\x20overlapping\x20Permission\x20control\x20'+'(shared\x20owner\x20or\x20admin).\x20Even\x20with\x20separate\x20Permission\x20objects,\x20the\x20merchant\x20can\x20'+'influence\x20dispute\x20outcomes.\x20The\x20contract\x20only\x20checks\x20Permission\x20object\x20addresses,\x20'+'not\x20control\x20overlap\x20—\x20this\x20risk\x20exists\x20on\x20ANY\x20network.\x20Require\x20completely\x20'+'independent\x20third-party\x20Permission\x20(different\x20owner\x20and\x20admin\x20list)\x20for\x20Arbitration.';else!d&&(h='🔴\x20Arbitrator\x20and\x20merchant\x20are\x20the\x20same\x20address:\x20arbitration\x20fairness\x20cannot\x20be\x20guaranteed.');}c['push']({'id':'trust_arb_independent','dimension':'trust','description':'Arbitrator\x20has\x20no\x20conflict\x20of\x20interest\x20with\x20the\x20merchant\x20(Permission\x20isolation)','weight':i,'passed':g,'advice':h});let j=![],k;if(b&&b['review_total']>0x0){const q=b['like_rate'];if(q>=0.85)j=!![];else q>=0.6?(j=!![],k='⚠️\x20Like\x20rate\x20is\x20'+Math['round'](q*0x64)+'%;\x20there\x20is\x20some\x20controversy.'):(j=![],k='🔴\x20Like\x20rate\x20is\x20only\x20'+Math['round'](q*0x64)+'%\x20('+b['review_likes']+'/'+b['review_total']+');\x20many\x20negative\x20reviews.');}else b?j=!![]:j=!![];c['push']({'id':'trust_review_reputation','dimension':'trust','description':'Good\x20review\x20reputation\x20(like\x20rate\x20≥60%)','weight':0x5,'passed':j,'advice':k});const l=b?.['trust_score']??0x32,m=l>=0x32;c['push']({'id':'trust_score','dimension':'trust','description':'Composite\x20trust\x20score\x20≥50\x20(current\x20'+l+')','weight':0x4,'passed':m,'advice':m?undefined:'🔴\x20Composite\x20trust\x20score\x20is\x20only\x20'+l+'/100;\x20recommend\x20finding\x20a\x20more\x20trustworthy\x20merchant.'});const n=b?.['has_contact']??![],o=b?.['has_messenger']??![];c['push']({'id':'trust_contact','dimension':'trust','description':'Merchant\x20has\x20a\x20contactable\x20Messenger\x20channel','weight':0x5,'passed':n&&o,'advice':n&&o?undefined:'🔴\x20Merchant\x20has\x20no\x20contactable\x20channel\x20(um\x20is\x20empty):\x20no\x20way\x20to\x20conduct\x20pre-order\x20negotiation\x20or\x20post-sale\x20communication.'});const p=c['reduce']((r,s)=>r+(s['passed']?s['weight']:0x0),0x0);return{'name':'trust','score':p,'max_score':RISK_DIMENSION_MAX['trust'],'checks':c};}export function assessBehaviorRisk(a){const b=a['merchant_behavior'],c=[];let d=![],e;if(b){if(b['recent_trend']==='improving')d=!![];else b['recent_trend']==='stable'?d=!![]:(d=![],e='🔴\x20Merchant\x27s\x20recent\x20dispute\x20rate\x20is\x20rising:\x20fulfillment\x20quality\x20may\x20be\x20deteriorating.');}else d=!![];c['push']({'id':'behavior_trend','dimension':'behavior','description':'Recent\x20fulfillment\x20trend\x20is\x20stable\x20or\x20improving','weight':0x6,'passed':d,'advice':e});const f=b!=null&&b['total_orders']>0x0,g=f?b['completed_rate']>=0.85:!![];c['push']({'id':'behavior_completion_rate','dimension':'behavior','description':'Order\x20completion\x20rate\x20≥85%','weight':0x4,'passed':g,'advice':g?undefined:'🔴\x20Completion\x20rate\x20is\x20only\x20'+Math['round']((b?.['completed_rate']??0x0)*0x64)+'%:\x20a\x20higher-than-average\x20share\x20of\x20orders\x20end\x20in\x20failure.'});const h=f?b['dispute_rate']<=0.1:!![];c['push']({'id':'behavior_low_dispute','dimension':'behavior','description':'Dispute\x20rate\x20≤10%','weight':0x4,'passed':h,'advice':h?undefined:'⚠️\x20Dispute\x20rate\x20is\x20'+Math['round']((b?.['dispute_rate']??0x0)*0x64)+'%:\x20above\x20the\x20industry\x20average.'});const i=f?b['arb_loss_rate']<=0.3:!![];c['push']({'id':'behavior_arb_loss','dimension':'behavior','description':'Arbitration\x20loss\x20rate\x20≤30%','weight':0x3,'passed':i,'advice':i?undefined:'🔴\x20Arbitration\x20loss\x20rate\x20is\x20'+Math['round']((b?.['arb_loss_rate']??0x0)*0x64)+'%:\x20the\x20merchant\x20has\x20lost\x20multiple\x20arbitration\x20cases,\x20indicating\x20a\x20tendency\x20to\x20violate\x20rules.'});const j=b?b['red_flags']['length']===0x0:!![];c['push']({'id':'behavior_no_red_flags','dimension':'behavior','description':'No\x20behavior\x20red_flags','weight':0x3,'passed':j,'advice':j?undefined:'⚠️\x20Detected\x20behavioral\x20warning\x20signals:\x20'+b?.['red_flags']['join'](',\x20')});const k=c['reduce']((l,m)=>l+(m['passed']?m['weight']:0x0),0x0);return{'name':'behavior','score':k,'max_score':RISK_DIMENSION_MAX['behavior'],'checks':c};}export function knowledgeServiceRisks(a){const b=a['service_basics'],c={'object':b['service_id'],'current_bPublished':b['bPublished'],'current_bPaused':b['bPaused'],'current_compensation_fund_balance':b['compensation_fund_balance']['toString'](),'current_arbitrations_count':b['arbitrations_count'],'current_sales_count':b['sales_count'],'current_machine_bound':!!b['machine_id']};return assessServiceRisks(c)['risks']['filter'](d=>(d['level']==='HIGH'||d['level']==='CRITICAL')&&d['affected_stakeholders']['includes']('customer'));}export function assessRisk(a){const b=[assessWorkflowRisk(a),assessFundRisk(a),assessTrustRisk(a),assessBehaviorRisk(a)],c=knowledgeServiceRisks(a),d=b['reduce']((n,o)=>n+o['score'],0x0),e=a['user_metrics']?.['adjustment']??0x0,g=a['service_nesting']?.['overall_risk_score'],h=a['service_nesting']?.['overall_risk_level'],i=a['workflow_analysis']?.['has_wonder_node']?0x2:0x0,j=Math['max'](0x0,Math['min'](0x64,d+e+i)),k=riskLevelFromScore(j),l=[];for(const n of b){for(const o of n['checks']){!o['passed']&&o['advice']&&o['advice']['startsWith']('🔴')&&l['push']('['+n['name']+']\x20'+o['description']+':\x20'+o['advice']);}}if(a['workflow_analysis']?.['risk_signals']['length'])for(const p of a['workflow_analysis']['risk_signals']){l['push']('[workflow_signal]\x20'+p);}if(a['merchant_behavior']?.['red_flags']['length'])for(const q of a['merchant_behavior']['red_flags']){l['push']('[behavior_flag]\x20'+q);}(h==='high'||h==='critical')&&l['push']('[service_nesting]\x20overall\x20nesting\x20risk:\x20'+h+'\x20(score\x20'+g+')');for(const r of c){l['push']('[service_risk]\x20'+r['id']+':\x20'+r['title']+'\x20—\x20'+r['description']);}const m=generateAdvice(a,j,k,b);for(const s of c){m['push']('🔴\x20[service_risk]\x20'+s['title']+':\x20'+s['mitigation']);}return{'total':j,'base_total':d,'level':k,'dimensions':b,'user_metrics_adjustment':e,'service_nesting_risk':g,'service_nesting_level':h,'red_flags':l,'advice':m};}function generateAdvice(a,b,c,d){const e=[],f=riskLevelEmoji(c),g=RISK_LEVELS['find'](i=>i['level']===c);e['push'](f+'\x20Composite\x20risk\x20score:\x20'+b+'/100\x20('+(g?.['label']??'unknown')+')');if(c==='high')e['push']('🚫\x20Recommend\x20abandoning\x20this\x20order:\x20the\x20risk\x20level\x20is\x20too\x20high;\x20fund\x20safety\x20cannot\x20be\x20guaranteed.');else{if(c==='medium_high')e['push']('⚠️\x20Recommend\x20ordering\x20with\x20caution:\x20be\x20sure\x20to\x20negotiate\x20supplementary\x20terms\x20via\x20Messenger\x20and\x20request\x20a\x20WTS\x20evidence\x20file.');else c==='medium_low'?e['push']('✅\x20You\x20may\x20order:\x20recommend\x20continuously\x20monitoring\x20order\x20progress\x20and\x20keeping\x20communication\x20records.'):e['push']('✅\x20Safe\x20order:\x20you\x20can\x20order\x20with\x20confidence;\x20still\x20recommend\x20enabling\x20order\x20monitoring\x20reminders.');}const h=[...d]['sort']((i,j)=>i['score']/ i['max_score']-j['score']/j['max_score']);for(const i of h){const j=i['max_score']>0x0?i['score']/ i['max_score']:0x0;if(j<0.5){const k=i['checks']['filter'](l=>!l['passed']);if(k['length']>0x0){e['push']('📊\x20'+i['name']+'\x20dimension\x20'+i['score']+'/'+i['max_score']+':\x20'+k['length']+'\x20check(s)\x20failed.');const l=k['find'](n=>n['advice']?.['startsWith']('🔴'));if(l?.['advice'])e['push'](l['advice']);}}}a['completeness']<0.8&&e['push']('ℹ️\x20Information\x20completeness\x20is\x20only\x20'+Math['round'](a['completeness']*0x64)+'%;\x20missing:\x20'+(a['gaps']['join'](',\x20')||'none')+'.\x20Recommend\x20supplementing\x20data\x20before\x20making\x20a\x20decision.');a['workflow_analysis']?.['has_wonder_node']&&e['push']('🌟\x20Machine\x20implements\x20wonder/no-wonder\x20praise\x20design:\x20customers\x20can\x20advance\x20Progress\x20to\x20\x27wonder\x27\x20(positive\x20review)\x20or\x20\x27no_wonder\x27\x20(negative\x20review)\x20after\x20completion.\x20Reward\x20objects\x20can\x20claim\x20against\x20Progress.current\x20==\x20\x27wonder\x27\x20to\x20incentivize\x20positive\x20outcomes.');a['workflow_analysis']?.['has_dispute_anti_pattern']&&e['push']('🔴\x20Machine\x20contains\x20dispute\x20anti-pattern\x20nodes\x20(disputed/refunded/arb/arbitration).\x20Dispute\x20is\x20INDEPENDENT\x20of\x20machine\x20—\x20it\x20flows\x20through\x20Order\x20→\x20Arbitration.dispute()\x20→\x20Arb\x20→\x20arbitration()\x20→\x20arb_withdraw.\x20Arbitrators\x20are\x20configured\x20in\x20Arbitration.voting_guard,\x20NOT\x20in\x20Permission.\x20Recommend\x20the\x20merchant\x20remove\x20these\x20nodes\x20and\x20bind\x20an\x20Arbitration\x20object\x20instead.');if(a['user_metrics']){const n=a['user_metrics'],o=n['metrics']['filter'](p=>p['passed'])['length'];e['push']('📊\x20User-customized\x20metrics:\x20'+o+'/'+n['metrics']['length']+'\x20passed\x20(score\x20'+n['score']+'/100,\x20adjustment\x20'+(n['adjustment']>=0x0?'+':'')+n['adjustment']+').'+(n['source_file']?'\x20Source:\x20'+n['source_file']:''));for(const p of n['metrics']){!p['passed']&&p['advice']&&e['push']('\x20\x20\x20•\x20'+p['label']+':\x20'+p['advice']);}}if(a['service_nesting']){const q=a['service_nesting'];e['push']('🔗\x20Service\x20nesting\x20evaluation:\x20'+q['total_bindings_evaluated']+'\x20bound\x20objects,\x20overall\x20risk\x20'+q['overall_risk_level']+'\x20(score\x20'+q['overall_risk_score']+'/100).'+(q['truncated']?'\x20Recursion\x20truncated\x20at\x20depth\x20limit.':''));}return e;}export function passesRiskThreshold(a,b='medium_high'){const c=['high','medium_high','medium_low','low'],d=c['indexOf'](b),e=c['indexOf'](a['level']);return e>=d;}export{CUSTOMER_INTELLIGENCE_VERSION};
@@ -1,7 +0,0 @@
1
- import { type PresenterAcceptanceRecord } from "../acceptance.js";
2
- import { type PuzzleRawData } from "../../customer/info-puzzle.js";
3
- import type { PuzzleDepth } from "../../customer/types.js";
4
- import type { EvaluationResult, UserInjection } from "../types.js";
5
- export declare const SERVICE_RISK_EVALUATION = "service_risk";
6
- export declare function registerServiceRiskEvaluation(engine?: import("../engine.js").EvaluationEngine): void;
7
- export declare function assessServiceRisk(serviceId: string, raw: PuzzleRawData, injection?: UserInjection, depth?: PuzzleDepth, presenterHistory?: PresenterAcceptanceRecord[]): Promise<EvaluationResult>;
@@ -1 +0,0 @@
1
- import{createAcceptanceRule}from'../acceptance.js';import{assembleInfoPuzzle}from'../../customer/info-puzzle.js';import{assessWorkflowRisk,assessFundRisk,assessTrustRisk,assessBehaviorRisk}from'../../customer/risk-assessment.js';import{getEvaluationEngine}from'../engine.js';export const SERVICE_RISK_EVALUATION='service_risk';const dsPuzzle={'id':'ds_puzzle','description':'Assemble\x20the\x20service\x20info\x20puzzle\x20from\x20raw\x20chain\x20data','evaluation_ids':[SERVICE_RISK_EVALUATION],'extract':a=>{const b=a['entities']['service_id'],c=a['entities']['puzzle_raw'],d=a['entities']['depth']??'preorder';return{'puzzle':assembleInfoPuzzle(b,c,d)};}};function dimensionRule(a,b,c,d){return{'id':a,'description':b+'\x20risk\x20dimension','dimension':b,'weight':c,'evaluation_ids':[SERVICE_RISK_EVALUATION],'evaluate':e=>{const f=e['facts']['puzzle'],g=d(f),h=g['max_score']>0x0?Math['round'](g['score']/g['max_score']*0x64):0x0,i=g['checks']['filter'](l=>l['passed']),j=g['checks']['filter'](l=>!l['passed']),k=j['filter'](l=>l['advice']?.['startsWith']('🔴'));return{'score':h,'weight':c,'reason':k['length']>0x0?k['map'](l=>'['+g['name']+']\x20'+l['description']+':\x20'+l['advice'])['join'](';\x20'):g['name']+'\x20'+g['score']+'/'+g['max_score'],'matched':i['map'](l=>l['id']),'mismatched':j['map'](l=>l['id']),'red_flag':k['length']>0x0};}};}const workflowRule=dimensionRule('workflow','workflow',0x23,assessWorkflowRisk),fundRule=dimensionRule('fund','fund',0x19,assessFundRisk),trustRule=dimensionRule('trust','trust',0x14,assessTrustRisk),behaviorRule=dimensionRule('behavior','behavior',0x14,assessBehaviorRisk),acceptanceRule=createAcceptanceRule(SERVICE_RISK_EVALUATION,{'weight':0xa,'dimension':'trust','redFlag':{'below':0x1e,'minRated':0x2}});export function registerServiceRiskEvaluation(a=getEvaluationEngine()){a['registerDataSource'](dsPuzzle);for(const b of[workflowRule,fundRule,trustRule,behaviorRule,acceptanceRule]){a['registerRule'](b);}}export async function assessServiceRisk(a,b,c,d='preorder',e){return getEvaluationEngine()['evaluate'](SERVICE_RISK_EVALUATION,{'service_id':a,'puzzle_raw':b,'depth':d,'presenter_history':e??[]},c);}