@wowok/agent-mcp 2.7.0 → 2.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (427) hide show
  1. package/dist/config/index.js +1 -1
  2. package/dist/config/runtime.js +1 -238
  3. package/dist/customer/customer-advice.js +1 -130
  4. package/dist/customer/index.js +1 -11
  5. package/dist/customer/industry-risks.js +1 -438
  6. package/dist/customer/info-puzzle.js +1 -681
  7. package/dist/customer/order-monitor.js +1 -328
  8. package/dist/customer/order-strategy.js +1 -373
  9. package/dist/customer/post-purchase.js +1 -351
  10. package/dist/customer/preorder-compare.js +1 -34
  11. package/dist/customer/reminder-system.js +1 -316
  12. package/dist/customer/risk-assessment.d.ts +5 -1
  13. package/dist/customer/risk-assessment.js +1 -397
  14. package/dist/customer/types.js +1 -13
  15. package/dist/customer/user-preferences.js +1 -460
  16. package/dist/evaluation/arbitration-game.d.ts +23 -0
  17. package/dist/evaluation/arbitration-game.js +1 -0
  18. package/dist/evaluation/builtins/demand-match.d.ts +15 -0
  19. package/dist/evaluation/builtins/demand-match.js +1 -0
  20. package/dist/evaluation/builtins/index.d.ts +3 -0
  21. package/dist/evaluation/builtins/index.js +1 -0
  22. package/dist/evaluation/builtins/service-risk.d.ts +6 -0
  23. package/dist/evaluation/builtins/service-risk.js +1 -0
  24. package/dist/evaluation/capability.d.ts +50 -0
  25. package/dist/evaluation/capability.js +1 -0
  26. package/dist/evaluation/composer.d.ts +13 -0
  27. package/dist/evaluation/composer.js +1 -0
  28. package/dist/evaluation/engine.d.ts +18 -0
  29. package/dist/evaluation/engine.js +1 -0
  30. package/dist/evaluation/extract.d.ts +30 -0
  31. package/dist/evaluation/extract.js +1 -0
  32. package/dist/evaluation/game-strategy.d.ts +27 -0
  33. package/dist/evaluation/game-strategy.js +1 -0
  34. package/dist/evaluation/gap.d.ts +2 -0
  35. package/dist/evaluation/gap.js +1 -0
  36. package/dist/evaluation/index.d.ts +12 -0
  37. package/dist/evaluation/index.js +1 -0
  38. package/dist/evaluation/node-game.d.ts +62 -0
  39. package/dist/evaluation/node-game.js +1 -0
  40. package/dist/evaluation/region.d.ts +10 -0
  41. package/dist/evaluation/region.js +1 -0
  42. package/dist/evaluation/types.d.ts +77 -0
  43. package/dist/evaluation/types.js +1 -0
  44. package/dist/evaluation/user-injection.d.ts +6 -0
  45. package/dist/evaluation/user-injection.js +1 -0
  46. package/dist/examples/education-contact-create.json +40 -0
  47. package/dist/examples/freelance-contact-create.json +40 -0
  48. package/dist/examples/insurance-machine-create.json +1 -1
  49. package/dist/examples/insurance-service-allocators.json +1 -1
  50. package/dist/examples/machine-publish.json +1 -1
  51. package/dist/examples/rental-ziroom-service-create.json +1 -1
  52. package/dist/examples/retail-adv-guard-messenger-proof-create.json +1 -1
  53. package/dist/examples/retail-myshop-service-create.json +1 -1
  54. package/dist/examples/retail-myshop-service-customer-required.json +1 -1
  55. package/dist/examples/subscription-contact-create.json +40 -0
  56. package/dist/examples/threebody-machine-create.json +1 -1
  57. package/dist/examples/travel-machine-create.json +1 -1
  58. package/dist/examples/travel-service-create.json +1 -1
  59. package/dist/experience/experience-reuse.js +1 -103
  60. package/dist/experience/index.js +1 -5
  61. package/dist/experience/intent-distill.js +1 -83
  62. package/dist/experience/realtime-feedback.js +1 -94
  63. package/dist/experience/types.js +1 -1
  64. package/dist/experience/user-profile.js +1 -171
  65. package/dist/extensions/business-modules.js +1 -287
  66. package/dist/extensions/capability-manifest.js +1 -781
  67. package/dist/extensions/constraint-registry.js +1 -198
  68. package/dist/extensions/index.js +1 -6
  69. package/dist/extensions/metric-registry.js +1 -257
  70. package/dist/extensions/mode-evaluator.js +1 -170
  71. package/dist/extensions/modes.js +1 -499
  72. package/dist/extensions/registry.js +1 -717
  73. package/dist/extensions/types.js +1 -1
  74. package/dist/harness/auto-escalation.js +1 -68
  75. package/dist/harness/checkpoint.js +1 -129
  76. package/dist/harness/index.js +1 -78
  77. package/dist/harness/plan.js +1 -276
  78. package/dist/harness/recover.js +1 -139
  79. package/dist/harness/types.js +1 -1
  80. package/dist/harness/verify.js +1 -237
  81. package/dist/index.js +1 -273
  82. package/dist/intent/enrich.d.ts +1 -0
  83. package/dist/intent/enrich.js +1 -0
  84. package/dist/intent/index.d.ts +23 -0
  85. package/dist/intent/index.js +1 -0
  86. package/dist/intent/matcher.d.ts +2 -0
  87. package/dist/intent/matcher.js +1 -0
  88. package/dist/intent/store.d.ts +19 -0
  89. package/dist/intent/store.js +1 -0
  90. package/dist/intent/types.d.ts +33 -0
  91. package/dist/intent/types.js +1 -0
  92. package/dist/knowledge/acquisition-flywheel.js +1 -192
  93. package/dist/knowledge/allocation-confirm.js +1 -534
  94. package/dist/knowledge/allocation-context.js +1 -249
  95. package/dist/knowledge/allocation-ledger.js +1 -463
  96. package/dist/knowledge/allocation-puzzle.js +1 -298
  97. package/dist/knowledge/allocation-risk.js +1 -568
  98. package/dist/knowledge/allocation-templates.js +1 -970
  99. package/dist/knowledge/allocation-translation.js +1 -585
  100. package/dist/knowledge/arb-risk.js +1 -210
  101. package/dist/knowledge/arbitration-confirm.js +1 -559
  102. package/dist/knowledge/arbitration-context.js +1 -505
  103. package/dist/knowledge/arbitration-ledger.js +1 -521
  104. package/dist/knowledge/arbitration-puzzle.js +1 -304
  105. package/dist/knowledge/arbitration-risk.js +1 -433
  106. package/dist/knowledge/arbitration-templates.js +1 -276
  107. package/dist/knowledge/arbitration-translation.js +1 -487
  108. package/dist/knowledge/arbitration-trust.js +1 -117
  109. package/dist/knowledge/audit-rules.js +1 -141
  110. package/dist/knowledge/bridge-risk.js +1 -263
  111. package/dist/knowledge/contact-risk.js +1 -200
  112. package/dist/knowledge/contact-templates.d.ts +27 -0
  113. package/dist/knowledge/contact-templates.js +1 -0
  114. package/dist/knowledge/demand-confirm.js +1 -206
  115. package/dist/knowledge/demand-matching.js +1 -132
  116. package/dist/knowledge/demand-risk.js +1 -240
  117. package/dist/knowledge/demand-translation.js +1 -354
  118. package/dist/knowledge/deployment-scanner.js +1 -823
  119. package/dist/knowledge/dynamic-pricing.js +1 -87
  120. package/dist/knowledge/examples-scanner-cli.js +1 -26
  121. package/dist/knowledge/examples-scanner.js +1 -825
  122. package/dist/knowledge/flywheel-loop.js +1 -404
  123. package/dist/knowledge/fund-layer.js +1 -973
  124. package/dist/knowledge/glossary.js +1 -211
  125. package/dist/knowledge/guard-confirm.js +1 -406
  126. package/dist/knowledge/guard-context.js +1 -287
  127. package/dist/knowledge/guard-design-patterns.js +1 -360
  128. package/dist/knowledge/guard-ledger.js +1 -260
  129. package/dist/knowledge/guard-lint.js +1 -670
  130. package/dist/knowledge/guard-migration.js +1 -228
  131. package/dist/knowledge/guard-puzzle.js +1 -805
  132. package/dist/knowledge/guard-render.js +1 -700
  133. package/dist/knowledge/guard-risk.js +1 -1879
  134. package/dist/knowledge/guard-submission-prompt.js +1 -171
  135. package/dist/knowledge/guard-templates.js +1 -1105
  136. package/dist/knowledge/guard-translation.js +1 -1119
  137. package/dist/knowledge/index.js +1 -436
  138. package/dist/knowledge/industry-evolution.js +1 -323
  139. package/dist/knowledge/industry-generalizer.js +1 -381
  140. package/dist/knowledge/industry-registry.js +1 -174
  141. package/dist/knowledge/intent-metrics.d.ts +4 -3
  142. package/dist/knowledge/intent-metrics.js +1 -566
  143. package/dist/knowledge/machine-confirm.js +1 -559
  144. package/dist/knowledge/machine-context.js +1 -833
  145. package/dist/knowledge/machine-ledger.js +1 -338
  146. package/dist/knowledge/machine-puzzle.js +1 -494
  147. package/dist/knowledge/machine-render.js +1 -565
  148. package/dist/knowledge/machine-risk.js +1 -670
  149. package/dist/knowledge/machine-templates.js +1 -1597
  150. package/dist/knowledge/machine-topology.js +1 -234
  151. package/dist/knowledge/machine-translation.js +1 -513
  152. package/dist/knowledge/mcp-schema-audit-cli.js +1 -45
  153. package/dist/knowledge/mcp-schema-audit.d.ts +1 -1
  154. package/dist/knowledge/mcp-schema-audit.js +1 -773
  155. package/dist/knowledge/onchain-constants.js +1 -35
  156. package/dist/knowledge/order-confirm.js +1 -573
  157. package/dist/knowledge/order-context.js +1 -390
  158. package/dist/knowledge/order-ledger.js +1 -341
  159. package/dist/knowledge/order-puzzle.js +1 -255
  160. package/dist/knowledge/order-risk.js +1 -653
  161. package/dist/knowledge/order-templates.js +1 -368
  162. package/dist/knowledge/order-translation.js +1 -550
  163. package/dist/knowledge/overrides-loader.js +1 -65
  164. package/dist/knowledge/passport-confirm.js +1 -531
  165. package/dist/knowledge/passport-context.js +1 -306
  166. package/dist/knowledge/passport-ledger.js +1 -282
  167. package/dist/knowledge/passport-puzzle.js +1 -333
  168. package/dist/knowledge/passport-risk.js +1 -450
  169. package/dist/knowledge/passport-templates.js +1 -568
  170. package/dist/knowledge/passport-translation.js +1 -516
  171. package/dist/knowledge/payment-risk.js +1 -249
  172. package/dist/knowledge/permission-confirm.js +1 -426
  173. package/dist/knowledge/permission-context.js +1 -224
  174. package/dist/knowledge/permission-ledger.js +1 -403
  175. package/dist/knowledge/permission-puzzle.js +1 -173
  176. package/dist/knowledge/permission-risk.js +1 -411
  177. package/dist/knowledge/permission-templates.js +1 -234
  178. package/dist/knowledge/permission-translation.js +1 -350
  179. package/dist/knowledge/personal-risk.js +1 -212
  180. package/dist/knowledge/process-model.js +1 -160
  181. package/dist/knowledge/progress-confirm.js +1 -456
  182. package/dist/knowledge/progress-context.js +1 -452
  183. package/dist/knowledge/progress-ledger.js +1 -330
  184. package/dist/knowledge/progress-puzzle.js +1 -219
  185. package/dist/knowledge/progress-risk.js +1 -461
  186. package/dist/knowledge/progress-templates.js +1 -228
  187. package/dist/knowledge/progress-translation.js +1 -405
  188. package/dist/knowledge/proof-confirm.js +1 -187
  189. package/dist/knowledge/proof-risk.js +1 -207
  190. package/dist/knowledge/proof-translation.js +1 -283
  191. package/dist/knowledge/registrar-risk.js +1 -217
  192. package/dist/knowledge/repository-confirm.js +1 -286
  193. package/dist/knowledge/repository-risk.js +1 -373
  194. package/dist/knowledge/repository-translation.js +1 -445
  195. package/dist/knowledge/reputation-rules.js +1 -99
  196. package/dist/knowledge/resource-risk.js +1 -157
  197. package/dist/knowledge/reward-confirm.js +1 -526
  198. package/dist/knowledge/reward-context.js +1 -504
  199. package/dist/knowledge/reward-ledger.js +1 -502
  200. package/dist/knowledge/reward-puzzle.js +1 -300
  201. package/dist/knowledge/reward-risk.js +1 -627
  202. package/dist/knowledge/reward-templates.js +1 -197
  203. package/dist/knowledge/reward-translation.js +1 -501
  204. package/dist/knowledge/safety-rules.js +1 -404
  205. package/dist/knowledge/scenario-modes.js +1 -321
  206. package/dist/knowledge/service-confirm.js +1 -807
  207. package/dist/knowledge/service-context.js +1 -403
  208. package/dist/knowledge/service-ledger.js +1 -609
  209. package/dist/knowledge/service-puzzle.js +1 -236
  210. package/dist/knowledge/service-risk.js +1 -615
  211. package/dist/knowledge/service-templates.js +1 -456
  212. package/dist/knowledge/service-translation.js +1 -622
  213. package/dist/knowledge/template-registry.d.ts +1 -1
  214. package/dist/knowledge/template-registry.js +1 -341
  215. package/dist/knowledge/tool-constraints.js +1 -195
  216. package/dist/knowledge/tools-reference.js +1 -155
  217. package/dist/knowledge/treasury-confirm.js +1 -512
  218. package/dist/knowledge/treasury-context.js +1 -363
  219. package/dist/knowledge/treasury-ledger.js +1 -300
  220. package/dist/knowledge/treasury-puzzle.js +1 -216
  221. package/dist/knowledge/treasury-risk.js +1 -440
  222. package/dist/knowledge/treasury-templates.js +1 -358
  223. package/dist/knowledge/treasury-translation.js +1 -498
  224. package/dist/knowledge/trust-metrics.js +1 -198
  225. package/dist/knowledge/util-risk.js +1 -135
  226. package/dist/loop-engineering/aggregate.js +1 -132
  227. package/dist/loop-engineering/context-collect.js +1 -83
  228. package/dist/loop-engineering/diagnose.js +1 -273
  229. package/dist/loop-engineering/improve.js +1 -405
  230. package/dist/loop-engineering/index.js +1 -4
  231. package/dist/loop-engineering/pipeline.js +1 -56
  232. package/dist/mode-market/index.js +1 -3
  233. package/dist/mode-market/registry.js +1 -124
  234. package/dist/mode-market/review.js +1 -214
  235. package/dist/mode-market/submission.js +1 -85
  236. package/dist/participation/collaborator-interest.d.ts +23 -0
  237. package/dist/participation/collaborator-interest.js +1 -0
  238. package/dist/participation/customer-interest.d.ts +25 -0
  239. package/dist/participation/customer-interest.js +1 -0
  240. package/dist/participation/merchant-interest.js +1 -100
  241. package/dist/participation/radar-core.d.ts +13 -3
  242. package/dist/participation/radar-core.js +1 -269
  243. package/dist/participation/supplier-interest.d.ts +25 -0
  244. package/dist/participation/supplier-interest.js +1 -0
  245. package/dist/persona/analyzer.d.ts +16 -0
  246. package/dist/persona/analyzer.js +1 -0
  247. package/dist/persona/bridge.d.ts +5 -0
  248. package/dist/persona/bridge.js +1 -0
  249. package/dist/persona/defaults.d.ts +4 -0
  250. package/dist/persona/defaults.js +1 -0
  251. package/dist/persona/experience-bridge.d.ts +3 -0
  252. package/dist/persona/experience-bridge.js +1 -0
  253. package/dist/persona/index.d.ts +18 -0
  254. package/dist/persona/index.js +1 -0
  255. package/dist/persona/model.d.ts +7 -0
  256. package/dist/persona/model.js +1 -0
  257. package/dist/persona/store.d.ts +19 -0
  258. package/dist/persona/store.js +1 -0
  259. package/dist/persona/types.d.ts +45 -0
  260. package/dist/persona/types.js +1 -0
  261. package/dist/project/business-puzzle.js +1 -383
  262. package/dist/project/context-assembly.js +1 -254
  263. package/dist/project/deployment-bridge.js +1 -120
  264. package/dist/project/deployment-doc.js +1 -1126
  265. package/dist/project/edit-planner.js +1 -1342
  266. package/dist/project/evaluation.js +1 -2011
  267. package/dist/project/game-theory.js +1 -177
  268. package/dist/project/graph-builder.js +1 -656
  269. package/dist/project/graph.js +1 -340
  270. package/dist/project/handlers.d.ts +5 -0
  271. package/dist/project/handlers.js +1 -1762
  272. package/dist/project/index.d.ts +1 -0
  273. package/dist/project/index.js +1 -301
  274. package/dist/project/intent-analyzer.js +1 -149
  275. package/dist/project/machine-nodes.js +1 -36
  276. package/dist/project/merchant-guide.js +1 -264
  277. package/dist/project/migration.js +1 -125
  278. package/dist/project/mode-actions.js +1 -309
  279. package/dist/project/namespace.js +1 -206
  280. package/dist/project/participation-radar.js +1 -428
  281. package/dist/project/pipeline-actions.js +1 -109
  282. package/dist/project/project-store.js +1 -422
  283. package/dist/project/query.js +1 -153
  284. package/dist/project/reverse-mapping.d.ts +34 -0
  285. package/dist/project/reverse-mapping.js +1 -0
  286. package/dist/project/risk-aggregator.js +1 -295
  287. package/dist/project/rollback-policy.js +1 -290
  288. package/dist/project/semantic-assembler.js +1 -345
  289. package/dist/project/semantic-graph.js +1 -245
  290. package/dist/project/stage-gate.js +1 -369
  291. package/dist/project/substep-trace.js +1 -332
  292. package/dist/project/task-tracker.js +1 -78
  293. package/dist/role/derivation.d.ts +18 -0
  294. package/dist/role/derivation.js +1 -0
  295. package/dist/role/index.d.ts +5 -0
  296. package/dist/role/index.js +1 -0
  297. package/dist/role/model.d.ts +8 -0
  298. package/dist/role/model.js +1 -0
  299. package/dist/role/resolution.d.ts +11 -0
  300. package/dist/role/resolution.js +1 -0
  301. package/dist/role/types.d.ts +11 -0
  302. package/dist/role/types.js +1 -0
  303. package/dist/rules.d.ts +2 -0
  304. package/dist/rules.js +1 -9
  305. package/dist/safety/confirm-gate.js +1 -88
  306. package/dist/safety/index.js +1 -3
  307. package/dist/safety/preview.js +1 -52
  308. package/dist/schema/call/allocation.js +1 -34
  309. package/dist/schema/call/arbitration.js +1 -113
  310. package/dist/schema/call/base.d.ts +15 -15
  311. package/dist/schema/call/base.js +1 -370
  312. package/dist/schema/call/bridge-handler.js +1 -265
  313. package/dist/schema/call/bridge.d.ts +7 -7
  314. package/dist/schema/call/bridge.js +1 -458
  315. package/dist/schema/call/contact.js +1 -37
  316. package/dist/schema/call/demand.js +1 -47
  317. package/dist/schema/call/guard.js +1 -161
  318. package/dist/schema/call/handler.js +1 -322
  319. package/dist/schema/call/index.js +1 -20
  320. package/dist/schema/call/machine.js +1 -193
  321. package/dist/schema/call/order.js +1 -35
  322. package/dist/schema/call/payment.js +1 -37
  323. package/dist/schema/call/permission-handler.js +1 -54
  324. package/dist/schema/call/permission.js +1 -105
  325. package/dist/schema/call/personal.js +1 -78
  326. package/dist/schema/call/progress.js +1 -47
  327. package/dist/schema/call/proof.js +1 -33
  328. package/dist/schema/call/repository.js +1 -77
  329. package/dist/schema/call/reward.js +1 -30
  330. package/dist/schema/call/semantic.js +1 -1657
  331. package/dist/schema/call/service.js +1 -178
  332. package/dist/schema/call/treasury.js +1 -71
  333. package/dist/schema/common/index.js +1 -407
  334. package/dist/schema/config/index.js +1 -68
  335. package/dist/schema/evaluation/index.d.ts +4436 -0
  336. package/dist/schema/evaluation/index.js +1 -0
  337. package/dist/schema/index.d.ts +4 -0
  338. package/dist/schema/index.js +1 -13
  339. package/dist/schema/intent-radar/index.d.ts +284 -0
  340. package/dist/schema/intent-radar/index.js +1 -0
  341. package/dist/schema/local/index.d.ts +21 -21
  342. package/dist/schema/local/index.js +1 -927
  343. package/dist/schema/local/wip.js +1 -187
  344. package/dist/schema/messenger/index.d.ts +7 -7
  345. package/dist/schema/messenger/index.js +1 -475
  346. package/dist/schema/operations.d.ts +7 -7
  347. package/dist/schema/operations.js +1 -520
  348. package/dist/schema/persona/index.d.ts +1985 -0
  349. package/dist/schema/persona/index.js +1 -0
  350. package/dist/schema/project/index.d.ts +96 -50
  351. package/dist/schema/project/index.js +1 -2057
  352. package/dist/schema/query/index.d.ts +423 -7
  353. package/dist/schema/query/index.js +1 -1640
  354. package/dist/schema/schema-query/index.js +1 -104
  355. package/dist/schema/schema-version.js +1 -76
  356. package/dist/schema/sync-layer4.d.ts +1 -1
  357. package/dist/schema/sync-layer4.js +1 -282
  358. package/dist/schema/task-status.d.ts +168 -0
  359. package/dist/schema/task-status.js +1 -0
  360. package/dist/schema/trust/index.js +1 -314
  361. package/dist/schema/utils/guard-parser.js +1 -419
  362. package/dist/schema/utils/guard-query-utils.js +1 -46
  363. package/dist/schema/utils/node-parser.js +1 -369
  364. package/dist/schema/utils/object-type-utils.js +1 -35
  365. package/dist/schema/utils/permission-index-utils.js +1 -7
  366. package/dist/schema/utils/permission-machine-check.js +1 -121
  367. package/dist/schema/utils/skills-recommendation.js +1 -77
  368. package/dist/schema-query/index.js +1 -810
  369. package/dist/schemas/account_operation.output.json +5 -2
  370. package/dist/schemas/bridge_operation.output.json +5 -2
  371. package/dist/schemas/evaluation_operation.output.json +782 -0
  372. package/dist/schemas/evaluation_operation.schema.json +990 -0
  373. package/dist/schemas/index.json +25 -1
  374. package/dist/schemas/intent_radar.output.json +232 -0
  375. package/dist/schemas/intent_radar.schema.json +138 -0
  376. package/dist/schemas/local_info_operation.output.json +5 -2
  377. package/dist/schemas/local_mark_operation.output.json +5 -2
  378. package/dist/schemas/messenger_operation.output.json +5 -2
  379. package/dist/schemas/onchain_events.output.json +5 -2
  380. package/dist/schemas/onchain_operations.output.json +5 -2
  381. package/dist/schemas/onchain_operations.schema.json +6 -6
  382. package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
  383. package/dist/schemas/onchain_operations_machine.schema.json +2 -2
  384. package/dist/schemas/onchain_operations_service.schema.json +3 -3
  385. package/dist/schemas/onchain_table_data.output.json +6 -3
  386. package/dist/schemas/persona_operation.output.json +392 -0
  387. package/dist/schemas/persona_operation.schema.json +250 -0
  388. package/dist/schemas/project_operation.output.json +28 -8
  389. package/dist/schemas/query_task_status.output.json +115 -0
  390. package/dist/schemas/query_task_status.schema.json +24 -0
  391. package/dist/schemas/query_toolkit.output.json +9 -6
  392. package/dist/schemas/trust_score.schema.json +1 -1
  393. package/dist/schemas/wowok_buildin_info.output.json +132 -0
  394. package/dist/schemas/wowok_buildin_info.schema.json +14 -0
  395. package/dist/telemetry/index.js +1 -112
  396. package/dist/telemetry/redact.js +1 -23
  397. package/dist/telemetry/storage.js +1 -80
  398. package/dist/tools/handlers/bridge.js +1 -1
  399. package/dist/tools/handlers/config.js +1 -74
  400. package/dist/tools/handlers/evaluation.d.ts +2 -0
  401. package/dist/tools/handlers/evaluation.js +1 -0
  402. package/dist/tools/handlers/file-export.js +1 -90
  403. package/dist/tools/handlers/intent-radar.d.ts +2 -0
  404. package/dist/tools/handlers/intent-radar.js +1 -0
  405. package/dist/tools/handlers/local.js +1 -53
  406. package/dist/tools/handlers/messenger.js +1 -188
  407. package/dist/tools/handlers/onchain.js +1 -1082
  408. package/dist/tools/handlers/persona.d.ts +4 -0
  409. package/dist/tools/handlers/persona.js +1 -0
  410. package/dist/tools/handlers/project.js +1 -211
  411. package/dist/tools/handlers/query.js +1 -434
  412. package/dist/tools/handlers/schema-query.js +1 -176
  413. package/dist/tools/handlers/task-status.d.ts +0 -168
  414. package/dist/tools/handlers/task-status.js +1 -55
  415. package/dist/tools/handlers/trust.js +1 -380
  416. package/dist/tools/handlers/wip.js +1 -90
  417. package/dist/tools/index.js +1 -1306
  418. package/dist/tools/retry.js +1 -85
  419. package/dist/tools/rules-hook.js +1 -23
  420. package/dist/tools/shared.js +1 -130
  421. package/dist/tools/types.js +1 -1
  422. package/dist/tools/upgrade-check.d.ts +19 -0
  423. package/dist/tools/upgrade-check.js +1 -0
  424. package/dist/tools/wip-deploy-assist.d.ts +1 -1
  425. package/dist/tools/wip-deploy-assist.js +1 -278
  426. package/dist/tools/wrap.js +1 -500
  427. package/package.json +5 -3
@@ -1,369 +1 @@
1
- import { NodeSchema } from '../call/machine.js';
2
- import { MachineNodeSchema, MachineNodePairSchema, MachineForwardSchema } from '../query/index.js';
3
- import { writeFileSync } from 'fs';
4
- function detectFormat(text) {
5
- const trimmed = text.trim();
6
- if (trimmed.startsWith('{') || trimmed.startsWith('[')) {
7
- return 'json';
8
- }
9
- return 'markdown';
10
- }
11
- function extractJsonFromMarkdown(markdown) {
12
- const codeBlockRegex = /```(?:json)?\s*\n([\s\S]*?)```/g;
13
- let match;
14
- let lastMatch = null;
15
- while ((match = codeBlockRegex.exec(markdown)) !== null) {
16
- const jsonContent = match[1].trim();
17
- if (jsonContent.startsWith('[') || jsonContent.startsWith('{')) {
18
- const beforeMatch = markdown.substring(0, match.index);
19
- const lineOffset = (beforeMatch.match(/\n/g) || []).length + 1;
20
- lastMatch = { json: jsonContent, lineOffset };
21
- }
22
- }
23
- return lastMatch;
24
- }
25
- function parseMarkdownToNodeData(markdown) {
26
- const errors = [];
27
- const jsonMatch = extractJsonFromMarkdown(markdown);
28
- if (jsonMatch) {
29
- try {
30
- const data = JSON.parse(jsonMatch.json);
31
- return { data, errors: [] };
32
- }
33
- catch (e) {
34
- errors.push({
35
- message: `Failed to parse JSON from markdown: ${e.message}`,
36
- path: '/',
37
- });
38
- return { data: null, errors };
39
- }
40
- }
41
- const result = { op: 'add' };
42
- const nodes = [];
43
- const opMatch = markdown.match(/(?:^|\n)#+\s*Operation[^\n]*\n+[-*]\s*op\s*:\s*(\w+)/i);
44
- if (opMatch) {
45
- result.op = opMatch[1].toLowerCase();
46
- }
47
- const replaceMatch = markdown.match(/(?:^|\n)#+\s*Options[^\n]*\n+[-*]\s*bReplace\s*:\s*(true|false)/i);
48
- if (replaceMatch) {
49
- result.bReplace = replaceMatch[1].toLowerCase() === 'true';
50
- }
51
- const nodeSections = markdown.split(/(?=^##\s*Node[:\s])/m);
52
- for (const section of nodeSections.slice(1)) {
53
- const nodeNameMatch = section.match(/^##\s*Node[:\s]+(.+?)(?:\n|$)/im);
54
- if (!nodeNameMatch)
55
- continue;
56
- const nodeName = nodeNameMatch[1].trim();
57
- const node = { name: nodeName, pairs: [] };
58
- const pairSections = section.split(/(?=^###\s*(?:Pair|Previous Node)[:\s])/m);
59
- for (const pairSection of pairSections.slice(1)) {
60
- const prevNodeMatch = pairSection.match(/(?:^|\n)[-*]\s*prev_node\s*[:]\s*(.+?)(?:\n|$)/im) ||
61
- pairSection.match(/^###\s*(?:Pair|Previous Node)[:\s]+(.+?)(?:\n|$)/im);
62
- const thresholdMatch = pairSection.match(/(?:^|\n)[-*]\s*threshold\s*[:]\s*(\d+)/i);
63
- if (!prevNodeMatch)
64
- continue;
65
- const pair = {
66
- prev_node: prevNodeMatch[1].trim(),
67
- threshold: thresholdMatch ? parseInt(thresholdMatch[1], 10) : 0,
68
- forwards: []
69
- };
70
- const tableRows = pairSection.match(/\|[^\n]+\|/g);
71
- if (tableRows && tableRows.length > 2) {
72
- for (const row of tableRows.slice(2)) {
73
- const cells = row.split('|').filter(c => c.trim()).map(c => c.trim());
74
- if (cells.length >= 2) {
75
- const forward = {
76
- name: cells[0],
77
- weight: parseInt(cells[1], 10) || 0
78
- };
79
- if (cells.length >= 3 && cells[2] && cells[2] !== '-') {
80
- forward.namedOperator = cells[2];
81
- }
82
- if (cells.length >= 4 && cells[3] && cells[3] !== '-') {
83
- forward.permissionIndex = parseInt(cells[3], 10);
84
- }
85
- if (cells.length >= 5 && cells[4] && cells[4] !== '-') {
86
- forward.guard = cells[4];
87
- }
88
- pair.forwards.push(forward);
89
- }
90
- }
91
- }
92
- const forwardMatches = pairSection.matchAll(/(?:^|\n)[-*]\s*(?:forward)?\s*[:]?\s*\n?([\s\S]*?)(?=(?:\n[-*]\s*(?:forward|prev_node|threshold))|\n###|\n##|$)/gi);
93
- for (const forwardMatch of forwardMatches) {
94
- const forwardSection = forwardMatch[1];
95
- const nameMatch = forwardSection.match(/\s*name\s*[:]\s*(.+?)(?:\n|$)/im);
96
- const weightMatch = forwardSection.match(/\s*weight\s*[:]\s*(\d+)/i);
97
- if (nameMatch && weightMatch) {
98
- const forward = {
99
- name: nameMatch[1].trim(),
100
- weight: parseInt(weightMatch[1], 10)
101
- };
102
- const namedOperatorMatch = forwardSection.match(/\s*namedOperator\s*[:]\s*(.+?)(?:\n|$)/im);
103
- const permissionIndexMatch = forwardSection.match(/\s*permissionIndex\s*[:]\s*(\d+)/i);
104
- const guardMatch = forwardSection.match(/\s*guard\s*[:]\s*(.+?)(?:\n|$)/im);
105
- if (namedOperatorMatch) {
106
- forward.namedOperator = namedOperatorMatch[1].trim();
107
- }
108
- if (permissionIndexMatch) {
109
- forward.permissionIndex = parseInt(permissionIndexMatch[1], 10);
110
- }
111
- if (guardMatch) {
112
- forward.guard = guardMatch[1].trim();
113
- }
114
- pair.forwards.push(forward);
115
- }
116
- }
117
- node.pairs.push(pair);
118
- }
119
- nodes.push(node);
120
- }
121
- if (nodes.length > 0) {
122
- result.nodes = nodes;
123
- }
124
- return { data: result, errors };
125
- }
126
- function formatZodPath(path) {
127
- return '/' + path.map(p => String(p).replace(/~/g, '~0').replace(/\//g, '~1')).join('/');
128
- }
129
- function parseJsonWithErrors(text) {
130
- const errors = [];
131
- try {
132
- const data = JSON.parse(text);
133
- return { data, errors: [] };
134
- }
135
- catch (e) {
136
- const jsonError = e;
137
- const lineMatch = jsonError.message.match(/position\s+(\d+)/);
138
- let line = 1;
139
- let column = 1;
140
- if (lineMatch) {
141
- const pos = parseInt(lineMatch[1], 10);
142
- const lines = text.substring(0, pos).split('\n');
143
- line = lines.length;
144
- column = lines[lines.length - 1].length + 1;
145
- }
146
- errors.push({
147
- message: `JSON parse error: ${jsonError.message}`,
148
- path: '/',
149
- line,
150
- column,
151
- });
152
- return { data: null, errors };
153
- }
154
- }
155
- function validateWithZod(schema, data, basePath = '') {
156
- const errors = [];
157
- const result = schema.safeParse(data);
158
- if (result.success) {
159
- return { success: true, data: result.data, errors: [] };
160
- }
161
- for (const issue of result.error.issues) {
162
- const path = basePath + formatZodPath(issue.path);
163
- errors.push({
164
- message: issue.message,
165
- path,
166
- });
167
- }
168
- return { success: false, errors };
169
- }
170
- export function parseNodeFromText(text) {
171
- const trimmed = text.trim();
172
- const format = detectFormat(trimmed);
173
- let parsedData;
174
- let errors = [];
175
- if (format === 'markdown') {
176
- const mdResult = parseMarkdownToNodeData(trimmed);
177
- if (mdResult.errors.length > 0) {
178
- return { success: false, errors: mdResult.errors };
179
- }
180
- parsedData = mdResult.data;
181
- }
182
- else {
183
- const jsonResult = parseJsonWithErrors(trimmed);
184
- if (jsonResult.errors.length > 0) {
185
- return { success: false, errors: jsonResult.errors };
186
- }
187
- parsedData = jsonResult.data;
188
- }
189
- const validation = validateWithZod(NodeSchema, parsedData);
190
- return {
191
- success: validation.success,
192
- data: validation.data,
193
- errors: validation.errors,
194
- };
195
- }
196
- export function parseMachineNodesFromText(text) {
197
- const trimmed = text.trim();
198
- const format = detectFormat(trimmed);
199
- let parsedData;
200
- let errors = [];
201
- if (format === 'markdown') {
202
- const mdResult = parseMarkdownToNodeData(trimmed);
203
- if (mdResult.errors.length > 0) {
204
- return { success: false, errors: mdResult.errors };
205
- }
206
- if (typeof mdResult.data === 'object' && mdResult.data !== null && 'nodes' in mdResult.data) {
207
- parsedData = mdResult.data.nodes;
208
- }
209
- else {
210
- parsedData = mdResult.data;
211
- }
212
- }
213
- else {
214
- const jsonResult = parseJsonWithErrors(trimmed);
215
- if (jsonResult.errors.length > 0) {
216
- return { success: false, errors: jsonResult.errors };
217
- }
218
- parsedData = jsonResult.data;
219
- }
220
- if (!Array.isArray(parsedData)) {
221
- if (typeof parsedData === 'object' && parsedData !== null && 'op' in parsedData) {
222
- return {
223
- success: false,
224
- errors: [{
225
- message: 'Expected JSON array of nodes for json_or_markdown mode. Use schema mode for operations with "op" field.',
226
- path: '/',
227
- }]
228
- };
229
- }
230
- return {
231
- success: false,
232
- errors: [{
233
- message: 'Expected JSON array of nodes',
234
- path: '/',
235
- }]
236
- };
237
- }
238
- const nodes = [];
239
- for (let i = 0; i < parsedData.length; i++) {
240
- const nodeData = parsedData[i];
241
- const validation = validateWithZod(MachineNodeSchema, nodeData, `/${i}`);
242
- if (validation.success && validation.data) {
243
- nodes.push(validation.data);
244
- }
245
- else {
246
- errors.push(...validation.errors);
247
- }
248
- }
249
- if (errors.length > 0) {
250
- return { success: false, errors };
251
- }
252
- const hasEntryForward = nodes.some(node => node.pairs.some(pair => pair.prev_node === ""));
253
- if (!hasEntryForward) {
254
- return {
255
- success: false,
256
- errors: [{
257
- message: 'Machine has no entry forward. At least one node must have a pair with prev_node="" (empty string), ' +
258
- 'which defines how Progress advances from the initial state (current="") to the first node. ' +
259
- 'Without an entry forward, the workflow will be permanently stuck. ' +
260
- 'Example: {name: "Subscribed", pairs: [{prev_node: "", forwards: [{name: "Subscribe", weight: 1}]}]}',
261
- path: '/',
262
- }]
263
- };
264
- }
265
- return { success: true, data: nodes, errors: [] };
266
- }
267
- export function formatNodeErrors(errors) {
268
- return errors.map(e => {
269
- let msg = `Path: ${e.path}`;
270
- if (e.line !== undefined && e.column !== undefined) {
271
- msg += ` (line ${e.line}, column ${e.column})`;
272
- }
273
- msg += `\n Error: ${e.message}`;
274
- return msg;
275
- }).join('\n\n');
276
- }
277
- export function validateMachineNode(node) {
278
- return validateWithZod(MachineNodeSchema, node);
279
- }
280
- export function validateMachineNodePair(pair) {
281
- const result = MachineNodePairSchema.safeParse(pair);
282
- if (result.success) {
283
- return { success: true, errors: [] };
284
- }
285
- const errors = result.error.issues.map(issue => ({
286
- message: issue.message,
287
- path: formatZodPath(issue.path),
288
- }));
289
- return { success: false, errors };
290
- }
291
- export function validateMachineForward(forward) {
292
- const result = MachineForwardSchema.safeParse(forward);
293
- if (result.success) {
294
- return { success: true, errors: [] };
295
- }
296
- const errors = result.error.issues.map(issue => ({
297
- message: issue.message,
298
- path: formatZodPath(issue.path),
299
- }));
300
- return { success: false, errors };
301
- }
302
- export function machineNodesToJson(nodes, options = {}) {
303
- const { machineId, includeComments = true } = options;
304
- let result = '';
305
- if (includeComments && machineId) {
306
- result += `// Machine ID: ${machineId}\n`;
307
- }
308
- result += JSON.stringify(nodes, null, 2);
309
- return result;
310
- }
311
- export function machineNodesToMarkdown(nodes, options = {}) {
312
- const { machineName, machineAddress, machineId, includeComments = true } = options;
313
- let md = `# Machine Node Definition\n\n`;
314
- if (machineName) {
315
- md += `**Machine:** ${machineName}\n\n`;
316
- }
317
- if (machineAddress) {
318
- md += `**Address:** ${machineAddress}\n\n`;
319
- }
320
- if (machineId) {
321
- md += `**ID:** ${machineId}\n\n`;
322
- }
323
- md += `**Total Nodes:** ${nodes.length}\n\n`;
324
- md += `---\n\n`;
325
- for (const node of nodes) {
326
- md += `## Node: ${node.name}\n\n`;
327
- if (includeComments) {
328
- md += `<!-- Node definition with pairs and forwards -->\n\n`;
329
- }
330
- for (const pair of node.pairs) {
331
- md += `### Pair: ${pair.prev_node}\n\n`;
332
- md += `- **prev_node**: ${pair.prev_node}\n`;
333
- md += `- **threshold**: ${pair.threshold}\n\n`;
334
- if (pair.forwards && pair.forwards.length > 0) {
335
- md += `#### Forwards\n\n`;
336
- md += `| name | weight | namedOperator | permissionIndex | guard |\n`;
337
- md += `|------|--------|---------------|-----------------|-------|\n`;
338
- for (const forward of pair.forwards) {
339
- const namedOp = forward.namedOperator || '';
340
- const permIdx = forward.permissionIndex?.toString() || '';
341
- const guardRaw = forward.guard;
342
- const guard = typeof guardRaw === 'string'
343
- ? guardRaw
344
- : (guardRaw?.guard || '');
345
- md += `| ${forward.name} | ${forward.weight} | ${namedOp} | ${permIdx} | ${guard} |\n`;
346
- }
347
- md += `\n`;
348
- }
349
- }
350
- md += `---\n\n`;
351
- }
352
- md += `## JSON Definition\n\n`;
353
- if (includeComments) {
354
- md += `<!-- You can also use the JSON format below -->\n\n`;
355
- }
356
- md += `\`\`\`json\n`;
357
- if (includeComments && machineId) {
358
- md += `// Machine ID: ${machineId}\n`;
359
- }
360
- md += JSON.stringify(nodes, null, 2);
361
- md += `\n\`\`\`\n`;
362
- return md;
363
- }
364
- export function saveMachineNodesToFile(nodes, filePath, format = 'json', options = {}) {
365
- const content = format === 'json'
366
- ? machineNodesToJson(nodes, options)
367
- : machineNodesToMarkdown(nodes, options);
368
- writeFileSync(filePath, content, 'utf-8');
369
- }
1
+ import{NodeSchema}from'../call/machine.js';import{MachineNodeSchema,MachineNodePairSchema,MachineForwardSchema}from'../query/index.js';import{writeFileSync}from'fs';function detectFormat(a){const b=a['trim']();if(b['startsWith']('{')||b['startsWith']('['))return'json';return'markdown';}function extractJsonFromMarkdown(a){const b=/```(?:json)?\s*\n([\s\S]*?)```/g;let c,d=null;while((c=b['exec'](a))!==null){const e=c[0x1]['trim']();if(e['startsWith']('[')||e['startsWith']('{')){const f=a['substring'](0x0,c['index']),g=(f['match'](/\n/g)||[])['length']+0x1;d={'json':e,'lineOffset':g};}}return d;}function parseMarkdownToNodeData(a){const b=[],c=extractJsonFromMarkdown(a);if(c)try{const j=JSON['parse'](c['json']);return{'data':j,'errors':[]};}catch(k){return b['push']({'message':'Failed\x20to\x20parse\x20JSON\x20from\x20markdown:\x20'+k['message'],'path':'/'}),{'data':null,'errors':b};}const d={'op':'add'},f=[],g=a['match'](/(?:^|\n)#+\s*Operation[^\n]*\n+[-*]\s*op\s*:\s*(\w+)/i);g&&(d['op']=g[0x1]['toLowerCase']());const h=a['match'](/(?:^|\n)#+\s*Options[^\n]*\n+[-*]\s*bReplace\s*:\s*(true|false)/i);h&&(d['bReplace']=h[0x1]['toLowerCase']()==='true');const i=a['split'](/(?=^##\s*Node[:\s])/m);for(const l of i['slice'](0x1)){const m=l['match'](/^##\s*Node[:\s]+(.+?)(?:\n|$)/im);if(!m)continue;const n=m[0x1]['trim'](),o={'name':n,'pairs':[]},p=l['split'](/(?=^###\s*(?:Pair|Previous Node)[:\s])/m);for(const q of p['slice'](0x1)){const r=q['match'](/(?:^|\n)[-*]\s*prev_node\s*[:]\s*(.+?)(?:\n|$)/im)||q['match'](/^###\s*(?:Pair|Previous Node)[:\s]+(.+?)(?:\n|$)/im),s=q['match'](/(?:^|\n)[-*]\s*threshold\s*[:]\s*(\d+)/i);if(!r)continue;const t={'prev_node':r[0x1]['trim'](),'threshold':s?parseInt(s[0x1],0xa):0x0,'forwards':[]},u=q['match'](/\|[^\n]+\|/g);if(u&&u['length']>0x2)for(const w of u['slice'](0x2)){const x=w['split']('|')['filter'](y=>y['trim']())['map'](y=>y['trim']());if(x['length']>=0x2){const y={'name':x[0x0],'weight':parseInt(x[0x1],0xa)||0x0};x['length']>=0x3&&x[0x2]&&x[0x2]!=='-'&&(y['namedOperator']=x[0x2]),x['length']>=0x4&&x[0x3]&&x[0x3]!=='-'&&(y['permissionIndex']=parseInt(x[0x3],0xa)),x['length']>=0x5&&x[0x4]&&x[0x4]!=='-'&&(y['guard']=x[0x4]),t['forwards']['push'](y);}}const v=q['matchAll'](/(?:^|\n)[-*]\s*(?:forward)?\s*[:]?\s*\n?([\s\S]*?)(?=(?:\n[-*]\s*(?:forward|prev_node|threshold))|\n###|\n##|$)/gi);for(const z of v){const A=z[0x1],B=A['match'](/\s*name\s*[:]\s*(.+?)(?:\n|$)/im),C=A['match'](/\s*weight\s*[:]\s*(\d+)/i);if(B&&C){const D={'name':B[0x1]['trim'](),'weight':parseInt(C[0x1],0xa)},E=A['match'](/\s*namedOperator\s*[:]\s*(.+?)(?:\n|$)/im),F=A['match'](/\s*permissionIndex\s*[:]\s*(\d+)/i),G=A['match'](/\s*guard\s*[:]\s*(.+?)(?:\n|$)/im);E&&(D['namedOperator']=E[0x1]['trim']()),F&&(D['permissionIndex']=parseInt(F[0x1],0xa)),G&&(D['guard']=G[0x1]['trim']()),t['forwards']['push'](D);}}o['pairs']['push'](t);}f['push'](o);}return f['length']>0x0&&(d['nodes']=f),{'data':d,'errors':b};}function formatZodPath(a){return'/'+a['map'](b=>String(b)['replace'](/~/g,'~0')['replace'](/\//g,'~1'))['join']('/');}function parseJsonWithErrors(a){const b=[];try{const c=JSON['parse'](a);return{'data':c,'errors':[]};}catch(d){const f=d,g=f['message']['match'](/position\s+(\d+)/);let h=0x1,i=0x1;if(g){const j=parseInt(g[0x1],0xa),k=a['substring'](0x0,j)['split']('\x0a');h=k['length'],i=k[k['length']-0x1]['length']+0x1;}return b['push']({'message':'JSON\x20parse\x20error:\x20'+f['message'],'path':'/','line':h,'column':i}),{'data':null,'errors':b};}}function validateWithZod(a,b,c=''){const d=[],e=a['safeParse'](b);if(e['success'])return{'success':!![],'data':e['data'],'errors':[]};for(const f of e['error']['issues']){const g=c+formatZodPath(f['path']);d['push']({'message':f['message'],'path':g});}return{'success':![],'errors':d};}export function parseNodeFromText(a){const b=a['trim'](),c=detectFormat(b);let d,e=[];if(c==='markdown'){const g=parseMarkdownToNodeData(b);if(g['errors']['length']>0x0)return{'success':![],'errors':g['errors']};d=g['data'];}else{const h=parseJsonWithErrors(b);if(h['errors']['length']>0x0)return{'success':![],'errors':h['errors']};d=h['data'];}const f=validateWithZod(NodeSchema,d);return{'success':f['success'],'data':f['data'],'errors':f['errors']};}export function parseMachineNodesFromText(a){const b=a['trim'](),c=detectFormat(b);let d,e=[];if(c==='markdown'){const h=parseMarkdownToNodeData(b);if(h['errors']['length']>0x0)return{'success':![],'errors':h['errors']};typeof h['data']==='object'&&h['data']!==null&&'nodes'in h['data']?d=h['data']['nodes']:d=h['data'];}else{const j=parseJsonWithErrors(b);if(j['errors']['length']>0x0)return{'success':![],'errors':j['errors']};d=j['data'];}if(!Array['isArray'](d)){if(typeof d==='object'&&d!==null&&'op'in d)return{'success':![],'errors':[{'message':'Expected\x20JSON\x20array\x20of\x20nodes\x20for\x20json_or_markdown\x20mode.\x20Use\x20schema\x20mode\x20for\x20operations\x20with\x20\x22op\x22\x20field.','path':'/'}]};return{'success':![],'errors':[{'message':'Expected\x20JSON\x20array\x20of\x20nodes','path':'/'}]};}const f=[];for(let k=0x0;k<d['length'];k++){const l=d[k],m=validateWithZod(MachineNodeSchema,l,'/'+k);m['success']&&m['data']?f['push'](m['data']):e['push'](...m['errors']);}if(e['length']>0x0)return{'success':![],'errors':e};const g=f['some'](n=>n['pairs']['some'](o=>o['prev_node']===''));if(!g)return{'success':![],'errors':[{'message':'Machine\x20has\x20no\x20entry\x20forward.\x20At\x20least\x20one\x20node\x20must\x20have\x20a\x20pair\x20with\x20prev_node=\x22\x22\x20(empty\x20string),\x20'+'which\x20defines\x20how\x20Progress\x20advances\x20from\x20the\x20initial\x20state\x20(current=\x22\x22)\x20to\x20the\x20first\x20node.\x20'+'Without\x20an\x20entry\x20forward,\x20the\x20workflow\x20will\x20be\x20permanently\x20stuck.\x20'+'Example:\x20{name:\x20\x22Subscribed\x22,\x20pairs:\x20[{prev_node:\x20\x22\x22,\x20forwards:\x20[{name:\x20\x22Subscribe\x22,\x20weight:\x201}]}]}','path':'/'}]};return{'success':!![],'data':f,'errors':[]};}export function formatNodeErrors(a){return a['map'](b=>{let c='Path:\x20'+b['path'];return b['line']!==undefined&&b['column']!==undefined&&(c+='\x20(line\x20'+b['line']+',\x20column\x20'+b['column']+')'),c+='\x0a\x20\x20Error:\x20'+b['message'],c;})['join']('\x0a\x0a');}export function validateMachineNode(a){return validateWithZod(MachineNodeSchema,a);}export function validateMachineNodePair(a){const b=MachineNodePairSchema['safeParse'](a);if(b['success'])return{'success':!![],'errors':[]};const c=b['error']['issues']['map'](d=>({'message':d['message'],'path':formatZodPath(d['path'])}));return{'success':![],'errors':c};}export function validateMachineForward(a){const b=MachineForwardSchema['safeParse'](a);if(b['success'])return{'success':!![],'errors':[]};const c=b['error']['issues']['map'](d=>({'message':d['message'],'path':formatZodPath(d['path'])}));return{'success':![],'errors':c};}export function machineNodesToJson(a,b={}){const {machineId:c,includeComments:includeComments=!![]}=b;let d='';return includeComments&&c&&(d+='//\x20Machine\x20ID:\x20'+c+'\x0a'),d+=JSON['stringify'](a,null,0x2),d;}export function machineNodesToMarkdown(a,b={}){const {machineName:c,machineAddress:d,machineId:e,includeComments:includeComments=!![]}=b;let f='#\x20Machine\x20Node\x20Definition\x0a\x0a';c&&(f+='**Machine:**\x20'+c+'\x0a\x0a');d&&(f+='**Address:**\x20'+d+'\x0a\x0a');e&&(f+='**ID:**\x20'+e+'\x0a\x0a');f+='**Total\x20Nodes:**\x20'+a['length']+'\x0a\x0a',f+='---\x0a\x0a';for(const g of a){f+='##\x20Node:\x20'+g['name']+'\x0a\x0a';includeComments&&(f+='<!--\x20Node\x20definition\x20with\x20pairs\x20and\x20forwards\x20-->\x0a\x0a');for(const h of g['pairs']){f+='###\x20Pair:\x20'+h['prev_node']+'\x0a\x0a',f+='-\x20**prev_node**:\x20'+h['prev_node']+'\x0a',f+='-\x20**threshold**:\x20'+h['threshold']+'\x0a\x0a';if(h['forwards']&&h['forwards']['length']>0x0){f+='####\x20Forwards\x0a\x0a',f+='|\x20name\x20|\x20weight\x20|\x20namedOperator\x20|\x20permissionIndex\x20|\x20guard\x20|\x0a',f+='|------|--------|---------------|-----------------|-------|\x0a';for(const i of h['forwards']){const j=i['namedOperator']||'',k=i['permissionIndex']?.['toString']()||'',l=i['guard'],m=typeof l==='string'?l:l?.['guard']||'';f+='|\x20'+i['name']+'\x20|\x20'+i['weight']+'\x20|\x20'+j+'\x20|\x20'+k+'\x20|\x20'+m+'\x20|\x0a';}f+='\x0a';}}f+='---\x0a\x0a';}return f+='##\x20JSON\x20Definition\x0a\x0a',includeComments&&(f+='<!--\x20You\x20can\x20also\x20use\x20the\x20JSON\x20format\x20below\x20-->\x0a\x0a'),f+='```json\x0a',includeComments&&e&&(f+='//\x20Machine\x20ID:\x20'+e+'\x0a'),f+=JSON['stringify'](a,null,0x2),f+='\x0a```\x0a',f;}export function saveMachineNodesToFile(a,b,c='json',d={}){const e=c==='json'?machineNodesToJson(a,d):machineNodesToMarkdown(a,d);writeFileSync(b,e,'utf-8');}
@@ -1,35 +1 @@
1
- export function shortTypeName(objectType) {
2
- if (!objectType)
3
- return "unknown";
4
- const base = objectType.replace(/<.*>/, "").trim();
5
- const segments = base.split("::");
6
- const shortName = segments[segments.length - 1] || "unknown";
7
- if (shortName.length > 0 && shortName === shortName.toLowerCase()) {
8
- return shortName.charAt(0).toUpperCase() + shortName.slice(1);
9
- }
10
- return shortName;
11
- }
12
- export function normalizeObjectType(objectType) {
13
- return shortTypeName(objectType).toLowerCase();
14
- }
15
- export function isObjectOfType(objectType, expectedShortName) {
16
- const normalized = normalizeObjectType(objectType);
17
- const expected = expectedShortName.toLowerCase();
18
- return normalized === expected;
19
- }
20
- export function groupObjectsByType(objects) {
21
- const byType = new Map();
22
- for (const obj of objects) {
23
- const t = shortTypeName(obj.objectType);
24
- if (!byType.has(t))
25
- byType.set(t, []);
26
- byType.get(t).push(obj);
27
- }
28
- return byType;
29
- }
30
- export function findObjectByType(objects, expectedShortName) {
31
- return objects.find(o => isObjectOfType(o.objectType, expectedShortName));
32
- }
33
- export function countObjectsByType(objects, expectedShortName) {
34
- return objects.filter(o => isObjectOfType(o.objectType, expectedShortName)).length;
35
- }
1
+ export function shortTypeName(a){if(!a)return'unknown';const b=a['replace'](/<.*>/,'')['trim'](),c=b['split']('::'),d=c[c['length']-0x1]||'unknown';if(d['length']>0x0&&d===d['toLowerCase']())return d['charAt'](0x0)['toUpperCase']()+d['slice'](0x1);return d;}export function normalizeObjectType(a){return shortTypeName(a)['toLowerCase']();}export function isObjectOfType(a,b){const c=normalizeObjectType(a),d=b['toLowerCase']();return c===d;}export function groupObjectsByType(a){const b=new Map();for(const c of a){const d=shortTypeName(c['objectType']);if(!b['has'](d))b['set'](d,[]);b['get'](d)['push'](c);}return b;}export function findObjectByType(a,b){return a['find'](c=>isObjectOfType(c['objectType'],b));}export function countObjectsByType(a,b){return a['filter'](c=>isObjectOfType(c['objectType'],b))['length'];}
@@ -1,7 +1 @@
1
- import { BuiltinPermissionIndex } from "@wowok/wowok";
2
- export const getValidBuiltinPermissionIndexes = () => {
3
- return new Set(Object.values(BuiltinPermissionIndex).filter(value => typeof value === 'number'));
4
- };
5
- export const isValidPermissionIndex = (index) => {
6
- return getValidBuiltinPermissionIndexes().has(index) || (index >= 1000 && index <= 65535);
7
- };
1
+ import{BuiltinPermissionIndex}from'@wowok/wowok';export const getValidBuiltinPermissionIndexes=()=>{return new Set(Object['values'](BuiltinPermissionIndex)['filter'](a=>typeof a==='number'));};export const isValidPermissionIndex=a=>{return getValidBuiltinPermissionIndexes()['has'](a)||a>=0x3e8&&a<=0xffff;};
@@ -1,121 +1 @@
1
- export function collectPermissionIndexes(nodes) {
2
- const indexRefs = [];
3
- const namedRefs = [];
4
- const missingRefs = [];
5
- const requiredIndexSet = new Set();
6
- for (const node of nodes) {
7
- if (!node.pairs)
8
- continue;
9
- for (const pair of node.pairs) {
10
- if (!pair.forwards)
11
- continue;
12
- for (const forward of pair.forwards) {
13
- const ref = {
14
- nodeName: node.name,
15
- prevNode: pair.prev_node,
16
- forwardName: forward.name,
17
- permissionIndex: forward.permissionIndex ?? null,
18
- namedOperator: forward.namedOperator ?? null,
19
- };
20
- if (ref.permissionIndex != null) {
21
- indexRefs.push(ref);
22
- requiredIndexSet.add(ref.permissionIndex);
23
- }
24
- else if (ref.namedOperator != null && ref.namedOperator !== "") {
25
- namedRefs.push(ref);
26
- }
27
- else {
28
- missingRefs.push(ref);
29
- }
30
- }
31
- }
32
- }
33
- return {
34
- indexRefs,
35
- namedRefs,
36
- missingRefs,
37
- requiredIndexes: Array.from(requiredIndexSet).sort((a, b) => a - b),
38
- };
39
- }
40
- export function checkPermissionAuthorization(requiredIndexes, permission) {
41
- const BUILTIN_THRESHOLD = 1000;
42
- const statuses = [];
43
- const missingIndexes = [];
44
- const authorizedIndexes = [];
45
- for (const index of requiredIndexes) {
46
- if (index < BUILTIN_THRESHOLD) {
47
- statuses.push({ index, authorized: true, entityCount: -1 });
48
- authorizedIndexes.push(index);
49
- continue;
50
- }
51
- let authorized = false;
52
- let entityCount = 0;
53
- if (permission?.entityPermissions) {
54
- for (const perms of permission.entityPermissions.values()) {
55
- if (perms.includes(index)) {
56
- entityCount++;
57
- }
58
- }
59
- authorized = entityCount > 0;
60
- }
61
- else if (permission?.perm_remark && permission.perm_remark.length > 0) {
62
- authorized = permission.perm_remark.some(r => r.index === index);
63
- entityCount = authorized ? -1 : 0;
64
- }
65
- else {
66
- authorized = true;
67
- entityCount = -1;
68
- }
69
- statuses.push({ index, authorized, entityCount });
70
- if (authorized) {
71
- authorizedIndexes.push(index);
72
- }
73
- else {
74
- missingIndexes.push(index);
75
- }
76
- }
77
- const allAuthorized = missingIndexes.length === 0;
78
- const summary = allAuthorized
79
- ? `All ${requiredIndexes.length} required permission index(es) are authorized.`
80
- : `${missingIndexes.length}/${requiredIndexes.length} required permission index(es) are NOT authorized: [${missingIndexes.join(", ")}]. ` +
81
- `Forwards using these indexes will be un-executable — Progress will be stuck. ` +
82
- `Grant entities for these indexes via permission.op="add perm by index" before publishing the Machine.`;
83
- return {
84
- statuses,
85
- missingIndexes,
86
- authorizedIndexes,
87
- allAuthorized,
88
- summary,
89
- };
90
- }
91
- export function formatPermissionWarning(report) {
92
- if (report.allAuthorized) {
93
- return "";
94
- }
95
- const lines = [
96
- "CRITICAL PRE-PUBLISH: Machine forwards reference permission indexes that are NOT authorized in the Permission object.",
97
- "",
98
- `Missing indexes (no entities granted): ${report.missingIndexes.join(", ")}`,
99
- "",
100
- "Impact: Forwards using these indexes can NEVER be executed — Progress will be permanently stuck at the source node.",
101
- "Buyer funds may be trapped if the workflow cannot advance past the stuck node.",
102
- "",
103
- "To fix BEFORE publishing:",
104
- ' 1. Call onchain_operations with op="permission"',
105
- ' 2. Set object=<your_permission_name_or_address>',
106
- ' 3. Set permission.op="add perm by index"',
107
- " 4. Set index=<missing_index> for each missing index",
108
- ' 5. Set entity=["<entity_address>"] — the address that should be authorized',
109
- " 6. After granting all missing indexes, re-attempt the Machine publish.",
110
- "",
111
- "Required permission indexes for this Machine:",
112
- ];
113
- for (const status of report.statuses) {
114
- const state = status.authorized ? "AUTHORIZED" : "MISSING";
115
- const count = status.entityCount === -1
116
- ? "(built-in or heuristic)"
117
- : `(${status.entityCount} entity/entities)`;
118
- lines.push(` - Index ${status.index}: ${state} ${count}`);
119
- }
120
- return lines.join("\n");
121
- }
1
+ export function collectPermissionIndexes(a){const b=[],c=[],d=[],e=new Set();for(const f of a){if(!f['pairs'])continue;for(const g of f['pairs']){if(!g['forwards'])continue;for(const h of g['forwards']){const i={'nodeName':f['name'],'prevNode':g['prev_node'],'forwardName':h['name'],'permissionIndex':h['permissionIndex']??null,'namedOperator':h['namedOperator']??null};if(i['permissionIndex']!=null)b['push'](i),e['add'](i['permissionIndex']);else i['namedOperator']!=null&&i['namedOperator']!==''?c['push'](i):d['push'](i);}}}return{'indexRefs':b,'namedRefs':c,'missingRefs':d,'requiredIndexes':Array['from'](e)['sort']((j,k)=>j-k)};}export function checkPermissionAuthorization(a,b){const c=0x3e8,d=[],e=[],f=[];for(const i of a){if(i<c){d['push']({'index':i,'authorized':!![],'entityCount':-0x1}),f['push'](i);continue;}let j=![],k=0x0;if(b?.['entityPermissions']){for(const l of b['entityPermissions']['values']()){l['includes'](i)&&k++;}j=k>0x0;}else b?.['perm_remark']&&b['perm_remark']['length']>0x0?(j=b['perm_remark']['some'](m=>m['index']===i),k=j?-0x1:0x0):(j=!![],k=-0x1);d['push']({'index':i,'authorized':j,'entityCount':k}),j?f['push'](i):e['push'](i);}const g=e['length']===0x0,h=g?'All\x20'+a['length']+'\x20required\x20permission\x20index(es)\x20are\x20authorized.':e['length']+'/'+a['length']+'\x20required\x20permission\x20index(es)\x20are\x20NOT\x20authorized:\x20['+e['join'](',\x20')+'].\x20'+'Forwards\x20using\x20these\x20indexes\x20will\x20be\x20un-executable\x20—\x20Progress\x20will\x20be\x20stuck.\x20'+'Grant\x20entities\x20for\x20these\x20indexes\x20via\x20permission.op=\x22add\x20perm\x20by\x20index\x22\x20before\x20publishing\x20the\x20Machine.';return{'statuses':d,'missingIndexes':e,'authorizedIndexes':f,'allAuthorized':g,'summary':h};}export function formatPermissionWarning(a){if(a['allAuthorized'])return'';const b=['CRITICAL\x20PRE-PUBLISH:\x20Machine\x20forwards\x20reference\x20permission\x20indexes\x20that\x20are\x20NOT\x20authorized\x20in\x20the\x20Permission\x20object.','','Missing\x20indexes\x20(no\x20entities\x20granted):\x20'+a['missingIndexes']['join'](',\x20'),'','Impact:\x20Forwards\x20using\x20these\x20indexes\x20can\x20NEVER\x20be\x20executed\x20—\x20Progress\x20will\x20be\x20permanently\x20stuck\x20at\x20the\x20source\x20node.','Buyer\x20funds\x20may\x20be\x20trapped\x20if\x20the\x20workflow\x20cannot\x20advance\x20past\x20the\x20stuck\x20node.','','To\x20fix\x20BEFORE\x20publishing:','\x20\x201.\x20Call\x20onchain_operations\x20with\x20op=\x22permission\x22','\x20\x202.\x20Set\x20object=<your_permission_name_or_address>','\x20\x203.\x20Set\x20permission.op=\x22add\x20perm\x20by\x20index\x22','\x20\x204.\x20Set\x20index=<missing_index>\x20for\x20each\x20missing\x20index','\x20\x205.\x20Set\x20entity=[\x22<entity_address>\x22]\x20—\x20the\x20address\x20that\x20should\x20be\x20authorized','\x20\x206.\x20After\x20granting\x20all\x20missing\x20indexes,\x20re-attempt\x20the\x20Machine\x20publish.','','Required\x20permission\x20indexes\x20for\x20this\x20Machine:'];for(const c of a['statuses']){const d=c['authorized']?'AUTHORIZED':'MISSING',e=c['entityCount']===-0x1?'(built-in\x20or\x20heuristic)':'('+c['entityCount']+'\x20entity/entities)';b['push']('\x20\x20-\x20Index\x20'+c['index']+':\x20'+d+'\x20'+e);}return b['join']('\x0a');}
@@ -1,77 +1 @@
1
- const SKILLS_BY_OPERATION_TYPE = {
2
- service: ["wowok-provider", "wowok-safety"],
3
- machine: ["wowok-machine"],
4
- guard: ["wowok-guard"],
5
- arbitration: ["wowok-arbitrator"],
6
- allocation: ["wowok-provider"],
7
- permission: ["wowok-safety"],
8
- treasury: ["wowok-provider", "wowok-safety"],
9
- reward: ["wowok-provider"],
10
- repository: ["wowok-provider"],
11
- demand: ["wowok-provider"],
12
- contact: ["wowok-messenger"],
13
- order: ["wowok-order"],
14
- progress: [],
15
- personal: [],
16
- payment: [],
17
- proof: [],
18
- };
19
- const SKILLS_BY_PROJECT_ACTION = {
20
- create_project: ["wowok-onboard", "wowok-planner"],
21
- create_project_from_onchain: ["wowok-onboard"],
22
- evaluate_project: ["wowok-auditor"],
23
- pre_evaluate_check: ["wowok-auditor"],
24
- verify_deployment: ["wowok-auditor"],
25
- generate_deployment_doc: ["wowok-planner"],
26
- migrate_to_mainnet: ["wowok-onboard", "wowok-safety"],
27
- migrate_network: ["wowok-onboard"],
28
- clone_project_to_network: ["wowok-onboard"],
29
- build_graph: ["wowok-planner"],
30
- list_projects: [],
31
- get_project_detail: [],
32
- update_project: [],
33
- add_object: [],
34
- remove_object: [],
35
- update_object: [],
36
- create_version: [],
37
- get_graph: [],
38
- save_evaluation: [],
39
- compare_projects: [],
40
- refresh_objects: [],
41
- get_object_diff: [],
42
- delete_project: [],
43
- assemble_context: [],
44
- get_machine_graph: ["wowok-machine"],
45
- get_guard_graph: ["wowok-guard"],
46
- plan_object_edit: ["wowok-machine", "wowok-guard", "wowok-auditor"],
47
- apply_object_edit: ["wowok-safety"],
48
- patch_machine_nodes: ["wowok-machine"],
49
- patch_guard_tree: ["wowok-guard"],
50
- participation_radar: ["wowok-order", "wowok-messenger"],
51
- };
52
- export function getSkillsHintForOnchain(operationType, data) {
53
- const skills = SKILLS_BY_OPERATION_TYPE[operationType];
54
- if (!skills || skills.length === 0)
55
- return undefined;
56
- const isPublish = data?.publish === true;
57
- const hasOrderAllocators = !!data?.order_allocators;
58
- const isComplex = isPublish || hasOrderAllocators;
59
- const prefix = isComplex
60
- ? "SKILLS RECOMMENDED (complex operation — skills provide business-semantic guidance):"
61
- : "SKILLS RECOMMENDED (optional — skills provide deeper guidance):";
62
- return `${prefix} ${skills.join(", ")}. ` +
63
- `skills focus on business intent → object parameter translation; ` +
64
- `MCP handles object structure and on-chain execution. ` +
65
- `If skills are installed, consult them BEFORE this call for design rationale. ` +
66
- `If not installed, MCP executes independently — this hint is informational only.`;
67
- }
68
- export function getSkillsHintForProject(action) {
69
- const skills = SKILLS_BY_PROJECT_ACTION[action];
70
- if (!skills || skills.length === 0)
71
- return undefined;
72
- return `SKILLS RECOMMENDED (optional — skills provide deeper guidance): ${skills.join(", ")}. ` +
73
- `skills focus on business intent → object parameter translation; ` +
74
- `MCP handles project structure and evaluation. ` +
75
- `If skills are installed, consult them for design/planning rationale. ` +
76
- `If not installed, MCP executes independently — this hint is informational only.`;
77
- }
1
+ const SKILLS_BY_OPERATION_TYPE={'service':['wowok-provider','wowok-safety'],'machine':['wowok-machine'],'guard':['wowok-guard'],'arbitration':['wowok-arbitrator'],'allocation':['wowok-provider'],'permission':['wowok-safety'],'treasury':['wowok-provider','wowok-safety'],'reward':['wowok-provider'],'repository':['wowok-provider'],'demand':['wowok-provider','wowok-supplier'],'contact':['wowok-messenger'],'order':['wowok-order'],'progress':['wowok-collaborator'],'personal':[],'payment':[],'proof':[]},SKILLS_BY_PROJECT_ACTION={'create_project':['wowok-onboard','wowok-planner'],'create_project_from_onchain':['wowok-onboard'],'evaluate_project':['wowok-auditor'],'pre_evaluate_check':['wowok-auditor'],'verify_deployment':['wowok-auditor'],'generate_deployment_doc':['wowok-planner'],'migrate_to_mainnet':['wowok-onboard','wowok-safety'],'migrate_network':['wowok-onboard'],'clone_project_to_network':['wowok-onboard'],'build_graph':['wowok-planner'],'list_projects':[],'get_project_detail':[],'update_project':[],'add_object':[],'remove_object':[],'update_object':[],'create_version':[],'get_graph':[],'save_evaluation':[],'compare_projects':[],'refresh_objects':[],'get_object_diff':[],'delete_project':[],'assemble_context':[],'get_machine_graph':['wowok-machine'],'get_guard_graph':['wowok-guard'],'plan_object_edit':['wowok-machine','wowok-guard','wowok-auditor'],'apply_object_edit':['wowok-safety'],'patch_machine_nodes':['wowok-machine'],'patch_guard_tree':['wowok-guard'],'participation_radar':['wowok-order','wowok-supplier','wowok-collaborator','wowok-messenger']};export function getSkillsHintForOnchain(a,b){const c=SKILLS_BY_OPERATION_TYPE[a];if(!c||c['length']===0x0)return undefined;const d=b?.['publish']===!![],e=!!b?.['order_allocators'],f=d||e,g=f?'SKILLS\x20RECOMMENDED\x20(complex\x20operation\x20—\x20skills\x20provide\x20business-semantic\x20guidance):':'SKILLS\x20RECOMMENDED\x20(optional\x20—\x20skills\x20provide\x20deeper\x20guidance):';return g+'\x20'+c['join'](',\x20')+'.\x20'+'skills\x20focus\x20on\x20business\x20intent\x20→\x20object\x20parameter\x20translation;\x20'+'MCP\x20handles\x20object\x20structure\x20and\x20on-chain\x20execution.\x20'+'If\x20skills\x20are\x20installed,\x20consult\x20them\x20BEFORE\x20this\x20call\x20for\x20design\x20rationale.\x20'+'If\x20not\x20installed,\x20MCP\x20executes\x20independently\x20—\x20this\x20hint\x20is\x20informational\x20only.';}export function getSkillsHintForProject(a){const b=SKILLS_BY_PROJECT_ACTION[a];if(!b||b['length']===0x0)return undefined;return'SKILLS\x20RECOMMENDED\x20(optional\x20—\x20skills\x20provide\x20deeper\x20guidance):\x20'+b['join'](',\x20')+'.\x20'+'skills\x20focus\x20on\x20business\x20intent\x20→\x20object\x20parameter\x20translation;\x20'+'MCP\x20handles\x20project\x20structure\x20and\x20evaluation.\x20'+'If\x20skills\x20are\x20installed,\x20consult\x20them\x20for\x20design/planning\x20rationale.\x20'+'If\x20not\x20installed,\x20MCP\x20executes\x20independently\x20—\x20this\x20hint\x20is\x20informational\x20only.';}