@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,565 +1 @@
|
|
|
1
|
-
function sanitizeMermaidLabel(text) {
|
|
2
|
-
if (/[<>"\[\]{}()|&]/.test(text)) {
|
|
3
|
-
return `"${text.replace(/"/g, "'")}"`;
|
|
4
|
-
}
|
|
5
|
-
return text;
|
|
6
|
-
}
|
|
7
|
-
const MACHINE_NODE_COLORS = {
|
|
8
|
-
entry: { fill: "#10b981", stroke: "#065f46" },
|
|
9
|
-
terminal: { fill: "#ef4444", stroke: "#991b1b" },
|
|
10
|
-
revision: { fill: "#f59e0b", stroke: "#92400e" },
|
|
11
|
-
normal: { fill: "#3b82f6", stroke: "#1e40af" },
|
|
12
|
-
};
|
|
13
|
-
function classifyMachineNode(nodeName, edges, entryNodes) {
|
|
14
|
-
const outEdges = edges.filter(e => e.from === nodeName);
|
|
15
|
-
if (outEdges.length === 0)
|
|
16
|
-
return "terminal";
|
|
17
|
-
const hasOutgoingToNode = outEdges.some(e => e.to !== "");
|
|
18
|
-
if (!hasOutgoingToNode)
|
|
19
|
-
return "terminal";
|
|
20
|
-
const isRevisionTarget = edges.some(e => e.to === nodeName && e.from === nodeName);
|
|
21
|
-
if (isRevisionTarget)
|
|
22
|
-
return "revision";
|
|
23
|
-
if (entryNodes.has(nodeName))
|
|
24
|
-
return "entry";
|
|
25
|
-
return "normal";
|
|
26
|
-
}
|
|
27
|
-
export function sanitizeMermaidNodeId(name) {
|
|
28
|
-
if (/[^a-zA-Z0-9_]/.test(name)) {
|
|
29
|
-
return `"${name}"`;
|
|
30
|
-
}
|
|
31
|
-
return name;
|
|
32
|
-
}
|
|
33
|
-
export function renderMachineMermaid(nodes, edges, options) {
|
|
34
|
-
const colored = options?.colored !== false;
|
|
35
|
-
const lines = ["stateDiagram-v2"];
|
|
36
|
-
if (colored) {
|
|
37
|
-
lines.push(" %% Color Legend (BehaviorTree.CPP-inspired workflow roles):");
|
|
38
|
-
lines.push(" %% green #10b981 - entry (start state, targeted by [*])");
|
|
39
|
-
lines.push(" %% red #ef4444 - terminal (end state, no outgoing edges)");
|
|
40
|
-
lines.push(" %% amber #f59e0b - revision (self-loop / revision cycle)");
|
|
41
|
-
lines.push(" %% blue #3b82f6 - normal (regular intermediate state)");
|
|
42
|
-
lines.push(" %% Priority: terminal > revision > entry > normal");
|
|
43
|
-
}
|
|
44
|
-
const nodesWithIncoming = new Set(edges.filter(e => e.from !== "").map(e => e.to));
|
|
45
|
-
const entryNodes = new Set();
|
|
46
|
-
for (const node of nodes) {
|
|
47
|
-
if (!nodesWithIncoming.has(node.name)) {
|
|
48
|
-
entryNodes.add(node.name);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
const entryNodesList = nodes.filter(n => entryNodes.has(n.name));
|
|
52
|
-
for (const entry of entryNodesList) {
|
|
53
|
-
const entryEdges = edges.filter(e => e.from === "" && e.to === entry.name);
|
|
54
|
-
if (entryEdges.length > 0) {
|
|
55
|
-
for (const edge of entryEdges) {
|
|
56
|
-
for (const fwd of edge.forwards) {
|
|
57
|
-
const label = buildForwardLabel(fwd, edge.threshold);
|
|
58
|
-
lines.push(` [*] --> ${sanitizeMermaidNodeId(entry.name)}: ${sanitizeMermaidLabel(label)}`);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
lines.push(` [*] --> ${sanitizeMermaidNodeId(entry.name)}`);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
for (const edge of edges) {
|
|
67
|
-
if (edge.from === "")
|
|
68
|
-
continue;
|
|
69
|
-
const fromId = sanitizeMermaidNodeId(edge.from);
|
|
70
|
-
const toId = edge.to === "" ? "[*]" : sanitizeMermaidNodeId(edge.to);
|
|
71
|
-
for (const fwd of edge.forwards) {
|
|
72
|
-
const label = buildForwardLabel(fwd, edge.threshold);
|
|
73
|
-
lines.push(` ${fromId} --> ${toId}: ${sanitizeMermaidLabel(label)}`);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
for (const node of nodes) {
|
|
77
|
-
if (node.description) {
|
|
78
|
-
lines.push(` ${sanitizeMermaidNodeId(node.name)}: ${sanitizeMermaidLabel(node.description)}`);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
if (colored) {
|
|
82
|
-
lines.push("");
|
|
83
|
-
lines.push(" %% Node colors (BehaviorTree.CPP-inspired workflow roles)");
|
|
84
|
-
for (const node of nodes) {
|
|
85
|
-
const category = classifyMachineNode(node.name, edges, entryNodes);
|
|
86
|
-
const color = MACHINE_NODE_COLORS[category];
|
|
87
|
-
lines.push(` style ${sanitizeMermaidNodeId(node.name)} fill:${color.fill},stroke:${color.stroke},color:#fff`);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return lines.join("\n");
|
|
91
|
-
}
|
|
92
|
-
function buildForwardLabel(fwd, threshold) {
|
|
93
|
-
let label = fwd.name;
|
|
94
|
-
const annotations = [];
|
|
95
|
-
if (threshold > 1) {
|
|
96
|
-
annotations.push(`threshold=${threshold}`);
|
|
97
|
-
}
|
|
98
|
-
if (fwd.guard) {
|
|
99
|
-
const shortGuard = fwd.guard.length > 10
|
|
100
|
-
? `${fwd.guard.slice(0, 6)}…${fwd.guard.slice(-4)}`
|
|
101
|
-
: fwd.guard;
|
|
102
|
-
annotations.push(`guard=${shortGuard}`);
|
|
103
|
-
}
|
|
104
|
-
if (annotations.length > 0) {
|
|
105
|
-
label += ` (${annotations.join(", ")})`;
|
|
106
|
-
}
|
|
107
|
-
return label;
|
|
108
|
-
}
|
|
109
|
-
export function renderMachineTreeIndented(input) {
|
|
110
|
-
const { nodes, edges, machineName, machineAddress, published, paused } = input;
|
|
111
|
-
const lines = [];
|
|
112
|
-
lines.push("# Machine Workflow Definition");
|
|
113
|
-
lines.push("");
|
|
114
|
-
if (machineName) {
|
|
115
|
-
lines.push(`**Machine:** ${machineName}`);
|
|
116
|
-
}
|
|
117
|
-
if (machineAddress) {
|
|
118
|
-
lines.push(`**Address:** ${machineAddress}`);
|
|
119
|
-
}
|
|
120
|
-
lines.push(`**Total Nodes:** ${nodes.length}`);
|
|
121
|
-
lines.push(`**Total Edges:** ${edges.length}`);
|
|
122
|
-
if (published !== null && published !== undefined) {
|
|
123
|
-
lines.push(`**Published:** ${published}`);
|
|
124
|
-
}
|
|
125
|
-
if (paused !== null && paused !== undefined) {
|
|
126
|
-
lines.push(`**Paused:** ${paused}`);
|
|
127
|
-
}
|
|
128
|
-
lines.push("");
|
|
129
|
-
lines.push("## Topology (directed graph outline)");
|
|
130
|
-
lines.push("");
|
|
131
|
-
const entryEdges = edges.filter(e => e.from === "");
|
|
132
|
-
const regularEdges = edges.filter(e => e.from !== "");
|
|
133
|
-
for (const edge of entryEdges) {
|
|
134
|
-
const header = `- [*] --> ${edge.to} (threshold=${edge.threshold})`;
|
|
135
|
-
lines.push(header);
|
|
136
|
-
for (const fwd of edge.forwards) {
|
|
137
|
-
lines.push(` - forward: ${formatForwardInline(fwd)}`);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
for (const edge of regularEdges) {
|
|
141
|
-
const isSelfLoop = edge.from === edge.to;
|
|
142
|
-
const annotation = isSelfLoop ? " # self-loop (revision cycle)" : "";
|
|
143
|
-
const toLabel = edge.to === "" ? "[*]" : edge.to;
|
|
144
|
-
const header = `- ${edge.from} --> ${toLabel} (threshold=${edge.threshold})${annotation}`;
|
|
145
|
-
lines.push(header);
|
|
146
|
-
for (const fwd of edge.forwards) {
|
|
147
|
-
lines.push(` - forward: ${formatForwardInline(fwd)}`);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
const nodesWithDesc = nodes.filter(n => n.description);
|
|
151
|
-
if (nodesWithDesc.length > 0) {
|
|
152
|
-
lines.push("");
|
|
153
|
-
lines.push("## Node Descriptions");
|
|
154
|
-
lines.push("");
|
|
155
|
-
for (const node of nodes) {
|
|
156
|
-
if (node.description) {
|
|
157
|
-
lines.push(`- ${node.name}: ${node.description}`);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
const incomingMap = new Map();
|
|
162
|
-
for (const edge of edges) {
|
|
163
|
-
if (!incomingMap.has(edge.to))
|
|
164
|
-
incomingMap.set(edge.to, []);
|
|
165
|
-
incomingMap.get(edge.to).push({
|
|
166
|
-
from: edge.from === "" ? "[*]" : edge.from,
|
|
167
|
-
forwards: edge.forwards.map(f => f.name),
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
if (incomingMap.size > 0) {
|
|
171
|
-
lines.push("");
|
|
172
|
-
lines.push("## Backrefs (incoming edges per node)");
|
|
173
|
-
lines.push("");
|
|
174
|
-
for (const node of nodes) {
|
|
175
|
-
const incoming = incomingMap.get(node.name);
|
|
176
|
-
if (!incoming || incoming.length === 0)
|
|
177
|
-
continue;
|
|
178
|
-
const parts = incoming.map(inc => {
|
|
179
|
-
const fwdStr = inc.forwards.length > 0 ? ` (${inc.forwards.join(", ")})` : "";
|
|
180
|
-
const selfLoop = inc.from === node.name ? " # self-loop" : "";
|
|
181
|
-
return `<- ${inc.from}${fwdStr}${selfLoop}`;
|
|
182
|
-
});
|
|
183
|
-
lines.push(`- ${node.name}: ${parts.join(", ")}`);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
lines.push("");
|
|
187
|
-
lines.push("## JSON Definition");
|
|
188
|
-
lines.push("");
|
|
189
|
-
lines.push("```json");
|
|
190
|
-
lines.push(JSON.stringify({ nodes, edges }, null, 2));
|
|
191
|
-
lines.push("```");
|
|
192
|
-
return lines.join("\n");
|
|
193
|
-
}
|
|
194
|
-
function formatForwardInline(fwd) {
|
|
195
|
-
const parts = [`weight=${fwd.weight}`];
|
|
196
|
-
if (fwd.named_operator !== null && fwd.named_operator !== undefined) {
|
|
197
|
-
parts.push(`namedOperator='${fwd.named_operator}'`);
|
|
198
|
-
}
|
|
199
|
-
if (fwd.permission_index !== null && fwd.permission_index !== undefined) {
|
|
200
|
-
parts.push(`permissionIndex=${fwd.permission_index}`);
|
|
201
|
-
}
|
|
202
|
-
if (fwd.guard) {
|
|
203
|
-
parts.push(`guard=${fwd.guard}`);
|
|
204
|
-
}
|
|
205
|
-
if (fwd.retained_submission) {
|
|
206
|
-
const rsStr = Array.isArray(fwd.retained_submission)
|
|
207
|
-
? `[${fwd.retained_submission.join(",")}]`
|
|
208
|
-
: String(fwd.retained_submission);
|
|
209
|
-
parts.push(`retained_submission=${rsStr}`);
|
|
210
|
-
}
|
|
211
|
-
return `${fwd.name} (${parts.join(", ")})`;
|
|
212
|
-
}
|
|
213
|
-
export function parseMachineTreeIndented(text) {
|
|
214
|
-
const errors = [];
|
|
215
|
-
const jsonMatch = text.match(/```json\s*\n([\s\S]*?)```/);
|
|
216
|
-
if (jsonMatch) {
|
|
217
|
-
try {
|
|
218
|
-
const data = JSON.parse(jsonMatch[1].trim());
|
|
219
|
-
if (data && typeof data === "object" && Array.isArray(data.nodes) && Array.isArray(data.edges)) {
|
|
220
|
-
return { success: true, data, errors: [] };
|
|
221
|
-
}
|
|
222
|
-
if (Array.isArray(data)) {
|
|
223
|
-
const { nodes, edges } = convertNodeArrayToGraph(data);
|
|
224
|
-
return { success: true, data: { nodes, edges }, errors: [] };
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
catch (e) {
|
|
228
|
-
errors.push(`JSON code block parse error: ${e.message}`);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
const topologyMatch = text.match(/##\s*Topology[^\n]*\n([\s\S]*?)(?=\n##\s|$)/i);
|
|
232
|
-
if (!topologyMatch) {
|
|
233
|
-
return {
|
|
234
|
-
success: false,
|
|
235
|
-
errors: [
|
|
236
|
-
"No '## Topology' section found. " +
|
|
237
|
-
"Use the format produced by renderMachineTreeIndented() or a JSON code block.",
|
|
238
|
-
],
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
const topologySection = topologyMatch[1];
|
|
242
|
-
const nodeNames = new Set();
|
|
243
|
-
const edges = [];
|
|
244
|
-
const edgeLines = topologySection.split("\n").filter(l => l.trim().startsWith("- "));
|
|
245
|
-
const pendingForwards = [];
|
|
246
|
-
let currentEdge = null;
|
|
247
|
-
for (const line of edgeLines) {
|
|
248
|
-
const trimmed = line.trim();
|
|
249
|
-
const isIndented = line.startsWith(" -");
|
|
250
|
-
if (isIndented) {
|
|
251
|
-
const fwdMatch = trimmed.match(/^-\s*forward:\s*(.+)$/);
|
|
252
|
-
if (fwdMatch && currentEdge) {
|
|
253
|
-
const fwd = parseForwardInline(fwdMatch[1]);
|
|
254
|
-
if (fwd) {
|
|
255
|
-
currentEdge.forwards.push(fwd);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
continue;
|
|
259
|
-
}
|
|
260
|
-
const edgeMatch = trimmed.match(/^-\s+(.+?)\s+-->\s+(\S+)(?:\s+\(threshold=(\d+)\))?(.*)$/);
|
|
261
|
-
if (edgeMatch) {
|
|
262
|
-
if (currentEdge) {
|
|
263
|
-
edges.push(currentEdge);
|
|
264
|
-
}
|
|
265
|
-
const fromRaw = edgeMatch[1].trim();
|
|
266
|
-
const to = edgeMatch[2].trim();
|
|
267
|
-
const threshold = edgeMatch[3] ? parseInt(edgeMatch[3], 10) : 1;
|
|
268
|
-
const from = fromRaw === "[*]" ? "" : fromRaw;
|
|
269
|
-
currentEdge = {
|
|
270
|
-
from,
|
|
271
|
-
to,
|
|
272
|
-
threshold,
|
|
273
|
-
forwards: [],
|
|
274
|
-
};
|
|
275
|
-
nodeNames.add(to);
|
|
276
|
-
if (from)
|
|
277
|
-
nodeNames.add(from);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
if (currentEdge) {
|
|
281
|
-
edges.push(currentEdge);
|
|
282
|
-
}
|
|
283
|
-
if (edges.length === 0) {
|
|
284
|
-
return {
|
|
285
|
-
success: false,
|
|
286
|
-
errors: ["No edges found in '## Topology' section. Expected lines like '- A --> B (threshold=1)'."],
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
const descMatch = text.match(/##\s*Node Descriptions[^\n]*\n([\s\S]*?)(?=\n##\s|$)/i);
|
|
290
|
-
const nodeDescMap = new Map();
|
|
291
|
-
if (descMatch) {
|
|
292
|
-
const descLines = descMatch[1].split("\n");
|
|
293
|
-
for (const line of descLines) {
|
|
294
|
-
const m = line.match(/^-\s+(\S+):\s*(.+)$/);
|
|
295
|
-
if (m) {
|
|
296
|
-
nodeDescMap.set(m[1], m[2]);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
const nodes = [];
|
|
301
|
-
for (const name of nodeNames) {
|
|
302
|
-
nodes.push({
|
|
303
|
-
name,
|
|
304
|
-
description: nodeDescMap.get(name) ?? null,
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
return { success: true, data: { nodes, edges }, errors };
|
|
308
|
-
}
|
|
309
|
-
function parseForwardInline(text) {
|
|
310
|
-
const match = text.match(/^(\S+)\s*\(([^)]*)\)$/);
|
|
311
|
-
if (!match) {
|
|
312
|
-
return {
|
|
313
|
-
name: text.trim(),
|
|
314
|
-
weight: 1,
|
|
315
|
-
named_operator: null,
|
|
316
|
-
permission_index: null,
|
|
317
|
-
guard: null,
|
|
318
|
-
retained_submission: null,
|
|
319
|
-
};
|
|
320
|
-
}
|
|
321
|
-
const name = match[1];
|
|
322
|
-
const annotationStr = match[2];
|
|
323
|
-
const fwd = {
|
|
324
|
-
name,
|
|
325
|
-
weight: 1,
|
|
326
|
-
named_operator: null,
|
|
327
|
-
permission_index: null,
|
|
328
|
-
guard: null,
|
|
329
|
-
retained_submission: null,
|
|
330
|
-
};
|
|
331
|
-
for (const part of annotationStr.split(",").map(s => s.trim())) {
|
|
332
|
-
if (!part)
|
|
333
|
-
continue;
|
|
334
|
-
const [key, ...valParts] = part.split("=");
|
|
335
|
-
const val = valParts.join("=").trim();
|
|
336
|
-
switch (key.trim()) {
|
|
337
|
-
case "weight":
|
|
338
|
-
fwd.weight = parseInt(val, 10) || 1;
|
|
339
|
-
break;
|
|
340
|
-
case "namedOperator":
|
|
341
|
-
fwd.named_operator = val.replace(/^'|'$/g, "");
|
|
342
|
-
break;
|
|
343
|
-
case "permissionIndex":
|
|
344
|
-
fwd.permission_index = parseInt(val, 10) || null;
|
|
345
|
-
break;
|
|
346
|
-
case "guard":
|
|
347
|
-
fwd.guard = val || null;
|
|
348
|
-
break;
|
|
349
|
-
case "retained_submission":
|
|
350
|
-
if (val.startsWith("[") && val.endsWith("]")) {
|
|
351
|
-
fwd.retained_submission = val
|
|
352
|
-
.slice(1, -1)
|
|
353
|
-
.split(",")
|
|
354
|
-
.map(s => parseInt(s.trim(), 10))
|
|
355
|
-
.filter(n => !isNaN(n));
|
|
356
|
-
}
|
|
357
|
-
else {
|
|
358
|
-
fwd.retained_submission = val;
|
|
359
|
-
}
|
|
360
|
-
break;
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
return fwd;
|
|
364
|
-
}
|
|
365
|
-
function convertNodeArrayToGraph(data) {
|
|
366
|
-
const nodes = [];
|
|
367
|
-
const edges = [];
|
|
368
|
-
for (const item of data) {
|
|
369
|
-
if (!item || typeof item !== "object")
|
|
370
|
-
continue;
|
|
371
|
-
const node = item;
|
|
372
|
-
const name = typeof node.name === "string" ? node.name : "";
|
|
373
|
-
if (!name)
|
|
374
|
-
continue;
|
|
375
|
-
nodes.push({
|
|
376
|
-
name,
|
|
377
|
-
description: typeof node.description === "string" ? node.description : null,
|
|
378
|
-
});
|
|
379
|
-
const pairs = Array.isArray(node.pairs) ? node.pairs : [];
|
|
380
|
-
for (const pairRaw of pairs) {
|
|
381
|
-
if (!pairRaw || typeof pairRaw !== "object")
|
|
382
|
-
continue;
|
|
383
|
-
const pair = pairRaw;
|
|
384
|
-
const prevNode = typeof pair.prev_node === "string" ? pair.prev_node : "";
|
|
385
|
-
const threshold = typeof pair.threshold === "number" ? pair.threshold : 1;
|
|
386
|
-
const forwardsRaw = Array.isArray(pair.forwards) ? pair.forwards : [];
|
|
387
|
-
const forwards = forwardsRaw.map((f) => {
|
|
388
|
-
const fwd = f;
|
|
389
|
-
return {
|
|
390
|
-
name: typeof fwd.name === "string" ? fwd.name : "",
|
|
391
|
-
weight: typeof fwd.weight === "number" ? fwd.weight : 1,
|
|
392
|
-
named_operator: typeof fwd.namedOperator === "string" ? fwd.namedOperator : null,
|
|
393
|
-
permission_index: typeof fwd.permissionIndex === "number" ? fwd.permissionIndex : null,
|
|
394
|
-
guard: typeof fwd.guard === "string"
|
|
395
|
-
? fwd.guard
|
|
396
|
-
: (fwd.guard && typeof fwd.guard.guard === "string")
|
|
397
|
-
? fwd.guard.guard
|
|
398
|
-
: null,
|
|
399
|
-
retained_submission: null,
|
|
400
|
-
};
|
|
401
|
-
});
|
|
402
|
-
edges.push({
|
|
403
|
-
from: prevNode,
|
|
404
|
-
to: name,
|
|
405
|
-
threshold,
|
|
406
|
-
forwards,
|
|
407
|
-
});
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
return { nodes, edges };
|
|
411
|
-
}
|
|
412
|
-
export function renderMachineAscii(input) {
|
|
413
|
-
const { nodes, edges, machineName, machineAddress, published, paused } = input;
|
|
414
|
-
const lines = [];
|
|
415
|
-
if (machineName) {
|
|
416
|
-
lines.push(`Machine: ${machineName}`);
|
|
417
|
-
}
|
|
418
|
-
if (machineAddress) {
|
|
419
|
-
lines.push(`Address: ${machineAddress}`);
|
|
420
|
-
}
|
|
421
|
-
if (published !== null && published !== undefined) {
|
|
422
|
-
lines.push(`Published: ${published}`);
|
|
423
|
-
}
|
|
424
|
-
if (paused !== null && paused !== undefined) {
|
|
425
|
-
lines.push(`Paused: ${paused}`);
|
|
426
|
-
}
|
|
427
|
-
if (machineName || machineAddress) {
|
|
428
|
-
lines.push("");
|
|
429
|
-
}
|
|
430
|
-
const outgoingMap = new Map();
|
|
431
|
-
for (const edge of edges) {
|
|
432
|
-
if (edge.from === "")
|
|
433
|
-
continue;
|
|
434
|
-
if (!outgoingMap.has(edge.from))
|
|
435
|
-
outgoingMap.set(edge.from, []);
|
|
436
|
-
outgoingMap.get(edge.from).push(edge);
|
|
437
|
-
}
|
|
438
|
-
const terminalNodes = new Set();
|
|
439
|
-
for (const node of nodes) {
|
|
440
|
-
const outEdges = outgoingMap.get(node.name) ?? [];
|
|
441
|
-
const hasOutgoingToNode = outEdges.some(e => e.to !== "");
|
|
442
|
-
if (!hasOutgoingToNode) {
|
|
443
|
-
const isTargeted = edges.some(e => e.to === node.name);
|
|
444
|
-
if (isTargeted) {
|
|
445
|
-
terminalNodes.add(node.name);
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
const entryNodes = new Set();
|
|
450
|
-
for (const edge of edges) {
|
|
451
|
-
if (edge.from === "") {
|
|
452
|
-
entryNodes.add(edge.to);
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
const revisionNodes = new Set();
|
|
456
|
-
for (const edge of edges) {
|
|
457
|
-
if (edge.from === edge.to && edge.from !== "") {
|
|
458
|
-
revisionNodes.add(edge.from);
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
for (const edge of edges) {
|
|
462
|
-
const fromLabel = edge.from === "" ? "[*]" : edge.from;
|
|
463
|
-
const toLabel = edge.to === "" ? "[*]" : edge.to;
|
|
464
|
-
const isCycle = edge.from === edge.to && edge.from !== "";
|
|
465
|
-
for (const fwd of edge.forwards) {
|
|
466
|
-
const annotations = [];
|
|
467
|
-
if (isCycle)
|
|
468
|
-
annotations.push("cycle");
|
|
469
|
-
if (fwd.guard)
|
|
470
|
-
annotations.push(`guard=${fwd.guard}`);
|
|
471
|
-
if (fwd.named_operator !== null && fwd.named_operator !== undefined && fwd.named_operator !== "") {
|
|
472
|
-
annotations.push(`op=${fwd.named_operator}`);
|
|
473
|
-
}
|
|
474
|
-
if (fwd.permission_index !== null && fwd.permission_index !== undefined) {
|
|
475
|
-
annotations.push(`perm=${fwd.permission_index}`);
|
|
476
|
-
}
|
|
477
|
-
if (edge.threshold > 1)
|
|
478
|
-
annotations.push(`threshold=${edge.threshold}`);
|
|
479
|
-
const annotationStr = annotations.length > 0 ? ` [${annotations.join(", ")}]` : "";
|
|
480
|
-
const cycleStr = isCycle ? " ⟲" : "";
|
|
481
|
-
lines.push(`${fromLabel} ─${fwd.name}→ ${toLabel}${cycleStr}${annotationStr}`);
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
const annotatedNodes = [];
|
|
485
|
-
for (const node of nodes) {
|
|
486
|
-
const annotations = [];
|
|
487
|
-
if (entryNodes.has(node.name))
|
|
488
|
-
annotations.push("entry");
|
|
489
|
-
if (terminalNodes.has(node.name))
|
|
490
|
-
annotations.push("terminal");
|
|
491
|
-
if (revisionNodes.has(node.name))
|
|
492
|
-
annotations.push("revision");
|
|
493
|
-
if (annotations.length > 0) {
|
|
494
|
-
annotatedNodes.push(` ${node.name}: ${annotations.join(", ")}`);
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
if (annotatedNodes.length > 0) {
|
|
498
|
-
lines.push("");
|
|
499
|
-
lines.push("Node roles:");
|
|
500
|
-
lines.push(...annotatedNodes);
|
|
501
|
-
}
|
|
502
|
-
return lines.join("\n");
|
|
503
|
-
}
|
|
504
|
-
export function renderMachineMarkmap(input) {
|
|
505
|
-
const { nodes, edges, machineName, machineAddress, published, paused } = input;
|
|
506
|
-
const lines = [];
|
|
507
|
-
const titleParts = ["Machine"];
|
|
508
|
-
if (machineName)
|
|
509
|
-
titleParts.push(machineName);
|
|
510
|
-
lines.push(`# ${titleParts.join(": ")}`);
|
|
511
|
-
if (machineAddress || published !== null || paused !== null) {
|
|
512
|
-
lines.push("");
|
|
513
|
-
if (machineAddress)
|
|
514
|
-
lines.push(`**Address:** ${machineAddress}`);
|
|
515
|
-
if (published !== null && published !== undefined)
|
|
516
|
-
lines.push(`**Published:** ${published}`);
|
|
517
|
-
if (paused !== null && paused !== undefined)
|
|
518
|
-
lines.push(`**Paused:** ${paused}`);
|
|
519
|
-
}
|
|
520
|
-
lines.push("");
|
|
521
|
-
const outgoingMap = new Map();
|
|
522
|
-
for (const edge of edges) {
|
|
523
|
-
if (edge.from === "")
|
|
524
|
-
continue;
|
|
525
|
-
if (!outgoingMap.has(edge.from))
|
|
526
|
-
outgoingMap.set(edge.from, []);
|
|
527
|
-
outgoingMap.get(edge.from).push(edge);
|
|
528
|
-
}
|
|
529
|
-
const terminalNodes = new Set();
|
|
530
|
-
for (const node of nodes) {
|
|
531
|
-
const outEdges = outgoingMap.get(node.name) ?? [];
|
|
532
|
-
const hasOutgoingToNode = outEdges.some(e => e.to !== "");
|
|
533
|
-
if (!hasOutgoingToNode) {
|
|
534
|
-
const isTargeted = edges.some(e => e.to === node.name);
|
|
535
|
-
if (isTargeted)
|
|
536
|
-
terminalNodes.add(node.name);
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
for (const edge of edges) {
|
|
540
|
-
const fromLabel = edge.from === "" ? "[*]" : edge.from;
|
|
541
|
-
const toLabel = edge.to === "" ? "[*]" : edge.to;
|
|
542
|
-
const isCycle = edge.from === edge.to && edge.from !== "";
|
|
543
|
-
const cycleStr = isCycle ? " (cycle)" : "";
|
|
544
|
-
const terminalStr = terminalNodes.has(edge.to) ? " (terminal)" : "";
|
|
545
|
-
lines.push(`## ${fromLabel} → ${toLabel}${cycleStr}${terminalStr}`);
|
|
546
|
-
for (const fwd of edge.forwards) {
|
|
547
|
-
const parts = [`weight=${fwd.weight}`];
|
|
548
|
-
if (fwd.named_operator !== null && fwd.named_operator !== undefined) {
|
|
549
|
-
parts.push(`namedOperator='${fwd.named_operator}'`);
|
|
550
|
-
}
|
|
551
|
-
if (fwd.permission_index !== null && fwd.permission_index !== undefined) {
|
|
552
|
-
parts.push(`permissionIndex=${fwd.permission_index}`);
|
|
553
|
-
}
|
|
554
|
-
if (fwd.guard) {
|
|
555
|
-
parts.push(`guard=${fwd.guard}`);
|
|
556
|
-
}
|
|
557
|
-
if (edge.threshold > 1) {
|
|
558
|
-
parts.push(`threshold=${edge.threshold}`);
|
|
559
|
-
}
|
|
560
|
-
lines.push(`### forward: ${fwd.name} (${parts.join(", ")})`);
|
|
561
|
-
}
|
|
562
|
-
lines.push("");
|
|
563
|
-
}
|
|
564
|
-
return lines.join("\n");
|
|
565
|
-
}
|
|
1
|
+
function sanitizeMermaidLabel(a){if(/[<>"\[\]{}()|&]/['test'](a))return'\x22'+a['replace'](/"/g,'\x27')+'\x22';return a;}const MACHINE_NODE_COLORS={'entry':{'fill':'#10b981','stroke':'#065f46'},'terminal':{'fill':'#ef4444','stroke':'#991b1b'},'revision':{'fill':'#f59e0b','stroke':'#92400e'},'normal':{'fill':'#3b82f6','stroke':'#1e40af'}};function classifyMachineNode(a,b,c){const d=b['filter'](g=>g['from']===a);if(d['length']===0x0)return'terminal';const e=d['some'](g=>g['to']!=='');if(!e)return'terminal';const f=b['some'](g=>g['to']===a&&g['from']===a);if(f)return'revision';if(c['has'](a))return'entry';return'normal';}export function sanitizeMermaidNodeId(a){if(/[^a-zA-Z0-9_]/['test'](a))return'\x22'+a+'\x22';return a;}export function renderMachineMermaid(a,b,c){const d=c?.['colored']!==![],e=['stateDiagram-v2'];d&&(e['push']('\x20\x20%%\x20Color\x20Legend\x20(BehaviorTree.CPP-inspired\x20workflow\x20roles):'),e['push']('\x20\x20%%\x20\x20\x20green\x20\x20#10b981\x20-\x20entry\x20\x20\x20\x20(start\x20state,\x20targeted\x20by\x20[*])'),e['push']('\x20\x20%%\x20\x20\x20red\x20\x20\x20\x20#ef4444\x20-\x20terminal\x20(end\x20state,\x20no\x20outgoing\x20edges)'),e['push']('\x20\x20%%\x20\x20\x20amber\x20\x20#f59e0b\x20-\x20revision\x20(self-loop\x20/\x20revision\x20cycle)'),e['push']('\x20\x20%%\x20\x20\x20blue\x20\x20\x20#3b82f6\x20-\x20normal\x20\x20\x20(regular\x20intermediate\x20state)'),e['push']('\x20\x20%%\x20Priority:\x20terminal\x20>\x20revision\x20>\x20entry\x20>\x20normal'));const f=new Set(b['filter'](i=>i['from']!=='')['map'](i=>i['to'])),g=new Set();for(const i of a){!f['has'](i['name'])&&g['add'](i['name']);}const h=a['filter'](j=>g['has'](j['name']));for(const j of h){const k=b['filter'](l=>l['from']===''&&l['to']===j['name']);if(k['length']>0x0)for(const l of k){for(const m of l['forwards']){const n=buildForwardLabel(m,l['threshold']);e['push']('\x20\x20[*]\x20-->\x20'+sanitizeMermaidNodeId(j['name'])+':\x20'+sanitizeMermaidLabel(n));}}else e['push']('\x20\x20[*]\x20-->\x20'+sanitizeMermaidNodeId(j['name']));}for(const o of b){if(o['from']==='')continue;const p=sanitizeMermaidNodeId(o['from']),q=o['to']===''?'[*]':sanitizeMermaidNodeId(o['to']);for(const r of o['forwards']){const s=buildForwardLabel(r,o['threshold']);e['push']('\x20\x20'+p+'\x20-->\x20'+q+':\x20'+sanitizeMermaidLabel(s));}}for(const t of a){t['description']&&e['push']('\x20\x20'+sanitizeMermaidNodeId(t['name'])+':\x20'+sanitizeMermaidLabel(t['description']));}if(d){e['push'](''),e['push']('\x20\x20%%\x20Node\x20colors\x20(BehaviorTree.CPP-inspired\x20workflow\x20roles)');for(const u of a){const v=classifyMachineNode(u['name'],b,g),w=MACHINE_NODE_COLORS[v];e['push']('\x20\x20style\x20'+sanitizeMermaidNodeId(u['name'])+'\x20fill:'+w['fill']+',stroke:'+w['stroke']+',color:#fff');}}return e['join']('\x0a');}function buildForwardLabel(a,b){let c=a['name'];const d=[];b>0x1&&d['push']('threshold='+b);if(a['guard']){const e=a['guard']['length']>0xa?a['guard']['slice'](0x0,0x6)+'…'+a['guard']['slice'](-0x4):a['guard'];d['push']('guard='+e);}return d['length']>0x0&&(c+='\x20('+d['join'](',\x20')+')'),c;}export function renderMachineTreeIndented(a){const {nodes:b,edges:c,machineName:d,machineAddress:e,published:f,paused:g}=a,h=[];h['push']('#\x20Machine\x20Workflow\x20Definition'),h['push']('');d&&h['push']('**Machine:**\x20'+d);e&&h['push']('**Address:**\x20'+e);h['push']('**Total\x20Nodes:**\x20'+b['length']),h['push']('**Total\x20Edges:**\x20'+c['length']);f!==null&&f!==undefined&&h['push']('**Published:**\x20'+f);g!==null&&g!==undefined&&h['push']('**Paused:**\x20'+g);h['push'](''),h['push']('##\x20Topology\x20(directed\x20graph\x20outline)'),h['push']('');const i=c['filter'](m=>m['from']===''),j=c['filter'](m=>m['from']!=='');for(const m of i){const n='-\x20[*]\x20-->\x20'+m['to']+'\x20(threshold='+m['threshold']+')';h['push'](n);for(const o of m['forwards']){h['push']('\x20\x20-\x20forward:\x20'+formatForwardInline(o));}}for(const p of j){const q=p['from']===p['to'],r=q?'\x20\x20#\x20self-loop\x20(revision\x20cycle)':'',s=p['to']===''?'[*]':p['to'],t='-\x20'+p['from']+'\x20-->\x20'+s+'\x20(threshold='+p['threshold']+')'+r;h['push'](t);for(const u of p['forwards']){h['push']('\x20\x20-\x20forward:\x20'+formatForwardInline(u));}}const k=b['filter'](v=>v['description']);if(k['length']>0x0){h['push'](''),h['push']('##\x20Node\x20Descriptions'),h['push']('');for(const v of b){v['description']&&h['push']('-\x20'+v['name']+':\x20'+v['description']);}}const l=new Map();for(const w of c){if(!l['has'](w['to']))l['set'](w['to'],[]);l['get'](w['to'])['push']({'from':w['from']===''?'[*]':w['from'],'forwards':w['forwards']['map'](x=>x['name'])});}if(l['size']>0x0){h['push'](''),h['push']('##\x20Backrefs\x20(incoming\x20edges\x20per\x20node)'),h['push']('');for(const x of b){const y=l['get'](x['name']);if(!y||y['length']===0x0)continue;const z=y['map'](A=>{const B=A['forwards']['length']>0x0?'\x20('+A['forwards']['join'](',\x20')+')':'',C=A['from']===x['name']?'\x20#\x20self-loop':'';return'<-\x20'+A['from']+B+C;});h['push']('-\x20'+x['name']+':\x20'+z['join'](',\x20'));}}return h['push'](''),h['push']('##\x20JSON\x20Definition'),h['push'](''),h['push']('```json'),h['push'](JSON['stringify']({'nodes':b,'edges':c},null,0x2)),h['push']('```'),h['join']('\x0a');}function formatForwardInline(a){const b=['weight='+a['weight']];a['named_operator']!==null&&a['named_operator']!==undefined&&b['push']('namedOperator=\x27'+a['named_operator']+'\x27');a['permission_index']!==null&&a['permission_index']!==undefined&&b['push']('permissionIndex='+a['permission_index']);a['guard']&&b['push']('guard='+a['guard']);if(a['retained_submission']){const c=Array['isArray'](a['retained_submission'])?'['+a['retained_submission']['join'](',')+']':String(a['retained_submission']);b['push']('retained_submission='+c);}return a['name']+'\x20('+b['join'](',\x20')+')';}export function parseMachineTreeIndented(a){const b=[],c=a['match'](/```json\s*\n([\s\S]*?)```/);if(c)try{const o=JSON['parse'](c[0x1]['trim']());if(o&&typeof o==='object'&&Array['isArray'](o['nodes'])&&Array['isArray'](o['edges']))return{'success':!![],'data':o,'errors':[]};if(Array['isArray'](o)){const {nodes:p,edges:q}=convertNodeArrayToGraph(o);return{'success':!![],'data':{'nodes':p,'edges':q},'errors':[]};}}catch(r){b['push']('JSON\x20code\x20block\x20parse\x20error:\x20'+r['message']);}const d=a['match'](/##\s*Topology[^\n]*\n([\s\S]*?)(?=\n##\s|$)/i);if(!d)return{'success':![],'errors':['No\x20\x27##\x20Topology\x27\x20section\x20found.\x20'+'Use\x20the\x20format\x20produced\x20by\x20renderMachineTreeIndented()\x20or\x20a\x20JSON\x20code\x20block.']};const f=d[0x1],g=new Set(),h=[],i=f['split']('\x0a')['filter'](s=>s['trim']()['startsWith']('-\x20'));let j=null;for(const s of i){const t=s['trim'](),u=s['startsWith']('\x20\x20-');if(u){const w=t['match'](/^-\s*forward:\s*(.+)$/);if(w&&j){const x=parseForwardInline(w[0x1]);x&&j['forwards']['push'](x);}continue;}const v=t['match'](/^-\s+(.+?)\s+-->\s+(\S+)(?:\s+\(threshold=(\d+)\))?(.*)$/);if(v){j&&h['push'](j);const y=v[0x1]['trim'](),z=v[0x2]['trim'](),A=v[0x3]?parseInt(v[0x3],0xa):0x1,B=y==='[*]'?'':y;j={'from':B,'to':z,'threshold':A,'forwards':[]},g['add'](z);if(B)g['add'](B);}}j&&h['push'](j);if(h['length']===0x0)return{'success':![],'errors':['No\x20edges\x20found\x20in\x20\x27##\x20Topology\x27\x20section.\x20Expected\x20lines\x20like\x20\x27-\x20A\x20-->\x20B\x20(threshold=1)\x27.']};const k=a['match'](/##\s*Node Descriptions[^\n]*\n([\s\S]*?)(?=\n##\s|$)/i),l=new Map();if(k){const C=k[0x1]['split']('\x0a');for(const D of C){const E=D['match'](/^-\s+(\S+):\s*(.+)$/);E&&l['set'](E[0x1],E[0x2]);}}const n=[];for(const F of g){n['push']({'name':F,'description':l['get'](F)??null});}return{'success':!![],'data':{'nodes':n,'edges':h},'errors':b};}function parseForwardInline(a){const b=a['match'](/^(\S+)\s*\(([^)]*)\)$/);if(!b)return{'name':a['trim'](),'weight':0x1,'named_operator':null,'permission_index':null,'guard':null,'retained_submission':null};const c=b[0x1],d=b[0x2],e={'name':c,'weight':0x1,'named_operator':null,'permission_index':null,'guard':null,'retained_submission':null};for(const f of d['split'](',')['map'](g=>g['trim']())){if(!f)continue;const [g,...h]=f['split']('='),i=h['join']('=')['trim']();switch(g['trim']()){case'weight':e['weight']=parseInt(i,0xa)||0x1;break;case'namedOperator':e['named_operator']=i['replace'](/^'|'$/g,'');break;case'permissionIndex':e['permission_index']=parseInt(i,0xa)||null;break;case'guard':e['guard']=i||null;break;case'retained_submission':i['startsWith']('[')&&i['endsWith'](']')?e['retained_submission']=i['slice'](0x1,-0x1)['split'](',')['map'](j=>parseInt(j['trim'](),0xa))['filter'](j=>!isNaN(j)):e['retained_submission']=i;break;}}return e;}function convertNodeArrayToGraph(a){const b=[],c=[];for(const d of a){if(!d||typeof d!=='object')continue;const e=d,f=typeof e['name']==='string'?e['name']:'';if(!f)continue;b['push']({'name':f,'description':typeof e['description']==='string'?e['description']:null});const g=Array['isArray'](e['pairs'])?e['pairs']:[];for(const h of g){if(!h||typeof h!=='object')continue;const i=h,j=typeof i['prev_node']==='string'?i['prev_node']:'',k=typeof i['threshold']==='number'?i['threshold']:0x1,l=Array['isArray'](i['forwards'])?i['forwards']:[],m=l['map'](n=>{const o=n;return{'name':typeof o['name']==='string'?o['name']:'','weight':typeof o['weight']==='number'?o['weight']:0x1,'named_operator':typeof o['namedOperator']==='string'?o['namedOperator']:null,'permission_index':typeof o['permissionIndex']==='number'?o['permissionIndex']:null,'guard':typeof o['guard']==='string'?o['guard']:o['guard']&&typeof o['guard']['guard']==='string'?o['guard']['guard']:null,'retained_submission':null};});c['push']({'from':j,'to':f,'threshold':k,'forwards':m});}}return{'nodes':b,'edges':c};}export function renderMachineAscii(a){const {nodes:b,edges:c,machineName:d,machineAddress:e,published:f,paused:g}=a,h=[];d&&h['push']('Machine:\x20'+d);e&&h['push']('Address:\x20'+e);f!==null&&f!==undefined&&h['push']('Published:\x20'+f);g!==null&&g!==undefined&&h['push']('Paused:\x20'+g);(d||e)&&h['push']('');const i=new Map();for(const n of c){if(n['from']==='')continue;if(!i['has'](n['from']))i['set'](n['from'],[]);i['get'](n['from'])['push'](n);}const j=new Set();for(const o of b){const p=i['get'](o['name'])??[],q=p['some'](r=>r['to']!=='');if(!q){const r=c['some'](s=>s['to']===o['name']);r&&j['add'](o['name']);}}const k=new Set();for(const s of c){s['from']===''&&k['add'](s['to']);}const l=new Set();for(const t of c){t['from']===t['to']&&t['from']!==''&&l['add'](t['from']);}for(const u of c){const v=u['from']===''?'[*]':u['from'],w=u['to']===''?'[*]':u['to'],x=u['from']===u['to']&&u['from']!=='';for(const y of u['forwards']){const z=[];if(x)z['push']('cycle');if(y['guard'])z['push']('guard='+y['guard']);y['named_operator']!==null&&y['named_operator']!==undefined&&y['named_operator']!==''&&z['push']('op='+y['named_operator']);y['permission_index']!==null&&y['permission_index']!==undefined&&z['push']('perm='+y['permission_index']);if(u['threshold']>0x1)z['push']('threshold='+u['threshold']);const A=z['length']>0x0?'\x20['+z['join'](',\x20')+']':'',B=x?'\x20⟲':'';h['push'](v+'\x20─'+y['name']+'→\x20'+w+B+A);}}const m=[];for(const C of b){const D=[];if(k['has'](C['name']))D['push']('entry');if(j['has'](C['name']))D['push']('terminal');if(l['has'](C['name']))D['push']('revision');D['length']>0x0&&m['push']('\x20\x20'+C['name']+':\x20'+D['join'](',\x20'));}return m['length']>0x0&&(h['push'](''),h['push']('Node\x20roles:'),h['push'](...m)),h['join']('\x0a');}export function renderMachineMarkmap(a){const {nodes:b,edges:c,machineName:d,machineAddress:e,published:f,paused:g}=a,h=[],i=['Machine'];if(d)i['push'](d);h['push']('#\x20'+i['join'](':\x20'));if(e||f!==null||g!==null){h['push']('');if(e)h['push']('**Address:**\x20'+e);if(f!==null&&f!==undefined)h['push']('**Published:**\x20'+f);if(g!==null&&g!==undefined)h['push']('**Paused:**\x20'+g);}h['push']('');const j=new Map();for(const l of c){if(l['from']==='')continue;if(!j['has'](l['from']))j['set'](l['from'],[]);j['get'](l['from'])['push'](l);}const k=new Set();for(const m of b){const n=j['get'](m['name'])??[],o=n['some'](p=>p['to']!=='');if(!o){const p=c['some'](q=>q['to']===m['name']);if(p)k['add'](m['name']);}}for(const q of c){const r=q['from']===''?'[*]':q['from'],s=q['to']===''?'[*]':q['to'],t=q['from']===q['to']&&q['from']!=='',u=t?'\x20(cycle)':'',v=k['has'](q['to'])?'\x20(terminal)':'';h['push']('##\x20'+r+'\x20→\x20'+s+u+v);for(const w of q['forwards']){const x=['weight='+w['weight']];w['named_operator']!==null&&w['named_operator']!==undefined&&x['push']('namedOperator=\x27'+w['named_operator']+'\x27'),w['permission_index']!==null&&w['permission_index']!==undefined&&x['push']('permissionIndex='+w['permission_index']),w['guard']&&x['push']('guard='+w['guard']),q['threshold']>0x1&&x['push']('threshold='+q['threshold']),h['push']('###\x20forward:\x20'+w['name']+'\x20('+x['join'](',\x20')+')');}h['push']('');}return h['join']('\x0a');}
|