@wowok/agent-mcp 3.0.3 → 3.0.5

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 (300) hide show
  1. package/dist/evaluation/path-reasoning.d.ts +4 -2
  2. package/dist/evaluation/path-reasoning.js +1 -1
  3. package/dist/extensions/constraint-registry.d.ts +2 -2
  4. package/dist/extensions/constraint-registry.js +1 -1
  5. package/dist/extensions/custom-registry-file.d.ts +22 -0
  6. package/dist/extensions/custom-registry-file.js +1 -0
  7. package/dist/extensions/index.d.ts +2 -1
  8. package/dist/extensions/index.js +1 -1
  9. package/dist/extensions/industry-pack.d.ts +7 -0
  10. package/dist/extensions/industry-pack.js +1 -1
  11. package/dist/extensions/metric-registry.d.ts +2 -2
  12. package/dist/extensions/metric-registry.js +1 -1
  13. package/dist/extensions/modes.js +1 -1
  14. package/dist/extensions/registry.d.ts +2 -2
  15. package/dist/extensions/registry.js +1 -1
  16. package/dist/extensions/types.d.ts +4 -0
  17. package/dist/goal/GoalEngine.d.ts +13 -1
  18. package/dist/goal/GoalEngine.js +1 -1
  19. package/dist/goal/next-steps.d.ts +12 -0
  20. package/dist/goal/next-steps.js +1 -0
  21. package/dist/goal/pursue.d.ts +18 -0
  22. package/dist/goal/pursue.js +1 -0
  23. package/dist/goal/types.d.ts +72 -0
  24. package/dist/goal/types.js +1 -1
  25. package/dist/graph/onchain/analyze.d.ts +44 -0
  26. package/dist/graph/onchain/analyze.js +1 -0
  27. package/dist/graph/onchain/analyze.spec.d.ts +1 -0
  28. package/dist/graph/onchain/analyze.spec.js +1 -0
  29. package/dist/graph/onchain/anti-cheat.d.ts +39 -0
  30. package/dist/graph/onchain/anti-cheat.js +1 -0
  31. package/dist/graph/onchain/anti-cheat.spec.d.ts +1 -0
  32. package/dist/graph/onchain/anti-cheat.spec.js +1 -0
  33. package/dist/graph/onchain/dataplane.d.ts +44 -0
  34. package/dist/graph/onchain/dataplane.js +1 -0
  35. package/dist/graph/onchain/edge-schema.d.ts +60 -0
  36. package/dist/graph/onchain/edge-schema.js +1 -0
  37. package/dist/graph/onchain/expand.d.ts +4 -0
  38. package/dist/graph/onchain/expand.js +1 -0
  39. package/dist/graph/onchain/extract.d.ts +21 -0
  40. package/dist/graph/onchain/extract.js +1 -0
  41. package/dist/graph/onchain/index.d.ts +17 -0
  42. package/dist/graph/onchain/index.js +1 -0
  43. package/dist/graph/onchain/interest.d.ts +10 -0
  44. package/dist/graph/onchain/interest.js +1 -0
  45. package/dist/graph/onchain/interest.spec.d.ts +1 -0
  46. package/dist/graph/onchain/interest.spec.js +1 -0
  47. package/dist/graph/onchain/onchain.spec.d.ts +1 -0
  48. package/dist/graph/onchain/onchain.spec.js +1 -0
  49. package/dist/graph/onchain/order-status.d.ts +53 -0
  50. package/dist/graph/onchain/order-status.js +1 -0
  51. package/dist/graph/onchain/project-relationship.d.ts +3 -0
  52. package/dist/graph/onchain/project-relationship.js +1 -0
  53. package/dist/graph/onchain/sdk-batch.d.ts +117 -0
  54. package/dist/graph/onchain/sdk-batch.js +1 -0
  55. package/dist/graph/onchain/sdk-dataplane.d.ts +40 -0
  56. package/dist/graph/onchain/sdk-dataplane.js +1 -0
  57. package/dist/graph/onchain/strategy.d.ts +54 -0
  58. package/dist/graph/onchain/strategy.js +1 -0
  59. package/dist/graph/onchain/strategy.spec.d.ts +1 -0
  60. package/dist/graph/onchain/strategy.spec.js +1 -0
  61. package/dist/graph/onchain/types.d.ts +238 -0
  62. package/dist/graph/onchain/types.js +1 -0
  63. package/dist/graph/onchain/viewport.d.ts +5 -0
  64. package/dist/graph/onchain/viewport.js +1 -0
  65. package/dist/harness/recover.js +1 -1
  66. package/dist/index.js +1 -1
  67. package/dist/intent/enrich.js +1 -1
  68. package/dist/keeper/detectors.d.ts +1 -1
  69. package/dist/keeper/detectors.js +1 -1
  70. package/dist/knowledge/account-marks.js +1 -1
  71. package/dist/knowledge/anti-cheat.d.ts +2 -37
  72. package/dist/knowledge/anti-cheat.js +1 -1
  73. package/dist/knowledge/contract-invariants.js +1 -1
  74. package/dist/knowledge/event-semantics.js +1 -1
  75. package/dist/knowledge/getting-started.d.ts +37 -0
  76. package/dist/knowledge/getting-started.js +1 -0
  77. package/dist/knowledge/goal-completion.js +1 -1
  78. package/dist/knowledge/guard-puzzle.js +1 -1
  79. package/dist/knowledge/guard-render.d.ts +1 -0
  80. package/dist/knowledge/guard-render.js +1 -1
  81. package/dist/knowledge/guard-submission-brief.d.ts +83 -0
  82. package/dist/knowledge/guard-submission-brief.js +1 -0
  83. package/dist/knowledge/guard-submission-prompt.d.ts +13 -0
  84. package/dist/knowledge/guard-submission-prompt.js +1 -1
  85. package/dist/knowledge/index.d.ts +6 -4
  86. package/dist/knowledge/index.js +1 -1
  87. package/dist/knowledge/industry-registry.js +1 -1
  88. package/dist/knowledge/industry-strategy.d.ts +91 -0
  89. package/dist/knowledge/industry-strategy.js +1 -0
  90. package/dist/knowledge/jsonrpc-enum.js +1 -1
  91. package/dist/knowledge/market-metrics.d.ts +14 -3
  92. package/dist/knowledge/market-metrics.js +1 -1
  93. package/dist/knowledge/migration-preflight.js +1 -1
  94. package/dist/knowledge/operation-dictionary.d.ts +1 -1
  95. package/dist/knowledge/safety-rules.js +1 -1
  96. package/dist/knowledge/scenario-topology.d.ts +6 -1
  97. package/dist/knowledge/scenario-topology.js +1 -1
  98. package/dist/knowledge/service-ledger.js +1 -1
  99. package/dist/knowledge/service-risk-node.d.ts +3 -0
  100. package/dist/knowledge/service-risk-node.js +1 -0
  101. package/dist/knowledge/service-risk.d.ts +2 -0
  102. package/dist/knowledge/service-risk.js +1 -1
  103. package/dist/knowledge/service-templates.d.ts +2 -0
  104. package/dist/knowledge/service-templates.js +1 -1
  105. package/dist/knowledge/strategy-manuals.d.ts +17 -0
  106. package/dist/knowledge/strategy-manuals.js +1 -0
  107. package/dist/knowledge/supply-chain.d.ts +3 -1
  108. package/dist/knowledge/supply-chain.js +1 -1
  109. package/dist/knowledge/template-registry.js +1 -1
  110. package/dist/knowledge/tools-reference.js +1 -1
  111. package/dist/knowledge/workflow-guidance.d.ts +3 -118
  112. package/dist/knowledge/workflow-guidance.js +1 -1
  113. package/dist/knowledge/workspace-lists.js +1 -1
  114. package/dist/monitor/MonitorLoop.js +1 -1
  115. package/dist/monitor/ScopeResolver.js +1 -1
  116. package/dist/participation/radar-core.d.ts +15 -15
  117. package/dist/participation/radar-core.js +1 -1
  118. package/dist/persona/analyzer.d.ts +2 -1
  119. package/dist/persona/bridge.d.ts +5 -1
  120. package/dist/persona/bridge.js +1 -1
  121. package/dist/persona/defaults.js +1 -1
  122. package/dist/persona/distill-goal.d.ts +7 -1
  123. package/dist/persona/distill-goal.js +1 -1
  124. package/dist/persona/index.d.ts +13 -3
  125. package/dist/persona/index.js +1 -1
  126. package/dist/persona/model.d.ts +12 -2
  127. package/dist/persona/model.js +1 -1
  128. package/dist/persona/overrides.d.ts +1 -0
  129. package/dist/persona/overrides.js +1 -1
  130. package/dist/persona/topology-focus.d.ts +29 -0
  131. package/dist/persona/topology-focus.js +1 -0
  132. package/dist/persona/types.d.ts +81 -0
  133. package/dist/playbooks/service-build/business-puzzle.js +1 -1
  134. package/dist/playbooks/service-build/context-assembly.js +1 -1
  135. package/dist/playbooks/service-build/machine-nodes.js +1 -1
  136. package/dist/playbooks/service-build/machine-panorama.js +1 -1
  137. package/dist/playbooks/service-build/object-panorama.js +1 -1
  138. package/dist/playbooks/service-build/participation-radar.js +1 -1
  139. package/dist/playbooks/service-build/relationship-profile.d.ts +1 -0
  140. package/dist/playbooks/service-build/relationship-profile.js +1 -1
  141. package/dist/playbooks/service-build/service-panorama.d.ts +4 -0
  142. package/dist/playbooks/service-build/service-panorama.js +1 -1
  143. package/dist/playbooks/service-build/topology-query.d.ts +14 -0
  144. package/dist/playbooks/service-build/topology-query.js +1 -0
  145. package/dist/role/index.d.ts +1 -0
  146. package/dist/role/index.js +1 -1
  147. package/dist/role/profiles.d.ts +26 -0
  148. package/dist/role/profiles.js +1 -0
  149. package/dist/safety/confirm-gate.d.ts +4 -1
  150. package/dist/safety/confirm-gate.js +1 -1
  151. package/dist/schema/call/allocation.d.ts +11 -6
  152. package/dist/schema/call/arbitration.d.ts +5 -0
  153. package/dist/schema/call/base.d.ts +5 -0
  154. package/dist/schema/call/base.js +1 -1
  155. package/dist/schema/call/bridge.d.ts +26 -1
  156. package/dist/schema/call/contact.d.ts +5 -0
  157. package/dist/schema/call/demand.d.ts +5 -0
  158. package/dist/schema/call/guard.d.ts +35 -20
  159. package/dist/schema/call/machine.d.ts +10 -0
  160. package/dist/schema/call/order.d.ts +5 -0
  161. package/dist/schema/call/payment.d.ts +5 -0
  162. package/dist/schema/call/permission.d.ts +5 -0
  163. package/dist/schema/call/personal.d.ts +5 -0
  164. package/dist/schema/call/progress.d.ts +5 -0
  165. package/dist/schema/call/proof.d.ts +10 -0
  166. package/dist/schema/call/repository.d.ts +5 -0
  167. package/dist/schema/call/repository.js +1 -1
  168. package/dist/schema/call/reward.d.ts +5 -0
  169. package/dist/schema/call/semantic.js +1 -1
  170. package/dist/schema/call/service.d.ts +9 -4
  171. package/dist/schema/call/treasury.d.ts +5 -0
  172. package/dist/schema/common/index.js +1 -1
  173. package/dist/schema/employee/index.d.ts +7 -7
  174. package/dist/schema/evaluation/index.d.ts +22 -9
  175. package/dist/schema/evaluation/index.js +1 -1
  176. package/dist/schema/goal/index.d.ts +37 -1
  177. package/dist/schema/goal/index.js +1 -1
  178. package/dist/schema/goal/planning.d.ts +1 -1
  179. package/dist/schema/index.d.ts +2 -0
  180. package/dist/schema/index.js +1 -1
  181. package/dist/schema/industry-pack/index.d.ts +7 -0
  182. package/dist/schema/industry-pack/index.js +1 -1
  183. package/dist/schema/interaction/index.d.ts +34 -0
  184. package/dist/schema/interaction/index.js +1 -0
  185. package/dist/schema/local/index.d.ts +8 -4
  186. package/dist/schema/local/index.js +1 -1
  187. package/dist/schema/messenger/index.d.ts +324 -64
  188. package/dist/schema/messenger/index.js +1 -1
  189. package/dist/schema/operations.d.ts +236 -11
  190. package/dist/schema/operations.js +1 -1
  191. package/dist/schema/persona/index.d.ts +15743 -0
  192. package/dist/schema/persona/index.js +1 -1
  193. package/dist/schema/query/bi.d.ts +869 -2
  194. package/dist/schema/query/bi.js +1 -1
  195. package/dist/schema/query/index.d.ts +163 -41
  196. package/dist/schema/query/index.js +1 -1
  197. package/dist/schema/schema-query/index.d.ts +16 -0
  198. package/dist/schema/schema-query/index.js +1 -1
  199. package/dist/schema/schema-version.js +1 -1
  200. package/dist/schema/strategy-review/index.d.ts +137 -0
  201. package/dist/schema/strategy-review/index.js +1 -0
  202. package/dist/schema/trust/index.d.ts +6 -6
  203. package/dist/schema/workflow/index.d.ts +2 -2
  204. package/dist/schema-query-impl/index.js +1 -1
  205. package/dist/schemas/account_operation.output.json +8 -4
  206. package/dist/schemas/account_operation.schema.json +6 -2
  207. package/dist/schemas/ask_user.output.json +54 -0
  208. package/dist/schemas/ask_user.schema.json +78 -0
  209. package/dist/schemas/bridge_operation.schema.json +50 -5
  210. package/dist/schemas/evaluation_operation.output.json +24 -0
  211. package/dist/schemas/goal_operation.schema.json +124 -0
  212. package/dist/schemas/guard2file.schema.json +10 -1
  213. package/dist/schemas/index.json +13 -1
  214. package/dist/schemas/industry_pack_operation.output.json +39 -0
  215. package/dist/schemas/local_mark_operation.schema.json +2 -2
  216. package/dist/schemas/machineNode2file.schema.json +10 -1
  217. package/dist/schemas/messenger_operation.output.json +678 -200
  218. package/dist/schemas/messenger_operation.schema.json +74 -239
  219. package/dist/schemas/onchain_events.output.json +2 -2
  220. package/dist/schemas/onchain_operations.schema.json +183 -21
  221. package/dist/schemas/onchain_operations_allocation.schema.json +10 -1
  222. package/dist/schemas/onchain_operations_arbitration.schema.json +10 -1
  223. package/dist/schemas/onchain_operations_contact.schema.json +10 -1
  224. package/dist/schemas/onchain_operations_demand.schema.json +10 -1
  225. package/dist/schemas/onchain_operations_gen_passport.schema.json +10 -1
  226. package/dist/schemas/onchain_operations_gen_proof.schema.json +10 -1
  227. package/dist/schemas/onchain_operations_guard.schema.json +10 -1
  228. package/dist/schemas/onchain_operations_machine.schema.json +10 -1
  229. package/dist/schemas/onchain_operations_order.schema.json +10 -1
  230. package/dist/schemas/onchain_operations_payment.schema.json +10 -1
  231. package/dist/schemas/onchain_operations_permission.schema.json +10 -1
  232. package/dist/schemas/onchain_operations_personal.schema.json +10 -1
  233. package/dist/schemas/onchain_operations_progress.schema.json +10 -1
  234. package/dist/schemas/onchain_operations_proof.schema.json +10 -1
  235. package/dist/schemas/onchain_operations_repository.schema.json +13 -4
  236. package/dist/schemas/onchain_operations_reward.schema.json +10 -1
  237. package/dist/schemas/onchain_operations_service.schema.json +10 -1
  238. package/dist/schemas/onchain_operations_treasury.schema.json +10 -1
  239. package/dist/schemas/onchain_table_data.output.json +184 -0
  240. package/dist/schemas/onchain_table_data.schema.json +43 -43
  241. package/dist/schemas/persona_operation.output.json +37778 -262
  242. package/dist/schemas/persona_operation.schema.json +5960 -1
  243. package/dist/schemas/query_toolkit.output.json +1580 -2
  244. package/dist/schemas/query_toolkit.schema.json +194 -32
  245. package/dist/schemas/schema_query.schema.json +25 -1
  246. package/dist/schemas/strategy_review_operation.output.json +532 -0
  247. package/dist/schemas/strategy_review_operation.schema.json +66 -0
  248. package/dist/schemas/wowok_buildin_info.output.json +188 -6
  249. package/dist/schemas/wowok_buildin_info.schema.json +14 -0
  250. package/dist/strategy/collectors.d.ts +66 -0
  251. package/dist/strategy/collectors.js +1 -0
  252. package/dist/strategy/collectors.spec.d.ts +1 -0
  253. package/dist/strategy/collectors.spec.js +1 -0
  254. package/dist/strategy/index.d.ts +5 -0
  255. package/dist/strategy/index.js +1 -0
  256. package/dist/strategy/metrics.d.ts +20 -0
  257. package/dist/strategy/metrics.js +1 -0
  258. package/dist/strategy/review.d.ts +48 -0
  259. package/dist/strategy/review.js +1 -0
  260. package/dist/strategy/scorecard.d.ts +32 -0
  261. package/dist/strategy/scorecard.js +1 -0
  262. package/dist/strategy/store.d.ts +26 -0
  263. package/dist/strategy/store.js +1 -0
  264. package/dist/tools/handlers/ask-user.d.ts +3 -0
  265. package/dist/tools/handlers/ask-user.js +1 -0
  266. package/dist/tools/handlers/config.js +1 -1
  267. package/dist/tools/handlers/evaluation.js +1 -1
  268. package/dist/tools/handlers/goal.js +1 -1
  269. package/dist/tools/handlers/industry-pack.js +1 -1
  270. package/dist/tools/handlers/local.js +1 -1
  271. package/dist/tools/handlers/messenger.js +1 -1
  272. package/dist/tools/handlers/onchain.js +1 -1
  273. package/dist/tools/handlers/permission.js +1 -1
  274. package/dist/tools/handlers/persona.js +1 -1
  275. package/dist/tools/handlers/query.d.ts +6 -0
  276. package/dist/tools/handlers/query.js +1 -1
  277. package/dist/tools/handlers/schema-query.js +1 -1
  278. package/dist/tools/handlers/strategy-review.d.ts +2 -0
  279. package/dist/tools/handlers/strategy-review.js +1 -0
  280. package/dist/tools/handlers/watch.js +1 -1
  281. package/dist/tools/handlers/workflow.js +1 -1
  282. package/dist/tools/index.d.ts +5 -2
  283. package/dist/tools/index.js +1 -1
  284. package/dist/tools/registry/agent.js +1 -1
  285. package/dist/tools/registry/bridge.js +1 -1
  286. package/dist/tools/registry/business.js +1 -1
  287. package/dist/tools/registry/interaction.d.ts +2 -0
  288. package/dist/tools/registry/interaction.js +1 -0
  289. package/dist/tools/registry/local.js +1 -1
  290. package/dist/tools/registry/messenger.js +1 -1
  291. package/dist/tools/registry/monitor.js +1 -1
  292. package/dist/tools/registry/onchain.js +1 -1
  293. package/dist/tools/registry/query.js +1 -1
  294. package/dist/tools/rules-hook.js +1 -1
  295. package/dist/tools/shared.d.ts +2 -1
  296. package/dist/tools/shared.js +1 -1
  297. package/dist/tools/types.d.ts +7 -1
  298. package/dist/tools/wrap.d.ts +3 -3
  299. package/dist/tools/wrap.js +1 -1
  300. package/package.json +2 -2
@@ -1 +1 @@
1
- function categorizeNodeType(a){if(a['startsWith']('logic_'))return'decision';if(a==='context')return'context';if(a==='identifier')return'leaf';if(a==='query')return'query';if(a['startsWith']('calc_')||a['startsWith']('convert_'))return'computation';if(a['startsWith']('vec_'))return'computation';if(a['startsWith']('query_reward_')||a['startsWith']('query_progress_'))return'query';return'computation';}function shortNodeLabel(a){const b=a['type'];switch(b){case'logic_and':return'AND';case'logic_or':return'OR';case'logic_not':return'NOT';case'logic_equal':return'==';case'logic_as_u256_equal':return'==#';case'logic_as_u256_greater':return'>';case'logic_as_u256_greater_or_equal':return'>=';case'logic_as_u256_lesser':return'<';case'logic_as_u256_lesser_or_equal':return'<=';case'logic_string_contains':return'contains';case'logic_string_nocase_contains':return'contains~';case'logic_string_nocase_equal':return'==~';case'calc_number_add':return'+';case'calc_number_subtract':return'-';case'calc_number_multiply':return'*';case'calc_number_divide':return'/';case'calc_number_mod':return'%';case'calc_string_length':return'len';case'calc_string_contains':return'contains';case'calc_string_nocase_contains':return'contains~';case'calc_string_nocase_equal':return'==~';case'calc_string_indexof':return'indexOf';case'calc_string_nocase_indexof':return'indexOf~';case'convert_number_address':return'→Addr';case'convert_address_number':return'→Num';case'convert_number_string':return'→Str';case'convert_string_number':return'→Num';case'convert_safe_u8':return'→U8';case'convert_safe_u16':return'→U16';case'convert_safe_u32':return'→U32';case'convert_safe_u64':return'→U64';case'convert_safe_u128':return'→U128';case'convert_safe_u256':return'→U256';case'value_type':return'typeOf';case'vec_length':return'len';case'vec_contains_bool':return'∈?';case'vec_contains_address':return'∈?';case'vec_contains_string':return'∈?';case'vec_contains_string_nocase':return'∈?~';case'vec_contains_number':return'∈?';case'vec_indexof_bool':return'idx';case'vec_indexof_address':return'idx';case'vec_indexof_string':return'idx';case'vec_indexof_string_nocase':return'idx~';case'vec_indexof_number':return'idx';case'query':return'Q:'+(typeof a['query']==='number'?'#'+a['query']:a['query']);case'query_reward_record_count':return'reward.count';case'query_reward_record_exists':return'reward.exists';case'query_reward_record_find':return'reward.find';case'query_progress_history_find':return'history.find';case'query_progress_history_session_find':return'session.find';case'query_progress_history_session_forward_find':return'forward.find';case'query_progress_history_session_count':return'session.count';case'query_progress_history_session_forward_count':return'forward.count';case'query_progress_history_session_forward_retained_submission_count':return'retained.count';case'identifier':return'id['+(a['identifier']??'?')+']';case'context':return a['context']??'ctx';default:return b;}}let nodeIdCounter=0x0;function makeNodeId(a){return nodeIdCounter++,a+'_'+nodeIdCounter;}function sanitizeMermaidLabel(a){if(/[<>"\[\]{}()|&]/['test'](a))return'\x22'+a['replace'](/"/g,'\x27')+'\x22';return a;}const GUARD_NODE_COLORS={'control':{'fill':'#3b82f6','stroke':'#1e40af'},'decision':{'fill':'#f59e0b','stroke':'#92400e'},'computation':{'fill':'#8b5cf6','stroke':'#6d28d9'},'query':{'fill':'#06b6d4','stroke':'#0e7490'},'leaf':{'fill':'#6b7280','stroke':'#374151'},'context':{'fill':'#10b981','stroke':'#065f46'}};function colorCategoryForNodeType(a){if(a==='logic_and'||a==='logic_or')return'control';if(a==='logic_not'||a['startsWith']('logic_'))return'decision';if(a['startsWith']('calc_')||a['startsWith']('convert_')||a['startsWith']('vec_'))return'computation';if(a==='query'||a['startsWith']('query_'))return'query';if(a==='identifier')return'leaf';if(a==='context')return'context';return'computation';}export function renderGuardMermaid(a,b){const c=b?.['colored']!==![];nodeIdCounter=0x0;const d=['flowchart\x20TD'];c&&(d['push']('\x20\x20%%\x20Color\x20Legend\x20(BehaviorTree.CPP-inspired\x20semantic\x20roles):'),d['push']('\x20\x20%%\x20\x20\x20blue\x20\x20\x20#3b82f6\x20-\x20control\x20\x20\x20\x20\x20(logic_and,\x20logic_or)'),d['push']('\x20\x20%%\x20\x20\x20amber\x20\x20#f59e0b\x20-\x20decision\x20\x20\x20\x20(logic_not,\x20comparisons)'),d['push']('\x20\x20%%\x20\x20\x20purple\x20#8b5cf6\x20-\x20computation\x20(calc_*,\x20convert_*,\x20vec_*)'),d['push']('\x20\x20%%\x20\x20\x20cyan\x20\x20\x20#06b6d4\x20-\x20query\x20\x20\x20\x20\x20\x20\x20(query,\x20query_*)'),d['push']('\x20\x20%%\x20\x20\x20gray\x20\x20\x20#6b7280\x20-\x20leaf\x20\x20\x20\x20\x20\x20\x20\x20(identifier)'),d['push']('\x20\x20%%\x20\x20\x20green\x20\x20#10b981\x20-\x20context\x20\x20\x20\x20\x20(Signer,\x20Clock,\x20Guard)'),d['push']('\x20\x20%%\x20Node\x20shapes:\x20{}=decision,\x20[]=computation/query,\x20([])=leaf,\x20{{}}=context'));const e=[],f=[],g=[];function h(i,j,k){const l=makeNodeId('n'),m=categorizeNodeType(i['type']),n=shortNodeLabel(i);let o='[',p=']';switch(m){case'decision':o='{',p='}';break;case'context':o='{{',p='}}';break;case'leaf':o='([',p='])';break;case'query':case'computation':default:o='[',p=']';break;}e['push'](''+l+o+sanitizeMermaidLabel(n)+p),g['push']({'id':l,'type':i['type']});j&&(k?f['push']('\x20\x20'+j+'\x20-->\x20'+l+':\x20'+sanitizeMermaidLabel(k)):f['push']('\x20\x20'+j+'\x20-->\x20'+l));i['nodes']&&Array['isArray'](i['nodes'])&&i['nodes']['forEach']((q,r)=>{h(q,l,'['+r+']');});i['node']&&h(i['node'],l,'child');i['nodeLeft']&&h(i['nodeLeft'],l,'left');i['nodeRight']&&h(i['nodeRight'],l,'right');i['parameters']&&Array['isArray'](i['parameters'])&&i['parameters']['forEach']((q,r)=>{h(q,l,'param['+r+']');});if(i['historyIdx'])h(i['historyIdx'],l,'historyIdx');if(i['sessionIdx'])h(i['sessionIdx'],l,'sessionIdx');if(i['forwardIdx'])h(i['forwardIdx'],l,'forwardIdx');if(i['where'])h(i['where'],l,'where');if(i['find'])h(i['find'],l,'find');if(i['objectLeft'])h(i['objectLeft'],l,'objLeft');if(i['objectRight'])h(i['objectRight'],l,'objRight');if(i['recipient'])h(i['recipient'],l,'recipient');return l;}h(a),d['push'](...e['map'](i=>'\x20\x20'+i)),d['push'](...f);if(c){d['push'](''),d['push']('\x20\x20%%\x20Node\x20colors\x20(BehaviorTree.CPP-inspired\x20semantic\x20roles)');for(const {id:i,type:j}of g){const k=colorCategoryForNodeType(j),l=GUARD_NODE_COLORS[k];d['push']('\x20\x20style\x20'+i+'\x20fill:'+l['fill']+',stroke:'+l['stroke']+',color:#fff');}}return d['join']('\x0a');}export function renderGuardTreeIndented(a){const {root:b,table:c,guardName:d,guardAddress:e,rely:f}=a,h=[];function i(k){const l=k['type'];if(l==='identifier'){const m=c?.['find'](o=>o['identifier']===k['identifier']),n=m?.['name']?'\x20\x22'+m['name']+'\x22':'';return'identifier['+(k['identifier']??'?')+']'+n;}if(l==='context')return'context('+(k['context']??'?')+')';if(l==='query'){const o=k['object']?.['convert_witness'],p=k['object']?.['identifier'],q=o!==undefined?',\x20witness='+o:'',r=p!==undefined?',\x20id['+p+']':'',s=k['parameters']&&k['parameters']['length']>0x0?',\x20params=['+k['parameters']['map'](u=>shortNodeLabel(u))['join'](',\x20')+']':'';return'query('+(typeof k['query']==='number'?'#'+k['query']:k['query'])+r+q+s+')';}return shortNodeLabel(k);}function j(k,l,m){const n='\x20\x20'['repeat'](l),o=l===0x0?'-\x20':'-\x20',p=m?m+':\x20':'',q=!k['nodes']&&!k['node']&&!k['nodeLeft']&&!k['nodeRight']&&!k['parameters']?.['length']&&!k['historyIdx']&&!k['sessionIdx']&&!k['forwardIdx']&&!k['where']&&!k['find']&&!k['objectLeft']&&!k['objectRight']&&!k['recipient'];q?h['push'](''+n+o+p+i(k)):h['push'](''+n+o+p+k['type']);k['nodes']&&Array['isArray'](k['nodes'])&&k['nodes']['forEach']((r,s)=>j(r,l+0x1,'child['+s+']'));k['node']&&j(k['node'],l+0x1,'child');k['nodeLeft']&&j(k['nodeLeft'],l+0x1,'left');k['nodeRight']&&j(k['nodeRight'],l+0x1,'right');k['parameters']&&Array['isArray'](k['parameters'])&&k['parameters']['forEach']((r,s)=>j(r,l+0x1,'param['+s+']'));if(k['historyIdx'])j(k['historyIdx'],l+0x1,'historyIdx');if(k['sessionIdx'])j(k['sessionIdx'],l+0x1,'sessionIdx');if(k['forwardIdx'])j(k['forwardIdx'],l+0x1,'forwardIdx');if(k['where'])j(k['where'],l+0x1,'where');if(k['find'])j(k['find'],l+0x1,'find');if(k['objectLeft'])j(k['objectLeft'],l+0x1,'objLeft');if(k['objectRight'])j(k['objectRight'],l+0x1,'objRight');if(k['recipient'])j(k['recipient'],l+0x1,'recipient');}h['push']('#\x20Guard\x20Tree\x20Definition'),h['push']('');d&&h['push']('**Guard:**\x20'+d);e&&h['push']('**Address:**\x20'+e);c&&h['push']('**Table\x20Entries:**\x20'+c['length']);f&&f['guards']['length']>0x0&&h['push']('**Rely:**\x20'+f['guards']['length']+'\x20guard(s)'+(f['logic_or']?'\x20(logic_or)':'\x20(logic_and)'));h['push'](''),h['push']('##\x20Root'),j(b,0x0);if(c&&c['length']>0x0){h['push'](''),h['push']('##\x20Table'),h['push'](''),h['push']('|\x20identifier\x20|\x20b_submission\x20|\x20value_type\x20|\x20value\x20|\x20name\x20|'),h['push']('|------------|-------------|------------|-------|------|');for(const k of c){const l=k['value']===undefined?'-':String(k['value']),m=l['replace'](/\|/g,'\x5c|')['replace'](/\n/g,'\x20'),n=k['name']??'-';h['push']('|\x20'+k['identifier']+'\x20|\x20'+k['b_submission']+'\x20|\x20'+k['value_type']+'\x20|\x20'+m+'\x20|\x20'+n+'\x20|');}h['push'](''),h['push']('##\x20Table\x20JSON'),h['push'](''),h['push']('```json'),h['push'](JSON['stringify'](c,null,0x2)),h['push']('```');}if(f&&f['guards']['length']>0x0){h['push'](''),h['push']('##\x20Rely'),h['push'](''),h['push']('Logic:\x20'+(f['logic_or']?'OR':'AND'));for(const o of f['guards']){h['push']('-\x20'+o);}}return h['push'](''),h['push']('##\x20JSON\x20Definition'),h['push'](''),h['push']('```json'),h['push'](JSON['stringify']({'root':b,'table':c,'guardName':d,'guardAddress':e,'rely':f},null,0x2)),h['push']('```'),h['join']('\x0a');}export function parseGuardTreeIndented(a){const b=[],c=a['matchAll'](/```json\s*\n([\s\S]*?)```/g);let d=null;for(const k of c){d=k[0x1];}if(d)try{const l=JSON['parse'](d['trim']());if(l&&typeof l==='object'){if('root'in l&&l['root']&&typeof l['root']==='object'&&'type'in l['root'])return{'success':!![],'data':l['root'],'errors':[]};if('type'in l)return{'success':!![],'data':l,'errors':[]};}}catch(m){b['push']('JSON\x20code\x20block\x20parse\x20error:\x20'+m['message']);}const f=a['split']('\x0a')['filter'](n=>n['trim']()['startsWith']('-\x20'));if(f['length']===0x0)return{'success':![],'errors':['No\x20outline\x20entries\x20found.\x20Use\x20\x27-\x20\x27\x20prefixed\x20lines\x20or\x20a\x20JSON\x20code\x20block.']};const g=[];let h=null;function i(n){const o=n['match'](/^(\s*)- /);return o?o[0x1]['length']/0x2:0x0;}function j(n){const o=n['replace'](/^\s*- /,'')['trim'](),p=o['match'](/^([^:]+):\s*(.*)$/),q=p?p[0x1]['trim']():undefined,r=p?p[0x2]['trim']():o,s=r['match'](/^identifier\[(\d+)\](?:\s+"(.+)")?$/);if(s)return{'label':q,'node':{'type':'identifier','identifier':parseInt(s[0x1],0xa)}};const t=r['match'](/^context\((\w+)\)$/);if(t)return{'label':q,'node':{'type':'context','context':t[0x1]}};const u=r['match'](/^query\((.+?)\)$/);if(u){const v=u[0x1],w=v['split'](',')['map'](A=>A['trim']()),x=w[0x0]['replace'](/^#/,''),y=/^\d+$/['test'](x),z={'type':'query','query':y?parseInt(x,0xa):x};for(const A of w['slice'](0x1)){const B=A['match'](/^id\[(\d+)\]$/);B&&(z['object']={'identifier':parseInt(B[0x1],0xa)});const C=A['match'](/^witness=(\d+)$/);C&&(z['object']={...z['object']||{},'convert_witness':parseInt(C[0x1],0xa)});}return{'label':q,'node':z};}return{'label':q,'node':{'type':r}};}for(const n of f){const o=i(n),{label:p,node:q}=j(n);if(o===0x0)h=q,g['length']=0x0,g['push']({'node':q,'depth':o});else{while(g['length']>0x0&&g[g['length']-0x1]['depth']>=o){g['pop']();}const r=g[g['length']-0x1];if(!r){b['push']('Orphaned\x20node\x20at\x20depth\x20'+o+':\x20'+n);continue;}if(p){const s=p['match'](/^child\[(\d+)\]$/),t=p['match'](/^param\[(\d+)\]$/);if(s){if(!r['node']['nodes'])r['node']['nodes']=[];r['node']['nodes']['push'](q);}else{if(t){if(!r['node']['parameters'])r['node']['parameters']=[];r['node']['parameters']['push'](q);}else{if(p==='child')r['node']['node']=q;else{if(p==='left')r['node']['nodeLeft']=q;else{if(p==='right')r['node']['nodeRight']=q;else{if(p==='historyIdx')r['node']['historyIdx']=q;else{if(p==='sessionIdx')r['node']['sessionIdx']=q;else{if(p==='forwardIdx')r['node']['forwardIdx']=q;else{if(p==='where')r['node']['where']=q;else{if(p==='find')r['node']['find']=q;else{if(p==='objLeft')r['node']['objectLeft']=q;else{if(p==='objRight')r['node']['objectRight']=q;else p==='recipient'&&(r['node']['recipient']=q);}}}}}}}}}}}}g['push']({'node':q,'depth':o});}}if(!h)return{'success':![],'errors':['No\x20root\x20node\x20found\x20in\x20outline.']};return{'success':!![],'data':h,'errors':b};}export function renderGuardAscii(a){const {root:b,table:c,guardName:d,guardAddress:e,rely:f}=a,h=[];if(d)h['push']('Guard:\x20'+d);if(e)h['push']('Address:\x20'+e);if(d||e)h['push']('');function i(m){const n=m['type'],o=shortNodeLabel(m);if(n==='identifier'){const p=c?.['find'](u=>u['identifier']===m['identifier']),q=p?'\x20['+(typeof p['value_type']==='string'?p['value_type']:'type='+p['value_type'])+']':'',r=p&&p['value']!==undefined&&!p['b_submission']?',\x20value='+String(p['value']):'',s=p?.['b_submission']?'\x20(submission)':'';return''+o+q+r+s;}if(n==='context')return o+'\x20['+(m['context']??'?')+']';if(n==='query'){const u=m['object']?.['convert_witness'],v=u!==undefined?',\x20witness='+u:'';return''+o+v;}return o;}function j(m){const n=[];m['nodes']&&Array['isArray'](m['nodes'])&&m['nodes']['forEach']((o,p)=>n['push']({'node':o,'label':'child['+p+']'}));if(m['node'])n['push']({'node':m['node'],'label':'child'});if(m['nodeLeft'])n['push']({'node':m['nodeLeft'],'label':'left'});if(m['nodeRight'])n['push']({'node':m['nodeRight'],'label':'right'});m['parameters']&&Array['isArray'](m['parameters'])&&m['parameters']['forEach']((o,p)=>n['push']({'node':o,'label':'param['+p+']'}));if(m['historyIdx'])n['push']({'node':m['historyIdx'],'label':'historyIdx'});if(m['sessionIdx'])n['push']({'node':m['sessionIdx'],'label':'sessionIdx'});if(m['forwardIdx'])n['push']({'node':m['forwardIdx'],'label':'forwardIdx'});if(m['where'])n['push']({'node':m['where'],'label':'where'});if(m['find'])n['push']({'node':m['find'],'label':'find'});if(m['objectLeft'])n['push']({'node':m['objectLeft'],'label':'objLeft'});if(m['objectRight'])n['push']({'node':m['objectRight'],'label':'objRight'});if(m['recipient'])n['push']({'node':m['recipient'],'label':'recipient'});return n;}function k(m,n,o,p){const q=o?'└─\x20':'├─\x20',r=p?p+':\x20':'';h['push'](''+n+q+r+i(m));const s=j(m),t=n+(o?'\x20\x20\x20':'│\x20\x20');s['forEach']((u,v)=>{k(u['node'],t,v===s['length']-0x1,u['label']);});}h['push'](i(b));const l=j(b);l['forEach']((m,n)=>{k(m['node'],'',n===l['length']-0x1,m['label']);});if(c&&c['length']>0x0){h['push'](''),h['push']('Table:');for(const m of c){const n=typeof m['value_type']==='string'?m['value_type']:'type='+m['value_type'],o=m['value']!==undefined&&!m['b_submission']?',\x20value='+String(m['value']):'',p=m['b_submission']?'\x20(submission)':'',q=m['name']?'\x20\x22'+m['name']+'\x22':'';h['push']('\x20\x20id['+m['identifier']+']'+q+':\x20'+n+o+p);}}if(f&&f['guards']['length']>0x0){h['push'](''),h['push']('Rely\x20('+(f['logic_or']?'OR':'AND')+'):');for(const r of f['guards']){h['push']('\x20\x20-\x20'+r);}}return h['join']('\x0a');}export function renderGuardMarkmap(a){const {root:b,table:c,guardName:d,guardAddress:e,rely:f}=a,h=[],i=d?'Guard:\x20'+d:'Guard';h['push']('#\x20'+i);if(e)h['push']('');if(e)h['push']('**Address:**\x20'+e);h['push']('');function j(m,n){return'#'['repeat'](Math['min'](m+0x1,0x6))+'\x20'+n;}function k(m){const n=m['type'],o=shortNodeLabel(m);if(n==='identifier'){const p=c?.['find'](u=>u['identifier']===m['identifier']),q=p?'\x20['+(typeof p['value_type']==='string'?p['value_type']:'type='+p['value_type'])+']':'',r=p&&p['value']!==undefined&&!p['b_submission']?',\x20value='+String(p['value']):'',s=p?.['b_submission']?'\x20(submission)':'';return''+o+q+r+s;}if(n==='context')return o+'\x20['+(m['context']??'?')+']';if(n==='query'){const u=m['object']?.['convert_witness'],v=u!==undefined?',\x20witness='+u:'';return''+o+v;}return o;}function l(m,n,o){const p=o?o+':\x20':'';h['push'](j(n,''+p+k(m)));m['nodes']&&Array['isArray'](m['nodes'])&&m['nodes']['forEach']((q,r)=>l(q,n+0x1,'child['+r+']'));if(m['node'])l(m['node'],n+0x1,'child');if(m['nodeLeft'])l(m['nodeLeft'],n+0x1,'left');if(m['nodeRight'])l(m['nodeRight'],n+0x1,'right');m['parameters']&&Array['isArray'](m['parameters'])&&m['parameters']['forEach']((q,r)=>l(q,n+0x1,'param['+r+']'));if(m['historyIdx'])l(m['historyIdx'],n+0x1,'historyIdx');if(m['sessionIdx'])l(m['sessionIdx'],n+0x1,'sessionIdx');if(m['forwardIdx'])l(m['forwardIdx'],n+0x1,'forwardIdx');if(m['where'])l(m['where'],n+0x1,'where');if(m['find'])l(m['find'],n+0x1,'find');if(m['objectLeft'])l(m['objectLeft'],n+0x1,'objLeft');if(m['objectRight'])l(m['objectRight'],n+0x1,'objRight');if(m['recipient'])l(m['recipient'],n+0x1,'recipient');}h['push'](j(0x1,'Root')),l(b,0x2);if(c&&c['length']>0x0){h['push'](''),h['push']('##\x20Table');for(const m of c){const n=typeof m['value_type']==='string'?m['value_type']:'type='+m['value_type'],o=m['value']!==undefined&&!m['b_submission']?',\x20value='+String(m['value']):'',p=m['b_submission']?'\x20(submission)':'',q=m['name']?'\x20\x22'+m['name']+'\x22':'';h['push']('-\x20id['+m['identifier']+']'+q+':\x20'+n+o+p);}}if(f&&f['guards']['length']>0x0){h['push'](''),h['push']('##\x20Rely\x20('+(f['logic_or']?'OR':'AND')+')');for(const r of f['guards']){h['push']('-\x20'+r);}}return h['join']('\x0a');}export function parseGuardTableJSON(a){const b=a['match'](/##\s*Table JSON[^\n]*\n\s*```json\s*\n([\s\S]*?)```/i);if(!b)return null;try{const c=JSON['parse'](b[0x1]['trim']());if(!Array['isArray'](c))return null;return c['filter'](d=>{return d&&typeof d==='object'&&typeof d['identifier']==='number'&&typeof d['b_submission']==='boolean';})['map'](d=>({'identifier':d['identifier'],'name':d['name'],'value_type':d['value_type'],'b_submission':d['b_submission'],'value':d['value']}));}catch{return null;}}
1
+ export function walkGuardTree(a,b){const c=[a];while(c['length']>0x0){const d=c['pop']();if(!d||typeof d!=='object')continue;b(d);if(Array['isArray'](d['nodes']))c['push'](...d['nodes']);if(d['node'])c['push'](d['node']);if(d['nodeLeft'])c['push'](d['nodeLeft']);if(d['nodeRight'])c['push'](d['nodeRight']);if(Array['isArray'](d['parameters']))c['push'](...d['parameters']);if(d['historyIdx'])c['push'](d['historyIdx']);if(d['sessionIdx'])c['push'](d['sessionIdx']);if(d['forwardIdx'])c['push'](d['forwardIdx']);if(d['where'])c['push'](d['where']);if(d['find'])c['push'](d['find']);if(d['objectLeft'])c['push'](d['objectLeft']);if(d['objectRight'])c['push'](d['objectRight']);if(d['recipient'])c['push'](d['recipient']);}}function categorizeNodeType(a){if(a['startsWith']('logic_'))return'decision';if(a==='context')return'context';if(a==='identifier')return'leaf';if(a==='query')return'query';if(a['startsWith']('calc_')||a['startsWith']('convert_'))return'computation';if(a['startsWith']('vec_'))return'computation';if(a['startsWith']('query_reward_')||a['startsWith']('query_progress_'))return'query';return'computation';}function shortNodeLabel(a){const b=a['type'];switch(b){case'logic_and':return'AND';case'logic_or':return'OR';case'logic_not':return'NOT';case'logic_equal':return'==';case'logic_as_u256_equal':return'==#';case'logic_as_u256_greater':return'>';case'logic_as_u256_greater_or_equal':return'>=';case'logic_as_u256_lesser':return'<';case'logic_as_u256_lesser_or_equal':return'<=';case'logic_string_contains':return'contains';case'logic_string_nocase_contains':return'contains~';case'logic_string_nocase_equal':return'==~';case'calc_number_add':return'+';case'calc_number_subtract':return'-';case'calc_number_multiply':return'*';case'calc_number_divide':return'/';case'calc_number_mod':return'%';case'calc_string_length':return'len';case'calc_string_contains':return'contains';case'calc_string_nocase_contains':return'contains~';case'calc_string_nocase_equal':return'==~';case'calc_string_indexof':return'indexOf';case'calc_string_nocase_indexof':return'indexOf~';case'convert_number_address':return'→Addr';case'convert_address_number':return'→Num';case'convert_number_string':return'→Str';case'convert_string_number':return'→Num';case'convert_safe_u8':return'→U8';case'convert_safe_u16':return'→U16';case'convert_safe_u32':return'→U32';case'convert_safe_u64':return'→U64';case'convert_safe_u128':return'→U128';case'convert_safe_u256':return'→U256';case'value_type':return'typeOf';case'vec_length':return'len';case'vec_contains_bool':return'∈?';case'vec_contains_address':return'∈?';case'vec_contains_string':return'∈?';case'vec_contains_string_nocase':return'∈?~';case'vec_contains_number':return'∈?';case'vec_indexof_bool':return'idx';case'vec_indexof_address':return'idx';case'vec_indexof_string':return'idx';case'vec_indexof_string_nocase':return'idx~';case'vec_indexof_number':return'idx';case'query':return'Q:'+(typeof a['query']==='number'?'#'+a['query']:a['query']);case'query_reward_record_count':return'reward.count';case'query_reward_record_exists':return'reward.exists';case'query_reward_record_find':return'reward.find';case'query_progress_history_find':return'history.find';case'query_progress_history_session_find':return'session.find';case'query_progress_history_session_forward_find':return'forward.find';case'query_progress_history_session_count':return'session.count';case'query_progress_history_session_forward_count':return'forward.count';case'query_progress_history_session_forward_retained_submission_count':return'retained.count';case'identifier':return'id['+(a['identifier']??'?')+']';case'context':return a['context']??'ctx';default:return b;}}let nodeIdCounter=0x0;function makeNodeId(a){return nodeIdCounter++,a+'_'+nodeIdCounter;}function sanitizeMermaidLabel(a){if(/[<>"\[\]{}()|&]/['test'](a))return'\x22'+a['replace'](/"/g,'\x27')+'\x22';return a;}const GUARD_NODE_COLORS={'control':{'fill':'#3b82f6','stroke':'#1e40af'},'decision':{'fill':'#f59e0b','stroke':'#92400e'},'computation':{'fill':'#8b5cf6','stroke':'#6d28d9'},'query':{'fill':'#06b6d4','stroke':'#0e7490'},'leaf':{'fill':'#6b7280','stroke':'#374151'},'context':{'fill':'#10b981','stroke':'#065f46'}};function colorCategoryForNodeType(a){if(a==='logic_and'||a==='logic_or')return'control';if(a==='logic_not'||a['startsWith']('logic_'))return'decision';if(a['startsWith']('calc_')||a['startsWith']('convert_')||a['startsWith']('vec_'))return'computation';if(a==='query'||a['startsWith']('query_'))return'query';if(a==='identifier')return'leaf';if(a==='context')return'context';return'computation';}export function renderGuardMermaid(a,b){const c=b?.['colored']!==![];nodeIdCounter=0x0;const d=['flowchart\x20TD'];c&&(d['push']('\x20\x20%%\x20Color\x20Legend\x20(BehaviorTree.CPP-inspired\x20semantic\x20roles):'),d['push']('\x20\x20%%\x20\x20\x20blue\x20\x20\x20#3b82f6\x20-\x20control\x20\x20\x20\x20\x20(logic_and,\x20logic_or)'),d['push']('\x20\x20%%\x20\x20\x20amber\x20\x20#f59e0b\x20-\x20decision\x20\x20\x20\x20(logic_not,\x20comparisons)'),d['push']('\x20\x20%%\x20\x20\x20purple\x20#8b5cf6\x20-\x20computation\x20(calc_*,\x20convert_*,\x20vec_*)'),d['push']('\x20\x20%%\x20\x20\x20cyan\x20\x20\x20#06b6d4\x20-\x20query\x20\x20\x20\x20\x20\x20\x20(query,\x20query_*)'),d['push']('\x20\x20%%\x20\x20\x20gray\x20\x20\x20#6b7280\x20-\x20leaf\x20\x20\x20\x20\x20\x20\x20\x20(identifier)'),d['push']('\x20\x20%%\x20\x20\x20green\x20\x20#10b981\x20-\x20context\x20\x20\x20\x20\x20(Signer,\x20Clock,\x20Guard)'),d['push']('\x20\x20%%\x20Node\x20shapes:\x20{}=decision,\x20[]=computation/query,\x20([])=leaf,\x20{{}}=context'));const e=[],f=[],g=[];function h(i,j,k){const l=makeNodeId('n'),m=categorizeNodeType(i['type']),n=shortNodeLabel(i);let o='[',p=']';switch(m){case'decision':o='{',p='}';break;case'context':o='{{',p='}}';break;case'leaf':o='([',p='])';break;case'query':case'computation':default:o='[',p=']';break;}e['push'](''+l+o+sanitizeMermaidLabel(n)+p),g['push']({'id':l,'type':i['type']});j&&(k?f['push']('\x20\x20'+j+'\x20-->\x20'+l+':\x20'+sanitizeMermaidLabel(k)):f['push']('\x20\x20'+j+'\x20-->\x20'+l));i['nodes']&&Array['isArray'](i['nodes'])&&i['nodes']['forEach']((q,r)=>{h(q,l,'['+r+']');});i['node']&&h(i['node'],l,'child');i['nodeLeft']&&h(i['nodeLeft'],l,'left');i['nodeRight']&&h(i['nodeRight'],l,'right');i['parameters']&&Array['isArray'](i['parameters'])&&i['parameters']['forEach']((q,r)=>{h(q,l,'param['+r+']');});if(i['historyIdx'])h(i['historyIdx'],l,'historyIdx');if(i['sessionIdx'])h(i['sessionIdx'],l,'sessionIdx');if(i['forwardIdx'])h(i['forwardIdx'],l,'forwardIdx');if(i['where'])h(i['where'],l,'where');if(i['find'])h(i['find'],l,'find');if(i['objectLeft'])h(i['objectLeft'],l,'objLeft');if(i['objectRight'])h(i['objectRight'],l,'objRight');if(i['recipient'])h(i['recipient'],l,'recipient');return l;}h(a),d['push'](...e['map'](i=>'\x20\x20'+i)),d['push'](...f);if(c){d['push'](''),d['push']('\x20\x20%%\x20Node\x20colors\x20(BehaviorTree.CPP-inspired\x20semantic\x20roles)');for(const {id:i,type:j}of g){const k=colorCategoryForNodeType(j),l=GUARD_NODE_COLORS[k];d['push']('\x20\x20style\x20'+i+'\x20fill:'+l['fill']+',stroke:'+l['stroke']+',color:#fff');}}return d['join']('\x0a');}export function renderGuardTreeIndented(a){const {root:b,table:c,guardName:d,guardAddress:e,rely:f}=a,h=[];function i(k){const l=k['type'];if(l==='identifier'){const m=c?.['find'](o=>o['identifier']===k['identifier']),n=m?.['name']?'\x20\x22'+m['name']+'\x22':'';return'identifier['+(k['identifier']??'?')+']'+n;}if(l==='context')return'context('+(k['context']??'?')+')';if(l==='query'){const o=k['object']?.['convert_witness'],p=k['object']?.['identifier'],q=o!==undefined?',\x20witness='+o:'',r=p!==undefined?',\x20id['+p+']':'',s=k['parameters']&&k['parameters']['length']>0x0?',\x20params=['+k['parameters']['map'](u=>shortNodeLabel(u))['join'](',\x20')+']':'';return'query('+(typeof k['query']==='number'?'#'+k['query']:k['query'])+r+q+s+')';}return shortNodeLabel(k);}function j(k,l,m){const n='\x20\x20'['repeat'](l),o=l===0x0?'-\x20':'-\x20',p=m?m+':\x20':'',q=!k['nodes']&&!k['node']&&!k['nodeLeft']&&!k['nodeRight']&&!k['parameters']?.['length']&&!k['historyIdx']&&!k['sessionIdx']&&!k['forwardIdx']&&!k['where']&&!k['find']&&!k['objectLeft']&&!k['objectRight']&&!k['recipient'];q?h['push'](''+n+o+p+i(k)):h['push'](''+n+o+p+k['type']);k['nodes']&&Array['isArray'](k['nodes'])&&k['nodes']['forEach']((r,s)=>j(r,l+0x1,'child['+s+']'));k['node']&&j(k['node'],l+0x1,'child');k['nodeLeft']&&j(k['nodeLeft'],l+0x1,'left');k['nodeRight']&&j(k['nodeRight'],l+0x1,'right');k['parameters']&&Array['isArray'](k['parameters'])&&k['parameters']['forEach']((r,s)=>j(r,l+0x1,'param['+s+']'));if(k['historyIdx'])j(k['historyIdx'],l+0x1,'historyIdx');if(k['sessionIdx'])j(k['sessionIdx'],l+0x1,'sessionIdx');if(k['forwardIdx'])j(k['forwardIdx'],l+0x1,'forwardIdx');if(k['where'])j(k['where'],l+0x1,'where');if(k['find'])j(k['find'],l+0x1,'find');if(k['objectLeft'])j(k['objectLeft'],l+0x1,'objLeft');if(k['objectRight'])j(k['objectRight'],l+0x1,'objRight');if(k['recipient'])j(k['recipient'],l+0x1,'recipient');}h['push']('#\x20Guard\x20Tree\x20Definition'),h['push']('');d&&h['push']('**Guard:**\x20'+d);e&&h['push']('**Address:**\x20'+e);c&&h['push']('**Table\x20Entries:**\x20'+c['length']);f&&f['guards']['length']>0x0&&h['push']('**Rely:**\x20'+f['guards']['length']+'\x20guard(s)'+(f['logic_or']?'\x20(logic_or)':'\x20(logic_and)'));h['push'](''),h['push']('##\x20Root'),j(b,0x0);if(c&&c['length']>0x0){h['push'](''),h['push']('##\x20Table'),h['push'](''),h['push']('|\x20identifier\x20|\x20b_submission\x20|\x20value_type\x20|\x20value\x20|\x20name\x20|'),h['push']('|------------|-------------|------------|-------|------|');for(const k of c){const l=k['value']===undefined?'-':String(k['value']),m=l['replace'](/\|/g,'\x5c|')['replace'](/\n/g,'\x20'),n=k['name']??'-';h['push']('|\x20'+k['identifier']+'\x20|\x20'+k['b_submission']+'\x20|\x20'+k['value_type']+'\x20|\x20'+m+'\x20|\x20'+n+'\x20|');}h['push'](''),h['push']('##\x20Table\x20JSON'),h['push'](''),h['push']('```json'),h['push'](JSON['stringify'](c,null,0x2)),h['push']('```');}if(f&&f['guards']['length']>0x0){h['push'](''),h['push']('##\x20Rely'),h['push'](''),h['push']('Logic:\x20'+(f['logic_or']?'OR':'AND'));for(const o of f['guards']){h['push']('-\x20'+o);}}return h['push'](''),h['push']('##\x20JSON\x20Definition'),h['push'](''),h['push']('```json'),h['push'](JSON['stringify']({'root':b,'table':c,'guardName':d,'guardAddress':e,'rely':f},null,0x2)),h['push']('```'),h['join']('\x0a');}export function parseGuardTreeIndented(a){const b=[],c=a['matchAll'](/```json\s*\n([\s\S]*?)```/g);let d=null;for(const k of c){d=k[0x1];}if(d)try{const l=JSON['parse'](d['trim']());if(l&&typeof l==='object'){if('root'in l&&l['root']&&typeof l['root']==='object'&&'type'in l['root'])return{'success':!![],'data':l['root'],'errors':[]};if('type'in l)return{'success':!![],'data':l,'errors':[]};}}catch(m){b['push']('JSON\x20code\x20block\x20parse\x20error:\x20'+m['message']);}const f=a['split']('\x0a')['filter'](n=>n['trim']()['startsWith']('-\x20'));if(f['length']===0x0)return{'success':![],'errors':['No\x20outline\x20entries\x20found.\x20Use\x20\x27-\x20\x27\x20prefixed\x20lines\x20or\x20a\x20JSON\x20code\x20block.']};const g=[];let h=null;function i(n){const o=n['match'](/^(\s*)- /);return o?o[0x1]['length']/0x2:0x0;}function j(n){const o=n['replace'](/^\s*- /,'')['trim'](),p=o['match'](/^([^:]+):\s*(.*)$/),q=p?p[0x1]['trim']():undefined,r=p?p[0x2]['trim']():o,s=r['match'](/^identifier\[(\d+)\](?:\s+"(.+)")?$/);if(s)return{'label':q,'node':{'type':'identifier','identifier':parseInt(s[0x1],0xa)}};const t=r['match'](/^context\((\w+)\)$/);if(t)return{'label':q,'node':{'type':'context','context':t[0x1]}};const u=r['match'](/^query\((.+?)\)$/);if(u){const v=u[0x1],w=v['split'](',')['map'](A=>A['trim']()),x=w[0x0]['replace'](/^#/,''),y=/^\d+$/['test'](x),z={'type':'query','query':y?parseInt(x,0xa):x};for(const A of w['slice'](0x1)){const B=A['match'](/^id\[(\d+)\]$/);B&&(z['object']={'identifier':parseInt(B[0x1],0xa)});const C=A['match'](/^witness=(\d+)$/);C&&(z['object']={...z['object']||{},'convert_witness':parseInt(C[0x1],0xa)});}return{'label':q,'node':z};}return{'label':q,'node':{'type':r}};}for(const n of f){const o=i(n),{label:p,node:q}=j(n);if(o===0x0)h=q,g['length']=0x0,g['push']({'node':q,'depth':o});else{while(g['length']>0x0&&g[g['length']-0x1]['depth']>=o){g['pop']();}const r=g[g['length']-0x1];if(!r){b['push']('Orphaned\x20node\x20at\x20depth\x20'+o+':\x20'+n);continue;}if(p){const s=p['match'](/^child\[(\d+)\]$/),t=p['match'](/^param\[(\d+)\]$/);if(s){if(!r['node']['nodes'])r['node']['nodes']=[];r['node']['nodes']['push'](q);}else{if(t){if(!r['node']['parameters'])r['node']['parameters']=[];r['node']['parameters']['push'](q);}else{if(p==='child')r['node']['node']=q;else{if(p==='left')r['node']['nodeLeft']=q;else{if(p==='right')r['node']['nodeRight']=q;else{if(p==='historyIdx')r['node']['historyIdx']=q;else{if(p==='sessionIdx')r['node']['sessionIdx']=q;else{if(p==='forwardIdx')r['node']['forwardIdx']=q;else{if(p==='where')r['node']['where']=q;else{if(p==='find')r['node']['find']=q;else{if(p==='objLeft')r['node']['objectLeft']=q;else{if(p==='objRight')r['node']['objectRight']=q;else p==='recipient'&&(r['node']['recipient']=q);}}}}}}}}}}}}g['push']({'node':q,'depth':o});}}if(!h)return{'success':![],'errors':['No\x20root\x20node\x20found\x20in\x20outline.']};return{'success':!![],'data':h,'errors':b};}export function renderGuardAscii(a){const {root:b,table:c,guardName:d,guardAddress:e,rely:f}=a,h=[];if(d)h['push']('Guard:\x20'+d);if(e)h['push']('Address:\x20'+e);if(d||e)h['push']('');function i(m){const n=m['type'],o=shortNodeLabel(m);if(n==='identifier'){const p=c?.['find'](u=>u['identifier']===m['identifier']),q=p?'\x20['+(typeof p['value_type']==='string'?p['value_type']:'type='+p['value_type'])+']':'',r=p&&p['value']!==undefined&&!p['b_submission']?',\x20value='+String(p['value']):'',s=p?.['b_submission']?'\x20(submission)':'';return''+o+q+r+s;}if(n==='context')return o+'\x20['+(m['context']??'?')+']';if(n==='query'){const u=m['object']?.['convert_witness'],v=u!==undefined?',\x20witness='+u:'';return''+o+v;}return o;}function j(m){const n=[];m['nodes']&&Array['isArray'](m['nodes'])&&m['nodes']['forEach']((o,p)=>n['push']({'node':o,'label':'child['+p+']'}));if(m['node'])n['push']({'node':m['node'],'label':'child'});if(m['nodeLeft'])n['push']({'node':m['nodeLeft'],'label':'left'});if(m['nodeRight'])n['push']({'node':m['nodeRight'],'label':'right'});m['parameters']&&Array['isArray'](m['parameters'])&&m['parameters']['forEach']((o,p)=>n['push']({'node':o,'label':'param['+p+']'}));if(m['historyIdx'])n['push']({'node':m['historyIdx'],'label':'historyIdx'});if(m['sessionIdx'])n['push']({'node':m['sessionIdx'],'label':'sessionIdx'});if(m['forwardIdx'])n['push']({'node':m['forwardIdx'],'label':'forwardIdx'});if(m['where'])n['push']({'node':m['where'],'label':'where'});if(m['find'])n['push']({'node':m['find'],'label':'find'});if(m['objectLeft'])n['push']({'node':m['objectLeft'],'label':'objLeft'});if(m['objectRight'])n['push']({'node':m['objectRight'],'label':'objRight'});if(m['recipient'])n['push']({'node':m['recipient'],'label':'recipient'});return n;}function k(m,n,o,p){const q=o?'└─\x20':'├─\x20',r=p?p+':\x20':'';h['push'](''+n+q+r+i(m));const s=j(m),t=n+(o?'\x20\x20\x20':'│\x20\x20');s['forEach']((u,v)=>{k(u['node'],t,v===s['length']-0x1,u['label']);});}h['push'](i(b));const l=j(b);l['forEach']((m,n)=>{k(m['node'],'',n===l['length']-0x1,m['label']);});if(c&&c['length']>0x0){h['push'](''),h['push']('Table:');for(const m of c){const n=typeof m['value_type']==='string'?m['value_type']:'type='+m['value_type'],o=m['value']!==undefined&&!m['b_submission']?',\x20value='+String(m['value']):'',p=m['b_submission']?'\x20(submission)':'',q=m['name']?'\x20\x22'+m['name']+'\x22':'';h['push']('\x20\x20id['+m['identifier']+']'+q+':\x20'+n+o+p);}}if(f&&f['guards']['length']>0x0){h['push'](''),h['push']('Rely\x20('+(f['logic_or']?'OR':'AND')+'):');for(const r of f['guards']){h['push']('\x20\x20-\x20'+r);}}return h['join']('\x0a');}export function renderGuardMarkmap(a){const {root:b,table:c,guardName:d,guardAddress:e,rely:f}=a,h=[],i=d?'Guard:\x20'+d:'Guard';h['push']('#\x20'+i);if(e)h['push']('');if(e)h['push']('**Address:**\x20'+e);h['push']('');function j(m,n){return'#'['repeat'](Math['min'](m+0x1,0x6))+'\x20'+n;}function k(m){const n=m['type'],o=shortNodeLabel(m);if(n==='identifier'){const p=c?.['find'](u=>u['identifier']===m['identifier']),q=p?'\x20['+(typeof p['value_type']==='string'?p['value_type']:'type='+p['value_type'])+']':'',r=p&&p['value']!==undefined&&!p['b_submission']?',\x20value='+String(p['value']):'',s=p?.['b_submission']?'\x20(submission)':'';return''+o+q+r+s;}if(n==='context')return o+'\x20['+(m['context']??'?')+']';if(n==='query'){const u=m['object']?.['convert_witness'],v=u!==undefined?',\x20witness='+u:'';return''+o+v;}return o;}function l(m,n,o){const p=o?o+':\x20':'';h['push'](j(n,''+p+k(m)));m['nodes']&&Array['isArray'](m['nodes'])&&m['nodes']['forEach']((q,r)=>l(q,n+0x1,'child['+r+']'));if(m['node'])l(m['node'],n+0x1,'child');if(m['nodeLeft'])l(m['nodeLeft'],n+0x1,'left');if(m['nodeRight'])l(m['nodeRight'],n+0x1,'right');m['parameters']&&Array['isArray'](m['parameters'])&&m['parameters']['forEach']((q,r)=>l(q,n+0x1,'param['+r+']'));if(m['historyIdx'])l(m['historyIdx'],n+0x1,'historyIdx');if(m['sessionIdx'])l(m['sessionIdx'],n+0x1,'sessionIdx');if(m['forwardIdx'])l(m['forwardIdx'],n+0x1,'forwardIdx');if(m['where'])l(m['where'],n+0x1,'where');if(m['find'])l(m['find'],n+0x1,'find');if(m['objectLeft'])l(m['objectLeft'],n+0x1,'objLeft');if(m['objectRight'])l(m['objectRight'],n+0x1,'objRight');if(m['recipient'])l(m['recipient'],n+0x1,'recipient');}h['push'](j(0x1,'Root')),l(b,0x2);if(c&&c['length']>0x0){h['push'](''),h['push']('##\x20Table');for(const m of c){const n=typeof m['value_type']==='string'?m['value_type']:'type='+m['value_type'],o=m['value']!==undefined&&!m['b_submission']?',\x20value='+String(m['value']):'',p=m['b_submission']?'\x20(submission)':'',q=m['name']?'\x20\x22'+m['name']+'\x22':'';h['push']('-\x20id['+m['identifier']+']'+q+':\x20'+n+o+p);}}if(f&&f['guards']['length']>0x0){h['push'](''),h['push']('##\x20Rely\x20('+(f['logic_or']?'OR':'AND')+')');for(const r of f['guards']){h['push']('-\x20'+r);}}return h['join']('\x0a');}export function parseGuardTableJSON(a){const b=a['match'](/##\s*Table JSON[^\n]*\n\s*```json\s*\n([\s\S]*?)```/i);if(!b)return null;try{const c=JSON['parse'](b[0x1]['trim']());if(!Array['isArray'](c))return null;return c['filter'](d=>{return d&&typeof d==='object'&&typeof d['identifier']==='number'&&typeof d['b_submission']==='boolean';})['map'](d=>({'identifier':d['identifier'],'name':d['name'],'value_type':d['value_type'],'b_submission':d['b_submission'],'value':d['value']}));}catch{return null;}}
@@ -0,0 +1,83 @@
1
+ import type { GuardJsonInput } from "./guard-lint.js";
2
+ import { type GuardSemanticsAnalysis } from "../schema-query-impl/index.js";
3
+ export type GuardAction = "buy" | "forward" | "allocate" | "claim_reward" | "vote" | "dispute" | "write_repository" | "submit_progress" | "gen_passport" | "custom";
4
+ export interface GuardBindingSemantic {
5
+ host: string;
6
+ binding_field: string;
7
+ role: string;
8
+ submission_meaning: string;
9
+ on_pass: string;
10
+ on_fail: string;
11
+ stakes: string;
12
+ }
13
+ export declare const GUARD_BINDING_SEMANTICS: Record<GuardAction, GuardBindingSemantic>;
14
+ export declare function valueTypeName(v: unknown): string;
15
+ export declare function loadGuardJsonFromChain(guardRef: string, network?: string): Promise<{
16
+ guard: string;
17
+ name?: string;
18
+ json: GuardJsonInput;
19
+ } | undefined>;
20
+ export declare const OPERATION_GUARD_ACTION: Record<string, GuardAction>;
21
+ export interface GuardSubmissionBrief {
22
+ guard: string;
23
+ guard_name?: string;
24
+ description?: string;
25
+ binding?: {
26
+ action: GuardAction;
27
+ semantics: GuardBindingSemantic;
28
+ };
29
+ analysis: GuardSemanticsAnalysis;
30
+ submission_checklist: Array<{
31
+ identifier: number;
32
+ name?: string;
33
+ value_type?: string;
34
+ object_type?: string;
35
+ consumed_by_queries: number[];
36
+ feeds_recipient: boolean;
37
+ }>;
38
+ data_source_warnings: string[];
39
+ consequences: {
40
+ on_pass: string;
41
+ on_fail: string;
42
+ };
43
+ has_errors: boolean;
44
+ }
45
+ export interface BuildBriefParams {
46
+ guard_ref?: string;
47
+ guard_json?: GuardJsonInput;
48
+ action?: GuardAction;
49
+ network?: string;
50
+ }
51
+ export declare function buildGuardSubmissionBrief(params: BuildBriefParams): Promise<GuardSubmissionBrief | undefined>;
52
+ export declare function renderSubmissionBrief(brief: GuardSubmissionBrief): string;
53
+ export interface SubmittedItem {
54
+ identifier?: number;
55
+ name?: string;
56
+ value_type?: unknown;
57
+ value?: unknown;
58
+ }
59
+ export interface SubmissionConfirmation {
60
+ guard: string;
61
+ guard_name?: string;
62
+ binding?: {
63
+ action: GuardAction;
64
+ semantics: GuardBindingSemantic;
65
+ };
66
+ items: Array<{
67
+ identifier: number | null;
68
+ name?: string;
69
+ submitted_value_preview: string;
70
+ expected_value_type?: string;
71
+ submitted_value_type?: string;
72
+ issues: string[];
73
+ feeds_recipient: boolean;
74
+ }>;
75
+ missing_identifiers: number[];
76
+ unknown_identifiers: number[];
77
+ confirmation_text: string;
78
+ ok: boolean;
79
+ }
80
+ export interface BuildConfirmationParams extends BuildBriefParams {
81
+ submission: SubmittedItem[];
82
+ }
83
+ export declare function buildSubmissionConfirmation(params: BuildConfirmationParams): Promise<SubmissionConfirmation | undefined>;
@@ -0,0 +1 @@
1
+ import{query_objects,LocalMark}from'@wowok/wowok';import{walkGuardTree}from'./guard-render.js';import{analyzeGuardSemantics}from'../schema-query-impl/index.js';export const GUARD_BINDING_SEMANTICS={'buy':{'host':'Service','binding_field':'buy_guard','role':'Purchase\x20gate\x20—\x20decides\x20WHO\x20may\x20place\x20an\x20order\x20on\x20this\x20Service','submission_meaning':'Evidence\x20that\x20you\x20qualify\x20as\x20a\x20buyer\x20(e.g.\x20a\x20Passport,\x20a\x20Proof,\x20an\x20allowlist\x20membership)','on_pass':'Your\x20order\x20is\x20accepted\x20and\x20the\x20payment\x20moves\x20into\x20the\x20Service\x20escrow\x20flow','on_fail':'The\x20order\x20transaction\x20aborts\x20—\x20you\x20cannot\x20buy\x20from\x20this\x20Service','stakes':'Money\x20is\x20committed\x20on\x20pass\x20—\x20wrong\x20evidence\x20may\x20either\x20block\x20you\x20or,\x20worse,\x20pass\x20a\x20check\x20you\x20did\x20not\x20intend'},'forward':{'host':'Machine','binding_field':'Forward.guard','role':'Workflow\x20advance\x20condition\x20—\x20what\x20must\x20be\x20TRUE\x20before\x20an\x20order\x20may\x20move\x20to\x20the\x20next\x20node','submission_meaning':'Evidence\x20for\x20the\x20node\x27s\x20condition\x20(delivery\x20proof,\x20inspection\x20result,\x20approval\x20object)','on_pass':'The\x20order\x20advances\x20to\x20the\x20next\x20node;\x20fund\x20allocation\x20for\x20that\x20transition\x20may\x20execute','on_fail':'The\x20transition\x20aborts\x20—\x20the\x20order\x20stays\x20at\x20the\x20current\x20node','stakes':'Advancing\x20may\x20release\x20funds\x20to\x20the\x20counterparty\x20—\x20verify\x20the\x20node\x20semantics\x20before\x20confirming'},'allocate':{'host':'Service\x20(order_allocators)','binding_field':'order_allocators[].guard','role':'Payment-recipient\x20qualification\x20—\x20the\x20Guard\x27s\x20submission\x20identifies\x20WHO\x20receives\x20the\x20allocation\x20share','submission_meaning':'The\x20recipient\x20identity/address\x20the\x20Guard\x20derives\x20from\x20your\x20submitted\x20data','on_pass':'Funds\x20are\x20allocated\x20to\x20the\x20recipient\x20the\x20Guard\x20resolved\x20from\x20your\x20submission','on_fail':'The\x20allocation\x20aborts\x20—\x20payment\x20cannot\x20settle','stakes':'HIGHEST\x20—\x20a\x20wrong\x20submitted\x20address\x20sends\x20funds\x20to\x20the\x20wrong\x20recipient\x20(irreversible)'},'claim_reward':{'host':'Reward','binding_field':'guard','role':'Reward\x20claim\x20eligibility\x20—\x20who\x20may\x20claim\x20this\x20Reward','submission_meaning':'Proof\x20of\x20eligibility\x20for\x20the\x20reward','on_pass':'The\x20reward\x20is\x20paid\x20out\x20to\x20you','on_fail':'The\x20claim\x20aborts','stakes':'A\x20wrong\x20claim\x20may\x20consume\x20a\x20one-time\x20eligibility'},'vote':{'host':'Arbitration','binding_field':'voting_guard','role':'Voting\x20right\x20—\x20who\x20may\x20vote\x20in\x20this\x20arbitration\x20(empty\x20guard\x20=\x20everyone)','submission_meaning':'Proof\x20of\x20voting\x20membership/weight','on_pass':'Your\x20vote\x20is\x20counted\x20with\x20your\x20weight','on_fail':'The\x20vote\x20aborts','stakes':'Votes\x20may\x20be\x20irrevocable\x20until\x20re-voted;\x20vote\x20count\x20caps\x20apply\x20(ring\x20buffer\x20≤\x205200)'},'dispute':{'host':'Arbitration','binding_field':'usage_guard','role':'Dispute\x20admission\x20—\x20who\x20may\x20open\x20a\x20dispute\x20on\x20an\x20order\x20under\x20this\x20Arbitration','submission_meaning':'Standing\x20to\x20dispute\x20(usually\x20order\x20involvement)','on_pass':'A\x20dispute\x20case\x20is\x20opened\x20and\x20the\x20order\x20flow\x20enters\x20arbitration','on_fail':'The\x20dispute\x20aborts','stakes':'Dispute\x20slots\x20are\x20capped\x20(≤\x2010\x20per\x20order);\x20a\x20failed\x20attempt\x20wastes\x20nothing,\x20a\x20wrong\x20one\x20locks\x20the\x20flow'},'write_repository':{'host':'Repository','binding_field':'write_guard','role':'Data\x20write\x20permission\x20—\x20who\x20may\x20write\x20entries\x20to\x20this\x20Repository','submission_meaning':'Write\x20authorization\x20evidence','on_pass':'Your\x20data\x20entry\x20is\x20written\x20to\x20the\x20Repository\x20(mutable\x20data\x20other\x20Guards\x20may\x20read!)','on_fail':'The\x20write\x20aborts','stakes':'Repository\x20data\x20feeds\x20OTHER\x20Guards\x27\x20decisions\x20—\x20wrong\x20writes\x20corrupt\x20downstream\x20checks'},'submit_progress':{'host':'Progress','binding_field':'submission\x20guard','role':'Progress\x20submission\x20permission\x20—\x20who\x20may\x20submit\x20task\x20progress/evidence','submission_meaning':'The\x20progress\x20evidence/attachment\x20itself','on_pass':'The\x20progress\x20record\x20is\x20attached\x20to\x20the\x20task','on_fail':'The\x20submission\x20aborts','stakes':'Progress\x20evidence\x20may\x20be\x20one-shot\x20per\x20task;\x20wrong\x20content\x20misrepresents\x20the\x20work'},'gen_passport':{'host':'Standalone','binding_field':'none','role':'Static\x20verification\x20—\x20test/credential\x20generation\x20outside\x20any\x20business\x20operation','submission_meaning':'The\x20data\x20the\x20Guard\x20needs\x20to\x20evaluate\x20(same\x20shape\x20as\x20in\x20business\x20use)','on_pass':'A\x20Passport\x20credential\x20object\x20is\x20generated\x20for\x20you','on_fail':'No\x20Passport\x20is\x20generated\x20(gas\x20is\x20still\x20consumed)','stakes':'Low\x20—\x20gen_passport\x20is\x20a\x20test\x20surface,\x20but\x20it\x20consumes\x20gas\x20per\x20call'},'custom':{'host':'Standalone','binding_field':'none','role':'Standalone\x20Guard\x20(rely\x20dependency\x20or\x20custom\x20scenario)','submission_meaning':'Whatever\x20the\x20Guard\x27s\x20table\x20declares\x20(b_submission\x20items)','on_pass':'Verification\x20succeeds\x20for\x20the\x20consuming\x20operation','on_fail':'The\x20consuming\x20operation\x20aborts','stakes':'Depends\x20on\x20the\x20consumer\x20—\x20inspect\x20the\x20tree\x20before\x20submitting'}};const VALUE_TYPE_NAMES={0x0:'Bool',0x1:'Address',0x2:'String',0x3:'U8',0x4:'U16',0x5:'U32',0x6:'U64',0x7:'U128',0x8:'U256',0x9:'VecBool',0xa:'VecAddress',0xb:'VecString',0xc:'VecU8',0xd:'VecU16',0xe:'VecU32',0xf:'VecU64',0x10:'VecU128',0x11:'VecU256',0x12:'VecVecU8',0x13:'Value'};export function valueTypeName(a){if(typeof a==='number')return VALUE_TYPE_NAMES[a]??String(a);return String(a??'Address');}export async function loadGuardJsonFromChain(a,b){let c=a,d;if(!a['startsWith']('0x'))try{const e=await LocalMark['Instance']()['get'](a);if(!e?.['address'])return undefined;c=e['address'],d=a;}catch{return undefined;}try{const f=await query_objects({'objects':[c],'network':b}),g=f?.['objects']?.[0x0];if(!g||g['type']!=='Guard')return undefined;const h=Array['isArray'](g['table'])?g['table']:[],i=Array['isArray'](g['relies'])?g['relies']:[],j={'description':typeof g['description']==='string'?g['description']:undefined,'table':h['map'](k=>{const l=k;return{'identifier':Number(l['identifier']??0x0),'b_submission':l['b_submission']===!![],'value_type':valueTypeName(l['value_type']),'value':l['value'],'name':typeof l['name']==='string'?l['name']:undefined,'object_type':typeof l['object_type']==='string'?l['object_type']:undefined};}),'root':g['root'],...i['length']>0x0?{'rely':{'guards':i,'logic_or':g['relies_logic_and']!==!![]}}:{}};return{'guard':c,'name':d,'json':j};}catch{return undefined;}}export const OPERATION_GUARD_ACTION={'machine':'forward','progress':'forward','allocation':'allocate','reward':'claim_reward','repository':'write_repository','arbitration':'vote','gen_passport':'gen_passport'};function identifierUsedByQueries(a,b){const c=new Set();return walkGuardTree(a,d=>{const e=d;if(e['type']==='query'&&typeof e['query']==='number'){const f=JSON['stringify'](e['parameters']??e['where']??e['find']??'');(f['includes']('\x22identifier\x22:'+b)||f['includes']('\x22identifier\x22:\x20'+b))&&c['add'](e['query']);}}),[...c]['sort']((d,e)=>d-e);}function identifierFeedsRecipient(a,b){let c=![];return walkGuardTree(a,d=>{const e=d;if(e['type']==='query'&&typeof e['query']==='number'&&e['query']===b){if(e['where']||e['find']||e['recipient'])c=!![];}}),c;}export async function buildGuardSubmissionBrief(a){let b=a['guard_json'],c=a['guard_ref']??'',d,e;if(!b){if(!a['guard_ref'])return undefined;const n=await loadGuardJsonFromChain(a['guard_ref'],a['network']);if(!n)return undefined;b=n['json'],c=n['guard'],d=n['name'];}else a['guard_ref']&&(c=a['guard_ref']);e=b['description'];const f=await analyzeGuardSemantics(b),g=a['action'],h=g?GUARD_BINDING_SEMANTICS[g]:undefined,i=(b['table']??[])['filter'](o=>o['b_submission']===!![]),j=b['root'],k=i['map'](o=>({'identifier':o['identifier'],'name':o['name'],'value_type':o['value_type'],'object_type':o['object_type'],'consumed_by_queries':identifierUsedByQueries(j,o['identifier']),'feeds_recipient':identifierFeedsRecipient(j,o['identifier'])})),l=[];for(const o of f['party_evaluation']['data_sources']){o['is_mutable_onchain']&&l['push']('Table\x20['+o['identifier']+']'+(o['name']?'\x20\x22'+o['name']+'\x22':'')+'\x20reads\x20a\x20Repository\x20—\x20its\x20value\x20is\x20MUTABLE\x20on-chain\x20and\x20may\x20have\x20changed\x20since\x20the\x20Guard\x20was\x20created;\x20verify\x20the\x20current\x20entry\x20before\x20relying\x20on\x20the\x20check');}f['party_evaluation']['has_time_conditions']&&l['push']('The\x20tree\x20contains\x20Clock\x20(time)\x20conditions\x20—\x20the\x20check\x20result\x20may\x20differ\x20from\x20an\x20earlier\x20static\x20test');f['party_evaluation']['has_rely_composition']&&l['push']('This\x20Guard\x20composes\x20other\x20Guards\x20via\x20rely\x20—\x20each\x20relied\x20Guard\x27s\x20semantics\x20apply\x20too\x20(max\x204,\x20one\x20layer)');const m=(f['lint']?.['summary']?.['errors']??0x0)>0x0;return{'guard':c,'guard_name':d,'description':e,...g&&h?{'binding':{'action':g,'semantics':h}}:{},'analysis':f,'submission_checklist':k,'data_source_warnings':l,'consequences':{'on_pass':h?.['on_pass']??'Verification\x20succeeds\x20for\x20the\x20consuming\x20operation','on_fail':h?.['on_fail']??'The\x20consuming\x20operation\x20aborts\x20(gas\x20consumed)'},'has_errors':m};}export function renderSubmissionBrief(a){const b=[],c=a['guard_name']??a['guard'];b['push']('GUARD\x20SUBMISSION\x20BRIEF\x20—\x20'+c);if(a['description'])b['push']('Description:\x20'+a['description']);a['binding']?b['push']('Business\x20slot:\x20'+a['binding']['semantics']['role']+'\x20('+a['binding']['semantics']['host']+'.'+a['binding']['semantics']['binding_field']+')'):b['push']('Business\x20slot:\x20unknown\x20—\x20pass\x20the\x20binding\x20action\x20(buy/forward/allocate/...)\x20for\x20slot-specific\x20semantics');b['push'](''),b['push']('What\x20you\x20must\x20submit\x20(b_submission\x20table\x20entries):');for(const d of a['submission_checklist']){const e=d['name']?'\x20\x22'+d['name']+'\x22':'';b['push']('\x20\x20['+d['identifier']+']'+e+'\x20type='+(d['value_type']??'?')+(d['object_type']?'\x20object='+d['object_type']:'')),d['consumed_by_queries']['length']>0x0&&b['push']('\x20\x20\x20\x20\x20\x20feeds\x20guard\x20query\x20id(s):\x20'+d['consumed_by_queries']['join'](',\x20')),d['feeds_recipient']&&b['push']('\x20\x20\x20\x20\x20\x20⚠\x20this\x20submission\x20can\x20determine\x20a\x20PAYMENT\x20RECIPIENT\x20—\x20wrong\x20value\x20=\x20funds\x20to\x20the\x20wrong\x20address');}a['submission_checklist']['length']===0x0&&b['push']('\x20\x20(no\x20b_submission\x20entries\x20—\x20this\x20Guard\x20verifies\x20without\x20user-submitted\x20data)');b['push'](''),b['push']('What\x20the\x20Guard\x20checks\x20(logic\x20tree):');for(const f of a['analysis']['render']['tree_indented']['split']('\x0a')['slice'](0x0,0x28))b['push']('\x20\x20'+f);b['push'](''),b['push']('Consequences\x20—\x20PASS:\x20'+a['consequences']['on_pass']),b['push']('\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FAIL:\x20'+a['consequences']['on_fail']);if(a['binding'])b['push']('Stakes:\x20'+a['binding']['semantics']['stakes']);if(a['data_source_warnings']['length']>0x0){b['push'](''),b['push']('Data-source\x20warnings:');for(const g of a['data_source_warnings'])b['push']('\x20\x20-\x20'+g);}return a['has_errors']&&(b['push'](''),b['push']('⚠\x20Guard\x20lint\x20reports\x20ERROR-level\x20diagnostics\x20—\x20review\x20before\x20submitting.')),b['join']('\x0a');}function previewValue(a){if(a===undefined||a===null)return'(empty)';if(typeof a==='string')return a['length']>0x40?a['slice'](0x0,0x3d)+'...':a;try{const b=JSON['stringify'](a);return b['length']>0x40?b['slice'](0x0,0x3d)+'...':b;}catch{return String(a);}}export async function buildSubmissionConfirmation(a){const b=await buildGuardSubmissionBrief(a);if(!b)return undefined;const c=new Set(b['analysis']['party_evaluation']['submission_requirements']['map'](m=>m['identifier'])),d=new Map(b['analysis']['party_evaluation']['submission_requirements']['map'](m=>[m['identifier'],m])),e=new Map(b['submission_checklist']['map'](m=>[m['identifier'],m])),f=[],g=new Set(),h=[];for(const m of a['submission']??[]){const n=typeof m['identifier']==='number'?m['identifier']:null;if(n!==null){if(c['has'](n))g['add'](n);else{if(!c['has'](n)&&!e['has'](n))h['push'](n);}}const o=n!==null?d['get'](n):undefined,p=n!==null?e['get'](n):undefined,q=[];if(n===null)q['push']('missing\x20identifier\x20—\x20the\x20Guard\x20cannot\x20match\x20this\x20entry\x20to\x20a\x20table\x20slot');o&&m['value_type']!==undefined&&valueTypeName(m['value_type'])!==o['value_type']&&String(m['value_type'])!==o['value_type']&&q['push']('value_type\x20mismatch:\x20submitted\x20'+valueTypeName(m['value_type'])+',\x20Guard\x20expects\x20'+o['value_type']),o&&(m['value']===undefined||m['value']===null||m['value']==='')&&q['push']('value\x20is\x20empty\x20—\x20verification\x20will\x20consume\x20an\x20empty\x20slot\x20(usually\x20fails)'),f['push']({'identifier':n,'name':m['name']??o?.['name'],'submitted_value_preview':previewValue(m['value']),'expected_value_type':o?.['value_type'],'submitted_value_type':m['value_type']!==undefined?valueTypeName(m['value_type']):undefined,'issues':q,'feeds_recipient':p?.['feeds_recipient']??![]});}const i=[...c]['filter'](r=>!g['has'](r))['sort']((r,s)=>r-s),j=b['guard_name']??b['guard'],k=[];k['push']('GUARD\x20SUBMISSION\x20CONFIRMATION\x20—\x20'+j);if(b['description'])k['push']('Guard:\x20'+b['description']);b['binding']&&(k['push']('Slot:\x20'+b['binding']['semantics']['role']),k['push']('Your\x20submission\x20means:\x20'+b['binding']['semantics']['submission_meaning']));k['push'](''),k['push']('You\x20are\x20about\x20to\x20submit:');for(const r of f){const s=r['name']?'\x20\x22'+r['name']+'\x22':'';k['push']('\x20\x20['+(r['identifier']??'?')+']'+s+'\x20=\x20'+r['submitted_value_preview']+(r['expected_value_type']?'\x20(type\x20'+r['expected_value_type']+')':''));if(r['feeds_recipient'])k['push']('\x20\x20\x20\x20\x20\x20⚠\x20this\x20value\x20can\x20determine\x20a\x20PAYMENT\x20RECIPIENT');for(const t of r['issues'])k['push']('\x20\x20\x20\x20\x20\x20!\x20'+t);}if(f['length']===0x0)k['push']('\x20\x20(nothing)');i['length']>0x0&&(k['push'](''),k['push']('Missing\x20required\x20identifier(s):\x20'+i['join'](',\x20')+'\x20—\x20the\x20Guard\x20will\x20treat\x20them\x20as\x20empty'));h['length']>0x0&&k['push']('Unknown\x20identifier(s)\x20not\x20in\x20this\x20Guard\x27s\x20table:\x20'+h['join'](',\x20'));k['push'](''),k['push']('If\x20verification\x20PASSES:\x20'+b['consequences']['on_pass']),k['push']('If\x20verification\x20FAILS:\x20'+b['consequences']['on_fail']);if(b['binding'])k['push']('Stakes:\x20'+b['binding']['semantics']['stakes']);k['push'](''),k['push']('Confirm\x20by\x20re-calling\x20with\x20env.confirmed=true,\x20or\x20modify/cancel.');const l=i['length']===0x0&&f['every'](u=>u['issues']['length']===0x0);return{'guard':b['guard'],...b['guard_name']?{'guard_name':b['guard_name']}:{},...b['binding']?{'binding':b['binding']}:{},'items':f,'missing_identifiers':i,'unknown_identifiers':h,'confirmation_text':k['join']('\x0a'),'ok':l};}
@@ -1,3 +1,4 @@
1
+ import { type GuardAction } from "./guard-submission-brief.js";
1
2
  export interface SubmissionFieldPrompt {
2
3
  identifier: number;
3
4
  name: string;
@@ -6,6 +7,7 @@ export interface SubmissionFieldPrompt {
6
7
  suggested_value?: string;
7
8
  suggestion_reason?: string;
8
9
  description: string;
10
+ feeds_recipient?: boolean;
9
11
  }
10
12
  export interface GuardSubmissionPrompt {
11
13
  guard_address: string;
@@ -14,6 +16,16 @@ export interface GuardSubmissionPrompt {
14
16
  required_fields: SubmissionFieldPrompt[];
15
17
  context: string;
16
18
  fill_example: string;
19
+ binding_semantics?: {
20
+ action: GuardAction;
21
+ role: string;
22
+ submission_meaning: string;
23
+ on_pass: string;
24
+ on_fail: string;
25
+ stakes: string;
26
+ };
27
+ data_source_warnings?: string[];
28
+ brief_text?: string;
17
29
  }
18
30
  export interface SubmissionContext {
19
31
  operation: string;
@@ -25,6 +37,7 @@ export interface SubmissionContext {
25
37
  service_address?: string;
26
38
  machine_address?: string;
27
39
  allocation_address?: string;
40
+ action?: GuardAction;
28
41
  extra?: Record<string, string>;
29
42
  }
30
43
  export declare function generateGuardSubmissionPrompt(guardRef: string, ctx: SubmissionContext): Promise<GuardSubmissionPrompt | undefined>;
@@ -1 +1 @@
1
- import{query_objects,LocalMark}from'@wowok/wowok';function inferValue(a,b,c){const d=a['toLowerCase']();if(d['includes']('order')||d['includes']('task')){if(c['order_address'])return{'value':c['order_address'],'reason':'Inferred\x20from\x20operation\x27s\x20order_address\x20context'};if(c['progress_address'])return{'value':c['progress_address'],'reason':'Progress.task\x20is\x20typically\x20the\x20order\x20—\x20query\x20Progress\x20to\x20get\x20the\x20actual\x20task\x20address'};}if(d['includes']('signer')||d['includes']('sender')||d['includes']('caller')){if(c['signer'])return{'value':c['signer'],'reason':'Inferred\x20from\x20env.account\x20(the\x20signing\x20account)'};}if(d['includes']('service')){if(c['service_address'])return{'value':c['service_address'],'reason':'Inferred\x20from\x20operation\x27s\x20service_address\x20context'};}if(d['includes']('machine')){if(c['machine_address'])return{'value':c['machine_address'],'reason':'Inferred\x20from\x20operation\x27s\x20machine_address\x20context'};}if(d['includes']('progress')||d['includes']('node')||d['includes']('current')){if(c['progress_current'])return{'value':c['progress_current'],'reason':'Inferred\x20from\x20Progress.current\x20node\x20name'};}if(d['includes']('allocation')||d['includes']('allocator')){if(c['allocation_address'])return{'value':c['allocation_address'],'reason':'Inferred\x20from\x20operation\x27s\x20allocation_address\x20context'};}if(c['extra'])for(const [e,f]of Object['entries'](c['extra'])){if(d['includes'](e['toLowerCase']()))return{'value':f,'reason':'Inferred\x20from\x20extra\x20context:\x20'+e};}return undefined;}function describeField(a,b){const c=a['toLowerCase']();if(c['includes']('order'))return'Order\x20object\x20address\x20(type:\x20'+b+')';if(c['includes']('signer')||c['includes']('sender'))return'Transaction\x20signer\x20address\x20(type:\x20'+b+')';if(c['includes']('service'))return'Service\x20object\x20address\x20(type:\x20'+b+')';if(c['includes']('machine'))return'Machine\x20object\x20address\x20(type:\x20'+b+')';if(c['includes']('progress'))return'Progress\x20object\x20address\x20(type:\x20'+b+')';if(c['includes']('node')||c['includes']('current'))return'Current\x20node\x20name\x20(type:\x20'+b+')';if(c['includes']('amount')||c['includes']('price')||c['includes']('balance'))return'Amount\x20in\x20smallest\x20unit\x20(type:\x20'+b+')';if(c['includes']('allocation'))return'Allocation\x20object\x20address\x20(type:\x20'+b+')';return'Field\x20\x22'+a+'\x22\x20(type:\x20'+b+')';}export async function generateGuardSubmissionPrompt(a,b){let c=a,d;if(!a['startsWith']('0x'))try{const k=await LocalMark['Instance']()['get'](a);if(k?.['address'])c=k['address'],d=a;else return undefined;}catch{return undefined;}let e;try{const l=await query_objects({'objects':[c],'network':b['network']});e=l?.['objects']?.[0x0];}catch{return undefined;}if(!e)return undefined;const f=e['table']??e['b_table']??[];if(!Array['isArray'](f)||f['length']===0x0)return undefined;const g=f['filter'](m=>m['b_submission']===!![]);if(g['length']===0x0)return undefined;const h=g['map'](m=>{const n=m['name']??'identifier_'+m['identifier'],o=typeof m['value_type']==='number'?ValueTypeNames[m['value_type']]??String(m['value_type']):String(m['value_type']),p=inferValue(n,o,b);return{'identifier':m['identifier'],'name':n,'value_type':o,'required':!![],'suggested_value':p?.['value'],'suggestion_reason':p?.['reason'],'description':describeField(n,o)};}),i=h['map'](m=>{const n=m['suggested_value']??'<'+m['value_type']+'_value>';return'\x20\x20\x20\x20\x20\x20{\x20identifier:\x20'+m['identifier']+',\x20name:\x20\x22'+m['name']+'\x22,\x20value_type:\x20\x22'+m['value_type']+'\x22,\x20value:\x20'+n+'\x20}';}),j='submission:\x20{\x0a\x20\x20\x20\x20guard:\x20\x22'+(d??c)+'\x22,\x0a\x20\x20\x20\x20submission:\x20[\x0a'+i['join'](',\x0a')+'\x0a\x20\x20\x20\x20]\x0a\x20\x20}';return{'guard_address':c,'guard_name':d,'operation':b['operation'],'required_fields':h,'context':'Operation\x20\x22'+b['operation']+'\x22\x20requires\x20Guard\x20\x22'+(d??c)+'\x22\x20verification.\x20'+('The\x20Guard\x20has\x20'+h['length']+'\x20field(s)\x20that\x20need\x20submission\x20data\x20(b_submission=true).\x20')+'Fill\x20the\x20submission\x20with\x20the\x20required\x20values\x20and\x20retry\x20the\x20operation\x20using\x20call_with_submission.\x20'+'Each\x20field\x20has\x20an\x20identifier\x20(number),\x20name,\x20and\x20expected\x20value_type.\x20'+'The\x20suggested_value\x20(if\x20provided)\x20is\x20inferred\x20from\x20the\x20operation\x20context\x20—\x20verify\x20before\x20using.','fill_example':j};}export function formatSubmissionPrompt(a){const b=[];b['push']('GUARD\x20SUBMISSION\x20REQUIRED\x20—\x20operation\x20cannot\x20proceed\x20without\x20submission\x20data.'),b['push']('Guard:\x20'+(a['guard_name']??a['guard_address'])+'\x20('+a['guard_address']+')'),b['push']('Operation:\x20'+a['operation']),b['push'](''),b['push']('Required\x20fields\x20(fill\x20these\x20in\x20the\x20submission):');for(const c of a['required_fields']){b['push']('\x20\x20['+c['identifier']+']\x20'+c['name']+'\x20('+c['value_type']+')\x20—\x20'+c['description']),c['suggested_value']?b['push']('\x20\x20\x20\x20\x20\x20Suggested:\x20'+c['suggested_value']+'\x20('+c['suggestion_reason']+')'):b['push']('\x20\x20\x20\x20\x20\x20No\x20suggestion\x20—\x20derive\x20value\x20from\x20context\x20or\x20ask\x20user.');}return b['push'](''),b['push']('Fill\x20example\x20(use\x20in\x20the\x20next\x20call\x20with\x20submission):'),b['push'](a['fill_example']),b['join']('\x0a');}const ValueTypeNames={0x0:'Bool',0x1:'Address',0x2:'String',0x3:'U8',0x4:'U16',0x5:'U32',0x6:'U64',0x7:'U128',0x8:'U256',0x9:'VecBool',0xa:'VecAddress',0xb:'VecString',0xc:'VecU8',0xd:'VecU16',0xe:'VecU32',0xf:'VecU64',0x10:'VecU128',0x11:'VecU256',0x12:'VecVecU8',0x13:'Value'};
1
+ import{buildGuardSubmissionBrief,loadGuardJsonFromChain,renderSubmissionBrief}from'./guard-submission-brief.js';function inferValue(a,b,c){const d=a['toLowerCase']();if(d['includes']('order')||d['includes']('task')){if(c['order_address'])return{'value':c['order_address'],'reason':'Inferred\x20from\x20operation\x27s\x20order_address\x20context'};if(c['progress_address'])return{'value':c['progress_address'],'reason':'Progress.task\x20is\x20typically\x20the\x20order\x20—\x20query\x20Progress\x20to\x20get\x20the\x20actual\x20task\x20address'};}if(d['includes']('signer')||d['includes']('sender')||d['includes']('caller')){if(c['signer'])return{'value':c['signer'],'reason':'Inferred\x20from\x20env.account\x20(the\x20signing\x20account)'};}if(d['includes']('service')){if(c['service_address'])return{'value':c['service_address'],'reason':'Inferred\x20from\x20operation\x27s\x20service_address\x20context'};}if(d['includes']('machine')){if(c['machine_address'])return{'value':c['machine_address'],'reason':'Inferred\x20from\x20operation\x27s\x20machine_address\x20context'};}if(d['includes']('progress')||d['includes']('node')||d['includes']('current')){if(c['progress_current'])return{'value':c['progress_current'],'reason':'Inferred\x20from\x20Progress.current\x20node\x20name'};}if(d['includes']('allocation')||d['includes']('allocator')){if(c['allocation_address'])return{'value':c['allocation_address'],'reason':'Inferred\x20from\x20operation\x27s\x20allocation_address\x20context'};}if(c['extra'])for(const [e,f]of Object['entries'](c['extra'])){if(d['includes'](e['toLowerCase']()))return{'value':f,'reason':'Inferred\x20from\x20extra\x20context:\x20'+e};}return undefined;}function describeField(a,b){const c=a['toLowerCase']();if(c['includes']('order'))return'Order\x20object\x20address\x20(type:\x20'+b+')';if(c['includes']('signer')||c['includes']('sender'))return'Transaction\x20signer\x20address\x20(type:\x20'+b+')';if(c['includes']('service'))return'Service\x20object\x20address\x20(type:\x20'+b+')';if(c['includes']('machine'))return'Machine\x20object\x20address\x20(type:\x20'+b+')';if(c['includes']('progress'))return'Progress\x20object\x20address\x20(type:\x20'+b+')';if(c['includes']('node')||c['includes']('current'))return'Current\x20node\x20name\x20(type:\x20'+b+')';if(c['includes']('amount')||c['includes']('price')||c['includes']('balance'))return'Amount\x20in\x20smallest\x20unit\x20(type:\x20'+b+')';if(c['includes']('allocation'))return'Allocation\x20object\x20address\x20(type:\x20'+b+')';return'Field\x20\x22'+a+'\x22\x20(type:\x20'+b+')';}export async function generateGuardSubmissionPrompt(a,b){const c=await loadGuardJsonFromChain(a,b['network']);if(!c)return undefined;const {guard:d,name:e,json:f}=c,g=await buildGuardSubmissionBrief({'guard_json':f,'action':b['action'],'network':b['network']});if(!g)return undefined;const h=(f['table']??[])['filter'](m=>m['b_submission']===!![]);if(h['length']===0x0)return undefined;const i=new Map(g['submission_checklist']['map'](m=>[m['identifier'],m['feeds_recipient']])),j=h['map'](m=>{const n=m['name']??'identifier_'+m['identifier'],o=m['value_type']??'Address',p=inferValue(n,o,b);return{'identifier':m['identifier'],'name':n,'value_type':o,'required':!![],'suggested_value':p?.['value'],'suggestion_reason':p?.['reason'],'description':describeField(n,o),...i['get'](m['identifier'])?{'feeds_recipient':!![]}:{}};}),k=j['map'](m=>{const n=m['suggested_value']??'<'+m['value_type']+'_value>';return'\x20\x20\x20\x20\x20\x20{\x20identifier:\x20'+m['identifier']+',\x20name:\x20\x22'+m['name']+'\x22,\x20value_type:\x20\x22'+m['value_type']+'\x22,\x20value:\x20'+n+'\x20}';}),l='submission:\x20{\x0a\x20\x20\x20\x20guard:\x20\x22'+(e??d)+'\x22,\x0a\x20\x20\x20\x20submission:\x20[\x0a'+k['join'](',\x0a')+'\x0a\x20\x20\x20\x20]\x0a\x20\x20}';return{'guard_address':d,'guard_name':e,'operation':b['operation'],'required_fields':j,'context':'Operation\x20\x22'+b['operation']+'\x22\x20requires\x20Guard\x20\x22'+(e??d)+'\x22\x20verification.\x20'+('The\x20Guard\x20has\x20'+j['length']+'\x20field(s)\x20that\x20need\x20submission\x20data\x20(b_submission=true).\x20')+'Fill\x20the\x20submission\x20with\x20the\x20required\x20values\x20and\x20retry\x20the\x20operation\x20using\x20call_with_submission.\x20'+'Each\x20field\x20has\x20an\x20identifier\x20(number),\x20name,\x20and\x20expected\x20value_type.\x20'+'The\x20suggested_value\x20(if\x20provided)\x20is\x20inferred\x20from\x20the\x20operation\x20context\x20—\x20verify\x20before\x20using.','fill_example':l,...g['binding']?{'binding_semantics':{'action':g['binding']['action'],'role':g['binding']['semantics']['role'],'submission_meaning':g['binding']['semantics']['submission_meaning'],'on_pass':g['binding']['semantics']['on_pass'],'on_fail':g['binding']['semantics']['on_fail'],'stakes':g['binding']['semantics']['stakes']}}:{},...g['data_source_warnings']['length']>0x0?{'data_source_warnings':g['data_source_warnings']}:{},'brief_text':renderSubmissionBrief(g)};}export function formatSubmissionPrompt(a){const b=[];b['push']('GUARD\x20SUBMISSION\x20REQUIRED\x20—\x20operation\x20cannot\x20proceed\x20without\x20submission\x20data.'),b['push']('Guard:\x20'+(a['guard_name']??a['guard_address'])+'\x20('+a['guard_address']+')'),b['push']('Operation:\x20'+a['operation']);a['binding_semantics']&&(b['push'](''),b['push']('Business\x20slot:\x20'+a['binding_semantics']['role']),b['push']('Your\x20submission\x20means:\x20'+a['binding_semantics']['submission_meaning']));b['push'](''),b['push']('Required\x20fields\x20(fill\x20these\x20in\x20the\x20submission):');for(const c of a['required_fields']){b['push']('\x20\x20['+c['identifier']+']\x20'+c['name']+'\x20('+c['value_type']+')\x20—\x20'+c['description']),c['suggested_value']?b['push']('\x20\x20\x20\x20\x20\x20Suggested:\x20'+c['suggested_value']+'\x20('+c['suggestion_reason']+')'):b['push']('\x20\x20\x20\x20\x20\x20No\x20suggestion\x20—\x20derive\x20value\x20from\x20context\x20or\x20ask\x20user.'),c['feeds_recipient']&&b['push']('\x20\x20\x20\x20\x20\x20⚠\x20this\x20value\x20can\x20determine\x20a\x20PAYMENT\x20RECIPIENT\x20—\x20wrong\x20address\x20=\x20funds\x20to\x20the\x20wrong\x20party');}a['binding_semantics']&&(b['push'](''),b['push']('If\x20verification\x20PASSES:\x20'+a['binding_semantics']['on_pass']),b['push']('If\x20verification\x20FAILS:\x20'+a['binding_semantics']['on_fail']),b['push']('Stakes:\x20'+a['binding_semantics']['stakes']));if(a['data_source_warnings']&&a['data_source_warnings']['length']>0x0){b['push'](''),b['push']('Data-source\x20warnings:');for(const d of a['data_source_warnings'])b['push']('\x20\x20-\x20'+d);}return b['push'](''),b['push']('Fill\x20example\x20(use\x20in\x20the\x20next\x20call\x20with\x20submission):'),b['push'](a['fill_example']),b['join']('\x0a');}
@@ -1,4 +1,4 @@
1
- import { fetchMachineNodes, buildWorkflowGuidance, buildWorkflowReceipt, enrichWorkflowGuidance, mergeGuidanceIntoOutput, resolvePermissionRole, fetchPermissionContext, fetchOrderContext, fetchEntityPermission, fetchEntityContact, fetchObjectLinkerCore, fetchObjectLinkerTx, fetchServiceOrders, fetchOrdersOfUser, resolveLocalNamesFor, fetchAllFieldObjectIds, batchQueryObjectsByIds, batchReadAddressKeyedFields, batchReadU64KeyedFields, listLocalAccounts, accountCanExecuteForward, enumerateActionableForwards, forwardOperatorKind, type GuidanceResult, type ReceiptResult, type ParsedMachineNode, type ParsedPair, type ParsedForward, type ActionableForwardOption, type ForwardOperatorKind, type LocalAccountInfo, type PermissionContext, type OrderContext, type EntityPermissionContext, type EntityPermissionItem, type EntityOrderContext, type EntityOrderItem, type EntityContactContext } from "./workflow-guidance.js";
1
+ import { buildWorkflowGuidance, buildWorkflowReceipt, enrichWorkflowGuidance, mergeGuidanceIntoOutput, resolvePermissionRole, resolveLocalNamesFor, listLocalAccounts, accountCanExecuteForward, enumerateActionableForwards, forwardOperatorKind, type GuidanceResult, type ReceiptResult, type ActionableForwardOption, type ForwardOperatorKind, type LocalAccountInfo } from "./workflow-guidance.js";
2
2
  import { CONFIRMATION_RULES, SAFETY_RULES_VERSION, OBJECT_REUSE_RULES, CREATE_VS_MODIFY_PATTERN, IMMUTABILITY_RULES, OPERATION_TYPE_CLASSIFICATION, OPERATION_CLASS_META, classifyTool, NAMING_CONVENTIONS, checkObjectReuseRules, checkImmutabilityRules, type ConfirmationRule, type OperationPreview, type ConfirmLevel, type ReuseRecommendation, type ObjectReuseRule, type ImmutabilityRule, type OperationClass, type OperationClassMeta, type SafetyRiskItem } from "./safety-rules.js";
3
3
  import { TOOL_CONSTRAINTS, TOOL_CONSTRAINTS_VERSION, validateOperation, hasBlockingViolations, getWarningViolations, type ConstraintSeverity, type FieldConstraint, type OperationConstraint, type ConstraintViolation } from "./tool-constraints.js";
4
4
  import { REWARD_TEMPLATES, REWARD_TEMPLATES_VERSION, getRewardTemplate, listRewardTemplates, suggestRewardTemplate, type RewardTemplateType, type RewardTemplate } from "./reward-templates.js";
@@ -17,7 +17,7 @@ import { SEMANTIC_TO_SCHEMA_RULES, SCHEMA_TO_SEMANTIC_RULES, GUARD_CONSTRAINT_RU
17
17
  import { checkPuzzleCompleteness, generateConfirmationText, initPuzzleFromIntent, inferBindingFromAction, emptyDataSources, getWitnessInfo, WITNESS_NAME_MAP, type GuardPuzzle, type IntentPuzzle, type BindingPuzzle, type DataSourcePuzzle, type OnChainConstantEntry, type WitnessDerivedEntry, type SubmittedObjectEntry, type SubmittedValueEntry, type SystemContextEntry, type QueryPuzzle, type LogicNodePuzzle, type ConstraintChecklist, type PuzzleCompleteness, type PuzzleDimension } from "./guard-puzzle.js";
18
18
  import { assessGuardRisks, assessGuardRisksForOperation, getRiskSummary, getRiskRulesByDataSourceClass, getAllRiskRules, getRiskRulesCount, type GuardRisk, type GuardRiskAssessment, type GuardStakeholder, type RiskLevel, type RiskCategory, type DataSourceClass, type RiskRule } from "./guard-risk.js";
19
19
  import { GUARD_BINDING_REGISTRY, GUARD_BINDINGS_VERSION, OWNER_RECEIVE_COGNITION, getGuardBindingsByObject, getGuardBinding, summarizeGuardBinding, type GuardBoundObject, type PresetKind, type GuardPresetSlot } from "./guard-bindings.js";
20
- import { SCENARIO_BRIDGE_REGISTRY, SCENARIO_CHAINS, SCENARIO_TOPOLOGY_VERSION, getBridgeById, getBridgesByObject, getChainById, summarizeBridge, detectBridgesForObjects, type ScenarioBridge, type ScenarioChain, type BridgeParticipant, type BridgeField } from "./scenario-topology.js";
20
+ import { SCENARIO_BRIDGE_REGISTRY, SCENARIO_CHAINS, SCENARIO_TOPOLOGY_VERSION, getBridgeById, getBridgeByCode, getBridgesByObject, getBridgesForEdge, detectBridgesForEdges, getChainById, summarizeBridge, detectBridgesForObjects, type ScenarioBridge, type ScenarioChain, type BridgeParticipant, type BridgeField } from "./scenario-topology.js";
21
21
  import { GUARD_TEMPLATES, GUARD_TEMPLATES_VERSION, GUARD_TEMPLATES_COUNT, getTemplatesByScene, getTemplateById, getTemplatesByIndustry, getTemplatesByPattern, listGuardTemplates, suggestTemplateForScene, getTemplateParameters, validateTemplateParams, type GuardTemplate, type GuardTemplateParam, type TemplateParamType } from "./guard-templates.js";
22
22
  import { lintGuard, autoFixGuard, isGuardReady, getGuardErrors, formatLintResult, type GuardJsonInput, type GuardLintResult, type GuardDiagnostic, type DiagnosticSeverity, type DiagnosticSource, type AutoFixAction } from "./guard-lint.js";
23
23
  import { MACHINE_SCENES, MACHINE_LEDGER_VERSION, MACHINE_SCENES_COUNT, findScene as findMachineScene, getScenesByIndustry as getMachineScenesByIndustry, getScenesByPattern, inferSceneFromFlow, type MachineScene, type ParticipantRoleDef, type GuardRequirement } from "./machine-ledger.js";
@@ -77,6 +77,8 @@ export { suggestPricing, MUTABLE_FIELDS, DYNAMIC_PRICING_VERSION, type MarketSig
77
77
  export { computeServiceTrustScore, quickTrustCheck, TRUST_METRICS_VERSION, type ServiceTrustMetrics, type ServiceTrustScore, type TrustDimension, type TrustInjection, type TrustDimensionId, type TrustFinding, TRUST_DIMENSION_WEIGHTS, };
78
78
  export { buildReviewRepositorySetup, computeReviewStats, isVerifiedReview, filterVerifiedReviews, detectReviewManipulation, REPUTATION_RULES_VERSION, type Review, type ReviewStats, type ReviewRepositorySetup, };
79
79
  export { INDUSTRY_FLYWHEELS, getFlywheelForIndustry, listIndustries, suggestAcquisitionActions, generateTrustDescription, buildAcquisitionDashboard, ACQUISITION_FLYWHEEL_VERSION, type FlywheelAction, type AcquisitionFlywheel, type TrustDescriptionParams, type AcquisitionDashboard, };
80
+ export { STRATEGY_MANUAL_FILENAME, STRATEGY_MANUAL_VERSION, renderStrategyManual, parseManualSentinel, classifyManualFile, getBuiltinStrategyManual, listBuiltinStrategyManualIndustries, type ManualSentinel, type ManualFileState, type BuiltinStrategyManual, } from "./strategy-manuals.js";
81
+ export { INDUSTRY_STRATEGIES, getIndustryStrategy, listIndustryStrategies, registerIndustryStrategy, unregisterIndustryStrategy, recommendStrategy, stageFromOrderCount, validateStrategyLevers, type IndustryStrategy, type PricingModel, type PosturePlaybook, type CompetitorWatch, type AcquisitionStrategy, type UnitEconomics, type SuccessPattern, type MerchantStage, type StrategyMetrics, type StrategyRecommendation, } from "./industry-strategy.js";
80
82
  export { INDUSTRY_REGISTRY_VERSION, getIndustryProfile, listIndustries as listRegistryIndustries, registerIndustry, getIndustryTraits, resolveIndustryName, getRegistrySize, listBuiltinIndustryNames, type IndustryTraits, type IndustryProfile, type IndustrySource, type IndustryEvolutionMeta, type ExtendedIndustry, };
81
83
  export { DEFAULT_TRAITS, inferTraitsFromDescription, synthesizeProfile, findSimilarIndustries, composeIndustries, type TraitInferenceResult, type SimilarIndustryMatch, };
82
84
  export { INDUSTRY_EVOLUTION_THRESHOLDS, aggregateIndustryMetrics, evaluateIndustryHealth, suggestIndustryUpdate, applyIndustryUpdate, runIndustryHealthPipeline, type IndustryMetrics, type OrderRawDataPoint, type IndustryHealthReport, type TraitDrift, type IndustryUpdateSuggestion, };
@@ -85,7 +87,7 @@ export { BUILTIN_INTENT_SPECS, registerIntentProfile, getIntentProfile, listInte
85
87
  export { GUARD_SCENES, findScene, inferSceneFromAction, getImmutableScenes, getNumericIdentifierScenes, type GuardScene, };
86
88
  export { SEMANTIC_TO_SCHEMA_RULES, SCHEMA_TO_SEMANTIC_RULES, GUARD_CONSTRAINT_RULES, matchSemanticPattern, explainNode, explainWitness, getConstraintsByCategory, type SemanticToSchemaRule, type SchemaToSemanticRule, type GuardConstraintRule, };
87
89
  export { checkPuzzleCompleteness, generateConfirmationText, initPuzzleFromIntent, inferBindingFromAction, emptyDataSources, getWitnessInfo, WITNESS_NAME_MAP, type GuardPuzzle, type IntentPuzzle, type BindingPuzzle, type DataSourcePuzzle, type OnChainConstantEntry, type WitnessDerivedEntry, type SubmittedObjectEntry, type SubmittedValueEntry, type SystemContextEntry, type QueryPuzzle, type LogicNodePuzzle, type ConstraintChecklist, type PuzzleCompleteness, type PuzzleDimension, };
88
- export { assessGuardRisks, assessGuardRisksForOperation, getRiskSummary, getRiskRulesByDataSourceClass, getAllRiskRules, getRiskRulesCount, type GuardRisk, type GuardRiskAssessment, type GuardStakeholder, type RiskLevel, type RiskCategory, type DataSourceClass, type RiskRule, GUARD_TEMPLATES, GUARD_TEMPLATES_VERSION, GUARD_TEMPLATES_COUNT, getTemplatesByScene, getTemplateById, getTemplatesByIndustry, getTemplatesByPattern, listGuardTemplates, suggestTemplateForScene, getTemplateParameters, validateTemplateParams, type GuardTemplate, type GuardTemplateParam, type TemplateParamType, GUARD_BINDING_REGISTRY, GUARD_BINDINGS_VERSION, OWNER_RECEIVE_COGNITION, getGuardBindingsByObject, getGuardBinding, summarizeGuardBinding, type GuardBoundObject, type PresetKind, type GuardPresetSlot, SCENARIO_BRIDGE_REGISTRY, SCENARIO_CHAINS, SCENARIO_TOPOLOGY_VERSION, getBridgeById, getBridgesByObject, getChainById, summarizeBridge, detectBridgesForObjects, type ScenarioBridge, type ScenarioChain, type BridgeParticipant, type BridgeField, lintGuard, autoFixGuard, isGuardReady, getGuardErrors, formatLintResult, type GuardJsonInput, type GuardLintResult, type GuardDiagnostic, type DiagnosticSeverity, type DiagnosticSource, type AutoFixAction, };
90
+ export { assessGuardRisks, assessGuardRisksForOperation, getRiskSummary, getRiskRulesByDataSourceClass, getAllRiskRules, getRiskRulesCount, type GuardRisk, type GuardRiskAssessment, type GuardStakeholder, type RiskLevel, type RiskCategory, type DataSourceClass, type RiskRule, GUARD_TEMPLATES, GUARD_TEMPLATES_VERSION, GUARD_TEMPLATES_COUNT, getTemplatesByScene, getTemplateById, getTemplatesByIndustry, getTemplatesByPattern, listGuardTemplates, suggestTemplateForScene, getTemplateParameters, validateTemplateParams, type GuardTemplate, type GuardTemplateParam, type TemplateParamType, GUARD_BINDING_REGISTRY, GUARD_BINDINGS_VERSION, OWNER_RECEIVE_COGNITION, getGuardBindingsByObject, getGuardBinding, summarizeGuardBinding, type GuardBoundObject, type PresetKind, type GuardPresetSlot, SCENARIO_BRIDGE_REGISTRY, SCENARIO_CHAINS, SCENARIO_TOPOLOGY_VERSION, getBridgeById, getBridgeByCode, getBridgesByObject, getBridgesForEdge, detectBridgesForEdges, getChainById, summarizeBridge, detectBridgesForObjects, type ScenarioBridge, type ScenarioChain, type BridgeParticipant, type BridgeField, lintGuard, autoFixGuard, isGuardReady, getGuardErrors, formatLintResult, type GuardJsonInput, type GuardLintResult, type GuardDiagnostic, type DiagnosticSeverity, type DiagnosticSource, type AutoFixAction, };
89
91
  export { MACHINE_SCENES, MACHINE_LEDGER_VERSION, MACHINE_SCENES_COUNT, findMachineScene, getMachineScenesByIndustry, getScenesByPattern, inferSceneFromFlow, type MachineScene, type ParticipantRoleDef, type GuardRequirement, };
90
92
  export { MACHINE_TEMPLATES, MACHINE_TEMPLATES_VERSION, MACHINE_TEMPLATES_COUNT, getAllMachineTemplates, getMachineTemplateById, getMachineTemplatesByScene, getMachineTemplatesByIndustry, suggestTemplateForIntent, walkDecisionTree, fillMachineTemplate, forkMachineTemplate, verifyTemplateSceneReferences, getReferencedGuardTemplateIds, getReferencedRiskIds, type MachineTemplate, type MachineTemplateParam, };
91
93
  export { SEMANTIC_TO_MACHINE_RULES, MACHINE_CONSTRAINT_RULES, MACHINE_TRANSLATION_VERSION, MACHINE_PATTERNS_COUNT, MACHINE_CONSTRAINTS_COUNT, matchMachinePattern, identifyExecutionMode, identifyTopology, explainForwardPermission, getMachineConstraintsByCategory, getConstraintById, getOnChainMachineConstraints, getOffChainMachineConstraints, type SemanticToMachineRule, type MachineConstraintRule, };
@@ -276,7 +278,7 @@ export declare function getKnowledgeBase(): {
276
278
  guard_design_patterns_count: number;
277
279
  verifier_level_guidance_count: number;
278
280
  };
279
- export { fetchMachineNodes, buildWorkflowGuidance, buildWorkflowReceipt, enrichWorkflowGuidance, mergeGuidanceIntoOutput, resolvePermissionRole, fetchPermissionContext, fetchOrderContext, fetchEntityPermission, fetchEntityContact, fetchObjectLinkerCore, fetchObjectLinkerTx, fetchServiceOrders, fetchOrdersOfUser, resolveLocalNamesFor, fetchAllFieldObjectIds, batchQueryObjectsByIds, batchReadAddressKeyedFields, batchReadU64KeyedFields, listLocalAccounts, accountCanExecuteForward, enumerateActionableForwards, forwardOperatorKind, type ActionableForwardOption, type ForwardOperatorKind, type GuidanceResult, type ReceiptResult, type ParsedMachineNode, type ParsedPair, type ParsedForward, type LocalAccountInfo, type PermissionContext, type OrderContext, type EntityPermissionContext, type EntityPermissionItem, type EntityOrderContext, type EntityOrderItem, type EntityContactContext, };
281
+ export { buildWorkflowGuidance, buildWorkflowReceipt, enrichWorkflowGuidance, mergeGuidanceIntoOutput, resolvePermissionRole, resolveLocalNamesFor, listLocalAccounts, accountCanExecuteForward, enumerateActionableForwards, forwardOperatorKind, type ActionableForwardOption, type ForwardOperatorKind, type GuidanceResult, type ReceiptResult, type LocalAccountInfo, };
280
282
  export { buildWorkspaceLists, type WorkspaceListsResult, type WorkspaceListItem, } from "./workspace-lists.js";
281
283
  export { resolveSupplyChainGraph, type SupplyChainGraph, type SupplyChainEdge, type SupplyChainService, type SupplyChainSubmission, } from "./supply-chain.js";
282
284
  export { enumerateObjectOperations, operationCategoryOf, operationComplexityOf, isPermissionIndexType, type OperationCategory, type ComplexityLevel, type OperationComplexity, type WatchOperationDraft, } from "./operation-dictionary.js";