@wowok/agent-mcp 2.7.1 → 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 (375) 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.js +1 -397
  13. package/dist/customer/types.js +1 -13
  14. package/dist/customer/user-preferences.js +1 -460
  15. package/dist/evaluation/arbitration-game.d.ts +9 -2
  16. package/dist/evaluation/arbitration-game.js +1 -48
  17. package/dist/evaluation/builtins/demand-match.js +1 -153
  18. package/dist/evaluation/builtins/index.js +1 -10
  19. package/dist/evaluation/builtins/service-risk.js +1 -55
  20. package/dist/evaluation/capability.js +1 -13
  21. package/dist/evaluation/composer.js +1 -40
  22. package/dist/evaluation/engine.js +1 -175
  23. package/dist/evaluation/extract.js +1 -115
  24. package/dist/evaluation/game-strategy.d.ts +27 -0
  25. package/dist/evaluation/game-strategy.js +1 -0
  26. package/dist/evaluation/gap.js +1 -100
  27. package/dist/evaluation/index.d.ts +1 -0
  28. package/dist/evaluation/index.js +1 -11
  29. package/dist/evaluation/node-game.d.ts +31 -3
  30. package/dist/evaluation/node-game.js +1 -57
  31. package/dist/evaluation/region.js +1 -36
  32. package/dist/evaluation/types.d.ts +1 -0
  33. package/dist/evaluation/types.js +1 -1
  34. package/dist/evaluation/user-injection.js +1 -27
  35. package/dist/experience/experience-reuse.js +1 -103
  36. package/dist/experience/index.js +1 -5
  37. package/dist/experience/intent-distill.js +1 -83
  38. package/dist/experience/realtime-feedback.js +1 -94
  39. package/dist/experience/types.js +1 -1
  40. package/dist/experience/user-profile.js +1 -171
  41. package/dist/extensions/business-modules.js +1 -287
  42. package/dist/extensions/capability-manifest.js +1 -781
  43. package/dist/extensions/constraint-registry.js +1 -198
  44. package/dist/extensions/index.js +1 -6
  45. package/dist/extensions/metric-registry.js +1 -257
  46. package/dist/extensions/mode-evaluator.js +1 -170
  47. package/dist/extensions/modes.js +1 -499
  48. package/dist/extensions/registry.js +1 -717
  49. package/dist/extensions/types.js +1 -1
  50. package/dist/harness/auto-escalation.js +1 -68
  51. package/dist/harness/checkpoint.js +1 -129
  52. package/dist/harness/index.js +1 -78
  53. package/dist/harness/plan.js +1 -315
  54. package/dist/harness/recover.js +1 -139
  55. package/dist/harness/types.js +1 -1
  56. package/dist/harness/verify.js +1 -237
  57. package/dist/index.js +1 -273
  58. package/dist/intent/enrich.js +1 -67
  59. package/dist/intent/index.js +1 -60
  60. package/dist/intent/matcher.js +1 -81
  61. package/dist/intent/store.js +1 -55
  62. package/dist/intent/types.js +1 -10
  63. package/dist/knowledge/acquisition-flywheel.js +1 -192
  64. package/dist/knowledge/allocation-confirm.js +1 -534
  65. package/dist/knowledge/allocation-context.js +1 -249
  66. package/dist/knowledge/allocation-ledger.js +1 -463
  67. package/dist/knowledge/allocation-puzzle.js +1 -298
  68. package/dist/knowledge/allocation-risk.js +1 -568
  69. package/dist/knowledge/allocation-templates.js +1 -970
  70. package/dist/knowledge/allocation-translation.js +1 -585
  71. package/dist/knowledge/arb-risk.js +1 -210
  72. package/dist/knowledge/arbitration-confirm.js +1 -559
  73. package/dist/knowledge/arbitration-context.js +1 -505
  74. package/dist/knowledge/arbitration-ledger.js +1 -521
  75. package/dist/knowledge/arbitration-puzzle.js +1 -304
  76. package/dist/knowledge/arbitration-risk.js +1 -423
  77. package/dist/knowledge/arbitration-templates.js +1 -276
  78. package/dist/knowledge/arbitration-translation.js +1 -487
  79. package/dist/knowledge/arbitration-trust.js +1 -117
  80. package/dist/knowledge/audit-rules.js +1 -141
  81. package/dist/knowledge/bridge-risk.js +1 -263
  82. package/dist/knowledge/contact-risk.js +1 -200
  83. package/dist/knowledge/contact-templates.js +1 -60
  84. package/dist/knowledge/demand-confirm.js +1 -206
  85. package/dist/knowledge/demand-matching.js +1 -132
  86. package/dist/knowledge/demand-risk.js +1 -240
  87. package/dist/knowledge/demand-translation.js +1 -354
  88. package/dist/knowledge/deployment-scanner.js +1 -823
  89. package/dist/knowledge/dynamic-pricing.js +1 -87
  90. package/dist/knowledge/examples-scanner-cli.js +1 -26
  91. package/dist/knowledge/examples-scanner.js +1 -843
  92. package/dist/knowledge/flywheel-loop.js +1 -404
  93. package/dist/knowledge/fund-layer.js +1 -973
  94. package/dist/knowledge/glossary.js +1 -211
  95. package/dist/knowledge/guard-confirm.js +1 -406
  96. package/dist/knowledge/guard-context.js +1 -287
  97. package/dist/knowledge/guard-design-patterns.js +1 -360
  98. package/dist/knowledge/guard-ledger.js +1 -260
  99. package/dist/knowledge/guard-lint.js +1 -670
  100. package/dist/knowledge/guard-migration.js +1 -228
  101. package/dist/knowledge/guard-puzzle.js +1 -805
  102. package/dist/knowledge/guard-render.js +1 -700
  103. package/dist/knowledge/guard-risk.js +1 -1879
  104. package/dist/knowledge/guard-submission-prompt.js +1 -171
  105. package/dist/knowledge/guard-templates.js +1 -1105
  106. package/dist/knowledge/guard-translation.js +1 -1119
  107. package/dist/knowledge/index.js +1 -436
  108. package/dist/knowledge/industry-evolution.js +1 -323
  109. package/dist/knowledge/industry-generalizer.js +1 -381
  110. package/dist/knowledge/industry-registry.js +1 -174
  111. package/dist/knowledge/intent-metrics.d.ts +4 -3
  112. package/dist/knowledge/intent-metrics.js +1 -566
  113. package/dist/knowledge/machine-confirm.js +1 -559
  114. package/dist/knowledge/machine-context.js +1 -833
  115. package/dist/knowledge/machine-ledger.js +1 -338
  116. package/dist/knowledge/machine-puzzle.js +1 -494
  117. package/dist/knowledge/machine-render.js +1 -565
  118. package/dist/knowledge/machine-risk.js +1 -669
  119. package/dist/knowledge/machine-templates.js +1 -1597
  120. package/dist/knowledge/machine-topology.js +1 -234
  121. package/dist/knowledge/machine-translation.js +1 -513
  122. package/dist/knowledge/mcp-schema-audit-cli.js +1 -45
  123. package/dist/knowledge/mcp-schema-audit.js +1 -777
  124. package/dist/knowledge/onchain-constants.js +1 -35
  125. package/dist/knowledge/order-confirm.js +1 -573
  126. package/dist/knowledge/order-context.js +1 -390
  127. package/dist/knowledge/order-ledger.js +1 -341
  128. package/dist/knowledge/order-puzzle.js +1 -255
  129. package/dist/knowledge/order-risk.js +1 -653
  130. package/dist/knowledge/order-templates.js +1 -368
  131. package/dist/knowledge/order-translation.js +1 -550
  132. package/dist/knowledge/overrides-loader.js +1 -65
  133. package/dist/knowledge/passport-confirm.js +1 -531
  134. package/dist/knowledge/passport-context.js +1 -306
  135. package/dist/knowledge/passport-ledger.js +1 -282
  136. package/dist/knowledge/passport-puzzle.js +1 -333
  137. package/dist/knowledge/passport-risk.js +1 -450
  138. package/dist/knowledge/passport-templates.js +1 -568
  139. package/dist/knowledge/passport-translation.js +1 -516
  140. package/dist/knowledge/payment-risk.js +1 -249
  141. package/dist/knowledge/permission-confirm.js +1 -426
  142. package/dist/knowledge/permission-context.js +1 -224
  143. package/dist/knowledge/permission-ledger.js +1 -403
  144. package/dist/knowledge/permission-puzzle.js +1 -173
  145. package/dist/knowledge/permission-risk.js +1 -411
  146. package/dist/knowledge/permission-templates.js +1 -234
  147. package/dist/knowledge/permission-translation.js +1 -350
  148. package/dist/knowledge/personal-risk.js +1 -212
  149. package/dist/knowledge/process-model.js +1 -160
  150. package/dist/knowledge/progress-confirm.js +1 -456
  151. package/dist/knowledge/progress-context.js +1 -452
  152. package/dist/knowledge/progress-ledger.js +1 -330
  153. package/dist/knowledge/progress-puzzle.js +1 -219
  154. package/dist/knowledge/progress-risk.js +1 -461
  155. package/dist/knowledge/progress-templates.js +1 -228
  156. package/dist/knowledge/progress-translation.js +1 -405
  157. package/dist/knowledge/proof-confirm.js +1 -187
  158. package/dist/knowledge/proof-risk.js +1 -207
  159. package/dist/knowledge/proof-translation.js +1 -283
  160. package/dist/knowledge/registrar-risk.js +1 -217
  161. package/dist/knowledge/repository-confirm.js +1 -286
  162. package/dist/knowledge/repository-risk.js +1 -373
  163. package/dist/knowledge/repository-translation.js +1 -445
  164. package/dist/knowledge/reputation-rules.js +1 -99
  165. package/dist/knowledge/resource-risk.js +1 -157
  166. package/dist/knowledge/reward-confirm.js +1 -526
  167. package/dist/knowledge/reward-context.js +1 -504
  168. package/dist/knowledge/reward-ledger.js +1 -502
  169. package/dist/knowledge/reward-puzzle.js +1 -300
  170. package/dist/knowledge/reward-risk.js +1 -627
  171. package/dist/knowledge/reward-templates.js +1 -197
  172. package/dist/knowledge/reward-translation.js +1 -501
  173. package/dist/knowledge/safety-rules.js +1 -404
  174. package/dist/knowledge/scenario-modes.js +1 -321
  175. package/dist/knowledge/service-confirm.js +1 -807
  176. package/dist/knowledge/service-context.js +1 -403
  177. package/dist/knowledge/service-ledger.js +1 -609
  178. package/dist/knowledge/service-puzzle.js +1 -236
  179. package/dist/knowledge/service-risk.js +1 -651
  180. package/dist/knowledge/service-templates.js +1 -456
  181. package/dist/knowledge/service-translation.js +1 -622
  182. package/dist/knowledge/template-registry.js +1 -353
  183. package/dist/knowledge/tool-constraints.js +1 -195
  184. package/dist/knowledge/tools-reference.js +1 -178
  185. package/dist/knowledge/treasury-confirm.js +1 -512
  186. package/dist/knowledge/treasury-context.js +1 -363
  187. package/dist/knowledge/treasury-ledger.js +1 -300
  188. package/dist/knowledge/treasury-puzzle.js +1 -216
  189. package/dist/knowledge/treasury-risk.js +1 -440
  190. package/dist/knowledge/treasury-templates.js +1 -358
  191. package/dist/knowledge/treasury-translation.js +1 -498
  192. package/dist/knowledge/trust-metrics.js +1 -198
  193. package/dist/knowledge/util-risk.js +1 -135
  194. package/dist/loop-engineering/aggregate.js +1 -132
  195. package/dist/loop-engineering/context-collect.js +1 -83
  196. package/dist/loop-engineering/diagnose.js +1 -273
  197. package/dist/loop-engineering/improve.js +1 -405
  198. package/dist/loop-engineering/index.js +1 -4
  199. package/dist/loop-engineering/pipeline.js +1 -56
  200. package/dist/mode-market/index.js +1 -3
  201. package/dist/mode-market/registry.js +1 -124
  202. package/dist/mode-market/review.js +1 -214
  203. package/dist/mode-market/submission.js +1 -85
  204. package/dist/participation/collaborator-interest.d.ts +23 -0
  205. package/dist/participation/collaborator-interest.js +1 -0
  206. package/dist/participation/customer-interest.d.ts +25 -0
  207. package/dist/participation/customer-interest.js +1 -0
  208. package/dist/participation/merchant-interest.js +1 -100
  209. package/dist/participation/radar-core.d.ts +13 -3
  210. package/dist/participation/radar-core.js +1 -269
  211. package/dist/participation/supplier-interest.d.ts +25 -0
  212. package/dist/participation/supplier-interest.js +1 -0
  213. package/dist/persona/analyzer.js +1 -66
  214. package/dist/persona/bridge.js +1 -86
  215. package/dist/persona/defaults.js +1 -195
  216. package/dist/persona/experience-bridge.js +1 -23
  217. package/dist/persona/index.js +1 -71
  218. package/dist/persona/model.js +1 -111
  219. package/dist/persona/store.js +1 -62
  220. package/dist/persona/types.d.ts +3 -1
  221. package/dist/persona/types.js +1 -5
  222. package/dist/project/business-puzzle.js +1 -383
  223. package/dist/project/context-assembly.js +1 -254
  224. package/dist/project/deployment-bridge.js +1 -120
  225. package/dist/project/deployment-doc.js +1 -1126
  226. package/dist/project/edit-planner.js +1 -1342
  227. package/dist/project/evaluation.js +1 -2011
  228. package/dist/project/game-theory.js +1 -177
  229. package/dist/project/graph-builder.js +1 -656
  230. package/dist/project/graph.js +1 -340
  231. package/dist/project/handlers.js +1 -1784
  232. package/dist/project/index.d.ts +1 -0
  233. package/dist/project/index.js +1 -301
  234. package/dist/project/intent-analyzer.js +1 -149
  235. package/dist/project/machine-nodes.js +1 -36
  236. package/dist/project/merchant-guide.js +1 -264
  237. package/dist/project/migration.js +1 -125
  238. package/dist/project/mode-actions.js +1 -309
  239. package/dist/project/namespace.js +1 -206
  240. package/dist/project/participation-radar.js +1 -428
  241. package/dist/project/pipeline-actions.js +1 -109
  242. package/dist/project/project-store.js +1 -422
  243. package/dist/project/query.js +1 -153
  244. package/dist/project/reverse-mapping.d.ts +34 -0
  245. package/dist/project/reverse-mapping.js +1 -0
  246. package/dist/project/risk-aggregator.js +1 -295
  247. package/dist/project/rollback-policy.js +1 -290
  248. package/dist/project/semantic-assembler.js +1 -345
  249. package/dist/project/semantic-graph.js +1 -292
  250. package/dist/project/stage-gate.js +1 -369
  251. package/dist/project/substep-trace.js +1 -332
  252. package/dist/project/task-tracker.js +1 -78
  253. package/dist/role/derivation.d.ts +18 -0
  254. package/dist/role/derivation.js +1 -0
  255. package/dist/role/index.d.ts +5 -0
  256. package/dist/role/index.js +1 -0
  257. package/dist/role/model.d.ts +8 -0
  258. package/dist/role/model.js +1 -0
  259. package/dist/role/resolution.d.ts +11 -0
  260. package/dist/role/resolution.js +1 -0
  261. package/dist/role/types.d.ts +11 -0
  262. package/dist/role/types.js +1 -0
  263. package/dist/rules.js +1 -52
  264. package/dist/safety/confirm-gate.js +1 -88
  265. package/dist/safety/index.js +1 -3
  266. package/dist/safety/preview.js +1 -52
  267. package/dist/schema/call/allocation.js +1 -34
  268. package/dist/schema/call/arbitration.js +1 -113
  269. package/dist/schema/call/base.d.ts +15 -15
  270. package/dist/schema/call/base.js +1 -370
  271. package/dist/schema/call/bridge-handler.js +1 -265
  272. package/dist/schema/call/bridge.d.ts +7 -7
  273. package/dist/schema/call/bridge.js +1 -458
  274. package/dist/schema/call/contact.js +1 -37
  275. package/dist/schema/call/demand.js +1 -47
  276. package/dist/schema/call/guard.js +1 -161
  277. package/dist/schema/call/handler.js +1 -322
  278. package/dist/schema/call/index.js +1 -20
  279. package/dist/schema/call/machine.js +1 -193
  280. package/dist/schema/call/order.js +1 -35
  281. package/dist/schema/call/payment.js +1 -37
  282. package/dist/schema/call/permission-handler.js +1 -54
  283. package/dist/schema/call/permission.js +1 -105
  284. package/dist/schema/call/personal.js +1 -78
  285. package/dist/schema/call/progress.js +1 -47
  286. package/dist/schema/call/proof.js +1 -33
  287. package/dist/schema/call/repository.js +1 -77
  288. package/dist/schema/call/reward.js +1 -30
  289. package/dist/schema/call/semantic.js +1 -1679
  290. package/dist/schema/call/service.js +1 -184
  291. package/dist/schema/call/treasury.js +1 -71
  292. package/dist/schema/common/index.js +1 -407
  293. package/dist/schema/config/index.js +1 -68
  294. package/dist/schema/evaluation/index.d.ts +213 -16
  295. package/dist/schema/evaluation/index.js +1 -356
  296. package/dist/schema/index.js +1 -17
  297. package/dist/schema/intent-radar/index.d.ts +13 -13
  298. package/dist/schema/intent-radar/index.js +1 -89
  299. package/dist/schema/local/index.d.ts +21 -21
  300. package/dist/schema/local/index.js +1 -927
  301. package/dist/schema/local/wip.js +1 -187
  302. package/dist/schema/messenger/index.d.ts +7 -7
  303. package/dist/schema/messenger/index.js +1 -475
  304. package/dist/schema/operations.d.ts +7 -7
  305. package/dist/schema/operations.js +1 -520
  306. package/dist/schema/persona/index.d.ts +54 -54
  307. package/dist/schema/persona/index.js +1 -148
  308. package/dist/schema/project/index.d.ts +94 -48
  309. package/dist/schema/project/index.js +1 -2057
  310. package/dist/schema/query/index.d.ts +423 -7
  311. package/dist/schema/query/index.js +1 -1646
  312. package/dist/schema/schema-query/index.js +1 -104
  313. package/dist/schema/schema-version.js +1 -76
  314. package/dist/schema/sync-layer4.js +1 -286
  315. package/dist/schema/task-status.js +1 -36
  316. package/dist/schema/trust/index.js +1 -314
  317. package/dist/schema/utils/guard-parser.js +1 -419
  318. package/dist/schema/utils/guard-query-utils.js +1 -46
  319. package/dist/schema/utils/node-parser.js +1 -369
  320. package/dist/schema/utils/object-type-utils.js +1 -35
  321. package/dist/schema/utils/permission-index-utils.js +1 -7
  322. package/dist/schema/utils/permission-machine-check.js +1 -121
  323. package/dist/schema/utils/skills-recommendation.js +1 -77
  324. package/dist/schema-query/index.js +1 -810
  325. package/dist/schemas/account_operation.output.json +5 -2
  326. package/dist/schemas/bridge_operation.output.json +5 -2
  327. package/dist/schemas/evaluation_operation.output.json +112 -7
  328. package/dist/schemas/evaluation_operation.schema.json +93 -6
  329. package/dist/schemas/index.json +1 -1
  330. package/dist/schemas/intent_radar.output.json +4 -1
  331. package/dist/schemas/intent_radar.schema.json +4 -1
  332. package/dist/schemas/local_info_operation.output.json +5 -2
  333. package/dist/schemas/local_mark_operation.output.json +5 -2
  334. package/dist/schemas/messenger_operation.output.json +5 -2
  335. package/dist/schemas/onchain_events.output.json +5 -2
  336. package/dist/schemas/onchain_operations.output.json +5 -2
  337. package/dist/schemas/onchain_operations.schema.json +4 -4
  338. package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
  339. package/dist/schemas/onchain_operations_machine.schema.json +2 -2
  340. package/dist/schemas/onchain_operations_service.schema.json +1 -1
  341. package/dist/schemas/onchain_table_data.output.json +6 -3
  342. package/dist/schemas/persona_operation.output.json +4 -1
  343. package/dist/schemas/persona_operation.schema.json +4 -1
  344. package/dist/schemas/project_operation.output.json +28 -8
  345. package/dist/schemas/query_toolkit.output.json +8 -5
  346. package/dist/schemas/wowok_buildin_info.output.json +132 -0
  347. package/dist/schemas/wowok_buildin_info.schema.json +14 -0
  348. package/dist/telemetry/index.js +1 -112
  349. package/dist/telemetry/redact.js +1 -23
  350. package/dist/telemetry/storage.js +1 -80
  351. package/dist/tools/handlers/bridge.js +1 -1
  352. package/dist/tools/handlers/config.js +1 -74
  353. package/dist/tools/handlers/evaluation.js +1 -123
  354. package/dist/tools/handlers/file-export.js +1 -90
  355. package/dist/tools/handlers/intent-radar.js +1 -76
  356. package/dist/tools/handlers/local.js +1 -53
  357. package/dist/tools/handlers/messenger.js +1 -188
  358. package/dist/tools/handlers/onchain.js +1 -1180
  359. package/dist/tools/handlers/persona.js +1 -89
  360. package/dist/tools/handlers/project.js +1 -211
  361. package/dist/tools/handlers/query.js +1 -434
  362. package/dist/tools/handlers/schema-query.js +1 -176
  363. package/dist/tools/handlers/task-status.js +1 -26
  364. package/dist/tools/handlers/trust.js +1 -380
  365. package/dist/tools/handlers/wip.js +1 -90
  366. package/dist/tools/index.js +1 -1382
  367. package/dist/tools/retry.js +1 -85
  368. package/dist/tools/rules-hook.js +1 -23
  369. package/dist/tools/shared.js +1 -130
  370. package/dist/tools/types.js +1 -1
  371. package/dist/tools/upgrade-check.d.ts +19 -0
  372. package/dist/tools/upgrade-check.js +1 -0
  373. package/dist/tools/wip-deploy-assist.js +1 -306
  374. package/dist/tools/wrap.js +1 -500
  375. package/package.json +4 -2
@@ -1,123 +1 @@
1
- import { strictParse } from "../../schema/index.js";
2
- import { EvaluationOperationInputSchema } from "../../schema/evaluation/index.js";
3
- import { evaluateArbGame } from "../../evaluation/arbitration-game.js";
4
- import { evaluateNodeGame } from "../../evaluation/node-game.js";
5
- import { summarizeCapabilityGaps } from "../../evaluation/gap.js";
6
- import { composeServicesForDemand } from "../../evaluation/composer.js";
7
- import { matchDemandToServices, matchServiceToDemands } from "../../evaluation/builtins/demand-match.js";
8
- import { assessServiceRisk } from "../../evaluation/builtins/service-risk.js";
9
- import { registerBuiltinEvaluations } from "../../evaluation/builtins/index.js";
10
- import { getEffectivePersona, mergeInjections, personaToInjection } from "../../persona/index.js";
11
- registerBuiltinEvaluations();
12
- function capabilityFromInput(input) {
13
- return {
14
- id: input.id,
15
- kind: input.kind,
16
- owner: input.owner ?? "",
17
- industry: input.industry,
18
- industry_confidence: input.industry_confidence ?? 0,
19
- region: input.region,
20
- price_min: input.price_min !== undefined ? BigInt(input.price_min) : undefined,
21
- price_max: input.price_max !== undefined ? BigInt(input.price_max) : undefined,
22
- token_type: input.token_type ?? "",
23
- ticket_size: input.ticket_size ?? "medium",
24
- trust_score: input.trust_score ?? 50,
25
- reputation_like_ratio: input.reputation_like_ratio ?? 1,
26
- arbitration_independent: input.arbitration_independent ?? false,
27
- merchant_history_count: input.merchant_history_count ?? 0,
28
- capabilities: input.capabilities,
29
- tags: input.tags ?? [],
30
- keywords: input.keywords ?? [],
31
- };
32
- }
33
- function puzzleRawFromInput(input) {
34
- return {
35
- service: {
36
- ...input.service,
37
- priceRaw: input.service.priceRaw !== undefined ? BigInt(input.service.priceRaw) : undefined,
38
- compensation_fund: input.service.compensation_fund
39
- ? { balance: input.service.compensation_fund.balance !== undefined ? BigInt(input.service.compensation_fund.balance) : undefined }
40
- : undefined,
41
- },
42
- machine_nodes: input.machine_nodes,
43
- machine_published: input.machine_published,
44
- machine_paused: input.machine_paused,
45
- reviews: input.reviews,
46
- events: input.events,
47
- similar_services: input.similar_services?.map((s) => ({ price: BigInt(s.price) })),
48
- order_amount: input.order_amount !== undefined ? BigInt(input.order_amount) : undefined,
49
- trust_score: input.trust_score,
50
- arbitration_owner: input.arbitration_owner,
51
- service_owner: input.service_owner,
52
- wip_verified: input.wip_verified,
53
- order_history: input.order_history,
54
- merchant_reputation: input.merchant_reputation,
55
- };
56
- }
57
- async function resolveInjection(account, explicit) {
58
- const base = account ? personaToInjection(await getEffectivePersona(account)) : undefined;
59
- return mergeInjections(base, explicit);
60
- }
61
- export async function handleEvaluationOperation(args) {
62
- const validated = strictParse(EvaluationOperationInputSchema, args, "evaluation_operation input");
63
- let result;
64
- switch (validated.action) {
65
- case "arb_game": {
66
- result = { action: "arb_game", ...evaluateArbGame(validated.status, validated.perspective) };
67
- break;
68
- }
69
- case "node_game": {
70
- result = {
71
- action: "node_game",
72
- ...evaluateNodeGame({
73
- current_node: validated.current_node,
74
- perspective: validated.perspective,
75
- operable: validated.operable,
76
- waiting_on: validated.waiting_on ?? [],
77
- }),
78
- };
79
- break;
80
- }
81
- case "capability_gap": {
82
- result = {
83
- action: "capability_gap",
84
- report: summarizeCapabilityGaps(capabilityFromInput(validated.demand), capabilityFromInput(validated.service)),
85
- };
86
- break;
87
- }
88
- case "compose_service": {
89
- result = {
90
- action: "compose_service",
91
- plan: composeServicesForDemand(capabilityFromInput(validated.demand), validated.services.map(capabilityFromInput)),
92
- };
93
- break;
94
- }
95
- case "demand_match": {
96
- result = {
97
- action: "demand_match",
98
- matches: await matchDemandToServices(capabilityFromInput(validated.demand_cap), validated.services, await resolveInjection(validated.account, validated.injection)),
99
- };
100
- break;
101
- }
102
- case "service_match": {
103
- result = {
104
- action: "service_match",
105
- matches: await matchServiceToDemands(capabilityFromInput(validated.service_cap), validated.demands, await resolveInjection(validated.account, validated.injection)),
106
- };
107
- break;
108
- }
109
- case "service_risk": {
110
- result = {
111
- action: "service_risk",
112
- result: await assessServiceRisk(validated.service_id, puzzleRawFromInput(validated.puzzle_raw), await resolveInjection(validated.account, validated.injection), validated.depth ?? "preorder"),
113
- };
114
- break;
115
- }
116
- default:
117
- throw new Error("Unknown evaluation_operation action");
118
- }
119
- return {
120
- content: [{ type: "text", text: JSON.stringify({ result }) }],
121
- structuredContent: { result },
122
- };
123
- }
1
+ import{strictParse}from'../../schema/index.js';import{EvaluationOperationInputSchema}from'../../schema/evaluation/index.js';import{evaluateArbGame}from'../../evaluation/arbitration-game.js';import{evaluateNodeGame}from'../../evaluation/node-game.js';import{summarizeCapabilityGaps}from'../../evaluation/gap.js';import{composeServicesForDemand}from'../../evaluation/composer.js';import{matchDemandToServices,matchServiceToDemands}from'../../evaluation/builtins/demand-match.js';import{assessServiceRisk}from'../../evaluation/builtins/service-risk.js';import{registerBuiltinEvaluations}from'../../evaluation/builtins/index.js';import{getEffectivePersona,mergeInjections,personaToInjection}from'../../persona/index.js';registerBuiltinEvaluations();function capabilityFromInput(a){return{'id':a['id'],'kind':a['kind'],'owner':a['owner']??'','industry':a['industry'],'industry_confidence':a['industry_confidence']??0x0,'region':a['region'],'price_min':a['price_min']!==undefined?BigInt(a['price_min']):undefined,'price_max':a['price_max']!==undefined?BigInt(a['price_max']):undefined,'token_type':a['token_type']??'','ticket_size':a['ticket_size']??'medium','trust_score':a['trust_score']??0x32,'reputation_like_ratio':a['reputation_like_ratio']??0x1,'arbitration_independent':a['arbitration_independent']??![],'merchant_history_count':a['merchant_history_count']??0x0,'capabilities':a['capabilities'],'tags':a['tags']??[],'keywords':a['keywords']??[]};}function puzzleRawFromInput(a){return{'service':{...a['service'],'priceRaw':a['service']['priceRaw']!==undefined?BigInt(a['service']['priceRaw']):undefined,'compensation_fund':a['service']['compensation_fund']?{'balance':a['service']['compensation_fund']['balance']!==undefined?BigInt(a['service']['compensation_fund']['balance']):undefined}:undefined},'machine_nodes':a['machine_nodes'],'machine_published':a['machine_published'],'machine_paused':a['machine_paused'],'reviews':a['reviews'],'events':a['events'],'similar_services':a['similar_services']?.['map'](b=>({'price':BigInt(b['price'])})),'order_amount':a['order_amount']!==undefined?BigInt(a['order_amount']):undefined,'trust_score':a['trust_score'],'arbitration_owner':a['arbitration_owner'],'service_owner':a['service_owner'],'wip_verified':a['wip_verified'],'order_history':a['order_history'],'merchant_reputation':a['merchant_reputation']};}async function resolveInjection(a,b){const c=a?personaToInjection(await getEffectivePersona(a)):undefined;return mergeInjections(c,b);}export async function handleEvaluationOperation(a){const b=strictParse(EvaluationOperationInputSchema,a,'evaluation_operation\x20input');let c;switch(b['action']){case'arb_game':{const d=b['account']?await getEffectivePersona(b['account']):null,e=b['appetite']??d?.['layer']['preferences']?.['risk_appetite'],f=b['requirements']??d?.['layer']['requirements'];c={'action':'arb_game',...evaluateArbGame(b['status'],b['perspective'],{'risk_appetite':e,'requirements':f})};break;}case'node_game':{const g=b['account']?await getEffectivePersona(b['account']):null,h=b['appetite']??g?.['layer']['preferences']?.['risk_appetite'],i=b['requirements']??g?.['layer']['requirements'];c={'action':'node_game',...evaluateNodeGame({'current_node':b['current_node'],'perspective':b['perspective'],'appetite':h,'requirements':i,'threshold':b['threshold'],'allocation':b['allocation'],'order_amount':b['order_amount'],'compensation_fund':b['compensation_fund'],'operable':b['operable'],'waiting_on':b['waiting_on']??[]})};break;}case'capability_gap':{c={'action':'capability_gap','report':summarizeCapabilityGaps(capabilityFromInput(b['demand']),capabilityFromInput(b['service']))};break;}case'compose_service':{c={'action':'compose_service','plan':composeServicesForDemand(capabilityFromInput(b['demand']),b['services']['map'](capabilityFromInput))};break;}case'demand_match':{c={'action':'demand_match','matches':await matchDemandToServices(capabilityFromInput(b['demand_cap']),b['services'],await resolveInjection(b['account'],b['injection']))};break;}case'service_match':{c={'action':'service_match','matches':await matchServiceToDemands(capabilityFromInput(b['service_cap']),b['demands'],await resolveInjection(b['account'],b['injection']))};break;}case'service_risk':{c={'action':'service_risk','result':await assessServiceRisk(b['service_id'],puzzleRawFromInput(b['puzzle_raw']),await resolveInjection(b['account'],b['injection']),b['depth']??'preorder')};break;}default:throw new Error('Unknown\x20evaluation_operation\x20action');}return{'content':[{'type':'text','text':JSON['stringify']({'result':c})}],'structuredContent':{'result':c}};}
@@ -1,90 +1 @@
1
- import { resolve } from "path";
2
- import { strictParse, getEnvConfig, Guard2File_InputSchema, MachineNode2File_InputSchema, } from "../../schema/index.js";
3
- import { guard2file, machineNode2file, } from "@wowok/wowok";
4
- export async function handleGuard2File(args) {
5
- const validated = strictParse(Guard2File_InputSchema, args, "guard2file input");
6
- const env = getEnvConfig(validated.env);
7
- try {
8
- await guard2file(validated.guard, validated.file_path, validated.format || "json", env.network);
9
- const result = {
10
- result: {
11
- status: "success",
12
- data: {
13
- file_path: resolve(validated.file_path),
14
- format: validated.format || "json",
15
- guard_object: validated.guard,
16
- },
17
- },
18
- };
19
- return {
20
- content: [{ type: "text", text: JSON.stringify(result) }],
21
- structuredContent: result,
22
- };
23
- }
24
- catch (error) {
25
- const result = {
26
- result: {
27
- status: "error",
28
- error: error.message,
29
- },
30
- };
31
- return {
32
- content: [{ type: "text", text: JSON.stringify(result) }],
33
- structuredContent: result,
34
- };
35
- }
36
- }
37
- export async function handleMachineNode2File(args) {
38
- const validated = strictParse(MachineNode2File_InputSchema, args, "machineNode2file input");
39
- const env = getEnvConfig(validated.env);
40
- try {
41
- await machineNode2file(validated.machine, validated.file_path, validated.format || "json", env.network);
42
- let node_count = undefined;
43
- try {
44
- const filePath = resolve(validated.file_path);
45
- const fileContent = await import('fs/promises').then(fs => fs.readFile(filePath, 'utf-8'));
46
- if ((validated.format || "json") === "json") {
47
- const parsed = JSON.parse(fileContent);
48
- if (Array.isArray(parsed)) {
49
- node_count = parsed.length;
50
- }
51
- }
52
- else {
53
- const nodeMatches = fileContent.match(/^##\s+Node:/gm);
54
- node_count = nodeMatches ? nodeMatches.length : 0;
55
- }
56
- }
57
- catch {
58
- node_count = undefined;
59
- }
60
- const result = {
61
- result: {
62
- status: "success",
63
- data: {
64
- file_path: resolve(validated.file_path),
65
- format: validated.format || "json",
66
- machine_object: validated.machine,
67
- },
68
- },
69
- };
70
- if (node_count !== undefined) {
71
- result.result.data.node_count = node_count;
72
- }
73
- return {
74
- content: [{ type: "text", text: JSON.stringify(result) }],
75
- structuredContent: result,
76
- };
77
- }
78
- catch (error) {
79
- const result = {
80
- result: {
81
- status: "error",
82
- error: error.message,
83
- },
84
- };
85
- return {
86
- content: [{ type: "text", text: JSON.stringify(result) }],
87
- structuredContent: result,
88
- };
89
- }
90
- }
1
+ import{resolve}from'path';import{strictParse,getEnvConfig,Guard2File_InputSchema,MachineNode2File_InputSchema}from'../../schema/index.js';import{guard2file,machineNode2file}from'@wowok/wowok';export async function handleGuard2File(a){const b=strictParse(Guard2File_InputSchema,a,'guard2file\x20input'),c=getEnvConfig(b['env']);try{await guard2file(b['guard'],b['file_path'],b['format']||'json',c['network']);const d={'result':{'status':'success','data':{'file_path':resolve(b['file_path']),'format':b['format']||'json','guard_object':b['guard']}}};return{'content':[{'type':'text','text':JSON['stringify'](d)}],'structuredContent':d};}catch(e){const f={'result':{'status':'error','error':e['message']}};return{'content':[{'type':'text','text':JSON['stringify'](f)}],'structuredContent':f};}}export async function handleMachineNode2File(a){const b=strictParse(MachineNode2File_InputSchema,a,'machineNode2file\x20input'),c=getEnvConfig(b['env']);try{await machineNode2file(b['machine'],b['file_path'],b['format']||'json',c['network']);let d=undefined;try{const f=resolve(b['file_path']),g=await import('fs/promises')['then'](h=>h['readFile'](f,'utf-8'));if((b['format']||'json')==='json'){const h=JSON['parse'](g);Array['isArray'](h)&&(d=h['length']);}else{const i=g['match'](/^##\s+Node:/gm);d=i?i['length']:0x0;}}catch{d=undefined;}const e={'result':{'status':'success','data':{'file_path':resolve(b['file_path']),'format':b['format']||'json','machine_object':b['machine']}}};return d!==undefined&&(e['result']['data']['node_count']=d),{'content':[{'type':'text','text':JSON['stringify'](e)}],'structuredContent':e};}catch(j){const k={'result':{'status':'error','error':j['message']}};return{'content':[{'type':'text','text':JSON['stringify'](k)}],'structuredContent':k};}}
@@ -1,76 +1 @@
1
- import { strictParse } from "../../schema/index.js";
2
- import { IntentRadarInputSchema } from "../../schema/intent-radar/index.js";
3
- import { createIntent, listIntents, matchAllIntents, matchIntent, removeIntent, } from "../../intent/index.js";
4
- import { enrichEventsWithObjectText } from "../../intent/enrich.js";
5
- import { query_events } from "@wowok/wowok";
6
- const AUTO_PULL_TYPES = [
7
- "NewOrderEvent",
8
- "DemandPresentEvent",
9
- "DemandFeedbackEvent",
10
- "ProgressEvent",
11
- "NewEntityEvent",
12
- "ArbEvent",
13
- ];
14
- async function pullRecentEvents(network, limit) {
15
- const all = [];
16
- for (const type of AUTO_PULL_TYPES) {
17
- try {
18
- const res = await query_events({
19
- type,
20
- cursor: null,
21
- limit,
22
- order: "descending",
23
- no_cache: false,
24
- network: network,
25
- });
26
- const data = res?.data;
27
- if (Array.isArray(data))
28
- all.push(...data);
29
- }
30
- catch {
31
- }
32
- }
33
- return all;
34
- }
35
- export async function handleIntentRadar(args) {
36
- const validated = strictParse(IntentRadarInputSchema, args, "intent_radar input");
37
- let result;
38
- switch (validated.action) {
39
- case "save": {
40
- const intent = await createIntent({
41
- intent: validated.intent,
42
- account: validated.account,
43
- role: validated.role,
44
- target_types: validated.target_types,
45
- });
46
- result = { action: "save", intent };
47
- break;
48
- }
49
- case "list": {
50
- result = { action: "list", intents: await listIntents(validated.account) };
51
- break;
52
- }
53
- case "remove": {
54
- result = { action: "remove", removed: await removeIntent(validated.id) };
55
- break;
56
- }
57
- case "match": {
58
- let events = validated.events ?? [];
59
- if (events.length === 0) {
60
- events = await pullRecentEvents(validated.network, validated.limit ?? 5);
61
- }
62
- events = await enrichEventsWithObjectText(events, validated.network);
63
- const results = validated.intent_id
64
- ? [await matchIntent(validated.intent_id, events)].filter((r) => r !== null)
65
- : await matchAllIntents(events, validated.account);
66
- result = { action: "match", results };
67
- break;
68
- }
69
- default:
70
- throw new Error("Unknown intent_radar action");
71
- }
72
- return {
73
- content: [{ type: "text", text: JSON.stringify({ result }) }],
74
- structuredContent: { result },
75
- };
76
- }
1
+ import{strictParse}from'../../schema/index.js';import{IntentRadarInputSchema}from'../../schema/intent-radar/index.js';import{createIntent,listIntents,matchAllIntents,matchIntent,removeIntent}from'../../intent/index.js';import{enrichEventsWithObjectText}from'../../intent/enrich.js';import{query_events}from'@wowok/wowok';const AUTO_PULL_TYPES=['NewOrderEvent','DemandPresentEvent','DemandFeedbackEvent','ProgressEvent','NewEntityEvent','ArbEvent'];async function pullRecentEvents(a,b){const c=[];for(const d of AUTO_PULL_TYPES){try{const e=await query_events({'type':d,'cursor':null,'limit':b,'order':'descending','no_cache':![],'network':a}),f=e?.['data'];if(Array['isArray'](f))c['push'](...f);}catch{}}return c;}export async function handleIntentRadar(a){const b=strictParse(IntentRadarInputSchema,a,'intent_radar\x20input');let c;switch(b['action']){case'save':{const d=await createIntent({'intent':b['intent'],'account':b['account'],'role':b['role'],'target_types':b['target_types']});c={'action':'save','intent':d};break;}case'list':{c={'action':'list','intents':await listIntents(b['account'])};break;}case'remove':{c={'action':'remove','removed':await removeIntent(b['id'])};break;}case'match':{let e=b['events']??[];e['length']===0x0&&(e=await pullRecentEvents(b['network'],b['limit']??0x5));e=await enrichEventsWithObjectText(e,b['network']);const f=b['intent_id']?[await matchIntent(b['intent_id'],e)]['filter'](g=>g!==null):await matchAllIntents(e,b['account']);c={'action':'match','results':f};break;}default:throw new Error('Unknown\x20intent_radar\x20action');}return{'content':[{'type':'text','text':JSON['stringify']({'result':c})}],'structuredContent':{'result':c}};}
@@ -1,53 +1 @@
1
- import { wrapLocalHandler } from "../shared.js";
2
- import { withFaucetRetry } from "../retry.js";
3
- import { AccountOperationSchema, LocalMarkOperationSchema, LocalInfoOperationSchema, } from "../../schema/index.js";
4
- import { account_operation, local_mark_operation, local_info_operation, } from "@wowok/wowok";
5
- function deriveOpType(prefix, validated) {
6
- for (const key of Object.keys(validated)) {
7
- if (validated[key] !== undefined) {
8
- return `${prefix}_${String(key)}`;
9
- }
10
- }
11
- return `${prefix}_unknown`;
12
- }
13
- export const handleAccountOperation = wrapLocalHandler({
14
- schema: AccountOperationSchema,
15
- operationFn: withFaucetRetry(account_operation),
16
- parseLabel: "account_operation input",
17
- buildContext: (validated) => ({
18
- operation_type: deriveOpType("account", validated),
19
- data: validated,
20
- }),
21
- });
22
- export const handleMarkOperation = wrapLocalHandler({
23
- schema: LocalMarkOperationSchema,
24
- operationFn: local_mark_operation,
25
- parseLabel: "local_mark_operation input",
26
- buildContext: (validated) => {
27
- const ctx = {
28
- operation_type: deriveOpType("mark", validated),
29
- data: validated,
30
- };
31
- const v = validated;
32
- if (v.add && Array.isArray(v.add.data) && v.add.data.length > 0) {
33
- ctx.pre_warnings = [
34
- "Cross-network consistency (FIX-011): LocalMark names are scoped per network. " +
35
- "When creating marks for the same logical object on different networks " +
36
- "(e.g. testnet and mainnet), use the SAME name value to keep name-based " +
37
- "references portable. Before creating a mark on mainnet, consider querying " +
38
- "testnet via query_local with network='testnet' to check for an existing " +
39
- "same-named mark and replicate it.",
40
- ];
41
- }
42
- return ctx;
43
- },
44
- });
45
- export const handleInfoOperation = wrapLocalHandler({
46
- schema: LocalInfoOperationSchema,
47
- operationFn: local_info_operation,
48
- parseLabel: "local_info_operation input",
49
- buildContext: (validated) => ({
50
- operation_type: deriveOpType("local_info", validated),
51
- data: validated,
52
- }),
53
- });
1
+ import{wrapLocalHandler}from'../shared.js';import{withFaucetRetry}from'../retry.js';import{AccountOperationSchema,LocalMarkOperationSchema,LocalInfoOperationSchema}from'../../schema/index.js';import{account_operation,local_mark_operation,local_info_operation}from'@wowok/wowok';function deriveOpType(a,b){for(const c of Object['keys'](b)){if(b[c]!==undefined)return a+'_'+String(c);}return a+'_unknown';}export const handleAccountOperation=wrapLocalHandler({'schema':AccountOperationSchema,'operationFn':withFaucetRetry(account_operation),'parseLabel':'account_operation\x20input','buildContext':a=>({'operation_type':deriveOpType('account',a),'data':a})});export const handleMarkOperation=wrapLocalHandler({'schema':LocalMarkOperationSchema,'operationFn':local_mark_operation,'parseLabel':'local_mark_operation\x20input','buildContext':a=>{const b={'operation_type':deriveOpType('mark',a),'data':a},c=a;return c['add']&&Array['isArray'](c['add']['data'])&&c['add']['data']['length']>0x0&&(b['pre_warnings']=['Cross-network\x20consistency\x20(FIX-011):\x20LocalMark\x20names\x20are\x20scoped\x20per\x20network.\x20'+'When\x20creating\x20marks\x20for\x20the\x20same\x20logical\x20object\x20on\x20different\x20networks\x20'+'(e.g.\x20testnet\x20and\x20mainnet),\x20use\x20the\x20SAME\x20name\x20value\x20to\x20keep\x20name-based\x20'+'references\x20portable.\x20Before\x20creating\x20a\x20mark\x20on\x20mainnet,\x20consider\x20querying\x20'+'testnet\x20via\x20query_local\x20with\x20network=\x27testnet\x27\x20to\x20check\x20for\x20an\x20existing\x20'+'same-named\x20mark\x20and\x20replicate\x20it.']),b;}});export const handleInfoOperation=wrapLocalHandler({'schema':LocalInfoOperationSchema,'operationFn':local_info_operation,'parseLabel':'local_info_operation\x20input','buildContext':a=>({'operation_type':deriveOpType('local_info',a),'data':a})});
@@ -1,188 +1 @@
1
- import { strictParse, MessengerOperationInputSchema, } from "../../schema/index.js";
2
- import { watch_conversations, send_message, send_file, watch_messages, extract_zip_messages, pull_messages, generate_wts, verify_wts, sign_wts, wts2html, proof_message, mark_messages_as_viewed, mark_conversation_as_viewed, blacklist, friendslist, guardlist, settings, } from "@wowok/wowok";
3
- import { classifyError, buildDataSemantic, } from "../../schema/call/semantic.js";
4
- export function normalizeAccountOrMark(input) {
5
- if (typeof input === 'string') {
6
- return { name_or_address: input, local_mark_first: true };
7
- }
8
- return input;
9
- }
10
- export function normalizeManyAccountOrMark(input) {
11
- if (Array.isArray(input)) {
12
- return {
13
- entities: input.map(item => typeof item === 'string' ? { name_or_address: item, local_mark_first: true } : item),
14
- check_all_founded: true,
15
- };
16
- }
17
- return input;
18
- }
19
- export async function handleMessengerOperation(args) {
20
- let validated;
21
- try {
22
- validated = strictParse(MessengerOperationInputSchema, args, "messenger_operation input");
23
- const opLiteral = validated.operation;
24
- let result;
25
- switch (validated.operation) {
26
- case "watch_conversations": {
27
- const conversations = await watch_conversations(validated.filter);
28
- result = { operation: "watch_conversations", result: conversations };
29
- break;
30
- }
31
- case "send_message": {
32
- const sendResult = await send_message(validated.from, normalizeAccountOrMark(validated.to), validated.content, validated.options);
33
- const filteredResult = {
34
- ...sendResult,
35
- merkleData: sendResult.merkleData ? {
36
- leafIndex: sendResult.merkleData.leafIndex,
37
- prevRoot: sendResult.merkleData.prevRoot,
38
- newRoot: sendResult.merkleData.newRoot,
39
- serverSignature: sendResult.merkleData.serverSignature,
40
- serverTimestamp: sendResult.merkleData.serverTimestamp,
41
- serverPublicKey: sendResult.merkleData.serverPublicKey,
42
- } : undefined,
43
- };
44
- result = { operation: "send_message", result: filteredResult };
45
- break;
46
- }
47
- case "send_file": {
48
- const sendResult = await send_file(validated.from, normalizeAccountOrMark(validated.to), validated.filePath, validated.options);
49
- const filteredResult = {
50
- ...sendResult,
51
- merkleData: sendResult.merkleData ? {
52
- leafIndex: sendResult.merkleData.leafIndex,
53
- prevRoot: sendResult.merkleData.prevRoot,
54
- newRoot: sendResult.merkleData.newRoot,
55
- serverSignature: sendResult.merkleData.serverSignature,
56
- serverTimestamp: sendResult.merkleData.serverTimestamp,
57
- serverPublicKey: sendResult.merkleData.serverPublicKey,
58
- } : undefined,
59
- };
60
- result = { operation: "send_file", result: filteredResult };
61
- break;
62
- }
63
- case "watch_messages": {
64
- const filter = validated.filter ? {
65
- ...validated.filter,
66
- peerAddress: validated.filter.peerAddress ? normalizeAccountOrMark(validated.filter.peerAddress) : undefined,
67
- } : undefined;
68
- const messages = await watch_messages(filter);
69
- result = { operation: "watch_messages", result: messages };
70
- break;
71
- }
72
- case "extract_zip_messages": {
73
- const extractedPaths = await extract_zip_messages(validated.account, validated.messages, validated.outputDir);
74
- result = { operation: "extract_zip_messages", result: extractedPaths };
75
- break;
76
- }
77
- case "generate_wts": {
78
- const params = validated.params ? {
79
- ...validated.params,
80
- peerAccount: normalizeAccountOrMark(validated.params.peerAccount),
81
- } : undefined;
82
- const wtsResult = await generate_wts(params);
83
- result = { operation: "generate_wts", result: wtsResult };
84
- break;
85
- }
86
- case "verify_wts": {
87
- const verifyResult = await verify_wts(validated.wtsFilePath);
88
- result = { operation: "verify_wts", result: verifyResult };
89
- break;
90
- }
91
- case "sign_wts": {
92
- const signedPath = await sign_wts(validated.wtsFilePath, validated.account, validated.outputPath);
93
- result = { operation: "sign_wts", result: signedPath };
94
- break;
95
- }
96
- case "wts2html": {
97
- const htmlResult = await wts2html(validated.wtsPath, validated.options);
98
- result = { operation: "wts2html", result: htmlResult };
99
- break;
100
- }
101
- case "proof_message": {
102
- const proofResult = await proof_message(validated.account, validated.messageId, validated.network);
103
- result = { operation: "proof_message", result: proofResult };
104
- break;
105
- }
106
- case "blacklist": {
107
- const blacklistParams = {
108
- account: validated.account,
109
- op: validated.blacklist.op,
110
- };
111
- if ('users' in validated.blacklist) {
112
- blacklistParams.users = normalizeManyAccountOrMark(validated.blacklist.users);
113
- }
114
- const blacklistResult = await blacklist(blacklistParams);
115
- result = { operation: "blacklist", op: validated.blacklist.op, result: blacklistResult.result };
116
- break;
117
- }
118
- case "friendslist": {
119
- const friendslistParams = {
120
- account: validated.account,
121
- op: validated.friendslist.op,
122
- };
123
- if ('users' in validated.friendslist) {
124
- friendslistParams.users = normalizeManyAccountOrMark(validated.friendslist.users);
125
- }
126
- const friendslistResult = await friendslist(friendslistParams);
127
- result = { operation: "friendslist", op: validated.friendslist.op, result: friendslistResult.result };
128
- break;
129
- }
130
- case "guardlist": {
131
- const guardlistResult = await guardlist({
132
- account: validated.account,
133
- ...validated.guardlist,
134
- });
135
- result = { operation: "guardlist", op: validated.guardlist.op, result: guardlistResult.result };
136
- break;
137
- }
138
- case "settings": {
139
- const settingsResult = await settings({
140
- account: validated.account,
141
- ...validated.settings,
142
- });
143
- result = { operation: "settings", op: validated.settings.op, result: settingsResult.result };
144
- break;
145
- }
146
- case "mark_messages_as_viewed": {
147
- const markedCount = await mark_messages_as_viewed(validated.messageIds, validated.account);
148
- result = { operation: "mark_messages_as_viewed", result: markedCount };
149
- break;
150
- }
151
- case "mark_conversation_as_viewed": {
152
- const markedCount = await mark_conversation_as_viewed(normalizeAccountOrMark(validated.peerAddress), validated.account);
153
- result = { operation: "mark_conversation_as_viewed", result: markedCount };
154
- break;
155
- }
156
- case "pull_messages": {
157
- const messages = await pull_messages(validated.account, validated.limit);
158
- result = { operation: "pull_messages", result: messages };
159
- break;
160
- }
161
- default:
162
- throw new Error(`Unknown messenger operation: ${opLiteral}`);
163
- }
164
- return {
165
- content: [{ type: "text", text: JSON.stringify(result) }],
166
- structuredContent: { result },
167
- };
168
- }
169
- catch (error) {
170
- const errorMessage = error instanceof Error ? error.message : String(error);
171
- const ctx = validated ? { operation_type: "messenger_" + validated.operation, data: validated } : undefined;
172
- const classified = classifyError(errorMessage);
173
- const errorResult = { operation: "error", error: errorMessage };
174
- if (classified.error_code !== undefined)
175
- errorResult.error_code = classified.error_code;
176
- if (classified.retryable !== undefined)
177
- errorResult.retryable = classified.retryable;
178
- if (classified.recovery_hint !== undefined)
179
- errorResult.recovery_hint = classified.recovery_hint;
180
- return {
181
- content: [{ type: "text", text: `Error: ${errorMessage}` }],
182
- structuredContent: {
183
- result: errorResult,
184
- semantic: buildDataSemantic(undefined, ctx, true, errorMessage),
185
- },
186
- };
187
- }
188
- }
1
+ import{strictParse,MessengerOperationInputSchema}from'../../schema/index.js';import{watch_conversations,send_message,send_file,watch_messages,extract_zip_messages,pull_messages,generate_wts,verify_wts,sign_wts,wts2html,proof_message,mark_messages_as_viewed,mark_conversation_as_viewed,blacklist,friendslist,guardlist,settings}from'@wowok/wowok';import{classifyError,buildDataSemantic}from'../../schema/call/semantic.js';export function normalizeAccountOrMark(a){if(typeof a==='string')return{'name_or_address':a,'local_mark_first':!![]};return a;}export function normalizeManyAccountOrMark(a){if(Array['isArray'](a))return{'entities':a['map'](b=>typeof b==='string'?{'name_or_address':b,'local_mark_first':!![]}:b),'check_all_founded':!![]};return a;}export async function handleMessengerOperation(a){let b;try{b=strictParse(MessengerOperationInputSchema,a,'messenger_operation\x20input');const c=b['operation'];let d;switch(b['operation']){case'watch_conversations':{const e=await watch_conversations(b['filter']);d={'operation':'watch_conversations','result':e};break;}case'send_message':{const f=await send_message(b['from'],normalizeAccountOrMark(b['to']),b['content'],b['options']),g={...f,'merkleData':f['merkleData']?{'leafIndex':f['merkleData']['leafIndex'],'prevRoot':f['merkleData']['prevRoot'],'newRoot':f['merkleData']['newRoot'],'serverSignature':f['merkleData']['serverSignature'],'serverTimestamp':f['merkleData']['serverTimestamp'],'serverPublicKey':f['merkleData']['serverPublicKey']}:undefined};d={'operation':'send_message','result':g};break;}case'send_file':{const h=await send_file(b['from'],normalizeAccountOrMark(b['to']),b['filePath'],b['options']),i={...h,'merkleData':h['merkleData']?{'leafIndex':h['merkleData']['leafIndex'],'prevRoot':h['merkleData']['prevRoot'],'newRoot':h['merkleData']['newRoot'],'serverSignature':h['merkleData']['serverSignature'],'serverTimestamp':h['merkleData']['serverTimestamp'],'serverPublicKey':h['merkleData']['serverPublicKey']}:undefined};d={'operation':'send_file','result':i};break;}case'watch_messages':{const j=b['filter']?{...b['filter'],'peerAddress':b['filter']['peerAddress']?normalizeAccountOrMark(b['filter']['peerAddress']):undefined}:undefined,k=await watch_messages(j);d={'operation':'watch_messages','result':k};break;}case'extract_zip_messages':{const l=await extract_zip_messages(b['account'],b['messages'],b['outputDir']);d={'operation':'extract_zip_messages','result':l};break;}case'generate_wts':{const m=b['params']?{...b['params'],'peerAccount':normalizeAccountOrMark(b['params']['peerAccount'])}:undefined,n=await generate_wts(m);d={'operation':'generate_wts','result':n};break;}case'verify_wts':{const o=await verify_wts(b['wtsFilePath']);d={'operation':'verify_wts','result':o};break;}case'sign_wts':{const p=await sign_wts(b['wtsFilePath'],b['account'],b['outputPath']);d={'operation':'sign_wts','result':p};break;}case'wts2html':{const q=await wts2html(b['wtsPath'],b['options']);d={'operation':'wts2html','result':q};break;}case'proof_message':{const r=await proof_message(b['account'],b['messageId'],b['network']);d={'operation':'proof_message','result':r};break;}case'blacklist':{const s={'account':b['account'],'op':b['blacklist']['op']};'users'in b['blacklist']&&(s['users']=normalizeManyAccountOrMark(b['blacklist']['users']));const t=await blacklist(s);d={'operation':'blacklist','op':b['blacklist']['op'],'result':t['result']};break;}case'friendslist':{const u={'account':b['account'],'op':b['friendslist']['op']};'users'in b['friendslist']&&(u['users']=normalizeManyAccountOrMark(b['friendslist']['users']));const v=await friendslist(u);d={'operation':'friendslist','op':b['friendslist']['op'],'result':v['result']};break;}case'guardlist':{const w=await guardlist({'account':b['account'],...b['guardlist']});d={'operation':'guardlist','op':b['guardlist']['op'],'result':w['result']};break;}case'settings':{const x=await settings({'account':b['account'],...b['settings']});d={'operation':'settings','op':b['settings']['op'],'result':x['result']};break;}case'mark_messages_as_viewed':{const y=await mark_messages_as_viewed(b['messageIds'],b['account']);d={'operation':'mark_messages_as_viewed','result':y};break;}case'mark_conversation_as_viewed':{const z=await mark_conversation_as_viewed(normalizeAccountOrMark(b['peerAddress']),b['account']);d={'operation':'mark_conversation_as_viewed','result':z};break;}case'pull_messages':{const A=await pull_messages(b['account'],b['limit']);d={'operation':'pull_messages','result':A};break;}default:throw new Error('Unknown\x20messenger\x20operation:\x20'+c);}return{'content':[{'type':'text','text':JSON['stringify'](d)}],'structuredContent':{'result':d}};}catch(B){const C=B instanceof Error?B['message']:String(B),D=b?{'operation_type':'messenger_'+b['operation'],'data':b}:undefined,E=classifyError(C),F={'operation':'error','error':C};if(E['error_code']!==undefined)F['error_code']=E['error_code'];if(E['retryable']!==undefined)F['retryable']=E['retryable'];if(E['recovery_hint']!==undefined)F['recovery_hint']=E['recovery_hint'];return{'content':[{'type':'text','text':'Error:\x20'+C}],'structuredContent':{'result':F,'semantic':buildDataSemantic(undefined,D,!![],C)}};}}