@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,369 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { MachineNodeSchema, MachineNodePairSchema, MachineForwardSchema } from '../query/index.js';
|
|
3
|
-
import { writeFileSync } from 'fs';
|
|
4
|
-
function detectFormat(text) {
|
|
5
|
-
const trimmed = text.trim();
|
|
6
|
-
if (trimmed.startsWith('{') || trimmed.startsWith('[')) {
|
|
7
|
-
return 'json';
|
|
8
|
-
}
|
|
9
|
-
return 'markdown';
|
|
10
|
-
}
|
|
11
|
-
function extractJsonFromMarkdown(markdown) {
|
|
12
|
-
const codeBlockRegex = /```(?:json)?\s*\n([\s\S]*?)```/g;
|
|
13
|
-
let match;
|
|
14
|
-
let lastMatch = null;
|
|
15
|
-
while ((match = codeBlockRegex.exec(markdown)) !== null) {
|
|
16
|
-
const jsonContent = match[1].trim();
|
|
17
|
-
if (jsonContent.startsWith('[') || jsonContent.startsWith('{')) {
|
|
18
|
-
const beforeMatch = markdown.substring(0, match.index);
|
|
19
|
-
const lineOffset = (beforeMatch.match(/\n/g) || []).length + 1;
|
|
20
|
-
lastMatch = { json: jsonContent, lineOffset };
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return lastMatch;
|
|
24
|
-
}
|
|
25
|
-
function parseMarkdownToNodeData(markdown) {
|
|
26
|
-
const errors = [];
|
|
27
|
-
const jsonMatch = extractJsonFromMarkdown(markdown);
|
|
28
|
-
if (jsonMatch) {
|
|
29
|
-
try {
|
|
30
|
-
const data = JSON.parse(jsonMatch.json);
|
|
31
|
-
return { data, errors: [] };
|
|
32
|
-
}
|
|
33
|
-
catch (e) {
|
|
34
|
-
errors.push({
|
|
35
|
-
message: `Failed to parse JSON from markdown: ${e.message}`,
|
|
36
|
-
path: '/',
|
|
37
|
-
});
|
|
38
|
-
return { data: null, errors };
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
const result = { op: 'add' };
|
|
42
|
-
const nodes = [];
|
|
43
|
-
const opMatch = markdown.match(/(?:^|\n)#+\s*Operation[^\n]*\n+[-*]\s*op\s*:\s*(\w+)/i);
|
|
44
|
-
if (opMatch) {
|
|
45
|
-
result.op = opMatch[1].toLowerCase();
|
|
46
|
-
}
|
|
47
|
-
const replaceMatch = markdown.match(/(?:^|\n)#+\s*Options[^\n]*\n+[-*]\s*bReplace\s*:\s*(true|false)/i);
|
|
48
|
-
if (replaceMatch) {
|
|
49
|
-
result.bReplace = replaceMatch[1].toLowerCase() === 'true';
|
|
50
|
-
}
|
|
51
|
-
const nodeSections = markdown.split(/(?=^##\s*Node[:\s])/m);
|
|
52
|
-
for (const section of nodeSections.slice(1)) {
|
|
53
|
-
const nodeNameMatch = section.match(/^##\s*Node[:\s]+(.+?)(?:\n|$)/im);
|
|
54
|
-
if (!nodeNameMatch)
|
|
55
|
-
continue;
|
|
56
|
-
const nodeName = nodeNameMatch[1].trim();
|
|
57
|
-
const node = { name: nodeName, pairs: [] };
|
|
58
|
-
const pairSections = section.split(/(?=^###\s*(?:Pair|Previous Node)[:\s])/m);
|
|
59
|
-
for (const pairSection of pairSections.slice(1)) {
|
|
60
|
-
const prevNodeMatch = pairSection.match(/(?:^|\n)[-*]\s*prev_node\s*[:]\s*(.+?)(?:\n|$)/im) ||
|
|
61
|
-
pairSection.match(/^###\s*(?:Pair|Previous Node)[:\s]+(.+?)(?:\n|$)/im);
|
|
62
|
-
const thresholdMatch = pairSection.match(/(?:^|\n)[-*]\s*threshold\s*[:]\s*(\d+)/i);
|
|
63
|
-
if (!prevNodeMatch)
|
|
64
|
-
continue;
|
|
65
|
-
const pair = {
|
|
66
|
-
prev_node: prevNodeMatch[1].trim(),
|
|
67
|
-
threshold: thresholdMatch ? parseInt(thresholdMatch[1], 10) : 0,
|
|
68
|
-
forwards: []
|
|
69
|
-
};
|
|
70
|
-
const tableRows = pairSection.match(/\|[^\n]+\|/g);
|
|
71
|
-
if (tableRows && tableRows.length > 2) {
|
|
72
|
-
for (const row of tableRows.slice(2)) {
|
|
73
|
-
const cells = row.split('|').filter(c => c.trim()).map(c => c.trim());
|
|
74
|
-
if (cells.length >= 2) {
|
|
75
|
-
const forward = {
|
|
76
|
-
name: cells[0],
|
|
77
|
-
weight: parseInt(cells[1], 10) || 0
|
|
78
|
-
};
|
|
79
|
-
if (cells.length >= 3 && cells[2] && cells[2] !== '-') {
|
|
80
|
-
forward.namedOperator = cells[2];
|
|
81
|
-
}
|
|
82
|
-
if (cells.length >= 4 && cells[3] && cells[3] !== '-') {
|
|
83
|
-
forward.permissionIndex = parseInt(cells[3], 10);
|
|
84
|
-
}
|
|
85
|
-
if (cells.length >= 5 && cells[4] && cells[4] !== '-') {
|
|
86
|
-
forward.guard = cells[4];
|
|
87
|
-
}
|
|
88
|
-
pair.forwards.push(forward);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
const forwardMatches = pairSection.matchAll(/(?:^|\n)[-*]\s*(?:forward)?\s*[:]?\s*\n?([\s\S]*?)(?=(?:\n[-*]\s*(?:forward|prev_node|threshold))|\n###|\n##|$)/gi);
|
|
93
|
-
for (const forwardMatch of forwardMatches) {
|
|
94
|
-
const forwardSection = forwardMatch[1];
|
|
95
|
-
const nameMatch = forwardSection.match(/\s*name\s*[:]\s*(.+?)(?:\n|$)/im);
|
|
96
|
-
const weightMatch = forwardSection.match(/\s*weight\s*[:]\s*(\d+)/i);
|
|
97
|
-
if (nameMatch && weightMatch) {
|
|
98
|
-
const forward = {
|
|
99
|
-
name: nameMatch[1].trim(),
|
|
100
|
-
weight: parseInt(weightMatch[1], 10)
|
|
101
|
-
};
|
|
102
|
-
const namedOperatorMatch = forwardSection.match(/\s*namedOperator\s*[:]\s*(.+?)(?:\n|$)/im);
|
|
103
|
-
const permissionIndexMatch = forwardSection.match(/\s*permissionIndex\s*[:]\s*(\d+)/i);
|
|
104
|
-
const guardMatch = forwardSection.match(/\s*guard\s*[:]\s*(.+?)(?:\n|$)/im);
|
|
105
|
-
if (namedOperatorMatch) {
|
|
106
|
-
forward.namedOperator = namedOperatorMatch[1].trim();
|
|
107
|
-
}
|
|
108
|
-
if (permissionIndexMatch) {
|
|
109
|
-
forward.permissionIndex = parseInt(permissionIndexMatch[1], 10);
|
|
110
|
-
}
|
|
111
|
-
if (guardMatch) {
|
|
112
|
-
forward.guard = guardMatch[1].trim();
|
|
113
|
-
}
|
|
114
|
-
pair.forwards.push(forward);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
node.pairs.push(pair);
|
|
118
|
-
}
|
|
119
|
-
nodes.push(node);
|
|
120
|
-
}
|
|
121
|
-
if (nodes.length > 0) {
|
|
122
|
-
result.nodes = nodes;
|
|
123
|
-
}
|
|
124
|
-
return { data: result, errors };
|
|
125
|
-
}
|
|
126
|
-
function formatZodPath(path) {
|
|
127
|
-
return '/' + path.map(p => String(p).replace(/~/g, '~0').replace(/\//g, '~1')).join('/');
|
|
128
|
-
}
|
|
129
|
-
function parseJsonWithErrors(text) {
|
|
130
|
-
const errors = [];
|
|
131
|
-
try {
|
|
132
|
-
const data = JSON.parse(text);
|
|
133
|
-
return { data, errors: [] };
|
|
134
|
-
}
|
|
135
|
-
catch (e) {
|
|
136
|
-
const jsonError = e;
|
|
137
|
-
const lineMatch = jsonError.message.match(/position\s+(\d+)/);
|
|
138
|
-
let line = 1;
|
|
139
|
-
let column = 1;
|
|
140
|
-
if (lineMatch) {
|
|
141
|
-
const pos = parseInt(lineMatch[1], 10);
|
|
142
|
-
const lines = text.substring(0, pos).split('\n');
|
|
143
|
-
line = lines.length;
|
|
144
|
-
column = lines[lines.length - 1].length + 1;
|
|
145
|
-
}
|
|
146
|
-
errors.push({
|
|
147
|
-
message: `JSON parse error: ${jsonError.message}`,
|
|
148
|
-
path: '/',
|
|
149
|
-
line,
|
|
150
|
-
column,
|
|
151
|
-
});
|
|
152
|
-
return { data: null, errors };
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
function validateWithZod(schema, data, basePath = '') {
|
|
156
|
-
const errors = [];
|
|
157
|
-
const result = schema.safeParse(data);
|
|
158
|
-
if (result.success) {
|
|
159
|
-
return { success: true, data: result.data, errors: [] };
|
|
160
|
-
}
|
|
161
|
-
for (const issue of result.error.issues) {
|
|
162
|
-
const path = basePath + formatZodPath(issue.path);
|
|
163
|
-
errors.push({
|
|
164
|
-
message: issue.message,
|
|
165
|
-
path,
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
return { success: false, errors };
|
|
169
|
-
}
|
|
170
|
-
export function parseNodeFromText(text) {
|
|
171
|
-
const trimmed = text.trim();
|
|
172
|
-
const format = detectFormat(trimmed);
|
|
173
|
-
let parsedData;
|
|
174
|
-
let errors = [];
|
|
175
|
-
if (format === 'markdown') {
|
|
176
|
-
const mdResult = parseMarkdownToNodeData(trimmed);
|
|
177
|
-
if (mdResult.errors.length > 0) {
|
|
178
|
-
return { success: false, errors: mdResult.errors };
|
|
179
|
-
}
|
|
180
|
-
parsedData = mdResult.data;
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
const jsonResult = parseJsonWithErrors(trimmed);
|
|
184
|
-
if (jsonResult.errors.length > 0) {
|
|
185
|
-
return { success: false, errors: jsonResult.errors };
|
|
186
|
-
}
|
|
187
|
-
parsedData = jsonResult.data;
|
|
188
|
-
}
|
|
189
|
-
const validation = validateWithZod(NodeSchema, parsedData);
|
|
190
|
-
return {
|
|
191
|
-
success: validation.success,
|
|
192
|
-
data: validation.data,
|
|
193
|
-
errors: validation.errors,
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
export function parseMachineNodesFromText(text) {
|
|
197
|
-
const trimmed = text.trim();
|
|
198
|
-
const format = detectFormat(trimmed);
|
|
199
|
-
let parsedData;
|
|
200
|
-
let errors = [];
|
|
201
|
-
if (format === 'markdown') {
|
|
202
|
-
const mdResult = parseMarkdownToNodeData(trimmed);
|
|
203
|
-
if (mdResult.errors.length > 0) {
|
|
204
|
-
return { success: false, errors: mdResult.errors };
|
|
205
|
-
}
|
|
206
|
-
if (typeof mdResult.data === 'object' && mdResult.data !== null && 'nodes' in mdResult.data) {
|
|
207
|
-
parsedData = mdResult.data.nodes;
|
|
208
|
-
}
|
|
209
|
-
else {
|
|
210
|
-
parsedData = mdResult.data;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
else {
|
|
214
|
-
const jsonResult = parseJsonWithErrors(trimmed);
|
|
215
|
-
if (jsonResult.errors.length > 0) {
|
|
216
|
-
return { success: false, errors: jsonResult.errors };
|
|
217
|
-
}
|
|
218
|
-
parsedData = jsonResult.data;
|
|
219
|
-
}
|
|
220
|
-
if (!Array.isArray(parsedData)) {
|
|
221
|
-
if (typeof parsedData === 'object' && parsedData !== null && 'op' in parsedData) {
|
|
222
|
-
return {
|
|
223
|
-
success: false,
|
|
224
|
-
errors: [{
|
|
225
|
-
message: 'Expected JSON array of nodes for json_or_markdown mode. Use schema mode for operations with "op" field.',
|
|
226
|
-
path: '/',
|
|
227
|
-
}]
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
return {
|
|
231
|
-
success: false,
|
|
232
|
-
errors: [{
|
|
233
|
-
message: 'Expected JSON array of nodes',
|
|
234
|
-
path: '/',
|
|
235
|
-
}]
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
const nodes = [];
|
|
239
|
-
for (let i = 0; i < parsedData.length; i++) {
|
|
240
|
-
const nodeData = parsedData[i];
|
|
241
|
-
const validation = validateWithZod(MachineNodeSchema, nodeData, `/${i}`);
|
|
242
|
-
if (validation.success && validation.data) {
|
|
243
|
-
nodes.push(validation.data);
|
|
244
|
-
}
|
|
245
|
-
else {
|
|
246
|
-
errors.push(...validation.errors);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
if (errors.length > 0) {
|
|
250
|
-
return { success: false, errors };
|
|
251
|
-
}
|
|
252
|
-
const hasEntryForward = nodes.some(node => node.pairs.some(pair => pair.prev_node === ""));
|
|
253
|
-
if (!hasEntryForward) {
|
|
254
|
-
return {
|
|
255
|
-
success: false,
|
|
256
|
-
errors: [{
|
|
257
|
-
message: 'Machine has no entry forward. At least one node must have a pair with prev_node="" (empty string), ' +
|
|
258
|
-
'which defines how Progress advances from the initial state (current="") to the first node. ' +
|
|
259
|
-
'Without an entry forward, the workflow will be permanently stuck. ' +
|
|
260
|
-
'Example: {name: "Subscribed", pairs: [{prev_node: "", forwards: [{name: "Subscribe", weight: 1}]}]}',
|
|
261
|
-
path: '/',
|
|
262
|
-
}]
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
return { success: true, data: nodes, errors: [] };
|
|
266
|
-
}
|
|
267
|
-
export function formatNodeErrors(errors) {
|
|
268
|
-
return errors.map(e => {
|
|
269
|
-
let msg = `Path: ${e.path}`;
|
|
270
|
-
if (e.line !== undefined && e.column !== undefined) {
|
|
271
|
-
msg += ` (line ${e.line}, column ${e.column})`;
|
|
272
|
-
}
|
|
273
|
-
msg += `\n Error: ${e.message}`;
|
|
274
|
-
return msg;
|
|
275
|
-
}).join('\n\n');
|
|
276
|
-
}
|
|
277
|
-
export function validateMachineNode(node) {
|
|
278
|
-
return validateWithZod(MachineNodeSchema, node);
|
|
279
|
-
}
|
|
280
|
-
export function validateMachineNodePair(pair) {
|
|
281
|
-
const result = MachineNodePairSchema.safeParse(pair);
|
|
282
|
-
if (result.success) {
|
|
283
|
-
return { success: true, errors: [] };
|
|
284
|
-
}
|
|
285
|
-
const errors = result.error.issues.map(issue => ({
|
|
286
|
-
message: issue.message,
|
|
287
|
-
path: formatZodPath(issue.path),
|
|
288
|
-
}));
|
|
289
|
-
return { success: false, errors };
|
|
290
|
-
}
|
|
291
|
-
export function validateMachineForward(forward) {
|
|
292
|
-
const result = MachineForwardSchema.safeParse(forward);
|
|
293
|
-
if (result.success) {
|
|
294
|
-
return { success: true, errors: [] };
|
|
295
|
-
}
|
|
296
|
-
const errors = result.error.issues.map(issue => ({
|
|
297
|
-
message: issue.message,
|
|
298
|
-
path: formatZodPath(issue.path),
|
|
299
|
-
}));
|
|
300
|
-
return { success: false, errors };
|
|
301
|
-
}
|
|
302
|
-
export function machineNodesToJson(nodes, options = {}) {
|
|
303
|
-
const { machineId, includeComments = true } = options;
|
|
304
|
-
let result = '';
|
|
305
|
-
if (includeComments && machineId) {
|
|
306
|
-
result += `// Machine ID: ${machineId}\n`;
|
|
307
|
-
}
|
|
308
|
-
result += JSON.stringify(nodes, null, 2);
|
|
309
|
-
return result;
|
|
310
|
-
}
|
|
311
|
-
export function machineNodesToMarkdown(nodes, options = {}) {
|
|
312
|
-
const { machineName, machineAddress, machineId, includeComments = true } = options;
|
|
313
|
-
let md = `# Machine Node Definition\n\n`;
|
|
314
|
-
if (machineName) {
|
|
315
|
-
md += `**Machine:** ${machineName}\n\n`;
|
|
316
|
-
}
|
|
317
|
-
if (machineAddress) {
|
|
318
|
-
md += `**Address:** ${machineAddress}\n\n`;
|
|
319
|
-
}
|
|
320
|
-
if (machineId) {
|
|
321
|
-
md += `**ID:** ${machineId}\n\n`;
|
|
322
|
-
}
|
|
323
|
-
md += `**Total Nodes:** ${nodes.length}\n\n`;
|
|
324
|
-
md += `---\n\n`;
|
|
325
|
-
for (const node of nodes) {
|
|
326
|
-
md += `## Node: ${node.name}\n\n`;
|
|
327
|
-
if (includeComments) {
|
|
328
|
-
md += `<!-- Node definition with pairs and forwards -->\n\n`;
|
|
329
|
-
}
|
|
330
|
-
for (const pair of node.pairs) {
|
|
331
|
-
md += `### Pair: ${pair.prev_node}\n\n`;
|
|
332
|
-
md += `- **prev_node**: ${pair.prev_node}\n`;
|
|
333
|
-
md += `- **threshold**: ${pair.threshold}\n\n`;
|
|
334
|
-
if (pair.forwards && pair.forwards.length > 0) {
|
|
335
|
-
md += `#### Forwards\n\n`;
|
|
336
|
-
md += `| name | weight | namedOperator | permissionIndex | guard |\n`;
|
|
337
|
-
md += `|------|--------|---------------|-----------------|-------|\n`;
|
|
338
|
-
for (const forward of pair.forwards) {
|
|
339
|
-
const namedOp = forward.namedOperator || '';
|
|
340
|
-
const permIdx = forward.permissionIndex?.toString() || '';
|
|
341
|
-
const guardRaw = forward.guard;
|
|
342
|
-
const guard = typeof guardRaw === 'string'
|
|
343
|
-
? guardRaw
|
|
344
|
-
: (guardRaw?.guard || '');
|
|
345
|
-
md += `| ${forward.name} | ${forward.weight} | ${namedOp} | ${permIdx} | ${guard} |\n`;
|
|
346
|
-
}
|
|
347
|
-
md += `\n`;
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
md += `---\n\n`;
|
|
351
|
-
}
|
|
352
|
-
md += `## JSON Definition\n\n`;
|
|
353
|
-
if (includeComments) {
|
|
354
|
-
md += `<!-- You can also use the JSON format below -->\n\n`;
|
|
355
|
-
}
|
|
356
|
-
md += `\`\`\`json\n`;
|
|
357
|
-
if (includeComments && machineId) {
|
|
358
|
-
md += `// Machine ID: ${machineId}\n`;
|
|
359
|
-
}
|
|
360
|
-
md += JSON.stringify(nodes, null, 2);
|
|
361
|
-
md += `\n\`\`\`\n`;
|
|
362
|
-
return md;
|
|
363
|
-
}
|
|
364
|
-
export function saveMachineNodesToFile(nodes, filePath, format = 'json', options = {}) {
|
|
365
|
-
const content = format === 'json'
|
|
366
|
-
? machineNodesToJson(nodes, options)
|
|
367
|
-
: machineNodesToMarkdown(nodes, options);
|
|
368
|
-
writeFileSync(filePath, content, 'utf-8');
|
|
369
|
-
}
|
|
1
|
+
import{NodeSchema}from'../call/machine.js';import{MachineNodeSchema,MachineNodePairSchema,MachineForwardSchema}from'../query/index.js';import{writeFileSync}from'fs';function detectFormat(a){const b=a['trim']();if(b['startsWith']('{')||b['startsWith']('['))return'json';return'markdown';}function extractJsonFromMarkdown(a){const b=/```(?:json)?\s*\n([\s\S]*?)```/g;let c,d=null;while((c=b['exec'](a))!==null){const e=c[0x1]['trim']();if(e['startsWith']('[')||e['startsWith']('{')){const f=a['substring'](0x0,c['index']),g=(f['match'](/\n/g)||[])['length']+0x1;d={'json':e,'lineOffset':g};}}return d;}function parseMarkdownToNodeData(a){const b=[],c=extractJsonFromMarkdown(a);if(c)try{const j=JSON['parse'](c['json']);return{'data':j,'errors':[]};}catch(k){return b['push']({'message':'Failed\x20to\x20parse\x20JSON\x20from\x20markdown:\x20'+k['message'],'path':'/'}),{'data':null,'errors':b};}const d={'op':'add'},f=[],g=a['match'](/(?:^|\n)#+\s*Operation[^\n]*\n+[-*]\s*op\s*:\s*(\w+)/i);g&&(d['op']=g[0x1]['toLowerCase']());const h=a['match'](/(?:^|\n)#+\s*Options[^\n]*\n+[-*]\s*bReplace\s*:\s*(true|false)/i);h&&(d['bReplace']=h[0x1]['toLowerCase']()==='true');const i=a['split'](/(?=^##\s*Node[:\s])/m);for(const l of i['slice'](0x1)){const m=l['match'](/^##\s*Node[:\s]+(.+?)(?:\n|$)/im);if(!m)continue;const n=m[0x1]['trim'](),o={'name':n,'pairs':[]},p=l['split'](/(?=^###\s*(?:Pair|Previous Node)[:\s])/m);for(const q of p['slice'](0x1)){const r=q['match'](/(?:^|\n)[-*]\s*prev_node\s*[:]\s*(.+?)(?:\n|$)/im)||q['match'](/^###\s*(?:Pair|Previous Node)[:\s]+(.+?)(?:\n|$)/im),s=q['match'](/(?:^|\n)[-*]\s*threshold\s*[:]\s*(\d+)/i);if(!r)continue;const t={'prev_node':r[0x1]['trim'](),'threshold':s?parseInt(s[0x1],0xa):0x0,'forwards':[]},u=q['match'](/\|[^\n]+\|/g);if(u&&u['length']>0x2)for(const w of u['slice'](0x2)){const x=w['split']('|')['filter'](y=>y['trim']())['map'](y=>y['trim']());if(x['length']>=0x2){const y={'name':x[0x0],'weight':parseInt(x[0x1],0xa)||0x0};x['length']>=0x3&&x[0x2]&&x[0x2]!=='-'&&(y['namedOperator']=x[0x2]),x['length']>=0x4&&x[0x3]&&x[0x3]!=='-'&&(y['permissionIndex']=parseInt(x[0x3],0xa)),x['length']>=0x5&&x[0x4]&&x[0x4]!=='-'&&(y['guard']=x[0x4]),t['forwards']['push'](y);}}const v=q['matchAll'](/(?:^|\n)[-*]\s*(?:forward)?\s*[:]?\s*\n?([\s\S]*?)(?=(?:\n[-*]\s*(?:forward|prev_node|threshold))|\n###|\n##|$)/gi);for(const z of v){const A=z[0x1],B=A['match'](/\s*name\s*[:]\s*(.+?)(?:\n|$)/im),C=A['match'](/\s*weight\s*[:]\s*(\d+)/i);if(B&&C){const D={'name':B[0x1]['trim'](),'weight':parseInt(C[0x1],0xa)},E=A['match'](/\s*namedOperator\s*[:]\s*(.+?)(?:\n|$)/im),F=A['match'](/\s*permissionIndex\s*[:]\s*(\d+)/i),G=A['match'](/\s*guard\s*[:]\s*(.+?)(?:\n|$)/im);E&&(D['namedOperator']=E[0x1]['trim']()),F&&(D['permissionIndex']=parseInt(F[0x1],0xa)),G&&(D['guard']=G[0x1]['trim']()),t['forwards']['push'](D);}}o['pairs']['push'](t);}f['push'](o);}return f['length']>0x0&&(d['nodes']=f),{'data':d,'errors':b};}function formatZodPath(a){return'/'+a['map'](b=>String(b)['replace'](/~/g,'~0')['replace'](/\//g,'~1'))['join']('/');}function parseJsonWithErrors(a){const b=[];try{const c=JSON['parse'](a);return{'data':c,'errors':[]};}catch(d){const f=d,g=f['message']['match'](/position\s+(\d+)/);let h=0x1,i=0x1;if(g){const j=parseInt(g[0x1],0xa),k=a['substring'](0x0,j)['split']('\x0a');h=k['length'],i=k[k['length']-0x1]['length']+0x1;}return b['push']({'message':'JSON\x20parse\x20error:\x20'+f['message'],'path':'/','line':h,'column':i}),{'data':null,'errors':b};}}function validateWithZod(a,b,c=''){const d=[],e=a['safeParse'](b);if(e['success'])return{'success':!![],'data':e['data'],'errors':[]};for(const f of e['error']['issues']){const g=c+formatZodPath(f['path']);d['push']({'message':f['message'],'path':g});}return{'success':![],'errors':d};}export function parseNodeFromText(a){const b=a['trim'](),c=detectFormat(b);let d;if(c==='markdown'){const f=parseMarkdownToNodeData(b);if(f['errors']['length']>0x0)return{'success':![],'errors':f['errors']};d=f['data'];}else{const g=parseJsonWithErrors(b);if(g['errors']['length']>0x0)return{'success':![],'errors':g['errors']};d=g['data'];}const e=validateWithZod(NodeSchema,d);return{'success':e['success'],'data':e['data'],'errors':e['errors']};}export function parseMachineNodesFromText(a){const b=a['trim'](),c=detectFormat(b);let d,e=[];if(c==='markdown'){const h=parseMarkdownToNodeData(b);if(h['errors']['length']>0x0)return{'success':![],'errors':h['errors']};typeof h['data']==='object'&&h['data']!==null&&'nodes'in h['data']?d=h['data']['nodes']:d=h['data'];}else{const j=parseJsonWithErrors(b);if(j['errors']['length']>0x0)return{'success':![],'errors':j['errors']};d=j['data'];}if(!Array['isArray'](d)){if(typeof d==='object'&&d!==null&&'op'in d)return{'success':![],'errors':[{'message':'Expected\x20JSON\x20array\x20of\x20nodes\x20for\x20json_or_markdown\x20mode.\x20Use\x20schema\x20mode\x20for\x20operations\x20with\x20\x22op\x22\x20field.','path':'/'}]};return{'success':![],'errors':[{'message':'Expected\x20JSON\x20array\x20of\x20nodes','path':'/'}]};}const f=[];for(let k=0x0;k<d['length'];k++){const l=d[k],m=validateWithZod(MachineNodeSchema,l,'/'+k);m['success']&&m['data']?f['push'](m['data']):e['push'](...m['errors']);}if(e['length']>0x0)return{'success':![],'errors':e};const g=f['some'](n=>n['pairs']['some'](o=>o['prev_node']===''));if(!g)return{'success':![],'errors':[{'message':'Machine\x20has\x20no\x20entry\x20forward.\x20At\x20least\x20one\x20node\x20must\x20have\x20a\x20pair\x20with\x20prev_node=\x22\x22\x20(empty\x20string),\x20'+'which\x20defines\x20how\x20Progress\x20advances\x20from\x20the\x20initial\x20state\x20(current=\x22\x22)\x20to\x20the\x20first\x20node.\x20'+'Without\x20an\x20entry\x20forward,\x20the\x20workflow\x20will\x20be\x20permanently\x20stuck.\x20'+'Example:\x20{name:\x20\x22Subscribed\x22,\x20pairs:\x20[{prev_node:\x20\x22\x22,\x20forwards:\x20[{name:\x20\x22Subscribe\x22,\x20weight:\x201}]}]}','path':'/'}]};return{'success':!![],'data':f,'errors':[]};}export function formatNodeErrors(a){return a['map'](b=>{let c='Path:\x20'+b['path'];return b['line']!==undefined&&b['column']!==undefined&&(c+='\x20(line\x20'+b['line']+',\x20column\x20'+b['column']+')'),c+='\x0a\x20\x20Error:\x20'+b['message'],c;})['join']('\x0a\x0a');}export function validateMachineNode(a){return validateWithZod(MachineNodeSchema,a);}export function validateMachineNodePair(a){const b=MachineNodePairSchema['safeParse'](a);if(b['success'])return{'success':!![],'errors':[]};const c=b['error']['issues']['map'](d=>({'message':d['message'],'path':formatZodPath(d['path'])}));return{'success':![],'errors':c};}export function validateMachineForward(a){const b=MachineForwardSchema['safeParse'](a);if(b['success'])return{'success':!![],'errors':[]};const c=b['error']['issues']['map'](d=>({'message':d['message'],'path':formatZodPath(d['path'])}));return{'success':![],'errors':c};}export function machineNodesToJson(a,b={}){const {machineId:c,includeComments:includeComments=!![]}=b;let d='';return includeComments&&c&&(d+='//\x20Machine\x20ID:\x20'+c+'\x0a'),d+=JSON['stringify'](a,null,0x2),d;}export function machineNodesToMarkdown(a,b={}){const {machineName:c,machineAddress:d,machineId:e,includeComments:includeComments=!![]}=b;let f='#\x20Machine\x20Node\x20Definition\x0a\x0a';c&&(f+='**Machine:**\x20'+c+'\x0a\x0a');d&&(f+='**Address:**\x20'+d+'\x0a\x0a');e&&(f+='**ID:**\x20'+e+'\x0a\x0a');f+='**Total\x20Nodes:**\x20'+a['length']+'\x0a\x0a',f+='---\x0a\x0a';for(const g of a){f+='##\x20Node:\x20'+g['name']+'\x0a\x0a';includeComments&&(f+='<!--\x20Node\x20definition\x20with\x20pairs\x20and\x20forwards\x20-->\x0a\x0a');for(const h of g['pairs']){f+='###\x20Pair:\x20'+h['prev_node']+'\x0a\x0a',f+='-\x20**prev_node**:\x20'+h['prev_node']+'\x0a',f+='-\x20**threshold**:\x20'+h['threshold']+'\x0a\x0a';if(h['forwards']&&h['forwards']['length']>0x0){f+='####\x20Forwards\x0a\x0a',f+='|\x20name\x20|\x20weight\x20|\x20namedOperator\x20|\x20permissionIndex\x20|\x20guard\x20|\x0a',f+='|------|--------|---------------|-----------------|-------|\x0a';for(const i of h['forwards']){const j=i['namedOperator']||'',k=i['permissionIndex']?.['toString']()||'',l=i['guard'],m=typeof l==='string'?l:l?.['guard']||'';f+='|\x20'+i['name']+'\x20|\x20'+i['weight']+'\x20|\x20'+j+'\x20|\x20'+k+'\x20|\x20'+m+'\x20|\x0a';}f+='\x0a';}}f+='---\x0a\x0a';}return f+='##\x20JSON\x20Definition\x0a\x0a',includeComments&&(f+='<!--\x20You\x20can\x20also\x20use\x20the\x20JSON\x20format\x20below\x20-->\x0a\x0a'),f+='```json\x0a',includeComments&&e&&(f+='//\x20Machine\x20ID:\x20'+e+'\x0a'),f+=JSON['stringify'](a,null,0x2),f+='\x0a```\x0a',f;}export function saveMachineNodesToFile(a,b,c='json',d={}){const e=c==='json'?machineNodesToJson(a,d):machineNodesToMarkdown(a,d);writeFileSync(b,e,'utf-8');}
|
|
@@ -1,35 +1 @@
|
|
|
1
|
-
export function shortTypeName(objectType) {
|
|
2
|
-
if (!objectType)
|
|
3
|
-
return "unknown";
|
|
4
|
-
const base = objectType.replace(/<.*>/, "").trim();
|
|
5
|
-
const segments = base.split("::");
|
|
6
|
-
const shortName = segments[segments.length - 1] || "unknown";
|
|
7
|
-
if (shortName.length > 0 && shortName === shortName.toLowerCase()) {
|
|
8
|
-
return shortName.charAt(0).toUpperCase() + shortName.slice(1);
|
|
9
|
-
}
|
|
10
|
-
return shortName;
|
|
11
|
-
}
|
|
12
|
-
export function normalizeObjectType(objectType) {
|
|
13
|
-
return shortTypeName(objectType).toLowerCase();
|
|
14
|
-
}
|
|
15
|
-
export function isObjectOfType(objectType, expectedShortName) {
|
|
16
|
-
const normalized = normalizeObjectType(objectType);
|
|
17
|
-
const expected = expectedShortName.toLowerCase();
|
|
18
|
-
return normalized === expected;
|
|
19
|
-
}
|
|
20
|
-
export function groupObjectsByType(objects) {
|
|
21
|
-
const byType = new Map();
|
|
22
|
-
for (const obj of objects) {
|
|
23
|
-
const t = shortTypeName(obj.objectType);
|
|
24
|
-
if (!byType.has(t))
|
|
25
|
-
byType.set(t, []);
|
|
26
|
-
byType.get(t).push(obj);
|
|
27
|
-
}
|
|
28
|
-
return byType;
|
|
29
|
-
}
|
|
30
|
-
export function findObjectByType(objects, expectedShortName) {
|
|
31
|
-
return objects.find(o => isObjectOfType(o.objectType, expectedShortName));
|
|
32
|
-
}
|
|
33
|
-
export function countObjectsByType(objects, expectedShortName) {
|
|
34
|
-
return objects.filter(o => isObjectOfType(o.objectType, expectedShortName)).length;
|
|
35
|
-
}
|
|
1
|
+
export function shortTypeName(a){if(!a)return'unknown';const b=a['replace'](/<.*>/,'')['trim'](),c=b['split']('::'),d=c[c['length']-0x1]||'unknown';if(d['length']>0x0&&d===d['toLowerCase']())return d['charAt'](0x0)['toUpperCase']()+d['slice'](0x1);return d;}export function normalizeObjectType(a){return shortTypeName(a)['toLowerCase']();}export function isObjectOfType(a,b){const c=normalizeObjectType(a),d=b['toLowerCase']();return c===d;}export function groupObjectsByType(a){const b=new Map();for(const c of a){const d=shortTypeName(c['objectType']);if(!b['has'](d))b['set'](d,[]);b['get'](d)['push'](c);}return b;}export function findObjectByType(a,b){return a['find'](c=>isObjectOfType(c['objectType'],b));}export function countObjectsByType(a,b){return a['filter'](c=>isObjectOfType(c['objectType'],b))['length'];}
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
export const getValidBuiltinPermissionIndexes = () => {
|
|
3
|
-
return new Set(Object.values(BuiltinPermissionIndex).filter(value => typeof value === 'number'));
|
|
4
|
-
};
|
|
5
|
-
export const isValidPermissionIndex = (index) => {
|
|
6
|
-
return getValidBuiltinPermissionIndexes().has(index) || (index >= 1000 && index <= 65535);
|
|
7
|
-
};
|
|
1
|
+
import{BuiltinPermissionIndex}from'@wowok/wowok';export const getValidBuiltinPermissionIndexes=()=>{return new Set(Object['values'](BuiltinPermissionIndex)['filter'](a=>typeof a==='number'));};export const isValidPermissionIndex=a=>{return getValidBuiltinPermissionIndexes()['has'](a)||a>=0x3e8&&a<=0xffff;};
|
|
@@ -1,121 +1 @@
|
|
|
1
|
-
export function collectPermissionIndexes(
|
|
2
|
-
const indexRefs = [];
|
|
3
|
-
const namedRefs = [];
|
|
4
|
-
const missingRefs = [];
|
|
5
|
-
const requiredIndexSet = new Set();
|
|
6
|
-
for (const node of nodes) {
|
|
7
|
-
if (!node.pairs)
|
|
8
|
-
continue;
|
|
9
|
-
for (const pair of node.pairs) {
|
|
10
|
-
if (!pair.forwards)
|
|
11
|
-
continue;
|
|
12
|
-
for (const forward of pair.forwards) {
|
|
13
|
-
const ref = {
|
|
14
|
-
nodeName: node.name,
|
|
15
|
-
prevNode: pair.prev_node,
|
|
16
|
-
forwardName: forward.name,
|
|
17
|
-
permissionIndex: forward.permissionIndex ?? null,
|
|
18
|
-
namedOperator: forward.namedOperator ?? null,
|
|
19
|
-
};
|
|
20
|
-
if (ref.permissionIndex != null) {
|
|
21
|
-
indexRefs.push(ref);
|
|
22
|
-
requiredIndexSet.add(ref.permissionIndex);
|
|
23
|
-
}
|
|
24
|
-
else if (ref.namedOperator != null && ref.namedOperator !== "") {
|
|
25
|
-
namedRefs.push(ref);
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
missingRefs.push(ref);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return {
|
|
34
|
-
indexRefs,
|
|
35
|
-
namedRefs,
|
|
36
|
-
missingRefs,
|
|
37
|
-
requiredIndexes: Array.from(requiredIndexSet).sort((a, b) => a - b),
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
export function checkPermissionAuthorization(requiredIndexes, permission) {
|
|
41
|
-
const BUILTIN_THRESHOLD = 1000;
|
|
42
|
-
const statuses = [];
|
|
43
|
-
const missingIndexes = [];
|
|
44
|
-
const authorizedIndexes = [];
|
|
45
|
-
for (const index of requiredIndexes) {
|
|
46
|
-
if (index < BUILTIN_THRESHOLD) {
|
|
47
|
-
statuses.push({ index, authorized: true, entityCount: -1 });
|
|
48
|
-
authorizedIndexes.push(index);
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
let authorized = false;
|
|
52
|
-
let entityCount = 0;
|
|
53
|
-
if (permission?.entityPermissions) {
|
|
54
|
-
for (const perms of permission.entityPermissions.values()) {
|
|
55
|
-
if (perms.includes(index)) {
|
|
56
|
-
entityCount++;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
authorized = entityCount > 0;
|
|
60
|
-
}
|
|
61
|
-
else if (permission?.perm_remark && permission.perm_remark.length > 0) {
|
|
62
|
-
authorized = permission.perm_remark.some(r => r.index === index);
|
|
63
|
-
entityCount = authorized ? -1 : 0;
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
authorized = true;
|
|
67
|
-
entityCount = -1;
|
|
68
|
-
}
|
|
69
|
-
statuses.push({ index, authorized, entityCount });
|
|
70
|
-
if (authorized) {
|
|
71
|
-
authorizedIndexes.push(index);
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
missingIndexes.push(index);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
const allAuthorized = missingIndexes.length === 0;
|
|
78
|
-
const summary = allAuthorized
|
|
79
|
-
? `All ${requiredIndexes.length} required permission index(es) are authorized.`
|
|
80
|
-
: `${missingIndexes.length}/${requiredIndexes.length} required permission index(es) are NOT authorized: [${missingIndexes.join(", ")}]. ` +
|
|
81
|
-
`Forwards using these indexes will be un-executable — Progress will be stuck. ` +
|
|
82
|
-
`Grant entities for these indexes via permission.op="add perm by index" before publishing the Machine.`;
|
|
83
|
-
return {
|
|
84
|
-
statuses,
|
|
85
|
-
missingIndexes,
|
|
86
|
-
authorizedIndexes,
|
|
87
|
-
allAuthorized,
|
|
88
|
-
summary,
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
export function formatPermissionWarning(report) {
|
|
92
|
-
if (report.allAuthorized) {
|
|
93
|
-
return "";
|
|
94
|
-
}
|
|
95
|
-
const lines = [
|
|
96
|
-
"CRITICAL PRE-PUBLISH: Machine forwards reference permission indexes that are NOT authorized in the Permission object.",
|
|
97
|
-
"",
|
|
98
|
-
`Missing indexes (no entities granted): ${report.missingIndexes.join(", ")}`,
|
|
99
|
-
"",
|
|
100
|
-
"Impact: Forwards using these indexes can NEVER be executed — Progress will be permanently stuck at the source node.",
|
|
101
|
-
"Buyer funds may be trapped if the workflow cannot advance past the stuck node.",
|
|
102
|
-
"",
|
|
103
|
-
"To fix BEFORE publishing:",
|
|
104
|
-
' 1. Call onchain_operations with op="permission"',
|
|
105
|
-
' 2. Set object=<your_permission_name_or_address>',
|
|
106
|
-
' 3. Set permission.op="add perm by index"',
|
|
107
|
-
" 4. Set index=<missing_index> for each missing index",
|
|
108
|
-
' 5. Set entity=["<entity_address>"] — the address that should be authorized',
|
|
109
|
-
" 6. After granting all missing indexes, re-attempt the Machine publish.",
|
|
110
|
-
"",
|
|
111
|
-
"Required permission indexes for this Machine:",
|
|
112
|
-
];
|
|
113
|
-
for (const status of report.statuses) {
|
|
114
|
-
const state = status.authorized ? "AUTHORIZED" : "MISSING";
|
|
115
|
-
const count = status.entityCount === -1
|
|
116
|
-
? "(built-in or heuristic)"
|
|
117
|
-
: `(${status.entityCount} entity/entities)`;
|
|
118
|
-
lines.push(` - Index ${status.index}: ${state} ${count}`);
|
|
119
|
-
}
|
|
120
|
-
return lines.join("\n");
|
|
121
|
-
}
|
|
1
|
+
export function collectPermissionIndexes(a){const b=[],c=[],d=[],e=new Set();for(const f of a){if(!f['pairs'])continue;for(const g of f['pairs']){if(!g['forwards'])continue;for(const h of g['forwards']){const i={'nodeName':f['name'],'prevNode':g['prev_node'],'forwardName':h['name'],'permissionIndex':h['permissionIndex']??null,'namedOperator':h['namedOperator']??null};if(i['permissionIndex']!=null)b['push'](i),e['add'](i['permissionIndex']);else i['namedOperator']!=null&&i['namedOperator']!==''?c['push'](i):d['push'](i);}}}return{'indexRefs':b,'namedRefs':c,'missingRefs':d,'requiredIndexes':Array['from'](e)['sort']((j,k)=>j-k)};}export function checkPermissionAuthorization(a,b){const c=0x3e8,d=[],e=[],f=[];for(const i of a){if(i<c){d['push']({'index':i,'authorized':!![],'entityCount':-0x1}),f['push'](i);continue;}let j=![],k=0x0;if(b?.['entityPermissions']){for(const l of b['entityPermissions']['values']()){l['includes'](i)&&k++;}j=k>0x0;}else b?.['perm_remark']&&b['perm_remark']['length']>0x0?(j=b['perm_remark']['some'](m=>m['index']===i),k=j?-0x1:0x0):(j=!![],k=-0x1);d['push']({'index':i,'authorized':j,'entityCount':k}),j?f['push'](i):e['push'](i);}const g=e['length']===0x0,h=g?'All\x20'+a['length']+'\x20required\x20permission\x20index(es)\x20are\x20authorized.':e['length']+'/'+a['length']+'\x20required\x20permission\x20index(es)\x20are\x20NOT\x20authorized:\x20['+e['join'](',\x20')+'].\x20'+'Forwards\x20using\x20these\x20indexes\x20will\x20be\x20un-executable\x20—\x20Progress\x20will\x20be\x20stuck.\x20'+'Grant\x20entities\x20for\x20these\x20indexes\x20via\x20permission.op=\x22add\x20perm\x20by\x20index\x22\x20before\x20publishing\x20the\x20Machine.';return{'statuses':d,'missingIndexes':e,'authorizedIndexes':f,'allAuthorized':g,'summary':h};}export function formatPermissionWarning(a){if(a['allAuthorized'])return'';const b=['CRITICAL\x20PRE-PUBLISH:\x20Machine\x20forwards\x20reference\x20permission\x20indexes\x20that\x20are\x20NOT\x20authorized\x20in\x20the\x20Permission\x20object.','','Missing\x20indexes\x20(no\x20entities\x20granted):\x20'+a['missingIndexes']['join'](',\x20'),'','Impact:\x20Forwards\x20using\x20these\x20indexes\x20can\x20NEVER\x20be\x20executed\x20—\x20Progress\x20will\x20be\x20permanently\x20stuck\x20at\x20the\x20source\x20node.','Buyer\x20funds\x20may\x20be\x20trapped\x20if\x20the\x20workflow\x20cannot\x20advance\x20past\x20the\x20stuck\x20node.','','To\x20fix\x20BEFORE\x20publishing:','\x20\x201.\x20Call\x20onchain_operations\x20with\x20op=\x22permission\x22','\x20\x202.\x20Set\x20object=<your_permission_name_or_address>','\x20\x203.\x20Set\x20permission.op=\x22add\x20perm\x20by\x20index\x22','\x20\x204.\x20Set\x20index=<missing_index>\x20for\x20each\x20missing\x20index','\x20\x205.\x20Set\x20entity=[\x22<entity_address>\x22]\x20—\x20the\x20address\x20that\x20should\x20be\x20authorized','\x20\x206.\x20After\x20granting\x20all\x20missing\x20indexes,\x20re-attempt\x20the\x20Machine\x20publish.','','Required\x20permission\x20indexes\x20for\x20this\x20Machine:'];for(const c of a['statuses']){const d=c['authorized']?'AUTHORIZED':'MISSING',e=c['entityCount']===-0x1?'(built-in\x20or\x20heuristic)':'('+c['entityCount']+'\x20entity/entities)';b['push']('\x20\x20-\x20Index\x20'+c['index']+':\x20'+d+'\x20'+e);}return b['join']('\x0a');}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export declare function getSkillsHintForOnchain(operationType: string, data?: unknown): string | undefined;
|
|
2
2
|
export declare function getSkillsHintForProject(action: string): string | undefined;
|
|
3
|
+
export declare function getSkillsHintForEvaluation(action: string): string | undefined;
|
|
@@ -1,77 +1 @@
|
|
|
1
|
-
const SKILLS_BY_OPERATION_TYPE = {
|
|
2
|
-
service: ["wowok-provider", "wowok-safety"],
|
|
3
|
-
machine: ["wowok-machine"],
|
|
4
|
-
guard: ["wowok-guard"],
|
|
5
|
-
arbitration: ["wowok-arbitrator"],
|
|
6
|
-
allocation: ["wowok-provider"],
|
|
7
|
-
permission: ["wowok-safety"],
|
|
8
|
-
treasury: ["wowok-provider", "wowok-safety"],
|
|
9
|
-
reward: ["wowok-provider"],
|
|
10
|
-
repository: ["wowok-provider"],
|
|
11
|
-
demand: ["wowok-provider"],
|
|
12
|
-
contact: ["wowok-messenger"],
|
|
13
|
-
order: ["wowok-order"],
|
|
14
|
-
progress: [],
|
|
15
|
-
personal: [],
|
|
16
|
-
payment: [],
|
|
17
|
-
proof: [],
|
|
18
|
-
};
|
|
19
|
-
const SKILLS_BY_PROJECT_ACTION = {
|
|
20
|
-
create_project: ["wowok-onboard", "wowok-planner"],
|
|
21
|
-
create_project_from_onchain: ["wowok-onboard"],
|
|
22
|
-
evaluate_project: ["wowok-auditor"],
|
|
23
|
-
pre_evaluate_check: ["wowok-auditor"],
|
|
24
|
-
verify_deployment: ["wowok-auditor"],
|
|
25
|
-
generate_deployment_doc: ["wowok-planner"],
|
|
26
|
-
migrate_to_mainnet: ["wowok-onboard", "wowok-safety"],
|
|
27
|
-
migrate_network: ["wowok-onboard"],
|
|
28
|
-
clone_project_to_network: ["wowok-onboard"],
|
|
29
|
-
build_graph: ["wowok-planner"],
|
|
30
|
-
list_projects: [],
|
|
31
|
-
get_project_detail: [],
|
|
32
|
-
update_project: [],
|
|
33
|
-
add_object: [],
|
|
34
|
-
remove_object: [],
|
|
35
|
-
update_object: [],
|
|
36
|
-
create_version: [],
|
|
37
|
-
get_graph: [],
|
|
38
|
-
save_evaluation: [],
|
|
39
|
-
compare_projects: [],
|
|
40
|
-
refresh_objects: [],
|
|
41
|
-
get_object_diff: [],
|
|
42
|
-
delete_project: [],
|
|
43
|
-
assemble_context: [],
|
|
44
|
-
get_machine_graph: ["wowok-machine"],
|
|
45
|
-
get_guard_graph: ["wowok-guard"],
|
|
46
|
-
plan_object_edit: ["wowok-machine", "wowok-guard", "wowok-auditor"],
|
|
47
|
-
apply_object_edit: ["wowok-safety"],
|
|
48
|
-
patch_machine_nodes: ["wowok-machine"],
|
|
49
|
-
patch_guard_tree: ["wowok-guard"],
|
|
50
|
-
participation_radar: ["wowok-order", "wowok-messenger"],
|
|
51
|
-
};
|
|
52
|
-
export function getSkillsHintForOnchain(operationType, data) {
|
|
53
|
-
const skills = SKILLS_BY_OPERATION_TYPE[operationType];
|
|
54
|
-
if (!skills || skills.length === 0)
|
|
55
|
-
return undefined;
|
|
56
|
-
const isPublish = data?.publish === true;
|
|
57
|
-
const hasOrderAllocators = !!data?.order_allocators;
|
|
58
|
-
const isComplex = isPublish || hasOrderAllocators;
|
|
59
|
-
const prefix = isComplex
|
|
60
|
-
? "SKILLS RECOMMENDED (complex operation — skills provide business-semantic guidance):"
|
|
61
|
-
: "SKILLS RECOMMENDED (optional — skills provide deeper guidance):";
|
|
62
|
-
return `${prefix} ${skills.join(", ")}. ` +
|
|
63
|
-
`skills focus on business intent → object parameter translation; ` +
|
|
64
|
-
`MCP handles object structure and on-chain execution. ` +
|
|
65
|
-
`If skills are installed, consult them BEFORE this call for design rationale. ` +
|
|
66
|
-
`If not installed, MCP executes independently — this hint is informational only.`;
|
|
67
|
-
}
|
|
68
|
-
export function getSkillsHintForProject(action) {
|
|
69
|
-
const skills = SKILLS_BY_PROJECT_ACTION[action];
|
|
70
|
-
if (!skills || skills.length === 0)
|
|
71
|
-
return undefined;
|
|
72
|
-
return `SKILLS RECOMMENDED (optional — skills provide deeper guidance): ${skills.join(", ")}. ` +
|
|
73
|
-
`skills focus on business intent → object parameter translation; ` +
|
|
74
|
-
`MCP handles project structure and evaluation. ` +
|
|
75
|
-
`If skills are installed, consult them for design/planning rationale. ` +
|
|
76
|
-
`If not installed, MCP executes independently — this hint is informational only.`;
|
|
77
|
-
}
|
|
1
|
+
const SKILLS_BY_OPERATION_TYPE={'service':['wowok-provider'],'machine':['wowok-machine'],'guard':[],'arbitration':['wowok-arbitrator'],'allocation':['wowok-provider'],'permission':[],'treasury':['wowok-provider'],'reward':['wowok-provider'],'repository':['wowok-provider'],'demand':['wowok-provider','wowok-supplier'],'contact':['wowok-messenger'],'order':['wowok-order'],'progress':['wowok-collaborator'],'personal':[],'payment':[],'proof':[]},SKILLS_BY_PROJECT_ACTION={'create_project':['wowok-onboard','wowok-planner'],'create_project_from_onchain':['wowok-onboard'],'evaluate_project':['wowok-auditor'],'pre_evaluate_check':['wowok-auditor'],'verify_deployment':['wowok-auditor'],'generate_deployment_doc':['wowok-planner'],'migrate_to_mainnet':['wowok-onboard'],'migrate_network':['wowok-onboard'],'clone_project_to_network':['wowok-onboard'],'build_graph':['wowok-planner'],'list_projects':[],'get_project_detail':[],'update_project':[],'add_object':[],'remove_object':[],'update_object':[],'create_version':[],'get_graph':[],'save_evaluation':[],'compare_projects':[],'refresh_objects':[],'get_object_diff':[],'delete_project':[],'assemble_context':[],'get_machine_graph':['wowok-machine'],'get_guard_graph':[],'plan_object_edit':['wowok-machine','wowok-auditor'],'apply_object_edit':[],'patch_machine_nodes':['wowok-machine'],'patch_guard_tree':[],'participation_radar':['wowok-order','wowok-supplier','wowok-collaborator','wowok-messenger']};export function getSkillsHintForOnchain(a,b){const c=SKILLS_BY_OPERATION_TYPE[a];if(!c||c['length']===0x0)return undefined;const d=b?.['publish']===!![],e=!!b?.['order_allocators'],f=d||e,g=f?'SKILLS\x20RECOMMENDED\x20(complex\x20operation\x20—\x20skills\x20provide\x20business-semantic\x20guidance):':'SKILLS\x20RECOMMENDED\x20(optional\x20—\x20skills\x20provide\x20deeper\x20guidance):';return g+'\x20'+c['join'](',\x20')+'.\x20'+'skills\x20focus\x20on\x20business\x20intent\x20→\x20object\x20parameter\x20translation;\x20'+'MCP\x20handles\x20object\x20structure\x20and\x20on-chain\x20execution.\x20'+'If\x20skills\x20are\x20installed,\x20consult\x20them\x20BEFORE\x20this\x20call\x20for\x20design\x20rationale.\x20'+'If\x20not\x20installed,\x20MCP\x20executes\x20independently\x20—\x20this\x20hint\x20is\x20informational\x20only.';}export function getSkillsHintForProject(a){const b=SKILLS_BY_PROJECT_ACTION[a];if(!b||b['length']===0x0)return undefined;return'SKILLS\x20RECOMMENDED\x20(optional\x20—\x20skills\x20provide\x20deeper\x20guidance):\x20'+b['join'](',\x20')+'.\x20'+'skills\x20focus\x20on\x20business\x20intent\x20→\x20object\x20parameter\x20translation;\x20'+'MCP\x20handles\x20project\x20structure\x20and\x20evaluation.\x20'+'If\x20skills\x20are\x20installed,\x20consult\x20them\x20for\x20design/planning\x20rationale.\x20'+'If\x20not\x20installed,\x20MCP\x20executes\x20independently\x20—\x20this\x20hint\x20is\x20informational\x20only.';}const SKILLS_BY_EVALUATION_ACTION={'match_discover':['wowok-market'],'discover_services':['wowok-market'],'discover_demands':['wowok-market'],'arbitration_score':['wowok-market','wowok-arbitrator'],'account_events':['wowok-market'],'market_metrics':['wowok-market'],'anti_cheat':['wowok-market'],'market_operations':['wowok-market']};export function getSkillsHintForEvaluation(a){const b=SKILLS_BY_EVALUATION_ACTION[a];if(!b||b['length']===0x0)return undefined;return'SKILLS\x20RECOMMENDED\x20(optional\x20—\x20skills\x20provide\x20deeper\x20guidance):\x20'+b['join'](',\x20')+'.\x20'+'skills\x20focus\x20on\x20market/operational\x20intent\x20→\x20action\x20parameters;\x20'+'MCP\x20handles\x20enumeration,\x20scoring\x20and\x20on-chain\x20execution.\x20'+'If\x20not\x20installed,\x20MCP\x20executes\x20independently\x20—\x20this\x20hint\x20is\x20informational\x20only.';}
|