@wowok/agent-mcp 2.7.0 → 2.7.2
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/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.js +1 -373
- package/dist/customer/post-purchase.js +1 -351
- package/dist/customer/preorder-compare.js +1 -34
- package/dist/customer/reminder-system.js +1 -316
- package/dist/customer/risk-assessment.d.ts +5 -1
- package/dist/customer/risk-assessment.js +1 -397
- package/dist/customer/types.js +1 -13
- package/dist/customer/user-preferences.js +1 -460
- package/dist/evaluation/arbitration-game.d.ts +23 -0
- package/dist/evaluation/arbitration-game.js +1 -0
- package/dist/evaluation/builtins/demand-match.d.ts +15 -0
- package/dist/evaluation/builtins/demand-match.js +1 -0
- package/dist/evaluation/builtins/index.d.ts +3 -0
- package/dist/evaluation/builtins/index.js +1 -0
- package/dist/evaluation/builtins/service-risk.d.ts +6 -0
- package/dist/evaluation/builtins/service-risk.js +1 -0
- package/dist/evaluation/capability.d.ts +50 -0
- package/dist/evaluation/capability.js +1 -0
- package/dist/evaluation/composer.d.ts +13 -0
- package/dist/evaluation/composer.js +1 -0
- package/dist/evaluation/engine.d.ts +18 -0
- package/dist/evaluation/engine.js +1 -0
- package/dist/evaluation/extract.d.ts +30 -0
- package/dist/evaluation/extract.js +1 -0
- package/dist/evaluation/game-strategy.d.ts +27 -0
- package/dist/evaluation/game-strategy.js +1 -0
- package/dist/evaluation/gap.d.ts +2 -0
- package/dist/evaluation/gap.js +1 -0
- package/dist/evaluation/index.d.ts +12 -0
- package/dist/evaluation/index.js +1 -0
- package/dist/evaluation/node-game.d.ts +62 -0
- package/dist/evaluation/node-game.js +1 -0
- package/dist/evaluation/region.d.ts +10 -0
- package/dist/evaluation/region.js +1 -0
- package/dist/evaluation/types.d.ts +77 -0
- package/dist/evaluation/types.js +1 -0
- package/dist/evaluation/user-injection.d.ts +6 -0
- package/dist/evaluation/user-injection.js +1 -0
- package/dist/examples/education-contact-create.json +40 -0
- package/dist/examples/freelance-contact-create.json +40 -0
- package/dist/examples/insurance-machine-create.json +1 -1
- package/dist/examples/insurance-service-allocators.json +1 -1
- package/dist/examples/machine-publish.json +1 -1
- package/dist/examples/rental-ziroom-service-create.json +1 -1
- package/dist/examples/retail-adv-guard-messenger-proof-create.json +1 -1
- package/dist/examples/retail-myshop-service-create.json +1 -1
- package/dist/examples/retail-myshop-service-customer-required.json +1 -1
- package/dist/examples/subscription-contact-create.json +40 -0
- package/dist/examples/threebody-machine-create.json +1 -1
- package/dist/examples/travel-machine-create.json +1 -1
- package/dist/examples/travel-service-create.json +1 -1
- 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.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.js +1 -6
- package/dist/extensions/metric-registry.js +1 -257
- package/dist/extensions/mode-evaluator.js +1 -170
- package/dist/extensions/modes.js +1 -499
- package/dist/extensions/registry.js +1 -717
- package/dist/extensions/types.js +1 -1
- package/dist/harness/auto-escalation.js +1 -68
- package/dist/harness/checkpoint.js +1 -129
- package/dist/harness/index.js +1 -78
- package/dist/harness/plan.js +1 -276
- package/dist/harness/recover.js +1 -139
- package/dist/harness/types.js +1 -1
- package/dist/harness/verify.js +1 -237
- package/dist/index.js +1 -273
- package/dist/intent/enrich.d.ts +1 -0
- package/dist/intent/enrich.js +1 -0
- package/dist/intent/index.d.ts +23 -0
- package/dist/intent/index.js +1 -0
- package/dist/intent/matcher.d.ts +2 -0
- package/dist/intent/matcher.js +1 -0
- package/dist/intent/store.d.ts +19 -0
- package/dist/intent/store.js +1 -0
- package/dist/intent/types.d.ts +33 -0
- package/dist/intent/types.js +1 -0
- 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/arb-risk.js +1 -210
- 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 -433
- package/dist/knowledge/arbitration-templates.js +1 -276
- package/dist/knowledge/arbitration-translation.js +1 -487
- package/dist/knowledge/arbitration-trust.js +1 -117
- package/dist/knowledge/audit-rules.js +1 -141
- package/dist/knowledge/bridge-risk.js +1 -263
- package/dist/knowledge/contact-risk.js +1 -200
- package/dist/knowledge/contact-templates.d.ts +27 -0
- package/dist/knowledge/contact-templates.js +1 -0
- package/dist/knowledge/demand-confirm.js +1 -206
- package/dist/knowledge/demand-matching.js +1 -132
- package/dist/knowledge/demand-risk.js +1 -240
- 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/examples-scanner-cli.js +1 -26
- package/dist/knowledge/examples-scanner.js +1 -825
- 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.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.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 -670
- 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/mcp-schema-audit-cli.js +1 -45
- package/dist/knowledge/mcp-schema-audit.d.ts +1 -1
- package/dist/knowledge/mcp-schema-audit.js +1 -773
- 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-risk.js +1 -249
- package/dist/knowledge/permission-confirm.js +1 -426
- package/dist/knowledge/permission-context.js +1 -224
- 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-risk.js +1 -212
- 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-risk.js +1 -207
- package/dist/knowledge/proof-translation.js +1 -283
- package/dist/knowledge/registrar-risk.js +1 -217
- package/dist/knowledge/repository-confirm.js +1 -286
- package/dist/knowledge/repository-risk.js +1 -373
- package/dist/knowledge/repository-translation.js +1 -445
- package/dist/knowledge/reputation-rules.js +1 -99
- package/dist/knowledge/resource-risk.js +1 -157
- package/dist/knowledge/reward-confirm.js +1 -526
- 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.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.js +1 -615
- package/dist/knowledge/service-templates.js +1 -456
- package/dist/knowledge/service-translation.js +1 -622
- package/dist/knowledge/template-registry.d.ts +1 -1
- package/dist/knowledge/template-registry.js +1 -341
- package/dist/knowledge/tool-constraints.js +1 -195
- package/dist/knowledge/tools-reference.js +1 -155
- 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/util-risk.js +1 -135
- 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/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.d.ts +16 -0
- package/dist/persona/analyzer.js +1 -0
- package/dist/persona/bridge.d.ts +5 -0
- package/dist/persona/bridge.js +1 -0
- package/dist/persona/defaults.d.ts +4 -0
- package/dist/persona/defaults.js +1 -0
- package/dist/persona/experience-bridge.d.ts +3 -0
- package/dist/persona/experience-bridge.js +1 -0
- package/dist/persona/index.d.ts +18 -0
- package/dist/persona/index.js +1 -0
- package/dist/persona/model.d.ts +7 -0
- package/dist/persona/model.js +1 -0
- package/dist/persona/store.d.ts +19 -0
- package/dist/persona/store.js +1 -0
- package/dist/persona/types.d.ts +45 -0
- package/dist/persona/types.js +1 -0
- 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.js +1 -2011
- package/dist/project/game-theory.js +1 -177
- package/dist/project/graph-builder.js +1 -656
- package/dist/project/graph.js +1 -340
- package/dist/project/handlers.d.ts +5 -0
- package/dist/project/handlers.js +1 -1762
- package/dist/project/index.d.ts +1 -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.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.js +1 -245
- 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/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.d.ts +2 -0
- package/dist/rules.js +1 -9
- 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.js +1 -34
- package/dist/schema/call/arbitration.js +1 -113
- package/dist/schema/call/base.d.ts +15 -15
- package/dist/schema/call/base.js +1 -370
- package/dist/schema/call/bridge-handler.js +1 -265
- package/dist/schema/call/bridge.d.ts +7 -7
- package/dist/schema/call/bridge.js +1 -458
- package/dist/schema/call/contact.js +1 -37
- package/dist/schema/call/demand.js +1 -47
- 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.js +1 -193
- package/dist/schema/call/order.js +1 -35
- package/dist/schema/call/payment.js +1 -37
- package/dist/schema/call/permission-handler.js +1 -54
- package/dist/schema/call/permission.js +1 -105
- package/dist/schema/call/personal.js +1 -78
- package/dist/schema/call/progress.js +1 -47
- package/dist/schema/call/proof.js +1 -33
- package/dist/schema/call/repository.js +1 -77
- package/dist/schema/call/reward.js +1 -30
- package/dist/schema/call/semantic.js +1 -1657
- package/dist/schema/call/service.js +1 -178
- package/dist/schema/call/treasury.js +1 -71
- package/dist/schema/common/index.js +1 -407
- package/dist/schema/config/index.js +1 -68
- package/dist/schema/evaluation/index.d.ts +4436 -0
- package/dist/schema/evaluation/index.js +1 -0
- package/dist/schema/index.d.ts +4 -0
- package/dist/schema/index.js +1 -13
- package/dist/schema/intent-radar/index.d.ts +284 -0
- package/dist/schema/intent-radar/index.js +1 -0
- package/dist/schema/local/index.d.ts +21 -21
- package/dist/schema/local/index.js +1 -927
- package/dist/schema/local/wip.js +1 -187
- package/dist/schema/messenger/index.d.ts +7 -7
- package/dist/schema/messenger/index.js +1 -475
- package/dist/schema/operations.d.ts +7 -7
- package/dist/schema/operations.js +1 -520
- package/dist/schema/persona/index.d.ts +1985 -0
- package/dist/schema/persona/index.js +1 -0
- package/dist/schema/project/index.d.ts +96 -50
- package/dist/schema/project/index.js +1 -2057
- package/dist/schema/query/index.d.ts +423 -7
- package/dist/schema/query/index.js +1 -1640
- package/dist/schema/schema-query/index.js +1 -104
- package/dist/schema/schema-version.js +1 -76
- package/dist/schema/sync-layer4.d.ts +1 -1
- package/dist/schema/sync-layer4.js +1 -282
- package/dist/schema/task-status.d.ts +168 -0
- package/dist/schema/task-status.js +1 -0
- 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.js +1 -77
- package/dist/schema-query/index.js +1 -810
- package/dist/schemas/account_operation.output.json +5 -2
- package/dist/schemas/bridge_operation.output.json +5 -2
- package/dist/schemas/evaluation_operation.output.json +782 -0
- package/dist/schemas/evaluation_operation.schema.json +990 -0
- package/dist/schemas/index.json +25 -1
- package/dist/schemas/intent_radar.output.json +232 -0
- package/dist/schemas/intent_radar.schema.json +138 -0
- package/dist/schemas/local_info_operation.output.json +5 -2
- package/dist/schemas/local_mark_operation.output.json +5 -2
- package/dist/schemas/messenger_operation.output.json +5 -2
- package/dist/schemas/onchain_events.output.json +5 -2
- package/dist/schemas/onchain_operations.output.json +5 -2
- package/dist/schemas/onchain_operations.schema.json +6 -6
- package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
- package/dist/schemas/onchain_operations_machine.schema.json +2 -2
- package/dist/schemas/onchain_operations_service.schema.json +3 -3
- package/dist/schemas/onchain_table_data.output.json +6 -3
- package/dist/schemas/persona_operation.output.json +392 -0
- package/dist/schemas/persona_operation.schema.json +250 -0
- package/dist/schemas/project_operation.output.json +28 -8
- package/dist/schemas/query_task_status.output.json +115 -0
- package/dist/schemas/query_task_status.schema.json +24 -0
- package/dist/schemas/query_toolkit.output.json +9 -6
- package/dist/schemas/trust_score.schema.json +1 -1
- package/dist/schemas/wowok_buildin_info.output.json +132 -0
- package/dist/schemas/wowok_buildin_info.schema.json +14 -0
- 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.js +1 -1
- package/dist/tools/handlers/config.js +1 -74
- package/dist/tools/handlers/evaluation.d.ts +2 -0
- package/dist/tools/handlers/evaluation.js +1 -0
- package/dist/tools/handlers/file-export.js +1 -90
- package/dist/tools/handlers/intent-radar.d.ts +2 -0
- package/dist/tools/handlers/intent-radar.js +1 -0
- package/dist/tools/handlers/local.js +1 -53
- package/dist/tools/handlers/messenger.js +1 -188
- package/dist/tools/handlers/onchain.js +1 -1082
- package/dist/tools/handlers/persona.d.ts +4 -0
- package/dist/tools/handlers/persona.js +1 -0
- 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.d.ts +0 -168
- package/dist/tools/handlers/task-status.js +1 -55
- package/dist/tools/handlers/trust.js +1 -380
- package/dist/tools/handlers/wip.js +1 -90
- package/dist/tools/index.js +1 -1306
- package/dist/tools/retry.js +1 -85
- package/dist/tools/rules-hook.js +1 -23
- package/dist/tools/shared.js +1 -130
- 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.d.ts +1 -1
- package/dist/tools/wip-deploy-assist.js +1 -278
- package/dist/tools/wrap.js +1 -500
- package/package.json +5 -3
|
@@ -1,494 +1 @@
|
|
|
1
|
-
import { inferSceneFromFlow, findScene, } from "./machine-ledger.js";
|
|
2
|
-
import { MACHINE_TEMPLATES, getTemplateById, } from "./machine-templates.js";
|
|
3
|
-
import { matchSemanticPattern, identifyExecutionMode, } from "./machine-translation.js";
|
|
4
|
-
import { analyzeTopology, identifyTopologyPattern, } from "./machine-topology.js";
|
|
5
|
-
export function initPuzzleFromIntent(intent) {
|
|
6
|
-
const scene = inferSceneFromFlow(intent);
|
|
7
|
-
const template = scene
|
|
8
|
-
? MACHINE_TEMPLATES.find((t) => t.scene_id === scene.id)
|
|
9
|
-
: undefined;
|
|
10
|
-
const pattern = matchSemanticPattern(intent);
|
|
11
|
-
return {
|
|
12
|
-
version: "1.0.0",
|
|
13
|
-
business_flow: {
|
|
14
|
-
scenario_description: intent,
|
|
15
|
-
scene_id: scene?.id,
|
|
16
|
-
template_id: template?.id,
|
|
17
|
-
industry: scene?.industry[0],
|
|
18
|
-
participation_mode: "P-M4",
|
|
19
|
-
},
|
|
20
|
-
node_design: {
|
|
21
|
-
nodes: [],
|
|
22
|
-
topological_order: [],
|
|
23
|
-
business_stage_mapping: {},
|
|
24
|
-
},
|
|
25
|
-
guard_acceptance: {
|
|
26
|
-
guard_bindings: [],
|
|
27
|
-
name_length_verified: false,
|
|
28
|
-
all_guards_created: false,
|
|
29
|
-
cross_machine_guards: [],
|
|
30
|
-
},
|
|
31
|
-
permission_model: {
|
|
32
|
-
forward_permissions: [],
|
|
33
|
-
named_operator_roles: [],
|
|
34
|
-
completeness_verified: false,
|
|
35
|
-
},
|
|
36
|
-
threshold_weight: {
|
|
37
|
-
pair_thresholds: [],
|
|
38
|
-
forward_weights: [],
|
|
39
|
-
execution_mode: pattern?.id || "P-M-SEQ",
|
|
40
|
-
allocator_integration: [],
|
|
41
|
-
},
|
|
42
|
-
branch_topology: {
|
|
43
|
-
topology_pattern: "P-M-LINEAR",
|
|
44
|
-
branching_points: [],
|
|
45
|
-
merge_points: [],
|
|
46
|
-
is_dag: true,
|
|
47
|
-
},
|
|
48
|
-
overall_objective: {
|
|
49
|
-
primary_branch: { start_node: "", end_node: "", description: "" },
|
|
50
|
-
secondary_branches: [],
|
|
51
|
-
success_criteria: "",
|
|
52
|
-
failure_criteria: "",
|
|
53
|
-
},
|
|
54
|
-
risk_assessment: {
|
|
55
|
-
overall_risk_level: "low",
|
|
56
|
-
identified_risks: [],
|
|
57
|
-
mitigation_strategy: "",
|
|
58
|
-
environment_readiness: {
|
|
59
|
-
permission_published: false,
|
|
60
|
-
guards_published: false,
|
|
61
|
-
arbitration_published: false,
|
|
62
|
-
reward_published: false,
|
|
63
|
-
testnet_tested: false,
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
export function initPuzzleFromTemplate(templateId) {
|
|
69
|
-
const template = getTemplateById(templateId);
|
|
70
|
-
if (!template)
|
|
71
|
-
return undefined;
|
|
72
|
-
const scene = findScene(template.scene_id);
|
|
73
|
-
if (!scene)
|
|
74
|
-
return undefined;
|
|
75
|
-
const puzzle = initPuzzleFromIntent(template.description);
|
|
76
|
-
puzzle.business_flow.template_id = template.id;
|
|
77
|
-
puzzle.business_flow.scene_id = scene.id;
|
|
78
|
-
puzzle.business_flow.industry = scene.industry[0];
|
|
79
|
-
puzzle.business_flow.participation_mode = "P-M1";
|
|
80
|
-
puzzle.node_design.nodes = template.example_nodes.map((n) => ({
|
|
81
|
-
name: n.name,
|
|
82
|
-
description: n.description || "",
|
|
83
|
-
is_entry: false,
|
|
84
|
-
is_terminal: false,
|
|
85
|
-
}));
|
|
86
|
-
puzzle.permission_model.permission_object = {
|
|
87
|
-
use_custom: true,
|
|
88
|
-
custom_indices: template.required_permissions.map((p) => ({
|
|
89
|
-
index: p.index,
|
|
90
|
-
name: p.name,
|
|
91
|
-
description: p.description,
|
|
92
|
-
})),
|
|
93
|
-
};
|
|
94
|
-
puzzle.guard_acceptance.guard_bindings = template.required_guards.map((g) => ({
|
|
95
|
-
forward_id: {
|
|
96
|
-
pair_id: { prev_node: "", next_node: "" },
|
|
97
|
-
forward_name: g.bound_to_forward,
|
|
98
|
-
},
|
|
99
|
-
guard_template_id: g.guard_template_id,
|
|
100
|
-
purpose: g.purpose,
|
|
101
|
-
tested_on_testnet: false,
|
|
102
|
-
}));
|
|
103
|
-
puzzle.threshold_weight.allocator_integration = template.required_allocators.map((a) => ({
|
|
104
|
-
name: a.name,
|
|
105
|
-
trigger_node: a.trigger_node,
|
|
106
|
-
sharing_who: "Entity",
|
|
107
|
-
recipient_description: a.description,
|
|
108
|
-
}));
|
|
109
|
-
return puzzle;
|
|
110
|
-
}
|
|
111
|
-
function resolveFragmentNameConflicts(fragments) {
|
|
112
|
-
const allNodes = [];
|
|
113
|
-
const allPairs = [];
|
|
114
|
-
const renameMap = new Map();
|
|
115
|
-
for (let i = 0; i < fragments.length; i++) {
|
|
116
|
-
const frag = fragments[i];
|
|
117
|
-
const localRename = new Map();
|
|
118
|
-
for (const node of frag.nodes) {
|
|
119
|
-
const isEntryTarget = frag.pairs.some((p) => p.prev_node === "" && p.next_node === node.name);
|
|
120
|
-
const newName = isEntryTarget ? node.name : `f${i}__${node.name}`;
|
|
121
|
-
localRename.set(node.name, newName);
|
|
122
|
-
allNodes.push({ name: newName, description: node.description });
|
|
123
|
-
}
|
|
124
|
-
renameMap.set(i, localRename);
|
|
125
|
-
for (const pair of frag.pairs) {
|
|
126
|
-
const localRenames = renameMap.get(i);
|
|
127
|
-
const newPrev = pair.prev_node === "" ? "" : (localRenames.get(pair.prev_node) ?? pair.prev_node);
|
|
128
|
-
const newNext = localRenames.get(pair.next_node) ?? pair.next_node;
|
|
129
|
-
allPairs.push({
|
|
130
|
-
prev_node: newPrev,
|
|
131
|
-
next_node: newNext,
|
|
132
|
-
threshold: pair.threshold,
|
|
133
|
-
forwards: pair.forwards.map((f) => ({ ...f })),
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return { nodes: allNodes, pairs: allPairs };
|
|
138
|
-
}
|
|
139
|
-
export function initPuzzleFromMachineId(machineId, machineJson) {
|
|
140
|
-
const puzzle = derivePuzzleFromMachineJson(machineJson);
|
|
141
|
-
puzzle.business_flow.participation_mode = "P-M1";
|
|
142
|
-
puzzle.business_flow.referenced_machine_ids = [machineId];
|
|
143
|
-
puzzle.business_flow.scenario_description =
|
|
144
|
-
`Reference to published Machine ${machineId}` +
|
|
145
|
-
(machineJson.name ? ` (${machineJson.name})` : "");
|
|
146
|
-
return puzzle;
|
|
147
|
-
}
|
|
148
|
-
export function initPuzzleFromFragments(fragments) {
|
|
149
|
-
if (fragments.length === 0) {
|
|
150
|
-
const puzzle = initPuzzleFromIntent("(composition of zero fragments)");
|
|
151
|
-
puzzle.business_flow.participation_mode = "P-M2";
|
|
152
|
-
return puzzle;
|
|
153
|
-
}
|
|
154
|
-
const { nodes, pairs } = resolveFragmentNameConflicts(fragments);
|
|
155
|
-
const mergedSceneId = fragments.find((f) => f.scene_id)?.scene_id;
|
|
156
|
-
const mergedTemplateId = fragments.find((f) => f.template_id)?.template_id;
|
|
157
|
-
const mergedName = fragments.map((f) => f.name ?? "(unnamed)").join(" + ");
|
|
158
|
-
const puzzle = derivePuzzleFromMachineJson({
|
|
159
|
-
name: mergedName,
|
|
160
|
-
nodes,
|
|
161
|
-
pairs,
|
|
162
|
-
scene_id: mergedSceneId,
|
|
163
|
-
template_id: mergedTemplateId,
|
|
164
|
-
});
|
|
165
|
-
puzzle.business_flow.participation_mode = "P-M2";
|
|
166
|
-
puzzle.business_flow.scenario_description =
|
|
167
|
-
`Composition of ${fragments.length} Machine fragments: ${mergedName}`;
|
|
168
|
-
return puzzle;
|
|
169
|
-
}
|
|
170
|
-
export function initPuzzleForCrossChain(machineBId, machineBJson) {
|
|
171
|
-
const puzzle = initPuzzleFromIntent(`Cross-chain dependency on upstream Machine ${machineBId}`);
|
|
172
|
-
puzzle.business_flow.participation_mode = "P-M3";
|
|
173
|
-
puzzle.business_flow.referenced_machine_ids = [machineBId];
|
|
174
|
-
if (machineBJson) {
|
|
175
|
-
const upstreamTopology = analyzeTopology(machineBJson.nodes, machineBJson.pairs);
|
|
176
|
-
for (const terminalNode of upstreamTopology.terminal_nodes) {
|
|
177
|
-
puzzle.guard_acceptance.cross_machine_guards.push({
|
|
178
|
-
forward_id: {
|
|
179
|
-
pair_id: { prev_node: "", next_node: "" },
|
|
180
|
-
forward_name: "",
|
|
181
|
-
},
|
|
182
|
-
upstream_machine_id: machineBId,
|
|
183
|
-
upstream_node_name: terminalNode,
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
return puzzle;
|
|
188
|
-
}
|
|
189
|
-
export function initPuzzleForForkModify(machineId, machineJson) {
|
|
190
|
-
const puzzle = derivePuzzleFromMachineJson(machineJson);
|
|
191
|
-
puzzle.business_flow.participation_mode = "P-M5";
|
|
192
|
-
puzzle.business_flow.referenced_machine_ids = [machineId];
|
|
193
|
-
puzzle.business_flow.fork_source_template_id =
|
|
194
|
-
machineJson.template_id ?? machineId;
|
|
195
|
-
puzzle.business_flow.scenario_description =
|
|
196
|
-
`Fork-modify from Machine ${machineId}` +
|
|
197
|
-
(machineJson.name ? ` (${machineJson.name})` : "");
|
|
198
|
-
return puzzle;
|
|
199
|
-
}
|
|
200
|
-
export function checkPuzzleCompleteness(puzzle) {
|
|
201
|
-
const dimensions = [];
|
|
202
|
-
const aMissing = [];
|
|
203
|
-
if (!puzzle.business_flow.scenario_description)
|
|
204
|
-
aMissing.push("scenario_description");
|
|
205
|
-
if (!puzzle.business_flow.scene_id)
|
|
206
|
-
aMissing.push("scene_id");
|
|
207
|
-
if (!puzzle.business_flow.participation_mode)
|
|
208
|
-
aMissing.push("participation_mode");
|
|
209
|
-
dimensions.push({
|
|
210
|
-
dimension: "A_business_flow",
|
|
211
|
-
complete: aMissing.length === 0,
|
|
212
|
-
missing_fields: aMissing,
|
|
213
|
-
});
|
|
214
|
-
const bMissing = [];
|
|
215
|
-
if (puzzle.node_design.nodes.length === 0)
|
|
216
|
-
bMissing.push("nodes (empty)");
|
|
217
|
-
dimensions.push({
|
|
218
|
-
dimension: "B_node_design",
|
|
219
|
-
complete: bMissing.length === 0,
|
|
220
|
-
missing_fields: bMissing,
|
|
221
|
-
});
|
|
222
|
-
const cMissing = [];
|
|
223
|
-
if (!puzzle.guard_acceptance.all_guards_created)
|
|
224
|
-
cMissing.push("all_guards_created");
|
|
225
|
-
dimensions.push({
|
|
226
|
-
dimension: "C_guard_acceptance",
|
|
227
|
-
complete: cMissing.length === 0,
|
|
228
|
-
missing_fields: cMissing,
|
|
229
|
-
});
|
|
230
|
-
const dMissing = [];
|
|
231
|
-
if (!puzzle.permission_model.completeness_verified)
|
|
232
|
-
dMissing.push("completeness_verified");
|
|
233
|
-
dimensions.push({
|
|
234
|
-
dimension: "D_permission_model",
|
|
235
|
-
complete: dMissing.length === 0,
|
|
236
|
-
missing_fields: dMissing,
|
|
237
|
-
});
|
|
238
|
-
const eMissing = [];
|
|
239
|
-
if (puzzle.threshold_weight.pair_thresholds.length === 0)
|
|
240
|
-
eMissing.push("pair_thresholds (empty)");
|
|
241
|
-
dimensions.push({
|
|
242
|
-
dimension: "E_threshold_weight",
|
|
243
|
-
complete: eMissing.length === 0,
|
|
244
|
-
missing_fields: eMissing,
|
|
245
|
-
});
|
|
246
|
-
const fMissing = [];
|
|
247
|
-
if (!puzzle.branch_topology.is_dag)
|
|
248
|
-
fMissing.push("is_dag (cycle detected)");
|
|
249
|
-
dimensions.push({
|
|
250
|
-
dimension: "F_branch_topology",
|
|
251
|
-
complete: fMissing.length === 0,
|
|
252
|
-
missing_fields: fMissing,
|
|
253
|
-
});
|
|
254
|
-
const gMissing = [];
|
|
255
|
-
if (!puzzle.overall_objective.primary_branch.end_node)
|
|
256
|
-
gMissing.push("primary_branch.end_node");
|
|
257
|
-
if (!puzzle.overall_objective.success_criteria)
|
|
258
|
-
gMissing.push("success_criteria");
|
|
259
|
-
dimensions.push({
|
|
260
|
-
dimension: "G_overall_objective",
|
|
261
|
-
complete: gMissing.length === 0,
|
|
262
|
-
missing_fields: gMissing,
|
|
263
|
-
});
|
|
264
|
-
const hMissing = [];
|
|
265
|
-
if (puzzle.risk_assessment.overall_risk_level === "critical")
|
|
266
|
-
hMissing.push("overall_risk_level=critical (must fix)");
|
|
267
|
-
dimensions.push({
|
|
268
|
-
dimension: "H_risk_assessment",
|
|
269
|
-
complete: hMissing.length === 0,
|
|
270
|
-
missing_fields: hMissing,
|
|
271
|
-
});
|
|
272
|
-
const complete = dimensions.every((d) => d.complete);
|
|
273
|
-
const firstIncomplete = dimensions.find((d) => !d.complete);
|
|
274
|
-
let next_step = "All dimensions complete. Ready for confirmation.";
|
|
275
|
-
if (firstIncomplete) {
|
|
276
|
-
next_step = `Complete dimension ${firstIncomplete.dimension}: ${firstIncomplete.missing_fields.join(", ")}`;
|
|
277
|
-
}
|
|
278
|
-
return { complete, dimensions, next_step };
|
|
279
|
-
}
|
|
280
|
-
export function recommendNextStep(puzzle) {
|
|
281
|
-
const completeness = checkPuzzleCompleteness(puzzle);
|
|
282
|
-
return completeness.next_step;
|
|
283
|
-
}
|
|
284
|
-
export function derivePuzzleFromMachineJson(machine) {
|
|
285
|
-
const topology = analyzeTopology(machine.nodes, machine.pairs);
|
|
286
|
-
const topologyPattern = identifyTopologyPattern(machine.pairs);
|
|
287
|
-
const node_design = {
|
|
288
|
-
nodes: machine.nodes.map((n) => ({
|
|
289
|
-
name: n.name,
|
|
290
|
-
description: n.description || "",
|
|
291
|
-
is_entry: topology.entry_nodes.includes(n.name),
|
|
292
|
-
is_terminal: topology.terminal_nodes.includes(n.name),
|
|
293
|
-
})),
|
|
294
|
-
topological_order: [],
|
|
295
|
-
business_stage_mapping: {},
|
|
296
|
-
};
|
|
297
|
-
const forward_permissions = [];
|
|
298
|
-
const named_operator_roles = [];
|
|
299
|
-
const roleSet = new Set();
|
|
300
|
-
for (const pair of machine.pairs) {
|
|
301
|
-
for (const fwd of pair.forwards) {
|
|
302
|
-
const hasNamed = fwd.named_operator !== undefined;
|
|
303
|
-
const hasPerm = fwd.permission_index !== undefined;
|
|
304
|
-
forward_permissions.push({
|
|
305
|
-
forward: {
|
|
306
|
-
pair_id: { prev_node: pair.prev_node, next_node: pair.next_node },
|
|
307
|
-
forward_name: fwd.name,
|
|
308
|
-
},
|
|
309
|
-
namedOperator: hasNamed
|
|
310
|
-
? { type: fwd.named_operator === "" ? "order_holder" : "role", role: fwd.named_operator || undefined }
|
|
311
|
-
: { type: "none" },
|
|
312
|
-
permissionIndex: hasPerm
|
|
313
|
-
? { type: "custom", index: fwd.permission_index }
|
|
314
|
-
: { type: "none" },
|
|
315
|
-
semantic: "",
|
|
316
|
-
});
|
|
317
|
-
if (fwd.named_operator && fwd.named_operator !== "" && !roleSet.has(fwd.named_operator)) {
|
|
318
|
-
roleSet.add(fwd.named_operator);
|
|
319
|
-
named_operator_roles.push({
|
|
320
|
-
role: fwd.named_operator,
|
|
321
|
-
semantic: "",
|
|
322
|
-
assignment_timing: "at_progress_new_via_sdk",
|
|
323
|
-
});
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
const pair_thresholds = machine.pairs.map((p) => ({
|
|
328
|
-
pair_id: { prev_node: p.prev_node, next_node: p.next_node },
|
|
329
|
-
threshold: p.threshold,
|
|
330
|
-
semantic: "",
|
|
331
|
-
}));
|
|
332
|
-
const forward_weights = machine.pairs.flatMap((p) => p.forwards.map((f) => ({
|
|
333
|
-
forward_id: {
|
|
334
|
-
pair_id: { prev_node: p.prev_node, next_node: p.next_node },
|
|
335
|
-
forward_name: f.name,
|
|
336
|
-
},
|
|
337
|
-
weight: f.weight,
|
|
338
|
-
semantic: "",
|
|
339
|
-
})));
|
|
340
|
-
const executionMode = machine.pairs.length > 0
|
|
341
|
-
? identifyExecutionMode({
|
|
342
|
-
threshold: machine.pairs[0].threshold,
|
|
343
|
-
forwards: machine.pairs[0].forwards.map((f) => ({
|
|
344
|
-
weight: f.weight,
|
|
345
|
-
named_operator: f.named_operator,
|
|
346
|
-
permission_index: f.permission_index,
|
|
347
|
-
})),
|
|
348
|
-
})
|
|
349
|
-
: "P-M-SEQ";
|
|
350
|
-
const branching_points = [];
|
|
351
|
-
const merge_points = [];
|
|
352
|
-
const outgoing = new Map();
|
|
353
|
-
const incoming = new Map();
|
|
354
|
-
for (const pair of machine.pairs) {
|
|
355
|
-
if (!outgoing.has(pair.prev_node))
|
|
356
|
-
outgoing.set(pair.prev_node, []);
|
|
357
|
-
outgoing.get(pair.prev_node).push(pair.next_node);
|
|
358
|
-
if (!incoming.has(pair.next_node))
|
|
359
|
-
incoming.set(pair.next_node, []);
|
|
360
|
-
incoming.get(pair.next_node).push(pair.prev_node);
|
|
361
|
-
}
|
|
362
|
-
for (const [node, nexts] of outgoing) {
|
|
363
|
-
if (nexts.length > 1 && node !== "") {
|
|
364
|
-
branching_points.push({
|
|
365
|
-
node,
|
|
366
|
-
branches: nexts,
|
|
367
|
-
branch_type: "competing",
|
|
368
|
-
});
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
for (const [node, prevs] of incoming) {
|
|
372
|
-
if (prevs.length > 1) {
|
|
373
|
-
merge_points.push({ node, incoming_from: prevs });
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
return {
|
|
377
|
-
version: "1.0.0",
|
|
378
|
-
business_flow: {
|
|
379
|
-
scenario_description: "",
|
|
380
|
-
scene_id: machine.scene_id,
|
|
381
|
-
template_id: machine.template_id,
|
|
382
|
-
participation_mode: "P-M1",
|
|
383
|
-
},
|
|
384
|
-
node_design,
|
|
385
|
-
guard_acceptance: {
|
|
386
|
-
guard_bindings: machine.pairs.flatMap((p) => p.forwards
|
|
387
|
-
.filter((f) => f.guard)
|
|
388
|
-
.map((f) => ({
|
|
389
|
-
forward_id: {
|
|
390
|
-
pair_id: { prev_node: p.prev_node, next_node: p.next_node },
|
|
391
|
-
forward_name: f.name,
|
|
392
|
-
},
|
|
393
|
-
guard_address: f.guard,
|
|
394
|
-
purpose: "",
|
|
395
|
-
tested_on_testnet: false,
|
|
396
|
-
}))),
|
|
397
|
-
name_length_verified: true,
|
|
398
|
-
all_guards_created: true,
|
|
399
|
-
cross_machine_guards: [],
|
|
400
|
-
},
|
|
401
|
-
permission_model: {
|
|
402
|
-
forward_permissions,
|
|
403
|
-
named_operator_roles,
|
|
404
|
-
completeness_verified: true,
|
|
405
|
-
},
|
|
406
|
-
threshold_weight: {
|
|
407
|
-
pair_thresholds,
|
|
408
|
-
forward_weights,
|
|
409
|
-
execution_mode: executionMode,
|
|
410
|
-
allocator_integration: [],
|
|
411
|
-
},
|
|
412
|
-
branch_topology: {
|
|
413
|
-
topology_pattern: topologyPattern,
|
|
414
|
-
branching_points,
|
|
415
|
-
merge_points,
|
|
416
|
-
is_dag: !topology.has_cycles,
|
|
417
|
-
},
|
|
418
|
-
overall_objective: {
|
|
419
|
-
primary_branch: {
|
|
420
|
-
start_node: topology.entry_nodes[0] || "",
|
|
421
|
-
end_node: topology.terminal_nodes[0] || "",
|
|
422
|
-
description: "",
|
|
423
|
-
},
|
|
424
|
-
secondary_branches: [],
|
|
425
|
-
success_criteria: "",
|
|
426
|
-
failure_criteria: "",
|
|
427
|
-
},
|
|
428
|
-
risk_assessment: {
|
|
429
|
-
overall_risk_level: "low",
|
|
430
|
-
identified_risks: [],
|
|
431
|
-
mitigation_strategy: "",
|
|
432
|
-
environment_readiness: {
|
|
433
|
-
permission_published: false,
|
|
434
|
-
guards_published: false,
|
|
435
|
-
arbitration_published: false,
|
|
436
|
-
reward_published: false,
|
|
437
|
-
testnet_tested: false,
|
|
438
|
-
},
|
|
439
|
-
},
|
|
440
|
-
};
|
|
441
|
-
}
|
|
442
|
-
export function generateConfirmationText(puzzle) {
|
|
443
|
-
const lines = [
|
|
444
|
-
"=== Machine Puzzle Summary ===",
|
|
445
|
-
"",
|
|
446
|
-
"A. Business Flow:",
|
|
447
|
-
` Scenario: ${puzzle.business_flow.scenario_description || "(not set)"}`,
|
|
448
|
-
` Scene: ${puzzle.business_flow.scene_id || "(not set)"}`,
|
|
449
|
-
` Template: ${puzzle.business_flow.template_id || "(not set)"}`,
|
|
450
|
-
` Participation: ${puzzle.business_flow.participation_mode || "(not set)"}`,
|
|
451
|
-
"",
|
|
452
|
-
"B. Node Design:",
|
|
453
|
-
` Nodes: ${puzzle.node_design.nodes.length}`,
|
|
454
|
-
...puzzle.node_design.nodes.slice(0, 10).map((n) => ` - ${n.name}${n.is_entry ? " [ENTRY]" : ""}${n.is_terminal ? " [TERMINAL]" : ""}`),
|
|
455
|
-
puzzle.node_design.nodes.length > 10 ? ` ... and ${puzzle.node_design.nodes.length - 10} more` : "",
|
|
456
|
-
"",
|
|
457
|
-
"C. Guard Acceptance:",
|
|
458
|
-
` Guards bound: ${puzzle.guard_acceptance.guard_bindings.length}`,
|
|
459
|
-
` All created: ${puzzle.guard_acceptance.all_guards_created ? "YES" : "NO"}`,
|
|
460
|
-
` Name length verified: ${puzzle.guard_acceptance.name_length_verified ? "YES" : "NO"}`,
|
|
461
|
-
` Cross-machine: ${puzzle.guard_acceptance.cross_machine_guards.length}`,
|
|
462
|
-
"",
|
|
463
|
-
"D. Permission Model:",
|
|
464
|
-
` Forward permissions: ${puzzle.permission_model.forward_permissions.length}`,
|
|
465
|
-
` NamedOperator roles: ${puzzle.permission_model.named_operator_roles.length}`,
|
|
466
|
-
` Completeness verified: ${puzzle.permission_model.completeness_verified ? "YES" : "NO"}`,
|
|
467
|
-
"",
|
|
468
|
-
"E. Threshold & Weight:",
|
|
469
|
-
` Pair thresholds: ${puzzle.threshold_weight.pair_thresholds.length}`,
|
|
470
|
-
` Forward weights: ${puzzle.threshold_weight.forward_weights.length}`,
|
|
471
|
-
` Execution mode: ${puzzle.threshold_weight.execution_mode}`,
|
|
472
|
-
` Allocators: ${puzzle.threshold_weight.allocator_integration.length}`,
|
|
473
|
-
"",
|
|
474
|
-
"F. Branch Topology:",
|
|
475
|
-
` Pattern: ${puzzle.branch_topology.topology_pattern}`,
|
|
476
|
-
` Branching points: ${puzzle.branch_topology.branching_points.length}`,
|
|
477
|
-
` Merge points: ${puzzle.branch_topology.merge_points.length}`,
|
|
478
|
-
` Is DAG: ${puzzle.branch_topology.is_dag ? "YES" : "NO"}`,
|
|
479
|
-
"",
|
|
480
|
-
"G. Overall Objective:",
|
|
481
|
-
` Primary: ${puzzle.overall_objective.primary_branch.start_node} -> ${puzzle.overall_objective.primary_branch.end_node}`,
|
|
482
|
-
` Secondary branches: ${puzzle.overall_objective.secondary_branches.length}`,
|
|
483
|
-
"",
|
|
484
|
-
"H. Risk Assessment:",
|
|
485
|
-
` Overall level: ${puzzle.risk_assessment.overall_risk_level}`,
|
|
486
|
-
` Identified risks: ${puzzle.risk_assessment.identified_risks.length}`,
|
|
487
|
-
"",
|
|
488
|
-
];
|
|
489
|
-
if (puzzle.environment) {
|
|
490
|
-
lines.push("Environment:", ` Network: ${puzzle.environment.network}`, ` Testnet passed: ${puzzle.environment.testnet_test_passed ? "YES" : "NO"}`, ` Backup created: ${puzzle.environment.backup_created ? "YES" : "NO"}`, "");
|
|
491
|
-
}
|
|
492
|
-
return lines.filter((l) => l !== "").join("\n");
|
|
493
|
-
}
|
|
494
|
-
export const MACHINE_PUZZLE_VERSION = "1.0.0";
|
|
1
|
+
import{inferSceneFromFlow,findScene}from'./machine-ledger.js';import{MACHINE_TEMPLATES,getTemplateById}from'./machine-templates.js';import{matchSemanticPattern,identifyExecutionMode}from'./machine-translation.js';import{analyzeTopology,identifyTopologyPattern}from'./machine-topology.js';export function initPuzzleFromIntent(a){const b=inferSceneFromFlow(a),c=b?MACHINE_TEMPLATES['find'](e=>e['scene_id']===b['id']):undefined,d=matchSemanticPattern(a);return{'version':'1.0.0','business_flow':{'scenario_description':a,'scene_id':b?.['id'],'template_id':c?.['id'],'industry':b?.['industry'][0x0],'participation_mode':'P-M4'},'node_design':{'nodes':[],'topological_order':[],'business_stage_mapping':{}},'guard_acceptance':{'guard_bindings':[],'name_length_verified':![],'all_guards_created':![],'cross_machine_guards':[]},'permission_model':{'forward_permissions':[],'named_operator_roles':[],'completeness_verified':![]},'threshold_weight':{'pair_thresholds':[],'forward_weights':[],'execution_mode':d?.['id']||'P-M-SEQ','allocator_integration':[]},'branch_topology':{'topology_pattern':'P-M-LINEAR','branching_points':[],'merge_points':[],'is_dag':!![]},'overall_objective':{'primary_branch':{'start_node':'','end_node':'','description':''},'secondary_branches':[],'success_criteria':'','failure_criteria':''},'risk_assessment':{'overall_risk_level':'low','identified_risks':[],'mitigation_strategy':'','environment_readiness':{'permission_published':![],'guards_published':![],'arbitration_published':![],'reward_published':![],'testnet_tested':![]}}};}export function initPuzzleFromTemplate(a){const b=getTemplateById(a);if(!b)return undefined;const c=findScene(b['scene_id']);if(!c)return undefined;const d=initPuzzleFromIntent(b['description']);return d['business_flow']['template_id']=b['id'],d['business_flow']['scene_id']=c['id'],d['business_flow']['industry']=c['industry'][0x0],d['business_flow']['participation_mode']='P-M1',d['node_design']['nodes']=b['example_nodes']['map'](e=>({'name':e['name'],'description':e['description']||'','is_entry':![],'is_terminal':![]})),d['permission_model']['permission_object']={'use_custom':!![],'custom_indices':b['required_permissions']['map'](e=>({'index':e['index'],'name':e['name'],'description':e['description']}))},d['guard_acceptance']['guard_bindings']=b['required_guards']['map'](e=>({'forward_id':{'pair_id':{'prev_node':'','next_node':''},'forward_name':e['bound_to_forward']},'guard_template_id':e['guard_template_id'],'purpose':e['purpose'],'tested_on_testnet':![]})),d['threshold_weight']['allocator_integration']=b['required_allocators']['map'](e=>({'name':e['name'],'trigger_node':e['trigger_node'],'sharing_who':'Entity','recipient_description':e['description']})),d;}function resolveFragmentNameConflicts(a){const b=[],c=[],d=new Map();for(let e=0x0;e<a['length'];e++){const f=a[e],g=new Map();for(const h of f['nodes']){const j=f['pairs']['some'](l=>l['prev_node']===''&&l['next_node']===h['name']),k=j?h['name']:'f'+e+'__'+h['name'];g['set'](h['name'],k),b['push']({'name':k,'description':h['description']});}d['set'](e,g);for(const l of f['pairs']){const m=d['get'](e),n=l['prev_node']===''?'':m['get'](l['prev_node'])??l['prev_node'],o=m['get'](l['next_node'])??l['next_node'];c['push']({'prev_node':n,'next_node':o,'threshold':l['threshold'],'forwards':l['forwards']['map'](p=>({...p}))});}}return{'nodes':b,'pairs':c};}export function initPuzzleFromMachineId(a,b){const c=derivePuzzleFromMachineJson(b);return c['business_flow']['participation_mode']='P-M1',c['business_flow']['referenced_machine_ids']=[a],c['business_flow']['scenario_description']='Reference\x20to\x20published\x20Machine\x20'+a+(b['name']?'\x20('+b['name']+')':''),c;}export function initPuzzleFromFragments(a){if(a['length']===0x0){const h=initPuzzleFromIntent('(composition\x20of\x20zero\x20fragments)');return h['business_flow']['participation_mode']='P-M2',h;}const {nodes:b,pairs:c}=resolveFragmentNameConflicts(a),d=a['find'](i=>i['scene_id'])?.['scene_id'],e=a['find'](i=>i['template_id'])?.['template_id'],f=a['map'](i=>i['name']??'(unnamed)')['join']('\x20+\x20'),g=derivePuzzleFromMachineJson({'name':f,'nodes':b,'pairs':c,'scene_id':d,'template_id':e});return g['business_flow']['participation_mode']='P-M2',g['business_flow']['scenario_description']='Composition\x20of\x20'+a['length']+'\x20Machine\x20fragments:\x20'+f,g;}export function initPuzzleForCrossChain(a,b){const c=initPuzzleFromIntent('Cross-chain\x20dependency\x20on\x20upstream\x20Machine\x20'+a);c['business_flow']['participation_mode']='P-M3',c['business_flow']['referenced_machine_ids']=[a];if(b){const d=analyzeTopology(b['nodes'],b['pairs']);for(const e of d['terminal_nodes']){c['guard_acceptance']['cross_machine_guards']['push']({'forward_id':{'pair_id':{'prev_node':'','next_node':''},'forward_name':''},'upstream_machine_id':a,'upstream_node_name':e});}}return c;}export function initPuzzleForForkModify(a,b){const c=derivePuzzleFromMachineJson(b);return c['business_flow']['participation_mode']='P-M5',c['business_flow']['referenced_machine_ids']=[a],c['business_flow']['fork_source_template_id']=b['template_id']??a,c['business_flow']['scenario_description']='Fork-modify\x20from\x20Machine\x20'+a+(b['name']?'\x20('+b['name']+')':''),c;}export function checkPuzzleCompleteness(a){const b=[],c=[];if(!a['business_flow']['scenario_description'])c['push']('scenario_description');if(!a['business_flow']['scene_id'])c['push']('scene_id');if(!a['business_flow']['participation_mode'])c['push']('participation_mode');b['push']({'dimension':'A_business_flow','complete':c['length']===0x0,'missing_fields':c});const d=[];if(a['node_design']['nodes']['length']===0x0)d['push']('nodes\x20(empty)');b['push']({'dimension':'B_node_design','complete':d['length']===0x0,'missing_fields':d});const e=[];if(!a['guard_acceptance']['all_guards_created'])e['push']('all_guards_created');b['push']({'dimension':'C_guard_acceptance','complete':e['length']===0x0,'missing_fields':e});const f=[];if(!a['permission_model']['completeness_verified'])f['push']('completeness_verified');b['push']({'dimension':'D_permission_model','complete':f['length']===0x0,'missing_fields':f});const g=[];if(a['threshold_weight']['pair_thresholds']['length']===0x0)g['push']('pair_thresholds\x20(empty)');b['push']({'dimension':'E_threshold_weight','complete':g['length']===0x0,'missing_fields':g});const h=[];if(!a['branch_topology']['is_dag'])h['push']('is_dag\x20(cycle\x20detected)');b['push']({'dimension':'F_branch_topology','complete':h['length']===0x0,'missing_fields':h});const i=[];if(!a['overall_objective']['primary_branch']['end_node'])i['push']('primary_branch.end_node');if(!a['overall_objective']['success_criteria'])i['push']('success_criteria');b['push']({'dimension':'G_overall_objective','complete':i['length']===0x0,'missing_fields':i});const j=[];if(a['risk_assessment']['overall_risk_level']==='critical')j['push']('overall_risk_level=critical\x20(must\x20fix)');b['push']({'dimension':'H_risk_assessment','complete':j['length']===0x0,'missing_fields':j});const k=b['every'](n=>n['complete']),l=b['find'](n=>!n['complete']);let m='All\x20dimensions\x20complete.\x20Ready\x20for\x20confirmation.';return l&&(m='Complete\x20dimension\x20'+l['dimension']+':\x20'+l['missing_fields']['join'](',\x20')),{'complete':k,'dimensions':b,'next_step':m};}export function recommendNextStep(a){const b=checkPuzzleCompleteness(a);return b['next_step'];}export function derivePuzzleFromMachineJson(a){const b=analyzeTopology(a['nodes'],a['pairs']),c=identifyTopologyPattern(a['pairs']),d={'nodes':a['nodes']['map'](o=>({'name':o['name'],'description':o['description']||'','is_entry':b['entry_nodes']['includes'](o['name']),'is_terminal':b['terminal_nodes']['includes'](o['name'])})),'topological_order':[],'business_stage_mapping':{}},e=[],f=[],g=new Set();for(const o of a['pairs']){for(const p of o['forwards']){const q=p['named_operator']!==undefined,r=p['permission_index']!==undefined;e['push']({'forward':{'pair_id':{'prev_node':o['prev_node'],'next_node':o['next_node']},'forward_name':p['name']},'namedOperator':q?{'type':p['named_operator']===''?'order_holder':'role','role':p['named_operator']||undefined}:{'type':'none'},'permissionIndex':r?{'type':'custom','index':p['permission_index']}:{'type':'none'},'semantic':''}),p['named_operator']&&p['named_operator']!==''&&!g['has'](p['named_operator'])&&(g['add'](p['named_operator']),f['push']({'role':p['named_operator'],'semantic':'','assignment_timing':'at_progress_new_via_sdk'}));}}const h=a['pairs']['map'](s=>({'pair_id':{'prev_node':s['prev_node'],'next_node':s['next_node']},'threshold':s['threshold'],'semantic':''})),i=a['pairs']['flatMap'](s=>s['forwards']['map'](t=>({'forward_id':{'pair_id':{'prev_node':s['prev_node'],'next_node':s['next_node']},'forward_name':t['name']},'weight':t['weight'],'semantic':''}))),j=a['pairs']['length']>0x0?identifyExecutionMode({'threshold':a['pairs'][0x0]['threshold'],'forwards':a['pairs'][0x0]['forwards']['map'](s=>({'weight':s['weight'],'named_operator':s['named_operator'],'permission_index':s['permission_index']}))}):'P-M-SEQ',k=[],l=[],m=new Map(),n=new Map();for(const s of a['pairs']){if(!m['has'](s['prev_node']))m['set'](s['prev_node'],[]);m['get'](s['prev_node'])['push'](s['next_node']);if(!n['has'](s['next_node']))n['set'](s['next_node'],[]);n['get'](s['next_node'])['push'](s['prev_node']);}for(const [t,u]of m){u['length']>0x1&&t!==''&&k['push']({'node':t,'branches':u,'branch_type':'competing'});}for(const [v,w]of n){w['length']>0x1&&l['push']({'node':v,'incoming_from':w});}return{'version':'1.0.0','business_flow':{'scenario_description':'','scene_id':a['scene_id'],'template_id':a['template_id'],'participation_mode':'P-M1'},'node_design':d,'guard_acceptance':{'guard_bindings':a['pairs']['flatMap'](x=>x['forwards']['filter'](y=>y['guard'])['map'](y=>({'forward_id':{'pair_id':{'prev_node':x['prev_node'],'next_node':x['next_node']},'forward_name':y['name']},'guard_address':y['guard'],'purpose':'','tested_on_testnet':![]}))),'name_length_verified':!![],'all_guards_created':!![],'cross_machine_guards':[]},'permission_model':{'forward_permissions':e,'named_operator_roles':f,'completeness_verified':!![]},'threshold_weight':{'pair_thresholds':h,'forward_weights':i,'execution_mode':j,'allocator_integration':[]},'branch_topology':{'topology_pattern':c,'branching_points':k,'merge_points':l,'is_dag':!b['has_cycles']},'overall_objective':{'primary_branch':{'start_node':b['entry_nodes'][0x0]||'','end_node':b['terminal_nodes'][0x0]||'','description':''},'secondary_branches':[],'success_criteria':'','failure_criteria':''},'risk_assessment':{'overall_risk_level':'low','identified_risks':[],'mitigation_strategy':'','environment_readiness':{'permission_published':![],'guards_published':![],'arbitration_published':![],'reward_published':![],'testnet_tested':![]}}};}export function generateConfirmationText(a){const b=['===\x20Machine\x20Puzzle\x20Summary\x20===','','A.\x20Business\x20Flow:','\x20\x20\x20Scenario:\x20'+(a['business_flow']['scenario_description']||'(not\x20set)'),'\x20\x20\x20Scene:\x20'+(a['business_flow']['scene_id']||'(not\x20set)'),'\x20\x20\x20Template:\x20'+(a['business_flow']['template_id']||'(not\x20set)'),'\x20\x20\x20Participation:\x20'+(a['business_flow']['participation_mode']||'(not\x20set)'),'','B.\x20Node\x20Design:','\x20\x20\x20Nodes:\x20'+a['node_design']['nodes']['length'],...a['node_design']['nodes']['slice'](0x0,0xa)['map'](c=>'\x20\x20\x20-\x20'+c['name']+(c['is_entry']?'\x20[ENTRY]':'')+(c['is_terminal']?'\x20[TERMINAL]':'')),a['node_design']['nodes']['length']>0xa?'\x20\x20\x20...\x20and\x20'+(a['node_design']['nodes']['length']-0xa)+'\x20more':'','','C.\x20Guard\x20Acceptance:','\x20\x20\x20Guards\x20bound:\x20'+a['guard_acceptance']['guard_bindings']['length'],'\x20\x20\x20All\x20created:\x20'+(a['guard_acceptance']['all_guards_created']?'YES':'NO'),'\x20\x20\x20Name\x20length\x20verified:\x20'+(a['guard_acceptance']['name_length_verified']?'YES':'NO'),'\x20\x20\x20Cross-machine:\x20'+a['guard_acceptance']['cross_machine_guards']['length'],'','D.\x20Permission\x20Model:','\x20\x20\x20Forward\x20permissions:\x20'+a['permission_model']['forward_permissions']['length'],'\x20\x20\x20NamedOperator\x20roles:\x20'+a['permission_model']['named_operator_roles']['length'],'\x20\x20\x20Completeness\x20verified:\x20'+(a['permission_model']['completeness_verified']?'YES':'NO'),'','E.\x20Threshold\x20&\x20Weight:','\x20\x20\x20Pair\x20thresholds:\x20'+a['threshold_weight']['pair_thresholds']['length'],'\x20\x20\x20Forward\x20weights:\x20'+a['threshold_weight']['forward_weights']['length'],'\x20\x20\x20Execution\x20mode:\x20'+a['threshold_weight']['execution_mode'],'\x20\x20\x20Allocators:\x20'+a['threshold_weight']['allocator_integration']['length'],'','F.\x20Branch\x20Topology:','\x20\x20\x20Pattern:\x20'+a['branch_topology']['topology_pattern'],'\x20\x20\x20Branching\x20points:\x20'+a['branch_topology']['branching_points']['length'],'\x20\x20\x20Merge\x20points:\x20'+a['branch_topology']['merge_points']['length'],'\x20\x20\x20Is\x20DAG:\x20'+(a['branch_topology']['is_dag']?'YES':'NO'),'','G.\x20Overall\x20Objective:','\x20\x20\x20Primary:\x20'+a['overall_objective']['primary_branch']['start_node']+'\x20->\x20'+a['overall_objective']['primary_branch']['end_node'],'\x20\x20\x20Secondary\x20branches:\x20'+a['overall_objective']['secondary_branches']['length'],'','H.\x20Risk\x20Assessment:','\x20\x20\x20Overall\x20level:\x20'+a['risk_assessment']['overall_risk_level'],'\x20\x20\x20Identified\x20risks:\x20'+a['risk_assessment']['identified_risks']['length'],''];return a['environment']&&b['push']('Environment:','\x20\x20\x20Network:\x20'+a['environment']['network'],'\x20\x20\x20Testnet\x20passed:\x20'+(a['environment']['testnet_test_passed']?'YES':'NO'),'\x20\x20\x20Backup\x20created:\x20'+(a['environment']['backup_created']?'YES':'NO'),''),b['filter'](c=>c!=='')['join']('\x0a');}export const MACHINE_PUZZLE_VERSION='1.0.0';
|