@wowok/agent-mcp 3.0.4 → 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.
- package/dist/evaluation/path-reasoning.d.ts +4 -2
- package/dist/evaluation/path-reasoning.js +1 -1
- package/dist/extensions/constraint-registry.d.ts +2 -2
- package/dist/extensions/constraint-registry.js +1 -1
- package/dist/extensions/custom-registry-file.d.ts +22 -0
- package/dist/extensions/custom-registry-file.js +1 -0
- package/dist/extensions/index.d.ts +2 -1
- package/dist/extensions/index.js +1 -1
- package/dist/extensions/industry-pack.d.ts +7 -0
- package/dist/extensions/industry-pack.js +1 -1
- package/dist/extensions/metric-registry.d.ts +2 -2
- package/dist/extensions/metric-registry.js +1 -1
- package/dist/extensions/modes.js +1 -1
- package/dist/extensions/registry.d.ts +2 -2
- package/dist/extensions/registry.js +1 -1
- package/dist/extensions/types.d.ts +4 -0
- package/dist/goal/GoalEngine.d.ts +13 -1
- package/dist/goal/GoalEngine.js +1 -1
- package/dist/goal/next-steps.d.ts +12 -0
- package/dist/goal/next-steps.js +1 -0
- package/dist/goal/pursue.d.ts +18 -0
- package/dist/goal/pursue.js +1 -0
- package/dist/goal/types.d.ts +72 -0
- package/dist/goal/types.js +1 -1
- package/dist/graph/onchain/analyze.d.ts +44 -0
- package/dist/graph/onchain/analyze.js +1 -0
- package/dist/graph/onchain/analyze.spec.d.ts +1 -0
- package/dist/graph/onchain/analyze.spec.js +1 -0
- package/dist/graph/onchain/anti-cheat.d.ts +39 -0
- package/dist/graph/onchain/anti-cheat.js +1 -0
- package/dist/graph/onchain/anti-cheat.spec.d.ts +1 -0
- package/dist/graph/onchain/anti-cheat.spec.js +1 -0
- package/dist/graph/onchain/dataplane.d.ts +44 -0
- package/dist/graph/onchain/dataplane.js +1 -0
- package/dist/graph/onchain/edge-schema.d.ts +60 -0
- package/dist/graph/onchain/edge-schema.js +1 -0
- package/dist/graph/onchain/expand.d.ts +4 -0
- package/dist/graph/onchain/expand.js +1 -0
- package/dist/graph/onchain/extract.d.ts +21 -0
- package/dist/graph/onchain/extract.js +1 -0
- package/dist/graph/onchain/index.d.ts +17 -0
- package/dist/graph/onchain/index.js +1 -0
- package/dist/graph/onchain/interest.d.ts +10 -0
- package/dist/graph/onchain/interest.js +1 -0
- package/dist/graph/onchain/interest.spec.d.ts +1 -0
- package/dist/graph/onchain/interest.spec.js +1 -0
- package/dist/graph/onchain/onchain.spec.d.ts +1 -0
- package/dist/graph/onchain/onchain.spec.js +1 -0
- package/dist/graph/onchain/order-status.d.ts +53 -0
- package/dist/graph/onchain/order-status.js +1 -0
- package/dist/graph/onchain/project-relationship.d.ts +3 -0
- package/dist/graph/onchain/project-relationship.js +1 -0
- package/dist/graph/onchain/sdk-batch.d.ts +117 -0
- package/dist/graph/onchain/sdk-batch.js +1 -0
- package/dist/graph/onchain/sdk-dataplane.d.ts +40 -0
- package/dist/graph/onchain/sdk-dataplane.js +1 -0
- package/dist/graph/onchain/strategy.d.ts +54 -0
- package/dist/graph/onchain/strategy.js +1 -0
- package/dist/graph/onchain/strategy.spec.d.ts +1 -0
- package/dist/graph/onchain/strategy.spec.js +1 -0
- package/dist/graph/onchain/types.d.ts +238 -0
- package/dist/graph/onchain/types.js +1 -0
- package/dist/graph/onchain/viewport.d.ts +5 -0
- package/dist/graph/onchain/viewport.js +1 -0
- package/dist/harness/recover.js +1 -1
- package/dist/index.js +1 -1
- package/dist/intent/enrich.js +1 -1
- package/dist/keeper/detectors.d.ts +1 -1
- package/dist/keeper/detectors.js +1 -1
- package/dist/knowledge/account-marks.js +1 -1
- package/dist/knowledge/anti-cheat.d.ts +2 -37
- package/dist/knowledge/anti-cheat.js +1 -1
- package/dist/knowledge/contract-invariants.js +1 -1
- package/dist/knowledge/getting-started.d.ts +37 -0
- package/dist/knowledge/getting-started.js +1 -0
- package/dist/knowledge/goal-completion.js +1 -1
- package/dist/knowledge/guard-render.d.ts +1 -0
- package/dist/knowledge/guard-render.js +1 -1
- package/dist/knowledge/guard-submission-brief.d.ts +83 -0
- package/dist/knowledge/guard-submission-brief.js +1 -0
- package/dist/knowledge/guard-submission-prompt.d.ts +13 -0
- package/dist/knowledge/guard-submission-prompt.js +1 -1
- package/dist/knowledge/index.d.ts +6 -4
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/industry-strategy.d.ts +91 -0
- package/dist/knowledge/industry-strategy.js +1 -0
- package/dist/knowledge/jsonrpc-enum.js +1 -1
- package/dist/knowledge/market-metrics.d.ts +14 -3
- package/dist/knowledge/market-metrics.js +1 -1
- package/dist/knowledge/migration-preflight.js +1 -1
- package/dist/knowledge/operation-dictionary.d.ts +1 -1
- package/dist/knowledge/safety-rules.js +1 -1
- package/dist/knowledge/scenario-topology.d.ts +6 -1
- package/dist/knowledge/scenario-topology.js +1 -1
- package/dist/knowledge/service-risk-node.d.ts +3 -0
- package/dist/knowledge/service-risk-node.js +1 -0
- package/dist/knowledge/service-risk.d.ts +2 -0
- package/dist/knowledge/service-risk.js +1 -1
- package/dist/knowledge/service-templates.d.ts +2 -0
- package/dist/knowledge/service-templates.js +1 -1
- package/dist/knowledge/strategy-manuals.d.ts +17 -0
- package/dist/knowledge/strategy-manuals.js +1 -0
- package/dist/knowledge/supply-chain.d.ts +3 -1
- package/dist/knowledge/supply-chain.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/tools-reference.js +1 -1
- package/dist/knowledge/workflow-guidance.d.ts +3 -118
- package/dist/knowledge/workflow-guidance.js +1 -1
- package/dist/knowledge/workspace-lists.js +1 -1
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/monitor/ScopeResolver.js +1 -1
- package/dist/participation/radar-core.d.ts +15 -15
- package/dist/participation/radar-core.js +1 -1
- package/dist/persona/analyzer.d.ts +2 -1
- package/dist/persona/bridge.d.ts +5 -1
- package/dist/persona/bridge.js +1 -1
- package/dist/persona/defaults.js +1 -1
- package/dist/persona/distill-goal.d.ts +7 -1
- package/dist/persona/distill-goal.js +1 -1
- package/dist/persona/index.d.ts +13 -3
- package/dist/persona/index.js +1 -1
- package/dist/persona/model.d.ts +12 -2
- package/dist/persona/model.js +1 -1
- package/dist/persona/overrides.d.ts +1 -0
- package/dist/persona/overrides.js +1 -1
- package/dist/persona/topology-focus.d.ts +29 -0
- package/dist/persona/topology-focus.js +1 -0
- package/dist/persona/types.d.ts +81 -0
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/context-assembly.js +1 -1
- package/dist/playbooks/service-build/machine-nodes.js +1 -1
- package/dist/playbooks/service-build/machine-panorama.js +1 -1
- package/dist/playbooks/service-build/object-panorama.js +1 -1
- package/dist/playbooks/service-build/participation-radar.js +1 -1
- package/dist/playbooks/service-build/relationship-profile.d.ts +1 -0
- package/dist/playbooks/service-build/relationship-profile.js +1 -1
- package/dist/playbooks/service-build/service-panorama.d.ts +4 -0
- package/dist/playbooks/service-build/service-panorama.js +1 -1
- package/dist/playbooks/service-build/topology-query.d.ts +14 -0
- package/dist/playbooks/service-build/topology-query.js +1 -0
- package/dist/role/index.d.ts +1 -0
- package/dist/role/index.js +1 -1
- package/dist/role/profiles.d.ts +26 -0
- package/dist/role/profiles.js +1 -0
- package/dist/safety/confirm-gate.d.ts +4 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/call/allocation.d.ts +6 -6
- package/dist/schema/call/bridge.d.ts +1 -1
- package/dist/schema/call/guard.d.ts +20 -20
- package/dist/schema/call/repository.js +1 -1
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.d.ts +4 -4
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/employee/index.d.ts +7 -7
- package/dist/schema/evaluation/index.d.ts +22 -9
- package/dist/schema/evaluation/index.js +1 -1
- package/dist/schema/goal/index.d.ts +37 -1
- package/dist/schema/goal/index.js +1 -1
- package/dist/schema/goal/planning.d.ts +1 -1
- package/dist/schema/index.d.ts +1 -0
- package/dist/schema/index.js +1 -1
- package/dist/schema/industry-pack/index.d.ts +7 -0
- package/dist/schema/industry-pack/index.js +1 -1
- package/dist/schema/local/index.d.ts +8 -4
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/messenger/index.d.ts +318 -64
- package/dist/schema/messenger/index.js +1 -1
- package/dist/schema/operations.d.ts +146 -11
- package/dist/schema/operations.js +1 -1
- package/dist/schema/persona/index.d.ts +15743 -0
- package/dist/schema/persona/index.js +1 -1
- package/dist/schema/query/bi.d.ts +869 -2
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/query/index.d.ts +163 -41
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-query/index.d.ts +16 -0
- package/dist/schema/schema-query/index.js +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema/strategy-review/index.d.ts +137 -0
- package/dist/schema/strategy-review/index.js +1 -0
- package/dist/schema/trust/index.d.ts +6 -6
- package/dist/schema/workflow/index.d.ts +2 -2
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +8 -4
- package/dist/schemas/account_operation.schema.json +6 -2
- package/dist/schemas/evaluation_operation.output.json +24 -0
- package/dist/schemas/goal_operation.schema.json +124 -0
- package/dist/schemas/index.json +7 -1
- package/dist/schemas/industry_pack_operation.output.json +39 -0
- package/dist/schemas/local_mark_operation.schema.json +2 -2
- package/dist/schemas/messenger_operation.output.json +670 -200
- package/dist/schemas/messenger_operation.schema.json +66 -239
- package/dist/schemas/onchain_operations.schema.json +3 -3
- package/dist/schemas/onchain_operations_repository.schema.json +3 -3
- package/dist/schemas/onchain_table_data.output.json +184 -0
- package/dist/schemas/onchain_table_data.schema.json +43 -43
- package/dist/schemas/persona_operation.output.json +37778 -262
- package/dist/schemas/persona_operation.schema.json +5960 -1
- package/dist/schemas/query_toolkit.output.json +1580 -2
- package/dist/schemas/query_toolkit.schema.json +194 -32
- package/dist/schemas/schema_query.schema.json +25 -1
- package/dist/schemas/strategy_review_operation.output.json +532 -0
- package/dist/schemas/strategy_review_operation.schema.json +66 -0
- package/dist/schemas/wowok_buildin_info.output.json +188 -6
- package/dist/schemas/wowok_buildin_info.schema.json +14 -0
- package/dist/strategy/collectors.d.ts +66 -0
- package/dist/strategy/collectors.js +1 -0
- package/dist/strategy/collectors.spec.d.ts +1 -0
- package/dist/strategy/collectors.spec.js +1 -0
- package/dist/strategy/index.d.ts +5 -0
- package/dist/strategy/index.js +1 -0
- package/dist/strategy/metrics.d.ts +20 -0
- package/dist/strategy/metrics.js +1 -0
- package/dist/strategy/review.d.ts +48 -0
- package/dist/strategy/review.js +1 -0
- package/dist/strategy/scorecard.d.ts +32 -0
- package/dist/strategy/scorecard.js +1 -0
- package/dist/strategy/store.d.ts +26 -0
- package/dist/strategy/store.js +1 -0
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/evaluation.js +1 -1
- package/dist/tools/handlers/goal.js +1 -1
- package/dist/tools/handlers/industry-pack.js +1 -1
- package/dist/tools/handlers/local.js +1 -1
- package/dist/tools/handlers/messenger.js +1 -1
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/permission.js +1 -1
- package/dist/tools/handlers/persona.js +1 -1
- package/dist/tools/handlers/query.d.ts +6 -0
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/handlers/schema-query.js +1 -1
- package/dist/tools/handlers/strategy-review.d.ts +2 -0
- package/dist/tools/handlers/strategy-review.js +1 -0
- package/dist/tools/handlers/watch.js +1 -1
- package/dist/tools/handlers/workflow.js +1 -1
- package/dist/tools/index.d.ts +3 -0
- package/dist/tools/index.js +1 -1
- package/dist/tools/registry/agent.js +1 -1
- package/dist/tools/registry/business.js +1 -1
- package/dist/tools/registry/local.js +1 -1
- package/dist/tools/registry/messenger.js +1 -1
- package/dist/tools/registry/query.js +1 -1
- package/dist/tools/rules-hook.js +1 -1
- package/dist/tools/shared.d.ts +2 -1
- package/dist/tools/shared.js +1 -1
- package/dist/tools/wrap.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
export const FIELD_MUTABILITY_RULES=[{'object_type':'Service','field':'machine','frozen_when':'after\x20publish','forbidden_actions':['set','remove'],'allowed_actions':[],'unfreeze':null,'move_anchor':'service.move\x20machine_set_imp\x20/\x20machine_none_imp\x20(assert!(!bPublished))'},{'object_type':'Service','field':'order_allocators','frozen_when':'after\x20publish','forbidden_actions':['set'],'allowed_actions':[],'unfreeze':null,'move_anchor':'service.move\x20order_allocators_set_imp\x20(assert!(!bPublished))'},{'object_type':'Service','field':'buy_guard','frozen_when':null,'forbidden_actions':[],'allowed_actions':['set','remove'],'unfreeze':null,'move_anchor':'service.move\x20buy_guard_set_imp\x20/\x20buy_guard_none_imp\x20(no\x20assert!(!bPublished))'},{'object_type':'Service','field':'rewards','frozen_when':'after\x20publish','forbidden_actions':['remove','clear'],'allowed_actions':['add'],'unfreeze':'pause\x20+\x20setting_lock_duration\x20elapsed','move_anchor':'service.move\x20reward_remove_imp\x20/\x20reward_clear_imp\x20(assert_not_published)'},{'object_type':'Service','field':'arbitrations','frozen_when':'after\x20publish','forbidden_actions':['remove','clear'],'allowed_actions':['add'],'unfreeze':'pause\x20+\x20setting_lock_duration\x20elapsed','move_anchor':'service.move\x20arbitration_remove_imp\x20/\x20arbitration_clear_imp\x20(assert_not_published)'},{'object_type':'Service','field':'repositories','frozen_when':null,'forbidden_actions':[],'allowed_actions':['add','remove','clear'],'unfreeze':null,'move_anchor':'service.move\x20repository_remove_imp\x20/\x20repository_clear_imp\x20(no\x20assert_not_published)'},{'object_type':'Service','field':'sales','frozen_when':null,'forbidden_actions':[],'allowed_actions':['add','remove','clear','update'],'unfreeze':null,'move_anchor':'service.move\x20sales_*_imp\x20/\x20price_*\x20/\x20stock_*\x20(mutable\x20after\x20publish)'},{'object_type':'Service','field':'description','frozen_when':null,'forbidden_actions':[],'allowed_actions':['set'],'unfreeze':null,'move_anchor':'service.move\x20description_set_imp'},{'object_type':'Service','field':'location','frozen_when':null,'forbidden_actions':[],'allowed_actions':['set'],'unfreeze':null,'move_anchor':'service.move\x20location_set_imp'},{'object_type':'Service','field':'bPaused','frozen_when':null,'forbidden_actions':[],'allowed_actions':['set'],'unfreeze':null,'move_anchor':'service.move\x20pause_imp'},{'object_type':'Machine','field':'nodes','frozen_when':'after\x20publish','forbidden_actions':['add','remove','update'],'allowed_actions':[],'unfreeze':null,'move_anchor':'machine.move\x20node_add_imp\x20/\x20node_remove_imp\x20/\x20node_rename_imp\x20(assert_not_published)'},{'object_type':'Machine','field':'consensus_repositories','frozen_when':null,'forbidden_actions':[],'allowed_actions':['add','remove','clear'],'unfreeze':null,'move_anchor':'machine.move\x20consensus_repositories_remove_imp\x20(no\x20assert_not_published)'},{'object_type':'Machine','field':'bPaused','frozen_when':null,'forbidden_actions':[],'allowed_actions':['set'],'unfreeze':null,'move_anchor':'machine.move\x20pause_imp'},{'object_type':'Progress','field':'machine','frozen_when':'bound\x20at\x20creation','forbidden_actions':['set','remove'],'allowed_actions':[],'unfreeze':null,'move_anchor':'progress.move\x20new_imp\x20(machine\x20bound\x20at\x20creation;\x20no\x20mutation\x20entry)'},{'object_type':'Progress','field':'task','frozen_when':'after\x20task_set','forbidden_actions':['set'],'allowed_actions':[],'unfreeze':null,'move_anchor':'progress.move\x20task_set_imp\x20(assert!\x20option::is_none\x20→\x20E_TASK_ALREADY_SET)'},{'object_type':'Treasury','field':'external_deposit_guard','frozen_when':null,'forbidden_actions':[],'allowed_actions':['add','remove','clear'],'unfreeze':null,'move_anchor':'treasury.move\x20external_deposit_guard_add/remove/clear_imp\x20(no\x20freeze)'},{'object_type':'Treasury','field':'external_withdraw_guard','frozen_when':null,'forbidden_actions':[],'allowed_actions':['add','remove','clear'],'unfreeze':null,'move_anchor':'treasury.move\x20external_withdraw_guard_add/remove/clear_imp\x20(no\x20freeze)'},{'object_type':'Treasury','field':'history','frozen_when':'at\x20creation\x20(append-only)','forbidden_actions':['remove','clear','set'],'allowed_actions':['add'],'unfreeze':null,'move_anchor':'treasury.move\x20parent_table::add\x20(withdraw/deposit/receive\x20append\x20only;\x20no\x20delete\x20entry)'},{'object_type':'Allocation','field':'allocators','frozen_when':'after\x20create\x20(share)','forbidden_actions':['add','remove','clear','set'],'allowed_actions':[],'unfreeze':null,'move_anchor':'allocation.move\x20create\x20(bound\x20via\x20new_with_balance;\x20no\x20mutation\x20entry)'},{'object_type':'Allocation','field':'payment_info','frozen_when':'after\x20create\x20(share)','forbidden_actions':['set','remove'],'allowed_actions':[],'unfreeze':null,'move_anchor':'allocation.move\x20create\x20(payment_info\x20bound\x20at\x20creation;\x20no\x20mutation\x20entry)'}];export const LOCK_CONSTRAINTS=[{'object_type':'Service','trigger':'after\x20publish\x20(bPublished=true)','locked':'remove\x20/\x20clear\x20of\x20rewards\x20/\x20arbitrations','release':'paused_time\x20present\x20and\x20paused_time\x20+\x20setting_lock_duration\x20<=\x20current\x20clock','move_anchor':'service.move\x20assert_not_published\x20(E_LOCKED_TIME_NOT_ENOUGH)'},{'object_type':'Reward','trigger':'guard_not_added_expiration_time\x20is\x20set\x20(Some)','locked':'add\x20of\x20guards','release':'clock\x20>\x20guard_not_added_expiration_time','move_anchor':'reward.move\x20guard_add_imp\x20(E_GUARD_LOCKED_TIME)'},{'object_type':'Reward','trigger':'guard.expiration_time\x20is\x20set\x20(Some)','locked':'claim','release':'clock\x20<=\x20guard.expiration_time\x20(cannot\x20claim\x20after\x20expiry)','move_anchor':'reward.move\x20claim\x20(E_GUARD_EXPIRED)'}];export const IRREVERSIBLE_OPERATIONS=[{'object_type':'Machine','operation':'publish','reason':'nodes/pairs/forwards\x20frozen\x20forever;\x20cannot\x20be\x20changed\x20again','move_anchor':'machine.move\x20publish_imp'},{'object_type':'Service','operation':'publish','reason':'machine\x20/\x20order_allocators\x20frozen\x20(rewards/arbitrations\x20need\x20pause+lock\x20before\x20remove)','move_anchor':'service.move\x20publish_imp'},{'object_type':'Permission','operation':'transfer','reason':'owner\x20change\x20is\x20irreversible;\x20the\x20old\x20owner\x20permanently\x20loses\x20control','move_anchor':'permission.move\x20transfer'},{'object_type':'Arb','operation':'arbitration\x20(award)','reason':'enters\x20Arbitrated\x20once\x20indemnity\x20is\x20set;\x20the\x20award\x20is\x20irreversible','move_anchor':'arb.move\x20arbitration'},{'object_type':'Arb','operation':'finish\x20/\x20withdraw','reason':'enters\x20terminal\x20state\x20Finished\x20/\x20Withdrawn;\x20state\x20no\x20longer\x20migrates','move_anchor':'arb.move\x20finish\x20/\x20withdraw'},{'object_type':'Payment','operation':'unwrap\x20/\x20transfer','reason':'fund\x20movement\x20is\x20irreversible','move_anchor':'payment.move\x20unwrap_with_check'},{'object_type':'Progress','operation':'task_set','reason':'task\x20is\x20set\x20once\x20and\x20cannot\x20be\x20reset\x20(permanently\x20bound\x20to\x20an\x20order/reward)','move_anchor':'progress.move\x20task_set_imp\x20(E_TASK_ALREADY_SET)'},{'object_type':'Allocation','operation':'create\x20(share)','reason':'allocators\x20/\x20payment_info\x20are\x20frozen\x20after\x20binding;\x20distribution\x20rules\x20cannot\x20change','move_anchor':'allocation.move\x20create'},{'object_type':'Reward','operation':'guard_expiration_time_add','reason':'guard_not_added_expiration_time\x20can\x20only\x20increase\x20(lock\x20cannot\x20be\x20shortened)','move_anchor':'reward.move\x20guard_expiration_time_add_imp\x20(E_GUARD_LOCKED_TIME_NOT_INCREASING)'}];export const STATE_MACHINE_TERMINALS=[{'object_type':'Arb','terminal_states':['Finished','Withdrawn'],'forbidden':'vote\x20/\x20arbitration\x20/\x20feedback\x20/\x20reset\x20(state\x20machine\x20no\x20longer\x20migrates)','move_anchor':'arb.move\x20status\x20state\x20machine\x20(7\x20states)'}];export const NUMERIC_LIMIT_CONSTRAINTS=[{'object_type':'Arb','field':'indemnity','limit':'<=\x20order.amount\x20*\x203\x20(MAX_INDEMNITY_MULTIPLE=3,\x20enforced\x20at\x20award\x20time,\x20not\x20claim\x20time)','move_anchor':'arb.move\x20arbitration\x20(E_INDEMNITY_EXCEEDS_LIMIT)'}];export const EXTERNAL_ACCESS_MECHANISMS=[{'object_type':'Treasury','field':'external_deposit_guard','actor':'any\x20external\x20party\x20that\x20passes\x20passport::result_for_guard\x20(no\x20Treasury\x20Permission\x20needed)','limit_source':'identifier\x20points\x20to\x20a\x20Guard\x20submission\x20amount\x20field\x20(u64);\x20deposit\x20amount\x20constrained\x20by\x20Guard\x20logic;\x20store_from_id\x20points\x20to\x20the\x20fund\x20source\x20address','move_anchor':'treasury.move\x20external_deposit\x20(no\x20permission::assert)'},{'object_type':'Treasury','field':'external_withdraw_guard','actor':'any\x20external\x20party\x20that\x20passes\x20passport::result_for_guard\x20(no\x20Treasury\x20Permission\x20needed)','limit_source':'identifier\x20points\x20to\x20a\x20Guard\x20submission\x20amount\x20field\x20(u64)\x20=\x20the\x20withdrawal\x20limit;\x20store_from_id\x20points\x20to\x20the\x20recipient\x20address','move_anchor':'treasury.move\x20external_withdraw\x20(no\x20permission::assert)'}];export function externalAccessOf(a,b){return EXTERNAL_ACCESS_MECHANISMS['find'](d=>d['object_type']===a&&d['field']===b);}export function numericLimitOf(a,b){return NUMERIC_LIMIT_CONSTRAINTS['find'](d=>d['object_type']===a&&d['field']===b);}export function fieldMutabilityOf(a,b){return FIELD_MUTABILITY_RULES['find'](c=>c['object_type']===a&&c['field']===b);}export function isActionForbidden(a,b,c,d){const e=fieldMutabilityOf(a,b);if(!e)return![];if(!d)return![];return e['forbidden_actions']['includes'](c);}export function lockConstraintOf(a){return LOCK_CONSTRAINTS['find'](b=>b['object_type']===a);}
|
|
1
|
+
import{EDGE_SCHEMAS}from'../graph/onchain/index.js';const LOCAL_FIELD_RULES=[{'object_type':'Service','field':'order_allocators','frozen_when':'after\x20publish','forbidden_actions':['set'],'allowed_actions':[],'unfreeze':null,'move_anchor':'service.move\x20order_allocators_set_imp\x20(assert!(!bPublished))'},{'object_type':'Service','field':'sales','frozen_when':null,'forbidden_actions':[],'allowed_actions':['add','remove','clear','update'],'unfreeze':null,'move_anchor':'service.move\x20sales_*_imp\x20/\x20price_*\x20/\x20stock_*\x20(mutable\x20after\x20publish)'},{'object_type':'Service','field':'description','frozen_when':null,'forbidden_actions':[],'allowed_actions':['set'],'unfreeze':null,'move_anchor':'service.move\x20description_set_imp'},{'object_type':'Service','field':'location','frozen_when':null,'forbidden_actions':[],'allowed_actions':['set'],'unfreeze':null,'move_anchor':'service.move\x20location_set_imp'},{'object_type':'Service','field':'bPaused','frozen_when':null,'forbidden_actions':[],'allowed_actions':['set'],'unfreeze':null,'move_anchor':'service.move\x20pause_imp'},{'object_type':'Machine','field':'bPaused','frozen_when':null,'forbidden_actions':[],'allowed_actions':['set'],'unfreeze':null,'move_anchor':'machine.move\x20pause_imp'},{'object_type':'Treasury','field':'external_deposit_guard','frozen_when':null,'forbidden_actions':[],'allowed_actions':['add','remove','clear'],'unfreeze':null,'move_anchor':'treasury.move\x20external_deposit_guard_add/remove/clear_imp\x20(no\x20freeze)'},{'object_type':'Treasury','field':'external_withdraw_guard','frozen_when':null,'forbidden_actions':[],'allowed_actions':['add','remove','clear'],'unfreeze':null,'move_anchor':'treasury.move\x20external_withdraw_guard_add/remove/clear_imp\x20(no\x20freeze)'},{'object_type':'Treasury','field':'history','frozen_when':'at\x20creation\x20(append-only)','forbidden_actions':['remove','clear','set'],'allowed_actions':['add'],'unfreeze':null,'move_anchor':'treasury.move\x20parent_table::add\x20(withdraw/deposit/receive\x20append\x20only;\x20no\x20delete\x20entry)'},{'object_type':'Allocation','field':'payment_info','frozen_when':'after\x20create\x20(share)','forbidden_actions':['set','remove'],'allowed_actions':[],'unfreeze':null,'move_anchor':'allocation.move\x20create\x20(payment_info\x20bound\x20at\x20creation;\x20no\x20mutation\x20entry)'}],EDGE_DERIVED_FIELD_RULES=EDGE_SCHEMAS['flatMap'](a=>{if(!a['contract'])return[];const b=a['contract'];return[{'object_type':a['source'],'field':b['field'],'frozen_when':b['frozenWhen'],'forbidden_actions':[...b['forbiddenActions']],'allowed_actions':[...b['allowedActions']],'unfreeze':b['unfreeze'],'move_anchor':b['moveAnchor']}];});export const FIELD_MUTABILITY_RULES=[...EDGE_DERIVED_FIELD_RULES,...LOCAL_FIELD_RULES];export const LOCK_CONSTRAINTS=[{'object_type':'Service','trigger':'after\x20publish\x20(bPublished=true)','locked':'remove\x20/\x20clear\x20of\x20rewards\x20/\x20arbitrations','release':'paused_time\x20present\x20and\x20paused_time\x20+\x20setting_lock_duration\x20<=\x20current\x20clock','move_anchor':'service.move\x20assert_not_published\x20(E_LOCKED_TIME_NOT_ENOUGH)'},{'object_type':'Reward','trigger':'guard_not_added_expiration_time\x20is\x20set\x20(Some)','locked':'add\x20of\x20guards','release':'clock\x20>\x20guard_not_added_expiration_time','move_anchor':'reward.move\x20guard_add_imp\x20(E_GUARD_LOCKED_TIME)'},{'object_type':'Reward','trigger':'guard.expiration_time\x20is\x20set\x20(Some)','locked':'claim','release':'clock\x20<=\x20guard.expiration_time\x20(cannot\x20claim\x20after\x20expiry)','move_anchor':'reward.move\x20claim\x20(E_GUARD_EXPIRED)'}];export const IRREVERSIBLE_OPERATIONS=[{'object_type':'Machine','operation':'publish','reason':'nodes/pairs/forwards\x20frozen\x20forever;\x20cannot\x20be\x20changed\x20again','move_anchor':'machine.move\x20publish_imp'},{'object_type':'Service','operation':'publish','reason':'machine\x20/\x20order_allocators\x20frozen\x20(rewards/arbitrations\x20need\x20pause+lock\x20before\x20remove)','move_anchor':'service.move\x20publish_imp'},{'object_type':'Permission','operation':'transfer','reason':'owner\x20change\x20is\x20irreversible;\x20the\x20old\x20owner\x20permanently\x20loses\x20control','move_anchor':'permission.move\x20transfer'},{'object_type':'Arb','operation':'arbitration\x20(award)','reason':'enters\x20Arbitrated\x20once\x20indemnity\x20is\x20set;\x20the\x20award\x20is\x20irreversible','move_anchor':'arb.move\x20arbitration'},{'object_type':'Arb','operation':'finish\x20/\x20withdraw','reason':'enters\x20terminal\x20state\x20Finished\x20/\x20Withdrawn;\x20state\x20no\x20longer\x20migrates','move_anchor':'arb.move\x20finish\x20/\x20withdraw'},{'object_type':'Payment','operation':'unwrap\x20/\x20transfer','reason':'fund\x20movement\x20is\x20irreversible','move_anchor':'payment.move\x20unwrap_with_check'},{'object_type':'Progress','operation':'task_set','reason':'task\x20is\x20set\x20once\x20and\x20cannot\x20be\x20reset\x20(permanently\x20bound\x20to\x20an\x20order/reward)','move_anchor':'progress.move\x20task_set_imp\x20(E_TASK_ALREADY_SET)'},{'object_type':'Allocation','operation':'create\x20(share)','reason':'allocators\x20/\x20payment_info\x20are\x20frozen\x20after\x20binding;\x20distribution\x20rules\x20cannot\x20change','move_anchor':'allocation.move\x20create'},{'object_type':'Reward','operation':'guard_expiration_time_add','reason':'guard_not_added_expiration_time\x20can\x20only\x20increase\x20(lock\x20cannot\x20be\x20shortened)','move_anchor':'reward.move\x20guard_expiration_time_add_imp\x20(E_GUARD_LOCKED_TIME_NOT_INCREASING)'}];export const STATE_MACHINE_TERMINALS=[{'object_type':'Arb','terminal_states':['Finished','Withdrawn'],'forbidden':'vote\x20/\x20arbitration\x20/\x20feedback\x20/\x20reset\x20(state\x20machine\x20no\x20longer\x20migrates)','move_anchor':'arb.move\x20status\x20state\x20machine\x20(7\x20states)'}];export const NUMERIC_LIMIT_CONSTRAINTS=[{'object_type':'Arb','field':'indemnity','limit':'<=\x20order.amount\x20*\x203\x20(MAX_INDEMNITY_MULTIPLE=3,\x20enforced\x20at\x20award\x20time,\x20not\x20claim\x20time)','move_anchor':'arb.move\x20arbitration\x20(E_INDEMNITY_EXCEEDS_LIMIT)'}];export const EXTERNAL_ACCESS_MECHANISMS=[{'object_type':'Treasury','field':'external_deposit_guard','actor':'any\x20external\x20party\x20that\x20passes\x20passport::result_for_guard\x20(no\x20Treasury\x20Permission\x20needed)','limit_source':'identifier\x20points\x20to\x20a\x20Guard\x20submission\x20amount\x20field\x20(u64);\x20deposit\x20amount\x20constrained\x20by\x20Guard\x20logic;\x20store_from_id\x20points\x20to\x20the\x20fund\x20source\x20address','move_anchor':'treasury.move\x20external_deposit\x20(no\x20permission::assert)'},{'object_type':'Treasury','field':'external_withdraw_guard','actor':'any\x20external\x20party\x20that\x20passes\x20passport::result_for_guard\x20(no\x20Treasury\x20Permission\x20needed)','limit_source':'identifier\x20points\x20to\x20a\x20Guard\x20submission\x20amount\x20field\x20(u64)\x20=\x20the\x20withdrawal\x20limit;\x20store_from_id\x20points\x20to\x20the\x20recipient\x20address','move_anchor':'treasury.move\x20external_withdraw\x20(no\x20permission::assert)'}];export function externalAccessOf(a,b){return EXTERNAL_ACCESS_MECHANISMS['find'](d=>d['object_type']===a&&d['field']===b);}export function numericLimitOf(a,b){return NUMERIC_LIMIT_CONSTRAINTS['find'](d=>d['object_type']===a&&d['field']===b);}export function fieldMutabilityOf(a,b){return FIELD_MUTABILITY_RULES['find'](c=>c['object_type']===a&&c['field']===b);}export function isActionForbidden(a,b,c,d){const e=fieldMutabilityOf(a,b);if(!e)return![];if(!d)return![];return e['forbidden_actions']['includes'](c);}export function lockConstraintOf(a){return LOCK_CONSTRAINTS['find'](b=>b['object_type']===a);}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export declare const SKILLS_PACKAGE = "@wowok/skills";
|
|
2
|
+
export declare const SKILLS_INSTALL_COMMAND = "npm install -g @wowok/skills";
|
|
3
|
+
export declare const SKILLS_DOCTOR_COMMAND = "wowok-skills doctor";
|
|
4
|
+
export declare const SKILLS_REPAIR_COMMAND = "wowok-skills init --force";
|
|
5
|
+
export declare const COLD_START_SECONDS = 20;
|
|
6
|
+
export declare const SKILL_ROLES: readonly string[];
|
|
7
|
+
export interface CommonGoal {
|
|
8
|
+
goal: string;
|
|
9
|
+
skills: string[];
|
|
10
|
+
tools: string[];
|
|
11
|
+
}
|
|
12
|
+
export declare const COMMON_GOALS: readonly CommonGoal[];
|
|
13
|
+
export interface SkillDetection {
|
|
14
|
+
status: "detected" | "not_detected";
|
|
15
|
+
detected_roots: string[];
|
|
16
|
+
}
|
|
17
|
+
export declare function detectInstalledSkills(cwd?: string): SkillDetection;
|
|
18
|
+
export interface GettingStartedInfo {
|
|
19
|
+
skills: {
|
|
20
|
+
what: string;
|
|
21
|
+
package: string;
|
|
22
|
+
recommended: boolean;
|
|
23
|
+
install_command: string;
|
|
24
|
+
doctor_command: string;
|
|
25
|
+
repair_command: string;
|
|
26
|
+
detection: SkillDetection;
|
|
27
|
+
detection_note: string;
|
|
28
|
+
roles: string[];
|
|
29
|
+
};
|
|
30
|
+
cold_start: {
|
|
31
|
+
ready_seconds: number;
|
|
32
|
+
note: string;
|
|
33
|
+
};
|
|
34
|
+
common_goals: CommonGoal[];
|
|
35
|
+
first_calls: string[];
|
|
36
|
+
}
|
|
37
|
+
export declare function getGettingStarted(cwd?: string): GettingStartedInfo;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as a125a from'fs';import*as a125b from'os';import*as a125c from'path';export const SKILLS_PACKAGE='@wowok/skills';export const SKILLS_INSTALL_COMMAND='npm\x20install\x20-g\x20@wowok/skills';export const SKILLS_DOCTOR_COMMAND='wowok-skills\x20doctor';export const SKILLS_REPAIR_COMMAND='wowok-skills\x20init\x20--force';export const COLD_START_SECONDS=0x14;export const SKILL_ROLES=['wowok-onboard','wowok-provider','wowok-order','wowok-supplier','wowok-collaborator','wowok-machine','wowok-arbitrator','wowok-messenger','wowok-market','wowok-governance','wowok-planner','wowok-auditor','wowok-output'];export const COMMON_GOALS=[{'goal':'Onboard\x20a\x20new\x20merchant\x20and\x20publish\x20a\x20commercial\x20service\x20end-to-end','skills':['wowok-onboard','wowok-provider'],'tools':['goal_operation','onchain_operations','query_toolkit']},{'goal':'Design\x20or\x20modify\x20a\x20Machine\x20workflow\x20(nodes,\x20forwards,\x20guards)','skills':['wowok-machine','wowok-auditor'],'tools':['onchain_operations','machineNode2file','guard2file']},{'goal':'Evaluate\x20or\x20buy\x20a\x20service\x20/\x20handle\x20an\x20in-order\x20customer\x20lifecycle','skills':['wowok-order'],'tools':['query_toolkit','trust_score','onchain_operations','messenger_operation']},{'goal':'Fulfill\x20a\x20sub-order\x20as\x20a\x20supplier\x20and\x20collect\x20settlement','skills':['wowok-supplier','wowok-collaborator'],'tools':['watch_operation','workflow_operation','keeper_operation']},{'goal':'Operate\x20order\x20workflows\x20/\x20advance\x20progress\x20on\x20behalf\x20of\x20a\x20merchant','skills':['wowok-collaborator'],'tools':['workflow_operation','watch_operation','keeper_operation']},{'goal':'Handle\x20a\x20dispute\x20or\x20run\x20an\x20arbitration\x20service','skills':['wowok-arbitrator','wowok-messenger'],'tools':['evaluation_operation','onchain_operations','messenger_operation']},{'goal':'Govern\x20permissions,\x20treasury\x20funds\x20and\x20the\x20on-chain\x20profile\x20after\x20setup','skills':['wowok-governance'],'tools':['permission_operation','onchain_operations','query_toolkit']},{'goal':'Obtain\x20WOW\x20gas\x20/\x20payment\x20tokens\x20before\x20the\x20first\x20transaction','skills':['wowok-onboard'],'tools':['wowok_buildin_info','bridge_operation','account_operation']}];function candidateSkillRoots(a){const b=a125b['homedir'](),c=[a125c['join'](b,'.claude','skills'),a125c['join'](b,'.agents','skills'),a125c['join'](b,'.codex','skills'),a125c['join'](b,'.cursor','skills'),a125c['join'](b,'.codebuddy','skills'),a125c['join'](b,'.kilo','skills'),a125c['join'](b,'.roo','skills'),a125c['join'](b,'.cline','skills'),a125c['join'](b,'.copilot','skills'),a125c['join'](b,'.codeium','windsurf','skills'),a125a['existsSync'](a125c['join'](b,'.trae-cn','skills'))?a125c['join'](b,'.trae-cn','skills'):a125c['join'](b,'.trae','skills')],d=['.agents/skills','.claude/skills','.cursor/skills','.trae/skills','.codebuddy/skills','.roo/skills','.cline/skills','.kilo/skills','.github/skills']['map'](e=>a125c['resolve'](a,e));return[...new Set([...c,...d])];}function rootHasWowokSkill(a){let b;try{b=a125a['readdirSync'](a,{'withFileTypes':!![]});}catch{return![];}if(b['some'](c=>c['isFile']()&&c['name']==='.wowok-skills.json'))return!![];return b['some'](c=>c['isDirectory']()&&c['name']['startsWith']('wowok-'));}export function detectInstalledSkills(a=process['cwd']()){const b=[];for(const c of candidateSkillRoots(a)){try{if(rootHasWowokSkill(c))b['push'](c);}catch{}}return{'status':b['length']>0x0?'detected':'not_detected','detected_roots':b};}export function getGettingStarted(a=process['cwd']()){return{'skills':{'what':'WoWok\x20Skills\x20are\x20role-based\x20playbooks\x20(SKILL.md\x20files\x20installed\x20into\x20AI\x20clients)\x20that\x20sit\x20on\x20top\x20of\x20this\x20MCP\x20server.\x20The\x20MCP\x20exposes\x20the\x20tools;\x20the\x20skills\x20tell\x20an\x20agent\x20WHEN\x20and\x20in\x20what\x20ORDER\x20to\x20use\x20them\x20for\x20complex\x20goals\x20(onboarding,\x20buying,\x20fulfillment,\x20arbitration,\x20governance),\x20and\x20materially\x20reduce\x20failed\x20calls.\x20This\x20server\x20works\x20without\x20them;\x20with\x20them\x20loaded,\x20agents\x20start\x20from\x20structured\x20guidance\x20instead\x20of\x20discovering\x20sub-tools\x20by\x20trial\x20and\x20error.','package':SKILLS_PACKAGE,'recommended':!![],'install_command':SKILLS_INSTALL_COMMAND,'doctor_command':SKILLS_DOCTOR_COMMAND,'repair_command':SKILLS_REPAIR_COMMAND,'detection':detectInstalledSkills(a),'detection_note':'Best-effort\x20scan\x20of\x20standard\x20client\x20skill\x20roots\x20on\x20this\x20machine.\x20`wowok-skills\x20doctor`\x20is\x20authoritative\x20and\x20also\x20reports\x20MCP\x20registration\x20state\x20per\x20client.\x20If\x20detection\x20says\x20not_detected\x20but\x20skills\x20were\x20installed\x20for\x20a\x20client\x20with\x20a\x20non-standard\x20root,\x20trust\x20doctor.','roles':[...SKILL_ROLES]},'cold_start':{'ready_seconds':COLD_START_SECONDS,'note':'The\x20first\x20call\x20after\x20the\x20server\x20boots\x20can\x20take\x20around\x2020\x20seconds\x20while\x20@wowok/agent-mcp\x20is\x20bootstrapped\x20(especially\x20via\x20npx\x20on\x20Windows).\x20A\x20transport\x20timeout\x20on\x20the\x20FIRST\x20call\x20is\x20startup\x20latency,\x20not\x20a\x20broken\x20server\x20—\x20wait\x20and\x20retry;\x20subsequent\x20calls\x20are\x20fast.\x20Never\x20interpret\x20a\x20delayed\x20first\x20response\x20as\x20a\x20failed\x20on-chain\x20transaction.'},'common_goals':COMMON_GOALS['map'](b=>({...b,'skills':[...b['skills']],'tools':[...b['tools']]})),'first_calls':['wowok_buildin_info\x20info=\x27getting\x20started\x27\x20—\x20this\x20orientation','wowok_buildin_info\x20info=\x27current\x20network\x27\x20—\x20which\x20chain\x20(mainnet/testnet)\x20the\x20SDK\x20defaults\x20to','wowok_buildin_info\x20info=\x27funding\x20guidance\x27\x20—\x20testnet\x20faucet\x20/\x20mainnet\x20bridge\x20/\x20airdrop','wowok_buildin_info\x20info=\x27upgrade_check\x27\x20—\x20whether\x20the\x20MCP\x20server\x20and\x20SDK\x20are\x20current','schema_query\x20action=\x27list\x27\x20—\x20enumerate\x20every\x20sub-tool\x20and\x20fetch\x20its\x20input\x20schema']};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function normAddr(a){if(!a)return'';const b=a['startsWith']('0x')?a['slice'](0x2):a;return b['toLowerCase']();}function isEmptyAddr(a){return a===null||a===undefined||String(a)['trim']()==='';}function balanceIsZero(a){if(a===null||a===undefined)return![];try{return BigInt(String(a))===0x0n;}catch{return![];}}async function fetchRefs(a,b,c){if(a['length']===0x0)return{'objects':[]};try{const d=await c['queryObjects'](a['map'](g=>g['object']),b),f=new Map();for(const g of d??[]){if(!g)continue;const h=normAddr(g?.['object']);if(h)f['set'](h,g);if(typeof g?.['query_name']==='string')f['set'](normAddr(g['query_name']),g);}return{'objects':a['map'](i=>f['get'](normAddr(i['object'])))};}catch(i){return{'objects':a['map'](()=>undefined),'queryError':'chain\x20query\x20failed:\x20'+(i instanceof Error?i['message']:String(i))};}}function typeMatches(a,b){const c=b?.['type'];if(!c)return!![];return String(c)['toLowerCase']()===a['type']['toLowerCase']();}function refsOfType(a,b){return a['objects']['filter'](c=>c['type']['toLowerCase']()===b['toLowerCase']());}async function checkPublishService(a,b,c){const d=refsOfType(a,'Service'),e=[],f=[];if(d['length']===0x0)return{'complete':![],'evidence':e,'missing':['no\x20Service\x20object\x20registered\x20on\x20the\x20goal']};const {objects:g,queryError:h}=await fetchRefs(d,b,c);if(h)f['push'](h);let i=![];return g['forEach']((j,k)=>{const l=d[k];if(!j){if(!h)f['push']('Service\x20'+l['object']+'\x20not\x20found\x20on\x20chain');return;}if(!typeMatches(l,j)){f['push']('Service\x20'+l['object']+'\x20type\x20mismatch\x20(fetched:\x20'+(j?.['type']??'unknown')+')');return;}if(j['bPaused']!==![]){f['push']('Service\x20'+l['object']+'\x20is\x20paused\x20(bPaused='+String(j['bPaused'])+')');return;}e['push']('Service\x20'+l['object']+'\x20exists\x20and\x20is\x20not\x20paused');const m=Array['isArray'](j['sales'])?j['sales']:[];if(m['length']<0x1){f['push']('Service\x20'+l['object']+'\x20has\x20no\x20purchasable\x20items\x20(sales\x20is\x20empty)');return;}e['push']('Service\x20'+l['object']+'\x20has\x20'+m['length']+'\x20purchasable\x20item(s)');if(isEmptyAddr(j['machine'])){f['push']('Service\x20'+l['object']+'\x20has\x20no\x20Machine\x20bound');return;}e['push']('Service\x20'+l['object']+'\x20has\x20a\x20Machine\x20bound\x20('+j['machine']+')');if(isEmptyAddr(j['permission'])){f['push']('Service\x20'+l['object']+'\x20has\x20no\x20Permission\x20bound');return;}e['push']('Service\x20'+l['object']+'\x20has\x20a\x20Permission\x20bound\x20('+j['permission']+')'),i=!![];}),{'complete':i,'evidence':e,'missing':f};}async function checkPurchaseService(a,b,c){const d=refsOfType(a,'Order'),f=[],g=[];if(d['length']===0x0)return{'complete':![],'evidence':f,'missing':['no\x20Order\x20object\x20registered\x20on\x20the\x20goal']};const {objects:h,queryError:j}=await fetchRefs(d,b,c);if(j)g['push'](j);for(let k=0x0;k<h['length'];k++){const l=h[k],m=d[k];if(!l){if(!j)g['push']('Order\x20'+m['object']+'\x20not\x20found\x20on\x20chain');continue;}f['push']('Order\x20'+m['object']+'\x20exists');if(isEmptyAddr(l['progress'])){g['push']('Order\x20'+m['object']+'\x20has\x20no\x20Progress\x20object');continue;}const o=await fetchRefs([{'type':'Progress','object':String(l['progress'])}],b,c),q=o['objects'][0x0];if(o['queryError']){g['push'](o['queryError']);continue;}if(!q){g['push']('Progress\x20'+l['progress']+'\x20not\x20found\x20on\x20chain');continue;}const r=typeof q['current']==='string'?q['current']:'';let s=![];if(c['fetchMachineNodes']&&!isEmptyAddr(q['machine']))try{const v=await c['fetchMachineNodes'](String(q['machine']),b);if(v['length']===0x0)f['push']('Progress\x20'+l['progress']+'\x20exists\x20(node\x20\x27'+r+'\x27);\x20machine\x20topology\x20empty\x20—\x20terminal\x20check\x20skipped'),s=!![];else{const w=new Set();for(const y of v){for(const z of y['pairs']??[]){if(z['prev_node'])w['add'](z['prev_node']);}}const x=v['some'](A=>A['name']===r);if(x&&!w['has'](r))f['push']('Progress\x20is\x20at\x20terminal\x20node\x20\x27'+r+'\x27'),s=!![];else!x?g['push']('Progress\x20node\x20\x27'+r+'\x27\x20not\x20found\x20in\x20machine\x20topology'):g['push']('Progress\x20node\x20\x27'+r+'\x27\x20is\x20not\x20terminal\x20(has\x20outgoing\x20forwards)');}}catch(A){f['push']('Progress\x20'+l['progress']+'\x20exists\x20(node\x20\x27'+r+'\x27);\x20terminal\x20check\x20skipped:\x20'+(A instanceof Error?A['message']:String(A))),s=!![];}else f['push']('Progress\x20'+l['progress']+'\x20exists\x20(node\x20\x27'+r+'\x27)'),s=!![];if(!s)continue;if(isEmptyAddr(l['allocation']))return f['push']('Order\x20'+m['object']+'\x20has\x20no\x20allocation\x20(nothing\x20to\x20settle)'),{'complete':!![],'evidence':f,'missing':g};if(!isEmptyAddr(l['claimed_by']))return f['push']('Order\x20'+m['object']+'\x20allocation\x20claimed\x20by\x20'+l['claimed_by']),{'complete':!![],'evidence':f,'missing':g};const t=await fetchRefs([{'type':'Allocation','object':String(l['allocation'])}],b,c);if(t['queryError']){g['push'](t['queryError']);continue;}const u=t['objects'][0x0];if(!u){g['push']('Allocation\x20'+l['allocation']+'\x20not\x20found\x20on\x20chain');continue;}if(balanceIsZero(u['balance']))return f['push']('Allocation\x20'+l['allocation']+'\x20balance\x20is\x20zero\x20(settled)'),{'complete':!![],'evidence':f,'missing':g};g['push']('Allocation\x20'+l['allocation']+'\x20still\x20holds\x20balance\x20'+String(u['balance']));}return{'complete':![],'evidence':f,'missing':g};}async function checkPublishDemand(a,b,c){const d=refsOfType(a,'Demand'),e=[],f=[];if(d['length']===0x0)return{'complete':![],'evidence':e,'missing':['no\x20Demand\x20object\x20registered\x20on\x20the\x20goal']};const {objects:g,queryError:h}=await fetchRefs(d,b,c);if(h)f['push'](h);let i=![];return g['forEach']((j,k)=>{const l=d[k];if(!j){if(!h)f['push']('Demand\x20'+l['object']+'\x20not\x20found\x20on\x20chain');return;}e['push']('Demand\x20'+l['object']+'\x20exists');const m=Array['isArray'](j['rewards'])?j['rewards']:[];if(m['length']<0x1){f['push']('Demand\x20'+l['object']+'\x20has\x20no\x20rewards\x20bound');return;}e['push']('Demand\x20'+l['object']+'\x20has\x20'+m['length']+'\x20reward(s)\x20bound'),i=!![];}),{'complete':i,'evidence':e,'missing':f};}async function checkRunArbitration(a,b,c){const d=refsOfType(a,'Arbitration'),e=[],f=[];if(d['length']===0x0)return{'complete':![],'evidence':e,'missing':['no\x20Arbitration\x20object\x20registered\x20on\x20the\x20goal']};const {objects:g,queryError:h}=await fetchRefs(d,b,c);if(h)f['push'](h);let i=![];return g['forEach']((j,k)=>{const l=d[k];if(!j){if(!h)f['push']('Arbitration\x20'+l['object']+'\x20not\x20found\x20on\x20chain');return;}e['push']('Arbitration\x20'+l['object']+'\x20exists');if(j['bPaused']===!![]){f['push']('Arbitration\x20'+l['object']+'\x20is\x20paused');return;}e['push']('Arbitration\x20'+l['object']+'\x20is\x20not\x20paused');if(j['fee']===null||j['fee']===undefined){f['push']('Arbitration\x20'+l['object']+'\x20fee\x20not\x20configured');return;}if(j['balance']===null||j['balance']===undefined){f['push']('Arbitration\x20'+l['object']+'\x20balance\x20not\x20configured');return;}e['push']('Arbitration\x20'+l['object']+'\x20fee='+String(j['fee'])+'\x20balance='+String(j['balance'])),i=!![];}),{'complete':i,'evidence':e,'missing':f};}async function checkExistence(a,b,c){const d=[],e=[];if(a['objects']['length']===0x0)return{'complete':![],'evidence':d,'missing':['no\x20objects\x20registered\x20on\x20the\x20goal']};const {objects:f,queryError:g}=await fetchRefs(a['objects'],b,c);if(g)e['push'](g);return f['forEach']((h,j)=>{const k=a['objects'][j];if(!h){if(!g)e['push'](k['type']+'\x20'+k['object']+'\x20not\x20found\x20on\x20chain');return;}if(!typeMatches(k,h)){e['push'](k['type']+'\x20'+k['object']+'\x20type\x20mismatch\x20(fetched:\x20'+(h?.['type']??'unknown')+')');return;}d['push'](k['type']+'\x20'+k['object']+'\x20exists');}),{'complete':e['length']===0x0,'evidence':d,'missing':e};}export const GOAL_COMPLETION_RULES={'publish_service':checkPublishService,'purchase_service':checkPurchaseService,'publish_demand':checkPublishDemand,'run_arbitration':checkRunArbitration,'fulfill_order':checkExistence,'capture_demand':checkExistence,'collaborate_flow':checkExistence,'supply_suborder':checkExistence,'dispute_resolution':checkExistence,'manage_assets':checkExistence};function defaultDeps(){return{'queryObjects':async(a,b)=>{const {batchQueryObjectsByIds:c}=await import('
|
|
1
|
+
function normAddr(a){if(!a)return'';const b=a['startsWith']('0x')?a['slice'](0x2):a;return b['toLowerCase']();}function isEmptyAddr(a){return a===null||a===undefined||String(a)['trim']()==='';}function balanceIsZero(a){if(a===null||a===undefined)return![];try{return BigInt(String(a))===0x0n;}catch{return![];}}async function fetchRefs(a,b,c){if(a['length']===0x0)return{'objects':[]};try{const d=await c['queryObjects'](a['map'](g=>g['object']),b),f=new Map();for(const g of d??[]){if(!g)continue;const h=normAddr(g?.['object']);if(h)f['set'](h,g);if(typeof g?.['query_name']==='string')f['set'](normAddr(g['query_name']),g);}return{'objects':a['map'](i=>f['get'](normAddr(i['object'])))};}catch(i){return{'objects':a['map'](()=>undefined),'queryError':'chain\x20query\x20failed:\x20'+(i instanceof Error?i['message']:String(i))};}}function typeMatches(a,b){const c=b?.['type'];if(!c)return!![];return String(c)['toLowerCase']()===a['type']['toLowerCase']();}function refsOfType(a,b){return a['objects']['filter'](c=>c['type']['toLowerCase']()===b['toLowerCase']());}async function checkPublishService(a,b,c){const d=refsOfType(a,'Service'),e=[],f=[];if(d['length']===0x0)return{'complete':![],'evidence':e,'missing':['no\x20Service\x20object\x20registered\x20on\x20the\x20goal']};const {objects:g,queryError:h}=await fetchRefs(d,b,c);if(h)f['push'](h);let i=![];return g['forEach']((j,k)=>{const l=d[k];if(!j){if(!h)f['push']('Service\x20'+l['object']+'\x20not\x20found\x20on\x20chain');return;}if(!typeMatches(l,j)){f['push']('Service\x20'+l['object']+'\x20type\x20mismatch\x20(fetched:\x20'+(j?.['type']??'unknown')+')');return;}if(j['bPaused']!==![]){f['push']('Service\x20'+l['object']+'\x20is\x20paused\x20(bPaused='+String(j['bPaused'])+')');return;}e['push']('Service\x20'+l['object']+'\x20exists\x20and\x20is\x20not\x20paused');const m=Array['isArray'](j['sales'])?j['sales']:[];if(m['length']<0x1){f['push']('Service\x20'+l['object']+'\x20has\x20no\x20purchasable\x20items\x20(sales\x20is\x20empty)');return;}e['push']('Service\x20'+l['object']+'\x20has\x20'+m['length']+'\x20purchasable\x20item(s)');if(isEmptyAddr(j['machine'])){f['push']('Service\x20'+l['object']+'\x20has\x20no\x20Machine\x20bound');return;}e['push']('Service\x20'+l['object']+'\x20has\x20a\x20Machine\x20bound\x20('+j['machine']+')');if(isEmptyAddr(j['permission'])){f['push']('Service\x20'+l['object']+'\x20has\x20no\x20Permission\x20bound');return;}e['push']('Service\x20'+l['object']+'\x20has\x20a\x20Permission\x20bound\x20('+j['permission']+')'),i=!![];}),{'complete':i,'evidence':e,'missing':f};}async function checkPurchaseService(a,b,c){const d=refsOfType(a,'Order'),f=[],g=[];if(d['length']===0x0)return{'complete':![],'evidence':f,'missing':['no\x20Order\x20object\x20registered\x20on\x20the\x20goal']};const {objects:h,queryError:j}=await fetchRefs(d,b,c);if(j)g['push'](j);for(let k=0x0;k<h['length'];k++){const l=h[k],m=d[k];if(!l){if(!j)g['push']('Order\x20'+m['object']+'\x20not\x20found\x20on\x20chain');continue;}f['push']('Order\x20'+m['object']+'\x20exists');if(isEmptyAddr(l['progress'])){g['push']('Order\x20'+m['object']+'\x20has\x20no\x20Progress\x20object');continue;}const o=await fetchRefs([{'type':'Progress','object':String(l['progress'])}],b,c),q=o['objects'][0x0];if(o['queryError']){g['push'](o['queryError']);continue;}if(!q){g['push']('Progress\x20'+l['progress']+'\x20not\x20found\x20on\x20chain');continue;}const r=typeof q['current']==='string'?q['current']:'';let s=![];if(c['fetchMachineNodes']&&!isEmptyAddr(q['machine']))try{const v=await c['fetchMachineNodes'](String(q['machine']),b);if(v['length']===0x0)f['push']('Progress\x20'+l['progress']+'\x20exists\x20(node\x20\x27'+r+'\x27);\x20machine\x20topology\x20empty\x20—\x20terminal\x20check\x20skipped'),s=!![];else{const w=new Set();for(const y of v){for(const z of y['pairs']??[]){if(z['prev_node'])w['add'](z['prev_node']);}}const x=v['some'](A=>A['name']===r);if(x&&!w['has'](r))f['push']('Progress\x20is\x20at\x20terminal\x20node\x20\x27'+r+'\x27'),s=!![];else!x?g['push']('Progress\x20node\x20\x27'+r+'\x27\x20not\x20found\x20in\x20machine\x20topology'):g['push']('Progress\x20node\x20\x27'+r+'\x27\x20is\x20not\x20terminal\x20(has\x20outgoing\x20forwards)');}}catch(A){f['push']('Progress\x20'+l['progress']+'\x20exists\x20(node\x20\x27'+r+'\x27);\x20terminal\x20check\x20skipped:\x20'+(A instanceof Error?A['message']:String(A))),s=!![];}else f['push']('Progress\x20'+l['progress']+'\x20exists\x20(node\x20\x27'+r+'\x27)'),s=!![];if(!s)continue;if(isEmptyAddr(l['allocation']))return f['push']('Order\x20'+m['object']+'\x20has\x20no\x20allocation\x20(nothing\x20to\x20settle)'),{'complete':!![],'evidence':f,'missing':g};if(!isEmptyAddr(l['claimed_by']))return f['push']('Order\x20'+m['object']+'\x20allocation\x20claimed\x20by\x20'+l['claimed_by']),{'complete':!![],'evidence':f,'missing':g};const t=await fetchRefs([{'type':'Allocation','object':String(l['allocation'])}],b,c);if(t['queryError']){g['push'](t['queryError']);continue;}const u=t['objects'][0x0];if(!u){g['push']('Allocation\x20'+l['allocation']+'\x20not\x20found\x20on\x20chain');continue;}if(balanceIsZero(u['balance']))return f['push']('Allocation\x20'+l['allocation']+'\x20balance\x20is\x20zero\x20(settled)'),{'complete':!![],'evidence':f,'missing':g};g['push']('Allocation\x20'+l['allocation']+'\x20still\x20holds\x20balance\x20'+String(u['balance']));}return{'complete':![],'evidence':f,'missing':g};}async function checkPublishDemand(a,b,c){const d=refsOfType(a,'Demand'),e=[],f=[];if(d['length']===0x0)return{'complete':![],'evidence':e,'missing':['no\x20Demand\x20object\x20registered\x20on\x20the\x20goal']};const {objects:g,queryError:h}=await fetchRefs(d,b,c);if(h)f['push'](h);let i=![];return g['forEach']((j,k)=>{const l=d[k];if(!j){if(!h)f['push']('Demand\x20'+l['object']+'\x20not\x20found\x20on\x20chain');return;}e['push']('Demand\x20'+l['object']+'\x20exists');const m=Array['isArray'](j['rewards'])?j['rewards']:[];if(m['length']<0x1){f['push']('Demand\x20'+l['object']+'\x20has\x20no\x20rewards\x20bound');return;}e['push']('Demand\x20'+l['object']+'\x20has\x20'+m['length']+'\x20reward(s)\x20bound'),i=!![];}),{'complete':i,'evidence':e,'missing':f};}async function checkRunArbitration(a,b,c){const d=refsOfType(a,'Arbitration'),e=[],f=[];if(d['length']===0x0)return{'complete':![],'evidence':e,'missing':['no\x20Arbitration\x20object\x20registered\x20on\x20the\x20goal']};const {objects:g,queryError:h}=await fetchRefs(d,b,c);if(h)f['push'](h);let i=![];return g['forEach']((j,k)=>{const l=d[k];if(!j){if(!h)f['push']('Arbitration\x20'+l['object']+'\x20not\x20found\x20on\x20chain');return;}e['push']('Arbitration\x20'+l['object']+'\x20exists');if(j['bPaused']===!![]){f['push']('Arbitration\x20'+l['object']+'\x20is\x20paused');return;}e['push']('Arbitration\x20'+l['object']+'\x20is\x20not\x20paused');if(j['fee']===null||j['fee']===undefined){f['push']('Arbitration\x20'+l['object']+'\x20fee\x20not\x20configured');return;}if(j['balance']===null||j['balance']===undefined){f['push']('Arbitration\x20'+l['object']+'\x20balance\x20not\x20configured');return;}e['push']('Arbitration\x20'+l['object']+'\x20fee='+String(j['fee'])+'\x20balance='+String(j['balance'])),i=!![];}),{'complete':i,'evidence':e,'missing':f};}async function checkExistence(a,b,c){const d=[],e=[];if(a['objects']['length']===0x0)return{'complete':![],'evidence':d,'missing':['no\x20objects\x20registered\x20on\x20the\x20goal']};const {objects:f,queryError:g}=await fetchRefs(a['objects'],b,c);if(g)e['push'](g);return f['forEach']((h,j)=>{const k=a['objects'][j];if(!h){if(!g)e['push'](k['type']+'\x20'+k['object']+'\x20not\x20found\x20on\x20chain');return;}if(!typeMatches(k,h)){e['push'](k['type']+'\x20'+k['object']+'\x20type\x20mismatch\x20(fetched:\x20'+(h?.['type']??'unknown')+')');return;}d['push'](k['type']+'\x20'+k['object']+'\x20exists');}),{'complete':e['length']===0x0,'evidence':d,'missing':e};}export const GOAL_COMPLETION_RULES={'publish_service':checkPublishService,'purchase_service':checkPurchaseService,'publish_demand':checkPublishDemand,'run_arbitration':checkRunArbitration,'fulfill_order':checkExistence,'capture_demand':checkExistence,'collaborate_flow':checkExistence,'supply_suborder':checkExistence,'dispute_resolution':checkExistence,'manage_assets':checkExistence};function defaultDeps(){return{'queryObjects':async(a,b)=>{const {batchQueryObjectsByIds:c}=await import('../graph/onchain/sdk-batch.js');return c(a,b,![]);},'fetchMachineNodes':async(a,b)=>{const {fetchMachineNodes:c}=await import('../graph/onchain/sdk-batch.js');return c(a,b,![]);}};}export async function evaluateGoalCompletion(a,b,c){const d={...defaultDeps(),...c??{}},f=GOAL_COMPLETION_RULES[a['goal_type']]??checkExistence;try{return await f(a,b,d);}catch(g){return{'complete':![],'evidence':[],'missing':['completion\x20check\x20failed:\x20'+(g instanceof Error?g['message']:String(g))]};}}
|
|
@@ -37,6 +37,7 @@ export interface GuardRenderInput {
|
|
|
37
37
|
logic_or?: boolean;
|
|
38
38
|
} | null;
|
|
39
39
|
}
|
|
40
|
+
export declare function walkGuardTree(root: GuardNodeForRender, visit: (node: GuardNodeForRender) => void): void;
|
|
40
41
|
export declare function renderGuardMermaid(root: GuardNodeForRender, options?: {
|
|
41
42
|
colored?: boolean;
|
|
42
43
|
}): string;
|
|
@@ -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{
|
|
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');}
|