@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,26 +1 @@
1
- import { TaskTracker } from "../../project/task-tracker.js";
2
- export async function handleQueryTaskStatus(args) {
3
- const validated = (args && typeof args === "object" ? args : {});
4
- if (validated.task_id) {
5
- const task = TaskTracker.get(validated.task_id);
6
- const result = {
7
- task_id: validated.task_id,
8
- task: task ?? null,
9
- tasks: undefined,
10
- };
11
- return {
12
- content: [{ type: "text", text: JSON.stringify(result) }],
13
- structuredContent: result,
14
- };
15
- }
16
- const tasks = TaskTracker.list(validated.project_id).slice(0, 50);
17
- const result = {
18
- task_id: undefined,
19
- task: null,
20
- tasks,
21
- };
22
- return {
23
- content: [{ type: "text", text: JSON.stringify(result) }],
24
- structuredContent: result,
25
- };
26
- }
1
+ import{TaskTracker}from'../../project/task-tracker.js';export async function handleQueryTaskStatus(a){const b=a&&typeof a==='object'?a:{};if(b['task_id']){const e=TaskTracker['get'](b['task_id']),f={'task_id':b['task_id'],'task':e??null,'tasks':undefined};return{'content':[{'type':'text','text':JSON['stringify'](f)}],'structuredContent':f};}const c=TaskTracker['list'](b['project_id'])['slice'](0x0,0x32),d={'task_id':undefined,'task':null,'tasks':c};return{'content':[{'type':'text','text':JSON['stringify'](d)}],'structuredContent':d};}
@@ -1,380 +1 @@
1
- import { strictParse, TrustScoreInputSchema, } from "../../schema/index.js";
2
- import { query_objects, query_personal, } from "@wowok/wowok";
3
- import { computeServiceTrustScore, } from "../../knowledge/index.js";
4
- import { assembleInfoPuzzle, assemblePreorderAdvice, assessRisk, buildPreorderComparison, getDefaultPreferences, inferIndustry, mergePreferences, validatePreferences, } from "../../customer/index.js";
5
- import { getProfile } from "../../experience/user-profile.js";
6
- function extractTrustMetrics(serviceObj) {
7
- const data = serviceObj?.data ?? serviceObj ?? {};
8
- const sales = Array.isArray(data.sales) ? data.sales : [];
9
- const activeSales = sales.filter((s) => s && !s.suspension);
10
- void activeSales;
11
- const compensationFund = data.compensation_fund;
12
- const compBalance = (() => {
13
- if (compensationFund === null || compensationFund === undefined)
14
- return undefined;
15
- if (typeof compensationFund === "bigint")
16
- return compensationFund;
17
- if (typeof compensationFund === "number")
18
- return BigInt(compensationFund);
19
- if (typeof compensationFund === "string") {
20
- try {
21
- return BigInt(compensationFund);
22
- }
23
- catch {
24
- return undefined;
25
- }
26
- }
27
- if (typeof compensationFund === "object") {
28
- const bal = compensationFund.balance;
29
- if (bal === null || bal === undefined)
30
- return undefined;
31
- try {
32
- return BigInt(bal);
33
- }
34
- catch {
35
- return undefined;
36
- }
37
- }
38
- return undefined;
39
- })();
40
- return {
41
- arbitrationCases: Array.isArray(data.arbitrations) ? data.arbitrations.length : undefined,
42
- compensationFundBalance: compBalance,
43
- hasMachineBound: typeof data.machine === "string" && data.machine.length > 0,
44
- hasBuyGuard: typeof data.buy_guard === "string" && data.buy_guard.length > 0,
45
- };
46
- }
47
- function buildPuzzleRawData(serviceObj, orderAmount, trustScore, serviceOwner) {
48
- const data = serviceObj?.data ?? serviceObj ?? {};
49
- const sales = Array.isArray(data.sales) ? data.sales : [];
50
- const order_allocators = data.order_allocators
51
- ? Array.isArray(data.order_allocators.allocators)
52
- ? data.order_allocators
53
- : { allocators: data.order_allocators }
54
- : undefined;
55
- const serviceRaw = {
56
- name: data.name ?? serviceObj?.id,
57
- bPublished: data.bPublished,
58
- bPaused: data.bPaused,
59
- price: sales[0]?.price != null ? String(sales[0].price) : "0",
60
- priceRaw: sales[0]?.price != null ? BigInt(sales[0].price) : 0n,
61
- token_type: sales[0]?.price_type ?? (compensation_fund_token(data) ?? "0x2::wow::WOW"),
62
- sales,
63
- machine: data.machine ?? undefined,
64
- buy_guard: data.buy_guard ?? undefined,
65
- customer_required: data.customer_required,
66
- arbitrations: data.arbitrations,
67
- compensation_fund: data.compensation_fund
68
- ? { balance: extractBalance(data.compensation_fund) }
69
- : undefined,
70
- compensation_lock_duration: typeof data.setting_lock_duration === "number"
71
- ? data.setting_lock_duration
72
- : undefined,
73
- um: data.um ?? undefined,
74
- order_allocators: order_allocators ? [order_allocators] : undefined,
75
- };
76
- return {
77
- service: serviceRaw,
78
- order_amount: orderAmount,
79
- trust_score: trustScore,
80
- service_owner: serviceOwner,
81
- };
82
- }
83
- function compensation_fund_token(data) {
84
- if (data?.compensation_fund && typeof data.compensation_fund === "object") {
85
- return data.compensation_fund.token_type;
86
- }
87
- return undefined;
88
- }
89
- function extractBalance(b) {
90
- if (b === null || b === undefined)
91
- return 0n;
92
- if (typeof b === "bigint")
93
- return b;
94
- if (typeof b === "number")
95
- return BigInt(b);
96
- if (typeof b === "string") {
97
- try {
98
- return BigInt(b);
99
- }
100
- catch {
101
- return 0n;
102
- }
103
- }
104
- if (typeof b === "object") {
105
- const bal = b.balance;
106
- if (bal === null || bal === undefined)
107
- return 0n;
108
- try {
109
- return BigInt(bal);
110
- }
111
- catch {
112
- return 0n;
113
- }
114
- }
115
- return 0n;
116
- }
117
- function toUserMetricsConfig(input) {
118
- return {
119
- version: 1,
120
- metrics: input.metrics.map((m) => ({
121
- name: m.name,
122
- label: m.label,
123
- evaluator: m.evaluator,
124
- params: {
125
- ...m.params,
126
- threshold: m.params.threshold !== undefined ? String(m.params.threshold) : undefined,
127
- },
128
- weight: m.weight,
129
- advice_on_fail: m.advice_on_fail,
130
- advice_on_pass: m.advice_on_pass,
131
- })),
132
- adjustment_cap: input.adjustment_cap,
133
- };
134
- }
135
- function derivePreferences(validated, industry) {
136
- const profile = getProfile();
137
- const withProfile = mergePreferences(getDefaultPreferences(industry), {
138
- risk_appetite: profile.risk_appetite,
139
- min_trust_score: profile.risk_appetite === "conservative" ? 70
140
- : profile.risk_appetite === "aggressive" ? 30 : 50,
141
- });
142
- const manualInput = validated.preferences;
143
- const manual = manualInput
144
- ? {
145
- ...manualInput,
146
- budget_range: manualInput.budget_range
147
- ? {
148
- min: BigInt(manualInput.budget_range.min),
149
- max: BigInt(manualInput.budget_range.max),
150
- }
151
- : undefined,
152
- }
153
- : undefined;
154
- const prefs = manual ? mergePreferences(withProfile, manual) : withProfile;
155
- return { prefs, issues: validatePreferences(prefs) };
156
- }
157
- async function fetchMerchantReputation(permissionAddr, network, noCache) {
158
- try {
159
- if (typeof permissionAddr !== "string" || !permissionAddr.startsWith("0x")) {
160
- return undefined;
161
- }
162
- const permResult = await query_objects({
163
- objects: [permissionAddr],
164
- no_cache: noCache,
165
- network,
166
- });
167
- const permObj = permResult?.objects?.[0];
168
- const builder = (permObj?.data ?? permObj)?.builder;
169
- if (typeof builder !== "string" || !builder.startsWith("0x")) {
170
- return undefined;
171
- }
172
- const personal = await query_personal({
173
- account: builder,
174
- no_cache: noCache,
175
- network,
176
- });
177
- if (!personal)
178
- return undefined;
179
- return { likes: personal.like ?? 0, dislikes: personal.dislike ?? 0 };
180
- }
181
- catch {
182
- return undefined;
183
- }
184
- }
185
- async function runTrustEvaluation(validated) {
186
- const depth = (validated.depth ?? "evaluate");
187
- const queryResult = await query_objects({
188
- objects: [validated.service],
189
- no_cache: validated.no_cache,
190
- network: validated.network,
191
- });
192
- const objects = queryResult?.objects;
193
- if (!objects || !Array.isArray(objects) || objects.length === 0) {
194
- throw new Error(`Service object not found for '${validated.service}'. ` +
195
- `Verify the ID/name and network, or use query_toolkit with query_type='onchain_objects' to debug.`);
196
- }
197
- const serviceObj = objects[0];
198
- const objType = serviceObj?.data?.object_type ?? serviceObj?.object_type ?? serviceObj?.type;
199
- if (objType && typeof objType === "string" && !objType.includes("Service")) {
200
- throw new Error(`Object '${validated.service}' is not a Service (type: ${objType}). ` +
201
- `trust_score only evaluates Service objects.`);
202
- }
203
- const metrics = extractTrustMetrics(serviceObj);
204
- const trustScore = computeServiceTrustScore(metrics);
205
- const sales = Array.isArray(serviceObj?.data?.sales) ? serviceObj.data.sales : [];
206
- const activeSale = sales.find((s) => s && !s.suspension) ?? sales[0];
207
- const salePriceRaw = activeSale?.price != null ? BigInt(activeSale.price) : 0n;
208
- const orderAmount = validated.order_amount != null
209
- ? BigInt(validated.order_amount)
210
- : salePriceRaw;
211
- let riskScore;
212
- let infoPuzzle;
213
- let preorderAdvice;
214
- let preferenceIssues;
215
- if (depth === "evaluate" || depth === "preorder") {
216
- const puzzleRaw = buildPuzzleRawData(serviceObj, orderAmount, { score: trustScore.score, level: trustScore.level }, undefined);
217
- if (validated.user_metrics) {
218
- puzzleRaw.user_metrics_config = toUserMetricsConfig(validated.user_metrics);
219
- }
220
- if (depth === "preorder") {
221
- const reputation = await fetchMerchantReputation((serviceObj?.data ?? serviceObj)?.permission, validated.network, validated.no_cache);
222
- if (reputation)
223
- puzzleRaw.merchant_reputation = reputation;
224
- }
225
- infoPuzzle = assembleInfoPuzzle(validated.service, puzzleRaw, depth);
226
- riskScore = assessRisk(infoPuzzle);
227
- if (depth === "preorder") {
228
- const industry = validated.industry ?? inferIndustry(infoPuzzle);
229
- const { prefs, issues } = derivePreferences(validated, industry);
230
- preferenceIssues = issues.length > 0 ? issues : undefined;
231
- preorderAdvice = assemblePreorderAdvice({
232
- puzzle: infoPuzzle,
233
- risk: riskScore,
234
- preferences: prefs,
235
- industry,
236
- });
237
- }
238
- }
239
- return {
240
- serviceId: validated.service,
241
- serviceName: serviceObj?.data?.name ?? serviceObj?.name ?? validated.service,
242
- serviceObj,
243
- sales,
244
- trustScore,
245
- orderAmount,
246
- infoPuzzle,
247
- riskScore,
248
- preorderAdvice,
249
- preferenceIssues,
250
- };
251
- }
252
- export async function handleTrustScore(args) {
253
- const validated = strictParse(TrustScoreInputSchema, args, "trust_score input");
254
- const depth = (validated.depth ?? "evaluate");
255
- const core = await runTrustEvaluation(validated);
256
- const { serviceObj, sales, trustScore, orderAmount, infoPuzzle, riskScore, preorderAdvice, preferenceIssues } = core;
257
- const result = {
258
- service_id: validated.service,
259
- service_name: serviceObj?.data?.name ?? serviceObj?.name ?? validated.service,
260
- service_basics: {
261
- bPublished: serviceObj?.data?.bPublished ?? false,
262
- bPaused: serviceObj?.data?.bPaused ?? false,
263
- sales_count: sales.filter((s) => s && !s.suspension).length,
264
- has_machine: !!serviceObj?.data?.machine,
265
- has_buy_guard: !!serviceObj?.data?.buy_guard,
266
- has_um_contact: !!serviceObj?.data?.um,
267
- arbitrations_count: Array.isArray(serviceObj?.data?.arbitrations)
268
- ? serviceObj.data.arbitrations.length
269
- : 0,
270
- },
271
- trust_score: {
272
- score: trustScore.score,
273
- level: trustScore.level,
274
- summary: trustScore.summary,
275
- warnings: trustScore.warnings,
276
- breakdown: trustScore.breakdown,
277
- },
278
- order_amount: orderAmount.toString(),
279
- depth,
280
- ...(riskScore ? {
281
- risk_score: {
282
- total: riskScore.total,
283
- level: riskScore.level,
284
- red_flags: riskScore.red_flags,
285
- advice: riskScore.advice,
286
- dimensions: riskScore.dimensions,
287
- },
288
- } : {}),
289
- ...(infoPuzzle ? {
290
- info_puzzle: {
291
- completeness: infoPuzzle.completeness,
292
- gaps: infoPuzzle.gaps,
293
- assembled_at: infoPuzzle.assembled_at,
294
- },
295
- } : {}),
296
- ...(preorderAdvice ? {
297
- preorder_advice: {
298
- confidence: preorderAdvice.confidence,
299
- industry: preorderAdvice.industry,
300
- strategies: preorderAdvice.strategies.map((s) => ({
301
- scenario: s.scenario,
302
- merchant_tactic: s.strategy.merchant_tactic,
303
- user_strategy: s.strategy.user_strategy,
304
- nash_equilibrium: s.strategy.nash_equilibrium,
305
- confidence: s.confidence,
306
- fallback: s.fallback,
307
- rationale: s.rationale,
308
- })),
309
- ...(preorderAdvice.preference_match
310
- ? { preference_match: preorderAdvice.preference_match }
311
- : {}),
312
- ...(preferenceIssues ? { preference_issues: preferenceIssues } : {}),
313
- ...(preorderAdvice.industry_risks
314
- ? {
315
- industry_risks: {
316
- score_adjustment: preorderAdvice.industry_risks.score_adjustment,
317
- summary: preorderAdvice.industry_risks.summary,
318
- checks: preorderAdvice.industry_risks.checks,
319
- unmet_needs: preorderAdvice.industry_risks.unmet_needs.map((n) => ({
320
- id: n.id,
321
- tier: n.tier,
322
- description: n.description,
323
- advice: n.advice,
324
- })),
325
- },
326
- }
327
- : {}),
328
- reminders: preorderAdvice.reminders,
329
- blocking_reminders: preorderAdvice.blocking_reminders,
330
- summary: preorderAdvice.summary,
331
- },
332
- } : {}),
333
- };
334
- let comparison;
335
- if (depth === "preorder" && validated.compare_with && validated.compare_with.length > 0) {
336
- const rows = [coreToCompareRow(core)];
337
- for (const candidate of validated.compare_with) {
338
- try {
339
- const candidateCore = await runTrustEvaluation({
340
- ...validated,
341
- service: candidate,
342
- depth: "preorder",
343
- });
344
- rows.push(coreToCompareRow(candidateCore));
345
- }
346
- catch (e) {
347
- rows.push({
348
- service_id: candidate,
349
- service_name: candidate,
350
- error: e.message,
351
- });
352
- }
353
- }
354
- comparison = buildPreorderComparison(rows);
355
- }
356
- const finalResult = comparison ? { ...result, comparison } : result;
357
- return {
358
- content: [{ type: "text", text: JSON.stringify({ result: finalResult }) }],
359
- structuredContent: { result: finalResult },
360
- };
361
- }
362
- function coreToCompareRow(core) {
363
- const reputation = core.infoPuzzle?.merchant_behavior?.reputation;
364
- return {
365
- service_id: core.serviceId,
366
- service_name: core.serviceName,
367
- industry: core.preorderAdvice?.industry,
368
- confidence: core.preorderAdvice?.confidence.score,
369
- risk_total: core.riskScore?.total,
370
- risk_level: core.riskScore?.level,
371
- trust_score: core.trustScore.score,
372
- trust_level: core.trustScore.level,
373
- preference_match: core.preorderAdvice?.preference_match?.score,
374
- reputation_like_ratio: reputation?.like_ratio,
375
- reputation_votes: reputation ? reputation.likes + reputation.dislikes : undefined,
376
- red_flags_count: core.riskScore?.red_flags.length,
377
- blocking_reminders_count: core.preorderAdvice?.blocking_reminders.length,
378
- info_gaps_count: core.infoPuzzle?.gaps.length,
379
- };
380
- }
1
+ import{strictParse,TrustScoreInputSchema}from'../../schema/index.js';import{query_objects,query_personal}from'@wowok/wowok';import{computeServiceTrustScore}from'../../knowledge/index.js';import{assembleInfoPuzzle,assemblePreorderAdvice,assessRisk,buildPreorderComparison,getDefaultPreferences,inferIndustry,mergePreferences,validatePreferences}from'../../customer/index.js';import{getProfile}from'../../experience/user-profile.js';function extractTrustMetrics(a){const b=a?.['data']??a??{},c=Array['isArray'](b['sales'])?b['sales']:[],d=c['filter'](g=>g&&!g['suspension']);void d;const e=b['compensation_fund'],f=((()=>{if(e===null||e===undefined)return undefined;if(typeof e==='bigint')return e;if(typeof e==='number')return BigInt(e);if(typeof e==='string')try{return BigInt(e);}catch{return undefined;}if(typeof e==='object'){const g=e['balance'];if(g===null||g===undefined)return undefined;try{return BigInt(g);}catch{return undefined;}}return undefined;})());return{'arbitrationCases':Array['isArray'](b['arbitrations'])?b['arbitrations']['length']:undefined,'compensationFundBalance':f,'hasMachineBound':typeof b['machine']==='string'&&b['machine']['length']>0x0,'hasBuyGuard':typeof b['buy_guard']==='string'&&b['buy_guard']['length']>0x0};}function buildPuzzleRawData(a,b,c,d){const e=a?.['data']??a??{},f=Array['isArray'](e['sales'])?e['sales']:[],g=e['order_allocators']?Array['isArray'](e['order_allocators']['allocators'])?e['order_allocators']:{'allocators':e['order_allocators']}:undefined,h={'name':e['name']??a?.['id'],'bPublished':e['bPublished'],'bPaused':e['bPaused'],'price':f[0x0]?.['price']!=null?String(f[0x0]['price']):'0','priceRaw':f[0x0]?.['price']!=null?BigInt(f[0x0]['price']):0x0n,'token_type':f[0x0]?.['price_type']??(compensation_fund_token(e)??'0x2::wow::WOW'),'sales':f,'machine':e['machine']??undefined,'buy_guard':e['buy_guard']??undefined,'customer_required':e['customer_required'],'arbitrations':e['arbitrations'],'compensation_fund':e['compensation_fund']?{'balance':extractBalance(e['compensation_fund'])}:undefined,'compensation_lock_duration':typeof e['setting_lock_duration']==='number'?e['setting_lock_duration']:undefined,'um':e['um']??undefined,'order_allocators':g?[g]:undefined};return{'service':h,'order_amount':b,'trust_score':c,'service_owner':d};}function compensation_fund_token(a){if(a?.['compensation_fund']&&typeof a['compensation_fund']==='object')return a['compensation_fund']['token_type'];return undefined;}function extractBalance(a){if(a===null||a===undefined)return 0x0n;if(typeof a==='bigint')return a;if(typeof a==='number')return BigInt(a);if(typeof a==='string')try{return BigInt(a);}catch{return 0x0n;}if(typeof a==='object'){const c=a['balance'];if(c===null||c===undefined)return 0x0n;try{return BigInt(c);}catch{return 0x0n;}}return 0x0n;}function toUserMetricsConfig(a){return{'version':0x1,'metrics':a['metrics']['map'](b=>({'name':b['name'],'label':b['label'],'evaluator':b['evaluator'],'params':{...b['params'],'threshold':b['params']['threshold']!==undefined?String(b['params']['threshold']):undefined},'weight':b['weight'],'advice_on_fail':b['advice_on_fail'],'advice_on_pass':b['advice_on_pass']})),'adjustment_cap':a['adjustment_cap']};}function derivePreferences(a,b){const c=getProfile(),d=mergePreferences(getDefaultPreferences(b),{'risk_appetite':c['risk_appetite'],'min_trust_score':c['risk_appetite']==='conservative'?0x46:c['risk_appetite']==='aggressive'?0x1e:0x32}),e=a['preferences'],f=e?{...e,'budget_range':e['budget_range']?{'min':BigInt(e['budget_range']['min']),'max':BigInt(e['budget_range']['max'])}:undefined}:undefined,g=f?mergePreferences(d,f):d;return{'prefs':g,'issues':validatePreferences(g)};}async function fetchMerchantReputation(a,b,c){try{if(typeof a!=='string'||!a['startsWith']('0x'))return undefined;const d=await query_objects({'objects':[a],'no_cache':c,'network':b}),e=d?.['objects']?.[0x0],f=(e?.['data']??e)?.['builder'];if(typeof f!=='string'||!f['startsWith']('0x'))return undefined;const g=await query_personal({'account':f,'no_cache':c,'network':b});if(!g)return undefined;return{'likes':g['like']??0x0,'dislikes':g['dislike']??0x0};}catch{return undefined;}}async function runTrustEvaluation(a){const b=a['depth']??'evaluate',c=await query_objects({'objects':[a['service']],'no_cache':a['no_cache'],'network':a['network']}),d=c?.['objects'];if(!d||!Array['isArray'](d)||d['length']===0x0)throw new Error('Service\x20object\x20not\x20found\x20for\x20\x27'+a['service']+'\x27.\x20'+'Verify\x20the\x20ID/name\x20and\x20network,\x20or\x20use\x20query_toolkit\x20with\x20query_type=\x27onchain_objects\x27\x20to\x20debug.');const e=d[0x0],f=e?.['data']?.['object_type']??e?.['object_type']??e?.['type'];if(f&&typeof f==='string'&&!f['includes']('Service'))throw new Error('Object\x20\x27'+a['service']+'\x27\x20is\x20not\x20a\x20Service\x20(type:\x20'+f+').\x20'+'trust_score\x20only\x20evaluates\x20Service\x20objects.');const g=extractTrustMetrics(e),h=computeServiceTrustScore(g),i=Array['isArray'](e?.['data']?.['sales'])?e['data']['sales']:[],j=i['find'](q=>q&&!q['suspension'])??i[0x0],k=j?.['price']!=null?BigInt(j['price']):0x0n,l=a['order_amount']!=null?BigInt(a['order_amount']):k;let m,n,o,p;if(b==='evaluate'||b==='preorder'){const q=buildPuzzleRawData(e,l,{'score':h['score'],'level':h['level']},undefined);a['user_metrics']&&(q['user_metrics_config']=toUserMetricsConfig(a['user_metrics']));if(b==='preorder'){const r=await fetchMerchantReputation((e?.['data']??e)?.['permission'],a['network'],a['no_cache']);if(r)q['merchant_reputation']=r;}n=assembleInfoPuzzle(a['service'],q,b),m=assessRisk(n);if(b==='preorder'){const s=a['industry']??inferIndustry(n),{prefs:t,issues:u}=derivePreferences(a,s);p=u['length']>0x0?u:undefined,o=assemblePreorderAdvice({'puzzle':n,'risk':m,'preferences':t,'industry':s});}}return{'serviceId':a['service'],'serviceName':e?.['data']?.['name']??e?.['name']??a['service'],'serviceObj':e,'sales':i,'trustScore':h,'orderAmount':l,'infoPuzzle':n,'riskScore':m,'preorderAdvice':o,'preferenceIssues':p};}export async function handleTrustScore(a){const b=strictParse(TrustScoreInputSchema,a,'trust_score\x20input'),c=b['depth']??'evaluate',d=await runTrustEvaluation(b),{serviceObj:f,sales:g,trustScore:h,orderAmount:i,infoPuzzle:j,riskScore:k,preorderAdvice:l,preferenceIssues:m}=d,n={'service_id':b['service'],'service_name':f?.['data']?.['name']??f?.['name']??b['service'],'service_basics':{'bPublished':f?.['data']?.['bPublished']??![],'bPaused':f?.['data']?.['bPaused']??![],'sales_count':g['filter'](q=>q&&!q['suspension'])['length'],'has_machine':!!f?.['data']?.['machine'],'has_buy_guard':!!f?.['data']?.['buy_guard'],'has_um_contact':!!f?.['data']?.['um'],'arbitrations_count':Array['isArray'](f?.['data']?.['arbitrations'])?f['data']['arbitrations']['length']:0x0},'trust_score':{'score':h['score'],'level':h['level'],'summary':h['summary'],'warnings':h['warnings'],'breakdown':h['breakdown']},'order_amount':i['toString'](),'depth':c,...k?{'risk_score':{'total':k['total'],'level':k['level'],'red_flags':k['red_flags'],'advice':k['advice'],'dimensions':k['dimensions']}}:{},...j?{'info_puzzle':{'completeness':j['completeness'],'gaps':j['gaps'],'assembled_at':j['assembled_at']}}:{},...l?{'preorder_advice':{'confidence':l['confidence'],'industry':l['industry'],'strategies':l['strategies']['map'](q=>({'scenario':q['scenario'],'merchant_tactic':q['strategy']['merchant_tactic'],'user_strategy':q['strategy']['user_strategy'],'nash_equilibrium':q['strategy']['nash_equilibrium'],'confidence':q['confidence'],'fallback':q['fallback'],'rationale':q['rationale']})),...l['preference_match']?{'preference_match':l['preference_match']}:{},...m?{'preference_issues':m}:{},...l['industry_risks']?{'industry_risks':{'score_adjustment':l['industry_risks']['score_adjustment'],'summary':l['industry_risks']['summary'],'checks':l['industry_risks']['checks'],'unmet_needs':l['industry_risks']['unmet_needs']['map'](q=>({'id':q['id'],'tier':q['tier'],'description':q['description'],'advice':q['advice']}))}}:{},'reminders':l['reminders'],'blocking_reminders':l['blocking_reminders'],'summary':l['summary']}}:{}};let o;if(c==='preorder'&&b['compare_with']&&b['compare_with']['length']>0x0){const q=[coreToCompareRow(d)];for(const r of b['compare_with']){try{const s=await runTrustEvaluation({...b,'service':r,'depth':'preorder'});q['push'](coreToCompareRow(s));}catch(t){q['push']({'service_id':r,'service_name':r,'error':t['message']});}}o=buildPreorderComparison(q);}const p=o?{...n,'comparison':o}:n;return{'content':[{'type':'text','text':JSON['stringify']({'result':p})}],'structuredContent':{'result':p}};}function coreToCompareRow(a){const b=a['infoPuzzle']?.['merchant_behavior']?.['reputation'];return{'service_id':a['serviceId'],'service_name':a['serviceName'],'industry':a['preorderAdvice']?.['industry'],'confidence':a['preorderAdvice']?.['confidence']['score'],'risk_total':a['riskScore']?.['total'],'risk_level':a['riskScore']?.['level'],'trust_score':a['trustScore']['score'],'trust_level':a['trustScore']['level'],'preference_match':a['preorderAdvice']?.['preference_match']?.['score'],'reputation_like_ratio':b?.['like_ratio'],'reputation_votes':b?b['likes']+b['dislikes']:undefined,'red_flags_count':a['riskScore']?.['red_flags']['length'],'blocking_reminders_count':a['preorderAdvice']?.['blocking_reminders']['length'],'info_gaps_count':a['infoPuzzle']?.['gaps']['length']};}
@@ -1,90 +1 @@
1
- import { strictParse, WipOperationsSchema, } from "../../schema/index.js";
2
- import { generate_wip, verify_wip, sign_wip, wip2html, } from "@wowok/wowok";
3
- import { analyzeWipDeployment, formatDeployHints, } from "../wip-deploy-assist.js";
4
- export async function handleWipOperations(args) {
5
- if (typeof args === "object" && args !== null
6
- && args.type === "deploy_assist") {
7
- const wipPath = args.wipFilePath;
8
- if (typeof wipPath !== "string") {
9
- return {
10
- content: [{
11
- type: "text",
12
- text: "Error: 'wipFilePath' is required for deploy_assist action",
13
- }],
14
- structuredContent: {
15
- result: {
16
- type: "error",
17
- error: "'wipFilePath' is required for deploy_assist action",
18
- },
19
- },
20
- };
21
- }
22
- const suggestion = analyzeWipDeployment(wipPath);
23
- const hints = formatDeployHints(suggestion);
24
- return {
25
- content: [{ type: "text", text: hints || "No deployment needed." }],
26
- structuredContent: {
27
- result: {
28
- type: "deploy_assist",
29
- ...suggestion,
30
- },
31
- },
32
- };
33
- }
34
- const validated = strictParse(WipOperationsSchema, args, "wip_file input");
35
- let structuredContent;
36
- switch (validated.type) {
37
- case "generate": {
38
- const result = await generate_wip(validated.options, validated.outputPath);
39
- structuredContent = { result: { type: "generate", filePath: result } };
40
- break;
41
- }
42
- case "verify": {
43
- const deploySuggestion = analyzeWipDeployment(validated.wipFilePath);
44
- const result = await verify_wip(validated.wipFilePath, validated.hash_equal, validated.requireSignature);
45
- const attachHints = deploySuggestion.needs_deployment
46
- || (!result.valid && deploySuggestion.classification.type !== "data_url");
47
- if (attachHints) {
48
- const hints = formatDeployHints(deploySuggestion);
49
- structuredContent = {
50
- result: {
51
- type: "verify",
52
- ...result,
53
- deployment_assistance: deploySuggestion,
54
- },
55
- deployment_hints: hints,
56
- };
57
- }
58
- else {
59
- structuredContent = { result: { type: "verify", ...result } };
60
- }
61
- break;
62
- }
63
- case "sign": {
64
- const result = await sign_wip(validated.wipFilePath, validated.account, validated.outputPath);
65
- structuredContent = { result: { type: "sign", filePath: result } };
66
- break;
67
- }
68
- case "wip2html": {
69
- const result = await wip2html(validated.wipPath, validated.options);
70
- const output = { type: "wip2html" };
71
- if (typeof result === "string") {
72
- output.html = result;
73
- }
74
- else if (Array.isArray(result)) {
75
- output.files = result;
76
- }
77
- else {
78
- output.html = String(result);
79
- }
80
- structuredContent = { result: output };
81
- break;
82
- }
83
- default:
84
- throw new Error("Unknown WIP operation type");
85
- }
86
- return {
87
- content: [{ type: "text", text: JSON.stringify(structuredContent) }],
88
- structuredContent,
89
- };
90
- }
1
+ import{strictParse,WipOperationsSchema}from'../../schema/index.js';import{generate_wip,verify_wip,sign_wip,wip2html}from'@wowok/wowok';import{analyzeWipDeployment,formatDeployHints}from'../wip-deploy-assist.js';export async function handleWipOperations(a){if(typeof a==='object'&&a!==null&&a['type']==='deploy_assist'){const d=a['wipFilePath'];if(typeof d!=='string')return{'content':[{'type':'text','text':'Error:\x20\x27wipFilePath\x27\x20is\x20required\x20for\x20deploy_assist\x20action'}],'structuredContent':{'result':{'type':'error','error':'\x27wipFilePath\x27\x20is\x20required\x20for\x20deploy_assist\x20action'}}};const e=analyzeWipDeployment(d),f=formatDeployHints(e);return{'content':[{'type':'text','text':f||'No\x20deployment\x20needed.'}],'structuredContent':{'result':{'type':'deploy_assist',...e}}};}const b=strictParse(WipOperationsSchema,a,'wip_file\x20input');let c;switch(b['type']){case'generate':{const g=await generate_wip(b['options'],b['outputPath']);c={'result':{'type':'generate','filePath':g}};break;}case'verify':{const h=analyzeWipDeployment(b['wipFilePath']),i=await verify_wip(b['wipFilePath'],b['hash_equal'],b['requireSignature']),j=h['needs_deployment']||!i['valid']&&h['classification']['type']!=='data_url';if(j){const k=formatDeployHints(h);c={'result':{'type':'verify',...i,'deployment_assistance':h},'deployment_hints':k};}else c={'result':{'type':'verify',...i}};break;}case'sign':{const l=await sign_wip(b['wipFilePath'],b['account'],b['outputPath']);c={'result':{'type':'sign','filePath':l}};break;}case'wip2html':{const m=await wip2html(b['wipPath'],b['options']),n={'type':'wip2html'};if(typeof m==='string')n['html']=m;else Array['isArray'](m)?n['files']=m:n['html']=String(m);c={'result':n};break;}default:throw new Error('Unknown\x20WIP\x20operation\x20type');}return{'content':[{'type':'text','text':JSON['stringify'](c)}],'structuredContent':c};}