@wowok/agent-mcp 3.4.2 → 3.4.3
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/.build-stamp.json +5 -0
- package/dist/chain-semantics/composition-truth.js +1 -1
- package/dist/chain-semantics/eval-order.js +1 -1
- package/dist/chain-semantics/field-capability.js +1 -1
- package/dist/chain-semantics/freeze-map.js +1 -1
- package/dist/chain-semantics/fund-flow.js +1 -1
- package/dist/chain-semantics/guard-verbs.js +1 -1
- package/dist/chain-semantics/object-graph.js +1 -1
- package/dist/composition/audit.js +1 -1
- package/dist/composition/compile.d.ts +10 -3
- package/dist/composition/compile.js +1 -1
- package/dist/composition/emit-phases.d.ts +30 -2
- package/dist/composition/emit-phases.js +1 -1
- package/dist/composition/guard-fill.d.ts +8 -0
- package/dist/composition/guard-fill.js +1 -1
- package/dist/composition/inflight.js +1 -1
- package/dist/composition/input-normalize.js +1 -1
- package/dist/composition/materialize.d.ts +2 -0
- package/dist/composition/materialize.js +1 -1
- package/dist/composition/mode-gates.js +1 -1
- package/dist/composition/param-disclosure.js +1 -1
- package/dist/composition/plan-retry-ledger.d.ts +16 -0
- package/dist/composition/plan-retry-ledger.js +1 -1
- package/dist/composition/plan.d.ts +15 -1
- package/dist/composition/plan.js +1 -1
- package/dist/config/config-audit.spec.js +1 -1
- package/dist/config/judgment.d.ts +5 -0
- package/dist/config/judgment.js +1 -1
- package/dist/evaluation/builtins/arbitration-score.d.ts +1 -0
- package/dist/evaluation/builtins/arbitration-score.js +1 -1
- package/dist/evaluation/builtins/demand-match.js +1 -1
- package/dist/evaluation/builtins/graph-service.d.ts +8 -0
- package/dist/evaluation/builtins/graph-service.js +1 -1
- package/dist/evaluation/capability.d.ts +9 -0
- package/dist/evaluation/engine.js +1 -1
- package/dist/evaluation/extract.d.ts +9 -1
- package/dist/evaluation/extract.js +1 -1
- package/dist/evaluation/match-operation.js +1 -1
- package/dist/evaluation/match-policy.d.ts +5 -3
- package/dist/evaluation/match-policy.js +1 -1
- package/dist/evaluation/standards.d.ts +1 -0
- package/dist/evaluation/standards.js +1 -1
- package/dist/evaluation/structured-lines.js +1 -1
- package/dist/evaluation/types.d.ts +1 -0
- package/dist/extensions/capability.js +1 -1
- package/dist/harness/recover.js +1 -1
- package/dist/index.js +1 -1
- package/dist/intent/types.d.ts +1 -1
- package/dist/intent/types.js +1 -1
- package/dist/knowledge/allocation-ledger.js +1 -1
- package/dist/knowledge/allocator-rail-verifier.d.ts +17 -1
- package/dist/knowledge/allocator-rail-verifier.js +1 -1
- package/dist/knowledge/arb-fund-facts.d.ts +7 -0
- package/dist/knowledge/arb-fund-facts.js +1 -1
- package/dist/knowledge/arbitration-rail-verifier.d.ts +35 -0
- package/dist/knowledge/arbitration-rail-verifier.js +1 -0
- package/dist/knowledge/audit-rules.d.ts +11 -0
- package/dist/knowledge/audit-rules.js +1 -1
- package/dist/knowledge/baselines/judgment-baselines.json +1 -0
- package/dist/knowledge/baselines/rules/guard.json +7 -6
- package/dist/knowledge/baselines/rules/progress.json +4 -4
- package/dist/knowledge/baselines/rules/reward.json +118 -3
- package/dist/knowledge/builtin-templates.d.ts +3 -2
- package/dist/knowledge/builtin-templates.js +1 -1
- package/dist/knowledge/chain-query-registry.d.ts +14 -0
- package/dist/knowledge/chain-query-registry.js +1 -0
- package/dist/knowledge/event-semantics.js +1 -1
- package/dist/knowledge/fee-param-bindings.d.ts +2 -0
- package/dist/knowledge/fee-param-bindings.js +1 -1
- package/dist/knowledge/getting-started.js +1 -1
- package/dist/knowledge/guard-binding-table.js +1 -1
- package/dist/knowledge/guard-binding-verifier.d.ts +7 -0
- package/dist/knowledge/guard-binding-verifier.js +1 -1
- package/dist/knowledge/guard-design-patterns.d.ts +1 -1
- package/dist/knowledge/guard-design-patterns.js +1 -1
- package/dist/knowledge/guard-host-context.js +1 -1
- package/dist/knowledge/guard-lint.js +1 -1
- package/dist/knowledge/guard-node-gates.d.ts +3 -1
- package/dist/knowledge/guard-node-gates.js +1 -1
- package/dist/knowledge/guard-puzzle.js +1 -1
- package/dist/knowledge/guard-render.js +1 -1
- package/dist/knowledge/guard-risk.js +1 -1
- package/dist/knowledge/guard-templates.d.ts +2 -1
- package/dist/knowledge/guard-templates.js +1 -1
- package/dist/knowledge/guard-translation.js +1 -1
- package/dist/knowledge/index.d.ts +2 -0
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/jsonrpc-enum.js +1 -1
- package/dist/knowledge/knob-docs.js +1 -1
- package/dist/knowledge/param-schema.d.ts +1 -1
- package/dist/knowledge/param-schema.js +1 -1
- package/dist/knowledge/param-tiers.d.ts +2 -0
- package/dist/knowledge/param-tiers.js +1 -1
- package/dist/knowledge/path-oracle/products/food-delivery.js +1 -1
- package/dist/knowledge/pattern-resolutions.d.ts +2 -0
- package/dist/knowledge/pattern-resolutions.js +1 -1
- package/dist/knowledge/product-detail-source.d.ts +37 -0
- package/dist/knowledge/product-detail-source.js +1 -0
- package/dist/knowledge/product-doc-b5.d.ts +16 -0
- package/dist/knowledge/product-doc-b5.js +1 -0
- package/dist/knowledge/progress-ledger.js +1 -1
- package/dist/knowledge/projection.spec.js +1 -1
- package/dist/knowledge/publish-gate.d.ts +20 -0
- package/dist/knowledge/publish-gate.js +1 -0
- package/dist/knowledge/publish-readiness.d.ts +25 -0
- package/dist/knowledge/publish-readiness.js +1 -0
- package/dist/knowledge/publish-surface-contract.d.ts +16 -0
- package/dist/knowledge/publish-surface-contract.js +1 -0
- package/dist/knowledge/rail-exit-satisfiability.d.ts +25 -0
- package/dist/knowledge/rail-exit-satisfiability.js +1 -0
- package/dist/knowledge/reward-ledger.d.ts +1 -1
- package/dist/knowledge/reward-ledger.js +1 -1
- package/dist/knowledge/reward-risk.d.ts +1 -1
- package/dist/knowledge/reward-risk.js +1 -1
- package/dist/knowledge/service-ledger.d.ts +3 -1
- package/dist/knowledge/service-ledger.js +1 -1
- package/dist/knowledge/template-loader.d.ts +41 -2
- package/dist/knowledge/template-loader.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/template-scanner.d.ts +17 -0
- package/dist/knowledge/template-scanner.js +1 -1
- package/dist/knowledge/workflow-guidance.d.ts +4 -0
- package/dist/knowledge/workflow-guidance.js +1 -1
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/monitor/normalize.d.ts +1 -1
- package/dist/monitor/normalize.js +1 -1
- package/dist/monitor/types.js +1 -1
- package/dist/participation/game-context.js +1 -1
- package/dist/participation/radar-core.js +1 -1
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/machine-panorama.js +1 -1
- package/dist/playbooks/service-build/merchant-guide.d.ts +28 -3
- package/dist/playbooks/service-build/merchant-guide.js +1 -1
- package/dist/playbooks/service-build/object-panorama.d.ts +4 -0
- 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.js +1 -1
- package/dist/playbooks/service-build/service-panorama.js +1 -1
- package/dist/playbooks/service-build/service-quote.js +1 -1
- package/dist/review/index.js +1 -1
- package/dist/review/order.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/benchmark-migration/index.d.ts +24 -0
- package/dist/schema/benchmark-migration/index.js +1 -1
- package/dist/schema/call/allocation.d.ts +11 -7
- package/dist/schema/call/allocation.js +1 -1
- package/dist/schema/call/arbitration.d.ts +4 -0
- package/dist/schema/call/arbitration.js +1 -1
- package/dist/schema/call/base.d.ts +28 -0
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/bridge.d.ts +21 -0
- package/dist/schema/call/contact.d.ts +4 -0
- package/dist/schema/call/demand.d.ts +4 -0
- package/dist/schema/call/guard.d.ts +12 -0
- package/dist/schema/call/handler.d.ts +1 -0
- package/dist/schema/call/handler.js +1 -1
- package/dist/schema/call/machine.d.ts +16 -8
- package/dist/schema/call/normalize-error.d.ts +1 -0
- package/dist/schema/call/normalize-error.js +1 -0
- package/dist/schema/call/order.d.ts +7 -3
- package/dist/schema/call/order.js +1 -1
- package/dist/schema/call/payment.d.ts +7 -3
- package/dist/schema/call/permission.d.ts +4 -0
- package/dist/schema/call/personal.d.ts +4 -0
- package/dist/schema/call/progress.d.ts +4 -0
- package/dist/schema/call/progress.js +1 -1
- package/dist/schema/call/proof.d.ts +8 -0
- package/dist/schema/call/receipt.js +1 -1
- package/dist/schema/call/repository.d.ts +4 -0
- package/dist/schema/call/reward.d.ts +6 -2
- package/dist/schema/call/reward.js +1 -1
- package/dist/schema/call/semantic.d.ts +2 -2
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.d.ts +6 -2
- package/dist/schema/call/treasury.d.ts +10 -6
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/envelope-unify.d.ts +1 -0
- package/dist/schema/envelope-unify.js +1 -1
- package/dist/schema/evaluation/index.d.ts +43 -0
- package/dist/schema/evaluation/index.js +1 -1
- package/dist/schema/goal/index.d.ts +14 -2
- package/dist/schema/goal/planning.d.ts +18 -0
- package/dist/schema/goal/planning.js +1 -1
- package/dist/schema/intent-radar/index.d.ts +12 -0
- package/dist/schema/intent-radar/index.js +1 -1
- package/dist/schema/keeper/index.d.ts +1 -0
- package/dist/schema/local/index.d.ts +10 -0
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/local/wip.js +1 -1
- package/dist/schema/messenger/index.d.ts +1 -0
- package/dist/schema/messenger/index.js +1 -1
- package/dist/schema/operations.d.ts +95 -12
- package/dist/schema/operations.js +1 -1
- package/dist/schema/persona/index.d.ts +22 -0
- package/dist/schema/query/bi.d.ts +28 -2
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/query/index.d.ts +67 -61
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema/workflow/index.js +1 -1
- package/dist/schema-query-impl/index.d.ts +1 -0
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +2 -1
- package/dist/schemas/benchmark_migration_operation.output.json +74 -0
- package/dist/schemas/benchmark_migration_operation.schema.json +32 -0
- package/dist/schemas/bridge_operation.output.json +2 -1
- package/dist/schemas/bridge_operation.schema.json +40 -0
- package/dist/schemas/evaluation_operation.output.json +96 -0
- package/dist/schemas/evaluation_operation.schema.json +39 -0
- package/dist/schemas/goal_operation.schema.json +32 -0
- package/dist/schemas/guard2file.schema.json +8 -0
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/intent_radar.output.json +10 -2
- package/dist/schemas/intent_radar.schema.json +5 -1
- package/dist/schemas/keeper_operation.output.json +2 -1
- package/dist/schemas/local_cache_operation.output.json +2 -1
- package/dist/schemas/local_history_operation.output.json +2 -1
- package/dist/schemas/local_info_operation.output.json +2 -1
- package/dist/schemas/local_mark_operation.output.json +2 -1
- package/dist/schemas/local_mark_operation.schema.json +10 -1
- package/dist/schemas/machineNode2file.schema.json +8 -0
- package/dist/schemas/messenger_operation.output.json +2 -1
- package/dist/schemas/messenger_operation.schema.json +2 -1
- package/dist/schemas/monitor_events.output.json +2 -1
- package/dist/schemas/monitor_subscription.output.json +2 -1
- package/dist/schemas/onchain_events.output.json +206 -13
- package/dist/schemas/onchain_events.schema.json +16 -0
- package/dist/schemas/onchain_operations.output.json +22 -3
- package/dist/schemas/onchain_operations.schema.json +971 -326
- package/dist/schemas/onchain_operations_allocation.schema.json +19 -12
- package/dist/schemas/onchain_operations_arbitration.schema.json +9 -1
- package/dist/schemas/onchain_operations_contact.schema.json +8 -0
- package/dist/schemas/onchain_operations_demand.schema.json +8 -0
- package/dist/schemas/onchain_operations_gen_passport.schema.json +8 -0
- package/dist/schemas/onchain_operations_gen_proof.schema.json +8 -0
- package/dist/schemas/onchain_operations_guard.schema.json +654 -114
- package/dist/schemas/onchain_operations_machine.schema.json +11 -3
- package/dist/schemas/onchain_operations_order.schema.json +14 -11
- package/dist/schemas/onchain_operations_payment.schema.json +12 -9
- package/dist/schemas/onchain_operations_permission.schema.json +8 -0
- package/dist/schemas/onchain_operations_personal.schema.json +8 -0
- package/dist/schemas/onchain_operations_progress.schema.json +9 -1
- package/dist/schemas/onchain_operations_proof.schema.json +8 -0
- package/dist/schemas/onchain_operations_repository.schema.json +8 -0
- package/dist/schemas/onchain_operations_reward.schema.json +14 -11
- package/dist/schemas/onchain_operations_service.schema.json +13 -10
- package/dist/schemas/onchain_operations_treasury.schema.json +17 -19
- package/dist/schemas/onchain_table_data.output.json +52 -10
- package/dist/schemas/persona_operation.output.json +57 -0
- package/dist/schemas/persona_operation.schema.json +9 -0
- package/dist/schemas/query_toolkit.output.json +325 -22
- package/dist/schemas/query_toolkit.schema.json +18 -5
- package/dist/schemas/wip_file.output.json +2 -2
- package/dist/schemas/wip_file.schema.json +2 -2
- package/dist/schemas/workflow_operation.schema.json +1 -1
- package/dist/tools/error-catalog.d.ts +17 -0
- package/dist/tools/error-catalog.js +1 -0
- package/dist/tools/handlers/benchmark-migration.d.ts +20 -8
- package/dist/tools/handlers/benchmark-migration.js +1 -1
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/entry-edge-recipe.d.ts +101 -0
- package/dist/tools/handlers/entry-edge-recipe.js +1 -0
- package/dist/tools/handlers/escrow-deficit.d.ts +10 -0
- package/dist/tools/handlers/escrow-deficit.js +1 -0
- package/dist/tools/handlers/evaluation.js +1 -1
- package/dist/tools/handlers/fund-rail-recipe.d.ts +10 -0
- package/dist/tools/handlers/fund-rail-recipe.js +1 -0
- package/dist/tools/handlers/intent-radar.js +1 -1
- package/dist/tools/handlers/local.js +1 -1
- package/dist/tools/handlers/mark-namespace.d.ts +30 -0
- package/dist/tools/handlers/mark-namespace.js +1 -0
- package/dist/tools/handlers/messenger.js +1 -1
- package/dist/tools/handlers/onchain-name-registration.d.ts +1 -0
- package/dist/tools/handlers/onchain-name-registration.js +1 -1
- package/dist/tools/handlers/onchain-name-registration.spec.js +1 -1
- package/dist/tools/handlers/onchain.d.ts +30 -1
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/publish-binding-echo.d.ts +22 -0
- package/dist/tools/handlers/publish-binding-echo.js +1 -0
- package/dist/tools/handlers/query.d.ts +1 -1
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/handlers/review-chain.d.ts +1 -0
- package/dist/tools/handlers/review-chain.js +1 -1
- package/dist/tools/handlers/schema-query.js +1 -1
- package/dist/tools/handlers/stale-build-check.d.ts +9 -0
- package/dist/tools/handlers/stale-build-check.js +1 -0
- package/dist/tools/handlers/submission-assembly.d.ts +55 -0
- package/dist/tools/handlers/submission-assembly.js +1 -0
- package/dist/tools/handlers/wip.js +1 -1
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.js +1 -1
- package/dist/tools/move-fn-index.gen.js +1 -1
- package/dist/tools/publish-gate-state.d.ts +5 -0
- package/dist/tools/publish-gate-state.js +1 -0
- package/dist/tools/registry/business.js +1 -1
- package/dist/tools/registry/onchain.js +1 -1
- package/dist/tools/registry/query.js +1 -1
- package/dist/tools/retry.js +1 -1
- package/dist/tools/runtime-health.js +1 -1
- package/dist/tools/shared.js +1 -1
- package/dist/tools/upgrade-check.d.ts +1 -0
- package/dist/tools/upgrade-check.js +1 -1
- package/dist/tools/wip-verify-ledger.d.ts +2 -0
- package/dist/tools/wip-verify-ledger.js +1 -1
- package/dist/tools/wrap.d.ts +15 -1
- package/dist/tools/wrap.js +1 -1
- package/package.json +5 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SERVICE_PERMISSIONS=[{'index':0x12c,'name':'SERVICE_NEW','description':'Create\x20new\x20Service','governed_operation':'create\x20a\x20new\x20Service','post_publish_mutability':'na'},{'index':0x12d,'name':'SERVICE_DESCRIPTION','description':'Modify\x20Service\x20description','governed_operation':'modify\x20the\x20Service\x20description','post_publish_mutability':'mutable'},{'index':0x12f,'name':'SERVICE_LOCATION','description':'Set\x20Service\x20location/URL','governed_operation':'set\x20the\x20Service\x20location/URL','post_publish_mutability':'mutable'},{'index':0x130,'name':'SERVICE_REPOSITORY','description':'Add/remove\x20Repository\x20references','governed_operation':'add/remove/clear\x20Repository\x20references','post_publish_mutability':'mutable'},{'index':0x131,'name':'SERVICE_SALES','description':'Add/set/remove/clear\x20sales\x20items;\x20opt\x20SKUs\x20into\x20refund\x20restocking\x20(per-SKU\x20restock\x20flag\x20and\x20order\x20restock)','governed_operation':'add/set/remove/clear\x20sales\x20items;\x20restock\x20flags\x20+\x20order\x20restock','post_publish_mutability':'mutable'},{'index':0x132,'name':'SERVICE_MACHINE','description':'Bind/unbind\x20Machine\x20workflow\x20template','governed_operation':'bind/unbind\x20the\x20Machine\x20workflow\x20template','post_publish_mutability':'immutable'},{'index':0x133,'name':'SERVICE_BUY_GUARD','description':'Set/clear\x20buy\x20Guard\x20(post-publish\x20mutable)','governed_operation':'set/clear\x20the\x20buy_guard\x20check','post_publish_mutability':'mutable'},{'index':0x134,'name':'SERVICE_ARBITRATION','description':'Add/remove\x20Arbitration\x20references','governed_operation':'add/remove/clear\x20Arbitration\x20references','post_publish_mutability':'immutable'},{'index':0x135,'name':'SERVICE_CUSTOMER_INFO_REQUIRED','description':'Set\x20customer\x20required\x20info\x20fields','governed_operation':'set\x20customer\x20required\x20info\x20fields','post_publish_mutability':'mutable'},{'index':0x136,'name':'SERVICE_PAUSE','description':'Pause/resume\x20Service\x20(block\x20new\x20orders)','governed_operation':'pause/resume\x20the\x20Service','post_publish_mutability':'mutable'},{'index':0x137,'name':'SERVICE_PUBLISH','description':'Publish\x20Service\x20(IRREVERSIBLE)','governed_operation':'publish\x20the\x20Service\x20(irreversible)','post_publish_mutability':'one_shot'},{'index':0x138,'name':'SERVICE_DISCOUNT','description':'Issue/discount_destroy\x20discount\x20coupons','governed_operation':'issue/destroy\x20discount\x20coupons','post_publish_mutability':'mutable'},{'index':0x139,'name':'SERVICE_ORDER_ALLOCATOR','description':'Set\x20order\x20allocator\x20strategy','governed_operation':'set\x20the\x20order_allocators\x20strategy','post_publish_mutability':'immutable'},{'index':0x13a,'name':'SERVICE_COMPENSATION_FUND_WITHDRAW','description':'Withdraw\x20compensation\x20fund\x20(time-locked)','governed_operation':'withdraw\x20from\x20the\x20compensation_fund\x20(time-locked)','post_publish_mutability':'locked_by_duration'},{'index':0x13b,'name':'SERVICE_COMPENSATION_FUND_DEPOSIT','description':'Deposit\x20to\x20compensation\x20fund','governed_operation':'deposit\x20to\x20the\x20compensation_fund','post_publish_mutability':'mutable'},{'index':0x13c,'name':'SERVICE_COMPENSATION_FUND_RECEIVE','description':'Receive\x20compensation\x20fund\x20(arbitration\x20payout)','governed_operation':'receive\x20the\x20compensation_fund\x20payout\x20(arbitration\x20payout)','post_publish_mutability':'mutable'},{'index':0x13d,'name':'SERVICE_COMPENSATION_LOCK_DURATION_ADD','description':'Extend\x20setting_lock_duration\x20(only-increase)','governed_operation':'extend\x20setting_lock_duration\x20(only-increase)','post_publish_mutability':'mutable'},{'index':0x13e,'name':'SERVICE_REWARD','description':'Add/remove\x20Reward\x20references\x20(remove/clear\x20time-locked)','governed_operation':'add/remove/clear\x20Reward\x20references','post_publish_mutability':'locked_by_duration'},{'index':0x13f,'name':'SERVICE_OWNER_RECEIVE','description':'Receive\x20Payment/objects\x20to\x20owner','governed_operation':'receive\x20Payments/objects\x20to\x20owner','post_publish_mutability':'mutable'},{'index':0x140,'name':'SERVICE_UM','description':'Bind/unbind\x20Contact\x20as\x20UM','governed_operation':'bind/unbind\x20Contact\x20as\x20UM','post_publish_mutability':'mutable'},{'index':0x141,'name':'SERVICE_ARB_STATEMENT','description':'Append\x20seller\x20statement\x20to\x20an\x20Arb\x20case\x20(event-only)','governed_operation':'append\x20seller\x20text\x20to\x20a\x20case\x20against\x20an\x20order\x20of\x20this\x20service\x20(ArbStatementEvent;\x20no\x20Arb\x20state\x20change)','post_publish_mutability':'mutable'}];export const SERVICE_LISTING_REFUND_GATES={'price_floor':{'rule':'A\x20sale\x20listed\x20at\x20price\x200\x20is\x20REFUSED\x20at\x20construction\x20time\x20(aborts\x20E_PRICE_BELOW_FLOOR\x20=\x2044)\x20—\x20applies\x20to\x20every\x20sale-minting\x20path\x20(sales\x20add\x20/\x20sales\x20set\x20/\x20replace).\x20The\x20SDK\x20refuses\x20it\x20locally\x20in\x20the\x20sale\x20builder.','rationale':'A\x20zero-priced\x20listing\x20plus\x20an\x20allocation-free\x200-amount\x20order\x20produced\x20stores\x20whose\x20entire\x20economics\x20live\x20outside\x20the\x20chain.\x20Repricing\x20an\x20EXISTING\x20sale\x20down\x20to\x20zero\x20stays\x20legal\x20and\x20is\x20caught\x20at\x20buy\x20time\x20by\x20the\x20zero-total\x20order\x20gate.'},'restock':{'rule':'Refund\x20restocking\x20is\x20opt-in\x20per\x20SKU:\x20the\x20merchant\x20marks\x20an\x20ALIVE\x20sale\x20with\x20the\x20restock\x20flag\x20(305),\x20then\x20a\x20refunded\x20order\x27s\x20purchased\x20units\x20can\x20be\x20put\x20back\x20on\x20shelf\x20(305).\x20Two-pass\x20on-chain\x20(validate\x20every\x20line,\x20then\x20apply)\x20—\x20ALL\x20lines\x20restock\x20or\x20NOTHING\x20mutates.\x20Unflagged\x20or\x20delisted\x20lines\x20abort\x20E_RESTOCK_NOT_FLAGGED\x20=\x2046\x20/\x20E_SALE_ITEM_NOT_FOUND.\x20Quantities\x20come\x20from\x20the\x20order\x27s\x20purchase\x20rows.\x20ONCE-PER-ORDER:\x20the\x20restock\x20operation\x20stamps\x20the\x20order\x20with\x20a\x20RestockStamp\x20dynamic\x20field\x20and\x20a\x20second\x20call\x20for\x20the\x20same\x20order\x20aborts\x20E_RESTOCK_ALREADY_APPLIED\x20=\x2049\x20(a\x20replay\x20would\x20stack\x20the\x20purchased\x20units\x20again,\x20an\x20unbounded\x20+quantity).\x20OWNERSHIP-BOUND:\x20only\x20an\x20order\x20whose\x20service\x20field\x20is\x20THIS\x20service\x20restocks\x20here\x20—\x20a\x20foreign\x20order\x20aborts\x20E_ORDER_SERVICE_NOT_MATCH\x20=\x2026.\x20The\x20applied\x20state\x20lives\x20in\x20a\x20RestockStamp\x20dynamic\x20field\x20on\x20the\x20service\x20(no\x20public\x20query\x20primitive);\x20the\x20MCP\x20restock\x20op:\x27order\x27\x20pre-gate\x20reads\x20that\x20stamp\x20pre-send\x20and\x20refuses\x20a\x20replay\x20without\x20burning\x20gas.','events':'StockRestockedEvent\x20per\x20line\x20(service,\x20order,\x20item,\x20quantity,\x20time).'},'dismissal_conclusion':{'rule':'The\x20dismissal\x20conclusion\x20stamps\x20a\x20CONCLUDED,\x20DEFENDANT-FAVORED\x20ruling\x20onto\x20the\x20order\x20(claimed_by\x20=\x20case\x20address)\x20—\x20the\x20mirror\x20of\x20the\x20compensation\x20claim.\x20Requires:\x20order\x20belongs\x20to\x20this\x20service,\x20arbitration\x20on\x20the\x20merchant\x20allowlist,\x20no\x20self-judging\x20(E_ARBITRATION_PERMISSION_CONFLICT),\x20case\x20concluded\x20(Arbitrated/Withdrawn)\x20AND\x20indemnity\x20none/0\x20(E_CASE_NOT_DISMISSAL_CONCLUSION\x20=\x2048).\x20Permissionless\x20keeper\x20surface;\x20writes\x20a\x20flag,\x20moves\x20no\x20funds.','closes':'A\x20dismissal\x20ruling\x20would\x20otherwise\x20never\x20stamp\x20claimed_by\x20(the\x20zero-indemnity\x20claim\x20gate\x20refuses\x20the\x20claim\x20path),\x20so\x20a\x20buyer\x20who\x20LOST\x20the\x20case\x20kept\x20every\x20`claimed_by\x20none`\x20refund\x20rail\x20open\x20forever.'}};export const SERVICE_ORDER_FLOW_STAGES=[{'stage':0x1,'name':'pre_check','preconditions':['Service.bPublished\x20==\x20true\x20(else\x20E_NOT_PUBLISHED,\x20service:7)','Service.bPaused\x20==\x20false\x20(else\x20E_PAUSED,\x20service:19)','buy_guard\x20(if\x20set)\x20added\x20to\x20guards[]\x20list\x20for\x20verification'],'side_effects':[],'always_executed':!![]},{'stage':0x2,'name':'wip_verify','preconditions':['buy.items\x20non-empty','Each\x20item.name\x20matches\x20a\x20sale\x20in\x20Service.sales\x20(else\x20E_SALE_ITEM_NOT_FOUND,\x20service:32)','sale.suspension\x20==\x20false\x20(else\x20E_SALE_SUSPENDED)'],'side_effects':['If\x20buyer\x20passes\x20empty\x20wip_hash,\x20SDK\x20auto-fills\x20with\x20sale.wip_hash','verifiedWipUrls\x20Set\x20avoids\x20re-verifying\x20same\x20WIP\x20URL\x20across\x20items','verify_wip()\x20fetches\x20WIP\x20file\x20and\x20compares\x20hash\x20(else\x20E_WIP_HASH_NOT_MATCH)'],'always_executed':!![]},{'stage':0x3,'name':'quote','preconditions':['All\x20items\x20have\x20valid\x20sale\x20+\x20wip_hash\x20match','stock\x20>=\x20purchase\x20quantity\x20(else\x20E_STOCK_NOT_ENOUGH,\x20service:16)','discount\x20object\x20(if\x20used)\x20is\x20valid\x20and\x20within\x20its\x20[time_start,\x20time_end]\x20window\x20(else\x20E_DISCOUNT_TIME_INVALID)'],'side_effects':['The\x20quote\x20step\x20computes\x20the\x20total\x20price\x20(with\x20discount\x20if\x20applicable)','⚠️\x20Stock\x20is\x20deducted\x20(split)\x20—\x20side\x20effect\x20is\x20NOT\x20auto-rolled-back\x20on\x20later\x20failure','The\x20on-chain\x20quote\x20call\x20executes\x20(the\x20discount\x20path\x20validates\x20the\x20Clock\x20time-window\x20check)'],'always_executed':!![]},{'stage':0x4,'name':'create_order','preconditions':['Quote\x20object\x20from\x20stage\x203','Registrar\x20+\x20Clock\x20objects\x20available'],'side_effects':['The\x20atomic\x20on-chain\x20buy\x20call\x20executes\x20(passport-gated\x20variant\x20supported)','Order\x20object\x20created\x20(builder=customer,\x20service=Service.id)','Order.id\x20recorded\x20for\x20stages\x205-7'],'always_executed':!![]},{'stage':0x5,'name':'create_allocation','preconditions':['Service.order_allocators\x20is\x20Some\x20(configured)','Order\x20from\x20stage\x204','CoinParam\x20for\x20total_pay\x20matches\x20Service<T>\x20type'],'side_effects':['The\x20on-chain\x20allocation\x20call\x20executes','Allocation\x20object\x20created\x20(guard-selected\x20fund\x20distribution)','Order.allocation\x20=\x20Allocation\x20address'],'always_executed':!![]},{'stage':0x6,'name':'create_progress','preconditions':['Service.machine\x20is\x20Some\x20(machine\x20bound)','Order\x20from\x20stage\x204','Machine\x20from\x20Service.machine'],'side_effects':['The\x20on-chain\x20progress-creation\x20call\x20executes','Progress\x20object\x20created\x20(Progress.machine\x20=\x20Service.machine,\x20Progress.task\x20=\x20Order.id)'],'always_executed':![]},{'stage':0x7,'name':'post_actions','preconditions':['Order/Allocation/Progress\x20objects\x20from\x20stages\x204-6'],'side_effects':['Attach\x20agents\x20to\x20the\x20order\x20(if\x20order_new.agents\x20provided)','order_required_info_update\x20(if\x20order_required_info\x20provided)','Transfer\x20Order\x20ownership\x20(if\x20transfer\x20provided\x20—\x20sets\x20new\x20Order\x20owner)','namedNewOrder\x20/\x20namedNewAllocation\x20/\x20namedNewProgress\x20(local\x20naming)'],'always_executed':![]},{'stage':0x8,'name':'return_result','preconditions':['All\x20preceding\x20stages\x20succeeded'],'side_effects':['Returns\x20BuyResult\x20{\x20order,\x20allocation?,\x20progress?\x20}','Caller\x20proceeds\x20to\x20sign\x20+\x20submit\x20transaction'],'always_executed':!![]}];export const SERVICE_CROSS_OBJECT_BINDINGS=[{'object':'Machine','field':'machine','required':![],'locked_after_publish':!![],'notes':'Workflow\x20template;\x20post-publish\x20immutable\x20(F-S-20).\x20Progress.machine\x20inherits\x20this\x20value.'},{'object':'Guard','field':'buy_guard','required':![],'locked_after_publish':![],'notes':'Buyer\x20eligibility\x20guard;\x20post-publish\x20STILL\x20MUTABLE\x20(unusual\x20—\x20see\x20F-S-26)'},{'object':'Allocation','field':'order_allocators','required':!![],'locked_after_publish':!![],'notes':'Order\x20fund\x20distribution\x20strategy;\x20publish\x20prerequisite\x20(F-S-18).\x20Post-publish\x20immutable\x20(F-S-22).'},{'object':'Arbitration','field':'arbitrations','required':![],'locked_after_publish':![],'notes':'Dispute\x20handlers;\x20required\x20if\x20compensation_fund\x20>\x200\x20(F-S-19).\x20add\x20always\x20mutable;\x20remove/clear\x20time-locked\x20after\x20publish\x20(F-S-21).'},{'object':'Repository','field':'repositories','required':![],'locked_after_publish':![],'notes':'Shared\x20data\x20stores;\x20mutable\x20post-publish'},{'object':'Reward','field':'rewards','required':![],'locked_after_publish':![],'notes':'Marketing\x20incentives;\x20add\x20always\x20mutable;\x20remove/clear\x20time-locked\x20after\x20publish\x20(F-S-24)'},{'object':'Contact','field':'um','required':![],'locked_after_publish':![],'notes':'User\x20Manager\x20(Contact\x20object);\x20mutable\x20post-publish'},{'object':'Treasury','field':'(indirect\x20via\x20order_allocators.sharing.who=Entity)','required':![],'locked_after_publish':![],'notes':'Treasury\x20is\x20referenced\x20by\x20Allocation.sharing.who,\x20not\x20by\x20Service\x20directly'}];export const SERVICE_SCENES=[{'id':'service_retail','name':'Retail\x20e-commerce\x20Service','category':'retail','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description','set\x20the\x20location/URL','set\x20customer\x20required\x20info\x20fields'],'permission_index_operations':['publish\x20the\x20Service\x20(311)','pause/resume\x20the\x20Service\x20(310)','add/set/remove/clear\x20sales\x20items\x20(305)','set\x20the\x20order_allocators\x20strategy\x20(313)','set/clear\x20the\x20buy_guard\x20check\x20(307)','issue/destroy\x20discount\x20coupons\x20(312)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set\x20(F-S-18,\x20E_NO_ALLOCATOR)','If\x20compensation_fund\x20>\x200,\x20arbitrations\x20must\x20be\x20non-empty\x20(F-S-19)'],'common_patterns':['Multi-tier\x20pricing\x20via\x20sales[]\x20(Standard/Premium/Enterprise)','WIP\x20hash\x20per\x20sale\x20item\x20for\x20tamper-proof\x20product\x20info','buy_guard\x20for\x20KYC\x20whitelist\x20during\x20pre-sale,\x20then\x20null\x20for\x20public\x20sale','compensation_fund\x20deposited\x20before\x20publish\x20+\x20arbitrations\x20configured'],'recommended_templates':['T-S-01','T-S-06']},{'id':'service_rental','name':'Rental\x20Service\x20(short/long-term)','category':'rental','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description','set\x20the\x20location/URL'],'permission_index_operations':['publish\x20the\x20Service\x20(311)','add/set\x20sales\x20items\x20(305)','bind\x20the\x20Machine\x20workflow\x20(306)\x20—\x20for\x20rental\x20workflow','add\x20Arbitration\x20references\x20(308)\x20—\x20for\x20deposit\x20disputes'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set','machine\x20recommended\x20(rental\x20workflow\x20with\x20deposit/return\x20stages)','arbitrations\x20recommended\x20(deposit\x20refund\x20disputes)'],'common_patterns':['Machine\x20workflow\x20with\x20\x27Deposit\x20→\x20Use\x20→\x20Return\x20→\x20Refund\x27\x20nodes','compensation_fund\x20holds\x20deposit\x20guarantees','buy_guard\x20verifies\x20renter\x20identity/KYC','stock=1\x20per\x20rental\x20item\x20(unique\x20items)'],'recommended_templates':['T-S-02','T-S-04']},{'id':'service_subscription','name':'Subscription\x20Service\x20(recurring)','category':'subscription','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description','set\x20the\x20location/URL'],'permission_index_operations':['publish\x20the\x20Service\x20(311)','add/set\x20sales\x20items\x20(305)','issue\x20discount\x20coupons\x20(312)\x20—\x20promotional\x20rates','add\x20Reward\x20references\x20(318)\x20—\x20loyalty\x20rewards'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Tiered\x20plans\x20(Free/Pro/Enterprise)\x20as\x20sales[]','Discount\x20coupons\x20for\x20trial\x20periods','Rewards\x20for\x20long-term\x20subscribers','Renewal\x20handled\x20by\x20repeat\x20orders\x20(no\x20native\x20recurring\x20billing)'],'recommended_templates':['T-S-03']},{'id':'service_workflow','name':'Workflow-bound\x20Service\x20(machine-bound)','category':'workflow','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description','set\x20the\x20location/URL'],'permission_index_operations':['bind\x20the\x20Machine\x20workflow\x20(306)','publish\x20the\x20Service\x20(311)','set\x20the\x20order_allocators\x20strategy\x20(313)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set','machine\x20must\x20be\x20published\x20before\x20binding','machine\x20recommended\x20for\x20any\x20multi-stage\x20service\x20delivery'],'common_patterns':['Machine\x20defines\x20Pay\x20→\x20Confirm\x20→\x20Deliver\x20→\x20Sign-off\x20nodes','Progress\x20created\x20per\x20order\x20(stage\x206\x20of\x20buy\x20flow)','Named\x20operators\x20assigned\x20per\x20Forward\x20in\x20Machine','Service.paused\x20does\x20NOT\x20affect\x20already-created\x20Progress\x20(existing\x20orders\x20continue)'],'recommended_templates':['T-S-04']},{'id':'service_arbitration','name':'Arbitration-bound\x20Service\x20(dispute-ready)','category':'arbitration','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description'],'permission_index_operations':['add\x20Arbitration\x20references\x20(308)','deposit\x20to\x20the\x20compensation_fund\x20(315)','extend\x20setting_lock_duration\x20(317)','publish\x20the\x20Service\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['If\x20compensation_fund\x20>\x200,\x20arbitrations\x20must\x20be\x20non-empty\x20(F-S-19)','Arbitration\x20objects\x20must\x20be\x20created\x20before\x20binding','compensation_fund_add\x20before\x20publish\x20recommended\x20(else\x20post-publish\x20deposit\x20still\x20possible)'],'common_patterns':['2-3\x20Arbitration\x20objects\x20(different\x20arb\x20committees\x20for\x20different\x20dispute\x20types)','compensation_fund\x20deposited\x20as\x20%\x20of\x20expected\x20order\x20volume','setting_lock_duration\x20extended\x20by\x20owner\x20to\x20build\x20customer\x20trust','Arbitration\x20compensation\x20payout\x20triggered\x20by\x20the\x20arbitration\x20result\x20(not\x20by\x20Service\x20directly)'],'recommended_templates':['T-S-05','T-S-06']},{'id':'service_compensation_fund','name':'Compensation\x20Fund\x20Service\x20(embedded\x20balance)','category':'compensation_fund','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description'],'permission_index_operations':['deposit\x20to\x20the\x20compensation_fund\x20(315)','withdraw\x20from\x20the\x20compensation_fund\x20(314)\x20—\x20time-locked\x20after\x20publish','receive\x20the\x20compensation_fund\x20payout\x20(316)\x20—\x20arbitration\x20payout\x20(always\x20mutable)','extend\x20setting_lock_duration\x20(317)\x20—\x20extend\x20lock'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['compensation_fund\x20>\x200\x20→\x20arbitrations\x20non-empty\x20(F-S-19)','compensation_fund\x20coin\x20type\x20must\x20match\x20Service<T>\x20type\x20parameter'],'common_patterns':['Fund\x20inflow:\x20compensation_fund_add\x20(315)\x20—\x20always\x20mutable','Fund\x20outflow:\x20compensation_fund_withdraw\x20(314)\x20—\x20requires\x20bPaused\x20+\x20lock_duration\x20expired','Fund\x20receive:\x20compensation_fund_receive\x20(316)\x20—\x20arbitration\x20payout,\x20always\x20mutable','Fund\x20consumer:\x20arbitration\x20compensation\x20payout\x20(driven\x20by\x20arb\x20result)','Distinct\x20from\x20Treasury:\x20Service-internal,\x20arbitration-bound,\x20lock-protected'],'recommended_templates':['T-S-06']},{'id':'service_reward','name':'Reward-attached\x20Service\x20(marketing)','category':'reward','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description'],'permission_index_operations':['add/remove/clear\x20Reward\x20references\x20(318)\x20—\x20add\x20always\x20mutable;\x20remove/clear\x20time-locked\x20after\x20publish','issue/destroy\x20discount\x20coupons\x20(312)','publish\x20the\x20Service\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Rewards\x20added\x20post-publish\x20(always\x20allowed;\x20remove/clear\x20is\x20time-locked\x20after\x20publish)','Reward\x20objects\x20must\x20exist\x20before\x20binding\x20(queryObjectsWithType\x20validation)','MAX_REWARD_COUNT\x20=\x2020\x20per\x20Service','Reward\x20remove/clear\x20requires\x20Service\x20paused\x20+\x20setting_lock_duration\x20elapsed\x20(protects\x20customer\x20expectations)'],'recommended_templates':['T-S-08']},{'id':'service_arbitration_binding','name':'Arbitration\x20Binding\x20Service\x20(post-publish\x20immutable)','category':'arbitration','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description'],'permission_index_operations':['add\x20Arbitration\x20references\x20(308)\x20—\x20pre-publish\x20only','remove\x20an\x20Arbitration\x20reference\x20(308)\x20—\x20pre-publish\x20only','clear\x20Arbitration\x20references\x20(308)\x20—\x20pre-publish\x20only','publish\x20the\x20Service\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['MAX_ARBITRATION_COUNT\x20=\x2020\x20per\x20Service\x20(F-S-04)','Each\x20Arbitration\x20object\x20must\x20be\x20valid\x20(queryObjectsWithType\x20validation)','Arbitration\x20bound\x20=\x20locked\x20post-publish\x20(F-S-21).\x20To\x20change:\x20create\x20new\x20Service.'],'common_patterns':['Pre-publish:\x20set\x201-3\x20Arbitration\x20objects\x20for\x20different\x20dispute\x20scopes','Post-publish:\x20immutable\x20—\x20clone\x20Service\x20if\x20change\x20needed','⚠️\x20Data\x20inconsistency:\x20the\x20dynamic-pricing\x20metadata\x20marks\x20arbitrations\x20as\x20mutable,\x20but\x20the\x20SDK\x20blocks\x20it\x20(F-S-21)'],'recommended_templates':['T-S-05']},{'id':'service_buy_guard','name':'Buy\x20Guard\x20Service\x20(post-publish\x20mutable\x20guard)','category':'buy_guard','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description'],'permission_index_operations':['bind\x20the\x20buy_guard\x20Guard\x20(307)','clear\x20the\x20buy_guard\x20Guard\x20(307)','publish\x20the\x20Service\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Pre-sale\x20phase:\x20buy_guard\x20=\x20whitelist\x20Guard\x20(KYC\x20verified\x20buyers\x20only)','Public\x20sale:\x20buy_guard\x20=\x20null\x20(anyone\x20can\x20buy)','Restricted\x20phase:\x20buy_guard\x20=\x20KYC\x20Guard\x20(compliance)','⚠️\x20buy_guard\x20is\x20the\x20ONLY\x20publish-locked-field\x20exception\x20—\x20still\x20mutable\x20post-publish','buy_guard\x20verification\x20happens\x20at\x20Stage\x201\x20of\x20buy\x20flow\x20(pre_check)'],'recommended_templates':['T-S-01']},{'id':'service_order_allocator','name':'Order\x20Allocator\x20Service\x20(fund\x20distribution\x20config)','category':'order_allocator','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description'],'permission_index_operations':['set\x20the\x20order_allocators\x20strategy\x20(313)\x20—\x20pre-publish\x20only','publish\x20the\x20Service\x20(311)\x20—\x20requires\x20order_allocators\x20(F-S-18)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20MUST\x20be\x20set\x20(F-S-18,\x20E_NO_ALLOCATOR)','Allocators.sharing.who\x20can\x20reference\x20Treasury\x20addresses\x20(indirect\x20Treasury\x20binding)','MAX_SHARING_COUNT\x20=\x20100\x20per\x20allocator'],'common_patterns':['Multi-party\x20split:\x20merchant\x2080%\x20/\x20platform\x2010%\x20/\x20logistics\x2010%','Threshold-based:\x20different\x20allocators\x20for\x20different\x20order\x20sizes','Guard-bound\x20allocator:\x20allocation\x20execution\x20requires\x20Guard\x20verification','Post-publish\x20immutable\x20—\x20clone\x20Service\x20to\x20change\x20allocation\x20strategy'],'recommended_templates':['T-S-08']},{'id':'service_dynamic_pricing','name':'Dynamic\x20Pricing\x20Service\x20(discount-driven)','category':'dynamic_pricing','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description'],'permission_index_operations':['issue\x20discount\x20coupons\x20(312)','add/set\x20sales\x20items\x20(305)\x20—\x20adjust\x20base\x20prices','remove\x20sales\x20items\x20(305)\x20—\x20remove\x20deprecated\x20SKUs'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Discount\x20types:\x200=rates\x20(basis\x20points,\x20per\x2010000),\x201=minus\x20(direct\x20deduction)','MAX_DISCOUNT_COUNT_ONCE\x20=\x201000\x20per\x20issue\x20call','MAX_DISCOUNT_RECEIVER_ONCE\x20=\x201000\x20receivers\x20per\x20call','MAX_DISCOUNT_TOTAL_COUNT\x20=\x2020000\x20total\x20coupons','discount_destroy:\x20holder-only\x20(no\x20SERVICE_DISCOUNT\x20permission\x20needed)','discount_send:\x20holder-only\x20transfer\x20of\x20owned\x20transferable:true\x20coupons\x20to\x20another\x20address\x20(no\x20permission\x20needed);\x20KB-02\x20semantics:\x20issuance\x20=\x20discount\x20(mint)\x20then\x20discount_send\x20(transfer)\x20—\x20holding\x20IS\x20the\x20credential\x20(only\x20the\x20holder\x27s\x20signature\x20spends\x20it),\x20one\x20coupon\x20one\x20burn\x20(single-use,\x20transfer\x20does\x20not\x20reset\x20it),\x20refunds\x20settle\x20the\x20post-coupon\x20amount\x20only;\x20a\x20coupon\x20held\x20by\x20another\x20address\x20cannot\x20be\x20applied\x20to\x20a\x20buy\x20—\x20have\x20the\x20owner\x20discount_send\x20it\x20to\x20the\x20buyer\x20first'],'recommended_templates':['T-S-07']},{'id':'service_multi_allocator','name':'Multi-Allocator\x20Service\x20(tiered\x20fund\x20distribution)','category':'multi_allocator','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description'],'permission_index_operations':['set\x20the\x20order_allocators\x20strategy\x20(313)\x20—\x20pre-publish\x20only','publish\x20the\x20Service\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20MUST\x20be\x20set','Each\x20allocator\x20has\x20its\x20own\x20Guard\x20+\x20sharing\x20+\x20threshold','Each\x20allocator\x20is\x20bound\x20to\x20a\x20DIFFERENT\x20guard\x20—\x20the\x20caller\x27s\x20submitted\x20guard\x20selects\x20which\x20path\x20fires'],'common_patterns':['Tier\x201\x20(small\x20orders):\x20single-recipient\x20allocator\x20(low\x20fee)','Tier\x202\x20(medium\x20orders):\x20two-recipient\x20split\x20(merchant\x20+\x20platform)','Tier\x203\x20(large\x20orders):\x20three-recipient\x20split\x20(merchant\x20+\x20platform\x20+\x20logistics)','Each\x20tier\x20can\x20have\x20its\x20own\x20Guard\x20for\x20execution\x20authorization'],'recommended_templates':['T-S-08']}];export const SERVICE_LEDGER_VERSION='1.0.0';export function getScenesByCategory(a){return SERVICE_SCENES['filter'](b=>b['category']===a);}export function findSceneById(a){return SERVICE_SCENES['find'](b=>b['id']===a);}export function getServicePermissionByIndex(a){return SERVICE_PERMISSIONS['find'](b=>b['index']===a);}export function isServicePermission(a){return getServicePermissionByIndex(a)!==undefined;}export function getPermissionsByMutability(a){return SERVICE_PERMISSIONS['filter'](b=>b['post_publish_mutability']===a);}export function getImmutablePostPublishPermissions(){return SERVICE_PERMISSIONS['filter'](a=>a['post_publish_mutability']==='immutable'||a['post_publish_mutability']==='one_shot');}export function getLockedByDurationPermissions(){return SERVICE_PERMISSIONS['filter'](a=>a['post_publish_mutability']==='locked_by_duration');}export function inferSceneFromIntent(a){const b=a['toLowerCase'](),c=[['retail','retail'],['ecommerce','retail'],['rental','rental'],['rent','rental'],['short-term\x20rental','rental'],['long-term\x20rental','rental'],['subscription','subscription'],['subscribe','subscription'],['workflow','workflow'],['machine-bound','workflow'],['arbitration','arbitration'],['dispute','arbitration'],['compensation','compensation_fund'],['compensation_fund','compensation_fund'],['reward','reward'],['marketing','reward'],['buy_guard','buy_guard'],['kyc','buy_guard'],['whitelist','buy_guard'],['allocator','order_allocator'],['discount','dynamic_pricing'],['coupon','dynamic_pricing'],['multi-allocator','multi_allocator'],['tiered','multi_allocator']];for(const [d,e]of c){if(b['includes'](d)){const f=getScenesByCategory(e);if(f['length']>0x0)return f[0x0];}}if(b['includes']('service'))return findSceneById('service_retail');return undefined;}export function getAllServiceScenes(){return[...SERVICE_SCENES];}export function getServiceScenesCount(){return SERVICE_SCENES['length'];}export function getServicePermissionsCount(){return SERVICE_PERMISSIONS['length'];}export function getOrderFlowStage(a){return SERVICE_ORDER_FLOW_STAGES['find'](b=>b['stage']===a);}export function getCrossObjectBindings(){return[...SERVICE_CROSS_OBJECT_BINDINGS];}
|
|
1
|
+
export const SERVICE_PERMISSIONS=[{'index':0x12c,'name':'SERVICE_NEW','description':'Create\x20new\x20Service','governed_operation':'create\x20a\x20new\x20Service','post_publish_mutability':'na'},{'index':0x12d,'name':'SERVICE_DESCRIPTION','description':'Modify\x20Service\x20description','governed_operation':'modify\x20the\x20Service\x20description','post_publish_mutability':'mutable'},{'index':0x12f,'name':'SERVICE_LOCATION','description':'Set\x20Service\x20location/URL','governed_operation':'set\x20the\x20Service\x20location/URL','post_publish_mutability':'mutable'},{'index':0x130,'name':'SERVICE_REPOSITORY','description':'Add/remove\x20Repository\x20references','governed_operation':'add/remove/clear\x20Repository\x20references','post_publish_mutability':'mutable'},{'index':0x131,'name':'SERVICE_SALES','description':'Add/set/remove/clear\x20sales\x20items;\x20opt\x20SKUs\x20into\x20refund\x20restocking\x20(per-SKU\x20restock\x20flag\x20and\x20order\x20restock)','governed_operation':'add/set/remove/clear\x20sales\x20items;\x20restock\x20flags\x20+\x20order\x20restock','post_publish_mutability':'mutable'},{'index':0x132,'name':'SERVICE_MACHINE','description':'Bind/unbind\x20Machine\x20workflow\x20template','governed_operation':'bind/unbind\x20the\x20Machine\x20workflow\x20template','post_publish_mutability':'immutable'},{'index':0x133,'name':'SERVICE_BUY_GUARD','description':'Set/clear\x20buy\x20Guard\x20(post-publish\x20mutable)','governed_operation':'set/clear\x20the\x20buy_guard\x20check','post_publish_mutability':'mutable'},{'index':0x134,'name':'SERVICE_ARBITRATION','description':'Add/remove\x20Arbitration\x20references','governed_operation':'add/remove/clear\x20Arbitration\x20references','post_publish_mutability':'immutable'},{'index':0x135,'name':'SERVICE_CUSTOMER_INFO_REQUIRED','description':'Set\x20customer\x20required\x20info\x20fields','governed_operation':'set\x20customer\x20required\x20info\x20fields','post_publish_mutability':'mutable'},{'index':0x136,'name':'SERVICE_PAUSE','description':'Pause/resume\x20Service\x20(block\x20new\x20orders)','governed_operation':'pause/resume\x20the\x20Service','post_publish_mutability':'mutable'},{'index':0x137,'name':'SERVICE_PUBLISH','description':'Publish\x20Service\x20(IRREVERSIBLE)','governed_operation':'publish\x20the\x20Service\x20(irreversible)','post_publish_mutability':'one_shot'},{'index':0x138,'name':'SERVICE_DISCOUNT','description':'Issue/discount_destroy\x20discount\x20coupons','governed_operation':'issue/destroy\x20discount\x20coupons','post_publish_mutability':'mutable'},{'index':0x139,'name':'SERVICE_ORDER_ALLOCATOR','description':'Set\x20order\x20allocator\x20strategy','governed_operation':'set\x20the\x20order_allocators\x20strategy','post_publish_mutability':'immutable'},{'index':0x13a,'name':'SERVICE_COMPENSATION_FUND_WITHDRAW','description':'Withdraw\x20compensation\x20fund\x20(time-locked)','governed_operation':'withdraw\x20from\x20the\x20compensation_fund\x20(time-locked)','post_publish_mutability':'locked_by_duration'},{'index':0x13b,'name':'SERVICE_COMPENSATION_FUND_DEPOSIT','description':'Deposit\x20to\x20compensation\x20fund','governed_operation':'deposit\x20to\x20the\x20compensation_fund','post_publish_mutability':'mutable'},{'index':0x13c,'name':'SERVICE_COMPENSATION_FUND_RECEIVE','description':'Receive\x20compensation\x20fund\x20(arbitration\x20payout)','governed_operation':'receive\x20the\x20compensation_fund\x20payout\x20(arbitration\x20payout)','post_publish_mutability':'mutable'},{'index':0x13d,'name':'SERVICE_COMPENSATION_LOCK_DURATION_ADD','description':'Extend\x20setting_lock_duration\x20(only-increase)','governed_operation':'extend\x20setting_lock_duration\x20(only-increase)','post_publish_mutability':'mutable'},{'index':0x13e,'name':'SERVICE_REWARD','description':'Add/remove\x20Reward\x20references\x20(remove/clear\x20time-locked)','governed_operation':'add/remove/clear\x20Reward\x20references','post_publish_mutability':'locked_by_duration'},{'index':0x13f,'name':'SERVICE_OWNER_RECEIVE','description':'Receive\x20Payment/objects\x20to\x20owner','governed_operation':'receive\x20Payments/objects\x20to\x20owner','post_publish_mutability':'mutable'},{'index':0x140,'name':'SERVICE_UM','description':'Bind/unbind\x20Contact\x20as\x20UM','governed_operation':'bind/unbind\x20Contact\x20as\x20UM','post_publish_mutability':'mutable'},{'index':0x141,'name':'SERVICE_ARB_STATEMENT','description':'Append\x20seller\x20statement\x20to\x20an\x20Arb\x20case\x20(event-only)','governed_operation':'append\x20seller\x20text\x20to\x20a\x20case\x20against\x20an\x20order\x20of\x20this\x20service\x20(ArbStatementEvent;\x20no\x20Arb\x20state\x20change)','post_publish_mutability':'mutable'}];export const SERVICE_LISTING_REFUND_GATES={'price_floor':{'rule':'A\x20sale\x20listed\x20at\x20price\x200\x20is\x20REFUSED\x20at\x20construction\x20time\x20(aborts\x20E_PRICE_BELOW_FLOOR\x20=\x2044)\x20—\x20applies\x20to\x20every\x20sale-minting\x20path\x20(sales\x20add\x20/\x20sales\x20set\x20/\x20replace).\x20The\x20SDK\x20refuses\x20it\x20locally\x20in\x20the\x20sale\x20builder.','rationale':'A\x20zero-priced\x20listing\x20plus\x20an\x20allocation-free\x200-amount\x20order\x20produced\x20stores\x20whose\x20entire\x20economics\x20live\x20outside\x20the\x20chain.\x20Repricing\x20an\x20EXISTING\x20sale\x20down\x20to\x20zero\x20stays\x20legal\x20and\x20is\x20caught\x20at\x20buy\x20time\x20by\x20the\x20zero-total\x20order\x20gate.'},'restock':{'rule':'Refund\x20restocking\x20is\x20opt-in\x20per\x20SKU:\x20the\x20merchant\x20marks\x20an\x20ALIVE\x20sale\x20with\x20the\x20restock\x20flag\x20(305),\x20then\x20a\x20refunded\x20order\x27s\x20purchased\x20units\x20can\x20be\x20put\x20back\x20on\x20shelf\x20(305).\x20Two-pass\x20on-chain\x20(validate\x20every\x20line,\x20then\x20apply)\x20—\x20ALL\x20lines\x20restock\x20or\x20NOTHING\x20mutates.\x20Unflagged\x20or\x20delisted\x20lines\x20abort\x20E_RESTOCK_NOT_FLAGGED\x20=\x2046\x20/\x20E_SALE_ITEM_NOT_FOUND.\x20Quantities\x20come\x20from\x20the\x20order\x27s\x20purchase\x20rows.\x20ONCE-PER-ORDER:\x20the\x20restock\x20operation\x20stamps\x20the\x20order\x20with\x20a\x20RestockStamp\x20dynamic\x20field\x20and\x20a\x20second\x20call\x20for\x20the\x20same\x20order\x20aborts\x20E_RESTOCK_ALREADY_APPLIED\x20=\x2049\x20(a\x20replay\x20would\x20stack\x20the\x20purchased\x20units\x20again,\x20an\x20unbounded\x20+quantity).\x20OWNERSHIP-BOUND:\x20only\x20an\x20order\x20whose\x20service\x20field\x20is\x20THIS\x20service\x20restocks\x20here\x20—\x20a\x20foreign\x20order\x20aborts\x20E_ORDER_SERVICE_NOT_MATCH\x20=\x2026.\x20The\x20applied\x20state\x20lives\x20in\x20a\x20RestockStamp\x20dynamic\x20field\x20on\x20the\x20service\x20(no\x20public\x20query\x20primitive);\x20the\x20MCP\x20restock\x20op:\x27order\x27\x20pre-gate\x20reads\x20that\x20stamp\x20pre-send\x20and\x20refuses\x20a\x20replay\x20without\x20burning\x20gas.','events':'StockRestockedEvent\x20per\x20line\x20(service,\x20order,\x20item,\x20quantity,\x20time).'},'dismissal_conclusion':{'rule':'The\x20dismissal\x20conclusion\x20stamps\x20a\x20CONCLUDED,\x20DEFENDANT-FAVORED\x20ruling\x20onto\x20the\x20order\x20(claimed_by\x20=\x20case\x20address)\x20—\x20the\x20mirror\x20of\x20the\x20compensation\x20claim.\x20Requires:\x20order\x20belongs\x20to\x20this\x20service,\x20arbitration\x20on\x20the\x20merchant\x20allowlist,\x20no\x20self-judging\x20(E_ARBITRATION_PERMISSION_CONFLICT),\x20case\x20concluded\x20(Arbitrated/Withdrawn)\x20AND\x20indemnity\x20none/0\x20(E_CASE_NOT_DISMISSAL_CONCLUSION\x20=\x2048).\x20Permissionless\x20keeper\x20surface;\x20writes\x20a\x20flag,\x20moves\x20no\x20funds.','closes':'A\x20dismissal\x20ruling\x20would\x20otherwise\x20never\x20stamp\x20claimed_by\x20(the\x20zero-indemnity\x20claim\x20gate\x20refuses\x20the\x20claim\x20path),\x20so\x20a\x20buyer\x20who\x20LOST\x20the\x20case\x20kept\x20every\x20`claimed_by\x20none`\x20refund\x20rail\x20open\x20forever.'}};export const SERVICE_ORDER_FLOW_STAGES=[{'stage':0x1,'name':'pre_check','preconditions':['Service.bPublished\x20==\x20true\x20(else\x20E_NOT_PUBLISHED,\x20service:7)','Service.bPaused\x20==\x20false\x20(else\x20E_PAUSED,\x20service:19)','buy_guard\x20(if\x20set)\x20added\x20to\x20guards[]\x20list\x20for\x20verification'],'side_effects':[],'always_executed':!![]},{'stage':0x2,'name':'wip_verify','preconditions':['buy.items\x20non-empty','Each\x20item.name\x20matches\x20a\x20sale\x20in\x20Service.sales\x20(else\x20E_SALE_ITEM_NOT_FOUND,\x20service:32)','sale.suspension\x20==\x20false\x20(else\x20E_SALE_SUSPENDED)'],'side_effects':['If\x20buyer\x20passes\x20empty\x20wip_hash,\x20SDK\x20auto-fills\x20with\x20sale.wip_hash','verifiedWipUrls\x20Set\x20avoids\x20re-verifying\x20same\x20WIP\x20URL\x20across\x20items','verify_wip()\x20fetches\x20WIP\x20file\x20and\x20compares\x20hash\x20(else\x20E_WIP_HASH_NOT_MATCH)'],'always_executed':!![]},{'stage':0x3,'name':'quote','preconditions':['All\x20items\x20have\x20valid\x20sale\x20+\x20wip_hash\x20match','stock\x20>=\x20purchase\x20quantity\x20(else\x20E_STOCK_NOT_ENOUGH,\x20service:16)','discount\x20object\x20(if\x20used)\x20is\x20valid\x20and\x20within\x20its\x20[time_start,\x20time_end]\x20window\x20(else\x20E_DISCOUNT_TIME_INVALID)'],'side_effects':['The\x20quote\x20step\x20computes\x20the\x20total\x20price\x20(with\x20discount\x20if\x20applicable)','⚠️\x20Stock\x20is\x20deducted\x20(split)\x20—\x20side\x20effect\x20is\x20NOT\x20auto-rolled-back\x20on\x20later\x20failure','The\x20on-chain\x20quote\x20call\x20executes\x20(the\x20discount\x20path\x20validates\x20the\x20Clock\x20time-window\x20check)'],'always_executed':!![]},{'stage':0x4,'name':'create_order','preconditions':['Quote\x20object\x20from\x20stage\x203','Registrar\x20+\x20Clock\x20objects\x20available'],'side_effects':['The\x20atomic\x20on-chain\x20buy\x20call\x20executes\x20(passport-gated\x20variant\x20supported)','Order\x20object\x20created\x20(builder=customer,\x20service=Service.id)','Order.id\x20recorded\x20for\x20stages\x205-7'],'always_executed':!![]},{'stage':0x5,'name':'create_allocation','preconditions':['Service.order_allocators\x20is\x20Some\x20(configured)','Order\x20from\x20stage\x204','CoinParam\x20for\x20total_pay\x20matches\x20Service<T>\x20type'],'side_effects':['The\x20on-chain\x20allocation\x20call\x20executes','Allocation\x20object\x20created\x20(guard-selected\x20fund\x20distribution)','Order.allocation\x20=\x20Allocation\x20address'],'always_executed':!![]},{'stage':0x6,'name':'create_progress','preconditions':['Service.machine\x20is\x20Some\x20(machine\x20bound)','Order\x20from\x20stage\x204','Machine\x20from\x20Service.machine'],'side_effects':['The\x20on-chain\x20progress-creation\x20call\x20executes','Progress\x20object\x20created\x20(Progress.machine\x20=\x20Service.machine,\x20Progress.task\x20=\x20Order.id)'],'always_executed':![]},{'stage':0x7,'name':'post_actions','preconditions':['Order/Allocation/Progress\x20objects\x20from\x20stages\x204-6'],'side_effects':['Attach\x20agents\x20to\x20the\x20order\x20(if\x20order_new.agents\x20provided)','order_required_info_update\x20(if\x20order_required_info\x20provided)','Transfer\x20Order\x20ownership\x20(if\x20transfer\x20provided\x20—\x20sets\x20new\x20Order\x20owner)','namedNewOrder\x20/\x20namedNewAllocation\x20/\x20namedNewProgress\x20(local\x20naming)'],'always_executed':![]},{'stage':0x8,'name':'return_result','preconditions':['All\x20preceding\x20stages\x20succeeded'],'side_effects':['Returns\x20BuyResult\x20{\x20order,\x20allocation?,\x20progress?\x20}','Caller\x20proceeds\x20to\x20sign\x20+\x20submit\x20transaction'],'always_executed':!![]}];export const SERVICE_CROSS_OBJECT_BINDINGS=[{'object':'Machine','field':'machine','required':![],'locked_after_publish':!![],'notes':'Workflow\x20template;\x20post-publish\x20immutable\x20(F-S-20).\x20Progress.machine\x20inherits\x20this\x20value.'},{'object':'Guard','field':'buy_guard','required':![],'locked_after_publish':![],'notes':'Buyer\x20eligibility\x20guard;\x20post-publish\x20STILL\x20MUTABLE\x20(unusual\x20—\x20see\x20F-S-26)'},{'object':'Allocation','field':'order_allocators','required':!![],'locked_after_publish':!![],'notes':'Order\x20fund\x20distribution\x20strategy;\x20publish\x20prerequisite\x20(F-S-18).\x20Post-publish\x20immutable\x20(F-S-22).'},{'object':'Arbitration','field':'arbitrations','required':![],'locked_after_publish':![],'notes':'Dispute\x20handlers;\x20required\x20if\x20compensation_fund\x20>\x200\x20(F-S-19).\x20add\x20always\x20mutable;\x20remove/clear\x20time-locked\x20after\x20publish\x20(F-S-21).'},{'object':'Repository','field':'repositories','required':![],'locked_after_publish':![],'notes':'Shared\x20data\x20stores;\x20mutable\x20post-publish'},{'object':'Reward','field':'rewards','required':![],'locked_after_publish':![],'notes':'Marketing\x20incentives\x20+\x20experience-compensation\x20pools\x20(C-11);\x20add\x20always\x20mutable;\x20remove/clear\x20time-locked\x20after\x20publish\x20(F-S-24).\x20BUYER\x20DUE-DILIGENCE\x20(hard\x20rule,\x20see\x20SERVICE_REWARDS_BUYER_DD\x20below):\x20a\x20pre-order\x20service\x20analysis\x20MUST\x20read\x20this\x20edge\x20and\x20present\x20the\x20compensation\x20promise\x20—\x20funded\x20pool\x20=\x20trust\x20signal,\x20absent\x20edge\x20=\x20no\x20compensation\x20promise;\x20never\x20silently\x20omit\x20either\x20conclusion'},{'object':'Contact','field':'um','required':![],'locked_after_publish':![],'notes':'User\x20Manager\x20(Contact\x20object);\x20mutable\x20post-publish'},{'object':'Treasury','field':'(indirect\x20via\x20order_allocators.sharing.who=Entity)','required':![],'locked_after_publish':![],'notes':'Treasury\x20is\x20referenced\x20by\x20Allocation.sharing.who,\x20not\x20by\x20Service\x20directly'}];export const SERVICE_REWARDS_BUYER_DD='Pre-order\x20service\x20analysis\x20MUST\x20read\x20Service.rewards\x20(the\x20object-graph\x20rewards[]\x20edge)\x20and\x20present\x20the\x20experience-compensation\x20'+'commitment\x20—\x20per\x20referenced\x20Reward:\x20recipient\x20(Signer\x20=\x20the\x20claimer\x20gets\x20paid),\x20amount\x20(Fixed\x20tier\x20or\x20submission-computed;\x20'+'submission-computed\x20amounts\x20are\x20not\x20clamped\x20on-chain,\x20disclose\x20the\x20rule),\x20balance\x20(funded\x20pool\x20=\x20trust\x20signal),\x20and\x20claim\x20'+'window.\x20An\x20empty\x20rewards[]\x20edge\x20means\x20NO\x20compensation\x20promise.\x20Both\x20conclusions\x20must\x20be\x20presented\x20explicitly\x20—\x20never\x20'+'silently\x20omit\x20the\x20rewards\x20edge\x20from\x20a\x20service\x20analysis.';export const SUBSERVICE_ACCOUNT_ALIGNMENT='First\x20service\x20provider\x20bears\x20overall\x20responsibility:\x20a\x20sub-service\x20failure\x20(e.g.\x20courier)\x20is\x20the\x20MAIN\x20provider\x27s\x20liability\x20to\x20'+'its\x20buyer.\x20The\x20main\x20provider\x20may\x20self-fund\x20an\x20experience-compensation\x20Reward\x20for\x20that\x20failure\x20(reward-ledger\x20scenes\x20'+'reward_delay_compensation\x20/\x20reward_experience_compensation)\x20—\x20the\x20buyer-facing\x20promise\x20and\x20the\x20supplier\x20recourse\x20are\x20SEPARATE\x20'+'ledgers:\x20a\x20Reward\x20claim\x20pays\x20the\x20buyer\x20from\x20the\x20merchant\x27s\x20own\x20pool\x20and\x20never\x20transfers\x20supplier\x20liability;\x20recourse\x20against\x20'+'the\x20supplier\x20is\x20a\x20distinct\x20(off-chain\x20or\x20separate\x20on-chain)\x20arrangement,\x20and\x20Reward\x20outflows\x20are\x20one-way\x20(no\x20clawback).\x20When\x20'+'selecting\x20suppliers,\x20require\x20payment\x20terms\x20aligned\x20with\x20the\x20account\x20cycle\x20—\x20periodic\x20/\x20offline\x20/\x20real-time\x20settlement\x20matched\x20'+'to\x20the\x20sub-order\x20settlement\x20cadence\x20—\x20so\x20the\x20compensation\x20pool\x27s\x20refill\x20schedule\x20tracks\x20actual\x20sub-order\x20liabilities.';export const SERVICE_SCENES=[{'id':'service_retail','name':'Retail\x20e-commerce\x20Service','category':'retail','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description','set\x20the\x20location/URL','set\x20customer\x20required\x20info\x20fields'],'permission_index_operations':['publish\x20the\x20Service\x20(311)','pause/resume\x20the\x20Service\x20(310)','add/set/remove/clear\x20sales\x20items\x20(305)','set\x20the\x20order_allocators\x20strategy\x20(313)','set/clear\x20the\x20buy_guard\x20check\x20(307)','issue/destroy\x20discount\x20coupons\x20(312)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set\x20(F-S-18,\x20E_NO_ALLOCATOR)','If\x20compensation_fund\x20>\x200,\x20arbitrations\x20must\x20be\x20non-empty\x20(F-S-19)'],'common_patterns':['Multi-tier\x20pricing\x20via\x20sales[]\x20(Standard/Premium/Enterprise)','WIP\x20hash\x20per\x20sale\x20item\x20for\x20tamper-proof\x20product\x20info','buy_guard\x20for\x20KYC\x20whitelist\x20during\x20pre-sale,\x20then\x20null\x20for\x20public\x20sale','compensation_fund\x20deposited\x20before\x20publish\x20+\x20arbitrations\x20configured'],'recommended_templates':['T-S-01','T-S-06']},{'id':'service_rental','name':'Rental\x20Service\x20(short/long-term)','category':'rental','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description','set\x20the\x20location/URL'],'permission_index_operations':['publish\x20the\x20Service\x20(311)','add/set\x20sales\x20items\x20(305)','bind\x20the\x20Machine\x20workflow\x20(306)\x20—\x20for\x20rental\x20workflow','add\x20Arbitration\x20references\x20(308)\x20—\x20for\x20deposit\x20disputes'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set','machine\x20recommended\x20(rental\x20workflow\x20with\x20deposit/return\x20stages)','arbitrations\x20recommended\x20(deposit\x20refund\x20disputes)'],'common_patterns':['Machine\x20workflow\x20with\x20\x27Deposit\x20→\x20Use\x20→\x20Return\x20→\x20Refund\x27\x20nodes','compensation_fund\x20holds\x20deposit\x20guarantees','buy_guard\x20verifies\x20renter\x20identity/KYC','stock=1\x20per\x20rental\x20item\x20(unique\x20items)'],'recommended_templates':['T-S-02','T-S-04']},{'id':'service_subscription','name':'Subscription\x20Service\x20(recurring)','category':'subscription','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description','set\x20the\x20location/URL'],'permission_index_operations':['publish\x20the\x20Service\x20(311)','add/set\x20sales\x20items\x20(305)','issue\x20discount\x20coupons\x20(312)\x20—\x20promotional\x20rates','add\x20Reward\x20references\x20(318)\x20—\x20loyalty\x20rewards'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Tiered\x20plans\x20(Free/Pro/Enterprise)\x20as\x20sales[]','Discount\x20coupons\x20for\x20trial\x20periods','Rewards\x20for\x20long-term\x20subscribers','Renewal\x20handled\x20by\x20repeat\x20orders\x20(no\x20native\x20recurring\x20billing)'],'recommended_templates':['T-S-03']},{'id':'service_workflow','name':'Workflow-bound\x20Service\x20(machine-bound)','category':'workflow','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description','set\x20the\x20location/URL'],'permission_index_operations':['bind\x20the\x20Machine\x20workflow\x20(306)','publish\x20the\x20Service\x20(311)','set\x20the\x20order_allocators\x20strategy\x20(313)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set','machine\x20must\x20be\x20published\x20before\x20binding','machine\x20recommended\x20for\x20any\x20multi-stage\x20service\x20delivery'],'common_patterns':['Machine\x20defines\x20Pay\x20→\x20Confirm\x20→\x20Deliver\x20→\x20Sign-off\x20nodes','Progress\x20created\x20per\x20order\x20(stage\x206\x20of\x20buy\x20flow)','Named\x20operators\x20assigned\x20per\x20Forward\x20in\x20Machine','Service.paused\x20does\x20NOT\x20affect\x20already-created\x20Progress\x20(existing\x20orders\x20continue)'],'recommended_templates':['T-S-04']},{'id':'service_arbitration','name':'Arbitration-bound\x20Service\x20(dispute-ready)','category':'arbitration','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description'],'permission_index_operations':['add\x20Arbitration\x20references\x20(308)','deposit\x20to\x20the\x20compensation_fund\x20(315)','extend\x20setting_lock_duration\x20(317)','publish\x20the\x20Service\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['If\x20compensation_fund\x20>\x200,\x20arbitrations\x20must\x20be\x20non-empty\x20(F-S-19)','Arbitration\x20objects\x20must\x20be\x20created\x20before\x20binding','compensation_fund_add\x20before\x20publish\x20recommended\x20(else\x20post-publish\x20deposit\x20still\x20possible)'],'common_patterns':['2-3\x20Arbitration\x20objects\x20(different\x20arb\x20committees\x20for\x20different\x20dispute\x20types)','compensation_fund\x20deposited\x20as\x20%\x20of\x20expected\x20order\x20volume','setting_lock_duration\x20extended\x20by\x20owner\x20to\x20build\x20customer\x20trust','Arbitration\x20compensation\x20payout\x20triggered\x20by\x20the\x20arbitration\x20result\x20(not\x20by\x20Service\x20directly)'],'recommended_templates':['T-S-05','T-S-06']},{'id':'service_compensation_fund','name':'Compensation\x20Fund\x20Service\x20(embedded\x20balance)','category':'compensation_fund','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description'],'permission_index_operations':['deposit\x20to\x20the\x20compensation_fund\x20(315)','withdraw\x20from\x20the\x20compensation_fund\x20(314)\x20—\x20time-locked\x20after\x20publish','receive\x20the\x20compensation_fund\x20payout\x20(316)\x20—\x20arbitration\x20payout\x20(always\x20mutable)','extend\x20setting_lock_duration\x20(317)\x20—\x20extend\x20lock'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['compensation_fund\x20>\x200\x20→\x20arbitrations\x20non-empty\x20(F-S-19)','compensation_fund\x20coin\x20type\x20must\x20match\x20Service<T>\x20type\x20parameter'],'common_patterns':['Fund\x20inflow:\x20compensation_fund_add\x20(315)\x20—\x20always\x20mutable','Fund\x20outflow:\x20compensation_fund_withdraw\x20(314)\x20—\x20requires\x20bPaused\x20+\x20lock_duration\x20expired','Fund\x20receive:\x20compensation_fund_receive\x20(316)\x20—\x20arbitration\x20payout,\x20always\x20mutable','Fund\x20consumer:\x20arbitration\x20compensation\x20payout\x20(driven\x20by\x20arb\x20result)','Distinct\x20from\x20Treasury:\x20Service-internal,\x20arbitration-bound,\x20lock-protected'],'recommended_templates':['T-S-06']},{'id':'service_reward','name':'Reward-attached\x20Service\x20(marketing)','category':'reward','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description'],'permission_index_operations':['add/remove/clear\x20Reward\x20references\x20(318)\x20—\x20add\x20always\x20mutable;\x20remove/clear\x20time-locked\x20after\x20publish','issue/destroy\x20discount\x20coupons\x20(312)','publish\x20the\x20Service\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Rewards\x20added\x20post-publish\x20(always\x20allowed;\x20remove/clear\x20is\x20time-locked\x20after\x20publish)','Reward\x20objects\x20must\x20exist\x20before\x20binding\x20(queryObjectsWithType\x20validation)','MAX_REWARD_COUNT\x20=\x2020\x20per\x20Service','Reward\x20remove/clear\x20requires\x20Service\x20paused\x20+\x20setting_lock_duration\x20elapsed\x20(protects\x20customer\x20expectations)'],'recommended_templates':['T-S-08']},{'id':'service_arbitration_binding','name':'Arbitration\x20Binding\x20Service\x20(post-publish\x20immutable)','category':'arbitration','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description'],'permission_index_operations':['add\x20Arbitration\x20references\x20(308)\x20—\x20pre-publish\x20only','remove\x20an\x20Arbitration\x20reference\x20(308)\x20—\x20pre-publish\x20only','clear\x20Arbitration\x20references\x20(308)\x20—\x20pre-publish\x20only','publish\x20the\x20Service\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['MAX_ARBITRATION_COUNT\x20=\x2020\x20per\x20Service\x20(F-S-04)','Each\x20Arbitration\x20object\x20must\x20be\x20valid\x20(queryObjectsWithType\x20validation)','Arbitration\x20bound\x20=\x20locked\x20post-publish\x20(F-S-21).\x20To\x20change:\x20create\x20new\x20Service.'],'common_patterns':['Pre-publish:\x20set\x201-3\x20Arbitration\x20objects\x20for\x20different\x20dispute\x20scopes','Post-publish:\x20immutable\x20—\x20clone\x20Service\x20if\x20change\x20needed','⚠️\x20Data\x20inconsistency:\x20the\x20dynamic-pricing\x20metadata\x20marks\x20arbitrations\x20as\x20mutable,\x20but\x20the\x20SDK\x20blocks\x20it\x20(F-S-21)'],'recommended_templates':['T-S-05']},{'id':'service_buy_guard','name':'Buy\x20Guard\x20Service\x20(post-publish\x20mutable\x20guard)','category':'buy_guard','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description'],'permission_index_operations':['bind\x20the\x20buy_guard\x20Guard\x20(307)','clear\x20the\x20buy_guard\x20Guard\x20(307)','publish\x20the\x20Service\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Pre-sale\x20phase:\x20buy_guard\x20=\x20whitelist\x20Guard\x20(KYC\x20verified\x20buyers\x20only)','Public\x20sale:\x20buy_guard\x20=\x20null\x20(anyone\x20can\x20buy)','Restricted\x20phase:\x20buy_guard\x20=\x20KYC\x20Guard\x20(compliance)','⚠️\x20buy_guard\x20is\x20the\x20ONLY\x20publish-locked-field\x20exception\x20—\x20still\x20mutable\x20post-publish','buy_guard\x20verification\x20happens\x20at\x20Stage\x201\x20of\x20buy\x20flow\x20(pre_check)'],'recommended_templates':['T-S-01']},{'id':'service_order_allocator','name':'Order\x20Allocator\x20Service\x20(fund\x20distribution\x20config)','category':'order_allocator','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description'],'permission_index_operations':['set\x20the\x20order_allocators\x20strategy\x20(313)\x20—\x20pre-publish\x20only','publish\x20the\x20Service\x20(311)\x20—\x20requires\x20order_allocators\x20(F-S-18)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20MUST\x20be\x20set\x20(F-S-18,\x20E_NO_ALLOCATOR)','Allocators.sharing.who\x20can\x20reference\x20Treasury\x20addresses\x20(indirect\x20Treasury\x20binding)','MAX_SHARING_COUNT\x20=\x20100\x20per\x20allocator'],'common_patterns':['Multi-party\x20split:\x20merchant\x2080%\x20/\x20platform\x2010%\x20/\x20logistics\x2010%','Threshold-based:\x20different\x20allocators\x20for\x20different\x20order\x20sizes','Guard-bound\x20allocator:\x20allocation\x20execution\x20requires\x20Guard\x20verification','Post-publish\x20immutable\x20—\x20clone\x20Service\x20to\x20change\x20allocation\x20strategy'],'recommended_templates':['T-S-08']},{'id':'service_dynamic_pricing','name':'Dynamic\x20Pricing\x20Service\x20(discount-driven)','category':'dynamic_pricing','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description'],'permission_index_operations':['issue\x20discount\x20coupons\x20(312)','add/set\x20sales\x20items\x20(305)\x20—\x20adjust\x20base\x20prices','remove\x20sales\x20items\x20(305)\x20—\x20remove\x20deprecated\x20SKUs'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Discount\x20types:\x200=rates\x20(basis\x20points,\x20per\x2010000),\x201=minus\x20(direct\x20deduction)','MAX_DISCOUNT_COUNT_ONCE\x20=\x201000\x20per\x20issue\x20call','MAX_DISCOUNT_RECEIVER_ONCE\x20=\x201000\x20receivers\x20per\x20call','MAX_DISCOUNT_TOTAL_COUNT\x20=\x2020000\x20total\x20coupons','discount_destroy:\x20holder-only\x20(no\x20SERVICE_DISCOUNT\x20permission\x20needed)','discount_send:\x20holder-only\x20transfer\x20of\x20owned\x20transferable:true\x20coupons\x20to\x20another\x20address\x20(no\x20permission\x20needed);\x20KB-02\x20semantics:\x20issuance\x20=\x20discount\x20(mint)\x20then\x20discount_send\x20(transfer)\x20—\x20holding\x20IS\x20the\x20credential\x20(only\x20the\x20holder\x27s\x20signature\x20spends\x20it),\x20one\x20coupon\x20one\x20burn\x20(single-use,\x20transfer\x20does\x20not\x20reset\x20it),\x20refunds\x20settle\x20the\x20post-coupon\x20amount\x20only;\x20a\x20coupon\x20held\x20by\x20another\x20address\x20cannot\x20be\x20applied\x20to\x20a\x20buy\x20—\x20have\x20the\x20owner\x20discount_send\x20it\x20to\x20the\x20buyer\x20first'],'recommended_templates':['T-S-07']},{'id':'service_multi_allocator','name':'Multi-Allocator\x20Service\x20(tiered\x20fund\x20distribution)','category':'multi_allocator','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description'],'permission_index_operations':['set\x20the\x20order_allocators\x20strategy\x20(313)\x20—\x20pre-publish\x20only','publish\x20the\x20Service\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20MUST\x20be\x20set','Each\x20allocator\x20has\x20its\x20own\x20Guard\x20+\x20sharing\x20+\x20threshold','Each\x20allocator\x20is\x20bound\x20to\x20a\x20DIFFERENT\x20guard\x20—\x20the\x20caller\x27s\x20submitted\x20guard\x20selects\x20which\x20path\x20fires'],'common_patterns':['Tier\x201\x20(small\x20orders):\x20single-recipient\x20allocator\x20(low\x20fee)','Tier\x202\x20(medium\x20orders):\x20two-recipient\x20split\x20(merchant\x20+\x20platform)','Tier\x203\x20(large\x20orders):\x20three-recipient\x20split\x20(merchant\x20+\x20platform\x20+\x20logistics)','Each\x20tier\x20can\x20have\x20its\x20own\x20Guard\x20for\x20execution\x20authorization'],'recommended_templates':['T-S-08']}];export const SERVICE_LEDGER_VERSION='1.1.0';export function getScenesByCategory(a){return SERVICE_SCENES['filter'](b=>b['category']===a);}export function findSceneById(a){return SERVICE_SCENES['find'](b=>b['id']===a);}export function getServicePermissionByIndex(a){return SERVICE_PERMISSIONS['find'](b=>b['index']===a);}export function isServicePermission(a){return getServicePermissionByIndex(a)!==undefined;}export function getPermissionsByMutability(a){return SERVICE_PERMISSIONS['filter'](b=>b['post_publish_mutability']===a);}export function getImmutablePostPublishPermissions(){return SERVICE_PERMISSIONS['filter'](a=>a['post_publish_mutability']==='immutable'||a['post_publish_mutability']==='one_shot');}export function getLockedByDurationPermissions(){return SERVICE_PERMISSIONS['filter'](a=>a['post_publish_mutability']==='locked_by_duration');}export function inferSceneFromIntent(a){const b=a['toLowerCase'](),c=[['retail','retail'],['ecommerce','retail'],['rental','rental'],['rent','rental'],['short-term\x20rental','rental'],['long-term\x20rental','rental'],['subscription','subscription'],['subscribe','subscription'],['workflow','workflow'],['machine-bound','workflow'],['arbitration','arbitration'],['dispute','arbitration'],['compensation','compensation_fund'],['compensation_fund','compensation_fund'],['reward','reward'],['marketing','reward'],['buy_guard','buy_guard'],['kyc','buy_guard'],['whitelist','buy_guard'],['allocator','order_allocator'],['discount','dynamic_pricing'],['coupon','dynamic_pricing'],['multi-allocator','multi_allocator'],['tiered','multi_allocator']];for(const [d,e]of c){if(b['includes'](d)){const f=getScenesByCategory(e);if(f['length']>0x0)return f[0x0];}}if(b['includes']('service'))return findSceneById('service_retail');return undefined;}export function getAllServiceScenes(){return[...SERVICE_SCENES];}export function getServiceScenesCount(){return SERVICE_SCENES['length'];}export function getServicePermissionsCount(){return SERVICE_PERMISSIONS['length'];}export function getOrderFlowStage(a){return SERVICE_ORDER_FLOW_STAGES['find'](b=>b['stage']===a);}export function getCrossObjectBindings(){return[...SERVICE_CROSS_OBJECT_BINDINGS];}
|
|
@@ -25,9 +25,9 @@ export declare const TemplateFrontmatterSchema: z.ZodObject<{
|
|
|
25
25
|
named_operator: z.ZodOptional<z.ZodString>;
|
|
26
26
|
semantic_role: z.ZodOptional<z.ZodEnum<{
|
|
27
27
|
active: "active";
|
|
28
|
+
final: "final";
|
|
28
29
|
draft: "draft";
|
|
29
30
|
delivered: "delivered";
|
|
30
|
-
final: "final";
|
|
31
31
|
cancelled: "cancelled";
|
|
32
32
|
}>>;
|
|
33
33
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -96,6 +96,7 @@ export declare const TemplateFrontmatterSchema: z.ZodObject<{
|
|
|
96
96
|
amount: "amount";
|
|
97
97
|
surplus: "surplus";
|
|
98
98
|
rate: "rate";
|
|
99
|
+
formula: "formula";
|
|
99
100
|
}>;
|
|
100
101
|
value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
101
102
|
value_from: z.ZodOptional<z.ZodString>;
|
|
@@ -104,6 +105,13 @@ export declare const TemplateFrontmatterSchema: z.ZodObject<{
|
|
|
104
105
|
fix: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
105
106
|
fix_from: z.ZodOptional<z.ZodString>;
|
|
106
107
|
guard_key: z.ZodOptional<z.ZodString>;
|
|
108
|
+
formula: z.ZodOptional<z.ZodObject<{
|
|
109
|
+
selector: z.ZodNumber;
|
|
110
|
+
repo: z.ZodOptional<z.ZodString>;
|
|
111
|
+
key: z.ZodOptional<z.ZodString>;
|
|
112
|
+
predicate: z.ZodOptional<z.ZodUnknown>;
|
|
113
|
+
ids: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
114
|
+
}, z.core.$strict>>;
|
|
107
115
|
note: z.ZodOptional<z.ZodString>;
|
|
108
116
|
}, z.core.$strict>>>;
|
|
109
117
|
description: z.ZodString;
|
|
@@ -194,6 +202,10 @@ export declare const TemplateFrontmatterSchema: z.ZodObject<{
|
|
|
194
202
|
none: "none";
|
|
195
203
|
review_reward: "review_reward";
|
|
196
204
|
}>>;
|
|
205
|
+
experience_compensation_mode: z.ZodOptional<z.ZodEnum<{
|
|
206
|
+
reward: "reward";
|
|
207
|
+
none: "none";
|
|
208
|
+
}>>;
|
|
197
209
|
after_sales_mode: z.ZodOptional<z.ZodEnum<{
|
|
198
210
|
none: "none";
|
|
199
211
|
return: "return";
|
|
@@ -258,7 +270,7 @@ export declare function canonicalTemplateContent(t: ArchetypeTemplate): string;
|
|
|
258
270
|
export declare function renderTemplateFile(t: ArchetypeTemplate): string;
|
|
259
271
|
export declare function templateCatalogDigest(id: string): string | undefined;
|
|
260
272
|
export declare const TEMPLATE_KNOBS_SENTINEL_KIND = "template-knobs";
|
|
261
|
-
export declare const TEMPLATE_KNOBS_VERSION =
|
|
273
|
+
export declare const TEMPLATE_KNOBS_VERSION = 5;
|
|
262
274
|
export declare const TemplateKnobOverlaySchema: z.ZodObject<{
|
|
263
275
|
review_mode: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
|
|
264
276
|
review: "review";
|
|
@@ -295,6 +307,10 @@ export declare const TemplateKnobOverlaySchema: z.ZodObject<{
|
|
|
295
307
|
min_claim_interval_ms: z.ZodOptional<z.ZodNumber>;
|
|
296
308
|
max_total_per_recipient: z.ZodOptional<z.ZodString>;
|
|
297
309
|
}, z.core.$strip>>>;
|
|
310
|
+
experience_compensation_mode: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
|
|
311
|
+
reward: "reward";
|
|
312
|
+
none: "none";
|
|
313
|
+
}>>>;
|
|
298
314
|
after_sales_mode: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
|
|
299
315
|
none: "none";
|
|
300
316
|
return: "return";
|
|
@@ -375,6 +391,29 @@ export declare function builtinTemplateDrift(options?: {
|
|
|
375
391
|
detail: string;
|
|
376
392
|
knob_state?: "current" | "user_modified" | "missing";
|
|
377
393
|
}>;
|
|
394
|
+
export interface TemplateTruthStamps {
|
|
395
|
+
template: string;
|
|
396
|
+
source: "builtin" | "user";
|
|
397
|
+
schema_version?: number;
|
|
398
|
+
content_sha256: string;
|
|
399
|
+
machine_layer: {
|
|
400
|
+
path: string;
|
|
401
|
+
sentinel: {
|
|
402
|
+
version: number;
|
|
403
|
+
hash: string;
|
|
404
|
+
} | null;
|
|
405
|
+
sentinel_binds_body: boolean;
|
|
406
|
+
matches_catalog: boolean;
|
|
407
|
+
} | null;
|
|
408
|
+
knob_layer: {
|
|
409
|
+
path: string;
|
|
410
|
+
state: "current" | "outdated" | "user_modified" | "missing" | "invalid";
|
|
411
|
+
override_keys: string[];
|
|
412
|
+
} | null;
|
|
413
|
+
consistency: "verified" | "drifted" | "user_template";
|
|
414
|
+
differences?: string;
|
|
415
|
+
}
|
|
416
|
+
export declare function templateTruthStamps(id: string): TemplateTruthStamps;
|
|
378
417
|
export declare function reloadTemplates(): void;
|
|
379
418
|
export declare function loadAndValidate(file: string): IndustryTemplate;
|
|
380
419
|
export declare function listTemplates(): {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{copyFileSync,existsSync,mkdirSync,readdirSync,readFileSync,rmSync,statSync,writeFileSync}from'node:fs';import{dirname,join,relative,sep}from'node:path';import{z}from'zod';import{getWowokIndustryDir}from'@wowok/wowok';import{SUPPORTED_INDUSTRIES}from'../customer/user-preferences.js';import{isRegisteredIndustry}from'./industry-registry.js';import{BUILTIN_TEMPLATES,BUILTIN_TEMPLATES_VERSION}from'./builtin-templates.js';import{knobDocLines}from'./knob-docs.js';import{MachineProseEnvelopeSchema}from'./template-prose.js';import{INDUSTRY_NAV_FILENAME,classifyIndustryNav,renderIndustryNav,wrapBullet,wrapParagraph}from'./template-nav.js';import{classifyRelease,releaseBodyHash,releaseSentinelLine,stripReleaseSentinel}from'./release-sentinel.js';export const TEMPLATES_SUBDIR='templates';export const MACHINE_TEMPLATES_SUBDIR='.machine';export const TEMPLATE_ARCHIVE_SUBDIR='.archive';export function resolveTemplatesDir(){return process['env']['WOWOK_TEMPLATES_DIR']||getWowokIndustryDir();}const MachineEdgeSchema=z['object']({'prev':z['string'](),'forward':z['string']()['min'](0x1)['optional'](),'operator':z['enum'](['merchant','order_payer'])['optional'](),'named_operator':z['string']()['min'](0x1)['optional'](),'permission_index':z['number']()['int']()['min'](0x3e8)['optional'](),'guard_key':z['string']()['min'](0x1)['optional']()}),MachineNodeSchema=z['object']({'name':z['string']()['min'](0x1),'role':z['string']()['min'](0x1),'operator':z['enum'](['merchant','order_payer'])['optional'](),'named_operator':z['string']()['min'](0x1)['optional'](),'semantic_role':z['enum'](['draft','active','delivered','final','cancelled'])['optional'](),'optional':z['boolean']()['optional'](),'threshold':z['number']()['int']()['min'](0x0)['optional'](),'from':z['array'](z['union']([z['string'](),MachineEdgeSchema]))['optional']()}),GuardRefSchema=z['object']({'template_id':z['string']()['regex'](/^(pattern\.[a-z0-9_]+|tpl_[a-z0-9_]+)$/,'guard\x20template_id\x20must\x20be\x20a\x20\x27pattern.*\x27\x20design\x20pattern\x20or\x20\x27tpl_*\x27\x20guard\x20template'),'host':z['enum'](['service','machine','reward','repository','arbitration']),'purpose':z['string']()['min'](0x1),'key':z['string']()['min'](0x1),'policy':z['object']({'name':z['string']()['min'](0x1)['optional'](),'description':z['string']()['min'](0x1)['optional'](),'id_from':z['string']()['min'](0x1)['optional'](),'value_type':z['string']()['min'](0x1)['optional']()})['optional'](),'params':z['record'](z['string'](),z['unknown']())['optional'](),'identity_leg_exempt':z['string']()['min'](0x1)['optional']()}),ConditionalGuardEmissionSchema=z['object']({'guard_key':z['string']()['min'](0x1),'param':z['string']()['min'](0x1),'values':z['array'](z['string']()['min'](0x1))['min'](0x2),'emit_value':z['string']()['min'](0x1),'question':z['string']()['min'](0x1)})['strict'](),AllocatorRowSchema=z['object']({'track':z['enum'](['settlement','refund']),'recipient':z['enum'](['entity','guard_identifier','signer']),'recipient_key':z['string']()['min'](0x1)['optional'](),'mode':z['enum'](['amount','rate','surplus']),'value':z['union']([z['string'](),z['number']()])['optional'](),'value_from':z['string']()['optional'](),'value_from_complement':z['string']()['min'](0x1)['optional'](),'repeat_from':z['string']()['min'](0x1)['optional'](),'fix':z['union']([z['string'](),z['number']()])['optional'](),'fix_from':z['string']()['optional'](),'guard_key':z['string']()['min'](0x1)['optional'](),'note':z['string']()['optional']()})['strict'](),AllocatorSchema=z['object']({'recipient':z['enum'](['signer','entity','fixed']),'recipient_key':z['string']()['min'](0x1)['optional'](),'refund_track':z['enum'](['order_anchored'])['optional'](),'count':z['number']()['int']()['positive'](),'mode':z['enum'](['amount','rate','surplus']),'once_per_order':z['boolean']()['optional'](),'rows':z['array'](AllocatorRowSchema)['optional'](),'description':z['string']()['min'](0x1)})['strict'](),UserInputSpecSchema=z['object']({'question':z['string']()['min'](0x1),'param_key':z['string']()['min'](0x1),'note':z['string']()['min'](0x1)['optional']()})['strict'](),IndustryNameSchema=z['string']()['regex'](/^[a-z][a-z0-9_]*$/,'industry\x20must\x20be\x20lowercase\x20snake_case\x20(a-z,\x200-9,\x20_)')['refine'](a=>isRegisteredIndustry(a),{'message':'unknown\x20industry\x20—\x20register\x20it\x20first\x20via\x20an\x20industry\x20pack\x20'+'(industry_pack_operation\x20action=\x27scaffold\x27)\x20or\x20the\x20industry\x20generalizer;\x20'+('builtin\x20industries:\x20'+SUPPORTED_INDUSTRIES['join'](',\x20'))});export const TemplateFrontmatterSchema=z['object']({'id':z['string']()['regex'](/^[a-z][a-z0-9_-]*\/[a-z][a-z0-9_-]*$/,'id\x20must\x20be\x20\x27<industry>/<variant>\x27'),'industry':IndustryNameSchema,'variant':z['string']()['regex'](/^[a-z][a-z0-9_-]*$/),'product_ref':z['string']()['regex'](/^[a-z][a-z0-9._-]*$/,'product_ref\x20must\x20be\x20a\x20lowercase\x20product\x20slug')['optional'](),'archetype':z['enum'](['leader','challenger']),'phase':z['number']()['int']()['min'](0x1)['max'](0x3),'machine_shape':z['array'](MachineNodeSchema)['min'](0x1),'guards':z['array'](GuardRefSchema),'allocator':AllocatorSchema,'fee_params':z['record'](z['string'](),z['union']([z['number'](),z['string']()])),'trust_mechanisms':z['array'](z['string']()),'keeper_dependencies':z['array'](z['string']()),'keeper_duty':z['array'](z['object']({'when':z['string']()['min'](0x1),'action':z['string']()['min'](0x1),'miss_consequence':z['string']()['min'](0x1)})['strict']())['optional'](),'recommended_role':z['enum'](['merchant','supplier','both']),'role_rationale':z['string']()['min'](0x1),'differences':z['array'](z['string']()),'user_inputs':z['array'](z['string']()),'user_input_specs':z['array'](UserInputSpecSchema)['optional'](),'key_risk':z['string']()['min'](0x1)['max'](0x12c,'key_risk\x20must\x20be\x20a\x20one-line\x20risk\x20statement\x20(<=\x20300\x20chars)\x20—\x20rules\x20and\x20doctrine\x20do\x20not\x20belong\x20in\x20this\x20field')['refine'](a=>!/STANDING RULE|TECHNOLOGY PROVIDER|NOT A PARTY TO THE DEAL|Full text:/i['test'](a),{'message':'key_risk\x20carries\x20an\x20instruction-block\x20fragment\x20(STANDING\x20RULE\x20/\x20provider\x20doctrine\x20/\x20\x27Full\x20text:\x27\x20reference)\x20—\x20keep\x20doctrine\x20in\x20body\x20prose\x20or\x20playbooks,\x20not\x20in\x20this\x20field'}),'build_notes':z['array'](z['string']()),'prose_language':z['enum'](['en','other'])['optional'](),'machine_prose':z['record'](z['string'](),MachineProseEnvelopeSchema)['optional'](),'evidence_refs':z['array'](z['string']())['optional'](),'conditional_guards':z['array'](ConditionalGuardEmissionSchema)['optional'](),'time_anchors':z['record'](z['string'](),z['string']())['optional'](),'payment_model':z['enum'](['milestone','subscription','escrow'])['optional'](),'arbitration_mode':z['enum'](['none','merchant_pick','mutual_pick','third_party'])['optional'](),'reward_claim_policy':z['object']({'kind':z['enum'](['once','periodic','capped']),'min_claim_interval_ms':z['number']()['optional'](),'max_total_per_recipient':z['string']()['optional']()})['optional'](),'review_mode':z['enum'](['none','review','review_reward'])['optional'](),'after_sales_mode':z['enum'](['none','return','exchange','warranty'])['optional'](),'acceptance_mode':z['enum'](['none','milestone','contest','bounty','agent'])['optional'](),'installment_mode':z['enum'](['none','deposit_balance','milestone_n'])['optional'](),'affiliate_mode':z['enum'](['none','commission'])['optional'](),'crowdfunding_mode':z['enum'](['none','threshold','flexible'])['optional'](),'logistics_mode':z['enum'](['none','carrier','merchant_managed','courier','pickup_point'])['optional'](),'compensation_fund_policy':z['enum'](['allowed','forbidden'])['optional'](),'reentry_kind':z['enum'](['none','review-loop','paid-cycle'])['optional'](),'settlement_window_merge':z['array'](z['string']())['optional']()})['strict']();export function userInputSpecIssues(a){if(a['user_input_specs']===undefined)return[];const b=[],c=new Set();for(const [d,e]of a['user_input_specs']['entries']()){!(e['param_key']in a['fee_params'])&&b['push']('user_input_specs['+d+'].param_key\x20\x27'+e['param_key']+'\x27\x20is\x20not\x20a\x20declared\x20fee_param\x20—\x20declare\x20it\x20in\x20fee_params\x20(the\x20question\x20fills\x20it)\x20or\x20fix\x20the\x20key'),c['has'](e['param_key'])&&b['push']('user_input_specs['+d+']\x20asks\x20about\x20\x27'+e['param_key']+'\x27\x20twice\x20—\x20one\x20question\x20per\x20parameter'),c['add'](e['param_key']);}return b;}import{validateAllocatorRows}from'./template-validation.js';export{validateAllocatorRows};export function platformShareBps(a){const b=Object['keys'](a)['find'](c=>/(?:platform|commission|service_fee)[a-z_]*_bps$/['test'](c)&&!/^attributed_/['test'](c)&&!/_cap_bps$/['test'](c)&&typeof a[c]==='number');return b!==undefined?a[b]:undefined;}export const PLATFORM_TAKE_KEY=/^(?:platform_(?:share|commission|take|tool_fee)_bps|platform_fee_rate_bps|commission_rate_bps|(?:base_)?commission_rate_bps|offsite_ads_rate_bps|service_fee_rate_bps|payment_fee_bps)$/;export function parseTemplateFile(a){const b=a['replace'](/^\uFEFF/,'')['replace'](/^<!-- builtin:[a-z0-9-]+:v\d+:[0-9a-f]+ -->\r?\n/,''),c=b['split'](/\r?\n/);if(c[0x0]?.['trim']()!=='---')throw new Error('template\x20must\x20start\x20with\x20a\x20\x27---\x27\x20frontmatter\x20block');let d=-0x1;for(let f=0x1;f<c['length'];f++){if(c[f]['trim']()==='---'){d=f;break;}}if(d===-0x1)throw new Error('unterminated\x20frontmatter\x20block\x20(missing\x20closing\x20\x27---\x27)');const e={};for(let g=0x1;g<d;g++){const h=c[g];if(!h['trim']()||h['trim']()['startsWith']('#'))continue;const j=h['indexOf'](':');if(j===-0x1)throw new Error('invalid\x20frontmatter\x20line\x20'+(g+0x1)+':\x20\x27'+h['trim']()+'\x27\x20(expected\x20\x27key:\x20value\x27)');const k=h['slice'](0x0,j)['trim'](),l=h['slice'](j+0x1)['trim']();if(!k)throw new Error('invalid\x20frontmatter\x20line\x20'+(g+0x1)+':\x20empty\x20key');if(l['startsWith']('[')||l['startsWith']('{'))try{e[k]=JSON['parse'](l);}catch(m){throw new Error('frontmatter\x20key\x20\x27'+k+'\x27\x20is\x20not\x20valid\x20JSON:\x20'+m['message']);}else{if(/^-?\d+(\.\d+)?$/['test'](l))e[k]=Number(l);else{if(l['startsWith']('\x22')&&l['endsWith']('\x22')&&l['length']>=0x2||l['startsWith']('\x27')&&l['endsWith']('\x27')&&l['length']>=0x2){if(l[0x0]==='\x22')try{e[k]=JSON['parse'](l);}catch(n){throw new Error('frontmatter\x20key\x20\x27'+k+'\x27\x20is\x20not\x20valid\x20JSON:\x20'+n['message']);}else e[k]=l['slice'](0x1,-0x1);}else e[k]=l;}}}return{'frontmatter':e,'body':c['slice'](d+0x1)['join']('\x0a')['trim']()};}function frontmatterLine(a,b){if(typeof b==='number')return a+':\x20'+b;if(typeof b==='string')return a+':\x20'+b;return a+':\x20'+JSON['stringify'](b);}export const TEMPLATE_SENTINEL_KIND='industry-template';export function canonicalTemplateContent(a){const b=a,c=[['id',a['id']],['industry',a['industry']],['variant',a['variant']],['product_ref',a['product_ref']],['archetype',a['archetype']],['phase',a['phase']],['recommended_role',a['recommended_role']],['role_rationale',a['role_rationale']],['key_risk',a['key_risk']],['machine_shape',a['machine_shape']],['guards',a['guards']],['allocator',a['allocator']],['fee_params',a['fee_params']],['trust_mechanisms',a['trust_mechanisms']],['keeper_dependencies',a['keeper_dependencies']],...a['keeper_duty']?[['keeper_duty',a['keeper_duty']]]:[],['differences',a['differences']],['user_inputs',a['user_inputs']],...a['user_input_specs']?[['user_input_specs',a['user_input_specs']]]:[],['build_notes',a['build_notes']],...b['prose_language']?[['prose_language',b['prose_language']]]:[],...b['machine_prose']?[['machine_prose',b['machine_prose']]]:[],...a['evidence_refs']?[['evidence_refs',a['evidence_refs']]]:[],...a['conditional_guards']?[['conditional_guards',a['conditional_guards']]]:[],...a['time_anchors']?[['time_anchors',a['time_anchors']]]:[],...a['payment_model']?[['payment_model',a['payment_model']]]:[],...a['arbitration_mode']?[['arbitration_mode',a['arbitration_mode']]]:[],...a['review_mode']?[['review_mode',a['review_mode']]]:[],...a['after_sales_mode']?[['after_sales_mode',a['after_sales_mode']]]:[],...a['acceptance_mode']?[['acceptance_mode',a['acceptance_mode']]]:[],...a['installment_mode']?[['installment_mode',a['installment_mode']]]:[],...a['affiliate_mode']?[['affiliate_mode',a['affiliate_mode']]]:[],...a['crowdfunding_mode']?[['crowdfunding_mode',a['crowdfunding_mode']]]:[],...a['logistics_mode']?[['logistics_mode',a['logistics_mode']]]:[],...a['reward_claim_policy']?[['reward_claim_policy',a['reward_claim_policy']]]:[],...a['compensation_fund_policy']?[['compensation_fund_policy',a['compensation_fund_policy']]]:[],...a['reentry_kind']&&a['reentry_kind']!=='none'?[['reentry_kind',a['reentry_kind']]]:[],...a['settlement_window_merge']?[['settlement_window_merge',a['settlement_window_merge']]]:[]],d=['---',...c['map'](([f,g])=>frontmatterLine(f,g)),'---'],e=['','#\x20'+a['industry']+'\x20/\x20'+a['variant']+'\x20('+a['archetype']+')','','>\x20Industry\x20archetype\x20template.\x20Editable\x20and\x20migratable:\x20the\x20frontmatter\x20is','>\x20zod-validated\x20on\x20every\x20load;\x20the\x20body\x20is\x20free-form\x20guidance\x20for\x20the\x20AI.','','##\x20Key\x20risk','',a['key_risk'],'','##\x20Differences\x20vs\x20the\x20sibling\x20variant','',...a['differences']['map'](f=>'-\x20'+f),'','##\x20Build-time\x20inputs\x20&\x20standing\x20constraints\x20(non-parameter)','',...a['user_inputs']['map'](f=>'-\x20'+f),...a['user_input_specs']&&a['user_input_specs']['length']>0x0?['','##\x20Structured\x20business\x20questions\x20(answer\x20rides\x20fee_overrides)','',...a['user_input_specs']['map'](f=>'-\x20\x22'+f['question']+'\x22\x20→\x20fee_overrides.'+f['param_key']+(f['note']?'\x20—\x20'+f['note']:''))]:[],'','##\x20Risk-avoidance\x20checklist\x20(R1-R10)','',...a['trust_mechanisms']['map'](f=>'-\x20'+f),'','##\x20Build\x20notes','',...a['build_notes']['map'](f=>'-\x20'+f),''];return[...d,...e]['join']('\x0a');}export function renderTemplateFile(a){const b=canonicalTemplateContent(a);return releaseSentinelLine(TEMPLATE_SENTINEL_KIND,BUILTIN_TEMPLATES_VERSION,releaseBodyHash(b))+'\x0a'+b;}export function templateCatalogDigest(a){const b=BUILTIN_TEMPLATES['find'](c=>c['id']===a);if(!b)return undefined;return releaseBodyHash(canonicalTemplateContent(b));}export const TEMPLATE_KNOBS_SENTINEL_KIND='template-knobs';export const TEMPLATE_KNOBS_VERSION=0x4;export const TemplateKnobOverlaySchema=TemplateFrontmatterSchema['pick']({'fee_params':!![],'key_risk':!![],'recommended_role':!![],'role_rationale':!![],'differences':!![],'user_inputs':!![],'payment_model':!![],'arbitration_mode':!![],'review_mode':!![],'after_sales_mode':!![],'acceptance_mode':!![],'installment_mode':!![],'affiliate_mode':!![],'crowdfunding_mode':!![],'logistics_mode':!![],'reward_claim_policy':!![],'reentry_kind':!![],'compensation_fund_policy':!![]})['partial']()['extend']({'id':z['string']()['regex'](/^[a-z][a-z0-9._-]*\/[a-z][a-z0-9._-]*$/,'knob\x20file\x20id\x20must\x20be\x20\x27<industry>/<variant>\x27')})['strict']();export function foldKnobFrontmatter(a){const b={},c={};for(const [d,e]of Object['entries'](a)){d['startsWith']('fee_params.')?c[d['slice']('fee_params.'['length'])]=e:b[d]=e;}if(Object['keys'](c)['length']>0x0)b['fee_params']=c;return b;}export function parseKnobFile(a,b){const c=stripReleaseSentinel(a,TEMPLATE_KNOBS_SENTINEL_KIND);let d;try{const f=parseTemplateFile(c['sentinel']?c['content']:a);d=f['frontmatter'];}catch{return null;}const e=TemplateKnobOverlaySchema['safeParse'](foldKnobFrontmatter(d));if(!e['success']||e['data']['id']!==b)return null;return e['data'];}function knobLine(a,b){if(typeof b==='number')return a+':\x20'+b;if(typeof b==='string')return/^-?\d+(\.\d+)?$/['test'](b)?a+':\x20\x27'+b+'\x27':a+':\x20'+b;return a+':\x20'+JSON['stringify'](b);}export function canonicalKnobContent(a){const b=['id:\x20'+a['id'],knobLine('key_risk',a['key_risk']),knobLine('recommended_role',a['recommended_role']),knobLine('role_rationale',a['role_rationale']),...Object['keys'](a['fee_params'])['sort']()['flatMap'](d=>[...knobDocLines(d),knobLine('fee_params.'+d,a['fee_params'][d])]),...a['payment_model']!==undefined?[knobLine('payment_model',a['payment_model'])]:[],...a['arbitration_mode']!==undefined?[knobLine('arbitration_mode',a['arbitration_mode'])]:[],...a['review_mode']!==undefined?[knobLine('review_mode',a['review_mode'])]:[],...a['after_sales_mode']!==undefined?[knobLine('after_sales_mode',a['after_sales_mode'])]:[],...a['acceptance_mode']!==undefined?[knobLine('acceptance_mode',a['acceptance_mode'])]:[],...a['installment_mode']!==undefined?[knobLine('installment_mode',a['installment_mode'])]:[],...a['affiliate_mode']!==undefined?[knobLine('affiliate_mode',a['affiliate_mode'])]:[],...a['crowdfunding_mode']!==undefined?[knobLine('crowdfunding_mode',a['crowdfunding_mode'])]:[],...a['logistics_mode']!==undefined?[knobLine('logistics_mode',a['logistics_mode'])]:[],...a['reward_claim_policy']!==undefined?[knobLine('reward_claim_policy',a['reward_claim_policy'])]:[],...a['reentry_kind']!==undefined&&a['reentry_kind']!=='none'?[knobLine('reentry_kind',a['reentry_kind'])]:[],...a['compensation_fund_policy']!==undefined?[knobLine('compensation_fund_policy',a['compensation_fund_policy'])]:[],knobLine('differences',a['differences']),knobLine('user_inputs',a['user_inputs'])],c=['','#\x20'+a['industry']+'\x20/\x20'+a['variant']+'\x20('+a['archetype']+')\x20—\x20business\x20knobs','','>\x20THIS\x20file\x20is\x20the\x20one\x20you\x20edit.\x20Each\x20line\x20above\x20the\x20body\x20is\x20a\x20knob\x20the','>\x20build\x20honors:\x20`fee_params.<name>`\x20(numbers\x20—\x20pricing\x20windows,\x20caps,','>\x20pools),\x20the\x20mode\x20switches\x20(review/arbitration/logistics/...),\x20and\x20the','>\x20guidance\x20prose\x20below.\x20Lines\x20starting\x20with\x20`#`\x20are\x20read-only\x20docs\x20for','>\x20the\x20knob\x20line\x20below\x20them\x20—\x20edit\x20the\x20value\x20line,\x20never\x20the\x20`#`\x20lines','>\x20(docs\x20refresh\x20with\x20each\x20release).\x20The\x20workflow\x20structure\x20itself','>\x20(nodes,\x20guards,\x20fund\x20rails)\x20is\x20system-managed\x20in\x20a\x20hidden\x20`.machine/`','>\x20file\x20next\x20to\x20this\x20one\x20and\x20is\x20deliberately\x20not\x20exposed\x20—\x20change','>\x20business\x20intent\x20through\x20these\x20knobs\x20or\x20through\x20the\x20migration\x20wizard,','>\x20never\x20by\x20editing\x20node\x20graphs\x20by\x20hand.','','##\x20Key\x20risk','',...wrapParagraph(a['key_risk']),'','##\x20Differences\x20vs\x20the\x20sibling\x20variant','',...a['differences']['flatMap'](e=>wrapBullet(e)),'','##\x20Build-time\x20inputs\x20&\x20standing\x20constraints\x20(non-parameter)','',...a['user_inputs']['flatMap'](d=>wrapBullet(d)),'','##\x20Your\x20notes\x20(free-form\x20—\x20the\x20AI\x20reads\x20this\x20body\x20as\x20guidance)','','-\x20(Add\x20your\x20own\x20pricing,\x20tone,\x20or\x20policy\x20notes\x20below\x20—\x20they\x20override\x20the','\x20\x20generic\x20guidance\x20the\x20same\x20way\x20playbook.md\x20does.)',''];return['---',...b,'---',...c]['join']('\x0a');}export function renderKnobFile(a){const b=canonicalKnobContent(a);return releaseSentinelLine(TEMPLATE_KNOBS_SENTINEL_KIND,TEMPLATE_KNOBS_VERSION,releaseBodyHash(b))+'\x0a'+b;}export function classifyKnobFile(a,b){const c=stripReleaseSentinel(a,TEMPLATE_KNOBS_SENTINEL_KIND);if(!c['sentinel'])return null;if(parseKnobFile(c['content'],b)===null)return null;const d=classifyRelease(c['sentinel'],c['content'],TEMPLATE_KNOBS_VERSION);return d==='user_file'?null:d;}export function applyKnobOverlay(a,b,c){return{...a,...b['fee_params']!==undefined?{'fee_params':{...a['fee_params'],...b['fee_params']}}:{},...b['key_risk']!==undefined?{'key_risk':b['key_risk']}:{},...b['recommended_role']!==undefined?{'recommended_role':b['recommended_role']}:{},...b['role_rationale']!==undefined?{'role_rationale':b['role_rationale']}:{},...b['differences']!==undefined?{'differences':b['differences']}:{},...b['user_inputs']!==undefined?{'user_inputs':b['user_inputs']}:{},...b['payment_model']!==undefined?{'payment_model':b['payment_model']}:{},...b['arbitration_mode']!==undefined?{'arbitration_mode':b['arbitration_mode']}:{},...b['review_mode']!==undefined?{'review_mode':b['review_mode']}:{},...b['after_sales_mode']!==undefined?{'after_sales_mode':b['after_sales_mode']}:{},...b['acceptance_mode']!==undefined?{'acceptance_mode':b['acceptance_mode']}:{},...b['installment_mode']!==undefined?{'installment_mode':b['installment_mode']}:{},...b['affiliate_mode']!==undefined?{'affiliate_mode':b['affiliate_mode']}:{},...b['crowdfunding_mode']!==undefined?{'crowdfunding_mode':b['crowdfunding_mode']}:{},...b['logistics_mode']!==undefined?{'logistics_mode':b['logistics_mode']}:{},...b['reward_claim_policy']!==undefined?{'reward_claim_policy':b['reward_claim_policy']}:{},...b['reentry_kind']!==undefined?{'reentry_kind':b['reentry_kind']}:{},...b['compensation_fund_policy']!==undefined?{'compensation_fund_policy':b['compensation_fund_policy']}:{},'body':c};}function machineTemplateFile(a,b){return join(a,b['industry'],TEMPLATES_SUBDIR,MACHINE_TEMPLATES_SUBDIR,b['variant']+'.md');}function knobTemplateFile(a,b){return join(a,b['industry'],TEMPLATES_SUBDIR,b['variant']+'.md');}function archiveBackupFile(a,b,c){return join(a,b['industry'],TEMPLATES_SUBDIR,TEMPLATE_ARCHIVE_SUBDIR,''+b['variant']+c);}export function matchBuiltinTemplateSlot(a){const b=relative(resolveTemplatesDir(),a);if(!b||b['startsWith']('..'))return null;const c=b['split'](sep);if(c['length']===0x4&&c[0x1]===TEMPLATES_SUBDIR&&c[0x2]===MACHINE_TEMPLATES_SUBDIR&&c[0x3]['endsWith']('.md')){const d=c[0x3]['slice'](0x0,-'.md'['length']),e=BUILTIN_TEMPLATES['find'](f=>f['industry']===c[0x0]&&f['variant']===d)??null;return e?{'template':e,'part':'machine'}:null;}if(c['length']===0x3&&c[0x1]===TEMPLATES_SUBDIR&&c[0x2]['endsWith']('.md')){const f=c[0x2]['slice'](0x0,-'.md'['length']),g=BUILTIN_TEMPLATES['find'](h=>h['industry']===c[0x0]&&h['variant']===f)??null;return g?{'template':g,'part':'knobs'}:null;}return null;}let seeded=![];export function seedBuiltinTemplates(){const a=[],b=resolveTemplatesDir();for(const c of BUILTIN_TEMPLATES){const d=machineTemplateFile(b,c),e=knobTemplateFile(b,c),f=dirname(d),g=canonicalTemplateContent(c),h={'template':c['id'],'status':'written','path':d};try{if(!existsSync(d))mkdirSync(f,{'recursive':!![]}),writeFileSync(d,renderTemplateFile(c),'utf-8');else{const i=readFileSync(d,'utf-8'),{sentinel:j,content:k}=stripReleaseSentinel(i,TEMPLATE_SENTINEL_KIND);!j?k===g?(writeFileSync(d,renderTemplateFile(c),'utf-8'),h['status']='restamped',h['detail']='body\x20matches\x20canonical\x20but\x20no\x20sentinel\x20present;\x20sentinel\x20header\x20added,\x20body\x20untouched'):(h['status']='skipped_user_file',h['detail']='machine\x20file\x20exists\x20without\x20builtin\x20sentinel\x20and\x20body\x20differs\x20from\x20canonical;\x20leaving\x20user\x20file\x20untouched'):k===g?j['version']!==BUILTIN_TEMPLATES_VERSION||releaseBodyHash(k)!==j['hash']?(writeFileSync(d,renderTemplateFile(c),'utf-8'),h['status']='restamped',h['detail']='body\x20matches\x20canonical\x20but\x20sentinel\x20stale/wrong;\x20header\x20refreshed,\x20body\x20untouched'):h['status']='current':(h['status']='skipped_modified',h['detail']='body\x20differs\x20from\x20canonical;\x20not\x20overwritten\x20by\x20seeding\x20—\x20use\x20repair_builtin_templates\x20(preview→confirm)\x20to\x20reseed');}}catch(l){h['status']='error',h['detail']=l['message'];}a['push'](h);try{a['push'](seedKnobSlot(b,c));}catch(m){a['push']({'template':c['id'],'status':'error','path':e,'detail':m['message']});}}try{a['push'](...seedIndustryNavPages(b));}catch{}return a;}function seedKnobSlot(a,b){const c=knobTemplateFile(a,b),d={'template':b['id'],'status':'knob_written','path':c};if(!existsSync(c))return mkdirSync(dirname(c),{'recursive':!![]}),writeFileSync(c,renderKnobFile(b),'utf-8'),d['detail']='knob\x20file\x20written\x20(fresh)',d;const e=readFileSync(c,'utf-8'),f=classifyKnobFile(e,b['id']);if(f==='current')return{...d,'status':'knob_current'};if(f==='outdated')return writeFileSync(c,renderKnobFile(b),'utf-8'),{...d,'status':'knob_current','detail':'unmodified\x20older\x20knob\x20release\x20auto-upgraded\x20to\x20the\x20current\x20render'};if(f==='user_modified')return{...d,'status':'knob_kept_user','detail':'user-edited\x20knobs\x20kept\x20by\x20design\x20(never\x20overwritten)'};let g;try{g=String(parseTemplateFile(e)['frontmatter']['id']??'');}catch{g=undefined;}if(g!==b['id'])return{...d,'status':'skipped_user_file','detail':'a\x20non-knob\x20file\x20(id\x20\x27'+(g??'<unparseable>')+'\x27)\x20occupies\x20the\x20knob\x20slot;\x20machine\x20template\x20wins,\x20file\x20untouched\x20—\x20rename\x20it\x20to\x20free\x20the\x20slot'};const h=join(dirname(c),TEMPLATE_ARCHIVE_SUBDIR);mkdirSync(h,{'recursive':!![]});const i=join(h,b['variant']+'.pre-split.md');return writeFileSync(i,e,'utf-8'),rmSync(c,{'force':!![]}),writeFileSync(c,renderKnobFile(b),'utf-8'),{...d,'status':'knob_written','detail':'obsolete\x20pre-S8\x20single-file\x20template\x20retired\x20to\x20'+i+';\x20knob\x20file\x20re-rendered\x20from\x20the\x20current\x20catalog'};}function seedIndustryNavPages(a){const b=[],c=new Map();for(const d of BUILTIN_TEMPLATES){const e=c['get'](d['industry'])??[];e['push'](d),c['set'](d['industry'],e);}for(const [f,g]of[...c['entries']()]['sort']()){const h=join(a,f,INDUSTRY_NAV_FILENAME),i={'template':'nav/'+f,'status':'written','path':h};try{if(!existsSync(h))mkdirSync(dirname(h),{'recursive':!![]}),writeFileSync(h,renderIndustryNav(f,g),'utf-8');else{const j=classifyIndustryNav(readFileSync(h,'utf-8'));if(j==='current')i['status']='current';else j==='outdated'?(writeFileSync(h,renderIndustryNav(f,g),'utf-8'),i['status']='restamped',i['detail']='unmodified\x20older\x20nav\x20page\x20auto-upgraded'):(i['status']='skipped_modified',i['detail']='nav\x20page\x20user-edited;\x20kept\x20by\x20design');}}catch(k){i['status']='error',i['detail']=k['message'];}b['push'](i);}return b;}export function summarizeTemplateDiff(a,b){let c,d;try{c=parseTemplateFile(a);}catch(g){return'on-disk\x20file\x20is\x20not\x20parseable\x20('+g['message']+');\x20full\x20content\x20will\x20be\x20replaced';}try{d=parseTemplateFile(b);}catch{return'canonical\x20render\x20is\x20not\x20parseable\x20(code\x20defect);\x20full\x20content\x20will\x20be\x20replaced';}const e=[],f=new Set([...Object['keys'](c['frontmatter']),...Object['keys'](d['frontmatter'])]);for(const h of[...f]['sort']()){const i=h in c['frontmatter'],j=h in d['frontmatter'];if(i&&!j)e['push']('-'+h);else{if(!i&&j)e['push']('+'+h);else{if(JSON['stringify'](c['frontmatter'][h])!==JSON['stringify'](d['frontmatter'][h]))e['push']('~'+h);}}}return c['body']!==d['body']&&e['push']('~body\x20('+c['body']['split']('\x0a')['length']+'\x20->\x20'+d['body']['split']('\x0a')['length']+'\x20lines)'),e['length']>0x0?e['join'](',\x20'):'whitespace/ordering\x20only';}export function repairBuiltinTemplates(a){const b=[],c=resolveTemplatesDir(),d=a?.['backup']!==![],e=a?.['dryRun']===!![],f=new Set(a?.['includeUserEdited']??[]);for(const g of BUILTIN_TEMPLATES){const h=machineTemplateFile(c,g);if(!existsSync(h))continue;const i=canonicalTemplateContent(g);let j=null,k='';const l={'template':g['id'],'status':'would_update','path':h};try{const p=stripReleaseSentinel(readFileSync(h,'utf-8'),TEMPLATE_SENTINEL_KIND);j=p['sentinel'],k=p['content'];}catch(q){l['status']='error',l['detail']=q['message'],b['push'](l);continue;}if(k===i)continue;let m;if(j){if(j['version']>BUILTIN_TEMPLATES_VERSION){l['status']='error',l['detail']='newer\x20release\x20on\x20disk\x20(sentinel\x20v'+j['version']+'\x20>\x20running\x20catalog\x20v'+BUILTIN_TEMPLATES_VERSION+')\x20—\x20'+'repair\x20would\x20DOWNGRADE\x20and\x20lose\x20the\x20newer\x20release\x27s\x20content;\x20refused.\x20Upgrade\x20the\x20MCP\x20server\x20instead',b['push'](l);continue;}if(releaseBodyHash(k)!==j['hash']){if(!f['has'](g['id']))continue;m='sentinel-body\x20hash\x20mismatch\x20(sentinel\x20v'+j['version']+'\x20no\x20longer\x20binds\x20the\x20body)\x20'+'reseeded\x20under\x20EXPLICIT\x20include_user_edited\x20authorization';}else m='untouched\x20older\x20release\x20(sentinel\x20v'+j['version']+',\x20current\x20v'+BUILTIN_TEMPLATES_VERSION+')';}else{let r;try{r=String(parseTemplateFile(k)['frontmatter']['id']??'');}catch{continue;}if(r!==g['id'])continue;m='legacy\x20sentinel-less\x20builtin\x20file';}const n=summarizeTemplateDiff(k,i),o=d?';\x20previous\x20body\x20would\x20be\x20saved\x20in\x20templates/.archive/':'';if(e){l['status']='would_update',l['detail']=m+'\x20would\x20be\x20reseeded\x20from\x20BUILTIN_TEMPLATES\x20('+g['id']+')\x20—\x20diff\x20vs\x20canonical:\x20'+n+o+'\x20—\x20execute\x20with\x20authorize=true\x20after\x20the\x20user\x20explicitly\x20confirms',b['push'](l);continue;}try{if(d){const s=archiveBackupFile(c,g,'.repair.md');mkdirSync(dirname(s),{'recursive':!![]}),copyFileSync(h,s);}writeFileSync(h,renderTemplateFile(g),'utf-8'),cache['delete'](h),l['status']='updated',l['detail']=m+'\x20reseeded\x20from\x20BUILTIN_TEMPLATES\x20('+g['id']+')\x20—\x20diff\x20was:\x20'+n+(d?';\x20previous\x20body\x20saved\x20in\x20templates/.archive/':'');}catch(u){l['status']='error',l['detail']=u['message'];}b['push'](l);}return b;}export function builtinTemplateDrift(a){const b=new Set(a?.['includeUserEdited']??[]),c=[],d=resolveTemplatesDir();for(const e of BUILTIN_TEMPLATES){const f=machineTemplateFile(d,e);if(!existsSync(f)){c['push']({'template':e['id'],'path':f,'state':'missing','repairable':!![],'detail':'no\x20file\x20on\x20disk;\x20seeding\x20will\x20create\x20it'});continue;}const g=canonicalTemplateContent(e);let h=null,i='';try{const k=stripReleaseSentinel(readFileSync(f,'utf-8'),TEMPLATE_SENTINEL_KIND);h=k['sentinel'],i=k['content'];}catch(l){c['push']({'template':e['id'],'path':f,'state':'modified','repairable':![],'detail':'unreadable:\x20'+l['message']});continue;}if(i===g)continue;const j=summarizeTemplateDiff(i,g);if(!h){let m;try{m=String(parseTemplateFile(i)['frontmatter']['id']??'');}catch{m=undefined;}m===e['id']?c['push']({'template':e['id'],'path':f,'state':'modified','repairable':!![],'detail':'legacy\x20sentinel-less\x20builtin\x20file\x20—\x20seeding\x20never\x20rewrites\x20it\x20and\x20no\x20sentinel\x20proves\x20provenance;\x20repair\x20can\x20reseed\x20—\x20diff\x20vs\x20canonical:\x20'+j}):c['push']({'template':e['id'],'path':f,'state':'modified','repairable':![],'detail':'no\x20release\x20sentinel\x20and\x20id\x20\x27'+(m??'<unparseable>')+'\x27\x20does\x20not\x20match\x20the\x20builtin\x20id\x20—\x20a\x20user\x20file\x20occupies\x20this\x20path;\x20never\x20touched\x20(rename\x20it\x20to\x20free\x20the\x20slot)'});continue;}if(releaseBodyHash(i)===h['hash'])h['version']>BUILTIN_TEMPLATES_VERSION?c['push']({'template':e['id'],'path':f,'state':'modified','repairable':![],'detail':'newer\x20release\x20(sentinel\x20v'+h['version']+'\x20>\x20running\x20catalog\x20v'+BUILTIN_TEMPLATES_VERSION+')\x20—\x20'+'repair\x20would\x20DOWNGRADE\x20and\x20lose\x20the\x20newer\x20release\x27s\x20content;\x20repairable:\x20false.\x20'+'Upgrade\x20the\x20MCP\x20server\x20to\x20match\x20—\x20diff\x20vs\x20canonical:\x20'+j}):c['push']({'template':e['id'],'path':f,'state':'modified','repairable':!![],'detail':'untouched\x20older\x20release\x20(sentinel\x20v'+h['version']+',\x20current\x20v'+BUILTIN_TEMPLATES_VERSION+')\x20—\x20repair\x20can\x20upgrade\x20—\x20diff\x20vs\x20canonical:\x20'+j});else{const n=b['has'](e['id']);c['push']({'template':e['id'],'path':f,'state':'modified','repairable':n,'detail':n?'sentinel-body\x20hash\x20mismatch\x20(sentinel\x20v'+h['version']+'\x20no\x20longer\x20binds\x20the\x20body)\x20—\x20reseedable\x20under\x20the\x20explicit\x20include_user_edited\x20authorization\x20for\x20this\x20id\x20—\x20diff\x20vs\x20canonical:\x20'+j:'user-edited\x20body\x20—\x20kept\x20by\x20design;\x20repair\x20never\x20overwrites\x20user\x20edits\x20—\x20diff\x20vs\x20canonical:\x20'+j});}}for(const o of c){const p=BUILTIN_TEMPLATES['find'](q=>q['id']===o['template']);if(p)o['knob_state']=knobFileState(d,p);}return c;}function knobFileState(a,b){const c=knobTemplateFile(a,b);if(!existsSync(c))return'missing';try{return classifyKnobFile(readFileSync(c,'utf-8'),b['id'])==='user_modified'?'user_modified':'current';}catch{return'current';}}const cache=new Map();export function reloadTemplates(){cache['clear'](),seeded=![];}export function loadAndValidate(a){const b=readFileSync(a,'utf-8');let c;try{c=parseTemplateFile(b);}catch(g){throw new Error('template\x20\x27'+a+'\x27\x20failed\x20to\x20parse:\x20'+g['message']);}const d=TemplateFrontmatterSchema['safeParse'](c['frontmatter']);if(!d['success']){const h=d['error']['issues']['map'](j=>(j['path']['join']('.')||'<root>')+':\x20'+j['message'])['join'](';\x20');throw new Error('template\x20\x27'+a+'\x27\x20failed\x20validation:\x20'+h);}const e=validateAllocatorRows(d['data']);if(e['length']>0x0)throw new Error('template\x20\x27'+a+'\x27\x20failed\x20allocator-row\x20validation:\x20'+e['join'](';\x20'));const f=userInputSpecIssues(d['data']);if(f['length']>0x0)throw new Error('template\x20\x27'+a+'\x27\x20failed\x20user_input_specs\x20validation:\x20'+f['join'](';\x20'));return{...d['data'],'body':c['body'],'source_path':a};}function templateFilesOnDisk(a){const b=[];if(!existsSync(a))return b;const c=new Set(BUILTIN_TEMPLATES['map'](d=>d['industry']+'/'+d['variant']));for(const d of readdirSync(a,{'withFileTypes':!![]})){if(!d['isDirectory']())continue;const e=join(a,d['name'],TEMPLATES_SUBDIR);if(!existsSync(e))continue;const g=join(e,MACHINE_TEMPLATES_SUBDIR);if(existsSync(g))for(const h of readdirSync(g,{'withFileTypes':!![]})){if(!h['isFile']()||!h['name']['endsWith']('.md'))continue;const i=h['name']['slice'](0x0,-'.md'['length']),j=c['has'](d['name']+'/'+i)?join(e,h['name']):null;b['push']({'file':join(g,h['name']),'id':d['name']+'/'+i,'knobFile':j});}for(const k of readdirSync(e,{'withFileTypes':!![]})){if(!k['isFile']()||!k['name']['endsWith']('.md'))continue;const l=k['name']['slice'](0x0,-'.md'['length']);if(c['has'](d['name']+'/'+l))continue;b['push']({'file':join(e,k['name']),'id':d['name']+'/'+l,'knobFile':null});}}return b['sort']((m,n)=>m['file']['localeCompare'](n['file']));}export function listTemplates(){!seeded&&(seedBuiltinTemplates(),seeded=!![]);const a=resolveTemplatesDir(),b=[],c=[],d=new Map(),e=new Set();for(const {file:f,id:g,knobFile:h}of templateFilesOnDisk(a)){e['add'](f);try{const i=statSync(f)['mtimeMs'],j=h&&existsSync(h)?statSync(h)['mtimeMs']:0x0,k=cache['get'](f);if(k&&k['mtimeMs']===i&&k['knobMtimeMs']===j){b['push'](k['template']);continue;}let l=loadAndValidate(f);if(h&&j>0x0){const m=readFileSync(h,'utf-8'),n=parseKnobFile(m,l['id']);if(n){l=applyKnobOverlay(l,n,parseTemplateFile(m)['body']);const o=validateAllocatorRows(l);if(o['length']>0x0)throw new Error('template\x20\x27'+f+'\x27\x20—\x20knob\x20overlay\x20\x27'+h+'\x27\x20broke\x20allocator-row\x20validation:\x20'+o['join'](';\x20'));}else c['push']('knob\x20file\x20\x27'+h+'\x27\x20is\x20not\x20a\x20valid\x20knob\x20overlay\x20for\x20\x27'+l['id']+'\x27\x20—\x20ignored,\x20machine\x20template\x20used\x20as-is');}cache['set'](f,{'mtimeMs':i,'knobMtimeMs':j,'template':l}),b['push'](l);}catch(p){cache['delete'](f),c['push'](p['message']),d['set'](g,p['message']);}}for(const q of[...cache['keys']()]){if(!e['has'](q))cache['delete'](q);}return b['sort']((r,s)=>r['id']['localeCompare'](s['id'])),loadErrorsById=d,{'templates':b,'errors':c};}let loadErrorsById=new Map();export function getTemplateLoadError(a){return listTemplates(),loadErrorsById['get'](a);}export function getTemplate(a){return listTemplates()['templates']['find'](b=>b['id']===a);}export function getTemplatesByIndustry(a){return listTemplates()['templates']['filter'](b=>b['industry']===a);}
|
|
1
|
+
import{copyFileSync,existsSync,mkdirSync,readdirSync,readFileSync,rmSync,statSync,writeFileSync}from'node:fs';import{dirname,join,relative,sep}from'node:path';import{z}from'zod';import{getWowokIndustryDir}from'@wowok/wowok';import{SUPPORTED_INDUSTRIES}from'../customer/user-preferences.js';import{isRegisteredIndustry}from'./industry-registry.js';import{BUILTIN_TEMPLATES,BUILTIN_TEMPLATES_VERSION}from'./builtin-templates.js';import{knobDocLines}from'./knob-docs.js';import{MachineProseEnvelopeSchema}from'./template-prose.js';import{INDUSTRY_NAV_FILENAME,classifyIndustryNav,renderIndustryNav,wrapBullet,wrapParagraph}from'./template-nav.js';import{classifyRelease,releaseBodyHash,releaseSentinelLine,stripReleaseSentinel}from'./release-sentinel.js';export const TEMPLATES_SUBDIR='templates';export const MACHINE_TEMPLATES_SUBDIR='.machine';export const TEMPLATE_ARCHIVE_SUBDIR='.archive';export function resolveTemplatesDir(){return process['env']['WOWOK_TEMPLATES_DIR']||getWowokIndustryDir();}const MachineEdgeSchema=z['object']({'prev':z['string'](),'forward':z['string']()['min'](0x1)['optional'](),'operator':z['enum'](['merchant','order_payer'])['optional'](),'named_operator':z['string']()['min'](0x1)['optional'](),'permission_index':z['number']()['int']()['min'](0x3e8)['optional'](),'guard_key':z['string']()['min'](0x1)['optional']()}),MachineNodeSchema=z['object']({'name':z['string']()['min'](0x1),'role':z['string']()['min'](0x1),'operator':z['enum'](['merchant','order_payer'])['optional'](),'named_operator':z['string']()['min'](0x1)['optional'](),'semantic_role':z['enum'](['draft','active','delivered','final','cancelled'])['optional'](),'optional':z['boolean']()['optional'](),'threshold':z['number']()['int']()['min'](0x0)['optional'](),'from':z['array'](z['union']([z['string'](),MachineEdgeSchema]))['optional']()}),GuardRefSchema=z['object']({'template_id':z['string']()['regex'](/^(pattern\.[a-z0-9_]+|tpl_[a-z0-9_]+)$/,'guard\x20template_id\x20must\x20be\x20a\x20\x27pattern.*\x27\x20design\x20pattern\x20or\x20\x27tpl_*\x27\x20guard\x20template'),'host':z['enum'](['service','machine','reward','repository','arbitration']),'purpose':z['string']()['min'](0x1),'key':z['string']()['min'](0x1),'policy':z['object']({'name':z['string']()['min'](0x1)['optional'](),'description':z['string']()['min'](0x1)['optional'](),'id_from':z['string']()['min'](0x1)['optional'](),'value_type':z['string']()['min'](0x1)['optional']()})['optional'](),'params':z['record'](z['string'](),z['unknown']())['optional'](),'identity_leg_exempt':z['string']()['min'](0x1)['optional']()}),ConditionalGuardEmissionSchema=z['object']({'guard_key':z['string']()['min'](0x1),'param':z['string']()['min'](0x1),'values':z['array'](z['string']()['min'](0x1))['min'](0x2),'emit_value':z['string']()['min'](0x1),'question':z['string']()['min'](0x1)})['strict'](),AllocatorRowSchema=z['object']({'track':z['enum'](['settlement','refund']),'recipient':z['enum'](['entity','guard_identifier','signer']),'recipient_key':z['string']()['min'](0x1)['optional'](),'mode':z['enum'](['amount','rate','surplus','formula']),'value':z['union']([z['string'](),z['number']()])['optional'](),'value_from':z['string']()['optional'](),'value_from_complement':z['string']()['min'](0x1)['optional'](),'repeat_from':z['string']()['min'](0x1)['optional'](),'fix':z['union']([z['string'](),z['number']()])['optional'](),'fix_from':z['string']()['optional'](),'guard_key':z['string']()['min'](0x1)['optional'](),'formula':z['object']({'selector':z['number']()['int']()['min'](0x0)['max'](0x2),'repo':z['string']()['min'](0x1)['optional'](),'key':z['string']()['min'](0x1)['optional'](),'predicate':z['unknown']()['optional'](),'ids':z['array'](z['unknown']())['optional']()})['strict']()['optional'](),'note':z['string']()['optional']()})['strict'](),AllocatorSchema=z['object']({'recipient':z['enum'](['signer','entity','fixed']),'recipient_key':z['string']()['min'](0x1)['optional'](),'refund_track':z['enum'](['order_anchored'])['optional'](),'count':z['number']()['int']()['positive'](),'mode':z['enum'](['amount','rate','surplus']),'once_per_order':z['boolean']()['optional'](),'rows':z['array'](AllocatorRowSchema)['optional'](),'description':z['string']()['min'](0x1)})['strict'](),UserInputSpecSchema=z['object']({'question':z['string']()['min'](0x1),'param_key':z['string']()['min'](0x1),'note':z['string']()['min'](0x1)['optional']()})['strict'](),IndustryNameSchema=z['string']()['regex'](/^[a-z][a-z0-9_]*$/,'industry\x20must\x20be\x20lowercase\x20snake_case\x20(a-z,\x200-9,\x20_)')['refine'](a=>isRegisteredIndustry(a),{'message':'unknown\x20industry\x20—\x20register\x20it\x20first\x20via\x20an\x20industry\x20pack\x20'+'(industry_pack_operation\x20action=\x27scaffold\x27)\x20or\x20the\x20industry\x20generalizer;\x20'+('builtin\x20industries:\x20'+SUPPORTED_INDUSTRIES['join'](',\x20'))});export const TemplateFrontmatterSchema=z['object']({'id':z['string']()['regex'](/^[a-z][a-z0-9_-]*\/[a-z][a-z0-9_-]*$/,'id\x20must\x20be\x20\x27<industry>/<variant>\x27'),'industry':IndustryNameSchema,'variant':z['string']()['regex'](/^[a-z][a-z0-9_-]*$/),'product_ref':z['string']()['regex'](/^[a-z][a-z0-9._-]*$/,'product_ref\x20must\x20be\x20a\x20lowercase\x20product\x20slug')['optional'](),'archetype':z['enum'](['leader','challenger']),'phase':z['number']()['int']()['min'](0x1)['max'](0x3),'machine_shape':z['array'](MachineNodeSchema)['min'](0x1),'guards':z['array'](GuardRefSchema),'allocator':AllocatorSchema,'fee_params':z['record'](z['string'](),z['union']([z['number'](),z['string']()])),'trust_mechanisms':z['array'](z['string']()),'keeper_dependencies':z['array'](z['string']()),'keeper_duty':z['array'](z['object']({'when':z['string']()['min'](0x1),'action':z['string']()['min'](0x1),'miss_consequence':z['string']()['min'](0x1)})['strict']())['optional'](),'recommended_role':z['enum'](['merchant','supplier','both']),'role_rationale':z['string']()['min'](0x1),'differences':z['array'](z['string']()),'user_inputs':z['array'](z['string']()),'user_input_specs':z['array'](UserInputSpecSchema)['optional'](),'key_risk':z['string']()['min'](0x1)['max'](0x12c,'key_risk\x20must\x20be\x20a\x20one-line\x20risk\x20statement\x20(<=\x20300\x20chars)\x20—\x20rules\x20and\x20doctrine\x20do\x20not\x20belong\x20in\x20this\x20field')['refine'](a=>!/STANDING RULE|TECHNOLOGY PROVIDER|NOT A PARTY TO THE DEAL|Full text:/i['test'](a),{'message':'key_risk\x20carries\x20an\x20instruction-block\x20fragment\x20(STANDING\x20RULE\x20/\x20provider\x20doctrine\x20/\x20\x27Full\x20text:\x27\x20reference)\x20—\x20keep\x20doctrine\x20in\x20body\x20prose\x20or\x20playbooks,\x20not\x20in\x20this\x20field'}),'build_notes':z['array'](z['string']()),'prose_language':z['enum'](['en','other'])['optional'](),'machine_prose':z['record'](z['string'](),MachineProseEnvelopeSchema)['optional'](),'evidence_refs':z['array'](z['string']())['optional'](),'conditional_guards':z['array'](ConditionalGuardEmissionSchema)['optional'](),'time_anchors':z['record'](z['string'](),z['string']())['optional'](),'payment_model':z['enum'](['milestone','subscription','escrow'])['optional'](),'arbitration_mode':z['enum'](['none','merchant_pick','mutual_pick','third_party'])['optional'](),'reward_claim_policy':z['object']({'kind':z['enum'](['once','periodic','capped']),'min_claim_interval_ms':z['number']()['optional'](),'max_total_per_recipient':z['string']()['optional']()})['optional'](),'review_mode':z['enum'](['none','review','review_reward'])['optional'](),'experience_compensation_mode':z['enum'](['none','reward'])['optional'](),'after_sales_mode':z['enum'](['none','return','exchange','warranty'])['optional'](),'acceptance_mode':z['enum'](['none','milestone','contest','bounty','agent'])['optional'](),'installment_mode':z['enum'](['none','deposit_balance','milestone_n'])['optional'](),'affiliate_mode':z['enum'](['none','commission'])['optional'](),'crowdfunding_mode':z['enum'](['none','threshold','flexible'])['optional'](),'logistics_mode':z['enum'](['none','carrier','merchant_managed','courier','pickup_point'])['optional'](),'compensation_fund_policy':z['enum'](['allowed','forbidden'])['optional'](),'reentry_kind':z['enum'](['none','review-loop','paid-cycle'])['optional'](),'settlement_window_merge':z['array'](z['string']())['optional']()})['strict']();export function userInputSpecIssues(a){if(a['user_input_specs']===undefined)return[];const b=[],c=new Set();for(const [d,e]of a['user_input_specs']['entries']()){!(e['param_key']in a['fee_params'])&&b['push']('user_input_specs['+d+'].param_key\x20\x27'+e['param_key']+'\x27\x20is\x20not\x20a\x20declared\x20fee_param\x20—\x20declare\x20it\x20in\x20fee_params\x20(the\x20question\x20fills\x20it)\x20or\x20fix\x20the\x20key'),c['has'](e['param_key'])&&b['push']('user_input_specs['+d+']\x20asks\x20about\x20\x27'+e['param_key']+'\x27\x20twice\x20—\x20one\x20question\x20per\x20parameter'),c['add'](e['param_key']);}return b;}import{validateAllocatorRows}from'./template-validation.js';export{validateAllocatorRows};export function platformShareBps(a){const b=Object['keys'](a)['find'](c=>/(?:platform|commission|service_fee)[a-z_]*_bps$/['test'](c)&&!/^attributed_/['test'](c)&&!/_cap_bps$/['test'](c)&&typeof a[c]==='number');return b!==undefined?a[b]:undefined;}export const PLATFORM_TAKE_KEY=/^(?:platform_(?:share|commission|take|tool_fee)_bps|platform_fee_rate_bps|commission_rate_bps|(?:base_)?commission_rate_bps|offsite_ads_rate_bps|service_fee_rate_bps|payment_fee_bps)$/;export function parseTemplateFile(a){const b=a['replace'](/^\uFEFF/,'')['replace'](/^<!-- builtin:[a-z0-9-]+:v\d+:[0-9a-f]+ -->\r?\n/,''),c=b['split'](/\r?\n/);if(c[0x0]?.['trim']()!=='---')throw new Error('template\x20must\x20start\x20with\x20a\x20\x27---\x27\x20frontmatter\x20block');let d=-0x1;for(let f=0x1;f<c['length'];f++){if(c[f]['trim']()==='---'){d=f;break;}}if(d===-0x1)throw new Error('unterminated\x20frontmatter\x20block\x20(missing\x20closing\x20\x27---\x27)');const e={};for(let g=0x1;g<d;g++){const h=c[g];if(!h['trim']()||h['trim']()['startsWith']('#'))continue;const j=h['indexOf'](':');if(j===-0x1)throw new Error('invalid\x20frontmatter\x20line\x20'+(g+0x1)+':\x20\x27'+h['trim']()+'\x27\x20(expected\x20\x27key:\x20value\x27)');const k=h['slice'](0x0,j)['trim'](),l=h['slice'](j+0x1)['trim']();if(!k)throw new Error('invalid\x20frontmatter\x20line\x20'+(g+0x1)+':\x20empty\x20key');if(l['startsWith']('[')||l['startsWith']('{'))try{e[k]=JSON['parse'](l);}catch(m){throw new Error('frontmatter\x20key\x20\x27'+k+'\x27\x20is\x20not\x20valid\x20JSON:\x20'+m['message']);}else{if(/^-?\d+(\.\d+)?$/['test'](l))e[k]=Number(l);else{if(l['startsWith']('\x22')&&l['endsWith']('\x22')&&l['length']>=0x2||l['startsWith']('\x27')&&l['endsWith']('\x27')&&l['length']>=0x2){if(l[0x0]==='\x22')try{e[k]=JSON['parse'](l);}catch(n){throw new Error('frontmatter\x20key\x20\x27'+k+'\x27\x20is\x20not\x20valid\x20JSON:\x20'+n['message']);}else e[k]=l['slice'](0x1,-0x1);}else e[k]=l;}}}return{'frontmatter':e,'body':c['slice'](d+0x1)['join']('\x0a')['trim']()};}function frontmatterLine(a,b){if(typeof b==='number')return a+':\x20'+b;if(typeof b==='string')return a+':\x20'+b;return a+':\x20'+JSON['stringify'](b);}export const TEMPLATE_SENTINEL_KIND='industry-template';export function canonicalTemplateContent(a){const b=a,c=[['id',a['id']],['industry',a['industry']],['variant',a['variant']],['product_ref',a['product_ref']],['archetype',a['archetype']],['phase',a['phase']],['recommended_role',a['recommended_role']],['role_rationale',a['role_rationale']],['key_risk',a['key_risk']],['machine_shape',a['machine_shape']],['guards',a['guards']],['allocator',a['allocator']],['fee_params',a['fee_params']],['trust_mechanisms',a['trust_mechanisms']],['keeper_dependencies',a['keeper_dependencies']],...a['keeper_duty']?[['keeper_duty',a['keeper_duty']]]:[],['differences',a['differences']],['user_inputs',a['user_inputs']],...a['user_input_specs']?[['user_input_specs',a['user_input_specs']]]:[],['build_notes',a['build_notes']],...b['prose_language']?[['prose_language',b['prose_language']]]:[],...b['machine_prose']?[['machine_prose',b['machine_prose']]]:[],...a['evidence_refs']?[['evidence_refs',a['evidence_refs']]]:[],...a['conditional_guards']?[['conditional_guards',a['conditional_guards']]]:[],...a['time_anchors']?[['time_anchors',a['time_anchors']]]:[],...a['payment_model']?[['payment_model',a['payment_model']]]:[],...a['arbitration_mode']?[['arbitration_mode',a['arbitration_mode']]]:[],...a['review_mode']?[['review_mode',a['review_mode']]]:[],...a['experience_compensation_mode']?[['experience_compensation_mode',a['experience_compensation_mode']]]:[],...a['after_sales_mode']?[['after_sales_mode',a['after_sales_mode']]]:[],...a['acceptance_mode']?[['acceptance_mode',a['acceptance_mode']]]:[],...a['installment_mode']?[['installment_mode',a['installment_mode']]]:[],...a['affiliate_mode']?[['affiliate_mode',a['affiliate_mode']]]:[],...a['crowdfunding_mode']?[['crowdfunding_mode',a['crowdfunding_mode']]]:[],...a['logistics_mode']?[['logistics_mode',a['logistics_mode']]]:[],...a['reward_claim_policy']?[['reward_claim_policy',a['reward_claim_policy']]]:[],...a['compensation_fund_policy']?[['compensation_fund_policy',a['compensation_fund_policy']]]:[],...a['reentry_kind']&&a['reentry_kind']!=='none'?[['reentry_kind',a['reentry_kind']]]:[],...a['settlement_window_merge']?[['settlement_window_merge',a['settlement_window_merge']]]:[]],d=['---',...c['map'](([f,g])=>frontmatterLine(f,g)),'---'],e=['','#\x20'+a['industry']+'\x20/\x20'+a['variant']+'\x20('+a['archetype']+')','','>\x20Industry\x20archetype\x20template.\x20Editable\x20and\x20migratable:\x20the\x20frontmatter\x20is','>\x20zod-validated\x20on\x20every\x20load;\x20the\x20body\x20is\x20free-form\x20guidance\x20for\x20the\x20AI.','','##\x20Key\x20risk','',a['key_risk'],'','##\x20Differences\x20vs\x20the\x20sibling\x20variant','',...a['differences']['map'](f=>'-\x20'+f),'','##\x20Build-time\x20inputs\x20&\x20standing\x20constraints\x20(non-parameter)','',...a['user_inputs']['map'](f=>'-\x20'+f),...a['user_input_specs']&&a['user_input_specs']['length']>0x0?['','##\x20Structured\x20business\x20questions\x20(answer\x20rides\x20fee_overrides)','',...a['user_input_specs']['map'](f=>'-\x20\x22'+f['question']+'\x22\x20→\x20fee_overrides.'+f['param_key']+(f['note']?'\x20—\x20'+f['note']:''))]:[],'','##\x20Risk-avoidance\x20checklist\x20(R1-R10)','',...a['trust_mechanisms']['map'](f=>'-\x20'+f),'','##\x20Build\x20notes','',...a['build_notes']['map'](f=>'-\x20'+f),''];return[...d,...e]['join']('\x0a');}export function renderTemplateFile(a){const b=canonicalTemplateContent(a);return releaseSentinelLine(TEMPLATE_SENTINEL_KIND,BUILTIN_TEMPLATES_VERSION,releaseBodyHash(b))+'\x0a'+b;}export function templateCatalogDigest(a){const b=BUILTIN_TEMPLATES['find'](c=>c['id']===a);if(!b)return undefined;return releaseBodyHash(canonicalTemplateContent(b));}export const TEMPLATE_KNOBS_SENTINEL_KIND='template-knobs';export const TEMPLATE_KNOBS_VERSION=0x5;export const TemplateKnobOverlaySchema=TemplateFrontmatterSchema['pick']({'fee_params':!![],'key_risk':!![],'recommended_role':!![],'role_rationale':!![],'differences':!![],'user_inputs':!![],'payment_model':!![],'arbitration_mode':!![],'review_mode':!![],'experience_compensation_mode':!![],'after_sales_mode':!![],'acceptance_mode':!![],'installment_mode':!![],'affiliate_mode':!![],'crowdfunding_mode':!![],'logistics_mode':!![],'reward_claim_policy':!![],'reentry_kind':!![],'compensation_fund_policy':!![]})['partial']()['extend']({'id':z['string']()['regex'](/^[a-z][a-z0-9._-]*\/[a-z][a-z0-9._-]*$/,'knob\x20file\x20id\x20must\x20be\x20\x27<industry>/<variant>\x27')})['strict']();export function foldKnobFrontmatter(a){const b={},c={};for(const [d,e]of Object['entries'](a)){d['startsWith']('fee_params.')?c[d['slice']('fee_params.'['length'])]=e:b[d]=e;}if(Object['keys'](c)['length']>0x0)b['fee_params']=c;return b;}export function parseKnobFile(a,b){const c=stripReleaseSentinel(a,TEMPLATE_KNOBS_SENTINEL_KIND);let d;try{const f=parseTemplateFile(c['sentinel']?c['content']:a);d=f['frontmatter'];}catch{return null;}const e=TemplateKnobOverlaySchema['safeParse'](foldKnobFrontmatter(d));if(!e['success']||e['data']['id']!==b)return null;return e['data'];}function knobLine(a,b){if(typeof b==='number')return a+':\x20'+b;if(typeof b==='string')return/^-?\d+(\.\d+)?$/['test'](b)?a+':\x20\x27'+b+'\x27':a+':\x20'+b;return a+':\x20'+JSON['stringify'](b);}export function canonicalKnobContent(a){const b=['id:\x20'+a['id'],knobLine('key_risk',a['key_risk']),knobLine('recommended_role',a['recommended_role']),knobLine('role_rationale',a['role_rationale']),...Object['keys'](a['fee_params'])['sort']()['flatMap'](d=>[...knobDocLines(d),knobLine('fee_params.'+d,a['fee_params'][d])]),...a['payment_model']!==undefined?[knobLine('payment_model',a['payment_model'])]:[],...a['arbitration_mode']!==undefined?[knobLine('arbitration_mode',a['arbitration_mode'])]:[],...a['review_mode']!==undefined?[knobLine('review_mode',a['review_mode'])]:[],...a['experience_compensation_mode']!==undefined?[knobLine('experience_compensation_mode',a['experience_compensation_mode'])]:[],...a['after_sales_mode']!==undefined?[knobLine('after_sales_mode',a['after_sales_mode'])]:[],...a['acceptance_mode']!==undefined?[knobLine('acceptance_mode',a['acceptance_mode'])]:[],...a['installment_mode']!==undefined?[knobLine('installment_mode',a['installment_mode'])]:[],...a['affiliate_mode']!==undefined?[knobLine('affiliate_mode',a['affiliate_mode'])]:[],...a['crowdfunding_mode']!==undefined?[knobLine('crowdfunding_mode',a['crowdfunding_mode'])]:[],...a['logistics_mode']!==undefined?[knobLine('logistics_mode',a['logistics_mode'])]:[],...a['reward_claim_policy']!==undefined?[knobLine('reward_claim_policy',a['reward_claim_policy'])]:[],...a['reentry_kind']!==undefined&&a['reentry_kind']!=='none'?[knobLine('reentry_kind',a['reentry_kind'])]:[],...a['compensation_fund_policy']!==undefined?[knobLine('compensation_fund_policy',a['compensation_fund_policy'])]:[],knobLine('differences',a['differences']),knobLine('user_inputs',a['user_inputs'])],c=['','#\x20'+a['industry']+'\x20/\x20'+a['variant']+'\x20('+a['archetype']+')\x20—\x20business\x20knobs','','>\x20THIS\x20file\x20is\x20the\x20one\x20you\x20edit.\x20Each\x20line\x20above\x20the\x20body\x20is\x20a\x20knob\x20the','>\x20build\x20honors:\x20`fee_params.<name>`\x20(numbers\x20—\x20pricing\x20windows,\x20caps,','>\x20pools),\x20the\x20mode\x20switches\x20(review/arbitration/logistics/...),\x20and\x20the','>\x20guidance\x20prose\x20below.\x20Lines\x20starting\x20with\x20`#`\x20are\x20read-only\x20docs\x20for','>\x20the\x20knob\x20line\x20below\x20them\x20—\x20edit\x20the\x20value\x20line,\x20never\x20the\x20`#`\x20lines','>\x20(docs\x20refresh\x20with\x20each\x20release).\x20The\x20workflow\x20structure\x20itself','>\x20(nodes,\x20guards,\x20fund\x20rails)\x20is\x20system-managed\x20in\x20a\x20hidden\x20`.machine/`','>\x20file\x20next\x20to\x20this\x20one\x20and\x20is\x20deliberately\x20not\x20exposed\x20—\x20change','>\x20business\x20intent\x20through\x20these\x20knobs\x20or\x20through\x20the\x20migration\x20wizard,','>\x20never\x20by\x20editing\x20node\x20graphs\x20by\x20hand.','','##\x20Key\x20risk','',...wrapParagraph(a['key_risk']),'','##\x20Differences\x20vs\x20the\x20sibling\x20variant','',...a['differences']['flatMap'](e=>wrapBullet(e)),'','##\x20Build-time\x20inputs\x20&\x20standing\x20constraints\x20(non-parameter)','',...a['user_inputs']['flatMap'](d=>wrapBullet(d)),'','##\x20Your\x20notes\x20(free-form\x20—\x20the\x20AI\x20reads\x20this\x20body\x20as\x20guidance)','','-\x20(Add\x20your\x20own\x20pricing,\x20tone,\x20or\x20policy\x20notes\x20below\x20—\x20they\x20override\x20the','\x20\x20generic\x20guidance\x20the\x20same\x20way\x20playbook.md\x20does.)',''];return['---',...b,'---',...c]['join']('\x0a');}export function renderKnobFile(a){const b=canonicalKnobContent(a);return releaseSentinelLine(TEMPLATE_KNOBS_SENTINEL_KIND,TEMPLATE_KNOBS_VERSION,releaseBodyHash(b))+'\x0a'+b;}export function classifyKnobFile(a,b){const c=stripReleaseSentinel(a,TEMPLATE_KNOBS_SENTINEL_KIND);if(!c['sentinel'])return null;if(parseKnobFile(c['content'],b)===null)return null;const d=classifyRelease(c['sentinel'],c['content'],TEMPLATE_KNOBS_VERSION);return d==='user_file'?null:d;}export function applyKnobOverlay(a,b,c){const d=b['fee_params']!==undefined?Object['keys'](b['fee_params'])['filter'](e=>!(e in a['fee_params'])):[];if(d['length']>0x0)throw new Error('template\x20\x27'+a['id']+'\x27\x20—\x20knob\x20overlay\x20declares\x20fee_params\x20key(s)\x20unknown\x20to\x20the\x20machine\x20layer:\x20'+d['join'](',\x20')+'.\x20'+'Knobs\x20are\x20a\x20pure\x20override\x20surface\x20(D2/F-03\x20single\x20source\x20of\x20truth):\x20a\x20key\x20the\x20.machine\x20template\x20does\x20not\x20declare\x20'+'cannot\x20land\x20and\x20would\x20silently\x20fork\x20the\x20template\x20into\x20two\x20truths.\x20Declare\x20it\x20in\x20the\x20machine\x20template\x20instead.');return{...a,...b['fee_params']!==undefined?{'fee_params':{...a['fee_params'],...b['fee_params']}}:{},...b['key_risk']!==undefined?{'key_risk':b['key_risk']}:{},...b['recommended_role']!==undefined?{'recommended_role':b['recommended_role']}:{},...b['role_rationale']!==undefined?{'role_rationale':b['role_rationale']}:{},...b['differences']!==undefined?{'differences':b['differences']}:{},...b['user_inputs']!==undefined?{'user_inputs':b['user_inputs']}:{},...b['payment_model']!==undefined?{'payment_model':b['payment_model']}:{},...b['arbitration_mode']!==undefined?{'arbitration_mode':b['arbitration_mode']}:{},...b['review_mode']!==undefined?{'review_mode':b['review_mode']}:{},...b['experience_compensation_mode']!==undefined?{'experience_compensation_mode':b['experience_compensation_mode']}:{},...b['after_sales_mode']!==undefined?{'after_sales_mode':b['after_sales_mode']}:{},...b['acceptance_mode']!==undefined?{'acceptance_mode':b['acceptance_mode']}:{},...b['installment_mode']!==undefined?{'installment_mode':b['installment_mode']}:{},...b['affiliate_mode']!==undefined?{'affiliate_mode':b['affiliate_mode']}:{},...b['crowdfunding_mode']!==undefined?{'crowdfunding_mode':b['crowdfunding_mode']}:{},...b['logistics_mode']!==undefined?{'logistics_mode':b['logistics_mode']}:{},...b['reward_claim_policy']!==undefined?{'reward_claim_policy':b['reward_claim_policy']}:{},...b['reentry_kind']!==undefined?{'reentry_kind':b['reentry_kind']}:{},...b['compensation_fund_policy']!==undefined?{'compensation_fund_policy':b['compensation_fund_policy']}:{},'body':c};}function machineTemplateFile(a,b){return join(a,b['industry'],TEMPLATES_SUBDIR,MACHINE_TEMPLATES_SUBDIR,b['variant']+'.md');}function knobTemplateFile(a,b){return join(a,b['industry'],TEMPLATES_SUBDIR,b['variant']+'.md');}function archiveBackupFile(a,b,c){return join(a,b['industry'],TEMPLATES_SUBDIR,TEMPLATE_ARCHIVE_SUBDIR,''+b['variant']+c);}export function matchBuiltinTemplateSlot(a){const b=relative(resolveTemplatesDir(),a);if(!b||b['startsWith']('..'))return null;const c=b['split'](sep);if(c['length']===0x4&&c[0x1]===TEMPLATES_SUBDIR&&c[0x2]===MACHINE_TEMPLATES_SUBDIR&&c[0x3]['endsWith']('.md')){const d=c[0x3]['slice'](0x0,-'.md'['length']),e=BUILTIN_TEMPLATES['find'](f=>f['industry']===c[0x0]&&f['variant']===d)??null;return e?{'template':e,'part':'machine'}:null;}if(c['length']===0x3&&c[0x1]===TEMPLATES_SUBDIR&&c[0x2]['endsWith']('.md')){const f=c[0x2]['slice'](0x0,-'.md'['length']),g=BUILTIN_TEMPLATES['find'](h=>h['industry']===c[0x0]&&h['variant']===f)??null;return g?{'template':g,'part':'knobs'}:null;}return null;}let seeded=![];export function seedBuiltinTemplates(){const a=[],b=resolveTemplatesDir();for(const c of BUILTIN_TEMPLATES){const d=machineTemplateFile(b,c),e=knobTemplateFile(b,c),f=dirname(d),g=canonicalTemplateContent(c),h={'template':c['id'],'status':'written','path':d};try{if(!existsSync(d))mkdirSync(f,{'recursive':!![]}),writeFileSync(d,renderTemplateFile(c),'utf-8');else{const i=readFileSync(d,'utf-8'),{sentinel:j,content:k}=stripReleaseSentinel(i,TEMPLATE_SENTINEL_KIND);!j?k===g?(writeFileSync(d,renderTemplateFile(c),'utf-8'),h['status']='restamped',h['detail']='body\x20matches\x20canonical\x20but\x20no\x20sentinel\x20present;\x20sentinel\x20header\x20added,\x20body\x20untouched'):(h['status']='skipped_user_file',h['detail']='machine\x20file\x20exists\x20without\x20builtin\x20sentinel\x20and\x20body\x20differs\x20from\x20canonical;\x20leaving\x20user\x20file\x20untouched'):k===g?j['version']!==BUILTIN_TEMPLATES_VERSION||releaseBodyHash(k)!==j['hash']?(writeFileSync(d,renderTemplateFile(c),'utf-8'),h['status']='restamped',h['detail']='body\x20matches\x20canonical\x20but\x20sentinel\x20stale/wrong;\x20header\x20refreshed,\x20body\x20untouched'):h['status']='current':(h['status']='skipped_modified',h['detail']='body\x20differs\x20from\x20canonical;\x20not\x20overwritten\x20by\x20seeding\x20—\x20use\x20repair_builtin_templates\x20(preview→confirm)\x20to\x20reseed');}}catch(l){h['status']='error',h['detail']=l['message'];}a['push'](h);try{a['push'](seedKnobSlot(b,c));}catch(m){a['push']({'template':c['id'],'status':'error','path':e,'detail':m['message']});}}try{a['push'](...seedIndustryNavPages(b));}catch{}return a;}function seedKnobSlot(a,b){const c=knobTemplateFile(a,b),d={'template':b['id'],'status':'knob_written','path':c};if(!existsSync(c))return mkdirSync(dirname(c),{'recursive':!![]}),writeFileSync(c,renderKnobFile(b),'utf-8'),d['detail']='knob\x20file\x20written\x20(fresh)',d;const e=readFileSync(c,'utf-8'),f=classifyKnobFile(e,b['id']);if(f==='current')return{...d,'status':'knob_current'};if(f==='outdated')return writeFileSync(c,renderKnobFile(b),'utf-8'),{...d,'status':'knob_current','detail':'unmodified\x20older\x20knob\x20release\x20auto-upgraded\x20to\x20the\x20current\x20render'};if(f==='user_modified')return{...d,'status':'knob_kept_user','detail':'user-edited\x20knobs\x20kept\x20by\x20design\x20(never\x20overwritten)'};let g;try{g=String(parseTemplateFile(e)['frontmatter']['id']??'');}catch{g=undefined;}if(g!==b['id'])return{...d,'status':'skipped_user_file','detail':'a\x20non-knob\x20file\x20(id\x20\x27'+(g??'<unparseable>')+'\x27)\x20occupies\x20the\x20knob\x20slot;\x20machine\x20template\x20wins,\x20file\x20untouched\x20—\x20rename\x20it\x20to\x20free\x20the\x20slot'};const h=join(dirname(c),TEMPLATE_ARCHIVE_SUBDIR);mkdirSync(h,{'recursive':!![]});const i=join(h,b['variant']+'.pre-split.md');return writeFileSync(i,e,'utf-8'),rmSync(c,{'force':!![]}),writeFileSync(c,renderKnobFile(b),'utf-8'),{...d,'status':'knob_written','detail':'obsolete\x20pre-S8\x20single-file\x20template\x20retired\x20to\x20'+i+';\x20knob\x20file\x20re-rendered\x20from\x20the\x20current\x20catalog'};}function seedIndustryNavPages(a){const b=[],c=new Map();for(const d of BUILTIN_TEMPLATES){const e=c['get'](d['industry'])??[];e['push'](d),c['set'](d['industry'],e);}for(const [f,g]of[...c['entries']()]['sort']()){const h=join(a,f,INDUSTRY_NAV_FILENAME),i={'template':'nav/'+f,'status':'written','path':h};try{if(!existsSync(h))mkdirSync(dirname(h),{'recursive':!![]}),writeFileSync(h,renderIndustryNav(f,g),'utf-8');else{const j=classifyIndustryNav(readFileSync(h,'utf-8'));if(j==='current')i['status']='current';else j==='outdated'?(writeFileSync(h,renderIndustryNav(f,g),'utf-8'),i['status']='restamped',i['detail']='unmodified\x20older\x20nav\x20page\x20auto-upgraded'):(i['status']='skipped_modified',i['detail']='nav\x20page\x20user-edited;\x20kept\x20by\x20design');}}catch(k){i['status']='error',i['detail']=k['message'];}b['push'](i);}return b;}export function summarizeTemplateDiff(a,b){let c,d;try{c=parseTemplateFile(a);}catch(g){return'on-disk\x20file\x20is\x20not\x20parseable\x20('+g['message']+');\x20full\x20content\x20will\x20be\x20replaced';}try{d=parseTemplateFile(b);}catch{return'canonical\x20render\x20is\x20not\x20parseable\x20(code\x20defect);\x20full\x20content\x20will\x20be\x20replaced';}const e=[],f=new Set([...Object['keys'](c['frontmatter']),...Object['keys'](d['frontmatter'])]);for(const h of[...f]['sort']()){const i=h in c['frontmatter'],j=h in d['frontmatter'];if(i&&!j)e['push']('-'+h);else{if(!i&&j)e['push']('+'+h);else{if(JSON['stringify'](c['frontmatter'][h])!==JSON['stringify'](d['frontmatter'][h]))e['push']('~'+h);}}}return c['body']!==d['body']&&e['push']('~body\x20('+c['body']['split']('\x0a')['length']+'\x20->\x20'+d['body']['split']('\x0a')['length']+'\x20lines)'),e['length']>0x0?e['join'](',\x20'):'whitespace/ordering\x20only';}export function repairBuiltinTemplates(a){const b=[],c=resolveTemplatesDir(),d=a?.['backup']!==![],e=a?.['dryRun']===!![],f=new Set(a?.['includeUserEdited']??[]);for(const g of BUILTIN_TEMPLATES){const h=machineTemplateFile(c,g);if(!existsSync(h))continue;const i=canonicalTemplateContent(g);let j=null,k='';const l={'template':g['id'],'status':'would_update','path':h};try{const p=stripReleaseSentinel(readFileSync(h,'utf-8'),TEMPLATE_SENTINEL_KIND);j=p['sentinel'],k=p['content'];}catch(q){l['status']='error',l['detail']=q['message'],b['push'](l);continue;}if(k===i)continue;let m;if(j){if(j['version']>BUILTIN_TEMPLATES_VERSION){l['status']='error',l['detail']='newer\x20release\x20on\x20disk\x20(sentinel\x20v'+j['version']+'\x20>\x20running\x20catalog\x20v'+BUILTIN_TEMPLATES_VERSION+')\x20—\x20'+'repair\x20would\x20DOWNGRADE\x20and\x20lose\x20the\x20newer\x20release\x27s\x20content;\x20refused.\x20Upgrade\x20the\x20MCP\x20server\x20instead',b['push'](l);continue;}if(releaseBodyHash(k)!==j['hash']){if(!f['has'](g['id']))continue;m='sentinel-body\x20hash\x20mismatch\x20(sentinel\x20v'+j['version']+'\x20no\x20longer\x20binds\x20the\x20body)\x20'+'reseeded\x20under\x20EXPLICIT\x20include_user_edited\x20authorization';}else m='untouched\x20older\x20release\x20(sentinel\x20v'+j['version']+',\x20current\x20v'+BUILTIN_TEMPLATES_VERSION+')';}else{let r;try{r=String(parseTemplateFile(k)['frontmatter']['id']??'');}catch{continue;}if(r!==g['id'])continue;m='legacy\x20sentinel-less\x20builtin\x20file';}const n=summarizeTemplateDiff(k,i),o=d?';\x20previous\x20body\x20would\x20be\x20saved\x20in\x20templates/.archive/':'';if(e){l['status']='would_update',l['detail']=m+'\x20would\x20be\x20reseeded\x20from\x20BUILTIN_TEMPLATES\x20('+g['id']+')\x20—\x20diff\x20vs\x20canonical:\x20'+n+o+'\x20—\x20execute\x20with\x20authorize=true\x20after\x20the\x20user\x20explicitly\x20confirms',b['push'](l);continue;}try{if(d){const s=archiveBackupFile(c,g,'.repair.md');mkdirSync(dirname(s),{'recursive':!![]}),copyFileSync(h,s);}writeFileSync(h,renderTemplateFile(g),'utf-8'),cache['delete'](h),l['status']='updated',l['detail']=m+'\x20reseeded\x20from\x20BUILTIN_TEMPLATES\x20('+g['id']+')\x20—\x20diff\x20was:\x20'+n+(d?';\x20previous\x20body\x20saved\x20in\x20templates/.archive/':'');}catch(u){l['status']='error',l['detail']=u['message'];}b['push'](l);}return b;}export function builtinTemplateDrift(a){const b=new Set(a?.['includeUserEdited']??[]),c=[],d=resolveTemplatesDir();for(const e of BUILTIN_TEMPLATES){const f=machineTemplateFile(d,e);if(!existsSync(f)){c['push']({'template':e['id'],'path':f,'state':'missing','repairable':!![],'detail':'no\x20file\x20on\x20disk;\x20seeding\x20will\x20create\x20it'});continue;}const g=canonicalTemplateContent(e);let h=null,i='';try{const k=stripReleaseSentinel(readFileSync(f,'utf-8'),TEMPLATE_SENTINEL_KIND);h=k['sentinel'],i=k['content'];}catch(l){c['push']({'template':e['id'],'path':f,'state':'modified','repairable':![],'detail':'unreadable:\x20'+l['message']});continue;}if(i===g)continue;const j=summarizeTemplateDiff(i,g);if(!h){let m;try{m=String(parseTemplateFile(i)['frontmatter']['id']??'');}catch{m=undefined;}m===e['id']?c['push']({'template':e['id'],'path':f,'state':'modified','repairable':!![],'detail':'legacy\x20sentinel-less\x20builtin\x20file\x20—\x20seeding\x20never\x20rewrites\x20it\x20and\x20no\x20sentinel\x20proves\x20provenance;\x20repair\x20can\x20reseed\x20—\x20diff\x20vs\x20canonical:\x20'+j}):c['push']({'template':e['id'],'path':f,'state':'modified','repairable':![],'detail':'no\x20release\x20sentinel\x20and\x20id\x20\x27'+(m??'<unparseable>')+'\x27\x20does\x20not\x20match\x20the\x20builtin\x20id\x20—\x20a\x20user\x20file\x20occupies\x20this\x20path;\x20never\x20touched\x20(rename\x20it\x20to\x20free\x20the\x20slot)'});continue;}if(releaseBodyHash(i)===h['hash'])h['version']>BUILTIN_TEMPLATES_VERSION?c['push']({'template':e['id'],'path':f,'state':'modified','repairable':![],'detail':'newer\x20release\x20(sentinel\x20v'+h['version']+'\x20>\x20running\x20catalog\x20v'+BUILTIN_TEMPLATES_VERSION+')\x20—\x20'+'repair\x20would\x20DOWNGRADE\x20and\x20lose\x20the\x20newer\x20release\x27s\x20content;\x20repairable:\x20false.\x20'+'Upgrade\x20the\x20MCP\x20server\x20to\x20match\x20—\x20diff\x20vs\x20canonical:\x20'+j}):c['push']({'template':e['id'],'path':f,'state':'modified','repairable':!![],'detail':'untouched\x20older\x20release\x20(sentinel\x20v'+h['version']+',\x20current\x20v'+BUILTIN_TEMPLATES_VERSION+')\x20—\x20repair\x20can\x20upgrade\x20—\x20diff\x20vs\x20canonical:\x20'+j});else{const n=b['has'](e['id']);c['push']({'template':e['id'],'path':f,'state':'modified','repairable':n,'detail':n?'sentinel-body\x20hash\x20mismatch\x20(sentinel\x20v'+h['version']+'\x20no\x20longer\x20binds\x20the\x20body)\x20—\x20reseedable\x20under\x20the\x20explicit\x20include_user_edited\x20authorization\x20for\x20this\x20id\x20—\x20diff\x20vs\x20canonical:\x20'+j:'user-edited\x20body\x20—\x20kept\x20by\x20design;\x20repair\x20never\x20overwrites\x20user\x20edits\x20—\x20diff\x20vs\x20canonical:\x20'+j});}}for(const o of c){const p=BUILTIN_TEMPLATES['find'](q=>q['id']===o['template']);if(p)o['knob_state']=knobFileState(d,p);}return c;}function knobFileState(a,b){const c=knobTemplateFile(a,b);if(!existsSync(c))return'missing';try{return classifyKnobFile(readFileSync(c,'utf-8'),b['id'])==='user_modified'?'user_modified':'current';}catch{return'current';}}export function templateTruthStamps(a){const b=resolveTemplatesDir(),c=BUILTIN_TEMPLATES['find'](n=>n['id']===a);if(!c){const n=getTemplate(a),o=n?.['source_path'];if(!o||!existsSync(o))return{'template':a,'source':'user','content_sha256':'','machine_layer':null,'knob_layer':null,'consistency':'user_template'};const {content:q}=stripReleaseSentinel(readFileSync(o,'utf-8'),TEMPLATE_SENTINEL_KIND);return{'template':a,'source':'user','content_sha256':releaseBodyHash(q),'machine_layer':null,'knob_layer':null,'consistency':'user_template'};}const d=machineTemplateFile(b,c);let e='',f=null;if(existsSync(d)){const r=stripReleaseSentinel(readFileSync(d,'utf-8'),TEMPLATE_SENTINEL_KIND);f=r['sentinel'],e=r['content'];}const g=canonicalTemplateContent(c),h=f!==null&&releaseBodyHash(e)===f['hash'],i=e===g,j=i?undefined:summarizeTemplateDiff(e,g),k=knobTemplateFile(b,c);let l;if(!existsSync(k))l={'path':k,'state':'missing','override_keys':[]};else{const s=readFileSync(k,'utf-8'),t=classifyKnobFile(s,c['id']),u=t!==null?parseKnobFile(stripReleaseSentinel(s,TEMPLATE_KNOBS_SENTINEL_KIND)['content'],c['id']):null,v=u?[...u['fee_params']!==undefined?Object['keys'](u['fee_params'])['map'](w=>'fee_params.'+w):[],...Object['keys'](u)['filter'](w=>w!=='id'&&w!=='fee_params')]:[];l={'path':k,'state':t??'invalid','override_keys':v};}const m=!i||f!==null&&!h;return{'template':a,'source':'builtin','schema_version':BUILTIN_TEMPLATES_VERSION,'content_sha256':releaseBodyHash(e),'machine_layer':{'path':d,'sentinel':f,'sentinel_binds_body':h,'matches_catalog':i},'knob_layer':l,'consistency':m?'drifted':'verified',...m&&j!==undefined?{'differences':j}:{}};}const cache=new Map();export function reloadTemplates(){cache['clear'](),seeded=![];}export function loadAndValidate(a){const b=readFileSync(a,'utf-8');let c;try{c=parseTemplateFile(b);}catch(g){throw new Error('template\x20\x27'+a+'\x27\x20failed\x20to\x20parse:\x20'+g['message']);}const d=TemplateFrontmatterSchema['safeParse'](c['frontmatter']);if(!d['success']){const h=d['error']['issues']['map'](j=>(j['path']['join']('.')||'<root>')+':\x20'+j['message'])['join'](';\x20');throw new Error('template\x20\x27'+a+'\x27\x20failed\x20validation:\x20'+h);}const e=validateAllocatorRows(d['data']);if(e['length']>0x0)throw new Error('template\x20\x27'+a+'\x27\x20failed\x20allocator-row\x20validation:\x20'+e['join'](';\x20'));const f=userInputSpecIssues(d['data']);if(f['length']>0x0)throw new Error('template\x20\x27'+a+'\x27\x20failed\x20user_input_specs\x20validation:\x20'+f['join'](';\x20'));return{...d['data'],'body':c['body'],'source_path':a};}function templateFilesOnDisk(a){const b=[];if(!existsSync(a))return b;const c=new Set(BUILTIN_TEMPLATES['map'](d=>d['industry']+'/'+d['variant']));for(const d of readdirSync(a,{'withFileTypes':!![]})){if(!d['isDirectory']())continue;const e=join(a,d['name'],TEMPLATES_SUBDIR);if(!existsSync(e))continue;const g=join(e,MACHINE_TEMPLATES_SUBDIR);if(existsSync(g))for(const h of readdirSync(g,{'withFileTypes':!![]})){if(!h['isFile']()||!h['name']['endsWith']('.md'))continue;const i=h['name']['slice'](0x0,-'.md'['length']),j=c['has'](d['name']+'/'+i)?join(e,h['name']):null;b['push']({'file':join(g,h['name']),'id':d['name']+'/'+i,'knobFile':j});}for(const k of readdirSync(e,{'withFileTypes':!![]})){if(!k['isFile']()||!k['name']['endsWith']('.md'))continue;const l=k['name']['slice'](0x0,-'.md'['length']);if(c['has'](d['name']+'/'+l))continue;b['push']({'file':join(e,k['name']),'id':d['name']+'/'+l,'knobFile':null});}}return b['sort']((m,n)=>m['file']['localeCompare'](n['file']));}export function listTemplates(){!seeded&&(seedBuiltinTemplates(),seeded=!![]);const a=resolveTemplatesDir(),b=[],c=[],d=new Map(),e=new Set();for(const {file:f,id:g,knobFile:h}of templateFilesOnDisk(a)){e['add'](f);try{const i=statSync(f)['mtimeMs'],j=h&&existsSync(h)?statSync(h)['mtimeMs']:0x0,k=cache['get'](f);if(k&&k['mtimeMs']===i&&k['knobMtimeMs']===j){b['push'](k['template']);continue;}let l=loadAndValidate(f);if(h&&j>0x0){const m=readFileSync(h,'utf-8'),n=parseKnobFile(m,l['id']);if(n){l=applyKnobOverlay(l,n,parseTemplateFile(m)['body']);const o=validateAllocatorRows(l);if(o['length']>0x0)throw new Error('template\x20\x27'+f+'\x27\x20—\x20knob\x20overlay\x20\x27'+h+'\x27\x20broke\x20allocator-row\x20validation:\x20'+o['join'](';\x20'));}else c['push']('knob\x20file\x20\x27'+h+'\x27\x20is\x20not\x20a\x20valid\x20knob\x20overlay\x20for\x20\x27'+l['id']+'\x27\x20—\x20ignored,\x20machine\x20template\x20used\x20as-is');}cache['set'](f,{'mtimeMs':i,'knobMtimeMs':j,'template':l}),b['push'](l);}catch(p){cache['delete'](f),c['push'](p['message']),d['set'](g,p['message']);}}for(const q of[...cache['keys']()]){if(!e['has'](q))cache['delete'](q);}return b['sort']((r,s)=>r['id']['localeCompare'](s['id'])),loadErrorsById=d,{'templates':b,'errors':c};}let loadErrorsById=new Map();export function getTemplateLoadError(a){return listTemplates(),loadErrorsById['get'](a);}export function getTemplate(a){return listTemplates()['templates']['find'](b=>b['id']===a);}export function getTemplatesByIndustry(a){return listTemplates()['templates']['filter'](b=>b['industry']===a);}
|