@wowok/agent-mcp 2.7.1 → 2.7.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/config/index.js +1 -1
- package/dist/config/runtime.js +1 -238
- package/dist/customer/account-events.d.ts +32 -0
- package/dist/customer/account-events.js +1 -0
- package/dist/customer/customer-advice.d.ts +1 -0
- package/dist/customer/customer-advice.js +1 -130
- package/dist/customer/index.js +1 -11
- package/dist/customer/industry-risks.js +1 -438
- package/dist/customer/info-puzzle.js +1 -681
- package/dist/customer/order-monitor.js +1 -328
- package/dist/customer/order-strategy.d.ts +1 -1
- package/dist/customer/order-strategy.js +1 -373
- package/dist/customer/post-purchase.js +1 -351
- package/dist/customer/preorder-compare.js +1 -34
- package/dist/customer/reminder-system.d.ts +2 -0
- package/dist/customer/reminder-system.js +1 -316
- package/dist/customer/risk-assessment.d.ts +1 -0
- package/dist/customer/risk-assessment.js +1 -397
- package/dist/customer/types.d.ts +2 -0
- package/dist/customer/types.js +1 -13
- package/dist/customer/user-preferences.js +1 -460
- package/dist/evaluation/arbitration-game.d.ts +9 -2
- package/dist/evaluation/arbitration-game.js +1 -48
- package/dist/evaluation/builtins/arbitration-score.d.ts +41 -0
- package/dist/evaluation/builtins/arbitration-score.js +1 -0
- package/dist/evaluation/builtins/demand-match.js +1 -153
- package/dist/evaluation/builtins/index.d.ts +1 -0
- package/dist/evaluation/builtins/index.js +1 -10
- package/dist/evaluation/builtins/service-risk.js +1 -55
- package/dist/evaluation/capability.js +1 -13
- package/dist/evaluation/category-match-rules.d.ts +30 -0
- package/dist/evaluation/category-match-rules.js +1 -0
- package/dist/evaluation/composer.js +1 -40
- package/dist/evaluation/engine.js +1 -175
- package/dist/evaluation/extract.js +1 -115
- package/dist/evaluation/game-strategy.d.ts +27 -0
- package/dist/evaluation/game-strategy.js +1 -0
- package/dist/evaluation/gap.js +1 -100
- package/dist/evaluation/index.d.ts +2 -0
- package/dist/evaluation/index.js +1 -11
- package/dist/evaluation/location-match.d.ts +42 -0
- package/dist/evaluation/location-match.js +1 -0
- package/dist/evaluation/node-game.d.ts +31 -3
- package/dist/evaluation/node-game.js +1 -57
- package/dist/evaluation/path-reasoning.d.ts +35 -0
- package/dist/evaluation/path-reasoning.js +1 -0
- package/dist/evaluation/region.d.ts +6 -0
- package/dist/evaluation/region.js +1 -36
- package/dist/evaluation/types.d.ts +18 -0
- package/dist/evaluation/types.js +1 -1
- package/dist/evaluation/user-injection.js +1 -27
- package/dist/experience/experience-reuse.js +1 -103
- package/dist/experience/index.js +1 -5
- package/dist/experience/intent-distill.js +1 -83
- package/dist/experience/realtime-feedback.js +1 -94
- package/dist/experience/types.js +1 -1
- package/dist/experience/user-profile.d.ts +1 -1
- package/dist/experience/user-profile.js +1 -171
- package/dist/extensions/business-modules.js +1 -287
- package/dist/extensions/capability-manifest.js +1 -781
- package/dist/extensions/constraint-registry.js +1 -198
- package/dist/extensions/index.d.ts +6 -0
- package/dist/extensions/index.js +1 -6
- package/dist/extensions/industry-layers.d.ts +75 -0
- package/dist/extensions/industry-layers.js +1 -0
- package/dist/extensions/industry-pack.d.ts +105 -0
- package/dist/extensions/industry-pack.js +1 -0
- package/dist/extensions/metric-registry.js +1 -257
- package/dist/extensions/mode-evaluator.d.ts +1 -1
- package/dist/extensions/mode-evaluator.js +1 -170
- package/dist/extensions/modes.js +1 -499
- package/dist/extensions/registry.d.ts +1 -0
- package/dist/extensions/registry.js +1 -717
- package/dist/extensions/types.js +1 -1
- package/dist/graph/base.d.ts +8 -0
- package/dist/graph/base.js +1 -0
- package/dist/harness/auto-escalation.js +1 -68
- package/dist/harness/checkpoint.js +1 -129
- package/dist/harness/index.d.ts +1 -0
- package/dist/harness/index.js +1 -78
- package/dist/harness/plan.d.ts +2 -0
- package/dist/harness/plan.js +1 -315
- package/dist/harness/recover.d.ts +1 -1
- package/dist/harness/recover.js +1 -139
- package/dist/harness/types.d.ts +2 -3
- package/dist/harness/types.js +1 -1
- package/dist/harness/verify.js +1 -237
- package/dist/index.js +1 -273
- package/dist/intent/enrich.js +1 -67
- package/dist/intent/index.js +1 -60
- package/dist/intent/matcher.js +1 -81
- package/dist/intent/store.js +1 -55
- package/dist/intent/types.js +1 -10
- package/dist/knowledge/acquisition-flywheel.js +1 -192
- package/dist/knowledge/allocation-confirm.js +1 -534
- package/dist/knowledge/allocation-context.js +1 -249
- package/dist/knowledge/allocation-ledger.js +1 -463
- package/dist/knowledge/allocation-puzzle.js +1 -298
- package/dist/knowledge/allocation-risk.js +1 -568
- package/dist/knowledge/allocation-templates.js +1 -970
- package/dist/knowledge/allocation-translation.js +1 -585
- package/dist/knowledge/anti-cheat.d.ts +37 -0
- package/dist/knowledge/anti-cheat.js +1 -0
- package/dist/knowledge/arb-confirm.d.ts +28 -0
- package/dist/knowledge/arb-confirm.js +1 -0
- package/dist/knowledge/arb-risk.js +1 -210
- package/dist/knowledge/arb-translation.d.ts +48 -0
- package/dist/knowledge/arb-translation.js +1 -0
- package/dist/knowledge/arbitration-confirm.js +1 -559
- package/dist/knowledge/arbitration-context.js +1 -505
- package/dist/knowledge/arbitration-ledger.js +1 -521
- package/dist/knowledge/arbitration-puzzle.js +1 -304
- package/dist/knowledge/arbitration-risk.js +1 -423
- package/dist/knowledge/arbitration-templates.js +1 -276
- package/dist/knowledge/arbitration-translation.js +1 -487
- package/dist/knowledge/audit-rules.js +1 -141
- package/dist/knowledge/bridge-confirm.d.ts +26 -0
- package/dist/knowledge/bridge-confirm.js +1 -0
- package/dist/knowledge/bridge-risk.js +1 -263
- package/dist/knowledge/bridge-translation.d.ts +37 -0
- package/dist/knowledge/bridge-translation.js +1 -0
- package/dist/knowledge/contact-confirm.d.ts +27 -0
- package/dist/knowledge/contact-confirm.js +1 -0
- package/dist/knowledge/contact-risk.js +1 -200
- package/dist/knowledge/contact-templates.js +1 -60
- package/dist/knowledge/contact-translation.d.ts +39 -0
- package/dist/knowledge/contact-translation.js +1 -0
- package/dist/knowledge/demand-confirm.js +1 -206
- package/dist/knowledge/demand-context.d.ts +17 -0
- package/dist/knowledge/demand-context.js +1 -0
- package/dist/knowledge/demand-ledger.d.ts +26 -0
- package/dist/knowledge/demand-ledger.js +1 -0
- package/dist/knowledge/demand-matching.js +1 -132
- package/dist/knowledge/demand-puzzle.d.ts +29 -0
- package/dist/knowledge/demand-puzzle.js +1 -0
- package/dist/knowledge/demand-risk.js +1 -240
- package/dist/knowledge/demand-templates.d.ts +12 -0
- package/dist/knowledge/demand-templates.js +1 -0
- package/dist/knowledge/demand-translation.js +1 -354
- package/dist/knowledge/deployment-scanner.js +1 -823
- package/dist/knowledge/dynamic-pricing.js +1 -87
- package/dist/knowledge/evidence-review.d.ts +12 -0
- package/dist/knowledge/evidence-review.js +1 -0
- package/dist/knowledge/examples-scanner-cli.js +1 -26
- package/dist/knowledge/examples-scanner.js +1 -843
- package/dist/knowledge/flywheel-loop.d.ts +0 -1
- package/dist/knowledge/flywheel-loop.js +1 -404
- package/dist/knowledge/fund-layer.js +1 -973
- package/dist/knowledge/glossary.js +1 -211
- package/dist/knowledge/guard-confirm.js +1 -406
- package/dist/knowledge/guard-context.js +1 -287
- package/dist/knowledge/guard-design-patterns.js +1 -360
- package/dist/knowledge/guard-ledger.js +1 -260
- package/dist/knowledge/guard-lint.js +1 -670
- package/dist/knowledge/guard-migration.d.ts +1 -1
- package/dist/knowledge/guard-migration.js +1 -228
- package/dist/knowledge/guard-puzzle.js +1 -805
- package/dist/knowledge/guard-render.js +1 -700
- package/dist/knowledge/guard-risk.js +1 -1879
- package/dist/knowledge/guard-submission-prompt.js +1 -171
- package/dist/knowledge/guard-templates.js +1 -1105
- package/dist/knowledge/guard-translation.js +1 -1119
- package/dist/knowledge/index.d.ts +71 -3
- package/dist/knowledge/index.js +1 -436
- package/dist/knowledge/industry-evolution.js +1 -323
- package/dist/knowledge/industry-generalizer.js +1 -381
- package/dist/knowledge/industry-registry.js +1 -174
- package/dist/knowledge/intent-metrics.d.ts +4 -3
- package/dist/knowledge/intent-metrics.js +1 -566
- package/dist/knowledge/machine-confirm.js +1 -559
- package/dist/knowledge/machine-context.js +1 -833
- package/dist/knowledge/machine-ledger.js +1 -338
- package/dist/knowledge/machine-puzzle.js +1 -494
- package/dist/knowledge/machine-render.js +1 -565
- package/dist/knowledge/machine-risk.js +1 -669
- package/dist/knowledge/machine-templates.js +1 -1597
- package/dist/knowledge/machine-topology.js +1 -234
- package/dist/knowledge/machine-translation.js +1 -513
- package/dist/knowledge/market-metrics.d.ts +12 -0
- package/dist/knowledge/market-metrics.js +1 -0
- package/dist/knowledge/market-operations.d.ts +46 -0
- package/dist/knowledge/market-operations.js +1 -0
- package/dist/knowledge/mcp-schema-audit-cli.js +1 -45
- package/dist/knowledge/mcp-schema-audit.d.ts +22 -22
- package/dist/knowledge/mcp-schema-audit.js +1 -777
- package/dist/knowledge/onchain-constants.js +1 -35
- package/dist/knowledge/order-confirm.js +1 -573
- package/dist/knowledge/order-context.js +1 -390
- package/dist/knowledge/order-ledger.js +1 -341
- package/dist/knowledge/order-puzzle.js +1 -255
- package/dist/knowledge/order-risk.js +1 -653
- package/dist/knowledge/order-templates.js +1 -368
- package/dist/knowledge/order-translation.js +1 -550
- package/dist/knowledge/overrides-loader.js +1 -65
- package/dist/knowledge/passport-confirm.js +1 -531
- package/dist/knowledge/passport-context.js +1 -306
- package/dist/knowledge/passport-ledger.js +1 -282
- package/dist/knowledge/passport-puzzle.js +1 -333
- package/dist/knowledge/passport-risk.js +1 -450
- package/dist/knowledge/passport-templates.js +1 -568
- package/dist/knowledge/passport-translation.js +1 -516
- package/dist/knowledge/payment-confirm.d.ts +26 -0
- package/dist/knowledge/payment-confirm.js +1 -0
- package/dist/knowledge/payment-risk.js +1 -249
- package/dist/knowledge/payment-translation.d.ts +37 -0
- package/dist/knowledge/payment-translation.js +1 -0
- package/dist/knowledge/permission-confirm.js +1 -426
- package/dist/knowledge/permission-context.js +1 -224
- package/dist/knowledge/permission-ledger.d.ts +11 -0
- package/dist/knowledge/permission-ledger.js +1 -403
- package/dist/knowledge/permission-puzzle.js +1 -173
- package/dist/knowledge/permission-risk.js +1 -411
- package/dist/knowledge/permission-templates.js +1 -234
- package/dist/knowledge/permission-translation.js +1 -350
- package/dist/knowledge/personal-confirm.d.ts +29 -0
- package/dist/knowledge/personal-confirm.js +1 -0
- package/dist/knowledge/personal-risk.js +1 -212
- package/dist/knowledge/personal-translation.d.ts +37 -0
- package/dist/knowledge/personal-translation.js +1 -0
- package/dist/knowledge/process-model.d.ts +1 -11
- package/dist/knowledge/process-model.js +1 -160
- package/dist/knowledge/progress-confirm.js +1 -456
- package/dist/knowledge/progress-context.js +1 -452
- package/dist/knowledge/progress-ledger.js +1 -330
- package/dist/knowledge/progress-puzzle.js +1 -219
- package/dist/knowledge/progress-risk.js +1 -461
- package/dist/knowledge/progress-templates.js +1 -228
- package/dist/knowledge/progress-translation.js +1 -405
- package/dist/knowledge/proof-confirm.js +1 -187
- package/dist/knowledge/proof-context.d.ts +17 -0
- package/dist/knowledge/proof-context.js +1 -0
- package/dist/knowledge/proof-ledger.d.ts +34 -0
- package/dist/knowledge/proof-ledger.js +1 -0
- package/dist/knowledge/proof-puzzle.d.ts +35 -0
- package/dist/knowledge/proof-puzzle.js +1 -0
- package/dist/knowledge/proof-risk.js +1 -207
- package/dist/knowledge/proof-templates.d.ts +22 -0
- package/dist/knowledge/proof-templates.js +1 -0
- package/dist/knowledge/proof-translation.js +1 -283
- package/dist/knowledge/registrar-confirm.d.ts +26 -0
- package/dist/knowledge/registrar-confirm.js +1 -0
- package/dist/knowledge/registrar-risk.js +1 -217
- package/dist/knowledge/registrar-translation.d.ts +37 -0
- package/dist/knowledge/registrar-translation.js +1 -0
- package/dist/knowledge/repository-confirm.js +1 -286
- package/dist/knowledge/repository-context.d.ts +12 -0
- package/dist/knowledge/repository-context.js +1 -0
- package/dist/knowledge/repository-ledger.d.ts +25 -0
- package/dist/knowledge/repository-ledger.js +1 -0
- package/dist/knowledge/repository-puzzle.d.ts +30 -0
- package/dist/knowledge/repository-puzzle.js +1 -0
- package/dist/knowledge/repository-risk.js +1 -373
- package/dist/knowledge/repository-templates.d.ts +14 -0
- package/dist/knowledge/repository-templates.js +1 -0
- package/dist/knowledge/repository-translation.js +1 -445
- package/dist/knowledge/reputation-rules.js +1 -99
- package/dist/knowledge/resource-confirm.d.ts +25 -0
- package/dist/knowledge/resource-confirm.js +1 -0
- package/dist/knowledge/resource-risk.js +1 -157
- package/dist/knowledge/resource-translation.d.ts +37 -0
- package/dist/knowledge/resource-translation.js +1 -0
- package/dist/knowledge/reward-confirm.js +1 -526
- package/dist/knowledge/reward-context.d.ts +2 -2
- package/dist/knowledge/reward-context.js +1 -504
- package/dist/knowledge/reward-ledger.js +1 -502
- package/dist/knowledge/reward-puzzle.js +1 -300
- package/dist/knowledge/reward-risk.js +1 -627
- package/dist/knowledge/reward-templates.js +1 -197
- package/dist/knowledge/reward-translation.js +1 -501
- package/dist/knowledge/safety-rules.d.ts +1 -0
- package/dist/knowledge/safety-rules.js +1 -404
- package/dist/knowledge/scenario-modes.js +1 -321
- package/dist/knowledge/service-confirm.js +1 -807
- package/dist/knowledge/service-context.js +1 -403
- package/dist/knowledge/service-ledger.js +1 -609
- package/dist/knowledge/service-puzzle.js +1 -236
- package/dist/knowledge/service-risk.d.ts +1 -1
- package/dist/knowledge/service-risk.js +1 -651
- package/dist/knowledge/service-templates.js +1 -456
- package/dist/knowledge/service-translation.js +1 -622
- package/dist/knowledge/template-registry.js +1 -353
- package/dist/knowledge/tool-constraints.js +1 -195
- package/dist/knowledge/tools-reference.js +1 -178
- package/dist/knowledge/treasury-confirm.js +1 -512
- package/dist/knowledge/treasury-context.js +1 -363
- package/dist/knowledge/treasury-ledger.js +1 -300
- package/dist/knowledge/treasury-puzzle.js +1 -216
- package/dist/knowledge/treasury-risk.js +1 -440
- package/dist/knowledge/treasury-templates.js +1 -358
- package/dist/knowledge/treasury-translation.js +1 -498
- package/dist/knowledge/trust-metrics.js +1 -198
- package/dist/knowledge/universal-template.d.ts +22 -0
- package/dist/knowledge/universal-template.js +1 -0
- package/dist/knowledge/util-confirm.d.ts +24 -0
- package/dist/knowledge/util-confirm.js +1 -0
- package/dist/knowledge/util-risk.js +1 -135
- package/dist/knowledge/util-translation.d.ts +38 -0
- package/dist/knowledge/util-translation.js +1 -0
- package/dist/knowledge/workflow-guidance.d.ts +116 -0
- package/dist/knowledge/workflow-guidance.js +1 -0
- package/dist/loop-engineering/aggregate.js +1 -132
- package/dist/loop-engineering/context-collect.js +1 -83
- package/dist/loop-engineering/diagnose.js +1 -273
- package/dist/loop-engineering/improve.js +1 -405
- package/dist/loop-engineering/index.js +1 -4
- package/dist/loop-engineering/pipeline.js +1 -56
- package/dist/mode-market/index.js +1 -3
- package/dist/mode-market/registry.js +1 -124
- package/dist/mode-market/review.js +1 -214
- package/dist/mode-market/submission.js +1 -85
- package/dist/participation/collaborator-interest.d.ts +23 -0
- package/dist/participation/collaborator-interest.js +1 -0
- package/dist/participation/customer-interest.d.ts +25 -0
- package/dist/participation/customer-interest.js +1 -0
- package/dist/participation/employee-kpi.d.ts +25 -0
- package/dist/participation/employee-kpi.js +1 -0
- package/dist/participation/employee-store.d.ts +16 -0
- package/dist/participation/employee-store.js +1 -0
- package/dist/participation/index.d.ts +2 -0
- package/dist/participation/index.js +1 -0
- package/dist/participation/merchant-interest.js +1 -100
- package/dist/participation/radar-core.d.ts +13 -3
- package/dist/participation/radar-core.js +1 -269
- package/dist/participation/supplier-interest.d.ts +25 -0
- package/dist/participation/supplier-interest.js +1 -0
- package/dist/persona/analyzer.js +1 -66
- package/dist/persona/bridge.js +1 -86
- package/dist/persona/defaults.js +1 -195
- package/dist/persona/experience-bridge.js +1 -23
- package/dist/persona/index.d.ts +9 -2
- package/dist/persona/index.js +1 -71
- package/dist/persona/local-region.d.ts +20 -0
- package/dist/persona/local-region.js +1 -0
- package/dist/persona/model.js +1 -111
- package/dist/persona/overrides.d.ts +10 -0
- package/dist/persona/overrides.js +1 -0
- package/dist/persona/pack-personae.d.ts +11 -0
- package/dist/persona/pack-personae.js +1 -0
- package/dist/persona/store.js +1 -62
- package/dist/persona/strategy-intent.d.ts +20 -0
- package/dist/persona/strategy-intent.js +1 -0
- package/dist/persona/types.d.ts +6 -2
- package/dist/persona/types.js +1 -5
- package/dist/project/business-puzzle.d.ts +1 -1
- package/dist/project/business-puzzle.js +1 -383
- package/dist/project/context-assembly.js +1 -254
- package/dist/project/deployment-bridge.js +1 -120
- package/dist/project/deployment-doc.js +1 -1126
- package/dist/project/edit-planner.js +1 -1342
- package/dist/project/evaluation.d.ts +37 -1
- package/dist/project/evaluation.js +1 -2011
- package/dist/project/game-theory.js +1 -177
- package/dist/project/graph-builder.js +1 -656
- package/dist/project/graph.d.ts +3 -6
- package/dist/project/graph.js +1 -340
- package/dist/project/handlers.d.ts +33 -2
- package/dist/project/handlers.js +1 -1784
- package/dist/project/index.d.ts +2 -0
- package/dist/project/index.js +1 -301
- package/dist/project/intent-analyzer.js +1 -149
- package/dist/project/machine-nodes.js +1 -36
- package/dist/project/merchant-guide.d.ts +19 -0
- package/dist/project/merchant-guide.js +1 -264
- package/dist/project/migration.js +1 -125
- package/dist/project/mode-actions.js +1 -309
- package/dist/project/namespace.js +1 -206
- package/dist/project/participation-radar.js +1 -428
- package/dist/project/pipeline-actions.js +1 -109
- package/dist/project/project-store.js +1 -422
- package/dist/project/query.js +1 -153
- package/dist/project/reverse-mapping.d.ts +34 -0
- package/dist/project/reverse-mapping.js +1 -0
- package/dist/project/risk-aggregator.js +1 -295
- package/dist/project/rollback-policy.js +1 -290
- package/dist/project/semantic-assembler.js +1 -345
- package/dist/project/semantic-graph.d.ts +3 -5
- package/dist/project/semantic-graph.js +1 -292
- package/dist/project/stage-gate.js +1 -369
- package/dist/project/substep-trace.js +1 -332
- package/dist/project/task-tracker.js +1 -78
- package/dist/project/workflow-design-assessment.d.ts +24 -0
- package/dist/project/workflow-design-assessment.js +1 -0
- package/dist/role/derivation.d.ts +18 -0
- package/dist/role/derivation.js +1 -0
- package/dist/role/index.d.ts +5 -0
- package/dist/role/index.js +1 -0
- package/dist/role/model.d.ts +8 -0
- package/dist/role/model.js +1 -0
- package/dist/role/resolution.d.ts +11 -0
- package/dist/role/resolution.js +1 -0
- package/dist/role/types.d.ts +11 -0
- package/dist/role/types.js +1 -0
- package/dist/rules.js +1 -52
- package/dist/safety/confirm-gate.d.ts +1 -1
- package/dist/safety/confirm-gate.js +1 -88
- package/dist/safety/index.js +1 -3
- package/dist/safety/preview.js +1 -52
- package/dist/schema/call/allocation.d.ts +186 -1385
- package/dist/schema/call/allocation.js +1 -34
- package/dist/schema/call/arbitration.d.ts +272 -1871
- package/dist/schema/call/arbitration.js +1 -113
- package/dist/schema/call/base.d.ts +1831 -9076
- package/dist/schema/call/base.js +1 -370
- package/dist/schema/call/bridge.d.ts +911 -3171
- package/dist/schema/call/bridge.js +1 -458
- package/dist/schema/call/contact.d.ts +135 -931
- package/dist/schema/call/contact.js +1 -37
- package/dist/schema/call/demand.d.ts +164 -1194
- package/dist/schema/call/demand.js +1 -47
- package/dist/schema/call/guard.d.ts +298 -1140
- package/dist/schema/call/guard.js +1 -161
- package/dist/schema/call/handler.js +1 -322
- package/dist/schema/call/index.js +1 -20
- package/dist/schema/call/machine.d.ts +459 -5403
- package/dist/schema/call/machine.js +1 -193
- package/dist/schema/call/order.d.ts +137 -844
- package/dist/schema/call/order.js +1 -35
- package/dist/schema/call/payment.d.ts +74 -561
- package/dist/schema/call/payment.js +1 -37
- package/dist/schema/call/permission-handler.js +1 -54
- package/dist/schema/call/permission.d.ts +335 -2791
- package/dist/schema/call/permission.js +1 -105
- package/dist/schema/call/personal.d.ts +227 -1814
- package/dist/schema/call/personal.js +1 -78
- package/dist/schema/call/progress.d.ts +140 -843
- package/dist/schema/call/progress.js +1 -47
- package/dist/schema/call/proof.d.ts +42 -258
- package/dist/schema/call/proof.js +1 -33
- package/dist/schema/call/repository.d.ts +324 -2222
- package/dist/schema/call/repository.js +1 -77
- package/dist/schema/call/reward.d.ts +153 -1183
- package/dist/schema/call/reward.js +1 -30
- package/dist/schema/call/semantic.js +1 -1679
- package/dist/schema/call/service.d.ts +376 -3431
- package/dist/schema/call/service.js +1 -184
- package/dist/schema/call/treasury.d.ts +252 -2158
- package/dist/schema/call/treasury.js +1 -71
- package/dist/schema/common/index.d.ts +222 -697
- package/dist/schema/common/index.js +1 -407
- package/dist/schema/config/index.d.ts +18 -161
- package/dist/schema/config/index.js +1 -68
- package/dist/schema/employee/index.d.ts +99 -0
- package/dist/schema/employee/index.js +1 -0
- package/dist/schema/evaluation/index.d.ts +1062 -3748
- package/dist/schema/evaluation/index.js +1 -356
- package/dist/schema/index.d.ts +3 -0
- package/dist/schema/index.js +1 -17
- package/dist/schema/industry-pack/index.d.ts +132 -0
- package/dist/schema/industry-pack/index.js +1 -0
- package/dist/schema/intent-radar/index.d.ts +92 -245
- package/dist/schema/intent-radar/index.js +1 -89
- package/dist/schema/local/index.d.ts +2045 -18080
- package/dist/schema/local/index.js +1 -927
- package/dist/schema/local/wip.d.ts +61 -651
- package/dist/schema/local/wip.js +1 -187
- package/dist/schema/messenger/index.d.ts +949 -5557
- package/dist/schema/messenger/index.js +1 -475
- package/dist/schema/operations.d.ts +2969 -26518
- package/dist/schema/operations.js +1 -520
- package/dist/schema/persona/index.d.ts +469 -1820
- package/dist/schema/persona/index.js +1 -148
- package/dist/schema/project/index.d.ts +1027 -8408
- package/dist/schema/project/index.js +1 -2057
- package/dist/schema/query/index.d.ts +12041 -75261
- package/dist/schema/query/index.js +1 -1646
- package/dist/schema/schema-query/index.d.ts +35 -98
- package/dist/schema/schema-query/index.js +1 -104
- package/dist/schema/schema-version.js +1 -76
- package/dist/schema/task-status.d.ts +26 -132
- package/dist/schema/task-status.js +1 -36
- package/dist/schema/trust/index.d.ts +194 -1290
- package/dist/schema/trust/index.js +1 -314
- package/dist/schema/utils/guard-parser.js +1 -419
- package/dist/schema/utils/guard-query-utils.js +1 -46
- package/dist/schema/utils/node-parser.js +1 -369
- package/dist/schema/utils/object-type-utils.js +1 -35
- package/dist/schema/utils/permission-index-utils.js +1 -7
- package/dist/schema/utils/permission-machine-check.js +1 -121
- package/dist/schema/utils/skills-recommendation.d.ts +1 -0
- package/dist/schema/utils/skills-recommendation.js +1 -77
- package/dist/schema/workspace/index.d.ts +69 -0
- package/dist/schema/workspace/index.js +1 -0
- package/dist/schema-query-impl/index.js +1 -0
- package/dist/schemas/account_operation.output.json +3147 -1652
- package/dist/schemas/account_operation.schema.json +225 -218
- package/dist/schemas/bridge_operation.output.json +1168 -650
- package/dist/schemas/bridge_operation.schema.json +736 -504
- package/dist/schemas/config_operation.output.json +185 -179
- package/dist/schemas/config_operation.schema.json +21 -26
- package/dist/schemas/employee_operation.output.json +207 -0
- package/dist/schemas/employee_operation.schema.json +176 -0
- package/dist/schemas/evaluation_operation.output.json +2329 -557
- package/dist/schemas/evaluation_operation.schema.json +2939 -720
- package/dist/schemas/guard2file.output.json +58 -64
- package/dist/schemas/guard2file.schema.json +79 -81
- package/dist/schemas/index.json +29 -11
- package/dist/schemas/industry_pack_operation.output.json +594 -0
- package/dist/schemas/industry_pack_operation.schema.json +55 -0
- package/dist/schemas/intent_radar.output.json +275 -200
- package/dist/schemas/intent_radar.schema.json +124 -123
- package/dist/schemas/local_info_operation.output.json +1174 -657
- package/dist/schemas/local_info_operation.schema.json +119 -125
- package/dist/schemas/local_mark_operation.output.json +1239 -689
- package/dist/schemas/local_mark_operation.schema.json +91 -96
- package/dist/schemas/machineNode2file.output.json +63 -69
- package/dist/schemas/machineNode2file.schema.json +79 -81
- package/dist/schemas/messenger_operation.output.json +2722 -1528
- package/dist/schemas/messenger_operation.schema.json +1482 -1264
- package/dist/schemas/onchain_events.output.json +2590 -975
- package/dist/schemas/onchain_events.schema.json +117 -99
- package/dist/schemas/onchain_operations.output.json +3957 -2309
- package/dist/schemas/onchain_operations.schema.json +20799 -9285
- package/dist/schemas/onchain_operations_allocation.schema.json +172 -108
- package/dist/schemas/onchain_operations_arbitration.schema.json +233 -146
- package/dist/schemas/onchain_operations_contact.schema.json +129 -90
- package/dist/schemas/onchain_operations_demand.schema.json +170 -112
- package/dist/schemas/onchain_operations_gen_passport.schema.json +61 -646
- package/dist/schemas/onchain_operations_gen_proof.schema.json +40 -172
- package/dist/schemas/onchain_operations_guard.schema.json +3765 -294
- package/dist/schemas/onchain_operations_machine.schema.json +537 -164
- package/dist/schemas/onchain_operations_order.schema.json +126 -96
- package/dist/schemas/onchain_operations_payment.schema.json +82 -67
- package/dist/schemas/onchain_operations_permission.schema.json +331 -93
- package/dist/schemas/onchain_operations_personal.schema.json +636 -96
- package/dist/schemas/onchain_operations_progress.schema.json +125 -92
- package/dist/schemas/onchain_operations_proof.schema.json +76 -69
- package/dist/schemas/onchain_operations_repository.schema.json +636 -249
- package/dist/schemas/onchain_operations_reward.schema.json +218 -108
- package/dist/schemas/onchain_operations_service.schema.json +679 -221
- package/dist/schemas/onchain_operations_treasury.schema.json +401 -135
- package/dist/schemas/onchain_table_data.output.json +6018 -2430
- package/dist/schemas/onchain_table_data.schema.json +544 -430
- package/dist/schemas/persona_operation.output.json +1568 -265
- package/dist/schemas/persona_operation.schema.json +346 -202
- package/dist/schemas/project_operation.output.json +6957 -5147
- package/dist/schemas/project_operation.schema.json +1050 -1020
- package/dist/schemas/query_task_status.output.json +195 -99
- package/dist/schemas/query_task_status.schema.json +12 -18
- package/dist/schemas/query_toolkit.output.json +18870 -14566
- package/dist/schemas/query_toolkit.schema.json +614 -522
- package/dist/schemas/schema_query.output.json +127 -129
- package/dist/schemas/schema_query.schema.json +64 -69
- package/dist/schemas/trust_score.output.json +678 -587
- package/dist/schemas/trust_score.schema.json +289 -277
- package/dist/schemas/wip_file.output.json +116 -124
- package/dist/schemas/wip_file.schema.json +142 -143
- package/dist/schemas/workspace_operation.output.json +277 -0
- package/dist/schemas/workspace_operation.schema.json +45 -0
- package/dist/schemas/wowok_buildin_info.output.json +1693 -723
- package/dist/schemas/wowok_buildin_info.schema.json +576 -512
- package/dist/telemetry/index.js +1 -112
- package/dist/telemetry/redact.js +1 -23
- package/dist/telemetry/storage.js +1 -80
- package/dist/tools/handlers/bridge.d.ts +8 -1
- package/dist/tools/handlers/bridge.js +1 -1
- package/dist/tools/handlers/config.js +1 -74
- package/dist/tools/handlers/employee.d.ts +2 -0
- package/dist/tools/handlers/employee.js +1 -0
- package/dist/tools/handlers/evaluation.js +1 -123
- package/dist/tools/handlers/file-export.js +1 -90
- package/dist/tools/handlers/industry-pack.d.ts +2 -0
- package/dist/tools/handlers/industry-pack.js +1 -0
- package/dist/tools/handlers/intent-radar.js +1 -76
- package/dist/tools/handlers/local.js +1 -53
- package/dist/tools/handlers/messenger.js +1 -188
- package/dist/tools/handlers/onchain.js +1 -1180
- package/dist/tools/handlers/persona.js +1 -89
- package/dist/tools/handlers/project.js +1 -211
- package/dist/tools/handlers/query.js +1 -434
- package/dist/tools/handlers/schema-query.js +1 -176
- package/dist/tools/handlers/task-status.js +1 -26
- package/dist/tools/handlers/trust.js +1 -380
- package/dist/tools/handlers/wip.js +1 -90
- package/dist/tools/handlers/workspace.d.ts +2 -0
- package/dist/tools/handlers/workspace.js +1 -0
- package/dist/tools/index.d.ts +2 -1
- package/dist/tools/index.js +1 -1382
- package/dist/tools/retry.js +1 -85
- package/dist/tools/rules-hook.d.ts +1 -1
- package/dist/tools/rules-hook.js +1 -23
- package/dist/tools/shared.d.ts +1 -1
- package/dist/tools/shared.js +1 -130
- package/dist/tools/types.d.ts +2 -1
- package/dist/tools/types.js +1 -1
- package/dist/tools/upgrade-check.d.ts +19 -0
- package/dist/tools/upgrade-check.js +1 -0
- package/dist/tools/wip-deploy-assist.js +1 -306
- package/dist/tools/wrap.js +1 -500
- package/package.json +7 -6
- package/dist/knowledge/arbitration-trust.d.ts +0 -24
- package/dist/knowledge/arbitration-trust.js +0 -117
- package/dist/schema/call/bridge-handler.d.ts +0 -8
- package/dist/schema/call/bridge-handler.js +0 -265
- package/dist/schema/sync-layer4.d.ts +0 -21
- package/dist/schema/sync-layer4.js +0 -286
- package/dist/schema-query/index.js +0 -810
- /package/dist/{schema-query → schema-query-impl}/index.d.ts +0 -0
|
@@ -1,234 +1 @@
|
|
|
1
|
-
export const PERMISSION_TEMPLATES = [
|
|
2
|
-
{
|
|
3
|
-
id: "T-P-01",
|
|
4
|
-
name: "Basic permission",
|
|
5
|
-
description: "Single-admin permission (owner=admin). Suitable for solo operators",
|
|
6
|
-
applicable_scenes: ["repository_permission", "reward_permission", "progress_permission", "demand_permission", "contact_permission"],
|
|
7
|
-
industry_tags: ["universal"],
|
|
8
|
-
params: [
|
|
9
|
-
{ name: "owner_address", type: "address", description: "Owner address (also becomes admin)", required: true },
|
|
10
|
-
{ name: "description", type: "string", description: "Permission description", required: true },
|
|
11
|
-
],
|
|
12
|
-
body: (p) => ({
|
|
13
|
-
object: null,
|
|
14
|
-
description: p.description,
|
|
15
|
-
admin: { op: "set", addresses: [p.owner_address] },
|
|
16
|
-
}),
|
|
17
|
-
notes: ["Use this as a starting point; add admins or entities as needed"],
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
id: "T-P-02",
|
|
21
|
-
name: "Multi-admin permission",
|
|
22
|
-
description: "Multiple admins for collaborative management. Suitable for teams",
|
|
23
|
-
applicable_scenes: ["service_permission", "machine_permission", "treasury_permission", "arbitration_permission"],
|
|
24
|
-
industry_tags: ["universal"],
|
|
25
|
-
params: [
|
|
26
|
-
{ name: "owner_address", type: "address", description: "Owner address", required: true },
|
|
27
|
-
{ name: "admin_addresses", type: "string[]", description: "Additional admin addresses", required: true },
|
|
28
|
-
{ name: "description", type: "string", description: "Permission description", required: true },
|
|
29
|
-
],
|
|
30
|
-
body: (p) => ({
|
|
31
|
-
object: null,
|
|
32
|
-
description: p.description,
|
|
33
|
-
admin: {
|
|
34
|
-
op: "set",
|
|
35
|
-
addresses: [p.owner_address, ...p.admin_addresses],
|
|
36
|
-
},
|
|
37
|
-
}),
|
|
38
|
-
notes: ["All admins have equal power; use multi-sig if available"],
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
id: "T-P-03",
|
|
42
|
-
name: "Service permission",
|
|
43
|
-
description: "Template for Service object with publish/pause/allocator permissions",
|
|
44
|
-
applicable_scenes: ["service_permission"],
|
|
45
|
-
industry_tags: ["retail", "service"],
|
|
46
|
-
params: [
|
|
47
|
-
{ name: "owner_address", type: "address", description: "Service owner", required: true },
|
|
48
|
-
{ name: "publisher_address", type: "address", description: "Address allowed to publish (can be same as owner)", required: true },
|
|
49
|
-
{ name: "allocator_address", type: "address", description: "Address allowed to set order allocator", required: true },
|
|
50
|
-
{ name: "pauser_address", type: "address", description: "Address allowed to pause/resume", required: true },
|
|
51
|
-
{ name: "service_address", type: "address", description: "Target Service object address (for apply)", required: false },
|
|
52
|
-
],
|
|
53
|
-
body: (p) => {
|
|
54
|
-
const result = {
|
|
55
|
-
object: null,
|
|
56
|
-
description: "Service permission",
|
|
57
|
-
admin: { op: "set", addresses: [p.owner_address] },
|
|
58
|
-
table: [
|
|
59
|
-
{ op: "add perm by index", index: 311, entity: [p.publisher_address] },
|
|
60
|
-
{ op: "add perm by index", index: 313, entity: [p.allocator_address] },
|
|
61
|
-
{ op: "add perm by index", index: 310, entity: [p.pauser_address] },
|
|
62
|
-
],
|
|
63
|
-
remark: [
|
|
64
|
-
{ op: "set", index: 311, remark: "service.publish" },
|
|
65
|
-
{ op: "set", index: 313, remark: "service.order_allocator" },
|
|
66
|
-
{ op: "set", index: 310, remark: "service.pause" },
|
|
67
|
-
],
|
|
68
|
-
};
|
|
69
|
-
if (p.service_address)
|
|
70
|
-
result.apply = [p.service_address];
|
|
71
|
-
return result;
|
|
72
|
-
},
|
|
73
|
-
notes: ["Assign different addresses to different roles for least-privilege"],
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
id: "T-P-04",
|
|
77
|
-
name: "Machine permission",
|
|
78
|
-
description: "Template for Machine object with publish/node/pause permissions",
|
|
79
|
-
applicable_scenes: ["machine_permission"],
|
|
80
|
-
industry_tags: ["workflow", "automation"],
|
|
81
|
-
params: [
|
|
82
|
-
{ name: "owner_address", type: "address", description: "Machine owner", required: true },
|
|
83
|
-
{ name: "node_editor_address", type: "address", description: "Address allowed to edit nodes (pre-publish only)", required: true },
|
|
84
|
-
{ name: "pauser_address", type: "address", description: "Address allowed to pause/resume", required: true },
|
|
85
|
-
{ name: "machine_address", type: "address", description: "Target Machine object address (for apply)", required: false },
|
|
86
|
-
],
|
|
87
|
-
body: (p) => {
|
|
88
|
-
const result = {
|
|
89
|
-
object: null,
|
|
90
|
-
description: "Machine permission",
|
|
91
|
-
admin: { op: "set", addresses: [p.owner_address] },
|
|
92
|
-
table: [
|
|
93
|
-
{ op: "add perm by index", index: 205, entity: [p.owner_address] },
|
|
94
|
-
{ op: "add perm by index", index: 206, entity: [p.node_editor_address] },
|
|
95
|
-
{ op: "add perm by index", index: 204, entity: [p.pauser_address] },
|
|
96
|
-
],
|
|
97
|
-
remark: [
|
|
98
|
-
{ op: "set", index: 205, remark: "machine.publish" },
|
|
99
|
-
{ op: "set", index: 206, remark: "machine.node" },
|
|
100
|
-
{ op: "set", index: 204, remark: "machine.pause" },
|
|
101
|
-
],
|
|
102
|
-
};
|
|
103
|
-
if (p.machine_address)
|
|
104
|
-
result.apply = [p.machine_address];
|
|
105
|
-
return result;
|
|
106
|
-
},
|
|
107
|
-
notes: ["MACHINE_PUBLISH (205) should be owner-only", "Node editing only effective before publish"],
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
id: "T-P-05",
|
|
111
|
-
name: "Treasury permission",
|
|
112
|
-
description: "Template for Treasury with deposit/withdraw/external ops + guard",
|
|
113
|
-
applicable_scenes: ["treasury_permission"],
|
|
114
|
-
industry_tags: ["finance", "treasury"],
|
|
115
|
-
params: [
|
|
116
|
-
{ name: "owner_address", type: "address", description: "Treasury owner", required: true },
|
|
117
|
-
{ name: "depositor_address", type: "address", description: "Address allowed to deposit", required: true },
|
|
118
|
-
{ name: "withdrawer_address", type: "address", description: "Address allowed to withdraw", required: true },
|
|
119
|
-
{ name: "external_operator_address", type: "address", description: "Address for external deposit/withdraw", required: false },
|
|
120
|
-
{ name: "treasury_address", type: "address", description: "Target Treasury object address (for apply)", required: false },
|
|
121
|
-
],
|
|
122
|
-
body: (p) => {
|
|
123
|
-
const table = [
|
|
124
|
-
{ op: "add perm by index", index: 252, entity: [p.depositor_address] },
|
|
125
|
-
{ op: "add perm by index", index: 254, entity: [p.withdrawer_address] },
|
|
126
|
-
];
|
|
127
|
-
const remark = [
|
|
128
|
-
{ op: "set", index: 252, remark: "treasury.deposit" },
|
|
129
|
-
{ op: "set", index: 254, remark: "treasury.withdraw" },
|
|
130
|
-
];
|
|
131
|
-
if (p.external_operator_address) {
|
|
132
|
-
table.push({ op: "add perm by index", index: 255, entity: [p.owner_address] }, { op: "add perm by index", index: 256, entity: [p.owner_address] });
|
|
133
|
-
remark.push({ op: "set", index: 255, remark: "treasury.external_deposit_guard" }, { op: "set", index: 256, remark: "treasury.external_withdraw_guard" });
|
|
134
|
-
}
|
|
135
|
-
const result = {
|
|
136
|
-
object: null,
|
|
137
|
-
description: "Treasury permission",
|
|
138
|
-
admin: { op: "set", addresses: [p.owner_address] },
|
|
139
|
-
table,
|
|
140
|
-
remark,
|
|
141
|
-
};
|
|
142
|
-
if (p.treasury_address)
|
|
143
|
-
result.apply = [p.treasury_address];
|
|
144
|
-
return result;
|
|
145
|
-
},
|
|
146
|
-
notes: ["Grant TREASURY_EXTERNAL_*_GUARD (255/256) to owner for guard-list management; authorize external operators via external_*_guard_add (Guard + Passport, no Permission index)"],
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
id: "T-P-06",
|
|
150
|
-
name: "Arbitration permission",
|
|
151
|
-
description: "Template for Arbitration with vote/feedback/confirm permissions",
|
|
152
|
-
applicable_scenes: ["arbitration_permission"],
|
|
153
|
-
industry_tags: ["arbitration", "dispute"],
|
|
154
|
-
params: [
|
|
155
|
-
{ name: "owner_address", type: "address", description: "Arbitration owner", required: true },
|
|
156
|
-
{ name: "voter_addresses", type: "string[]", description: "Arbiter addresses allowed to vote", required: true },
|
|
157
|
-
{ name: "feedback_address", type: "address", description: "Address allowed to provide feedback", required: false },
|
|
158
|
-
{ name: "arbitration_address", type: "address", description: "Target Arbitration object address (for apply)", required: false },
|
|
159
|
-
],
|
|
160
|
-
body: (p) => {
|
|
161
|
-
const result = {
|
|
162
|
-
object: null,
|
|
163
|
-
description: "Arbitration permission",
|
|
164
|
-
admin: { op: "set", addresses: [p.owner_address] },
|
|
165
|
-
table: [
|
|
166
|
-
{ op: "add perm by index", index: 357, entity: p.voter_addresses },
|
|
167
|
-
],
|
|
168
|
-
remark: [
|
|
169
|
-
{ op: "set", index: 357, remark: "arbitration.vote" },
|
|
170
|
-
],
|
|
171
|
-
};
|
|
172
|
-
if (p.feedback_address) {
|
|
173
|
-
result.table.push({ op: "add perm by index", index: 359, entity: [p.feedback_address] });
|
|
174
|
-
result.remark.push({ op: "set", index: 359, remark: "arbitration.feedback" });
|
|
175
|
-
}
|
|
176
|
-
if (p.arbitration_address)
|
|
177
|
-
result.apply = [p.arbitration_address];
|
|
178
|
-
return result;
|
|
179
|
-
},
|
|
180
|
-
notes: ["Voting weight is determined by voting_guard, not by permission index", "Multiple arbiters can share ARBITRATION_VOTE"],
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
id: "T-P-08",
|
|
184
|
-
name: "Ownership transfer",
|
|
185
|
-
description: "Template for transferring Permission ownership",
|
|
186
|
-
applicable_scenes: ["ownership_transfer"],
|
|
187
|
-
industry_tags: ["universal"],
|
|
188
|
-
params: [
|
|
189
|
-
{ name: "permission_address", type: "address", description: "Permission object address", required: true },
|
|
190
|
-
{ name: "new_owner_address", type: "address", description: "New owner address", required: true },
|
|
191
|
-
],
|
|
192
|
-
body: (p) => ({
|
|
193
|
-
object: p.permission_address,
|
|
194
|
-
builder: p.new_owner_address,
|
|
195
|
-
}),
|
|
196
|
-
notes: ["⚠️ IRREVERSIBLE operation", "Export Permission JSON before transfer", "Verify new owner address twice"],
|
|
197
|
-
},
|
|
198
|
-
];
|
|
199
|
-
export const PERMISSION_TEMPLATES_VERSION = "1.0.0";
|
|
200
|
-
export function getAllTemplates() {
|
|
201
|
-
return [...PERMISSION_TEMPLATES];
|
|
202
|
-
}
|
|
203
|
-
export function getTemplateById(id) {
|
|
204
|
-
return PERMISSION_TEMPLATES.find(t => t.id === id);
|
|
205
|
-
}
|
|
206
|
-
export function getTemplatesByScene(sceneId) {
|
|
207
|
-
return PERMISSION_TEMPLATES.filter(t => t.applicable_scenes.includes(sceneId));
|
|
208
|
-
}
|
|
209
|
-
export function getTemplatesByIndustry(industry) {
|
|
210
|
-
return PERMISSION_TEMPLATES.filter(t => t.industry_tags.includes(industry) || t.industry_tags.includes("universal"));
|
|
211
|
-
}
|
|
212
|
-
export function suggestTemplateForScene(sceneId) {
|
|
213
|
-
const matches = getTemplatesByScene(sceneId);
|
|
214
|
-
return matches.length > 0 ? matches[0] : undefined;
|
|
215
|
-
}
|
|
216
|
-
export function listTemplates() {
|
|
217
|
-
return PERMISSION_TEMPLATES.map(t => ({
|
|
218
|
-
id: t.id,
|
|
219
|
-
name: t.name,
|
|
220
|
-
description: t.description,
|
|
221
|
-
scenes: t.applicable_scenes,
|
|
222
|
-
}));
|
|
223
|
-
}
|
|
224
|
-
export function fillTemplate(templateId, params) {
|
|
225
|
-
const tpl = getTemplateById(templateId);
|
|
226
|
-
if (!tpl)
|
|
227
|
-
return { ok: false, error: `Template ${templateId} not found` };
|
|
228
|
-
for (const p of tpl.params) {
|
|
229
|
-
if (p.required && !(p.name in params)) {
|
|
230
|
-
return { ok: false, error: `Missing required param: ${p.name}` };
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
return { ok: true, body: tpl.body(params) };
|
|
234
|
-
}
|
|
1
|
+
export const PERMISSION_TEMPLATES=[{'id':'T-P-01','name':'Basic\x20permission','description':'Single-admin\x20permission\x20(owner=admin).\x20Suitable\x20for\x20solo\x20operators','applicable_scenes':['repository_permission','reward_permission','progress_permission','demand_permission','contact_permission'],'industry_tags':['universal'],'params':[{'name':'owner_address','type':'address','description':'Owner\x20address\x20(also\x20becomes\x20admin)','required':!![]},{'name':'description','type':'string','description':'Permission\x20description','required':!![]}],'body':a=>({'object':null,'description':a['description'],'admin':{'op':'set','addresses':[a['owner_address']]}}),'notes':['Use\x20this\x20as\x20a\x20starting\x20point;\x20add\x20admins\x20or\x20entities\x20as\x20needed']},{'id':'T-P-02','name':'Multi-admin\x20permission','description':'Multiple\x20admins\x20for\x20collaborative\x20management.\x20Suitable\x20for\x20teams','applicable_scenes':['service_permission','machine_permission','treasury_permission','arbitration_permission'],'industry_tags':['universal'],'params':[{'name':'owner_address','type':'address','description':'Owner\x20address','required':!![]},{'name':'admin_addresses','type':'string[]','description':'Additional\x20admin\x20addresses','required':!![]},{'name':'description','type':'string','description':'Permission\x20description','required':!![]}],'body':a=>({'object':null,'description':a['description'],'admin':{'op':'set','addresses':[a['owner_address'],...a['admin_addresses']]}}),'notes':['All\x20admins\x20have\x20equal\x20power;\x20use\x20multi-sig\x20if\x20available']},{'id':'T-P-03','name':'Service\x20permission','description':'Template\x20for\x20Service\x20object\x20with\x20publish/pause/allocator\x20permissions','applicable_scenes':['service_permission'],'industry_tags':['retail','service'],'params':[{'name':'owner_address','type':'address','description':'Service\x20owner','required':!![]},{'name':'publisher_address','type':'address','description':'Address\x20allowed\x20to\x20publish\x20(can\x20be\x20same\x20as\x20owner)','required':!![]},{'name':'allocator_address','type':'address','description':'Address\x20allowed\x20to\x20set\x20order\x20allocator','required':!![]},{'name':'pauser_address','type':'address','description':'Address\x20allowed\x20to\x20pause/resume','required':!![]},{'name':'service_address','type':'address','description':'Target\x20Service\x20object\x20address\x20(for\x20apply)','required':![]}],'body':a=>{const b={'object':null,'description':'Service\x20permission','admin':{'op':'set','addresses':[a['owner_address']]},'table':[{'op':'add\x20perm\x20by\x20index','index':0x137,'entity':[a['publisher_address']]},{'op':'add\x20perm\x20by\x20index','index':0x139,'entity':[a['allocator_address']]},{'op':'add\x20perm\x20by\x20index','index':0x136,'entity':[a['pauser_address']]}],'remark':[{'op':'set','index':0x137,'remark':'service.publish'},{'op':'set','index':0x139,'remark':'service.order_allocator'},{'op':'set','index':0x136,'remark':'service.pause'}]};if(a['service_address'])b['apply']=[a['service_address']];return b;},'notes':['Assign\x20different\x20addresses\x20to\x20different\x20roles\x20for\x20least-privilege']},{'id':'T-P-04','name':'Machine\x20permission','description':'Template\x20for\x20Machine\x20object\x20with\x20publish/node/pause\x20permissions','applicable_scenes':['machine_permission'],'industry_tags':['workflow','automation'],'params':[{'name':'owner_address','type':'address','description':'Machine\x20owner','required':!![]},{'name':'node_editor_address','type':'address','description':'Address\x20allowed\x20to\x20edit\x20nodes\x20(pre-publish\x20only)','required':!![]},{'name':'pauser_address','type':'address','description':'Address\x20allowed\x20to\x20pause/resume','required':!![]},{'name':'machine_address','type':'address','description':'Target\x20Machine\x20object\x20address\x20(for\x20apply)','required':![]}],'body':a=>{const b={'object':null,'description':'Machine\x20permission','admin':{'op':'set','addresses':[a['owner_address']]},'table':[{'op':'add\x20perm\x20by\x20index','index':0xcd,'entity':[a['owner_address']]},{'op':'add\x20perm\x20by\x20index','index':0xce,'entity':[a['node_editor_address']]},{'op':'add\x20perm\x20by\x20index','index':0xcc,'entity':[a['pauser_address']]}],'remark':[{'op':'set','index':0xcd,'remark':'machine.publish'},{'op':'set','index':0xce,'remark':'machine.node'},{'op':'set','index':0xcc,'remark':'machine.pause'}]};if(a['machine_address'])b['apply']=[a['machine_address']];return b;},'notes':['MACHINE_PUBLISH\x20(205)\x20should\x20be\x20owner-only','Node\x20editing\x20only\x20effective\x20before\x20publish']},{'id':'T-P-05','name':'Treasury\x20permission','description':'Template\x20for\x20Treasury\x20with\x20deposit/withdraw/external\x20ops\x20+\x20guard','applicable_scenes':['treasury_permission'],'industry_tags':['finance','treasury'],'params':[{'name':'owner_address','type':'address','description':'Treasury\x20owner','required':!![]},{'name':'depositor_address','type':'address','description':'Address\x20allowed\x20to\x20deposit','required':!![]},{'name':'withdrawer_address','type':'address','description':'Address\x20allowed\x20to\x20withdraw','required':!![]},{'name':'external_operator_address','type':'address','description':'Address\x20for\x20external\x20deposit/withdraw','required':![]},{'name':'treasury_address','type':'address','description':'Target\x20Treasury\x20object\x20address\x20(for\x20apply)','required':![]}],'body':a=>{const b=[{'op':'add\x20perm\x20by\x20index','index':0xfc,'entity':[a['depositor_address']]},{'op':'add\x20perm\x20by\x20index','index':0xfe,'entity':[a['withdrawer_address']]}],c=[{'op':'set','index':0xfc,'remark':'treasury.deposit'},{'op':'set','index':0xfe,'remark':'treasury.withdraw'}];a['external_operator_address']&&(b['push']({'op':'add\x20perm\x20by\x20index','index':0xff,'entity':[a['owner_address']]},{'op':'add\x20perm\x20by\x20index','index':0x100,'entity':[a['owner_address']]}),c['push']({'op':'set','index':0xff,'remark':'treasury.external_deposit_guard'},{'op':'set','index':0x100,'remark':'treasury.external_withdraw_guard'}));const d={'object':null,'description':'Treasury\x20permission','admin':{'op':'set','addresses':[a['owner_address']]},'table':b,'remark':c};if(a['treasury_address'])d['apply']=[a['treasury_address']];return d;},'notes':['Grant\x20TREASURY_EXTERNAL_*_GUARD\x20(255/256)\x20to\x20owner\x20for\x20guard-list\x20management;\x20authorize\x20external\x20operators\x20via\x20external_*_guard_add\x20(Guard\x20+\x20Passport,\x20no\x20Permission\x20index)']},{'id':'T-P-06','name':'Arbitration\x20permission','description':'Template\x20for\x20Arbitration\x20with\x20vote/feedback/confirm\x20permissions','applicable_scenes':['arbitration_permission'],'industry_tags':['arbitration','dispute'],'params':[{'name':'owner_address','type':'address','description':'Arbitration\x20owner','required':!![]},{'name':'voter_addresses','type':'string[]','description':'Arbiter\x20addresses\x20allowed\x20to\x20vote','required':!![]},{'name':'feedback_address','type':'address','description':'Address\x20allowed\x20to\x20provide\x20feedback','required':![]},{'name':'arbitration_address','type':'address','description':'Target\x20Arbitration\x20object\x20address\x20(for\x20apply)','required':![]}],'body':a=>{const b={'object':null,'description':'Arbitration\x20permission','admin':{'op':'set','addresses':[a['owner_address']]},'table':[{'op':'add\x20perm\x20by\x20index','index':0x165,'entity':a['voter_addresses']}],'remark':[{'op':'set','index':0x165,'remark':'arbitration.vote'}]};a['feedback_address']&&(b['table']['push']({'op':'add\x20perm\x20by\x20index','index':0x167,'entity':[a['feedback_address']]}),b['remark']['push']({'op':'set','index':0x167,'remark':'arbitration.feedback'}));if(a['arbitration_address'])b['apply']=[a['arbitration_address']];return b;},'notes':['Voting\x20weight\x20is\x20determined\x20by\x20voting_guard,\x20not\x20by\x20permission\x20index','Multiple\x20arbiters\x20can\x20share\x20ARBITRATION_VOTE']},{'id':'T-P-08','name':'Ownership\x20transfer','description':'Template\x20for\x20transferring\x20Permission\x20ownership','applicable_scenes':['ownership_transfer'],'industry_tags':['universal'],'params':[{'name':'permission_address','type':'address','description':'Permission\x20object\x20address','required':!![]},{'name':'new_owner_address','type':'address','description':'New\x20owner\x20address','required':!![]}],'body':a=>({'object':a['permission_address'],'builder':a['new_owner_address']}),'notes':['⚠️\x20IRREVERSIBLE\x20operation','Export\x20Permission\x20JSON\x20before\x20transfer','Verify\x20new\x20owner\x20address\x20twice']}];export const PERMISSION_TEMPLATES_VERSION='1.0.0';export function getAllTemplates(){return[...PERMISSION_TEMPLATES];}export function getTemplateById(a){return PERMISSION_TEMPLATES['find'](b=>b['id']===a);}export function getTemplatesByScene(a){return PERMISSION_TEMPLATES['filter'](b=>b['applicable_scenes']['includes'](a));}export function getTemplatesByIndustry(a){return PERMISSION_TEMPLATES['filter'](b=>b['industry_tags']['includes'](a)||b['industry_tags']['includes']('universal'));}export function suggestTemplateForScene(a){const b=getTemplatesByScene(a);return b['length']>0x0?b[0x0]:undefined;}export function listTemplates(){return PERMISSION_TEMPLATES['map'](a=>({'id':a['id'],'name':a['name'],'description':a['description'],'scenes':a['applicable_scenes']}));}export function fillTemplate(a,b){const c=getTemplateById(a);if(!c)return{'ok':![],'error':'Template\x20'+a+'\x20not\x20found'};for(const d of c['params']){if(d['required']&&!(d['name']in b))return{'ok':![],'error':'Missing\x20required\x20param:\x20'+d['name']};}return{'ok':!![],'body':c['body'](b)};}
|
|
@@ -1,350 +1 @@
|
|
|
1
|
-
import { isBuiltinPermission, getBuiltinPermissionByIndex, findSceneByPermissionIndex, } from "./permission-ledger.js";
|
|
2
|
-
export const SEMANTIC_TO_SCHEMA_RULES = [
|
|
3
|
-
{
|
|
4
|
-
id: "P-P-01",
|
|
5
|
-
pattern_name: "Create new Permission",
|
|
6
|
-
semantic_intent: "Create a new Permission for a Service/Machine/Treasury/etc.",
|
|
7
|
-
match_keywords: ["create", "new"],
|
|
8
|
-
schema_fields: ["object(null)", "description", "admin", "table", "remark"],
|
|
9
|
-
example_json: {
|
|
10
|
-
object: null,
|
|
11
|
-
description: "Permission for myshop service",
|
|
12
|
-
admin: { op: "set", addresses: ["0xOWNER", "0xADMIN1"] },
|
|
13
|
-
table: { op: "set perm by index", index: 311, entity: ["0xUSER1", "0xUSER2"] },
|
|
14
|
-
remark: { op: "set", index: 311, remark: "service.publish" },
|
|
15
|
-
},
|
|
16
|
-
reverse_explanation: "object=null indicates creation; admin/table/remark initialize the permission",
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
id: "P-P-02",
|
|
20
|
-
pattern_name: "Grant permission to entities",
|
|
21
|
-
semantic_intent: "Grant a specific permission index to multiple entities",
|
|
22
|
-
match_keywords: ["grant", "authorize"],
|
|
23
|
-
schema_fields: ["object", "table(op=add perm by index)"],
|
|
24
|
-
example_json: {
|
|
25
|
-
object: "0xPERMISSION_ADDRESS",
|
|
26
|
-
table: { op: "add perm by index", index: 313, entity: ["0xNEW_USER"] },
|
|
27
|
-
},
|
|
28
|
-
reverse_explanation: "table.op='add perm by index' adds entities to an existing permission index",
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
id: "P-P-03",
|
|
32
|
-
pattern_name: "Set admin list",
|
|
33
|
-
semantic_intent: "Replace the admin list",
|
|
34
|
-
match_keywords: ["admin", "set admin"],
|
|
35
|
-
schema_fields: ["object", "admin(op=set)"],
|
|
36
|
-
example_json: {
|
|
37
|
-
object: "0xPERMISSION_ADDRESS",
|
|
38
|
-
admin: { op: "set", addresses: ["0xADMIN1", "0xADMIN2", "0xADMIN3"] },
|
|
39
|
-
},
|
|
40
|
-
reverse_explanation: "admin.op='set' overwrites the entire admin list",
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
id: "P-P-04",
|
|
44
|
-
pattern_name: "Transfer ownership",
|
|
45
|
-
semantic_intent: "Transfer Permission ownership to a new address",
|
|
46
|
-
match_keywords: ["transfer", "handover"],
|
|
47
|
-
schema_fields: ["object", "builder"],
|
|
48
|
-
example_json: {
|
|
49
|
-
object: "0xPERMISSION_ADDRESS",
|
|
50
|
-
builder: "0xNEW_OWNER",
|
|
51
|
-
},
|
|
52
|
-
reverse_explanation: "builder field triggers ownership transfer; irreversible",
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
id: "P-P-05",
|
|
56
|
-
pattern_name: "Set/clear UM (User Manager)",
|
|
57
|
-
semantic_intent: "Delegate UM management or revoke UM",
|
|
58
|
-
match_keywords: ["um", "user manager", "delegate", "contact"],
|
|
59
|
-
schema_fields: ["object", "um"],
|
|
60
|
-
example_json: {
|
|
61
|
-
object: "0xPERMISSION_ADDRESS",
|
|
62
|
-
um: "0xUM_ADDRESS",
|
|
63
|
-
},
|
|
64
|
-
reverse_explanation: "um=null revokes; um=<address> delegates to Contact object",
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
id: "P-P-06",
|
|
68
|
-
pattern_name: "Apply Permission to other objects",
|
|
69
|
-
semantic_intent: "Apply Permission to Service/Machine/Treasury/Arbitration/Repository/Reward/Demand",
|
|
70
|
-
match_keywords: ["apply", "bind"],
|
|
71
|
-
schema_fields: ["object", "apply"],
|
|
72
|
-
example_json: {
|
|
73
|
-
object: "0xPERMISSION_ADDRESS",
|
|
74
|
-
apply: ["0xSERVICE_ADDRESS", "0xMACHINE_ADDRESS"],
|
|
75
|
-
},
|
|
76
|
-
reverse_explanation: "apply field binds Permission to target objects; signer must be owner of those objects",
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
id: "P-P-07",
|
|
80
|
-
pattern_name: "Manage remarks",
|
|
81
|
-
semantic_intent: "Add/remove/clear remarks for permission indexes",
|
|
82
|
-
match_keywords: ["remark", "note"],
|
|
83
|
-
schema_fields: ["object", "remark"],
|
|
84
|
-
example_json: {
|
|
85
|
-
object: "0xPERMISSION_ADDRESS",
|
|
86
|
-
remark: { op: "set", index: 1000, remark: "custom.refund_approval" },
|
|
87
|
-
},
|
|
88
|
-
reverse_explanation: "remark.op='set|remove|clear' manages documentation for permission indexes",
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
id: "P-P-08",
|
|
92
|
-
pattern_name: "Entity batch operations",
|
|
93
|
-
semantic_intent: "Swap/replace/copy/del entities",
|
|
94
|
-
match_keywords: ["swap", "replace", "copy", "del"],
|
|
95
|
-
schema_fields: ["object", "entity"],
|
|
96
|
-
example_json: {
|
|
97
|
-
object: "0xPERMISSION_ADDRESS",
|
|
98
|
-
entity: { op: "swap", entity1: "0xUSER1", entity2: "0xUSER2" },
|
|
99
|
-
},
|
|
100
|
-
reverse_explanation: "entity.op manages bulk entity-permission reassignments",
|
|
101
|
-
},
|
|
102
|
-
];
|
|
103
|
-
export const SCHEMA_TO_SEMANTIC_RULES = [
|
|
104
|
-
{
|
|
105
|
-
element_type: "field",
|
|
106
|
-
type_name: "object",
|
|
107
|
-
semantic_explanation: "Permission object address. STRING=operate existing; null/omitted=create new",
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
element_type: "field",
|
|
111
|
-
type_name: "description",
|
|
112
|
-
semantic_explanation: "Human-readable description of this Permission's purpose",
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
element_type: "field",
|
|
116
|
-
type_name: "admin",
|
|
117
|
-
semantic_explanation: "Admin list management. Admin can modify table/remark/entity/description but cannot transfer ownership",
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
element_type: "field",
|
|
121
|
-
type_name: "table",
|
|
122
|
-
semantic_explanation: "Permission table operations. 'by index' = permission-centric (one perm, many entities); 'by entity' = entity-centric (one entity, many perms)",
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
element_type: "field",
|
|
126
|
-
type_name: "entity",
|
|
127
|
-
semantic_explanation: "Bulk entity operations (swap/replace/copy/del). Affects all permission indexes of affected entities",
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
element_type: "field",
|
|
131
|
-
type_name: "remark",
|
|
132
|
-
semantic_explanation: "Documentation for permission indexes. Highly recommended for custom indexes >= 1000",
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
element_type: "field",
|
|
136
|
-
type_name: "apply",
|
|
137
|
-
semantic_explanation: "Bind Permission to target objects. Signer must be owner of those target objects",
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
element_type: "field",
|
|
141
|
-
type_name: "builder",
|
|
142
|
-
semantic_explanation: "Transfer ownership. IRREVERSIBLE. Original owner loses ALL control",
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
element_type: "field",
|
|
146
|
-
type_name: "um",
|
|
147
|
-
semantic_explanation: "User Manager (Contact object address). UM ≠ admin; UM is for contact management",
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
element_type: "field",
|
|
151
|
-
type_name: "owner_receive",
|
|
152
|
-
semantic_explanation: "Unwrap received objects and send to owner",
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
element_type: "op",
|
|
156
|
-
type_name: "add perm by index",
|
|
157
|
-
semantic_explanation: "Grant a permission index to multiple entities (additive)",
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
element_type: "op",
|
|
161
|
-
type_name: "set perm by index",
|
|
162
|
-
semantic_explanation: "REPLACE the entity list for a permission index (destructive)",
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
element_type: "op",
|
|
166
|
-
type_name: "remove perm by index",
|
|
167
|
-
semantic_explanation: "Revoke a permission index from multiple entities",
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
element_type: "op",
|
|
171
|
-
type_name: "add perm by entity",
|
|
172
|
-
semantic_explanation: "Grant multiple permission indexes to one entity (additive)",
|
|
173
|
-
},
|
|
174
|
-
{
|
|
175
|
-
element_type: "op",
|
|
176
|
-
type_name: "set perm by entity",
|
|
177
|
-
semantic_explanation: "REPLACE all permission indexes for an entity (destructive)",
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
element_type: "op",
|
|
181
|
-
type_name: "remove perm by entity",
|
|
182
|
-
semantic_explanation: "Revoke multiple permission indexes from one entity",
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
element_type: "op",
|
|
186
|
-
type_name: "swap",
|
|
187
|
-
semantic_explanation: "Exchange ALL permission indexes between two entities",
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
element_type: "op",
|
|
191
|
-
type_name: "replace",
|
|
192
|
-
semantic_explanation: "Move all permission indexes from entity1 to entity2; entity1 loses all permissions",
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
element_type: "op",
|
|
196
|
-
type_name: "copy",
|
|
197
|
-
semantic_explanation: "Copy all permission indexes from entity1 to entity2 (additive); entity1 retains permissions",
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
element_type: "op",
|
|
201
|
-
type_name: "del",
|
|
202
|
-
semantic_explanation: "Delete an entity and all its permission indexes",
|
|
203
|
-
},
|
|
204
|
-
];
|
|
205
|
-
export const PERMISSION_CONSTRAINT_RULES = [
|
|
206
|
-
{
|
|
207
|
-
id: "MC-P-01",
|
|
208
|
-
category: "structural",
|
|
209
|
-
rule: "Custom permission index must be >= 1000 (USER_DEFINED_PERM_INDEX_START)",
|
|
210
|
-
applies_to: ["table.index", "remark.index"],
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
id: "MC-P-02",
|
|
214
|
-
category: "structural",
|
|
215
|
-
rule: "Builtin permission indexes (0-999) must match their host object type",
|
|
216
|
-
applies_to: ["table.index", "apply"],
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
id: "MC-P-03",
|
|
220
|
-
category: "structural",
|
|
221
|
-
rule: "Entity count <= MAX_ENTITY_COUNT (1000)",
|
|
222
|
-
applies_to: ["table.entity", "entity.entity1", "entity.entity2"],
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
id: "MC-P-04",
|
|
226
|
-
category: "structural",
|
|
227
|
-
rule: "Per-entity permission count <= MAX_PERM_FOR_ENTITY (1000)",
|
|
228
|
-
applies_to: ["table.index (when array)"],
|
|
229
|
-
},
|
|
230
|
-
{
|
|
231
|
-
id: "MC-P-05",
|
|
232
|
-
category: "structural",
|
|
233
|
-
rule: "Admin count <= MAX_ADMIN_COUNT (500)",
|
|
234
|
-
applies_to: ["admin.addresses"],
|
|
235
|
-
},
|
|
236
|
-
{
|
|
237
|
-
id: "MC-P-06",
|
|
238
|
-
category: "authority",
|
|
239
|
-
rule: "Only owner can call builder (transfer) and um_set (assert_owner)",
|
|
240
|
-
applies_to: ["builder", "um"],
|
|
241
|
-
},
|
|
242
|
-
{
|
|
243
|
-
id: "MC-P-07",
|
|
244
|
-
category: "authority",
|
|
245
|
-
rule: "Only admin can modify description/remark/table/entity/admin (assert_admin)",
|
|
246
|
-
applies_to: ["description", "remark", "table", "entity", "admin"],
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
id: "MC-P-08",
|
|
250
|
-
category: "lifecycle",
|
|
251
|
-
rule: "Ownership transfer is irreversible; new owner auto-becomes admin",
|
|
252
|
-
applies_to: ["builder"],
|
|
253
|
-
},
|
|
254
|
-
{
|
|
255
|
-
id: "MC-P-09",
|
|
256
|
-
category: "semantic",
|
|
257
|
-
rule: "UM is for contact management only; UM ≠ admin (cannot modify permissions)",
|
|
258
|
-
applies_to: ["um"],
|
|
259
|
-
},
|
|
260
|
-
{
|
|
261
|
-
id: "MC-P-10",
|
|
262
|
-
category: "cross_object",
|
|
263
|
-
rule: "apply target object type must match the permission indexes used",
|
|
264
|
-
applies_to: ["apply", "table.index"],
|
|
265
|
-
},
|
|
266
|
-
{
|
|
267
|
-
id: "MC-P-11",
|
|
268
|
-
category: "cross_object",
|
|
269
|
-
rule: "Once Permission is bound to Progress (which binds Machine), post-publish permission table changes have limited effect",
|
|
270
|
-
applies_to: ["apply (Progress)"],
|
|
271
|
-
},
|
|
272
|
-
{
|
|
273
|
-
id: "MC-P-12",
|
|
274
|
-
category: "semantic",
|
|
275
|
-
rule: "Custom permission indexes (>= 1000) should have remark for maintainability",
|
|
276
|
-
applies_to: ["remark", "table.index"],
|
|
277
|
-
},
|
|
278
|
-
];
|
|
279
|
-
export const PERMISSION_TRANSLATION_VERSION = "1.0.0";
|
|
280
|
-
export function matchSemanticPattern(userIntent) {
|
|
281
|
-
const lower = userIntent.toLowerCase();
|
|
282
|
-
return SEMANTIC_TO_SCHEMA_RULES.filter(rule => rule.match_keywords.some(kw => lower.includes(kw.toLowerCase())));
|
|
283
|
-
}
|
|
284
|
-
export function explainPermissionCallData(data) {
|
|
285
|
-
const lines = [];
|
|
286
|
-
if (data.object === null || data.object === undefined) {
|
|
287
|
-
lines.push("Operation: CREATE new Permission");
|
|
288
|
-
}
|
|
289
|
-
else {
|
|
290
|
-
lines.push(`Operation: MODIFY existing Permission at ${data.object}`);
|
|
291
|
-
}
|
|
292
|
-
if (data.description)
|
|
293
|
-
lines.push(`- Set description: "${data.description}"`);
|
|
294
|
-
if (data.admin) {
|
|
295
|
-
lines.push(`- Admin ${data.admin.op}: [${data.admin.addresses.join(", ")}]`);
|
|
296
|
-
}
|
|
297
|
-
if (data.table) {
|
|
298
|
-
const t = data.table;
|
|
299
|
-
if (typeof t.index === "number") {
|
|
300
|
-
const builtin = getBuiltinPermissionByIndex(t.index);
|
|
301
|
-
const indexDesc = builtin ? `${builtin.name} (${builtin.description})` : `custom index ${t.index}`;
|
|
302
|
-
lines.push(`- Table ${t.op}: ${indexDesc}`);
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
if (data.entity) {
|
|
306
|
-
const e = data.entity;
|
|
307
|
-
if (e.op === "del") {
|
|
308
|
-
lines.push(`- Entity del: remove ${e.entity} and all its permissions`);
|
|
309
|
-
}
|
|
310
|
-
else if (e.entity1 && e.entity2) {
|
|
311
|
-
lines.push(`- Entity ${e.op}: ${e.entity1} → ${e.entity2}`);
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
if (data.remark) {
|
|
315
|
-
const r = data.remark;
|
|
316
|
-
if (r.op === "set")
|
|
317
|
-
lines.push(`- Remark set: index ${r.index} = "${r.remark}"`);
|
|
318
|
-
else if (r.op === "remove")
|
|
319
|
-
lines.push(`- Remark remove: index ${r.index}`);
|
|
320
|
-
else if (r.op === "clear")
|
|
321
|
-
lines.push(`- Remark clear: all indexes`);
|
|
322
|
-
}
|
|
323
|
-
if (data.apply && data.apply.length > 0) {
|
|
324
|
-
lines.push(`- Apply to: ${data.apply.join(", ")}`);
|
|
325
|
-
}
|
|
326
|
-
if (data.builder) {
|
|
327
|
-
lines.push(`- ⚠️ TRANSFER ownership to ${data.builder} (IRREVERSIBLE)`);
|
|
328
|
-
}
|
|
329
|
-
if (data.um !== undefined) {
|
|
330
|
-
lines.push(data.um === null ? `- UM: revoke` : `- UM: set to ${data.um}`);
|
|
331
|
-
}
|
|
332
|
-
return lines.join("\n");
|
|
333
|
-
}
|
|
334
|
-
export function explainField(fieldName) {
|
|
335
|
-
return SCHEMA_TO_SEMANTIC_RULES.find(r => r.element_type === "field" && r.type_name === fieldName);
|
|
336
|
-
}
|
|
337
|
-
export function explainOp(opName) {
|
|
338
|
-
return SCHEMA_TO_SEMANTIC_RULES.find(r => r.element_type === "op" && r.type_name === opName);
|
|
339
|
-
}
|
|
340
|
-
export function getConstraintsByCategory(category) {
|
|
341
|
-
return PERMISSION_CONSTRAINT_RULES.filter(r => r.category === category);
|
|
342
|
-
}
|
|
343
|
-
export function explainPermissionIndex(index) {
|
|
344
|
-
if (isBuiltinPermission(index)) {
|
|
345
|
-
const entry = getBuiltinPermissionByIndex(index);
|
|
346
|
-
const scene = findSceneByPermissionIndex(index);
|
|
347
|
-
return `${entry?.name ?? "Unknown"} (${index}) — ${entry?.description ?? ""} [host: ${scene?.host_object ?? "unknown"}]`;
|
|
348
|
-
}
|
|
349
|
-
return `Custom permission (${index}) — must be documented via remark`;
|
|
350
|
-
}
|
|
1
|
+
import{isBuiltinPermission,getBuiltinPermissionByIndex,findSceneByPermissionIndex}from'./permission-ledger.js';export const SEMANTIC_TO_SCHEMA_RULES=[{'id':'P-P-01','pattern_name':'Create\x20new\x20Permission','semantic_intent':'Create\x20a\x20new\x20Permission\x20for\x20a\x20Service/Machine/Treasury/etc.','match_keywords':['create','new'],'schema_fields':['object(null)','description','admin','table','remark'],'example_json':{'object':null,'description':'Permission\x20for\x20myshop\x20service','admin':{'op':'set','addresses':['0xOWNER','0xADMIN1']},'table':{'op':'set\x20perm\x20by\x20index','index':0x137,'entity':['0xUSER1','0xUSER2']},'remark':{'op':'set','index':0x137,'remark':'service.publish'}},'reverse_explanation':'object=null\x20indicates\x20creation;\x20admin/table/remark\x20initialize\x20the\x20permission'},{'id':'P-P-02','pattern_name':'Grant\x20permission\x20to\x20entities','semantic_intent':'Grant\x20a\x20specific\x20permission\x20index\x20to\x20multiple\x20entities','match_keywords':['grant','authorize'],'schema_fields':['object','table(op=add\x20perm\x20by\x20index)'],'example_json':{'object':'0xPERMISSION_ADDRESS','table':{'op':'add\x20perm\x20by\x20index','index':0x139,'entity':['0xNEW_USER']}},'reverse_explanation':'table.op=\x27add\x20perm\x20by\x20index\x27\x20adds\x20entities\x20to\x20an\x20existing\x20permission\x20index'},{'id':'P-P-03','pattern_name':'Set\x20admin\x20list','semantic_intent':'Replace\x20the\x20admin\x20list','match_keywords':['admin','set\x20admin'],'schema_fields':['object','admin(op=set)'],'example_json':{'object':'0xPERMISSION_ADDRESS','admin':{'op':'set','addresses':['0xADMIN1','0xADMIN2','0xADMIN3']}},'reverse_explanation':'admin.op=\x27set\x27\x20overwrites\x20the\x20entire\x20admin\x20list'},{'id':'P-P-04','pattern_name':'Transfer\x20ownership','semantic_intent':'Transfer\x20Permission\x20ownership\x20to\x20a\x20new\x20address','match_keywords':['transfer','handover'],'schema_fields':['object','builder'],'example_json':{'object':'0xPERMISSION_ADDRESS','builder':'0xNEW_OWNER'},'reverse_explanation':'builder\x20field\x20triggers\x20ownership\x20transfer;\x20irreversible'},{'id':'P-P-05','pattern_name':'Set/clear\x20UM\x20(User\x20Manager)','semantic_intent':'Delegate\x20UM\x20management\x20or\x20revoke\x20UM','match_keywords':['um','user\x20manager','delegate','contact'],'schema_fields':['object','um'],'example_json':{'object':'0xPERMISSION_ADDRESS','um':'0xUM_ADDRESS'},'reverse_explanation':'um=null\x20revokes;\x20um=<address>\x20delegates\x20to\x20Contact\x20object'},{'id':'P-P-06','pattern_name':'Apply\x20Permission\x20to\x20other\x20objects','semantic_intent':'Apply\x20Permission\x20to\x20Service/Machine/Treasury/Arbitration/Repository/Reward/Demand','match_keywords':['apply','bind'],'schema_fields':['object','apply'],'example_json':{'object':'0xPERMISSION_ADDRESS','apply':['0xSERVICE_ADDRESS','0xMACHINE_ADDRESS']},'reverse_explanation':'apply\x20field\x20binds\x20Permission\x20to\x20target\x20objects;\x20signer\x20must\x20be\x20owner\x20of\x20those\x20objects'},{'id':'P-P-07','pattern_name':'Manage\x20remarks','semantic_intent':'Add/remove/clear\x20remarks\x20for\x20permission\x20indexes','match_keywords':['remark','note'],'schema_fields':['object','remark'],'example_json':{'object':'0xPERMISSION_ADDRESS','remark':{'op':'set','index':0x3e8,'remark':'custom.refund_approval'}},'reverse_explanation':'remark.op=\x27set|remove|clear\x27\x20manages\x20documentation\x20for\x20permission\x20indexes'},{'id':'P-P-08','pattern_name':'Entity\x20batch\x20operations','semantic_intent':'Swap/replace/copy/del\x20entities','match_keywords':['swap','replace','copy','del'],'schema_fields':['object','entity'],'example_json':{'object':'0xPERMISSION_ADDRESS','entity':{'op':'swap','entity1':'0xUSER1','entity2':'0xUSER2'}},'reverse_explanation':'entity.op\x20manages\x20bulk\x20entity-permission\x20reassignments'}];export const SCHEMA_TO_SEMANTIC_RULES=[{'element_type':'field','type_name':'object','semantic_explanation':'Permission\x20object\x20address.\x20STRING=operate\x20existing;\x20null/omitted=create\x20new'},{'element_type':'field','type_name':'description','semantic_explanation':'Human-readable\x20description\x20of\x20this\x20Permission\x27s\x20purpose'},{'element_type':'field','type_name':'admin','semantic_explanation':'Admin\x20list\x20management.\x20Admin\x20can\x20modify\x20table/remark/entity/description\x20but\x20cannot\x20transfer\x20ownership'},{'element_type':'field','type_name':'table','semantic_explanation':'Permission\x20table\x20operations.\x20\x27by\x20index\x27\x20=\x20permission-centric\x20(one\x20perm,\x20many\x20entities);\x20\x27by\x20entity\x27\x20=\x20entity-centric\x20(one\x20entity,\x20many\x20perms)'},{'element_type':'field','type_name':'entity','semantic_explanation':'Bulk\x20entity\x20operations\x20(swap/replace/copy/del).\x20Affects\x20all\x20permission\x20indexes\x20of\x20affected\x20entities'},{'element_type':'field','type_name':'remark','semantic_explanation':'Documentation\x20for\x20permission\x20indexes.\x20Highly\x20recommended\x20for\x20custom\x20indexes\x20>=\x201000'},{'element_type':'field','type_name':'apply','semantic_explanation':'Bind\x20Permission\x20to\x20target\x20objects.\x20Signer\x20must\x20be\x20owner\x20of\x20those\x20target\x20objects'},{'element_type':'field','type_name':'builder','semantic_explanation':'Transfer\x20ownership.\x20IRREVERSIBLE.\x20Original\x20owner\x20loses\x20ALL\x20control'},{'element_type':'field','type_name':'um','semantic_explanation':'User\x20Manager\x20(Contact\x20object\x20address).\x20UM\x20≠\x20admin;\x20UM\x20is\x20for\x20contact\x20management'},{'element_type':'field','type_name':'owner_receive','semantic_explanation':'Unwrap\x20received\x20objects\x20and\x20send\x20to\x20owner'},{'element_type':'op','type_name':'add\x20perm\x20by\x20index','semantic_explanation':'Grant\x20a\x20permission\x20index\x20to\x20multiple\x20entities\x20(additive)'},{'element_type':'op','type_name':'set\x20perm\x20by\x20index','semantic_explanation':'REPLACE\x20the\x20entity\x20list\x20for\x20a\x20permission\x20index\x20(destructive)'},{'element_type':'op','type_name':'remove\x20perm\x20by\x20index','semantic_explanation':'Revoke\x20a\x20permission\x20index\x20from\x20multiple\x20entities'},{'element_type':'op','type_name':'add\x20perm\x20by\x20entity','semantic_explanation':'Grant\x20multiple\x20permission\x20indexes\x20to\x20one\x20entity\x20(additive)'},{'element_type':'op','type_name':'set\x20perm\x20by\x20entity','semantic_explanation':'REPLACE\x20all\x20permission\x20indexes\x20for\x20an\x20entity\x20(destructive)'},{'element_type':'op','type_name':'remove\x20perm\x20by\x20entity','semantic_explanation':'Revoke\x20multiple\x20permission\x20indexes\x20from\x20one\x20entity'},{'element_type':'op','type_name':'swap','semantic_explanation':'Exchange\x20ALL\x20permission\x20indexes\x20between\x20two\x20entities'},{'element_type':'op','type_name':'replace','semantic_explanation':'Move\x20all\x20permission\x20indexes\x20from\x20entity1\x20to\x20entity2;\x20entity1\x20loses\x20all\x20permissions'},{'element_type':'op','type_name':'copy','semantic_explanation':'Copy\x20all\x20permission\x20indexes\x20from\x20entity1\x20to\x20entity2\x20(additive);\x20entity1\x20retains\x20permissions'},{'element_type':'op','type_name':'del','semantic_explanation':'Delete\x20an\x20entity\x20and\x20all\x20its\x20permission\x20indexes'}];export const PERMISSION_CONSTRAINT_RULES=[{'id':'MC-P-01','category':'structural','rule':'Custom\x20permission\x20index\x20must\x20be\x20>=\x201000\x20(USER_DEFINED_PERM_INDEX_START)','applies_to':['table.index','remark.index']},{'id':'MC-P-02','category':'structural','rule':'Builtin\x20permission\x20indexes\x20(0-999)\x20must\x20match\x20their\x20host\x20object\x20type','applies_to':['table.index','apply']},{'id':'MC-P-03','category':'structural','rule':'Entity\x20count\x20<=\x20MAX_ENTITY_COUNT\x20(1000)','applies_to':['table.entity','entity.entity1','entity.entity2']},{'id':'MC-P-04','category':'structural','rule':'Per-entity\x20permission\x20count\x20<=\x20MAX_PERM_FOR_ENTITY\x20(1000)','applies_to':['table.index\x20(when\x20array)']},{'id':'MC-P-05','category':'structural','rule':'Admin\x20count\x20<=\x20MAX_ADMIN_COUNT\x20(500)','applies_to':['admin.addresses']},{'id':'MC-P-06','category':'authority','rule':'Only\x20owner\x20can\x20call\x20builder\x20(transfer)\x20and\x20um_set\x20(assert_owner)','applies_to':['builder','um']},{'id':'MC-P-07','category':'authority','rule':'Only\x20admin\x20can\x20modify\x20description/remark/table/entity/admin\x20(assert_admin)','applies_to':['description','remark','table','entity','admin']},{'id':'MC-P-08','category':'lifecycle','rule':'Ownership\x20transfer\x20is\x20irreversible;\x20new\x20owner\x20auto-becomes\x20admin','applies_to':['builder']},{'id':'MC-P-09','category':'semantic','rule':'UM\x20is\x20for\x20contact\x20management\x20only;\x20UM\x20≠\x20admin\x20(cannot\x20modify\x20permissions)','applies_to':['um']},{'id':'MC-P-10','category':'cross_object','rule':'apply\x20target\x20object\x20type\x20must\x20match\x20the\x20permission\x20indexes\x20used','applies_to':['apply','table.index']},{'id':'MC-P-11','category':'cross_object','rule':'Once\x20Permission\x20is\x20bound\x20to\x20Progress\x20(which\x20binds\x20Machine),\x20post-publish\x20permission\x20table\x20changes\x20have\x20limited\x20effect','applies_to':['apply\x20(Progress)']},{'id':'MC-P-12','category':'semantic','rule':'Custom\x20permission\x20indexes\x20(>=\x201000)\x20should\x20have\x20remark\x20for\x20maintainability','applies_to':['remark','table.index']}];export const PERMISSION_TRANSLATION_VERSION='1.0.0';export function matchSemanticPattern(a){const b=a['toLowerCase']();return SEMANTIC_TO_SCHEMA_RULES['filter'](c=>c['match_keywords']['some'](d=>b['includes'](d['toLowerCase']())));}export function explainPermissionCallData(a){const b=[];a['object']===null||a['object']===undefined?b['push']('Operation:\x20CREATE\x20new\x20Permission'):b['push']('Operation:\x20MODIFY\x20existing\x20Permission\x20at\x20'+a['object']);if(a['description'])b['push']('-\x20Set\x20description:\x20\x22'+a['description']+'\x22');a['admin']&&b['push']('-\x20Admin\x20'+a['admin']['op']+':\x20['+a['admin']['addresses']['join'](',\x20')+']');if(a['table']){const c=a['table'];if(typeof c['index']==='number'){const d=getBuiltinPermissionByIndex(c['index']),f=d?d['name']+'\x20('+d['description']+')':'custom\x20index\x20'+c['index'];b['push']('-\x20Table\x20'+c['op']+':\x20'+f);}}if(a['entity']){const g=a['entity'];if(g['op']==='del')b['push']('-\x20Entity\x20del:\x20remove\x20'+g['entity']+'\x20and\x20all\x20its\x20permissions');else g['entity1']&&g['entity2']&&b['push']('-\x20Entity\x20'+g['op']+':\x20'+g['entity1']+'\x20→\x20'+g['entity2']);}if(a['remark']){const h=a['remark'];if(h['op']==='set')b['push']('-\x20Remark\x20set:\x20index\x20'+h['index']+'\x20=\x20\x22'+h['remark']+'\x22');else{if(h['op']==='remove')b['push']('-\x20Remark\x20remove:\x20index\x20'+h['index']);else{if(h['op']==='clear')b['push']('-\x20Remark\x20clear:\x20all\x20indexes');}}}return a['apply']&&a['apply']['length']>0x0&&b['push']('-\x20Apply\x20to:\x20'+a['apply']['join'](',\x20')),a['builder']&&b['push']('-\x20⚠️\x20TRANSFER\x20ownership\x20to\x20'+a['builder']+'\x20(IRREVERSIBLE)'),a['um']!==undefined&&b['push'](a['um']===null?'-\x20UM:\x20revoke':'-\x20UM:\x20set\x20to\x20'+a['um']),b['join']('\x0a');}export function explainField(a){return SCHEMA_TO_SEMANTIC_RULES['find'](b=>b['element_type']==='field'&&b['type_name']===a);}export function explainOp(a){return SCHEMA_TO_SEMANTIC_RULES['find'](b=>b['element_type']==='op'&&b['type_name']===a);}export function getConstraintsByCategory(a){return PERMISSION_CONSTRAINT_RULES['filter'](b=>b['category']===a);}export function explainPermissionIndex(a){if(isBuiltinPermission(a)){const b=getBuiltinPermissionByIndex(a),c=findSceneByPermissionIndex(a);return(b?.['name']??'Unknown')+'\x20('+a+')\x20—\x20'+(b?.['description']??'')+'\x20[host:\x20'+(c?.['host_object']??'unknown')+']';}return'Custom\x20permission\x20('+a+')\x20—\x20must\x20be\x20documented\x20via\x20remark';}
|