@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,383 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { initPuzzleFromIntent as initPermissionPuzzleFromIntent, checkPuzzleCompleteness as checkPermissionPuzzleCompleteness, } from "../knowledge/permission-puzzle.js";
|
|
3
|
-
const KEYWORD_TABLE = [
|
|
4
|
-
{
|
|
5
|
-
category: "Product/Service",
|
|
6
|
-
keywords_zh: ["product", "selling", "sell", "sales", "store", "open shop"],
|
|
7
|
-
keywords_en: ["sell", "product", "sale", "shop", "store"],
|
|
8
|
-
objects: ["service", "order", "progress"],
|
|
9
|
-
required_level: "R",
|
|
10
|
-
scene_id: "retail",
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
category: "Subscription",
|
|
14
|
-
keywords_zh: ["subscription", "cycle", "renewal"],
|
|
15
|
-
keywords_en: ["subscribe", "recurring", "subscription"],
|
|
16
|
-
objects: ["service", "machine", "reward"],
|
|
17
|
-
required_level: "C",
|
|
18
|
-
scene_id: "subscription",
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
category: "Rental",
|
|
22
|
-
keywords_zh: ["rent", "lease", "return"],
|
|
23
|
-
keywords_en: ["rent", "lease", "return"],
|
|
24
|
-
objects: ["service", "machine", "arb"],
|
|
25
|
-
required_level: "C",
|
|
26
|
-
scene_id: "rental_return",
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
category: "Trust",
|
|
30
|
-
keywords_zh: ["deposit", "pledge", "verify", "trust"],
|
|
31
|
-
keywords_en: ["deposit", "trust", "verify"],
|
|
32
|
-
objects: ["guard", "permission", "treasury"],
|
|
33
|
-
required_level: "R",
|
|
34
|
-
scene_id: "trust_deposit",
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
category: "Funds",
|
|
38
|
-
keywords_zh: ["split", "collect", "share profit", "income", "incentive"],
|
|
39
|
-
keywords_en: ["split", "revenue", "reward"],
|
|
40
|
-
objects: ["allocation", "treasury", "reward"],
|
|
41
|
-
required_level: "R",
|
|
42
|
-
scene_id: "revenue_split",
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
category: "Workflow",
|
|
46
|
-
keywords_zh: ["node", "stage", "process", "workflow"],
|
|
47
|
-
keywords_en: ["workflow", "stage", "node"],
|
|
48
|
-
objects: ["machine", "progress"],
|
|
49
|
-
required_level: "R",
|
|
50
|
-
scene_id: "workflow",
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
category: "Dispute",
|
|
54
|
-
keywords_zh: ["arbitration", "refund", "conflict", "rights protection"],
|
|
55
|
-
keywords_en: ["arbitration", "refund", "dispute"],
|
|
56
|
-
objects: ["arb", "proof"],
|
|
57
|
-
required_level: "C",
|
|
58
|
-
scene_id: "arbitration_dispute",
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
category: "Contact",
|
|
62
|
-
keywords_zh: ["customer service", "contact", "communication"],
|
|
63
|
-
keywords_en: ["contact", "support", "im"],
|
|
64
|
-
objects: ["contact"],
|
|
65
|
-
required_level: "C",
|
|
66
|
-
scene_id: "contact_im",
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
category: "Data",
|
|
70
|
-
keywords_zh: ["evidence", "record", "data"],
|
|
71
|
-
keywords_en: ["evidence", "record", "data"],
|
|
72
|
-
objects: ["repository", "proof"],
|
|
73
|
-
required_level: "C",
|
|
74
|
-
scene_id: "evidence_record",
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
category: "User Profile",
|
|
78
|
-
keywords_zh: ["personal info", "preference", "privacy"],
|
|
79
|
-
keywords_en: ["personal", "profile", "privacy"],
|
|
80
|
-
objects: ["personal", "contact"],
|
|
81
|
-
required_level: "OPTIONAL",
|
|
82
|
-
scene_id: "user_profile",
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
category: "Demand Submission",
|
|
86
|
-
keywords_zh: ["demand", "publish", "inquiry"],
|
|
87
|
-
keywords_en: ["demand", "request", "inquiry"],
|
|
88
|
-
objects: ["demand"],
|
|
89
|
-
required_level: "OPTIONAL",
|
|
90
|
-
scene_id: "demand_inquiry",
|
|
91
|
-
},
|
|
92
|
-
];
|
|
93
|
-
const INDUSTRY_KEYWORDS = [
|
|
94
|
-
{ industry: "freelance", words: ["freelance", "outsourcing", "freelance", "gig"] },
|
|
95
|
-
{ industry: "rental", words: ["rental", "lease", "rental", "rent"] },
|
|
96
|
-
{ industry: "education", words: ["education", "course", "training", "education", "course"] },
|
|
97
|
-
{ industry: "travel", words: ["travel", "tour", "itinerary", "travel", "trip"] },
|
|
98
|
-
{ industry: "subscription", words: ["subscription", "cycle", "subscription", "recurring"] },
|
|
99
|
-
];
|
|
100
|
-
function buildPuzzleDispatch() {
|
|
101
|
-
const safeInit = (fn, input) => {
|
|
102
|
-
try {
|
|
103
|
-
return fn(input);
|
|
104
|
-
}
|
|
105
|
-
catch {
|
|
106
|
-
return undefined;
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
const safeCheck = (puzzle, fn) => {
|
|
110
|
-
if (!puzzle)
|
|
111
|
-
return { missing: [], complete: false, next_step: "init failed" };
|
|
112
|
-
try {
|
|
113
|
-
return fn(puzzle);
|
|
114
|
-
}
|
|
115
|
-
catch {
|
|
116
|
-
return { missing: [], complete: false, next_step: "check failed" };
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
return {
|
|
120
|
-
service: {
|
|
121
|
-
init: (intent) => safeInit(initServicePuzzleFromIntent, { primary_goal: intent }),
|
|
122
|
-
check: (p) => safeCheck(p, checkServicePuzzleCompleteness),
|
|
123
|
-
},
|
|
124
|
-
machine: {
|
|
125
|
-
init: (intent) => safeInit(initMachinePuzzleFromIntent, intent),
|
|
126
|
-
check: (p) => safeCheck(p, checkMachinePuzzleCompleteness),
|
|
127
|
-
},
|
|
128
|
-
allocation: {
|
|
129
|
-
init: (intent) => safeInit(initAllocationPuzzleFromIntent, { primary_goal: intent }),
|
|
130
|
-
check: (p) => safeCheck(p, checkAllocationPuzzleCompleteness),
|
|
131
|
-
},
|
|
132
|
-
treasury: {
|
|
133
|
-
init: (intent) => safeInit(initTreasuryPuzzleFromIntent, { primary_goal: intent }),
|
|
134
|
-
check: (p) => safeCheck(p, checkTreasuryPuzzleCompleteness),
|
|
135
|
-
},
|
|
136
|
-
arb: {
|
|
137
|
-
init: (intent) => safeInit(initArbitrationPuzzleFromIntent, { primary_goal: intent }),
|
|
138
|
-
check: (p) => safeCheck(p, checkArbitrationPuzzleCompleteness),
|
|
139
|
-
},
|
|
140
|
-
reward: {
|
|
141
|
-
init: (intent) => safeInit(initRewardPuzzleFromIntent, { primary_goal: intent }),
|
|
142
|
-
check: (p) => safeCheck(p, checkRewardPuzzleCompleteness),
|
|
143
|
-
},
|
|
144
|
-
progress: {
|
|
145
|
-
init: (intent) => safeInit(initProgressPuzzleFromIntent, { primary_goal: intent }),
|
|
146
|
-
check: (p) => safeCheck(p, checkProgressPuzzleCompleteness),
|
|
147
|
-
},
|
|
148
|
-
order: {
|
|
149
|
-
init: (intent) => safeInit(initOrderPuzzleFromIntent, { primary_goal: intent }),
|
|
150
|
-
check: (p) => safeCheck(p, checkOrderPuzzleCompleteness),
|
|
151
|
-
},
|
|
152
|
-
permission: {
|
|
153
|
-
init: (intent) => safeInit(initPermissionPuzzleFromIntent, { primary_goal: intent }),
|
|
154
|
-
check: (p) => safeCheck(p, checkPermissionPuzzleCompleteness),
|
|
155
|
-
},
|
|
156
|
-
guard: {
|
|
157
|
-
init: (intent) => safeInit(initGuardPuzzleFromIntent, { primary_goal: intent }),
|
|
158
|
-
check: (p) => safeCheck(p, checkGuardPuzzleCompleteness),
|
|
159
|
-
},
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
export function extractKeywords(business_intent) {
|
|
163
|
-
if (!business_intent || typeof business_intent !== "string")
|
|
164
|
-
return [];
|
|
165
|
-
const matches = [];
|
|
166
|
-
for (const entry of KEYWORD_TABLE) {
|
|
167
|
-
const allKeywords = [...entry.keywords_zh, ...entry.keywords_en];
|
|
168
|
-
for (const keyword of allKeywords) {
|
|
169
|
-
try {
|
|
170
|
-
const regex = new RegExp(escapeRegex(keyword), "gi");
|
|
171
|
-
const count = (business_intent.match(regex) || []).length;
|
|
172
|
-
if (count > 0) {
|
|
173
|
-
matches.push({
|
|
174
|
-
keyword,
|
|
175
|
-
category: entry.category,
|
|
176
|
-
matched_objects: [...entry.objects],
|
|
177
|
-
required_level: entry.required_level,
|
|
178
|
-
match_count: count,
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
catch {
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
matches.sort((a, b) => b.match_count - a.match_count);
|
|
187
|
-
return matches;
|
|
188
|
-
}
|
|
189
|
-
function escapeRegex(s) {
|
|
190
|
-
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
191
|
-
}
|
|
192
|
-
export function resolveIndustry(intent, hint) {
|
|
193
|
-
const text = `${intent ?? ""} ${hint ?? ""}`.toLowerCase();
|
|
194
|
-
for (const entry of INDUSTRY_KEYWORDS) {
|
|
195
|
-
for (const w of entry.words) {
|
|
196
|
-
if (text.includes(w.toLowerCase()))
|
|
197
|
-
return entry.industry;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
return "general";
|
|
201
|
-
}
|
|
202
|
-
export function identifyObjects(intent, matches) {
|
|
203
|
-
if (matches.length === 0) {
|
|
204
|
-
return {
|
|
205
|
-
primary: "service",
|
|
206
|
-
secondary: ["permission", "machine", "progress"],
|
|
207
|
-
scenes: [{ object: "service", scene_id: "general" }],
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
const firstR = matches.find((m) => m.required_level === "R");
|
|
211
|
-
const primary = (firstR ?? matches[0]).matched_objects[0];
|
|
212
|
-
const seen = new Set([primary]);
|
|
213
|
-
const secondary = [];
|
|
214
|
-
for (const m of matches) {
|
|
215
|
-
for (const obj of m.matched_objects) {
|
|
216
|
-
if (!seen.has(obj)) {
|
|
217
|
-
seen.add(obj);
|
|
218
|
-
secondary.push(obj);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
const scenes = [];
|
|
223
|
-
const sceneSeen = new Set();
|
|
224
|
-
for (const entry of KEYWORD_TABLE) {
|
|
225
|
-
const matched = matches.find((m) => m.category === entry.category);
|
|
226
|
-
if (!matched)
|
|
227
|
-
continue;
|
|
228
|
-
if (sceneSeen.has(entry.scene_id))
|
|
229
|
-
continue;
|
|
230
|
-
sceneSeen.add(entry.scene_id);
|
|
231
|
-
scenes.push({ object: entry.objects[0], scene_id: entry.scene_id });
|
|
232
|
-
}
|
|
233
|
-
return { primary, secondary, scenes };
|
|
234
|
-
}
|
|
235
|
-
export function analyzeBusinessIntent(input) {
|
|
236
|
-
const warnings = [];
|
|
237
|
-
if (!input || !input.user_intent || typeof input.user_intent !== "string") {
|
|
238
|
-
return {
|
|
239
|
-
intent_parsed: {
|
|
240
|
-
primary_object: "service",
|
|
241
|
-
secondary_objects: [],
|
|
242
|
-
detected_scenes: [],
|
|
243
|
-
industry: "general",
|
|
244
|
-
keyword_matches: [],
|
|
245
|
-
},
|
|
246
|
-
puzzles: {},
|
|
247
|
-
overall_completeness: "empty",
|
|
248
|
-
next_step: "Please provide a non-empty business intent.",
|
|
249
|
-
recommended_creation_order: [],
|
|
250
|
-
warnings: ["input.user_intent is empty"],
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
const intent = input.user_intent;
|
|
254
|
-
const matches = extractKeywords(intent);
|
|
255
|
-
const industry = resolveIndustry(intent, input.industry);
|
|
256
|
-
const { primary, secondary, scenes } = identifyObjects(intent, matches);
|
|
257
|
-
let targetObjects = [primary, ...secondary];
|
|
258
|
-
if (input.target_objects && input.target_objects.length > 0) {
|
|
259
|
-
const explicit = input.target_objects.filter((t) => [
|
|
260
|
-
"service", "machine", "guard", "permission", "reward", "arb",
|
|
261
|
-
"progress", "treasury", "demand", "repository", "contact", "order",
|
|
262
|
-
"allocation", "personal", "payment", "proof",
|
|
263
|
-
].includes(t));
|
|
264
|
-
if (explicit.length > 0)
|
|
265
|
-
targetObjects = explicit;
|
|
266
|
-
}
|
|
267
|
-
const dispatch = buildPuzzleDispatch();
|
|
268
|
-
const puzzles = {};
|
|
269
|
-
for (const objType of targetObjects) {
|
|
270
|
-
const d = dispatch[objType];
|
|
271
|
-
if (!d) {
|
|
272
|
-
warnings.push(`No puzzle module for '${objType}' — skipped (L3 object)`);
|
|
273
|
-
continue;
|
|
274
|
-
}
|
|
275
|
-
const puzzle = d.init(intent);
|
|
276
|
-
const completeness = puzzle ? d.check(puzzle) : undefined;
|
|
277
|
-
const missingDimensions = extractMissingDimensions(completeness);
|
|
278
|
-
puzzles[objType] = {
|
|
279
|
-
puzzle,
|
|
280
|
-
completeness,
|
|
281
|
-
missing_dimensions: missingDimensions,
|
|
282
|
-
};
|
|
283
|
-
if (!puzzle) {
|
|
284
|
-
warnings.push(`Puzzle init failed for '${objType}'`);
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
const overall = aggregatePuzzleCompleteness(puzzles);
|
|
288
|
-
const nextStep = suggestNextPuzzleStep({
|
|
289
|
-
intent_parsed: {
|
|
290
|
-
primary_object: primary,
|
|
291
|
-
secondary_objects: secondary,
|
|
292
|
-
detected_scenes: scenes,
|
|
293
|
-
industry,
|
|
294
|
-
keyword_matches: matches,
|
|
295
|
-
},
|
|
296
|
-
puzzles,
|
|
297
|
-
overall_completeness: overall,
|
|
298
|
-
next_step: "",
|
|
299
|
-
recommended_creation_order: [],
|
|
300
|
-
warnings,
|
|
301
|
-
});
|
|
302
|
-
const creationOrder = [
|
|
303
|
-
"permission",
|
|
304
|
-
"progress",
|
|
305
|
-
"guard",
|
|
306
|
-
"allocation",
|
|
307
|
-
"machine",
|
|
308
|
-
"service",
|
|
309
|
-
];
|
|
310
|
-
return {
|
|
311
|
-
intent_parsed: {
|
|
312
|
-
primary_object: primary,
|
|
313
|
-
secondary_objects: secondary,
|
|
314
|
-
detected_scenes: scenes,
|
|
315
|
-
industry,
|
|
316
|
-
keyword_matches: matches,
|
|
317
|
-
},
|
|
318
|
-
puzzles,
|
|
319
|
-
overall_completeness: overall,
|
|
320
|
-
next_step: nextStep,
|
|
321
|
-
recommended_creation_order: creationOrder,
|
|
322
|
-
warnings,
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
function extractMissingDimensions(completeness) {
|
|
326
|
-
if (!completeness || typeof completeness !== "object")
|
|
327
|
-
return [];
|
|
328
|
-
const c = completeness;
|
|
329
|
-
const missing = c.missing;
|
|
330
|
-
if (Array.isArray(missing)) {
|
|
331
|
-
return missing.map((m) => String(m));
|
|
332
|
-
}
|
|
333
|
-
const missingDetails = c.missing_details;
|
|
334
|
-
if (Array.isArray(missingDetails)) {
|
|
335
|
-
return missingDetails.map((m) => String(m?.dimension ?? m));
|
|
336
|
-
}
|
|
337
|
-
return [];
|
|
338
|
-
}
|
|
339
|
-
export function aggregatePuzzleCompleteness(puzzles) {
|
|
340
|
-
const entries = Object.values(puzzles ?? {});
|
|
341
|
-
if (entries.length === 0)
|
|
342
|
-
return "empty";
|
|
343
|
-
const emptyCount = entries.filter((e) => !e.puzzle).length;
|
|
344
|
-
if (emptyCount === entries.length)
|
|
345
|
-
return "empty";
|
|
346
|
-
const missingCount = entries.reduce((sum, e) => sum + (e.missing_dimensions?.length ?? 0), 0);
|
|
347
|
-
if (missingCount === 0)
|
|
348
|
-
return "complete";
|
|
349
|
-
return "partial";
|
|
350
|
-
}
|
|
351
|
-
export function suggestNextPuzzleStep(currentResult) {
|
|
352
|
-
if (!currentResult)
|
|
353
|
-
return "No result to suggest from.";
|
|
354
|
-
if (currentResult.overall_completeness === "complete") {
|
|
355
|
-
return "All puzzle dimensions are complete — ready for risk calibration (stage 3).";
|
|
356
|
-
}
|
|
357
|
-
if (currentResult.overall_completeness === "empty") {
|
|
358
|
-
return "No puzzle has been initialized. Provide more concrete business intent so the primary object can be identified.";
|
|
359
|
-
}
|
|
360
|
-
const order = [
|
|
361
|
-
"permission", "treasury", "allocation", "guard", "machine",
|
|
362
|
-
"service", "order", "progress", "arb", "reward",
|
|
363
|
-
"proof", "repository", "demand", "contact",
|
|
364
|
-
"personal", "payment",
|
|
365
|
-
];
|
|
366
|
-
const puzzles = currentResult.puzzles ?? {};
|
|
367
|
-
const ordered = order.filter((o) => puzzles[o]);
|
|
368
|
-
for (const objType of ordered) {
|
|
369
|
-
const entry = puzzles[objType];
|
|
370
|
-
if (!entry)
|
|
371
|
-
continue;
|
|
372
|
-
const missing = entry.missing_dimensions ?? [];
|
|
373
|
-
if (missing.length === 0)
|
|
374
|
-
continue;
|
|
375
|
-
const c = entry.completeness;
|
|
376
|
-
const innerNext = c && typeof c === "object" ? c.next_step : undefined;
|
|
377
|
-
if (typeof innerNext === "string" && innerNext.trim()) {
|
|
378
|
-
return `[${objType}] ${innerNext}`;
|
|
379
|
-
}
|
|
380
|
-
return `[${objType}] Complete dimension${missing.length > 1 ? "s" : ""} ${missing.join(", ")} to advance the puzzle.`;
|
|
381
|
-
}
|
|
382
|
-
return "Continue dialog to fill remaining pending fields.";
|
|
383
|
-
}
|
|
1
|
+
import{initServicePuzzleFromIntent,initMachinePuzzleFromIntent,initAllocationPuzzleFromIntent,initTreasuryPuzzleFromIntent,initArbitrationPuzzleFromIntent,initRewardPuzzleFromIntent,initProgressPuzzleFromIntent,initOrderPuzzleFromIntent,initPuzzleFromIntent as a210a,checkServicePuzzleCompleteness,checkMachinePuzzleCompleteness,checkAllocationPuzzleCompleteness,checkTreasuryPuzzleCompleteness,checkArbitrationPuzzleCompleteness,checkRewardPuzzleCompleteness,checkProgressPuzzleCompleteness,checkOrderPuzzleCompleteness,checkPuzzleCompleteness as a210b}from'../knowledge/index.js';import{initPuzzleFromIntent as a210c,checkPuzzleCompleteness as a210d}from'../knowledge/permission-puzzle.js';const KEYWORD_TABLE=[{'category':'Product/Service','keywords_zh':['product','selling','sell','sales','store','open\x20shop'],'keywords_en':['sell','product','sale','shop','store'],'objects':['service','order','progress'],'required_level':'R','scene_id':'retail'},{'category':'Subscription','keywords_zh':['subscription','cycle','renewal'],'keywords_en':['subscribe','recurring','subscription'],'objects':['service','machine','reward'],'required_level':'C','scene_id':'subscription'},{'category':'Rental','keywords_zh':['rent','lease','return'],'keywords_en':['rent','lease','return'],'objects':['service','machine','arb'],'required_level':'C','scene_id':'rental_return'},{'category':'Trust','keywords_zh':['deposit','pledge','verify','trust'],'keywords_en':['deposit','trust','verify'],'objects':['guard','permission','treasury'],'required_level':'R','scene_id':'trust_deposit'},{'category':'Funds','keywords_zh':['split','collect','share\x20profit','income','incentive'],'keywords_en':['split','revenue','reward'],'objects':['allocation','treasury','reward'],'required_level':'R','scene_id':'revenue_split'},{'category':'Workflow','keywords_zh':['node','stage','process','workflow'],'keywords_en':['workflow','stage','node'],'objects':['machine','progress'],'required_level':'R','scene_id':'workflow'},{'category':'Dispute','keywords_zh':['arbitration','refund','conflict','rights\x20protection'],'keywords_en':['arbitration','refund','dispute'],'objects':['arb','proof'],'required_level':'C','scene_id':'arbitration_dispute'},{'category':'Contact','keywords_zh':['customer\x20service','contact','communication'],'keywords_en':['contact','support','im'],'objects':['contact'],'required_level':'C','scene_id':'contact_im'},{'category':'Data','keywords_zh':['evidence','record','data'],'keywords_en':['evidence','record','data'],'objects':['repository','proof'],'required_level':'C','scene_id':'evidence_record'},{'category':'User\x20Profile','keywords_zh':['personal\x20info','preference','privacy'],'keywords_en':['personal','profile','privacy'],'objects':['personal','contact'],'required_level':'OPTIONAL','scene_id':'user_profile'},{'category':'Demand\x20Submission','keywords_zh':['demand','publish','inquiry'],'keywords_en':['demand','request','inquiry'],'objects':['demand'],'required_level':'OPTIONAL','scene_id':'demand_inquiry'}],INDUSTRY_KEYWORDS=[{'industry':'freelance','words':['freelance','outsourcing','freelance','gig']},{'industry':'rental','words':['rental','lease','rental','rent']},{'industry':'education','words':['education','course','training','education','course']},{'industry':'travel','words':['travel','tour','itinerary','travel','trip']},{'industry':'subscription','words':['subscription','cycle','subscription','recurring']}];function buildPuzzleDispatch(){const a=(c,d)=>{try{return c(d);}catch{return undefined;}},b=(c,d)=>{if(!c)return{'missing':[],'complete':![],'next_step':'init\x20failed'};try{return d(c);}catch{return{'missing':[],'complete':![],'next_step':'check\x20failed'};}};return{'service':{'init':c=>a(initServicePuzzleFromIntent,{'primary_goal':c}),'check':c=>b(c,checkServicePuzzleCompleteness)},'machine':{'init':c=>a(initMachinePuzzleFromIntent,c),'check':c=>b(c,checkMachinePuzzleCompleteness)},'allocation':{'init':c=>a(initAllocationPuzzleFromIntent,{'primary_goal':c}),'check':c=>b(c,checkAllocationPuzzleCompleteness)},'treasury':{'init':c=>a(initTreasuryPuzzleFromIntent,{'primary_goal':c}),'check':c=>b(c,checkTreasuryPuzzleCompleteness)},'arb':{'init':c=>a(initArbitrationPuzzleFromIntent,{'primary_goal':c}),'check':c=>b(c,checkArbitrationPuzzleCompleteness)},'reward':{'init':c=>a(initRewardPuzzleFromIntent,{'primary_goal':c}),'check':c=>b(c,checkRewardPuzzleCompleteness)},'progress':{'init':c=>a(initProgressPuzzleFromIntent,{'primary_goal':c}),'check':c=>b(c,checkProgressPuzzleCompleteness)},'order':{'init':c=>a(initOrderPuzzleFromIntent,{'primary_goal':c}),'check':c=>b(c,checkOrderPuzzleCompleteness)},'permission':{'init':c=>a(a210c,{'primary_goal':c}),'check':c=>b(c,a210d)},'guard':{'init':c=>a(a210a,{'primary_goal':c}),'check':c=>b(c,a210b)}};}export function extractKeywords(a){if(!a||typeof a!=='string')return[];const b=[];for(const c of KEYWORD_TABLE){const d=[...c['keywords_zh'],...c['keywords_en']];for(const e of d){try{const f=new RegExp(escapeRegex(e),'gi'),g=(a['match'](f)||[])['length'];g>0x0&&b['push']({'keyword':e,'category':c['category'],'matched_objects':[...c['objects']],'required_level':c['required_level'],'match_count':g});}catch{}}}return b['sort']((h,i)=>i['match_count']-h['match_count']),b;}function escapeRegex(a){return a['replace'](/[.*+?^${}()|[\]\\]/g,'\x5c$&');}export function resolveIndustry(a,b){const c=((a??'')+'\x20'+(b??''))['toLowerCase']();for(const d of INDUSTRY_KEYWORDS){for(const e of d['words']){if(c['includes'](e['toLowerCase']()))return d['industry'];}}return'general';}export function identifyObjects(a,b){if(b['length']===0x0)return{'primary':'service','secondary':['permission','machine','progress'],'scenes':[{'object':'service','scene_id':'general'}]};const c=b['find'](i=>i['required_level']==='R'),d=(c??b[0x0])['matched_objects'][0x0],e=new Set([d]),f=[];for(const i of b){for(const j of i['matched_objects']){!e['has'](j)&&(e['add'](j),f['push'](j));}}const g=[],h=new Set();for(const k of KEYWORD_TABLE){const l=b['find'](n=>n['category']===k['category']);if(!l)continue;if(h['has'](k['scene_id']))continue;h['add'](k['scene_id']),g['push']({'object':k['objects'][0x0],'scene_id':k['scene_id']});}return{'primary':d,'secondary':f,'scenes':g};}export function analyzeBusinessIntent(a){const b=[];if(!a||!a['user_intent']||typeof a['user_intent']!=='string')return{'intent_parsed':{'primary_object':'service','secondary_objects':[],'detected_scenes':[],'industry':'general','keyword_matches':[]},'puzzles':{},'overall_completeness':'empty','next_step':'Please\x20provide\x20a\x20non-empty\x20business\x20intent.','recommended_creation_order':[],'warnings':['input.user_intent\x20is\x20empty']};const c=a['user_intent'],e=extractKeywords(c),f=resolveIndustry(c,a['industry']),{primary:g,secondary:h,scenes:i}=identifyObjects(c,e);let j=[g,...h];if(a['target_objects']&&a['target_objects']['length']>0x0){const p=a['target_objects']['filter'](q=>['service','machine','guard','permission','reward','arb','progress','treasury','demand','repository','contact','order','allocation','personal','payment','proof']['includes'](q));if(p['length']>0x0)j=p;}const k=buildPuzzleDispatch(),l={};for(const q of j){const r=k[q];if(!r){b['push']('No\x20puzzle\x20module\x20for\x20\x27'+q+'\x27\x20—\x20skipped\x20(L3\x20object)');continue;}const s=r['init'](c),t=s?r['check'](s):undefined,u=extractMissingDimensions(t);l[q]={'puzzle':s,'completeness':t,'missing_dimensions':u},!s&&b['push']('Puzzle\x20init\x20failed\x20for\x20\x27'+q+'\x27');}const m=aggregatePuzzleCompleteness(l),n=suggestNextPuzzleStep({'intent_parsed':{'primary_object':g,'secondary_objects':h,'detected_scenes':i,'industry':f,'keyword_matches':e},'puzzles':l,'overall_completeness':m,'next_step':'','recommended_creation_order':[],'warnings':b}),o=['permission','progress','guard','allocation','machine','service'];return{'intent_parsed':{'primary_object':g,'secondary_objects':h,'detected_scenes':i,'industry':f,'keyword_matches':e},'puzzles':l,'overall_completeness':m,'next_step':n,'recommended_creation_order':o,'warnings':b};}function extractMissingDimensions(a){if(!a||typeof a!=='object')return[];const b=a,d=b['missing'];if(Array['isArray'](d))return d['map'](f=>String(f));const e=b['missing_details'];if(Array['isArray'](e))return e['map'](f=>String(f?.['dimension']??f));return[];}export function aggregatePuzzleCompleteness(a){const b=Object['values'](a??{});if(b['length']===0x0)return'empty';const c=b['filter'](f=>!f['puzzle'])['length'];if(c===b['length'])return'empty';const d=b['reduce']((f,g)=>f+(g['missing_dimensions']?.['length']??0x0),0x0);if(d===0x0)return'complete';return'partial';}export function suggestNextPuzzleStep(a){if(!a)return'No\x20result\x20to\x20suggest\x20from.';if(a['overall_completeness']==='complete')return'All\x20puzzle\x20dimensions\x20are\x20complete\x20—\x20ready\x20for\x20risk\x20calibration\x20(stage\x203).';if(a['overall_completeness']==='empty')return'No\x20puzzle\x20has\x20been\x20initialized.\x20Provide\x20more\x20concrete\x20business\x20intent\x20so\x20the\x20primary\x20object\x20can\x20be\x20identified.';const b=['permission','treasury','allocation','guard','machine','service','order','progress','arb','reward','proof','repository','demand','contact','personal','payment'],d=a['puzzles']??{},e=b['filter'](f=>d[f]);for(const f of e){const g=d[f];if(!g)continue;const h=g['missing_dimensions']??[];if(h['length']===0x0)continue;const i=g['completeness'],j=i&&typeof i==='object'?i['next_step']:undefined;if(typeof j==='string'&&j['trim']())return'['+f+']\x20'+j;return'['+f+']\x20Complete\x20dimension'+(h['length']>0x1?'s':'')+'\x20'+h['join'](',\x20')+'\x20to\x20advance\x20the\x20puzzle.';}return'Continue\x20dialog\x20to\x20fill\x20remaining\x20pending\x20fields.';}
|