@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 +1 @@
1
- export {};
1
+ export{};
@@ -1,68 +1 @@
1
- import { getHarnessTier, setHarnessTier } from "../config/runtime.js";
2
- const state = {
3
- current_tier: "lightweight",
4
- history: [],
5
- recent_failures: [],
6
- };
7
- const REPEATED_FAILURE_WINDOW_MS = 60_000;
8
- const REPEATED_FAILURE_THRESHOLD = 3;
9
- export function isFullTier(tier) {
10
- return tier === "full";
11
- }
12
- export function shouldRunHeavyHooks() {
13
- return isFullTier(getHarnessTier());
14
- }
15
- export function shouldRunLightHooks() {
16
- const tier = getHarnessTier();
17
- return tier === "lightweight" || tier === "full";
18
- }
19
- export function recordCriticalRisk(description) {
20
- return escalate("E1_CRITICAL_RISK", `CRITICAL risk detected: ${description}`);
21
- }
22
- export function recordCriticalOperation(operation, errorCode) {
23
- return escalate("E2_OPERATION_CRITICAL", `Operation '${operation}' returned CRITICAL error: ${errorCode}`);
24
- }
25
- export function recordSubstepFailure(detail) {
26
- return escalate("E3_SUBSTEP_FAILURE", `Substep trace reported failure: ${detail}`);
27
- }
28
- export function recordOperationFailure(operation, errorCode) {
29
- const now = Date.now();
30
- state.recent_failures.push({ timestamp: now, operation, error_code: errorCode });
31
- state.recent_failures = state.recent_failures.filter((f) => now - f.timestamp <= REPEATED_FAILURE_WINDOW_MS);
32
- if (state.recent_failures.length >= REPEATED_FAILURE_THRESHOLD) {
33
- const summary = state.recent_failures
34
- .map((f) => `${f.operation}:${f.error_code}`)
35
- .join(", ");
36
- return escalate("E4_REPEATED_FAILURE", `Repeated failures (${state.recent_failures.length} in ${REPEATED_FAILURE_WINDOW_MS / 1000}s): ${summary}`);
37
- }
38
- return null;
39
- }
40
- export function getEscalationState() {
41
- return {
42
- current_tier: getHarnessTier(),
43
- history: [...state.history],
44
- recent_failures: [...state.recent_failures],
45
- };
46
- }
47
- export function resetEscalation() {
48
- state.history = [];
49
- state.recent_failures = [];
50
- setHarnessTier("lightweight");
51
- state.current_tier = "lightweight";
52
- }
53
- function escalate(trigger, reason) {
54
- const fromTier = getHarnessTier();
55
- if (fromTier !== "lightweight")
56
- return null;
57
- const event = {
58
- trigger,
59
- timestamp: new Date().toISOString(),
60
- reason,
61
- from_tier: fromTier,
62
- to_tier: "full",
63
- };
64
- setHarnessTier("full");
65
- state.current_tier = "full";
66
- state.history.push(event);
67
- return event;
68
- }
1
+ import{getHarnessTier,setHarnessTier}from'../config/runtime.js';const state={'current_tier':'lightweight','history':[],'recent_failures':[]},REPEATED_FAILURE_WINDOW_MS=0xea60,REPEATED_FAILURE_THRESHOLD=0x3;export function isFullTier(a){return a==='full';}export function shouldRunHeavyHooks(){return isFullTier(getHarnessTier());}export function shouldRunLightHooks(){const a=getHarnessTier();return a==='lightweight'||a==='full';}export function recordCriticalRisk(a){return escalate('E1_CRITICAL_RISK','CRITICAL\x20risk\x20detected:\x20'+a);}export function recordCriticalOperation(a,b){return escalate('E2_OPERATION_CRITICAL','Operation\x20\x27'+a+'\x27\x20returned\x20CRITICAL\x20error:\x20'+b);}export function recordSubstepFailure(a){return escalate('E3_SUBSTEP_FAILURE','Substep\x20trace\x20reported\x20failure:\x20'+a);}export function recordOperationFailure(a,b){const c=Date['now']();state['recent_failures']['push']({'timestamp':c,'operation':a,'error_code':b}),state['recent_failures']=state['recent_failures']['filter'](d=>c-d['timestamp']<=REPEATED_FAILURE_WINDOW_MS);if(state['recent_failures']['length']>=REPEATED_FAILURE_THRESHOLD){const d=state['recent_failures']['map'](e=>e['operation']+':'+e['error_code'])['join'](',\x20');return escalate('E4_REPEATED_FAILURE','Repeated\x20failures\x20('+state['recent_failures']['length']+'\x20in\x20'+REPEATED_FAILURE_WINDOW_MS/0x3e8+'s):\x20'+d);}return null;}export function getEscalationState(){return{'current_tier':getHarnessTier(),'history':[...state['history']],'recent_failures':[...state['recent_failures']]};}export function resetEscalation(){state['history']=[],state['recent_failures']=[],setHarnessTier('lightweight'),state['current_tier']='lightweight';}function escalate(a,b){const c=getHarnessTier();if(c!=='lightweight')return null;const d={'trigger':a,'timestamp':new Date()['toISOString'](),'reason':b,'from_tier':c,'to_tier':'full'};return setHarnessTier('full'),state['current_tier']='full',state['history']['push'](d),d;}
@@ -1,129 +1 @@
1
- import { existsSync, mkdirSync, writeFileSync, readFileSync, readdirSync, unlinkSync, openSync, closeSync } from "fs";
2
- import { join } from "path";
3
- import { getWowMcpDir } from "@wowok/wowok";
4
- const CHECKPOINT_ROOT = join(getWowMcpDir(), "checkpoints");
5
- function getTaskDir(taskId) {
6
- return join(CHECKPOINT_ROOT, taskId);
7
- }
8
- function getCheckpointPath(taskId, checkpointId) {
9
- return join(getTaskDir(taskId), `${checkpointId}.json`);
10
- }
11
- function getLatestPath(taskId) {
12
- return join(getTaskDir(taskId), "latest.json");
13
- }
14
- function acquireLock(filePath) {
15
- const lockPath = filePath + ".lock";
16
- try {
17
- const fd = openSync(lockPath, "wx");
18
- closeSync(fd);
19
- return true;
20
- }
21
- catch {
22
- return false;
23
- }
24
- }
25
- function releaseLock(filePath) {
26
- const lockPath = filePath + ".lock";
27
- try {
28
- unlinkSync(lockPath);
29
- }
30
- catch {
31
- }
32
- }
33
- export function saveCheckpoint(cp) {
34
- const taskDir = getTaskDir(cp.task_id);
35
- if (!existsSync(taskDir)) {
36
- mkdirSync(taskDir, { recursive: true });
37
- }
38
- const cpPath = getCheckpointPath(cp.task_id, cp.checkpoint_id);
39
- const latestPath = getLatestPath(cp.task_id);
40
- if (!acquireLock(cpPath)) {
41
- throw new Error(`Cannot acquire lock for checkpoint ${cp.checkpoint_id} — another process may be writing`);
42
- }
43
- try {
44
- writeFileSync(cpPath, JSON.stringify(cp, null, 2), "utf8");
45
- writeFileSync(latestPath, JSON.stringify(cp, null, 2), "utf8");
46
- }
47
- finally {
48
- releaseLock(cpPath);
49
- }
50
- }
51
- export function loadCheckpoint(taskId, checkpointId) {
52
- const cpPath = getCheckpointPath(taskId, checkpointId);
53
- if (!existsSync(cpPath))
54
- return null;
55
- try {
56
- const raw = readFileSync(cpPath, "utf8");
57
- return JSON.parse(raw);
58
- }
59
- catch {
60
- return null;
61
- }
62
- }
63
- export function loadLatestCheckpoint(taskId) {
64
- const latestPath = getLatestPath(taskId);
65
- if (!existsSync(latestPath))
66
- return null;
67
- try {
68
- const raw = readFileSync(latestPath, "utf8");
69
- return JSON.parse(raw);
70
- }
71
- catch {
72
- return null;
73
- }
74
- }
75
- export function listCheckpoints(taskId) {
76
- const taskDir = getTaskDir(taskId);
77
- if (!existsSync(taskDir))
78
- return [];
79
- const files = readdirSync(taskDir)
80
- .filter((f) => f.endsWith(".json") && f !== "latest.json")
81
- .sort();
82
- return files
83
- .map((f) => {
84
- try {
85
- const raw = readFileSync(join(taskDir, f), "utf8");
86
- return JSON.parse(raw);
87
- }
88
- catch {
89
- return null;
90
- }
91
- })
92
- .filter((cp) => cp !== null);
93
- }
94
- export function listTasks() {
95
- if (!existsSync(CHECKPOINT_ROOT))
96
- return [];
97
- return readdirSync(CHECKPOINT_ROOT, { withFileTypes: true })
98
- .filter((d) => d.isDirectory())
99
- .map((d) => d.name);
100
- }
101
- export function deleteCheckpoint(taskId, checkpointId) {
102
- const cpPath = getCheckpointPath(taskId, checkpointId);
103
- if (existsSync(cpPath)) {
104
- if (!acquireLock(cpPath)) {
105
- throw new Error(`Cannot acquire lock for deletion of ${checkpointId}`);
106
- }
107
- try {
108
- unlinkSync(cpPath);
109
- }
110
- finally {
111
- releaseLock(cpPath);
112
- }
113
- }
114
- }
115
- export function createCheckpoint(taskId, phase, phaseStatus, odgSnapshot, userDecisions, operationLog, nextPhase, semanticSummary) {
116
- const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
117
- return {
118
- checkpoint_id: `CP-${phase.replace(/\s+/g, "")}-${phaseStatus}-${timestamp}`,
119
- task_id: taskId,
120
- timestamp: new Date().toISOString(),
121
- phase,
122
- phase_status: phaseStatus,
123
- odg_snapshot: odgSnapshot,
124
- user_decisions: userDecisions,
125
- operation_log: operationLog,
126
- next_phase: nextPhase,
127
- semantic_summary: semanticSummary,
128
- };
129
- }
1
+ import{existsSync,mkdirSync,writeFileSync,readFileSync,readdirSync,unlinkSync,openSync,closeSync}from'fs';import{join}from'path';import{getWowMcpDir}from'@wowok/wowok';const CHECKPOINT_ROOT=join(getWowMcpDir(),'checkpoints');function getTaskDir(a){return join(CHECKPOINT_ROOT,a);}function getCheckpointPath(a,b){return join(getTaskDir(a),b+'.json');}function getLatestPath(a){return join(getTaskDir(a),'latest.json');}function acquireLock(a){const b=a+'.lock';try{const c=openSync(b,'wx');return closeSync(c),!![];}catch{return![];}}function releaseLock(a){const b=a+'.lock';try{unlinkSync(b);}catch{}}export function saveCheckpoint(a){const b=getTaskDir(a['task_id']);!existsSync(b)&&mkdirSync(b,{'recursive':!![]});const c=getCheckpointPath(a['task_id'],a['checkpoint_id']),d=getLatestPath(a['task_id']);if(!acquireLock(c))throw new Error('Cannot\x20acquire\x20lock\x20for\x20checkpoint\x20'+a['checkpoint_id']+'\x20—\x20another\x20process\x20may\x20be\x20writing');try{writeFileSync(c,JSON['stringify'](a,null,0x2),'utf8'),writeFileSync(d,JSON['stringify'](a,null,0x2),'utf8');}finally{releaseLock(c);}}export function loadCheckpoint(a,b){const c=getCheckpointPath(a,b);if(!existsSync(c))return null;try{const d=readFileSync(c,'utf8');return JSON['parse'](d);}catch{return null;}}export function loadLatestCheckpoint(a){const b=getLatestPath(a);if(!existsSync(b))return null;try{const c=readFileSync(b,'utf8');return JSON['parse'](c);}catch{return null;}}export function listCheckpoints(a){const b=getTaskDir(a);if(!existsSync(b))return[];const c=readdirSync(b)['filter'](d=>d['endsWith']('.json')&&d!=='latest.json')['sort']();return c['map'](d=>{try{const e=readFileSync(join(b,d),'utf8');return JSON['parse'](e);}catch{return null;}})['filter'](d=>d!==null);}export function listTasks(){if(!existsSync(CHECKPOINT_ROOT))return[];return readdirSync(CHECKPOINT_ROOT,{'withFileTypes':!![]})['filter'](a=>a['isDirectory']())['map'](a=>a['name']);}export function deleteCheckpoint(a,b){const c=getCheckpointPath(a,b);if(existsSync(c)){if(!acquireLock(c))throw new Error('Cannot\x20acquire\x20lock\x20for\x20deletion\x20of\x20'+b);try{unlinkSync(c);}finally{releaseLock(c);}}}export function createCheckpoint(a,b,c,d,e,f,g,h){const i=new Date()['toISOString']()['replace'](/[:.]/g,'-');return{'checkpoint_id':'CP-'+b['replace'](/\s+/g,'')+'-'+c+'-'+i,'task_id':a,'timestamp':new Date()['toISOString'](),'phase':b,'phase_status':c,'odg_snapshot':d,'user_decisions':e,'operation_log':f,'next_phase':g,'semantic_summary':h};}
@@ -1,78 +1 @@
1
- export * from "./types.js";
2
- export * from "./plan.js";
3
- export * from "./verify.js";
4
- export * from "./recover.js";
5
- export * from "./checkpoint.js";
6
- import { classifyIntent, generateODG, identifyDecisionPoints, detectCycles, SCENARIO_REGISTRY, identifyMigrationDecisions } from "./plan.js";
7
- import { verify, generateExpected } from "./verify.js";
8
- import { recover, resetAttempts, getBackoffDelay, RECOVERY_RULES } from "./recover.js";
9
- import { saveCheckpoint, loadLatestCheckpoint, listCheckpoints, listTasks, createCheckpoint } from "./checkpoint.js";
10
- export class Harness {
11
- context = new Map();
12
- plan(userInput, taskId) {
13
- return generateODG(userInput, taskId);
14
- }
15
- classifyIntent(userInput) {
16
- return classifyIntent(userInput);
17
- }
18
- getDecisions(odg) {
19
- return identifyDecisionPoints(odg);
20
- }
21
- getMigrationDecisions(options) {
22
- return identifyMigrationDecisions(options);
23
- }
24
- detectCycles(odg) {
25
- return detectCycles(odg);
26
- }
27
- getScenarioRegistry() {
28
- return SCENARIO_REGISTRY;
29
- }
30
- expect(operation, intent, operationType, data) {
31
- return generateExpected(operation, intent, operationType, data);
32
- }
33
- verify(input) {
34
- return verify(input);
35
- }
36
- recover(errorCode, operationId, context) {
37
- return recover(errorCode, operationId, context);
38
- }
39
- resetRecovery(operationId) {
40
- resetAttempts(operationId);
41
- }
42
- getBackoffDelay(attempt) {
43
- return getBackoffDelay(attempt);
44
- }
45
- getRecoveryRules() {
46
- return RECOVERY_RULES;
47
- }
48
- checkpoint(taskId, phase, phaseStatus, odgSnapshot, userDecisions, operationLog, nextPhase, semanticSummary) {
49
- const cp = createCheckpoint(taskId, phase, phaseStatus, odgSnapshot, userDecisions, operationLog, nextPhase, semanticSummary);
50
- saveCheckpoint(cp);
51
- return cp;
52
- }
53
- loadCheckpoint(taskId) {
54
- return loadLatestCheckpoint(taskId);
55
- }
56
- listCheckpoints(taskId) {
57
- return listCheckpoints(taskId);
58
- }
59
- listTasks() {
60
- return listTasks();
61
- }
62
- setContext(key, value) {
63
- this.context.set(key, value);
64
- }
65
- getContext(key) {
66
- return this.context.get(key);
67
- }
68
- }
69
- let singleton = null;
70
- export function getHarness() {
71
- if (!singleton) {
72
- singleton = new Harness();
73
- }
74
- return singleton;
75
- }
76
- export function setHarness(h) {
77
- singleton = h;
78
- }
1
+ export*from'./types.js';export*from'./plan.js';export*from'./verify.js';export*from'./recover.js';export*from'./checkpoint.js';import{classifyIntent,generateODG,identifyDecisionPoints,detectCycles,SCENARIO_REGISTRY,identifyMigrationDecisions}from'./plan.js';import{verify,generateExpected}from'./verify.js';import{recover,resetAttempts,getBackoffDelay,RECOVERY_RULES}from'./recover.js';import{saveCheckpoint,loadLatestCheckpoint,listCheckpoints,listTasks,createCheckpoint}from'./checkpoint.js';export class Harness{['context']=new Map();['plan'](a,b){return generateODG(a,b);}['classifyIntent'](a){return classifyIntent(a);}['getDecisions'](a){return identifyDecisionPoints(a);}['getMigrationDecisions'](a){return identifyMigrationDecisions(a);}['detectCycles'](a){return detectCycles(a);}['getScenarioRegistry'](){return SCENARIO_REGISTRY;}['expect'](a,b,c,d){return generateExpected(a,b,c,d);}['verify'](a){return verify(a);}['recover'](a,b,c){return recover(a,b,c);}['resetRecovery'](a){resetAttempts(a);}['getBackoffDelay'](a){return getBackoffDelay(a);}['getRecoveryRules'](){return RECOVERY_RULES;}['checkpoint'](a,b,c,d,e,f,g,h){const i=createCheckpoint(a,b,c,d,e,f,g,h);return saveCheckpoint(i),i;}['loadCheckpoint'](a){return loadLatestCheckpoint(a);}['listCheckpoints'](a){return listCheckpoints(a);}['listTasks'](){return listTasks();}['setContext'](a,b){this['context']['set'](a,b);}['getContext'](a){return this['context']['get'](a);}}let singleton=null;export function getHarness(){return!singleton&&(singleton=new Harness()),singleton;}export function setHarness(a){singleton=a;}
@@ -1,276 +1 @@
1
- export const SCENARIO_REGISTRY = [
2
- {
3
- name: "freelance",
4
- keywords: ["freelance", "service", "deliverable", "client", "gig", "consult", "design", "develop"],
5
- description: "Service delivery with escrow: publish → order → deliver → accept → withdraw",
6
- default_permissions: { provider: 1000, customer: "namedOperator", arbiter: 1500 },
7
- objects: [
8
- { type: "Permission", reversible: true, dependencies: [], user_decisions: ["reuse existing or create new?"], estimated_time: "2min" },
9
- { type: "Service", reversible: true, dependencies: ["Permission"], user_decisions: ["name", "description", "token_type"], estimated_time: "3min" },
10
- { type: "Machine", reversible: true, dependencies: ["Service"], user_decisions: ["state graph", "operators"], estimated_time: "10min" },
11
- { type: "Guard", reversible: false, dependencies: ["Machine"], user_decisions: ["guard table", "submission fields"], risk_flags: ["immutable_after_creation"], estimated_time: "5min" },
12
- { type: "Guard", reversible: false, dependencies: ["Machine"], user_decisions: ["refund guard"], risk_flags: ["immutable_after_creation"], estimated_time: "5min" },
13
- { type: "Allocation", reversible: true, dependencies: ["Service", "Guard"], user_decisions: ["sharing ratios", "allocators"], estimated_time: "5min" },
14
- ],
15
- phases: [
16
- { name: "Foundation", object_types: ["Permission", "Service"] },
17
- { name: "Business Logic", object_types: ["Machine"] },
18
- { name: "Trust Layer", object_types: ["Guard"] },
19
- { name: "Revenue", object_types: ["Allocation"] },
20
- { name: "Publish", object_types: ["Service"] },
21
- ],
22
- },
23
- {
24
- name: "rental",
25
- keywords: ["rent", "rental", "lease", "property", "item", "deposit", "tenant", "landlord"],
26
- description: "Item rental with deposit: publish → rent → inspect → return/refund",
27
- default_permissions: { provider: 1000, customer: "namedOperator", arbiter: 1500 },
28
- objects: [
29
- { type: "Permission", reversible: true, dependencies: [], user_decisions: ["reuse existing or create new?"], estimated_time: "2min" },
30
- { type: "Service", reversible: true, dependencies: ["Permission"], user_decisions: ["name", "deposit amount", "rental terms"], estimated_time: "3min" },
31
- { type: "Machine", reversible: true, dependencies: ["Service"], user_decisions: ["rental states", "return/inspect flow"], estimated_time: "10min" },
32
- { type: "Guard", reversible: false, dependencies: ["Machine"], user_decisions: ["return guard", "damage guard"], risk_flags: ["immutable_after_creation"], estimated_time: "5min" },
33
- { type: "Guard", reversible: false, dependencies: ["Machine"], user_decisions: ["refund guard"], risk_flags: ["immutable_after_creation"], estimated_time: "5min" },
34
- { type: "Allocation", reversible: true, dependencies: ["Service", "Guard"], user_decisions: ["deposit/refund allocation", "damage compensation"], estimated_time: "5min" },
35
- ],
36
- phases: [
37
- { name: "Foundation", object_types: ["Permission", "Service"] },
38
- { name: "Business Logic", object_types: ["Machine"] },
39
- { name: "Trust Layer", object_types: ["Guard"] },
40
- { name: "Revenue", object_types: ["Allocation"] },
41
- { name: "Publish", object_types: ["Service"] },
42
- ],
43
- },
44
- {
45
- name: "digital_goods",
46
- keywords: ["digital", "download", "ebook", "software", "license", "instant", "content"],
47
- description: "Instant digital delivery: publish → buy → instant delivery",
48
- default_permissions: { provider: 1000, customer: "namedOperator" },
49
- objects: [
50
- { type: "Permission", reversible: true, dependencies: [], estimated_time: "2min" },
51
- { type: "Service", reversible: true, dependencies: ["Permission"], user_decisions: ["name", "price", "delivery method"], estimated_time: "3min" },
52
- { type: "Machine", reversible: true, dependencies: ["Service"], user_decisions: ["instant delivery states"], estimated_time: "5min" },
53
- { type: "Allocation", reversible: true, dependencies: ["Service"], user_decisions: ["revenue split"], estimated_time: "3min" },
54
- ],
55
- phases: [
56
- { name: "Foundation", object_types: ["Permission", "Service"] },
57
- { name: "Business Logic", object_types: ["Machine"] },
58
- { name: "Revenue", object_types: ["Allocation"] },
59
- { name: "Publish", object_types: ["Service"] },
60
- ],
61
- },
62
- {
63
- name: "travel_package",
64
- keywords: ["travel", "tour", "trip", "package", "booking", "itinerary", "vacation", "hotel"],
65
- description: "Multi-stage service with milestones: publish → book → itinerary → complete",
66
- default_permissions: { provider: 1000, customer: "namedOperator", arbiter: 1500 },
67
- objects: [
68
- { type: "Permission", reversible: true, dependencies: [], estimated_time: "2min" },
69
- { type: "Service", reversible: true, dependencies: ["Permission"], user_decisions: ["name", "package details", "pricing tiers"], estimated_time: "5min" },
70
- { type: "Machine", reversible: true, dependencies: ["Service"], user_decisions: ["booking states", "milestone flow", "cancellation"], estimated_time: "15min" },
71
- { type: "Guard", reversible: false, dependencies: ["Machine"], user_decisions: ["booking guard", "cancellation guard"], risk_flags: ["immutable_after_creation"], estimated_time: "5min" },
72
- { type: "Allocation", reversible: true, dependencies: ["Service", "Guard"], user_decisions: ["milestone payments", "refund policy"], estimated_time: "5min" },
73
- ],
74
- phases: [
75
- { name: "Foundation", object_types: ["Permission", "Service"] },
76
- { name: "Business Logic", object_types: ["Machine"] },
77
- { name: "Trust Layer", object_types: ["Guard"] },
78
- { name: "Revenue", object_types: ["Allocation"] },
79
- { name: "Publish", object_types: ["Service"] },
80
- ],
81
- },
82
- {
83
- name: "general",
84
- keywords: [],
85
- description: "Fallback for unmatched scenarios — generic service template",
86
- default_permissions: { provider: 1000, customer: "namedOperator" },
87
- objects: [
88
- { type: "Permission", reversible: true, dependencies: [], estimated_time: "2min" },
89
- { type: "Service", reversible: true, dependencies: ["Permission"], user_decisions: ["name", "description", "token_type"], estimated_time: "3min" },
90
- { type: "Machine", reversible: true, dependencies: ["Service"], user_decisions: ["state graph"], estimated_time: "10min" },
91
- { type: "Guard", reversible: false, dependencies: ["Machine"], user_decisions: ["guard requirements"], risk_flags: ["immutable_after_creation"], estimated_time: "5min" },
92
- { type: "Allocation", reversible: true, dependencies: ["Service"], user_decisions: ["sharing"], estimated_time: "5min" },
93
- ],
94
- phases: [
95
- { name: "Foundation", object_types: ["Permission", "Service"] },
96
- { name: "Business Logic", object_types: ["Machine"] },
97
- { name: "Trust Layer", object_types: ["Guard"] },
98
- { name: "Revenue", object_types: ["Allocation"] },
99
- { name: "Publish", object_types: ["Service"] },
100
- ],
101
- },
102
- ];
103
- export function classifyIntent(userInput) {
104
- const lower = userInput.toLowerCase();
105
- let bestMatch = null;
106
- let bestScore = 0;
107
- let matchedKeywords = [];
108
- for (const scenario of SCENARIO_REGISTRY) {
109
- if (scenario.keywords.length === 0)
110
- continue;
111
- const hits = scenario.keywords.filter((kw) => lower.includes(kw));
112
- if (hits.length > bestScore) {
113
- bestScore = hits.length;
114
- bestMatch = scenario;
115
- matchedKeywords = hits;
116
- }
117
- }
118
- if (bestMatch && bestScore > 0) {
119
- const confidence = Math.min(bestScore / 3, 1.0);
120
- return {
121
- scenario: bestMatch.name,
122
- matched_keywords: matchedKeywords,
123
- confidence,
124
- fallback: false,
125
- };
126
- }
127
- return {
128
- scenario: "general",
129
- matched_keywords: [],
130
- confidence: 0.3,
131
- fallback: true,
132
- };
133
- }
134
- let nodeIdCounter = 0;
135
- function nextNodeId(type) {
136
- nodeIdCounter++;
137
- return `${type.toLowerCase()}_${nodeIdCounter}`;
138
- }
139
- export function generateODG(userInput, taskId) {
140
- const classification = classifyIntent(userInput);
141
- const template = SCENARIO_REGISTRY.find((s) => s.name === classification.scenario) ?? SCENARIO_REGISTRY[SCENARIO_REGISTRY.length - 1];
142
- const objects = template.objects.map((obj) => ({
143
- id: nextNodeId(obj.type),
144
- type: obj.type,
145
- status: "not_created",
146
- reversible: obj.reversible,
147
- dependencies: [],
148
- user_decisions: obj.user_decisions,
149
- risk_flags: obj.risk_flags,
150
- estimated_time: obj.estimated_time,
151
- }));
152
- const typeToLatestId = new Map();
153
- for (const obj of objects) {
154
- const depTypes = template.objects.find((t) => t.type === obj.type)?.dependencies ?? [];
155
- obj.dependencies = depTypes
156
- .map((depType) => typeToLatestId.get(depType))
157
- .filter((id) => id !== undefined);
158
- typeToLatestId.set(obj.type, obj.id);
159
- }
160
- const phases = template.phases.map((phase) => {
161
- const phaseObjectIds = objects
162
- .filter((obj) => phase.object_types.includes(obj.type))
163
- .map((obj) => obj.id);
164
- return { name: phase.name, objects: phaseObjectIds };
165
- });
166
- return {
167
- task_id: taskId ?? `task_${Date.now()}`,
168
- scenario: classification.scenario,
169
- objects,
170
- phases,
171
- };
172
- }
173
- export function identifyDecisionPoints(odg) {
174
- const decisions = [];
175
- const scenario = SCENARIO_REGISTRY.find((s) => s.name === odg.scenario);
176
- decisions.push({
177
- round: "R1",
178
- question: `I've classified your intent as "${odg.scenario}". Is this correct?`,
179
- options: ["Yes, correct", "No, let me clarify"],
180
- });
181
- decisions.push({
182
- round: "R2",
183
- question: "Do you have existing Permission objects to reuse, or should I create a new one?",
184
- options: ["Create new", "Reuse existing", "Show me what I have"],
185
- });
186
- decisions.push({
187
- round: "R3",
188
- question: "What is the service name, description, and pricing token?",
189
- options: ["WOW (default)", "USDT", "USDC", "Custom token"],
190
- default: "WOW (default)",
191
- });
192
- if (scenario?.default_permissions.arbiter) {
193
- decisions.push({
194
- round: "R4",
195
- question: "Permission model: provider=1000, customer uses namedOperator, arbiter=1500. Adjust?",
196
- options: ["Use defaults", "Customize"],
197
- default: "Use defaults",
198
- });
199
- }
200
- decisions.push({
201
- round: "R5",
202
- question: "What are the service states and transitions? (entry → states → terminals)",
203
- options: ["Use scenario template", "Custom design"],
204
- });
205
- const guardNodes = odg.objects.filter((o) => o.type === "Guard");
206
- if (guardNodes.length > 0) {
207
- decisions.push({
208
- round: "R6",
209
- question: `${guardNodes.length} Guard(s) needed. What should each Guard verify?`,
210
- options: ["Withdrawal guard", "Refund guard", "Delivery guard", "Custom"],
211
- });
212
- }
213
- decisions.push({
214
- round: "R7",
215
- question: "How should revenue be split? (e.g., merchant 80%, platform 20%)",
216
- options: ["100% to merchant", "80/20 split", "Custom split"],
217
- default: "100% to merchant",
218
- });
219
- return decisions;
220
- }
221
- export function detectCycles(odg) {
222
- const visited = new Set();
223
- const stack = new Set();
224
- const cycleNodes = [];
225
- function dfs(nodeId, path) {
226
- if (stack.has(nodeId)) {
227
- const cycleStart = path.indexOf(nodeId);
228
- cycleNodes.push(...path.slice(cycleStart), nodeId);
229
- return true;
230
- }
231
- if (visited.has(nodeId))
232
- return false;
233
- visited.add(nodeId);
234
- stack.add(nodeId);
235
- const node = odg.objects.find((o) => o.id === nodeId);
236
- if (node) {
237
- for (const dep of node.dependencies) {
238
- if (dfs(dep, [...path, nodeId]))
239
- return true;
240
- }
241
- }
242
- stack.delete(nodeId);
243
- return false;
244
- }
245
- for (const obj of odg.objects) {
246
- if (!visited.has(obj.id)) {
247
- if (dfs(obj.id, []))
248
- return cycleNodes;
249
- }
250
- }
251
- return null;
252
- }
253
- export function identifyMigrationDecisions(options) {
254
- const current = options?.current_payment_token ?? "WOW";
255
- const from = options?.from_network ?? "testnet";
256
- const to = options?.to_network ?? "mainnet";
257
- return [
258
- {
259
- round: "M1",
260
- question: `Your project currently uses "${current}" as the payment token on ${from}. ` +
261
- `When migrating to ${to}, do you want to keep "${current}" or switch to a stablecoin ` +
262
- `(e.g. USDT, available via the ETH mainnet cross-chain bridge)?`,
263
- options: [
264
- `Keep ${current}`,
265
- "Switch to USDT",
266
- "Switch to USDC",
267
- "Other stablecoin",
268
- ],
269
- default: `Keep ${current}`,
270
- note: `Testnet recommendation: WOW for all merchant and order testing. ` +
271
- `Mainnet: USDT and other stablecoins are available via the ETH mainnet cross-chain bridge ` +
272
- `and are often preferred to avoid price volatility. If switching, the Service / Treasury / ` +
273
- `Allocation type_parameter must be updated to the stablecoin's WOW type tag before publishing on mainnet.`,
274
- },
275
- ];
276
- }
1
+ export const SCENARIO_REGISTRY=[{'name':'freelance','keywords':['freelance','service','deliverable','client','gig','consult','design','develop'],'description':'Service\x20delivery\x20with\x20escrow:\x20publish\x20→\x20order\x20→\x20deliver\x20→\x20accept\x20→\x20withdraw','default_permissions':{'provider':0x3e8,'customer':'namedOperator','arbiter':0x5dc},'objects':[{'type':'Permission','reversible':!![],'dependencies':[],'user_decisions':['reuse\x20existing\x20or\x20create\x20new?'],'estimated_time':'2min'},{'type':'Service','reversible':!![],'dependencies':['Permission'],'user_decisions':['name','description','token_type'],'estimated_time':'3min'},{'type':'Machine','reversible':!![],'dependencies':['Service'],'user_decisions':['state\x20graph','operators'],'estimated_time':'10min'},{'type':'Guard','reversible':![],'dependencies':['Machine'],'user_decisions':['guard\x20table','submission\x20fields'],'risk_flags':['immutable_after_creation'],'estimated_time':'5min'},{'type':'Guard','reversible':![],'dependencies':['Machine'],'user_decisions':['refund\x20guard'],'risk_flags':['immutable_after_creation'],'estimated_time':'5min'},{'type':'Allocation','reversible':!![],'dependencies':['Service','Guard'],'user_decisions':['sharing\x20ratios','allocators'],'estimated_time':'5min'}],'phases':[{'name':'Foundation','object_types':['Permission','Service']},{'name':'Business\x20Logic','object_types':['Machine']},{'name':'Trust\x20Layer','object_types':['Guard']},{'name':'Revenue','object_types':['Allocation']},{'name':'Publish','object_types':['Service']}]},{'name':'rental','keywords':['rent','rental','lease','property','item','deposit','tenant','landlord'],'description':'Item\x20rental\x20with\x20deposit:\x20publish\x20→\x20rent\x20→\x20inspect\x20→\x20return/refund','default_permissions':{'provider':0x3e8,'customer':'namedOperator','arbiter':0x5dc},'objects':[{'type':'Permission','reversible':!![],'dependencies':[],'user_decisions':['reuse\x20existing\x20or\x20create\x20new?'],'estimated_time':'2min'},{'type':'Service','reversible':!![],'dependencies':['Permission'],'user_decisions':['name','deposit\x20amount','rental\x20terms'],'estimated_time':'3min'},{'type':'Machine','reversible':!![],'dependencies':['Service'],'user_decisions':['rental\x20states','return/inspect\x20flow'],'estimated_time':'10min'},{'type':'Guard','reversible':![],'dependencies':['Machine'],'user_decisions':['return\x20guard','damage\x20guard'],'risk_flags':['immutable_after_creation'],'estimated_time':'5min'},{'type':'Guard','reversible':![],'dependencies':['Machine'],'user_decisions':['refund\x20guard'],'risk_flags':['immutable_after_creation'],'estimated_time':'5min'},{'type':'Allocation','reversible':!![],'dependencies':['Service','Guard'],'user_decisions':['deposit/refund\x20allocation','damage\x20compensation'],'estimated_time':'5min'}],'phases':[{'name':'Foundation','object_types':['Permission','Service']},{'name':'Business\x20Logic','object_types':['Machine']},{'name':'Trust\x20Layer','object_types':['Guard']},{'name':'Revenue','object_types':['Allocation']},{'name':'Publish','object_types':['Service']}]},{'name':'retail','keywords':['retail','shop','store','ecommerce','buy','sell','product','digital','download','ebook','software','license','instant','content'],'description':'Instant\x20digital\x20delivery:\x20publish\x20→\x20buy\x20→\x20instant\x20delivery','default_permissions':{'provider':0x3e8,'customer':'namedOperator'},'objects':[{'type':'Permission','reversible':!![],'dependencies':[],'estimated_time':'2min'},{'type':'Service','reversible':!![],'dependencies':['Permission'],'user_decisions':['name','price','delivery\x20method'],'estimated_time':'3min'},{'type':'Machine','reversible':!![],'dependencies':['Service'],'user_decisions':['instant\x20delivery\x20states'],'estimated_time':'5min'},{'type':'Allocation','reversible':!![],'dependencies':['Service'],'user_decisions':['revenue\x20split'],'estimated_time':'3min'}],'phases':[{'name':'Foundation','object_types':['Permission','Service']},{'name':'Business\x20Logic','object_types':['Machine']},{'name':'Revenue','object_types':['Allocation']},{'name':'Publish','object_types':['Service']}]},{'name':'travel','keywords':['travel','tour','trip','package','booking','itinerary','vacation','hotel'],'description':'Multi-stage\x20service\x20with\x20milestones:\x20publish\x20→\x20book\x20→\x20itinerary\x20→\x20complete','default_permissions':{'provider':0x3e8,'customer':'namedOperator','arbiter':0x5dc},'objects':[{'type':'Permission','reversible':!![],'dependencies':[],'estimated_time':'2min'},{'type':'Service','reversible':!![],'dependencies':['Permission'],'user_decisions':['name','package\x20details','pricing\x20tiers'],'estimated_time':'5min'},{'type':'Machine','reversible':!![],'dependencies':['Service'],'user_decisions':['booking\x20states','milestone\x20flow','cancellation'],'estimated_time':'15min'},{'type':'Guard','reversible':![],'dependencies':['Machine'],'user_decisions':['booking\x20guard','cancellation\x20guard'],'risk_flags':['immutable_after_creation'],'estimated_time':'5min'},{'type':'Allocation','reversible':!![],'dependencies':['Service','Guard'],'user_decisions':['milestone\x20payments','refund\x20policy'],'estimated_time':'5min'}],'phases':[{'name':'Foundation','object_types':['Permission','Service']},{'name':'Business\x20Logic','object_types':['Machine']},{'name':'Trust\x20Layer','object_types':['Guard']},{'name':'Revenue','object_types':['Allocation']},{'name':'Publish','object_types':['Service']}]},{'name':'education','keywords':['education','course','training','tutor','teach','learn','school','coach','class','lesson'],'description':'Long-cycle\x20education\x20with\x20milestones:\x20publish\x20→\x20enroll\x20→\x20teach\x20→\x20complete\x20→\x20certificate','default_permissions':{'provider':0x3e8,'customer':'namedOperator','arbiter':0x5dc},'objects':[{'type':'Permission','reversible':!![],'dependencies':[],'user_decisions':['reuse\x20existing\x20or\x20create\x20new?'],'estimated_time':'2min'},{'type':'Service','reversible':!![],'dependencies':['Permission'],'user_decisions':['name','course\x20details','token_type'],'estimated_time':'3min'},{'type':'Machine','reversible':!![],'dependencies':['Service'],'user_decisions':['enrollment\x20states','milestone\x20flow','completion'],'estimated_time':'15min'},{'type':'Guard','reversible':![],'dependencies':['Machine'],'user_decisions':['enrollment\x20guard','completion\x20guard'],'risk_flags':['immutable_after_creation'],'estimated_time':'5min'},{'type':'Guard','reversible':![],'dependencies':['Machine'],'user_decisions':['refund\x20guard'],'risk_flags':['immutable_after_creation'],'estimated_time':'5min'},{'type':'Allocation','reversible':!![],'dependencies':['Service','Guard'],'user_decisions':['milestone\x20payments','refund\x20policy'],'estimated_time':'5min'}],'phases':[{'name':'Foundation','object_types':['Permission','Service']},{'name':'Business\x20Logic','object_types':['Machine']},{'name':'Trust\x20Layer','object_types':['Guard']},{'name':'Revenue','object_types':['Allocation']},{'name':'Publish','object_types':['Service']}]},{'name':'subscription','keywords':['subscription','subscribe','membership','recurring','monthly','newsletter','patreon','tier'],'description':'Recurring\x20subscription\x20with\x20renewal:\x20publish\x20→\x20subscribe\x20→\x20renew\x20→\x20cancel','default_permissions':{'provider':0x3e8,'customer':'namedOperator'},'objects':[{'type':'Permission','reversible':!![],'dependencies':[],'estimated_time':'2min'},{'type':'Service','reversible':!![],'dependencies':['Permission'],'user_decisions':['name','subscription\x20tiers','token_type'],'estimated_time':'3min'},{'type':'Machine','reversible':!![],'dependencies':['Service'],'user_decisions':['subscribe\x20states','renewal\x20flow','cancellation'],'estimated_time':'10min'},{'type':'Allocation','reversible':!![],'dependencies':['Service'],'user_decisions':['revenue\x20split'],'estimated_time':'3min'}],'phases':[{'name':'Foundation','object_types':['Permission','Service']},{'name':'Business\x20Logic','object_types':['Machine']},{'name':'Revenue','object_types':['Allocation']},{'name':'Publish','object_types':['Service']}]},{'name':'general','keywords':[],'description':'Fallback\x20for\x20unmatched\x20scenarios\x20—\x20generic\x20service\x20template','default_permissions':{'provider':0x3e8,'customer':'namedOperator'},'objects':[{'type':'Permission','reversible':!![],'dependencies':[],'estimated_time':'2min'},{'type':'Service','reversible':!![],'dependencies':['Permission'],'user_decisions':['name','description','token_type'],'estimated_time':'3min'},{'type':'Machine','reversible':!![],'dependencies':['Service'],'user_decisions':['state\x20graph'],'estimated_time':'10min'},{'type':'Guard','reversible':![],'dependencies':['Machine'],'user_decisions':['guard\x20requirements'],'risk_flags':['immutable_after_creation'],'estimated_time':'5min'},{'type':'Allocation','reversible':!![],'dependencies':['Service'],'user_decisions':['sharing'],'estimated_time':'5min'}],'phases':[{'name':'Foundation','object_types':['Permission','Service']},{'name':'Business\x20Logic','object_types':['Machine']},{'name':'Trust\x20Layer','object_types':['Guard']},{'name':'Revenue','object_types':['Allocation']},{'name':'Publish','object_types':['Service']}]}];export function classifyIntent(a){const b=a['toLowerCase']();let c=null,d=0x0,e=[];for(const f of SCENARIO_REGISTRY){if(f['keywords']['length']===0x0)continue;const g=f['keywords']['filter'](h=>b['includes'](h));g['length']>d&&(d=g['length'],c=f,e=g);}if(c&&d>0x0){const h=Math['min'](d/0x3,0x1);return{'scenario':c['name'],'matched_keywords':e,'confidence':h,'fallback':![]};}return{'scenario':'general','matched_keywords':[],'confidence':0.3,'fallback':!![]};}let nodeIdCounter=0x0;function nextNodeId(a){return nodeIdCounter++,a['toLowerCase']()+'_'+nodeIdCounter;}export function generateODG(a,b){const c=classifyIntent(a),d=SCENARIO_REGISTRY['find'](h=>h['name']===c['scenario'])??SCENARIO_REGISTRY[SCENARIO_REGISTRY['length']-0x1],e=d['objects']['map'](h=>({'id':nextNodeId(h['type']),'type':h['type'],'status':'not_created','reversible':h['reversible'],'dependencies':[],'user_decisions':h['user_decisions'],'risk_flags':h['risk_flags'],'estimated_time':h['estimated_time']})),f=new Map();for(const h of e){const i=d['objects']['find'](j=>j['type']===h['type'])?.['dependencies']??[];h['dependencies']=i['map'](j=>f['get'](j))['filter'](j=>j!==undefined),f['set'](h['type'],h['id']);}const g=d['phases']['map'](j=>{const k=e['filter'](l=>j['object_types']['includes'](l['type']))['map'](l=>l['id']);return{'name':j['name'],'objects':k};});return{'task_id':b??'task_'+Date['now'](),'scenario':c['scenario'],'objects':e,'phases':g};}export function identifyDecisionPoints(a){const b=[],c=SCENARIO_REGISTRY['find'](e=>e['name']===a['scenario']);b['push']({'round':'R1','question':'I\x27ve\x20classified\x20your\x20intent\x20as\x20\x22'+a['scenario']+'\x22.\x20Is\x20this\x20correct?','options':['Yes,\x20correct','No,\x20let\x20me\x20clarify']}),b['push']({'round':'R2','question':'Do\x20you\x20have\x20existing\x20Permission\x20objects\x20to\x20reuse,\x20or\x20should\x20I\x20create\x20a\x20new\x20one?','options':['Create\x20new','Reuse\x20existing','Show\x20me\x20what\x20I\x20have']}),b['push']({'round':'R3','question':'What\x20is\x20the\x20service\x20name,\x20description,\x20and\x20pricing\x20token?','options':['WOW\x20(default)','USDT','USDC','Custom\x20token'],'default':'WOW\x20(default)'});c?.['default_permissions']['arbiter']&&b['push']({'round':'R4','question':'Permission\x20model:\x20provider=1000,\x20customer\x20uses\x20namedOperator,\x20arbiter=1500.\x20Adjust?','options':['Use\x20defaults','Customize'],'default':'Use\x20defaults'});b['push']({'round':'R5','question':'What\x20are\x20the\x20service\x20states\x20and\x20transitions?\x20(entry\x20→\x20states\x20→\x20terminals)','options':['Use\x20scenario\x20template','Custom\x20design']});const d=a['objects']['filter'](e=>e['type']==='Guard');return d['length']>0x0&&b['push']({'round':'R6','question':d['length']+'\x20Guard(s)\x20needed.\x20What\x20should\x20each\x20Guard\x20verify?','options':['Withdrawal\x20guard','Refund\x20guard','Delivery\x20guard','Custom']}),b['push']({'round':'R7','question':'How\x20should\x20revenue\x20be\x20split?\x20(e.g.,\x20merchant\x2080%,\x20platform\x2020%)','options':['100%\x20to\x20merchant','80/20\x20split','Custom\x20split'],'default':'100%\x20to\x20merchant'}),b;}export function detectCycles(a){const b=new Set(),c=new Set(),d=[];function e(f,g){if(c['has'](f)){const i=g['indexOf'](f);return d['push'](...g['slice'](i),f),!![];}if(b['has'](f))return![];b['add'](f),c['add'](f);const h=a['objects']['find'](j=>j['id']===f);if(h)for(const j of h['dependencies']){if(e(j,[...g,f]))return!![];}return c['delete'](f),![];}for(const f of a['objects']){if(!b['has'](f['id'])){if(e(f['id'],[]))return d;}}return null;}export function identifyMigrationDecisions(a){const b=a?.['current_payment_token']??'WOW',c=a?.['from_network']??'testnet',d=a?.['to_network']??'mainnet';return[{'round':'M1','question':'Your\x20project\x20currently\x20uses\x20\x22'+b+'\x22\x20as\x20the\x20payment\x20token\x20on\x20'+c+'.\x20'+('When\x20migrating\x20to\x20'+d+',\x20do\x20you\x20want\x20to\x20keep\x20\x22'+b+'\x22\x20or\x20switch\x20to\x20a\x20stablecoin\x20')+'(e.g.\x20USDT,\x20available\x20via\x20the\x20ETH\x20mainnet\x20cross-chain\x20bridge)?','options':['Keep\x20'+b,'Switch\x20to\x20USDT','Switch\x20to\x20USDC','Other\x20stablecoin'],'default':'Keep\x20'+b,'note':'Testnet\x20recommendation:\x20WOW\x20for\x20all\x20merchant\x20and\x20order\x20testing.\x20'+'Mainnet:\x20USDT\x20and\x20other\x20stablecoins\x20are\x20available\x20via\x20the\x20ETH\x20mainnet\x20cross-chain\x20bridge\x20'+'and\x20are\x20often\x20preferred\x20to\x20avoid\x20price\x20volatility.\x20If\x20switching,\x20the\x20Service\x20/\x20Treasury\x20/\x20'+'Allocation\x20type_parameter\x20must\x20be\x20updated\x20to\x20the\x20stablecoin\x27s\x20WOW\x20type\x20tag\x20before\x20publishing\x20on\x20mainnet.'}];}