@wowok/agent-mcp 2.7.0 → 2.7.2

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 (427) hide show
  1. package/dist/config/index.js +1 -1
  2. package/dist/config/runtime.js +1 -238
  3. package/dist/customer/customer-advice.js +1 -130
  4. package/dist/customer/index.js +1 -11
  5. package/dist/customer/industry-risks.js +1 -438
  6. package/dist/customer/info-puzzle.js +1 -681
  7. package/dist/customer/order-monitor.js +1 -328
  8. package/dist/customer/order-strategy.js +1 -373
  9. package/dist/customer/post-purchase.js +1 -351
  10. package/dist/customer/preorder-compare.js +1 -34
  11. package/dist/customer/reminder-system.js +1 -316
  12. package/dist/customer/risk-assessment.d.ts +5 -1
  13. package/dist/customer/risk-assessment.js +1 -397
  14. package/dist/customer/types.js +1 -13
  15. package/dist/customer/user-preferences.js +1 -460
  16. package/dist/evaluation/arbitration-game.d.ts +23 -0
  17. package/dist/evaluation/arbitration-game.js +1 -0
  18. package/dist/evaluation/builtins/demand-match.d.ts +15 -0
  19. package/dist/evaluation/builtins/demand-match.js +1 -0
  20. package/dist/evaluation/builtins/index.d.ts +3 -0
  21. package/dist/evaluation/builtins/index.js +1 -0
  22. package/dist/evaluation/builtins/service-risk.d.ts +6 -0
  23. package/dist/evaluation/builtins/service-risk.js +1 -0
  24. package/dist/evaluation/capability.d.ts +50 -0
  25. package/dist/evaluation/capability.js +1 -0
  26. package/dist/evaluation/composer.d.ts +13 -0
  27. package/dist/evaluation/composer.js +1 -0
  28. package/dist/evaluation/engine.d.ts +18 -0
  29. package/dist/evaluation/engine.js +1 -0
  30. package/dist/evaluation/extract.d.ts +30 -0
  31. package/dist/evaluation/extract.js +1 -0
  32. package/dist/evaluation/game-strategy.d.ts +27 -0
  33. package/dist/evaluation/game-strategy.js +1 -0
  34. package/dist/evaluation/gap.d.ts +2 -0
  35. package/dist/evaluation/gap.js +1 -0
  36. package/dist/evaluation/index.d.ts +12 -0
  37. package/dist/evaluation/index.js +1 -0
  38. package/dist/evaluation/node-game.d.ts +62 -0
  39. package/dist/evaluation/node-game.js +1 -0
  40. package/dist/evaluation/region.d.ts +10 -0
  41. package/dist/evaluation/region.js +1 -0
  42. package/dist/evaluation/types.d.ts +77 -0
  43. package/dist/evaluation/types.js +1 -0
  44. package/dist/evaluation/user-injection.d.ts +6 -0
  45. package/dist/evaluation/user-injection.js +1 -0
  46. package/dist/examples/education-contact-create.json +40 -0
  47. package/dist/examples/freelance-contact-create.json +40 -0
  48. package/dist/examples/insurance-machine-create.json +1 -1
  49. package/dist/examples/insurance-service-allocators.json +1 -1
  50. package/dist/examples/machine-publish.json +1 -1
  51. package/dist/examples/rental-ziroom-service-create.json +1 -1
  52. package/dist/examples/retail-adv-guard-messenger-proof-create.json +1 -1
  53. package/dist/examples/retail-myshop-service-create.json +1 -1
  54. package/dist/examples/retail-myshop-service-customer-required.json +1 -1
  55. package/dist/examples/subscription-contact-create.json +40 -0
  56. package/dist/examples/threebody-machine-create.json +1 -1
  57. package/dist/examples/travel-machine-create.json +1 -1
  58. package/dist/examples/travel-service-create.json +1 -1
  59. package/dist/experience/experience-reuse.js +1 -103
  60. package/dist/experience/index.js +1 -5
  61. package/dist/experience/intent-distill.js +1 -83
  62. package/dist/experience/realtime-feedback.js +1 -94
  63. package/dist/experience/types.js +1 -1
  64. package/dist/experience/user-profile.js +1 -171
  65. package/dist/extensions/business-modules.js +1 -287
  66. package/dist/extensions/capability-manifest.js +1 -781
  67. package/dist/extensions/constraint-registry.js +1 -198
  68. package/dist/extensions/index.js +1 -6
  69. package/dist/extensions/metric-registry.js +1 -257
  70. package/dist/extensions/mode-evaluator.js +1 -170
  71. package/dist/extensions/modes.js +1 -499
  72. package/dist/extensions/registry.js +1 -717
  73. package/dist/extensions/types.js +1 -1
  74. package/dist/harness/auto-escalation.js +1 -68
  75. package/dist/harness/checkpoint.js +1 -129
  76. package/dist/harness/index.js +1 -78
  77. package/dist/harness/plan.js +1 -276
  78. package/dist/harness/recover.js +1 -139
  79. package/dist/harness/types.js +1 -1
  80. package/dist/harness/verify.js +1 -237
  81. package/dist/index.js +1 -273
  82. package/dist/intent/enrich.d.ts +1 -0
  83. package/dist/intent/enrich.js +1 -0
  84. package/dist/intent/index.d.ts +23 -0
  85. package/dist/intent/index.js +1 -0
  86. package/dist/intent/matcher.d.ts +2 -0
  87. package/dist/intent/matcher.js +1 -0
  88. package/dist/intent/store.d.ts +19 -0
  89. package/dist/intent/store.js +1 -0
  90. package/dist/intent/types.d.ts +33 -0
  91. package/dist/intent/types.js +1 -0
  92. package/dist/knowledge/acquisition-flywheel.js +1 -192
  93. package/dist/knowledge/allocation-confirm.js +1 -534
  94. package/dist/knowledge/allocation-context.js +1 -249
  95. package/dist/knowledge/allocation-ledger.js +1 -463
  96. package/dist/knowledge/allocation-puzzle.js +1 -298
  97. package/dist/knowledge/allocation-risk.js +1 -568
  98. package/dist/knowledge/allocation-templates.js +1 -970
  99. package/dist/knowledge/allocation-translation.js +1 -585
  100. package/dist/knowledge/arb-risk.js +1 -210
  101. package/dist/knowledge/arbitration-confirm.js +1 -559
  102. package/dist/knowledge/arbitration-context.js +1 -505
  103. package/dist/knowledge/arbitration-ledger.js +1 -521
  104. package/dist/knowledge/arbitration-puzzle.js +1 -304
  105. package/dist/knowledge/arbitration-risk.js +1 -433
  106. package/dist/knowledge/arbitration-templates.js +1 -276
  107. package/dist/knowledge/arbitration-translation.js +1 -487
  108. package/dist/knowledge/arbitration-trust.js +1 -117
  109. package/dist/knowledge/audit-rules.js +1 -141
  110. package/dist/knowledge/bridge-risk.js +1 -263
  111. package/dist/knowledge/contact-risk.js +1 -200
  112. package/dist/knowledge/contact-templates.d.ts +27 -0
  113. package/dist/knowledge/contact-templates.js +1 -0
  114. package/dist/knowledge/demand-confirm.js +1 -206
  115. package/dist/knowledge/demand-matching.js +1 -132
  116. package/dist/knowledge/demand-risk.js +1 -240
  117. package/dist/knowledge/demand-translation.js +1 -354
  118. package/dist/knowledge/deployment-scanner.js +1 -823
  119. package/dist/knowledge/dynamic-pricing.js +1 -87
  120. package/dist/knowledge/examples-scanner-cli.js +1 -26
  121. package/dist/knowledge/examples-scanner.js +1 -825
  122. package/dist/knowledge/flywheel-loop.js +1 -404
  123. package/dist/knowledge/fund-layer.js +1 -973
  124. package/dist/knowledge/glossary.js +1 -211
  125. package/dist/knowledge/guard-confirm.js +1 -406
  126. package/dist/knowledge/guard-context.js +1 -287
  127. package/dist/knowledge/guard-design-patterns.js +1 -360
  128. package/dist/knowledge/guard-ledger.js +1 -260
  129. package/dist/knowledge/guard-lint.js +1 -670
  130. package/dist/knowledge/guard-migration.js +1 -228
  131. package/dist/knowledge/guard-puzzle.js +1 -805
  132. package/dist/knowledge/guard-render.js +1 -700
  133. package/dist/knowledge/guard-risk.js +1 -1879
  134. package/dist/knowledge/guard-submission-prompt.js +1 -171
  135. package/dist/knowledge/guard-templates.js +1 -1105
  136. package/dist/knowledge/guard-translation.js +1 -1119
  137. package/dist/knowledge/index.js +1 -436
  138. package/dist/knowledge/industry-evolution.js +1 -323
  139. package/dist/knowledge/industry-generalizer.js +1 -381
  140. package/dist/knowledge/industry-registry.js +1 -174
  141. package/dist/knowledge/intent-metrics.d.ts +4 -3
  142. package/dist/knowledge/intent-metrics.js +1 -566
  143. package/dist/knowledge/machine-confirm.js +1 -559
  144. package/dist/knowledge/machine-context.js +1 -833
  145. package/dist/knowledge/machine-ledger.js +1 -338
  146. package/dist/knowledge/machine-puzzle.js +1 -494
  147. package/dist/knowledge/machine-render.js +1 -565
  148. package/dist/knowledge/machine-risk.js +1 -670
  149. package/dist/knowledge/machine-templates.js +1 -1597
  150. package/dist/knowledge/machine-topology.js +1 -234
  151. package/dist/knowledge/machine-translation.js +1 -513
  152. package/dist/knowledge/mcp-schema-audit-cli.js +1 -45
  153. package/dist/knowledge/mcp-schema-audit.d.ts +1 -1
  154. package/dist/knowledge/mcp-schema-audit.js +1 -773
  155. package/dist/knowledge/onchain-constants.js +1 -35
  156. package/dist/knowledge/order-confirm.js +1 -573
  157. package/dist/knowledge/order-context.js +1 -390
  158. package/dist/knowledge/order-ledger.js +1 -341
  159. package/dist/knowledge/order-puzzle.js +1 -255
  160. package/dist/knowledge/order-risk.js +1 -653
  161. package/dist/knowledge/order-templates.js +1 -368
  162. package/dist/knowledge/order-translation.js +1 -550
  163. package/dist/knowledge/overrides-loader.js +1 -65
  164. package/dist/knowledge/passport-confirm.js +1 -531
  165. package/dist/knowledge/passport-context.js +1 -306
  166. package/dist/knowledge/passport-ledger.js +1 -282
  167. package/dist/knowledge/passport-puzzle.js +1 -333
  168. package/dist/knowledge/passport-risk.js +1 -450
  169. package/dist/knowledge/passport-templates.js +1 -568
  170. package/dist/knowledge/passport-translation.js +1 -516
  171. package/dist/knowledge/payment-risk.js +1 -249
  172. package/dist/knowledge/permission-confirm.js +1 -426
  173. package/dist/knowledge/permission-context.js +1 -224
  174. package/dist/knowledge/permission-ledger.js +1 -403
  175. package/dist/knowledge/permission-puzzle.js +1 -173
  176. package/dist/knowledge/permission-risk.js +1 -411
  177. package/dist/knowledge/permission-templates.js +1 -234
  178. package/dist/knowledge/permission-translation.js +1 -350
  179. package/dist/knowledge/personal-risk.js +1 -212
  180. package/dist/knowledge/process-model.js +1 -160
  181. package/dist/knowledge/progress-confirm.js +1 -456
  182. package/dist/knowledge/progress-context.js +1 -452
  183. package/dist/knowledge/progress-ledger.js +1 -330
  184. package/dist/knowledge/progress-puzzle.js +1 -219
  185. package/dist/knowledge/progress-risk.js +1 -461
  186. package/dist/knowledge/progress-templates.js +1 -228
  187. package/dist/knowledge/progress-translation.js +1 -405
  188. package/dist/knowledge/proof-confirm.js +1 -187
  189. package/dist/knowledge/proof-risk.js +1 -207
  190. package/dist/knowledge/proof-translation.js +1 -283
  191. package/dist/knowledge/registrar-risk.js +1 -217
  192. package/dist/knowledge/repository-confirm.js +1 -286
  193. package/dist/knowledge/repository-risk.js +1 -373
  194. package/dist/knowledge/repository-translation.js +1 -445
  195. package/dist/knowledge/reputation-rules.js +1 -99
  196. package/dist/knowledge/resource-risk.js +1 -157
  197. package/dist/knowledge/reward-confirm.js +1 -526
  198. package/dist/knowledge/reward-context.js +1 -504
  199. package/dist/knowledge/reward-ledger.js +1 -502
  200. package/dist/knowledge/reward-puzzle.js +1 -300
  201. package/dist/knowledge/reward-risk.js +1 -627
  202. package/dist/knowledge/reward-templates.js +1 -197
  203. package/dist/knowledge/reward-translation.js +1 -501
  204. package/dist/knowledge/safety-rules.js +1 -404
  205. package/dist/knowledge/scenario-modes.js +1 -321
  206. package/dist/knowledge/service-confirm.js +1 -807
  207. package/dist/knowledge/service-context.js +1 -403
  208. package/dist/knowledge/service-ledger.js +1 -609
  209. package/dist/knowledge/service-puzzle.js +1 -236
  210. package/dist/knowledge/service-risk.js +1 -615
  211. package/dist/knowledge/service-templates.js +1 -456
  212. package/dist/knowledge/service-translation.js +1 -622
  213. package/dist/knowledge/template-registry.d.ts +1 -1
  214. package/dist/knowledge/template-registry.js +1 -341
  215. package/dist/knowledge/tool-constraints.js +1 -195
  216. package/dist/knowledge/tools-reference.js +1 -155
  217. package/dist/knowledge/treasury-confirm.js +1 -512
  218. package/dist/knowledge/treasury-context.js +1 -363
  219. package/dist/knowledge/treasury-ledger.js +1 -300
  220. package/dist/knowledge/treasury-puzzle.js +1 -216
  221. package/dist/knowledge/treasury-risk.js +1 -440
  222. package/dist/knowledge/treasury-templates.js +1 -358
  223. package/dist/knowledge/treasury-translation.js +1 -498
  224. package/dist/knowledge/trust-metrics.js +1 -198
  225. package/dist/knowledge/util-risk.js +1 -135
  226. package/dist/loop-engineering/aggregate.js +1 -132
  227. package/dist/loop-engineering/context-collect.js +1 -83
  228. package/dist/loop-engineering/diagnose.js +1 -273
  229. package/dist/loop-engineering/improve.js +1 -405
  230. package/dist/loop-engineering/index.js +1 -4
  231. package/dist/loop-engineering/pipeline.js +1 -56
  232. package/dist/mode-market/index.js +1 -3
  233. package/dist/mode-market/registry.js +1 -124
  234. package/dist/mode-market/review.js +1 -214
  235. package/dist/mode-market/submission.js +1 -85
  236. package/dist/participation/collaborator-interest.d.ts +23 -0
  237. package/dist/participation/collaborator-interest.js +1 -0
  238. package/dist/participation/customer-interest.d.ts +25 -0
  239. package/dist/participation/customer-interest.js +1 -0
  240. package/dist/participation/merchant-interest.js +1 -100
  241. package/dist/participation/radar-core.d.ts +13 -3
  242. package/dist/participation/radar-core.js +1 -269
  243. package/dist/participation/supplier-interest.d.ts +25 -0
  244. package/dist/participation/supplier-interest.js +1 -0
  245. package/dist/persona/analyzer.d.ts +16 -0
  246. package/dist/persona/analyzer.js +1 -0
  247. package/dist/persona/bridge.d.ts +5 -0
  248. package/dist/persona/bridge.js +1 -0
  249. package/dist/persona/defaults.d.ts +4 -0
  250. package/dist/persona/defaults.js +1 -0
  251. package/dist/persona/experience-bridge.d.ts +3 -0
  252. package/dist/persona/experience-bridge.js +1 -0
  253. package/dist/persona/index.d.ts +18 -0
  254. package/dist/persona/index.js +1 -0
  255. package/dist/persona/model.d.ts +7 -0
  256. package/dist/persona/model.js +1 -0
  257. package/dist/persona/store.d.ts +19 -0
  258. package/dist/persona/store.js +1 -0
  259. package/dist/persona/types.d.ts +45 -0
  260. package/dist/persona/types.js +1 -0
  261. package/dist/project/business-puzzle.js +1 -383
  262. package/dist/project/context-assembly.js +1 -254
  263. package/dist/project/deployment-bridge.js +1 -120
  264. package/dist/project/deployment-doc.js +1 -1126
  265. package/dist/project/edit-planner.js +1 -1342
  266. package/dist/project/evaluation.js +1 -2011
  267. package/dist/project/game-theory.js +1 -177
  268. package/dist/project/graph-builder.js +1 -656
  269. package/dist/project/graph.js +1 -340
  270. package/dist/project/handlers.d.ts +5 -0
  271. package/dist/project/handlers.js +1 -1762
  272. package/dist/project/index.d.ts +1 -0
  273. package/dist/project/index.js +1 -301
  274. package/dist/project/intent-analyzer.js +1 -149
  275. package/dist/project/machine-nodes.js +1 -36
  276. package/dist/project/merchant-guide.js +1 -264
  277. package/dist/project/migration.js +1 -125
  278. package/dist/project/mode-actions.js +1 -309
  279. package/dist/project/namespace.js +1 -206
  280. package/dist/project/participation-radar.js +1 -428
  281. package/dist/project/pipeline-actions.js +1 -109
  282. package/dist/project/project-store.js +1 -422
  283. package/dist/project/query.js +1 -153
  284. package/dist/project/reverse-mapping.d.ts +34 -0
  285. package/dist/project/reverse-mapping.js +1 -0
  286. package/dist/project/risk-aggregator.js +1 -295
  287. package/dist/project/rollback-policy.js +1 -290
  288. package/dist/project/semantic-assembler.js +1 -345
  289. package/dist/project/semantic-graph.js +1 -245
  290. package/dist/project/stage-gate.js +1 -369
  291. package/dist/project/substep-trace.js +1 -332
  292. package/dist/project/task-tracker.js +1 -78
  293. package/dist/role/derivation.d.ts +18 -0
  294. package/dist/role/derivation.js +1 -0
  295. package/dist/role/index.d.ts +5 -0
  296. package/dist/role/index.js +1 -0
  297. package/dist/role/model.d.ts +8 -0
  298. package/dist/role/model.js +1 -0
  299. package/dist/role/resolution.d.ts +11 -0
  300. package/dist/role/resolution.js +1 -0
  301. package/dist/role/types.d.ts +11 -0
  302. package/dist/role/types.js +1 -0
  303. package/dist/rules.d.ts +2 -0
  304. package/dist/rules.js +1 -9
  305. package/dist/safety/confirm-gate.js +1 -88
  306. package/dist/safety/index.js +1 -3
  307. package/dist/safety/preview.js +1 -52
  308. package/dist/schema/call/allocation.js +1 -34
  309. package/dist/schema/call/arbitration.js +1 -113
  310. package/dist/schema/call/base.d.ts +15 -15
  311. package/dist/schema/call/base.js +1 -370
  312. package/dist/schema/call/bridge-handler.js +1 -265
  313. package/dist/schema/call/bridge.d.ts +7 -7
  314. package/dist/schema/call/bridge.js +1 -458
  315. package/dist/schema/call/contact.js +1 -37
  316. package/dist/schema/call/demand.js +1 -47
  317. package/dist/schema/call/guard.js +1 -161
  318. package/dist/schema/call/handler.js +1 -322
  319. package/dist/schema/call/index.js +1 -20
  320. package/dist/schema/call/machine.js +1 -193
  321. package/dist/schema/call/order.js +1 -35
  322. package/dist/schema/call/payment.js +1 -37
  323. package/dist/schema/call/permission-handler.js +1 -54
  324. package/dist/schema/call/permission.js +1 -105
  325. package/dist/schema/call/personal.js +1 -78
  326. package/dist/schema/call/progress.js +1 -47
  327. package/dist/schema/call/proof.js +1 -33
  328. package/dist/schema/call/repository.js +1 -77
  329. package/dist/schema/call/reward.js +1 -30
  330. package/dist/schema/call/semantic.js +1 -1657
  331. package/dist/schema/call/service.js +1 -178
  332. package/dist/schema/call/treasury.js +1 -71
  333. package/dist/schema/common/index.js +1 -407
  334. package/dist/schema/config/index.js +1 -68
  335. package/dist/schema/evaluation/index.d.ts +4436 -0
  336. package/dist/schema/evaluation/index.js +1 -0
  337. package/dist/schema/index.d.ts +4 -0
  338. package/dist/schema/index.js +1 -13
  339. package/dist/schema/intent-radar/index.d.ts +284 -0
  340. package/dist/schema/intent-radar/index.js +1 -0
  341. package/dist/schema/local/index.d.ts +21 -21
  342. package/dist/schema/local/index.js +1 -927
  343. package/dist/schema/local/wip.js +1 -187
  344. package/dist/schema/messenger/index.d.ts +7 -7
  345. package/dist/schema/messenger/index.js +1 -475
  346. package/dist/schema/operations.d.ts +7 -7
  347. package/dist/schema/operations.js +1 -520
  348. package/dist/schema/persona/index.d.ts +1985 -0
  349. package/dist/schema/persona/index.js +1 -0
  350. package/dist/schema/project/index.d.ts +96 -50
  351. package/dist/schema/project/index.js +1 -2057
  352. package/dist/schema/query/index.d.ts +423 -7
  353. package/dist/schema/query/index.js +1 -1640
  354. package/dist/schema/schema-query/index.js +1 -104
  355. package/dist/schema/schema-version.js +1 -76
  356. package/dist/schema/sync-layer4.d.ts +1 -1
  357. package/dist/schema/sync-layer4.js +1 -282
  358. package/dist/schema/task-status.d.ts +168 -0
  359. package/dist/schema/task-status.js +1 -0
  360. package/dist/schema/trust/index.js +1 -314
  361. package/dist/schema/utils/guard-parser.js +1 -419
  362. package/dist/schema/utils/guard-query-utils.js +1 -46
  363. package/dist/schema/utils/node-parser.js +1 -369
  364. package/dist/schema/utils/object-type-utils.js +1 -35
  365. package/dist/schema/utils/permission-index-utils.js +1 -7
  366. package/dist/schema/utils/permission-machine-check.js +1 -121
  367. package/dist/schema/utils/skills-recommendation.js +1 -77
  368. package/dist/schema-query/index.js +1 -810
  369. package/dist/schemas/account_operation.output.json +5 -2
  370. package/dist/schemas/bridge_operation.output.json +5 -2
  371. package/dist/schemas/evaluation_operation.output.json +782 -0
  372. package/dist/schemas/evaluation_operation.schema.json +990 -0
  373. package/dist/schemas/index.json +25 -1
  374. package/dist/schemas/intent_radar.output.json +232 -0
  375. package/dist/schemas/intent_radar.schema.json +138 -0
  376. package/dist/schemas/local_info_operation.output.json +5 -2
  377. package/dist/schemas/local_mark_operation.output.json +5 -2
  378. package/dist/schemas/messenger_operation.output.json +5 -2
  379. package/dist/schemas/onchain_events.output.json +5 -2
  380. package/dist/schemas/onchain_operations.output.json +5 -2
  381. package/dist/schemas/onchain_operations.schema.json +6 -6
  382. package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
  383. package/dist/schemas/onchain_operations_machine.schema.json +2 -2
  384. package/dist/schemas/onchain_operations_service.schema.json +3 -3
  385. package/dist/schemas/onchain_table_data.output.json +6 -3
  386. package/dist/schemas/persona_operation.output.json +392 -0
  387. package/dist/schemas/persona_operation.schema.json +250 -0
  388. package/dist/schemas/project_operation.output.json +28 -8
  389. package/dist/schemas/query_task_status.output.json +115 -0
  390. package/dist/schemas/query_task_status.schema.json +24 -0
  391. package/dist/schemas/query_toolkit.output.json +9 -6
  392. package/dist/schemas/trust_score.schema.json +1 -1
  393. package/dist/schemas/wowok_buildin_info.output.json +132 -0
  394. package/dist/schemas/wowok_buildin_info.schema.json +14 -0
  395. package/dist/telemetry/index.js +1 -112
  396. package/dist/telemetry/redact.js +1 -23
  397. package/dist/telemetry/storage.js +1 -80
  398. package/dist/tools/handlers/bridge.js +1 -1
  399. package/dist/tools/handlers/config.js +1 -74
  400. package/dist/tools/handlers/evaluation.d.ts +2 -0
  401. package/dist/tools/handlers/evaluation.js +1 -0
  402. package/dist/tools/handlers/file-export.js +1 -90
  403. package/dist/tools/handlers/intent-radar.d.ts +2 -0
  404. package/dist/tools/handlers/intent-radar.js +1 -0
  405. package/dist/tools/handlers/local.js +1 -53
  406. package/dist/tools/handlers/messenger.js +1 -188
  407. package/dist/tools/handlers/onchain.js +1 -1082
  408. package/dist/tools/handlers/persona.d.ts +4 -0
  409. package/dist/tools/handlers/persona.js +1 -0
  410. package/dist/tools/handlers/project.js +1 -211
  411. package/dist/tools/handlers/query.js +1 -434
  412. package/dist/tools/handlers/schema-query.js +1 -176
  413. package/dist/tools/handlers/task-status.d.ts +0 -168
  414. package/dist/tools/handlers/task-status.js +1 -55
  415. package/dist/tools/handlers/trust.js +1 -380
  416. package/dist/tools/handlers/wip.js +1 -90
  417. package/dist/tools/index.js +1 -1306
  418. package/dist/tools/retry.js +1 -85
  419. package/dist/tools/rules-hook.js +1 -23
  420. package/dist/tools/shared.js +1 -130
  421. package/dist/tools/types.js +1 -1
  422. package/dist/tools/upgrade-check.d.ts +19 -0
  423. package/dist/tools/upgrade-check.js +1 -0
  424. package/dist/tools/wip-deploy-assist.d.ts +1 -1
  425. package/dist/tools/wip-deploy-assist.js +1 -278
  426. package/dist/tools/wrap.js +1 -500
  427. package/package.json +5 -3
@@ -5650,11 +5650,22 @@
5650
5650
  "perspective": {
5651
5651
  "type": "string",
5652
5652
  "enum": [
5653
+ "merchant",
5653
5654
  "customer",
5654
- "operator",
5655
- "observer"
5655
+ "prospect",
5656
+ "supplier",
5657
+ "collaborator",
5658
+ "arbitrator"
5656
5659
  ],
5657
- "description": "Derived from on-chain data (Order.builder + PermissionPerm grants), never caller-asserted."
5660
+ "description": "Derived commercial role from on-chain data (Order.builder + PermissionPerm grants + named operators), never caller-asserted."
5661
+ },
5662
+ "collaborator_kind": {
5663
+ "type": "string",
5664
+ "enum": [
5665
+ "permission_entity",
5666
+ "named_operator"
5667
+ ],
5668
+ "description": "Collaborator sub-kind when perspective === 'collaborator' (internal staff vs external operator)."
5658
5669
  },
5659
5670
  "roles": {
5660
5671
  "type": "array",
@@ -5718,6 +5729,10 @@
5718
5729
  "consequence": {
5719
5730
  "type": "string",
5720
5731
  "description": "Consequence hint (completion fund-release / refund path)."
5732
+ },
5733
+ "weight": {
5734
+ "type": "number",
5735
+ "description": "Forward weight (accumulates toward the pair's threshold)."
5721
5736
  }
5722
5737
  },
5723
5738
  "required": [
@@ -5831,6 +5846,11 @@
5831
5846
  "type": "boolean",
5832
5847
  "description": "True when Machine data was unavailable — operable/waiting_on unknown."
5833
5848
  },
5849
+ "threshold": {
5850
+ "type": "integer",
5851
+ "minimum": 1,
5852
+ "description": "Current pair's threshold (accumulated forward weights to advance)."
5853
+ },
5834
5854
  "interest_analysis": {
5835
5855
  "type": "object",
5836
5856
  "properties": {
@@ -5839,7 +5859,7 @@
5839
5859
  "items": {
5840
5860
  "type": "string"
5841
5861
  },
5842
- "description": "Where money sits and what releases it (escrow, Allocation waterfall, compensation_fund)."
5862
+ "description": "Where money sits and what releases it (escrow, Allocation waterfall, compensation_fund, or the role's non-settlement stake)."
5843
5863
  },
5844
5864
  "responsibility": {
5845
5865
  "type": "array",
@@ -5853,18 +5873,18 @@
5853
5873
  "items": {
5854
5874
  "type": "string"
5855
5875
  },
5856
- "description": "Actions serving the merchant's own interest (settlement speed, evidence pre-upload, Messenger nudge). Informational only."
5876
+ "description": "Actions serving the role's own interest (settlement speed, evidence pre-upload, Messenger nudge, arbitration). Informational only."
5857
5877
  },
5858
5878
  "stakes": {
5859
5879
  "type": "array",
5860
5880
  "items": {
5861
5881
  "type": "string"
5862
5882
  },
5863
- "description": "Downside exposure (arbitration indemnity, arb-loss record, stall statistics, refund aftermath)."
5883
+ "description": "Downside exposure (arbitration indemnity, arb-loss record, stall statistics, non-delivery, refund aftermath)."
5864
5884
  },
5865
5885
  "summary": {
5866
5886
  "type": "string",
5867
- "description": "One-paragraph merchant-interest summary."
5887
+ "description": "One-paragraph role-interest summary."
5868
5888
  }
5869
5889
  },
5870
5890
  "required": [
@@ -5875,7 +5895,7 @@
5875
5895
  "summary"
5876
5896
  ],
5877
5897
  "additionalProperties": false,
5878
- "description": "Merchant-side interest analysis (fund_flow/responsibility/leverage/stakes) — present ONLY when perspective='operator' and order data is available. AI MUST surface it as neutral information; the merchant decides."
5898
+ "description": "Role-specific interest analysis (fund_flow/responsibility/leverage/stakes) — present when order data is available. merchant → merchant-interest; supplier → supplier-interest; collaborator → collaborator-interest; customer → customer-interest. AI MUST surface it as neutral information; the role decides."
5879
5899
  },
5880
5900
  "summary": {
5881
5901
  "type": "string",
@@ -0,0 +1,115 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://wowok.net/schemas/query_task_status.json",
4
+ "title": "Task Status - Async Operation Tracking",
5
+ "description": "Query the status of a long-running async task (created by build_graph or evaluate_project with async_mode=true). Returns progress percentage, current status, and the final result.",
6
+ "$ref": "#/definitions/query_task_status",
7
+ "definitions": {
8
+ "query_task_status": {
9
+ "type": "object",
10
+ "properties": {
11
+ "task_id": {
12
+ "type": "string",
13
+ "description": "The queried task ID (present when a single task was queried)."
14
+ },
15
+ "task": {
16
+ "anyOf": [
17
+ {
18
+ "type": "object",
19
+ "properties": {
20
+ "task_id": {
21
+ "type": "string",
22
+ "description": "Unique task identifier."
23
+ },
24
+ "operation": {
25
+ "type": "string",
26
+ "description": "Operation type that created this task (e.g. 'build_graph')."
27
+ },
28
+ "status": {
29
+ "type": "string",
30
+ "enum": [
31
+ "pending",
32
+ "running",
33
+ "completed",
34
+ "failed",
35
+ "cancelled"
36
+ ],
37
+ "description": "Current task status."
38
+ },
39
+ "progress": {
40
+ "type": "number",
41
+ "description": "Progress percentage 0-100."
42
+ },
43
+ "message": {
44
+ "type": "string",
45
+ "description": "Human-readable progress message."
46
+ },
47
+ "result": {
48
+ "anyOf": [
49
+ {},
50
+ {
51
+ "type": "null"
52
+ }
53
+ ],
54
+ "description": "Result payload (set when status='completed'). null otherwise."
55
+ },
56
+ "error": {
57
+ "type": [
58
+ "string",
59
+ "null"
60
+ ],
61
+ "description": "Error message (set when status='failed'). null otherwise."
62
+ },
63
+ "started_at": {
64
+ "type": "number",
65
+ "description": "Timestamp (ms) when the task was created."
66
+ },
67
+ "completed_at": {
68
+ "type": [
69
+ "number",
70
+ "null"
71
+ ],
72
+ "description": "Timestamp (ms) when the task reached a terminal state. null if still running."
73
+ },
74
+ "project_id": {
75
+ "type": [
76
+ "string",
77
+ "null"
78
+ ],
79
+ "description": "Project ID associated with this task, if any."
80
+ }
81
+ },
82
+ "required": [
83
+ "task_id",
84
+ "operation",
85
+ "status",
86
+ "progress",
87
+ "message",
88
+ "error",
89
+ "started_at",
90
+ "completed_at",
91
+ "project_id"
92
+ ],
93
+ "additionalProperties": false
94
+ },
95
+ {
96
+ "type": "null"
97
+ }
98
+ ],
99
+ "description": "The task state. null if task_id not found or when listing."
100
+ },
101
+ "tasks": {
102
+ "type": "array",
103
+ "items": {
104
+ "$ref": "#/definitions/query_task_status/properties/task/anyOf/0"
105
+ },
106
+ "description": "List of tasks (present when task_id was omitted)."
107
+ }
108
+ },
109
+ "required": [
110
+ "task"
111
+ ],
112
+ "additionalProperties": false
113
+ }
114
+ }
115
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://wowok.net/schemas/query_task_status.json",
4
+ "title": "Task Status - Async Operation Tracking",
5
+ "description": "Query the status of a long-running async task (created by build_graph or evaluate_project with async_mode=true). Returns progress percentage, current status, and the final result.",
6
+ "$ref": "#/definitions/query_task_status",
7
+ "definitions": {
8
+ "query_task_status": {
9
+ "type": "object",
10
+ "properties": {
11
+ "task_id": {
12
+ "type": "string",
13
+ "description": "The task ID to query (returned by a prior async operation). If omitted, lists all recent tasks (most recent first, max 50)."
14
+ },
15
+ "project_id": {
16
+ "type": "string",
17
+ "description": "Optional filter — when listing tasks (task_id omitted), only return tasks for this project."
18
+ }
19
+ },
20
+ "additionalProperties": false,
21
+ "description": "Query the status of an async task, or list all recent tasks when task_id is omitted."
22
+ }
23
+ }
24
+ }
@@ -2648,7 +2648,7 @@
2648
2648
  },
2649
2649
  "wip": {
2650
2650
  "type": "string",
2651
- "description": "WIP file URL. EMPTY string \"\" skips verification (TESTING ONLY). Production MUST use a real HTTP URL pointing to a .wip file generated by the wip_file tool. Example: \"https://cdn.example.com/products/phone_v1.wip\""
2651
+ "description": "WIP file URL. EMPTY string \"\" skips verification (TESTING ONLY). Production MUST use a real HTTP URL pointing to a .wip file generated by the wip_file tool. ⚠️ NETWORK DEPLOYMENT REQUIRED: the URL is stored ON-CHAIN and every customer fetches it when placing an order. A local file path (C:\\..., /path/file.wip), a localhost/loopback URL or a LAN private-IP URL is unreachable by customers on other machines — it passes the merchant-side set-time verification but makes order_new abort 100% for customers. Either deploy the .wip file to a public endpoint (GitHub Pages / IPFS / your own website) and set this to the public URL, or leave it empty (\"\") to skip WIP verification (TESTING ONLY). Example: \"https://cdn.example.com/products/phone_v1.wip\""
2652
2652
  },
2653
2653
  "wip_hash": {
2654
2654
  "type": "string",
@@ -2829,7 +2829,7 @@
2829
2829
  "number",
2830
2830
  "string"
2831
2831
  ],
2832
- "description": "Allocation value. SEMANTICS DEPEND ON `mode`:\n• mode='Amount': absolute amount in smallest unit (e.g., '750000000' for 0.75 WOW, '250000000' for 0.25 WOW). Allocated first; sum of Amount items cached as `fix`.\n• mode='Rate': basis-points rate, 10000 = 100% (e.g., '7500' for 75%, '2500' for 25%). When no Surplus in same Allocator, sum MUST == 10000; when Surplus present, sum MUST <= 10000.\n• mode='Surplus': IGNORED (contract forces to 0). Set to '0' for clarity. Receives remaining balance after Amount + Rate allocations."
2832
+ "description": "Allocation value. SEMANTICS DEPEND ON `mode`:\n• mode='Amount': absolute amount in smallest unit (e.g., '750000000' for 0.75 WOW, '250000000' for 0.25 WOW). Allocated first; sum of Amount items cached as `fix`.\n• mode='Rate': basis-points rate, 10000 = 100% (e.g., '7500' for 75%, '2500' for 25%). When no Surplus in same Allocator, sum MUST == 10000; when Surplus present, sum MUST <= 10000.\n• mode='Surplus': IGNORED (contract forces to 0). Set to '0' for clarity. Receives remaining balance after Amount + Rate allocations.\n⚠️ T1 LOSSY POINT (B-2): the value is PRE-CONFIGURED and STATIC. A continuous/conditional amount (e.g. 'pay exactly the assessed loss amount') CANNOT be expressed — there is no runtime formula field. Model variable payouts as (a) a fixed-tier Allocator list guarded by distinct Guards, or (b) an Amount with a `max` cap — both are finite configurations, not free-form formulas."
2833
2833
  },
2834
2834
  "mode": {
2835
2835
  "anyOf": [
@@ -4960,7 +4960,7 @@
4960
4960
  "number",
4961
4961
  "string"
4962
4962
  ],
4963
- "description": "Allocation value. SEMANTICS DEPEND ON `mode`:\n• mode='Amount': absolute amount in smallest unit (e.g., '750000000' for 0.75 WOW, '250000000' for 0.25 WOW). Allocated first; sum of Amount items cached as `fix`.\n• mode='Rate': basis-points rate, 10000 = 100% (e.g., '7500' for 75%, '2500' for 25%). When no Surplus in same Allocator, sum MUST == 10000; when Surplus present, sum MUST <= 10000.\n• mode='Surplus': IGNORED (contract forces to 0). Set to '0' for clarity. Receives remaining balance after Amount + Rate allocations."
4963
+ "description": "Allocation value. SEMANTICS DEPEND ON `mode`:\n• mode='Amount': absolute amount in smallest unit (e.g., '750000000' for 0.75 WOW, '250000000' for 0.25 WOW). Allocated first; sum of Amount items cached as `fix`.\n• mode='Rate': basis-points rate, 10000 = 100% (e.g., '7500' for 75%, '2500' for 25%). When no Surplus in same Allocator, sum MUST == 10000; when Surplus present, sum MUST <= 10000.\n• mode='Surplus': IGNORED (contract forces to 0). Set to '0' for clarity. Receives remaining balance after Amount + Rate allocations.\n⚠️ T1 LOSSY POINT (B-2): the value is PRE-CONFIGURED and STATIC. A continuous/conditional amount (e.g. 'pay exactly the assessed loss amount') CANNOT be expressed — there is no runtime formula field. Model variable payouts as (a) a fixed-tier Allocator list guarded by distinct Guards, or (b) an Amount with a `max` cap — both are finite configurations, not free-form formulas."
4964
4964
  },
4965
4965
  "mode": {
4966
4966
  "anyOf": [
@@ -13132,7 +13132,7 @@
13132
13132
  "type": "null"
13133
13133
  }
13134
13134
  ],
13135
- "description": "Guard reference for this forward. Accepts TWO formats:\n• STRING (preferred): \"my_guard_name\" — the Guard's name or address as a plain string.\n• OBJECT (only when retained_submission is needed): {guard: \"my_guard_name\", retained_submission: [1,2,3]}.\nFOLLOW THE SCHEMA FIELD STRUCTURE: A Guard reference is fundamentally a STRING (the Guard object's name or address). Provide a string when you only need to reference a Guard — do NOT wrap a bare string in an object structure. The OBJECT form {guard: \"...\", retained_submission: [...]} exists ONLY to carry additional `retained_submission` data alongside the string reference; inside the object, the `guard` field is STILL a string. In short: string-in for a string reference, object-in only when you need to pass extra data.\nCOGNITIVE PRINCIPLE: Guard validation ALWAYS occurs BEFORE the forward operation. A Guard that queries state of the SAME Progress object this forward operates on (e.g. progress.current) will see the PRE-transition value (source node), NOT the target node. If the Guard checks progress.current == target_node, it will ALWAYS FAIL. Querying a DIFFERENT Progress object (cross-machine) is safe and reasonable — that progress is not modified by this forward. For target-node verification after transition, bind the Guard to the Allocator instead (allocation.alloc runs AFTER the state transition completes)."
13135
+ "description": "Guard reference for this forward. Accepts TWO formats:\n• STRING (preferred): \"my_guard_name\" — the Guard's name or address as a plain string.\n• OBJECT (only when retained_submission is needed): {guard: \"my_guard_name\", retained_submission: [1,2,3]}.\nFOLLOW THE SCHEMA FIELD STRUCTURE: A Guard reference is fundamentally a STRING (the Guard object's name or address). Provide a string when you only need to reference a Guard — do NOT wrap a bare string in an object structure. The OBJECT form {guard: \"...\", retained_submission: [...]} exists ONLY to carry additional `retained_submission` data alongside the string reference; inside the object, the `guard` field is STILL a string. In short: string-in for a string reference, object-in only when you need to pass extra data.\nCOGNITIVE PRINCIPLE: Guard validation ALWAYS occurs BEFORE the forward operation. A Guard that queries state of the SAME Progress object this forward operates on (e.g. progress.current) will see the PRE-transition value (source node), NOT the target node. If the Guard checks progress.current == target_node, it will ALWAYS FAIL. Querying a DIFFERENT Progress object (cross-machine) is safe and reasonable — that progress is not modified by this forward. For target-node verification after transition, bind the Guard to the Allocator instead (allocation.alloc runs AFTER the state transition completes).\n⚠️ T1 LOSSY POINT (B-3): WoWok has NO on-chain cron. A business phrase like 'after N days, auto-X' is NOT an automatic trigger — it decomposes into (1) a time_guard that checks elapsed time, and (2) an OFF-CHAIN keeper that must submit the forward when the guard passes. Configuring a time_guard WITHOUT a keeper means nothing ever fires."
13136
13136
  }
13137
13137
  },
13138
13138
  "required": [
@@ -15136,13 +15136,16 @@
15136
15136
  "items": {
15137
15137
  "type": "string"
15138
15138
  },
15139
- "description": "Phase 4 P4-6.C: Role-targeted advice strings (user/merchant/arbitrator). Example: ['Strengthen loyalty flywheel','Optimize first-order conversion']"
15139
+ "description": "Phase 4 P4-6.C: Role-targeted advice strings (merchant/customer/prospect/supplier/collaborator/arbitrator). Example: ['Strengthen loyalty flywheel','Optimize first-order conversion']"
15140
15140
  },
15141
15141
  "role": {
15142
15142
  "type": "string",
15143
15143
  "enum": [
15144
- "user",
15145
15144
  "merchant",
15145
+ "customer",
15146
+ "prospect",
15147
+ "supplier",
15148
+ "collaborator",
15146
15149
  "arbitrator"
15147
15150
  ],
15148
15151
  "description": "Phase 4 P4-6.C: Role used for advice routing. Example: 'merchant'"
@@ -291,7 +291,7 @@
291
291
  "metrics"
292
292
  ],
293
293
  "additionalProperties": false,
294
- "description": "Optional user-controllable scoring factors (评分体系用户可控). Evaluated at depth=preorder; the composite adjustment (±cap) nudges the order confidence score."
294
+ "description": "Optional user-controllable scoring factors. Evaluated at depth=preorder; the composite adjustment (±cap) nudges the order confidence score."
295
295
  },
296
296
  "network": {
297
297
  "type": "string",
@@ -835,6 +835,138 @@
835
835
  "result"
836
836
  ],
837
837
  "additionalProperties": false
838
+ },
839
+ {
840
+ "type": "object",
841
+ "properties": {
842
+ "info": {
843
+ "type": "string",
844
+ "const": "upgrade_check"
845
+ },
846
+ "result": {
847
+ "type": "object",
848
+ "properties": {
849
+ "mcp": {
850
+ "type": "object",
851
+ "properties": {
852
+ "current": {
853
+ "type": [
854
+ "string",
855
+ "null"
856
+ ],
857
+ "description": "Currently installed/running version"
858
+ },
859
+ "latest": {
860
+ "type": [
861
+ "string",
862
+ "null"
863
+ ],
864
+ "description": "Latest published npm version (null when offline/unreachable)"
865
+ },
866
+ "outdated": {
867
+ "type": "boolean",
868
+ "description": "true when a newer version is available"
869
+ }
870
+ },
871
+ "required": [
872
+ "current",
873
+ "latest",
874
+ "outdated"
875
+ ],
876
+ "additionalProperties": false,
877
+ "description": "WoWok MCP server version comparison"
878
+ },
879
+ "sdk": {
880
+ "type": "object",
881
+ "properties": {
882
+ "current": {
883
+ "$ref": "#/definitions/wowok_buildin_info/properties/result/anyOf/8/properties/result/properties/mcp/properties/current"
884
+ },
885
+ "latest": {
886
+ "$ref": "#/definitions/wowok_buildin_info/properties/result/anyOf/8/properties/result/properties/mcp/properties/latest"
887
+ },
888
+ "outdated": {
889
+ "$ref": "#/definitions/wowok_buildin_info/properties/result/anyOf/8/properties/result/properties/mcp/properties/outdated"
890
+ }
891
+ },
892
+ "required": [
893
+ "current",
894
+ "latest",
895
+ "outdated"
896
+ ],
897
+ "additionalProperties": false,
898
+ "description": "WoWok SDK version comparison"
899
+ },
900
+ "client_installed": {
901
+ "type": "boolean",
902
+ "description": "Whether the WoWok desktop client is installed"
903
+ },
904
+ "client_install_hint": {
905
+ "type": [
906
+ "string",
907
+ "null"
908
+ ],
909
+ "description": "Where to get the desktop client (e.g. download URL)"
910
+ },
911
+ "upgrade_available": {
912
+ "type": "boolean",
913
+ "description": "true when any component is outdated"
914
+ },
915
+ "reminder": {
916
+ "type": "object",
917
+ "properties": {
918
+ "type": {
919
+ "type": "string",
920
+ "enum": [
921
+ "upgrade",
922
+ "install_client",
923
+ "none"
924
+ ],
925
+ "description": "Reminder kind"
926
+ },
927
+ "due": {
928
+ "type": "boolean",
929
+ "description": "Whether to surface the reminder in this conversation"
930
+ },
931
+ "message": {
932
+ "type": [
933
+ "string",
934
+ "null"
935
+ ],
936
+ "description": "Ready-to-use, benefit-focused reminder message; null when not due"
937
+ }
938
+ },
939
+ "required": [
940
+ "type",
941
+ "due",
942
+ "message"
943
+ ],
944
+ "additionalProperties": false,
945
+ "description": "Reminder decision"
946
+ },
947
+ "checked_at": {
948
+ "type": "string",
949
+ "description": "ISO timestamp of the check"
950
+ }
951
+ },
952
+ "required": [
953
+ "mcp",
954
+ "sdk",
955
+ "client_installed",
956
+ "client_install_hint",
957
+ "upgrade_available",
958
+ "reminder",
959
+ "checked_at"
960
+ ],
961
+ "additionalProperties": false,
962
+ "description": "Upgrade & client-install reminder check result"
963
+ }
964
+ },
965
+ "required": [
966
+ "info",
967
+ "result"
968
+ ],
969
+ "additionalProperties": false
838
970
  }
839
971
  ],
840
972
  "description": "Protocol info result"
@@ -551,6 +551,20 @@
551
551
  ],
552
552
  "additionalProperties": false,
553
553
  "description": "Funding guidance query - how to obtain WOW gas and payment tokens. Returns testnet faucet info, mainnet ETH cross-chain bridge flow, and the WOW mainnet airdrop link. Use this when a user asks how to obtain tokens/gas/funds, or as a proactive first-use reminder."
554
+ },
555
+ {
556
+ "type": "object",
557
+ "properties": {
558
+ "info": {
559
+ "type": "string",
560
+ "const": "upgrade_check"
561
+ }
562
+ },
563
+ "required": [
564
+ "info"
565
+ ],
566
+ "additionalProperties": false,
567
+ "description": "Upgrade check - returns current vs latest npm versions of the WoWok MCP server and SDK, whether the WoWok desktop client is installed, and whether an upgrade/install reminder is due. Call at the start of a conversation to decide whether to remind the user to upgrade or install the client."
554
568
  }
555
569
  ],
556
570
  "description": "WoWok Build-in infomation query"
@@ -1,112 +1 @@
1
- import { getStorage } from "./storage.js";
2
- import { redactObject } from "./redact.js";
3
- let _enabled = true;
4
- export function setTelemetryEnabled(enabled) {
5
- _enabled = enabled;
6
- }
7
- export function isTelemetryEnabled() {
8
- return _enabled;
9
- }
10
- function extractFromOutput(structuredContent, toolName, operationTypeHint) {
11
- if (!structuredContent) {
12
- return { tool_name: toolName, semantic_hit: false };
13
- }
14
- const semantic = structuredContent.semantic;
15
- const result = structuredContent.result;
16
- const event = {
17
- tool_name: toolName,
18
- semantic_hit: !!semantic,
19
- };
20
- if (semantic) {
21
- event.intent = semantic.intent;
22
- event.status = semantic.status;
23
- }
24
- if (result?.type === "error") {
25
- event.status = event.status || "failed";
26
- event.error_code = result.error_code;
27
- if (result.error) {
28
- const truncated = String(result.error).slice(0, 500);
29
- event.error_message = redactObject(truncated);
30
- }
31
- }
32
- if (operationTypeHint) {
33
- event.operation_type = operationTypeHint;
34
- }
35
- else if (semantic?.intent) {
36
- event.operation_type = "unknown";
37
- }
38
- return event;
39
- }
40
- export async function captureTelemetry(toolName, structuredContent, durationMs, operationTypeHint) {
41
- if (!_enabled)
42
- return;
43
- try {
44
- const extracted = extractFromOutput(structuredContent, toolName, operationTypeHint);
45
- const event = {
46
- timestamp: new Date().toISOString(),
47
- tool_name: extracted.tool_name || toolName,
48
- operation_type: extracted.operation_type || "unknown",
49
- intent: extracted.intent,
50
- status: extracted.status,
51
- error_code: extracted.error_code,
52
- duration_ms: durationMs,
53
- semantic_hit: extracted.semantic_hit ?? false,
54
- error_message: extracted.error_message,
55
- };
56
- await getStorage().append(event);
57
- }
58
- catch {
59
- }
60
- }
61
- export async function captureTelemetryError(toolName, error, durationMs, operationTypeHint) {
62
- if (!_enabled)
63
- return;
64
- try {
65
- const errorMsg = String(error?.message ?? error).slice(0, 500);
66
- const event = {
67
- timestamp: new Date().toISOString(),
68
- tool_name: toolName,
69
- operation_type: operationTypeHint || "unknown",
70
- status: "failed",
71
- duration_ms: durationMs,
72
- semantic_hit: false,
73
- error_message: redactObject(errorMsg),
74
- };
75
- await getStorage().append(event);
76
- }
77
- catch {
78
- }
79
- }
80
- export function withTelemetry(toolName, handler) {
81
- return async (args) => {
82
- const start = Date.now();
83
- let output;
84
- try {
85
- output = await handler(args);
86
- return output;
87
- }
88
- catch (error) {
89
- await captureTelemetryError(toolName, error, Date.now() - start, extractOperationType(args));
90
- throw error;
91
- }
92
- finally {
93
- if (output) {
94
- await captureTelemetry(toolName, output?.structuredContent, Date.now() - start, extractOperationType(args));
95
- }
96
- }
97
- };
98
- }
99
- function extractOperationType(args) {
100
- if (!args || typeof args !== "object")
101
- return undefined;
102
- if (typeof args.operation_type === "string") {
103
- if (args.operation_type.startsWith("cross_chain") || args.operation_type.startsWith("claim") ||
104
- args.operation_type.startsWith("withdraw") || args.operation_type.startsWith("query_")) {
105
- return "bridge_" + args.operation_type;
106
- }
107
- return args.operation_type;
108
- }
109
- if (args.data?.operation_type)
110
- return args.data.operation_type;
111
- return undefined;
112
- }
1
+ import{getStorage}from'./storage.js';import{redactObject}from'./redact.js';let _enabled=!![];export function setTelemetryEnabled(a){_enabled=a;}export function isTelemetryEnabled(){return _enabled;}function extractFromOutput(a,b,c){if(!a)return{'tool_name':b,'semantic_hit':![]};const d=a['semantic'],e=a['result'],f={'tool_name':b,'semantic_hit':!!d};d&&(f['intent']=d['intent'],f['status']=d['status']);if(e?.['type']==='error'){f['status']=f['status']||'failed',f['error_code']=e['error_code'];if(e['error']){const g=String(e['error'])['slice'](0x0,0x1f4);f['error_message']=redactObject(g);}}if(c)f['operation_type']=c;else d?.['intent']&&(f['operation_type']='unknown');return f;}export async function captureTelemetry(a,b,c,d){if(!_enabled)return;try{const e=extractFromOutput(b,a,d),f={'timestamp':new Date()['toISOString'](),'tool_name':e['tool_name']||a,'operation_type':e['operation_type']||'unknown','intent':e['intent'],'status':e['status'],'error_code':e['error_code'],'duration_ms':c,'semantic_hit':e['semantic_hit']??![],'error_message':e['error_message']};await getStorage()['append'](f);}catch{}}export async function captureTelemetryError(a,b,c,d){if(!_enabled)return;try{const e=String(b?.['message']??b)['slice'](0x0,0x1f4),f={'timestamp':new Date()['toISOString'](),'tool_name':a,'operation_type':d||'unknown','status':'failed','duration_ms':c,'semantic_hit':![],'error_message':redactObject(e)};await getStorage()['append'](f);}catch{}}export function withTelemetry(a,b){return async c=>{const d=Date['now']();let e;try{return e=await b(c),e;}catch(f){await captureTelemetryError(a,f,Date['now']()-d,extractOperationType(c));throw f;}finally{e&&await captureTelemetry(a,e?.['structuredContent'],Date['now']()-d,extractOperationType(c));}};}function extractOperationType(a){if(!a||typeof a!=='object')return undefined;if(typeof a['operation_type']==='string'){if(a['operation_type']['startsWith']('cross_chain')||a['operation_type']['startsWith']('claim')||a['operation_type']['startsWith']('withdraw')||a['operation_type']['startsWith']('query_'))return'bridge_'+a['operation_type'];return a['operation_type'];}if(a['data']?.['operation_type'])return a['data']['operation_type'];return undefined;}
@@ -1,23 +1 @@
1
- import { createHash } from "crypto";
2
- const ADDRESS_PATTERN = /^0x[0-9a-fA-F]{40,}$/;
3
- export function redactAddress(value) {
4
- if (typeof value !== "string")
5
- return value;
6
- if (!ADDRESS_PATTERN.test(value))
7
- return value;
8
- const hash = createHash("sha256").update(value.toLowerCase()).digest("hex");
9
- return "0x" + hash.slice(0, 16);
10
- }
11
- export function redactObject(obj) {
12
- if (typeof obj === "string")
13
- return redactAddress(obj);
14
- if (Array.isArray(obj))
15
- return obj.map(redactObject);
16
- if (obj && typeof obj === "object" && obj.constructor === Object) {
17
- const out = {};
18
- for (const k of Object.keys(obj))
19
- out[k] = redactObject(obj[k]);
20
- return out;
21
- }
22
- return obj;
23
- }
1
+ import{createHash}from'crypto';const ADDRESS_PATTERN=/^0x[0-9a-fA-F]{40,}$/;export function redactAddress(a){if(typeof a!=='string')return a;if(!ADDRESS_PATTERN['test'](a))return a;const b=createHash('sha256')['update'](a['toLowerCase']())['digest']('hex');return'0x'+b['slice'](0x0,0x10);}export function redactObject(a){if(typeof a==='string')return redactAddress(a);if(Array['isArray'](a))return a['map'](redactObject);if(a&&typeof a==='object'&&a['constructor']===Object){const b={};for(const c of Object['keys'](a))b[c]=redactObject(a[c]);return b;}return a;}