@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,211 +1 @@
1
- import { USER_DEFINED_PERM_INDEX_START } from "./onchain-constants.js";
2
- export const CONCEPT_GLOSSARY = [
3
- {
4
- term: "Permission",
5
- definition: `Organization-wide permission object. indices 0-${USER_DEFINED_PERM_INDEX_START - 1} builtin, ` +
6
- `${USER_DEFINED_PERM_INDEX_START}-65535 custom. ` +
7
- "Shared across all Progress instances of a Service. Use for internal staff roles.",
8
- aliases: ["permission object"],
9
- category: "permission",
10
- },
11
- {
12
- term: "NamedOperator",
13
- definition: "Per-order role assignment inside a Progress. Each Progress node can map a role " +
14
- "string to an address. Use for external collaborators whose identity varies per order.",
15
- aliases: ["named operator", "namedoperator"],
16
- category: "permission",
17
- },
18
- {
19
- term: "OrderHolder",
20
- definition: "The order holder and their agents. Represented by namedOperator=\"\" (empty string) " +
21
- "on a Forward. Lets the customer operate their own order.",
22
- aliases: ["order owner", "orderholder", "order holder"],
23
- category: "permission",
24
- },
25
- {
26
- term: "Forward",
27
- definition: "A state-transition edge in a Machine. Carries weight, a permission " +
28
- "(Permission index / NamedOperator / OrderHolder), and an optional Guard. " +
29
- "Every Forward MUST define at least one permission.",
30
- aliases: ["transition"],
31
- category: "operation",
32
- },
33
- {
34
- term: "Pair",
35
- definition: "A prev_node → next_node transition group in a Machine with a threshold. " +
36
- "When the cumulative weight of executed Forwards meets the threshold, the Pair fires.",
37
- aliases: ["transition pair"],
38
- category: "operation",
39
- },
40
- {
41
- term: "Machine",
42
- definition: "Workflow blueprint (directed graph). Becomes immutable after publish. " +
43
- "A Progress instance is created per order from the Machine.",
44
- aliases: ["machine template"],
45
- category: "object",
46
- },
47
- {
48
- term: "Progress",
49
- definition: "A workflow instance bound to one order. Advances via Forwards; " +
50
- "carries retained_submission values for Guard verification.",
51
- aliases: ["progress instance"],
52
- category: "object",
53
- },
54
- {
55
- term: "Guard",
56
- definition: "Immutable static validation rule. Verifies submissions and on-chain object data. " +
57
- "Returns boolean. Cannot be mutated after creation.",
58
- aliases: ["guard object"],
59
- category: "acceptance",
60
- },
61
- {
62
- term: "Repository",
63
- definition: "Mutable dynamic acceptance store. Keyed by (name, entity). " +
64
- "Used for data that can change over time (e.g. SLA config, review records).",
65
- aliases: ["repository object"],
66
- category: "acceptance",
67
- },
68
- {
69
- term: "Acceptance",
70
- definition: "The verification standard for a process step. Composed of static Guard + " +
71
- "dynamic Repository. Drives whether a Forward can execute.",
72
- aliases: ["acceptance standard"],
73
- category: "acceptance",
74
- },
75
- {
76
- term: "Service",
77
- definition: "A merchant's service listing. References Machine, order_allocators, arbitrations, " +
78
- "compensation_fund, rewards, buy_guard. machine & order_allocators lock after publish.",
79
- aliases: ["service object"],
80
- category: "object",
81
- },
82
- {
83
- term: "Order",
84
- definition: "An order against a Service. Funds are escrowed; released via Progress + Allocation. " +
85
- "Arb cases attach to orders for dispute resolution.",
86
- aliases: ["order instance"],
87
- category: "object",
88
- },
89
- {
90
- term: "Allocator",
91
- definition: "Fund distribution rules. Priority: Amount → Rate → Surplus. first-Guard-wins. " +
92
- "Locked on Service publish (order_allocators).",
93
- aliases: ["allocation"],
94
- category: "fund",
95
- },
96
- {
97
- term: "Allocation",
98
- definition: "The act of distributing escrowed funds to recipients per an Allocator. " +
99
- "Executed by the order holder or Permission holder.",
100
- aliases: ["allocation act"],
101
- category: "fund",
102
- },
103
- {
104
- term: "Arbitration",
105
- definition: "Independent arbitration service object. Configured with voting_guard, usage_guard, " +
106
- "fee. Generates Arb cases per dispute. Third-party preferred over self-built.",
107
- aliases: ["arb service"],
108
- category: "object",
109
- },
110
- {
111
- term: "Arb",
112
- definition: "A single dispute case instance of an Arbitration. Has a state machine " +
113
- "(dispute → confirm → vote → verdict → settle).",
114
- aliases: ["arb case"],
115
- category: "object",
116
- },
117
- {
118
- term: "compensation_fund",
119
- definition: "A fund attached to a Service. Arbitration indemnity is drawn from it. " +
120
- "Adequacy is a key trust signal for customers.",
121
- aliases: ["compensation fund"],
122
- category: "fund",
123
- },
124
- {
125
- term: "buy_guard",
126
- definition: "A Guard attached to a Service that gates purchasing. Validates customer eligibility.",
127
- aliases: ["buy guard"],
128
- category: "acceptance",
129
- },
130
- {
131
- term: "Sub-Order",
132
- definition: "A child order in a cross-Machine supply chain. Introduced at a node with transparent " +
133
- "suppliers; verified by Guard to originate from one of the declared suppliers.",
134
- aliases: ["suborder", "sub order"],
135
- category: "object",
136
- },
137
- {
138
- term: "Reward",
139
- definition: "Incentive pool. claim is Guard-gated. guard_add supports Fixed or GuardU64Identifier " +
140
- "(dynamic). Used for marketing (first-order, cumulative, referral).",
141
- aliases: ["reward pool"],
142
- category: "fund",
143
- },
144
- {
145
- term: "Demand",
146
- definition: "A user's posted service request with optional reward. presenters submit proposals; " +
147
- "Guard filters them. Matches Services for personalized acquisition.",
148
- aliases: ["demand request"],
149
- category: "object",
150
- },
151
- {
152
- term: "Personal",
153
- definition: "Permanently public on-chain identity profile. Social links, reputation (likes/dislikes), " +
154
- "personal info records. CRITICAL: everything here is PUBLIC forever.",
155
- aliases: ["personal profile"],
156
- category: "object",
157
- },
158
- {
159
- term: "Contact",
160
- definition: "Bridges a Service's um (contact) and the Messenger ims (messaging). Enables " +
161
- "off-chain encrypted communication for pre-order negotiation & evidence.",
162
- aliases: ["contact bridge"],
163
- category: "object",
164
- },
165
- ];
166
- const ALIAS_INDEX = (() => {
167
- const m = new Map();
168
- for (const e of CONCEPT_GLOSSARY) {
169
- m.set(e.term.toLowerCase(), e.term);
170
- for (const a of e.aliases)
171
- m.set(a.toLowerCase(), e.term);
172
- }
173
- return m;
174
- })();
175
- export function resolveTerm(alias) {
176
- if (!alias)
177
- return alias;
178
- return ALIAS_INDEX.get(alias.toLowerCase()) ?? alias;
179
- }
180
- export function lookupEntry(term) {
181
- const t = term.toLowerCase();
182
- return CONCEPT_GLOSSARY.find((e) => e.term.toLowerCase() === t || e.aliases.some((a) => a.toLowerCase() === t));
183
- }
184
- export function validateText(text) {
185
- const findings = [];
186
- if (!text)
187
- return findings;
188
- const lower = text.toLowerCase();
189
- for (const entry of CONCEPT_GLOSSARY) {
190
- for (const alias of entry.aliases) {
191
- const a = alias.toLowerCase();
192
- if (entry.term.toLowerCase() === a)
193
- continue;
194
- if (lower.includes(a)) {
195
- findings.push({ alias, canonical: entry.term });
196
- }
197
- }
198
- }
199
- return findings;
200
- }
201
- export function auditSchemaFields(obj) {
202
- const findings = [];
203
- for (const key of Object.keys(obj)) {
204
- const canonical = ALIAS_INDEX.get(key.toLowerCase());
205
- if (canonical && canonical !== key) {
206
- findings.push({ alias: key, canonical });
207
- }
208
- }
209
- return findings;
210
- }
211
- export const CONCEPT_GLOSSARY_VERSION = 1;
1
+ import{USER_DEFINED_PERM_INDEX_START}from'./onchain-constants.js';export const CONCEPT_GLOSSARY=[{'term':'Permission','definition':'Organization-wide\x20permission\x20object.\x20indices\x200-'+(USER_DEFINED_PERM_INDEX_START-0x1)+'\x20builtin,\x20'+(USER_DEFINED_PERM_INDEX_START+'-65535\x20custom.\x20')+'Shared\x20across\x20all\x20Progress\x20instances\x20of\x20a\x20Service.\x20Use\x20for\x20internal\x20staff\x20roles.','aliases':['permission\x20object'],'category':'permission'},{'term':'NamedOperator','definition':'Per-order\x20role\x20assignment\x20inside\x20a\x20Progress.\x20Each\x20Progress\x20node\x20can\x20map\x20a\x20role\x20'+'string\x20to\x20an\x20address.\x20Use\x20for\x20external\x20collaborators\x20whose\x20identity\x20varies\x20per\x20order.','aliases':['named\x20operator','namedoperator'],'category':'permission'},{'term':'OrderHolder','definition':'The\x20order\x20holder\x20and\x20their\x20agents.\x20Represented\x20by\x20namedOperator=\x22\x22\x20(empty\x20string)\x20'+'on\x20a\x20Forward.\x20Lets\x20the\x20customer\x20operate\x20their\x20own\x20order.','aliases':['order\x20owner','orderholder','order\x20holder'],'category':'permission'},{'term':'Forward','definition':'A\x20state-transition\x20edge\x20in\x20a\x20Machine.\x20Carries\x20weight,\x20a\x20permission\x20'+'(Permission\x20index\x20/\x20NamedOperator\x20/\x20OrderHolder),\x20and\x20an\x20optional\x20Guard.\x20'+'Every\x20Forward\x20MUST\x20define\x20at\x20least\x20one\x20permission.','aliases':['transition'],'category':'operation'},{'term':'Pair','definition':'A\x20prev_node\x20→\x20next_node\x20transition\x20group\x20in\x20a\x20Machine\x20with\x20a\x20threshold.\x20'+'When\x20the\x20cumulative\x20weight\x20of\x20executed\x20Forwards\x20meets\x20the\x20threshold,\x20the\x20Pair\x20fires.','aliases':['transition\x20pair'],'category':'operation'},{'term':'Machine','definition':'Workflow\x20blueprint\x20(directed\x20graph).\x20Becomes\x20immutable\x20after\x20publish.\x20'+'A\x20Progress\x20instance\x20is\x20created\x20per\x20order\x20from\x20the\x20Machine.','aliases':['machine\x20template'],'category':'object'},{'term':'Progress','definition':'A\x20workflow\x20instance\x20bound\x20to\x20one\x20order.\x20Advances\x20via\x20Forwards;\x20'+'carries\x20retained_submission\x20values\x20for\x20Guard\x20verification.','aliases':['progress\x20instance'],'category':'object'},{'term':'Guard','definition':'Immutable\x20static\x20validation\x20rule.\x20Verifies\x20submissions\x20and\x20on-chain\x20object\x20data.\x20'+'Returns\x20boolean.\x20Cannot\x20be\x20mutated\x20after\x20creation.','aliases':['guard\x20object'],'category':'acceptance'},{'term':'Repository','definition':'Mutable\x20dynamic\x20acceptance\x20store.\x20Keyed\x20by\x20(name,\x20entity).\x20'+'Used\x20for\x20data\x20that\x20can\x20change\x20over\x20time\x20(e.g.\x20SLA\x20config,\x20review\x20records).','aliases':['repository\x20object'],'category':'acceptance'},{'term':'Acceptance','definition':'The\x20verification\x20standard\x20for\x20a\x20process\x20step.\x20Composed\x20of\x20static\x20Guard\x20+\x20'+'dynamic\x20Repository.\x20Drives\x20whether\x20a\x20Forward\x20can\x20execute.','aliases':['acceptance\x20standard'],'category':'acceptance'},{'term':'Service','definition':'A\x20merchant\x27s\x20service\x20listing.\x20References\x20Machine,\x20order_allocators,\x20arbitrations,\x20'+'compensation_fund,\x20rewards,\x20buy_guard.\x20machine\x20&\x20order_allocators\x20lock\x20after\x20publish.','aliases':['service\x20object'],'category':'object'},{'term':'Order','definition':'An\x20order\x20against\x20a\x20Service.\x20Funds\x20are\x20escrowed;\x20released\x20via\x20Progress\x20+\x20Allocation.\x20'+'Arb\x20cases\x20attach\x20to\x20orders\x20for\x20dispute\x20resolution.','aliases':['order\x20instance'],'category':'object'},{'term':'Allocator','definition':'Fund\x20distribution\x20rules.\x20Priority:\x20Amount\x20→\x20Rate\x20→\x20Surplus.\x20first-Guard-wins.\x20'+'Locked\x20on\x20Service\x20publish\x20(order_allocators).','aliases':['allocation'],'category':'fund'},{'term':'Allocation','definition':'The\x20act\x20of\x20distributing\x20escrowed\x20funds\x20to\x20recipients\x20per\x20an\x20Allocator.\x20'+'Executed\x20by\x20the\x20order\x20holder\x20or\x20Permission\x20holder.','aliases':['allocation\x20act'],'category':'fund'},{'term':'Arbitration','definition':'Independent\x20arbitration\x20service\x20object.\x20Configured\x20with\x20voting_guard,\x20usage_guard,\x20'+'fee.\x20Generates\x20Arb\x20cases\x20per\x20dispute.\x20Third-party\x20preferred\x20over\x20self-built.','aliases':['arb\x20service'],'category':'object'},{'term':'Arb','definition':'A\x20single\x20dispute\x20case\x20instance\x20of\x20an\x20Arbitration.\x20Has\x20a\x20state\x20machine\x20'+'(dispute\x20→\x20confirm\x20→\x20vote\x20→\x20verdict\x20→\x20settle).','aliases':['arb\x20case'],'category':'object'},{'term':'compensation_fund','definition':'A\x20fund\x20attached\x20to\x20a\x20Service.\x20Arbitration\x20indemnity\x20is\x20drawn\x20from\x20it.\x20'+'Adequacy\x20is\x20a\x20key\x20trust\x20signal\x20for\x20customers.','aliases':['compensation\x20fund'],'category':'fund'},{'term':'buy_guard','definition':'A\x20Guard\x20attached\x20to\x20a\x20Service\x20that\x20gates\x20purchasing.\x20Validates\x20customer\x20eligibility.','aliases':['buy\x20guard'],'category':'acceptance'},{'term':'Sub-Order','definition':'A\x20child\x20order\x20in\x20a\x20cross-Machine\x20supply\x20chain.\x20Introduced\x20at\x20a\x20node\x20with\x20transparent\x20'+'suppliers;\x20verified\x20by\x20Guard\x20to\x20originate\x20from\x20one\x20of\x20the\x20declared\x20suppliers.','aliases':['suborder','sub\x20order'],'category':'object'},{'term':'Reward','definition':'Incentive\x20pool.\x20claim\x20is\x20Guard-gated.\x20guard_add\x20supports\x20Fixed\x20or\x20GuardU64Identifier\x20'+'(dynamic).\x20Used\x20for\x20marketing\x20(first-order,\x20cumulative,\x20referral).','aliases':['reward\x20pool'],'category':'fund'},{'term':'Demand','definition':'A\x20user\x27s\x20posted\x20service\x20request\x20with\x20optional\x20reward.\x20presenters\x20submit\x20proposals;\x20'+'Guard\x20filters\x20them.\x20Matches\x20Services\x20for\x20personalized\x20acquisition.','aliases':['demand\x20request'],'category':'object'},{'term':'Personal','definition':'Permanently\x20public\x20on-chain\x20identity\x20profile.\x20Social\x20links,\x20reputation\x20(likes/dislikes),\x20'+'personal\x20info\x20records.\x20CRITICAL:\x20everything\x20here\x20is\x20PUBLIC\x20forever.','aliases':['personal\x20profile'],'category':'object'},{'term':'Contact','definition':'Bridges\x20a\x20Service\x27s\x20um\x20(contact)\x20and\x20the\x20Messenger\x20ims\x20(messaging).\x20Enables\x20'+'off-chain\x20encrypted\x20communication\x20for\x20pre-order\x20negotiation\x20&\x20evidence.','aliases':['contact\x20bridge'],'category':'object'}];const ALIAS_INDEX=((()=>{const b=new Map();for(const c of CONCEPT_GLOSSARY){b['set'](c['term']['toLowerCase'](),c['term']);for(const d of c['aliases'])b['set'](d['toLowerCase'](),c['term']);}return b;})());export function resolveTerm(a){if(!a)return a;return ALIAS_INDEX['get'](a['toLowerCase']())??a;}export function lookupEntry(a){const b=a['toLowerCase']();return CONCEPT_GLOSSARY['find'](c=>c['term']['toLowerCase']()===b||c['aliases']['some'](d=>d['toLowerCase']()===b));}export function validateText(b){const c=[];if(!b)return c;const d=b['toLowerCase']();for(const e of CONCEPT_GLOSSARY){for(const f of e['aliases']){const g=f['toLowerCase']();if(e['term']['toLowerCase']()===g)continue;d['includes'](g)&&c['push']({'alias':f,'canonical':e['term']});}}return c;}export function auditSchemaFields(a){const b=[];for(const c of Object['keys'](a)){const d=ALIAS_INDEX['get'](c['toLowerCase']());d&&d!==c&&b['push']({'alias':c,'canonical':d});}return b;}export const CONCEPT_GLOSSARY_VERSION=0x1;
@@ -1,406 +1 @@
1
- import { assessGuardRisks, } from "./guard-risk.js";
2
- import { GUARD_SCENES, } from "./guard-ledger.js";
3
- export const GUARD_PUBLISH_CHECKLIST = [
4
- {
5
- id: "GC-01",
6
- description: "Root node exists and is a valid GuardNode type",
7
- status: "skip",
8
- },
9
- {
10
- id: "GC-02",
11
- description: "All table entries have valid value_type (0-18)",
12
- status: "skip",
13
- },
14
- {
15
- id: "GC-03",
16
- description: "Table size within MAX_TABLE_SIZE limit",
17
- status: "skip",
18
- },
19
- {
20
- id: "GC-04",
21
- description: "Description length within MAX_DESCRIPTION_LENGTH",
22
- status: "skip",
23
- },
24
- {
25
- id: "GC-05",
26
- description: "Binding scene identified (one of 8 scenes) or Standalone",
27
- status: "skip",
28
- },
29
- {
30
- id: "GC-06",
31
- description: "All query nodes reference valid GUARDQUERY instructions",
32
- status: "skip",
33
- },
34
- {
35
- id: "GC-07",
36
- description: "All witness nodes use valid WitnessType (100-108)",
37
- status: "skip",
38
- },
39
- {
40
- id: "GC-08",
41
- description: "No circular rely chain in root tree",
42
- status: "skip",
43
- },
44
- {
45
- id: "GC-09",
46
- description: "Type compatibility verified for all equal/compare nodes",
47
- status: "skip",
48
- },
49
- {
50
- id: "GC-10",
51
- description: "Context nodes (Signer/Clock/Guard) used with correct semantics",
52
- status: "skip",
53
- },
54
- {
55
- id: "GC-11",
56
- description: "Submission data (b_submission=true) marked as Type3 with forgery risk evaluated",
57
- status: "skip",
58
- },
59
- {
60
- id: "GC-12",
61
- description: "Immutability acknowledged — Guard CANNOT be modified after creation",
62
- status: "skip",
63
- },
64
- ];
65
- export const GUARD_CONFIRMATION_QUESTIONS = [
66
- {
67
- id: "QG1",
68
- question: "Have you verified that the Guard's validation rule matches your business intent (e.g., 'customer must have paid' rather than 'customer must NOT have paid')?",
69
- expected_response: "yes",
70
- blocking: true,
71
- explanation: "Inverted logic is the #1 cause of Guard failures. The rule_sentence in your puzzle should match the on-chain enforcement direction.",
72
- },
73
- {
74
- id: "QG2",
75
- question: "Have you confirmed that all Type3 (b_submission=true) data sources are forgery-resistant (submitted by trusted callers, not user-supplied)?",
76
- expected_response: "yes",
77
- blocking: true,
78
- explanation: "Type3 data is the most common attack vector. If users can submit arbitrary values, the Guard is bypassable.",
79
- },
80
- {
81
- id: "QG3",
82
- question: "Have you tested the Guard on testnet with gen_passport to verify it returns the expected pass/fail result for both valid and invalid inputs?",
83
- expected_response: "yes",
84
- blocking: true,
85
- explanation: "gen_passport is the only way to test Guard evaluation without binding it. Skipping this risks publishing a broken Guard.",
86
- },
87
- {
88
- id: "QG4",
89
- question: "Is the binding target (Service/Machine/Reward/etc.) already published or planned in the same deployment batch?",
90
- expected_response: "yes",
91
- blocking: false,
92
- explanation: "Guard can be created standalone, but its binding field expects an existing object. Plan creation order accordingly.",
93
- },
94
- {
95
- id: "QG5",
96
- question: "Are you aware that this Guard is IMMUTABLE after creation and cannot be modified (only a new version can be created)?",
97
- expected_response: "yes",
98
- blocking: true,
99
- explanation: "Unlike Machine (which allows permission changes), Guard has NO update entry point. Review the rule twice before confirming.",
100
- },
101
- {
102
- id: "QG6",
103
- question: "Have you reviewed the game-theory implications — does this Guard favor one stakeholder (customer/provider/arbitrator) unfairly?",
104
- expected_response: "no",
105
- blocking: false,
106
- explanation: "Answer 'no' = no unfair advantage. If 'yes', review the game_theory risk rules in guard-risk.ts and adjust.",
107
- },
108
- ];
109
- export const GUARD_CONFIRM_VERSION = "1.0.0";
110
- export function runGuardConfirmGate(input) {
111
- const decision_record = {
112
- final_decision: "blocked",
113
- timestamp: new Date().toISOString(),
114
- layers_passed: [],
115
- };
116
- const checklist_result = runStaticChecklist(input.guard_json, input.existing_lint_issues);
117
- if (!checklist_result.passed) {
118
- return {
119
- status: "blocked_checklist",
120
- checklist_result,
121
- decision_record: {
122
- ...decision_record,
123
- final_reason: `Layer 1 failed: ${checklist_result.failed_items.map(i => i.id).join(", ")}`,
124
- },
125
- };
126
- }
127
- decision_record.layers_passed.push("checklist");
128
- let risk_result;
129
- if (input.existing_risk_assessment) {
130
- risk_result = adaptRiskAssessment(input.existing_risk_assessment);
131
- }
132
- else {
133
- const guard_data = input.guard_json.root;
134
- const assessment = assessGuardRisks({
135
- table: guard_data?.table ?? [],
136
- root: input.guard_json.root,
137
- rely: guard_data?.rely,
138
- });
139
- risk_result = adaptRiskAssessment(assessment);
140
- }
141
- if (risk_result.recommendation === "do_not_publish") {
142
- return {
143
- status: "blocked_risk",
144
- checklist_result,
145
- risk_result,
146
- decision_record: {
147
- ...decision_record,
148
- final_reason: `Layer 2 blocked: ${risk_result.blocking_risks.length} CRITICAL risks`,
149
- },
150
- };
151
- }
152
- decision_record.layers_passed.push("risk");
153
- if (!input.skip_user_confirmation) {
154
- const confirmation_text = generateGuardConfirmationText(input.guard_json, checklist_result, risk_result);
155
- const user_confirmation = processUserConfirmation(input.user_responses);
156
- if (!user_confirmation.approved) {
157
- return {
158
- status: "blocked_user",
159
- checklist_result,
160
- risk_result,
161
- confirmation_text,
162
- user_confirmation,
163
- decision_record: {
164
- ...decision_record,
165
- final_reason: `Layer 3 declined: ${user_confirmation.declined_reason ?? "no reason given"}`,
166
- },
167
- };
168
- }
169
- decision_record.layers_passed.push("user");
170
- if (!input.skip_environment) {
171
- const environment_result = verifyGuardEnvironment(input.guard_json);
172
- if (!environment_result.testnet_tested || !environment_result.rely_chain_resolvable) {
173
- return {
174
- status: "blocked_environment",
175
- checklist_result,
176
- risk_result,
177
- user_confirmation,
178
- environment_result,
179
- decision_record: {
180
- ...decision_record,
181
- final_reason: `Layer 4 failed: environment issues`,
182
- },
183
- };
184
- }
185
- decision_record.layers_passed.push("environment");
186
- }
187
- return {
188
- status: "approved",
189
- checklist_result,
190
- risk_result,
191
- user_confirmation,
192
- confirmation_text: generateGuardConfirmationText(input.guard_json, checklist_result, risk_result),
193
- decision_record: {
194
- ...decision_record,
195
- final_decision: "approved",
196
- },
197
- };
198
- }
199
- decision_record.layers_passed.push("user");
200
- return {
201
- status: "approved",
202
- checklist_result,
203
- risk_result,
204
- decision_record: {
205
- ...decision_record,
206
- final_decision: "approved",
207
- },
208
- };
209
- }
210
- function runStaticChecklist(guard_json, existing_issues) {
211
- const checked_items = [];
212
- const failed_items = [];
213
- const warnings = [];
214
- for (const template of GUARD_PUBLISH_CHECKLIST) {
215
- const item = { ...template, status: "skip" };
216
- try {
217
- const result = evaluateChecklistItem(item.id, guard_json, existing_issues);
218
- item.status = result.status;
219
- item.detail = result.detail;
220
- if (result.status === "fail")
221
- failed_items.push(item);
222
- else if (result.status === "warning")
223
- warnings.push(item);
224
- }
225
- catch (err) {
226
- item.status = "warning";
227
- item.detail = `Check error: ${err.message}`;
228
- warnings.push(item);
229
- }
230
- checked_items.push(item);
231
- }
232
- return {
233
- passed: failed_items.length === 0,
234
- checked_items,
235
- failed_items,
236
- warnings,
237
- };
238
- }
239
- function evaluateChecklistItem(id, guard_json, existing_issues) {
240
- const root = guard_json.root;
241
- switch (id) {
242
- case "GC-01":
243
- if (!root || !root.type)
244
- return { status: "fail", detail: "Root node missing or has no type" };
245
- return { status: "pass" };
246
- case "GC-02":
247
- case "GC-03":
248
- case "GC-04": {
249
- if (existing_issues && existing_issues.length > 0) {
250
- const related = existing_issues.find(i => i.path?.includes("table") || i.path?.includes("description"));
251
- if (related)
252
- return { status: "fail", detail: related.message };
253
- }
254
- return { status: "pass", detail: "Validated by SDK validateGuardData" };
255
- }
256
- case "GC-05": {
257
- if (guard_json.binding_scene_id) {
258
- const scene = GUARD_SCENES.find(s => s.id === guard_json.binding_scene_id);
259
- if (scene)
260
- return { status: "pass", detail: `Scene: ${scene.id}` };
261
- return { status: "warning", detail: `Scene ID "${guard_json.binding_scene_id}" not found in ledger` };
262
- }
263
- return { status: "warning", detail: "No binding scene identified — verify Standalone intent" };
264
- }
265
- case "GC-06":
266
- case "GC-07":
267
- case "GC-08":
268
- case "GC-09":
269
- case "GC-10":
270
- case "GC-11":
271
- if (existing_issues && existing_issues.some(i => i.path?.includes("query") || i.path?.includes("witness"))) {
272
- return { status: "fail", detail: "SDK validation flagged query/witness issues" };
273
- }
274
- return { status: "pass", detail: "Delegated to guard-lint.ts" };
275
- case "GC-12":
276
- return { status: "pass", detail: "Immutability noted — Guard cannot be modified after creation" };
277
- default:
278
- return { status: "skip" };
279
- }
280
- }
281
- function adaptRiskAssessment(assessment) {
282
- const blocking_risks = [];
283
- const warning_risks = [];
284
- for (const risk of assessment.risks ?? []) {
285
- if (risk.level === "critical")
286
- blocking_risks.push(risk.id);
287
- else if (risk.level === "high")
288
- warning_risks.push(risk.id);
289
- }
290
- let recommendation = "publish";
291
- if (blocking_risks.length > 0)
292
- recommendation = "do_not_publish";
293
- else if (warning_risks.length > 2)
294
- recommendation = "fix_first";
295
- return {
296
- overall_risk_level: assessment.overall_risk,
297
- blocking_risks,
298
- warning_risks,
299
- recommendation,
300
- };
301
- }
302
- function processUserConfirmation(responses) {
303
- const questions_asked = GUARD_CONFIRMATION_QUESTIONS;
304
- if (!responses || responses.length === 0) {
305
- return {
306
- questions_asked,
307
- user_responses: [],
308
- approved: false,
309
- declined_reason: "No user responses provided",
310
- timestamp: new Date().toISOString(),
311
- };
312
- }
313
- const blocking_questions = questions_asked.filter(q => q.blocking);
314
- for (const q of blocking_questions) {
315
- const response = responses.find(r => r.question_id === q.id);
316
- if (!response) {
317
- return {
318
- questions_asked,
319
- user_responses: responses,
320
- approved: false,
321
- declined_reason: `Blocking question ${q.id} not answered`,
322
- timestamp: new Date().toISOString(),
323
- };
324
- }
325
- if (q.expected_response === "yes" && response.response !== "yes") {
326
- return {
327
- questions_asked,
328
- user_responses: responses,
329
- approved: false,
330
- declined_reason: `${q.id} expected 'yes', got '${response.response}'`,
331
- timestamp: new Date().toISOString(),
332
- };
333
- }
334
- if (q.expected_response === "no" && response.response !== "no") {
335
- return {
336
- questions_asked,
337
- user_responses: responses,
338
- approved: false,
339
- declined_reason: `${q.id} expected 'no', got '${response.response}'`,
340
- timestamp: new Date().toISOString(),
341
- };
342
- }
343
- }
344
- return {
345
- questions_asked,
346
- user_responses: responses,
347
- approved: true,
348
- timestamp: new Date().toISOString(),
349
- };
350
- }
351
- function generateGuardConfirmationText(guard_json, checklist, risk) {
352
- const lines = [];
353
- lines.push("═══════════════════════════════════════════════════════════");
354
- lines.push(" GUARD PUBLISH CONFIRMATION");
355
- lines.push("═══════════════════════════════════════════════════════════");
356
- lines.push(`Name: ${guard_json.name ?? "(unnamed)"}`);
357
- lines.push(`Description: ${guard_json.description ?? "(none)"}`);
358
- lines.push(`Binding Scene: ${guard_json.binding_scene_id ?? "Standalone"}`);
359
- lines.push("");
360
- lines.push("─ Layer 1: Static Checklist ─────────────────────────────");
361
- lines.push(`Result: ${checklist.passed ? "✅ PASS" : "❌ FAIL"}`);
362
- lines.push(`Items: ${checklist.checked_items.length} checked, ${checklist.failed_items.length} failed, ${checklist.warnings.length} warnings`);
363
- lines.push("");
364
- lines.push("─ Layer 2: Risk Assessment ──────────────────────────────");
365
- lines.push(`Overall: ${risk.overall_risk_level.toUpperCase()}`);
366
- lines.push(`Blocking: ${risk.blocking_risks.length} | Warning: ${risk.warning_risks.length}`);
367
- lines.push(`Recommendation: ${risk.recommendation}`);
368
- lines.push("");
369
- lines.push("⚠️ CRITICAL REMINDER: Guard is IMMUTABLE after creation.");
370
- lines.push(" There is NO update path. If the rule is wrong, you must");
371
- lines.push(" create a NEW Guard and rebind the host object.");
372
- lines.push("");
373
- lines.push("Please review the above and confirm publication.");
374
- lines.push("═══════════════════════════════════════════════════════════");
375
- return lines.join("\n");
376
- }
377
- function verifyGuardEnvironment(guard_json) {
378
- const warnings = [];
379
- if (!guard_json.binding_target) {
380
- warnings.push("No binding target specified — Guard will be Standalone (verify intent)");
381
- }
382
- return {
383
- testnet_tested: false,
384
- binding_target_exists: !!guard_json.binding_target,
385
- rely_chain_resolvable: true,
386
- passport_generated_successfully: false,
387
- warnings,
388
- };
389
- }
390
- export function progressiveGuardCheck(guard_json) {
391
- const checklist = runStaticChecklist(guard_json);
392
- if (!checklist.passed) {
393
- return { layer: "checklist", result: checklist };
394
- }
395
- const guard_data = guard_json.root;
396
- const assessment = assessGuardRisks({
397
- table: guard_data?.table ?? [],
398
- root: guard_json.root,
399
- rely: guard_data?.rely,
400
- });
401
- const risk = adaptRiskAssessment(assessment);
402
- if (risk.recommendation === "do_not_publish") {
403
- return { layer: "risk", result: risk };
404
- }
405
- return { layer: "none", result: null };
406
- }
1
+ import{assessGuardRisks}from'./guard-risk.js';import{GUARD_SCENES}from'./guard-ledger.js';export const GUARD_PUBLISH_CHECKLIST=[{'id':'GC-01','description':'Root\x20node\x20exists\x20and\x20is\x20a\x20valid\x20GuardNode\x20type','status':'skip'},{'id':'GC-02','description':'All\x20table\x20entries\x20have\x20valid\x20value_type\x20(0-18)','status':'skip'},{'id':'GC-03','description':'Table\x20size\x20within\x20MAX_TABLE_SIZE\x20limit','status':'skip'},{'id':'GC-04','description':'Description\x20length\x20within\x20MAX_DESCRIPTION_LENGTH','status':'skip'},{'id':'GC-05','description':'Binding\x20scene\x20identified\x20(one\x20of\x208\x20scenes)\x20or\x20Standalone','status':'skip'},{'id':'GC-06','description':'All\x20query\x20nodes\x20reference\x20valid\x20GUARDQUERY\x20instructions','status':'skip'},{'id':'GC-07','description':'All\x20witness\x20nodes\x20use\x20valid\x20WitnessType\x20(100-108)','status':'skip'},{'id':'GC-08','description':'No\x20circular\x20rely\x20chain\x20in\x20root\x20tree','status':'skip'},{'id':'GC-09','description':'Type\x20compatibility\x20verified\x20for\x20all\x20equal/compare\x20nodes','status':'skip'},{'id':'GC-10','description':'Context\x20nodes\x20(Signer/Clock/Guard)\x20used\x20with\x20correct\x20semantics','status':'skip'},{'id':'GC-11','description':'Submission\x20data\x20(b_submission=true)\x20marked\x20as\x20Type3\x20with\x20forgery\x20risk\x20evaluated','status':'skip'},{'id':'GC-12','description':'Immutability\x20acknowledged\x20—\x20Guard\x20CANNOT\x20be\x20modified\x20after\x20creation','status':'skip'}];export const GUARD_CONFIRMATION_QUESTIONS=[{'id':'QG1','question':'Have\x20you\x20verified\x20that\x20the\x20Guard\x27s\x20validation\x20rule\x20matches\x20your\x20business\x20intent\x20(e.g.,\x20\x27customer\x20must\x20have\x20paid\x27\x20rather\x20than\x20\x27customer\x20must\x20NOT\x20have\x20paid\x27)?','expected_response':'yes','blocking':!![],'explanation':'Inverted\x20logic\x20is\x20the\x20#1\x20cause\x20of\x20Guard\x20failures.\x20The\x20rule_sentence\x20in\x20your\x20puzzle\x20should\x20match\x20the\x20on-chain\x20enforcement\x20direction.'},{'id':'QG2','question':'Have\x20you\x20confirmed\x20that\x20all\x20Type3\x20(b_submission=true)\x20data\x20sources\x20are\x20forgery-resistant\x20(submitted\x20by\x20trusted\x20callers,\x20not\x20user-supplied)?','expected_response':'yes','blocking':!![],'explanation':'Type3\x20data\x20is\x20the\x20most\x20common\x20attack\x20vector.\x20If\x20users\x20can\x20submit\x20arbitrary\x20values,\x20the\x20Guard\x20is\x20bypassable.'},{'id':'QG3','question':'Have\x20you\x20tested\x20the\x20Guard\x20on\x20testnet\x20with\x20gen_passport\x20to\x20verify\x20it\x20returns\x20the\x20expected\x20pass/fail\x20result\x20for\x20both\x20valid\x20and\x20invalid\x20inputs?','expected_response':'yes','blocking':!![],'explanation':'gen_passport\x20is\x20the\x20only\x20way\x20to\x20test\x20Guard\x20evaluation\x20without\x20binding\x20it.\x20Skipping\x20this\x20risks\x20publishing\x20a\x20broken\x20Guard.'},{'id':'QG4','question':'Is\x20the\x20binding\x20target\x20(Service/Machine/Reward/etc.)\x20already\x20published\x20or\x20planned\x20in\x20the\x20same\x20deployment\x20batch?','expected_response':'yes','blocking':![],'explanation':'Guard\x20can\x20be\x20created\x20standalone,\x20but\x20its\x20binding\x20field\x20expects\x20an\x20existing\x20object.\x20Plan\x20creation\x20order\x20accordingly.'},{'id':'QG5','question':'Are\x20you\x20aware\x20that\x20this\x20Guard\x20is\x20IMMUTABLE\x20after\x20creation\x20and\x20cannot\x20be\x20modified\x20(only\x20a\x20new\x20version\x20can\x20be\x20created)?','expected_response':'yes','blocking':!![],'explanation':'Unlike\x20Machine\x20(which\x20allows\x20permission\x20changes),\x20Guard\x20has\x20NO\x20update\x20entry\x20point.\x20Review\x20the\x20rule\x20twice\x20before\x20confirming.'},{'id':'QG6','question':'Have\x20you\x20reviewed\x20the\x20game-theory\x20implications\x20—\x20does\x20this\x20Guard\x20favor\x20one\x20stakeholder\x20(customer/provider/arbitrator)\x20unfairly?','expected_response':'no','blocking':![],'explanation':'Answer\x20\x27no\x27\x20=\x20no\x20unfair\x20advantage.\x20If\x20\x27yes\x27,\x20review\x20the\x20game_theory\x20risk\x20rules\x20in\x20guard-risk.ts\x20and\x20adjust.'}];export const GUARD_CONFIRM_VERSION='1.0.0';export function runGuardConfirmGate(a){const b={'final_decision':'blocked','timestamp':new Date()['toISOString'](),'layers_passed':[]},c=runStaticChecklist(a['guard_json'],a['existing_lint_issues']);if(!c['passed'])return{'status':'blocked_checklist','checklist_result':c,'decision_record':{...b,'final_reason':'Layer\x201\x20failed:\x20'+c['failed_items']['map'](e=>e['id'])['join'](',\x20')}};b['layers_passed']['push']('checklist');let d;if(a['existing_risk_assessment'])d=adaptRiskAssessment(a['existing_risk_assessment']);else{const e=a['guard_json']['root'],f=assessGuardRisks({'table':e?.['table']??[],'root':a['guard_json']['root'],'rely':e?.['rely']});d=adaptRiskAssessment(f);}if(d['recommendation']==='do_not_publish')return{'status':'blocked_risk','checklist_result':c,'risk_result':d,'decision_record':{...b,'final_reason':'Layer\x202\x20blocked:\x20'+d['blocking_risks']['length']+'\x20CRITICAL\x20risks'}};b['layers_passed']['push']('risk');if(!a['skip_user_confirmation']){const g=generateGuardConfirmationText(a['guard_json'],c,d),h=processUserConfirmation(a['user_responses']);if(!h['approved'])return{'status':'blocked_user','checklist_result':c,'risk_result':d,'confirmation_text':g,'user_confirmation':h,'decision_record':{...b,'final_reason':'Layer\x203\x20declined:\x20'+(h['declined_reason']??'no\x20reason\x20given')}};b['layers_passed']['push']('user');if(!a['skip_environment']){const i=verifyGuardEnvironment(a['guard_json']);if(!i['testnet_tested']||!i['rely_chain_resolvable'])return{'status':'blocked_environment','checklist_result':c,'risk_result':d,'user_confirmation':h,'environment_result':i,'decision_record':{...b,'final_reason':'Layer\x204\x20failed:\x20environment\x20issues'}};b['layers_passed']['push']('environment');}return{'status':'approved','checklist_result':c,'risk_result':d,'user_confirmation':h,'confirmation_text':generateGuardConfirmationText(a['guard_json'],c,d),'decision_record':{...b,'final_decision':'approved'}};}return b['layers_passed']['push']('user'),{'status':'approved','checklist_result':c,'risk_result':d,'decision_record':{...b,'final_decision':'approved'}};}function runStaticChecklist(a,b){const c=[],d=[],e=[];for(const f of GUARD_PUBLISH_CHECKLIST){const g={...f,'status':'skip'};try{const h=evaluateChecklistItem(g['id'],a,b);g['status']=h['status'],g['detail']=h['detail'];if(h['status']==='fail')d['push'](g);else{if(h['status']==='warning')e['push'](g);}}catch(i){g['status']='warning',g['detail']='Check\x20error:\x20'+i['message'],e['push'](g);}c['push'](g);}return{'passed':d['length']===0x0,'checked_items':c,'failed_items':d,'warnings':e};}function evaluateChecklistItem(a,b,c){const d=b['root'];switch(a){case'GC-01':if(!d||!d['type'])return{'status':'fail','detail':'Root\x20node\x20missing\x20or\x20has\x20no\x20type'};return{'status':'pass'};case'GC-02':case'GC-03':case'GC-04':{if(c&&c['length']>0x0){const e=c['find'](f=>f['path']?.['includes']('table')||f['path']?.['includes']('description'));if(e)return{'status':'fail','detail':e['message']};}return{'status':'pass','detail':'Validated\x20by\x20SDK\x20validateGuardData'};}case'GC-05':{if(b['binding_scene_id']){const f=GUARD_SCENES['find'](g=>g['id']===b['binding_scene_id']);if(f)return{'status':'pass','detail':'Scene:\x20'+f['id']};return{'status':'warning','detail':'Scene\x20ID\x20\x22'+b['binding_scene_id']+'\x22\x20not\x20found\x20in\x20ledger'};}return{'status':'warning','detail':'No\x20binding\x20scene\x20identified\x20—\x20verify\x20Standalone\x20intent'};}case'GC-06':case'GC-07':case'GC-08':case'GC-09':case'GC-10':case'GC-11':if(c&&c['some'](g=>g['path']?.['includes']('query')||g['path']?.['includes']('witness')))return{'status':'fail','detail':'SDK\x20validation\x20flagged\x20query/witness\x20issues'};return{'status':'pass','detail':'Delegated\x20to\x20guard-lint.ts'};case'GC-12':return{'status':'pass','detail':'Immutability\x20noted\x20—\x20Guard\x20cannot\x20be\x20modified\x20after\x20creation'};default:return{'status':'skip'};}}function adaptRiskAssessment(a){const b=[],c=[];for(const e of a['risks']??[]){if(e['level']==='critical')b['push'](e['id']);else{if(e['level']==='high')c['push'](e['id']);}}let d='publish';if(b['length']>0x0)d='do_not_publish';else{if(c['length']>0x2)d='fix_first';}return{'overall_risk_level':a['overall_risk'],'blocking_risks':b,'warning_risks':c,'recommendation':d};}function processUserConfirmation(a){const b=GUARD_CONFIRMATION_QUESTIONS;if(!a||a['length']===0x0)return{'questions_asked':b,'user_responses':[],'approved':![],'declined_reason':'No\x20user\x20responses\x20provided','timestamp':new Date()['toISOString']()};const c=b['filter'](d=>d['blocking']);for(const d of c){const e=a['find'](f=>f['question_id']===d['id']);if(!e)return{'questions_asked':b,'user_responses':a,'approved':![],'declined_reason':'Blocking\x20question\x20'+d['id']+'\x20not\x20answered','timestamp':new Date()['toISOString']()};if(d['expected_response']==='yes'&&e['response']!=='yes')return{'questions_asked':b,'user_responses':a,'approved':![],'declined_reason':d['id']+'\x20expected\x20\x27yes\x27,\x20got\x20\x27'+e['response']+'\x27','timestamp':new Date()['toISOString']()};if(d['expected_response']==='no'&&e['response']!=='no')return{'questions_asked':b,'user_responses':a,'approved':![],'declined_reason':d['id']+'\x20expected\x20\x27no\x27,\x20got\x20\x27'+e['response']+'\x27','timestamp':new Date()['toISOString']()};}return{'questions_asked':b,'user_responses':a,'approved':!![],'timestamp':new Date()['toISOString']()};}function generateGuardConfirmationText(a,b,c){const d=[];return d['push']('═══════════════════════════════════════════════════════════'),d['push']('\x20\x20GUARD\x20PUBLISH\x20CONFIRMATION'),d['push']('═══════════════════════════════════════════════════════════'),d['push']('Name:\x20'+(a['name']??'(unnamed)')),d['push']('Description:\x20'+(a['description']??'(none)')),d['push']('Binding\x20Scene:\x20'+(a['binding_scene_id']??'Standalone')),d['push'](''),d['push']('─\x20Layer\x201:\x20Static\x20Checklist\x20─────────────────────────────'),d['push']('Result:\x20'+(b['passed']?'✅\x20PASS':'❌\x20FAIL')),d['push']('Items:\x20'+b['checked_items']['length']+'\x20checked,\x20'+b['failed_items']['length']+'\x20failed,\x20'+b['warnings']['length']+'\x20warnings'),d['push'](''),d['push']('─\x20Layer\x202:\x20Risk\x20Assessment\x20──────────────────────────────'),d['push']('Overall:\x20'+c['overall_risk_level']['toUpperCase']()),d['push']('Blocking:\x20'+c['blocking_risks']['length']+'\x20|\x20Warning:\x20'+c['warning_risks']['length']),d['push']('Recommendation:\x20'+c['recommendation']),d['push'](''),d['push']('⚠️\x20\x20CRITICAL\x20REMINDER:\x20Guard\x20is\x20IMMUTABLE\x20after\x20creation.'),d['push']('\x20\x20\x20\x20There\x20is\x20NO\x20update\x20path.\x20If\x20the\x20rule\x20is\x20wrong,\x20you\x20must'),d['push']('\x20\x20\x20\x20create\x20a\x20NEW\x20Guard\x20and\x20rebind\x20the\x20host\x20object.'),d['push'](''),d['push']('Please\x20review\x20the\x20above\x20and\x20confirm\x20publication.'),d['push']('═══════════════════════════════════════════════════════════'),d['join']('\x0a');}function verifyGuardEnvironment(a){const b=[];return!a['binding_target']&&b['push']('No\x20binding\x20target\x20specified\x20—\x20Guard\x20will\x20be\x20Standalone\x20(verify\x20intent)'),{'testnet_tested':![],'binding_target_exists':!!a['binding_target'],'rely_chain_resolvable':!![],'passport_generated_successfully':![],'warnings':b};}export function progressiveGuardCheck(a){const b=runStaticChecklist(a);if(!b['passed'])return{'layer':'checklist','result':b};const c=a['root'],d=assessGuardRisks({'table':c?.['table']??[],'root':a['root'],'rely':c?.['rely']}),e=adaptRiskAssessment(d);if(e['recommendation']==='do_not_publish')return{'layer':'risk','result':e};return{'layer':'none','result':null};}