@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,403 +1 @@
|
|
|
1
|
-
import { MAX_SALE_COUNT, MAX_REPOSITORY_COUNT, MAX_ARBITRATION_COUNT, MAX_DISCOUNT_COUNT_ONCE, MAX_DISCOUNT_TOTAL_COUNT, MAX_WIP_LENGTH, MAX_WIP_HASH_LENGTH, DEFAULT_LOCK_DURATION, } from "@wowok/wowok";
|
|
2
|
-
import { findSceneById, inferSceneFromIntent, getScenesByCategory, isServicePermission, SERVICE_PERMISSIONS, SERVICE_ORDER_FLOW_STAGES, SERVICE_CROSS_OBJECT_BINDINGS, } from "./service-ledger.js";
|
|
3
|
-
import { getServiceTemplatesByScene, } from "./service-templates.js";
|
|
4
|
-
import { matchSemanticPattern, } from "./service-translation.js";
|
|
5
|
-
import { getAllServiceRiskRules, assessServiceRisks, } from "./service-risk.js";
|
|
6
|
-
import { initPuzzleFromIntent, checkPuzzleCompleteness, } from "./service-puzzle.js";
|
|
7
|
-
import { SERVICE_PUBLISH_CHECKLIST, SERVICE_CONFIRMATION_QUESTIONS, } from "./service-confirm.js";
|
|
8
|
-
export const SERVICE_CONTEXT_VERSION = "1.0.0";
|
|
9
|
-
export function buildServiceContext(input) {
|
|
10
|
-
const max_length = input.max_length ?? 6000;
|
|
11
|
-
let matched_scene;
|
|
12
|
-
if (input.intent) {
|
|
13
|
-
matched_scene = inferSceneFromIntent(input.intent);
|
|
14
|
-
}
|
|
15
|
-
if (!matched_scene && input.target_scene_id) {
|
|
16
|
-
matched_scene = findSceneById(input.target_scene_id);
|
|
17
|
-
}
|
|
18
|
-
if (!matched_scene && input.target_category) {
|
|
19
|
-
const scenes = getScenesByCategory(input.target_category);
|
|
20
|
-
if (scenes.length > 0)
|
|
21
|
-
matched_scene = scenes[0];
|
|
22
|
-
}
|
|
23
|
-
if (!matched_scene && input.target_permission_index !== undefined && isServicePermission(input.target_permission_index)) {
|
|
24
|
-
matched_scene = findSceneById("service_retail");
|
|
25
|
-
}
|
|
26
|
-
let matched_template;
|
|
27
|
-
if (matched_scene) {
|
|
28
|
-
const templates = getServiceTemplatesByScene(matched_scene.id);
|
|
29
|
-
if (templates.length > 0)
|
|
30
|
-
matched_template = templates[0];
|
|
31
|
-
}
|
|
32
|
-
let matched_pattern;
|
|
33
|
-
if (input.intent) {
|
|
34
|
-
const patterns = matchSemanticPattern(input.intent);
|
|
35
|
-
if (patterns.length > 0)
|
|
36
|
-
matched_pattern = patterns[0];
|
|
37
|
-
}
|
|
38
|
-
let puzzle_state;
|
|
39
|
-
let puzzle_completeness;
|
|
40
|
-
if (input.mode === "initial_design" && input.intent) {
|
|
41
|
-
puzzle_state = initPuzzleFromIntent({ primary_goal: input.intent });
|
|
42
|
-
puzzle_completeness = checkPuzzleCompleteness(puzzle_state);
|
|
43
|
-
}
|
|
44
|
-
const relevant_risks = filterRiskRules(input.mode, input.stakeholder, matched_scene);
|
|
45
|
-
let risk_assessment;
|
|
46
|
-
if ((input.mode === "pre_publish" || input.mode === "post_publish_modify" || input.mode === "order_flow_check") && input.service_json) {
|
|
47
|
-
const ctx = {
|
|
48
|
-
object: input.service_json.object,
|
|
49
|
-
description: input.service_json.description,
|
|
50
|
-
location: input.service_json.location,
|
|
51
|
-
sales: input.service_json.sales,
|
|
52
|
-
repositories: input.service_json.repositories,
|
|
53
|
-
rewards: input.service_json.rewards,
|
|
54
|
-
arbitrations: input.service_json.arbitrations,
|
|
55
|
-
machine: input.service_json.machine,
|
|
56
|
-
discount: input.service_json.discount,
|
|
57
|
-
customer_required: input.service_json.customer_required,
|
|
58
|
-
order_allocators: input.service_json.order_allocators,
|
|
59
|
-
buy_guard: input.service_json.buy_guard,
|
|
60
|
-
compensation_fund_add: input.service_json.compensation_fund_add,
|
|
61
|
-
setting_lock_duration_add: input.service_json.setting_lock_duration_add,
|
|
62
|
-
compensation_fund_receive: input.service_json.compensation_fund_receive,
|
|
63
|
-
owner_receive: input.service_json.owner_receive,
|
|
64
|
-
pause: input.service_json.pause,
|
|
65
|
-
publish: input.service_json.publish,
|
|
66
|
-
um: input.service_json.um,
|
|
67
|
-
order_new: input.service_json.order_new,
|
|
68
|
-
current_bPublished: input.current_bPublished,
|
|
69
|
-
current_bPaused: input.current_bPaused,
|
|
70
|
-
current_machine_bound: input.current_bPublished,
|
|
71
|
-
};
|
|
72
|
-
risk_assessment = assessServiceRisks(ctx);
|
|
73
|
-
}
|
|
74
|
-
const relevant_checklist = filterChecklist(input.mode);
|
|
75
|
-
const relevant_questions = filterQuestions(input.mode);
|
|
76
|
-
const relevant_builtin_permissions = matched_scene
|
|
77
|
-
? matched_scene.builtin_indexes
|
|
78
|
-
: [...SERVICE_PERMISSIONS];
|
|
79
|
-
const relevant_order_flow_stages = input.mode === "order_flow_check"
|
|
80
|
-
? [...SERVICE_ORDER_FLOW_STAGES]
|
|
81
|
-
: [];
|
|
82
|
-
const cross_object_bindings = [...SERVICE_CROSS_OBJECT_BINDINGS];
|
|
83
|
-
const cross_object_refs = buildCrossObjectRefs(matched_scene);
|
|
84
|
-
const onchain_constraints = buildOnchainConstraints();
|
|
85
|
-
const rendering_hints = buildRenderingHints(input.mode, max_length, !!input.service_json?.publish, !!input.service_json?.builder, !!input.service_json?.order_new, input.current_bPublished ?? false);
|
|
86
|
-
return {
|
|
87
|
-
version: SERVICE_CONTEXT_VERSION,
|
|
88
|
-
mode: input.mode,
|
|
89
|
-
stakeholder_perspective: input.stakeholder,
|
|
90
|
-
matched_scene,
|
|
91
|
-
matched_template,
|
|
92
|
-
matched_pattern,
|
|
93
|
-
puzzle_state,
|
|
94
|
-
puzzle_completeness,
|
|
95
|
-
relevant_risks,
|
|
96
|
-
risk_assessment,
|
|
97
|
-
relevant_checklist,
|
|
98
|
-
relevant_questions,
|
|
99
|
-
relevant_builtin_permissions,
|
|
100
|
-
relevant_order_flow_stages,
|
|
101
|
-
cross_object_bindings,
|
|
102
|
-
cross_object_refs,
|
|
103
|
-
onchain_constraints,
|
|
104
|
-
rendering_hints,
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
function filterRiskRules(mode, stakeholder, scene) {
|
|
108
|
-
let rules = getAllServiceRiskRules();
|
|
109
|
-
if (mode === "initial_design") {
|
|
110
|
-
return rules.filter(r => r.category === "structural" || r.category === "authority");
|
|
111
|
-
}
|
|
112
|
-
if (mode === "pre_publish") {
|
|
113
|
-
return rules;
|
|
114
|
-
}
|
|
115
|
-
if (mode === "post_publish_modify") {
|
|
116
|
-
return rules.filter(r => r.category === "lifecycle" || r.category === "cross_object");
|
|
117
|
-
}
|
|
118
|
-
if (mode === "order_flow_check") {
|
|
119
|
-
return rules.filter(r => r.category === "semantic" || r.id.startsWith("R-S-2"));
|
|
120
|
-
}
|
|
121
|
-
if (mode === "stakeholder_review" && stakeholder) {
|
|
122
|
-
if (stakeholder === "owner") {
|
|
123
|
-
return rules.filter(r => r.category === "authority" || r.category === "lifecycle");
|
|
124
|
-
}
|
|
125
|
-
if (stakeholder === "customer") {
|
|
126
|
-
return rules.filter(r => r.category === "semantic" || r.id.startsWith("R-S-2"));
|
|
127
|
-
}
|
|
128
|
-
if (stakeholder === "provider") {
|
|
129
|
-
return rules.filter(r => r.category === "cross_object" || r.id.startsWith("R-S-5-01"));
|
|
130
|
-
}
|
|
131
|
-
if (stakeholder === "arbitrator") {
|
|
132
|
-
return rules.filter(r => r.id.startsWith("R-S-5-02") || r.id.startsWith("R-S-2-02"));
|
|
133
|
-
}
|
|
134
|
-
if (stakeholder === "system") {
|
|
135
|
-
return rules.filter(r => r.category === "lifecycle");
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return rules;
|
|
139
|
-
}
|
|
140
|
-
function filterChecklist(mode) {
|
|
141
|
-
if (mode === "initial_design") {
|
|
142
|
-
return SERVICE_PUBLISH_CHECKLIST.filter(i => ["C-S-01", "C-S-02", "C-S-03", "C-S-04", "C-S-05", "C-S-06", "C-S-07"].includes(i.id));
|
|
143
|
-
}
|
|
144
|
-
if (mode === "pre_publish") {
|
|
145
|
-
return SERVICE_PUBLISH_CHECKLIST;
|
|
146
|
-
}
|
|
147
|
-
if (mode === "post_publish_modify") {
|
|
148
|
-
return SERVICE_PUBLISH_CHECKLIST.filter(i => ["C-S-12", "C-S-13", "C-S-14", "C-S-15", "C-S-16"].includes(i.id));
|
|
149
|
-
}
|
|
150
|
-
if (mode === "order_flow_check") {
|
|
151
|
-
return SERVICE_PUBLISH_CHECKLIST.filter(i => ["C-S-07"].includes(i.id));
|
|
152
|
-
}
|
|
153
|
-
return SERVICE_PUBLISH_CHECKLIST;
|
|
154
|
-
}
|
|
155
|
-
function filterQuestions(mode) {
|
|
156
|
-
if (mode === "pre_publish") {
|
|
157
|
-
return SERVICE_CONFIRMATION_QUESTIONS;
|
|
158
|
-
}
|
|
159
|
-
if (mode === "post_publish_modify") {
|
|
160
|
-
return SERVICE_CONFIRMATION_QUESTIONS.filter(q => !["QS1", "QS2", "QS5"].includes(q.id));
|
|
161
|
-
}
|
|
162
|
-
if (mode === "order_flow_check") {
|
|
163
|
-
return SERVICE_CONFIRMATION_QUESTIONS.filter(q => q.id === "QS9");
|
|
164
|
-
}
|
|
165
|
-
return [];
|
|
166
|
-
}
|
|
167
|
-
function buildCrossObjectRefs(scene) {
|
|
168
|
-
return [
|
|
169
|
-
{
|
|
170
|
-
object: "Machine",
|
|
171
|
-
field: "machine",
|
|
172
|
-
scene_id: "service_workflow",
|
|
173
|
-
description: "Machine workflow template — post-publish immutable. Progress inherits this binding.",
|
|
174
|
-
locked_after_publish: true,
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
object: "Allocation",
|
|
178
|
-
field: "order_allocators",
|
|
179
|
-
scene_id: "service_order_allocator",
|
|
180
|
-
description: "Fund distribution strategy — publish prerequisite, post-publish immutable.",
|
|
181
|
-
locked_after_publish: true,
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
object: "Arbitration",
|
|
185
|
-
field: "arbitrations",
|
|
186
|
-
scene_id: "service_arbitration",
|
|
187
|
-
description: "Dispute handlers — required when compensation_fund > 0, post-publish immutable.",
|
|
188
|
-
locked_after_publish: true,
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
object: "Repository",
|
|
192
|
-
field: "repositories",
|
|
193
|
-
scene_id: "service_retail",
|
|
194
|
-
description: "Shared data stores — mutable post-publish.",
|
|
195
|
-
locked_after_publish: false,
|
|
196
|
-
},
|
|
197
|
-
{
|
|
198
|
-
object: "Reward",
|
|
199
|
-
field: "rewards",
|
|
200
|
-
scene_id: "service_reward",
|
|
201
|
-
description: "Marketing incentives — mutable but locked by setting_lock_duration.",
|
|
202
|
-
locked_after_publish: false,
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
object: "Guard",
|
|
206
|
-
field: "buy_guard",
|
|
207
|
-
scene_id: "service_buy_guard",
|
|
208
|
-
description: "Buyer eligibility Guard — UNUSUAL: still mutable post-publish.",
|
|
209
|
-
locked_after_publish: false,
|
|
210
|
-
},
|
|
211
|
-
{
|
|
212
|
-
object: "Contact",
|
|
213
|
-
field: "um",
|
|
214
|
-
scene_id: "service_retail",
|
|
215
|
-
description: "User Manager (Contact object) — mutable post-publish.",
|
|
216
|
-
locked_after_publish: false,
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
object: "Treasury",
|
|
220
|
-
field: "(indirect via order_allocators.sharing.who=Entity)",
|
|
221
|
-
scene_id: "service_multi_allocator",
|
|
222
|
-
description: "Treasury referenced by Allocation.sharing.who=Entity (Treasury address). Not directly bound to Service.",
|
|
223
|
-
locked_after_publish: false,
|
|
224
|
-
},
|
|
225
|
-
{
|
|
226
|
-
object: "Progress",
|
|
227
|
-
field: "(created at order time)",
|
|
228
|
-
scene_id: "service_workflow",
|
|
229
|
-
description: "Progress object created per order (Stage 6 of buy flow). Inherits Machine from Service.",
|
|
230
|
-
locked_after_publish: false,
|
|
231
|
-
},
|
|
232
|
-
{
|
|
233
|
-
object: "Permission",
|
|
234
|
-
field: "permission",
|
|
235
|
-
scene_id: "service_retail",
|
|
236
|
-
description: "Permission object governing 21 SERVICE_* indexes (300-320). Bound at Service creation, immutable.",
|
|
237
|
-
locked_after_publish: true,
|
|
238
|
-
},
|
|
239
|
-
];
|
|
240
|
-
}
|
|
241
|
-
function buildOnchainConstraints() {
|
|
242
|
-
return [
|
|
243
|
-
{ name: "MAX_SALE_COUNT", value: MAX_SALE_COUNT, description: "Maximum sales items per Service" },
|
|
244
|
-
{ name: "MAX_REPOSITORY_COUNT", value: MAX_REPOSITORY_COUNT, description: "Maximum repositories per Service" },
|
|
245
|
-
{ name: "MAX_ARBITRATION_COUNT", value: MAX_ARBITRATION_COUNT, description: "Maximum arbitrations per Service" },
|
|
246
|
-
{ name: "MAX_REWARD_COUNT", value: 20, description: "Maximum rewards per Service" },
|
|
247
|
-
{ name: "MAX_DISCOUNT_COUNT_ONCE", value: MAX_DISCOUNT_COUNT_ONCE, description: "Maximum discount coupons per issue call" },
|
|
248
|
-
{ name: "MAX_DISCOUNT_TOTAL_COUNT", value: MAX_DISCOUNT_TOTAL_COUNT, description: "Maximum total discount coupons per Service" },
|
|
249
|
-
{ name: "MAX_WIP_LENGTH", value: MAX_WIP_LENGTH, description: "Maximum WIP URL length" },
|
|
250
|
-
{ name: "MAX_WIP_HASH_LENGTH", value: MAX_WIP_HASH_LENGTH, description: "Maximum WIP hash length (sha256 hex)" },
|
|
251
|
-
{ name: "DEFAULT_LOCK_DURATION", value: DEFAULT_LOCK_DURATION, description: "Default setting_lock_duration (30 days in ms)" },
|
|
252
|
-
];
|
|
253
|
-
}
|
|
254
|
-
function buildRenderingHints(mode, max_length, hasPublish, hasTransfer, hasOrder, isPublished) {
|
|
255
|
-
return {
|
|
256
|
-
include_puzzle_template: mode === "initial_design",
|
|
257
|
-
include_risk_details: mode === "pre_publish" || mode === "stakeholder_review" || mode === "order_flow_check",
|
|
258
|
-
include_questions: mode === "pre_publish" || mode === "order_flow_check",
|
|
259
|
-
include_publish_warning: hasPublish,
|
|
260
|
-
include_transfer_warning: hasTransfer,
|
|
261
|
-
include_order_flow_warning: hasOrder,
|
|
262
|
-
include_immutability_matrix: mode === "post_publish_modify" || mode === "pre_publish" || isPublished,
|
|
263
|
-
max_length,
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
export function buildPromptFromServiceContext(bundle) {
|
|
267
|
-
const lines = [];
|
|
268
|
-
const h = bundle.rendering_hints;
|
|
269
|
-
lines.push(`═══ Service Context (mode: ${bundle.mode}) ═══`);
|
|
270
|
-
lines.push("");
|
|
271
|
-
if (bundle.matched_scene) {
|
|
272
|
-
lines.push(`Scene: ${bundle.matched_scene.name}`);
|
|
273
|
-
lines.push(`Category: ${bundle.matched_scene.category}`);
|
|
274
|
-
lines.push(`Permission range: ${bundle.matched_scene.permission_index_range}`);
|
|
275
|
-
lines.push("");
|
|
276
|
-
}
|
|
277
|
-
if (bundle.matched_template) {
|
|
278
|
-
lines.push(`Suggested template: ${bundle.matched_template.id} — ${bundle.matched_template.name}`);
|
|
279
|
-
if (bundle.matched_template.notes && bundle.matched_template.notes.length > 0) {
|
|
280
|
-
lines.push("Notes:");
|
|
281
|
-
for (const note of bundle.matched_template.notes.slice(0, 3)) {
|
|
282
|
-
lines.push(` - ${note}`);
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
lines.push("");
|
|
286
|
-
}
|
|
287
|
-
if (h.include_puzzle_template && bundle.puzzle_completeness) {
|
|
288
|
-
const c = bundle.puzzle_completeness;
|
|
289
|
-
lines.push("─ Puzzle Completeness ──────────────");
|
|
290
|
-
lines.push(`Complete: ${c.complete ? "YES" : "NO"}`);
|
|
291
|
-
if (c.missing.length > 0) {
|
|
292
|
-
lines.push(`Missing dimensions: ${c.missing.join(", ")}`);
|
|
293
|
-
for (const md of c.missing_details.slice(0, 3)) {
|
|
294
|
-
lines.push(` - ${md.dimension}: ${md.reason}`);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
lines.push(`Next: ${c.next_step}`);
|
|
298
|
-
lines.push("");
|
|
299
|
-
}
|
|
300
|
-
if (h.include_risk_details && bundle.relevant_risks.length > 0) {
|
|
301
|
-
lines.push(`─ Relevant Risk Rules (${bundle.relevant_risks.length}) ──────────────`);
|
|
302
|
-
for (const r of bundle.relevant_risks.slice(0, 8)) {
|
|
303
|
-
lines.push(` ${r.id} [${r.category}] — ${r.trigger}`);
|
|
304
|
-
}
|
|
305
|
-
if (bundle.relevant_risks.length > 8) {
|
|
306
|
-
lines.push(` ... and ${bundle.relevant_risks.length - 8} more`);
|
|
307
|
-
}
|
|
308
|
-
lines.push("");
|
|
309
|
-
}
|
|
310
|
-
if (bundle.risk_assessment) {
|
|
311
|
-
lines.push("─ Risk Assessment ──────────────");
|
|
312
|
-
lines.push(`Overall: ${bundle.risk_assessment.overall_risk}`);
|
|
313
|
-
lines.push(`Detected: ${bundle.risk_assessment.risks.length} risk(s)`);
|
|
314
|
-
if (bundle.risk_assessment.risks.length > 0) {
|
|
315
|
-
for (const r of bundle.risk_assessment.risks.slice(0, 5)) {
|
|
316
|
-
lines.push(` [${r.level}] ${r.id}: ${r.title}`);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
lines.push("");
|
|
320
|
-
}
|
|
321
|
-
if (bundle.relevant_builtin_permissions.length > 0) {
|
|
322
|
-
lines.push(`─ Builtin Permissions (${bundle.relevant_builtin_permissions.length}) ──────────────`);
|
|
323
|
-
for (const p of bundle.relevant_builtin_permissions.slice(0, 10)) {
|
|
324
|
-
const mut = p.post_publish_mutability === "immutable" ? " [IMMUTABLE]"
|
|
325
|
-
: p.post_publish_mutability === "one_shot" ? " [ONE-SHOT]"
|
|
326
|
-
: p.post_publish_mutability === "locked_by_duration" ? " [LOCKED]"
|
|
327
|
-
: "";
|
|
328
|
-
lines.push(` [${p.index}] ${p.name}: ${p.description}${mut}`);
|
|
329
|
-
}
|
|
330
|
-
if (bundle.relevant_builtin_permissions.length > 10) {
|
|
331
|
-
lines.push(` ... and ${bundle.relevant_builtin_permissions.length - 10} more`);
|
|
332
|
-
}
|
|
333
|
-
lines.push("");
|
|
334
|
-
}
|
|
335
|
-
if (bundle.relevant_order_flow_stages.length > 0) {
|
|
336
|
-
lines.push("─ 8-Stage Order Flow ──────────────");
|
|
337
|
-
for (const stage of bundle.relevant_order_flow_stages) {
|
|
338
|
-
lines.push(` Stage ${stage.stage}: ${stage.name} ${stage.always_executed ? "(always)" : "(conditional)"}`);
|
|
339
|
-
if (stage.side_effects.length > 0) {
|
|
340
|
-
lines.push(` Side effects: ${stage.side_effects[0]}`);
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
lines.push("");
|
|
344
|
-
}
|
|
345
|
-
if (h.include_publish_warning) {
|
|
346
|
-
lines.push("⚠️ PUBLISH OPERATION DETECTED — IRREVERSIBLE");
|
|
347
|
-
lines.push(" Once published: machine/arbitrations/order_allocators become PERMANENTLY immutable");
|
|
348
|
-
lines.push(" bPublished cannot be reset to false — clone Service to 'reset'");
|
|
349
|
-
lines.push("");
|
|
350
|
-
}
|
|
351
|
-
if (h.include_transfer_warning) {
|
|
352
|
-
lines.push("⚠️ TRANSFER OPERATION DETECTED — IRREVERSIBLE");
|
|
353
|
-
lines.push(" Original owner loses ALL control. New owner inherits everything.");
|
|
354
|
-
lines.push("");
|
|
355
|
-
}
|
|
356
|
-
if (h.include_order_flow_warning) {
|
|
357
|
-
lines.push("⚠️ ORDER FLOW — 8 STAGES, stock deducted at quote (Stage 3)");
|
|
358
|
-
lines.push(" If Stages 4-7 fail, stock remains deducted (not rolled back)");
|
|
359
|
-
lines.push("");
|
|
360
|
-
}
|
|
361
|
-
if (h.include_immutability_matrix && bundle.cross_object_bindings.length > 0) {
|
|
362
|
-
lines.push("─ Post-publish Immutability Matrix ──────────────");
|
|
363
|
-
for (const b of bundle.cross_object_bindings) {
|
|
364
|
-
const status = b.locked_after_publish ? "🔒 IMMUTABLE" : "🔓 mutable";
|
|
365
|
-
lines.push(` ${b.object} (${b.field}): ${status}`);
|
|
366
|
-
}
|
|
367
|
-
lines.push("");
|
|
368
|
-
}
|
|
369
|
-
if (bundle.onchain_constraints.length > 0) {
|
|
370
|
-
lines.push("─ On-chain Constraints ──────────────");
|
|
371
|
-
for (const c of bundle.onchain_constraints) {
|
|
372
|
-
lines.push(` ${c.name} = ${c.value} — ${c.description}`);
|
|
373
|
-
}
|
|
374
|
-
lines.push("");
|
|
375
|
-
}
|
|
376
|
-
if (bundle.cross_object_refs.length > 0) {
|
|
377
|
-
lines.push(`─ Cross-object References (${bundle.cross_object_refs.length}) ──────────────`);
|
|
378
|
-
for (const ref of bundle.cross_object_refs.slice(0, 6)) {
|
|
379
|
-
const lock = ref.locked_after_publish ? " [locked]" : "";
|
|
380
|
-
lines.push(` ${ref.object} (${ref.field})${lock}: ${ref.description}`);
|
|
381
|
-
}
|
|
382
|
-
if (bundle.cross_object_refs.length > 6) {
|
|
383
|
-
lines.push(` ... and ${bundle.cross_object_refs.length - 6} more`);
|
|
384
|
-
}
|
|
385
|
-
lines.push("");
|
|
386
|
-
}
|
|
387
|
-
return lines.join("\n");
|
|
388
|
-
}
|
|
389
|
-
export function getServiceContextSummary(bundle) {
|
|
390
|
-
const parts = [
|
|
391
|
-
`mode=${bundle.mode}`,
|
|
392
|
-
`scene=${bundle.matched_scene?.id ?? "none"}`,
|
|
393
|
-
`risks=${bundle.relevant_risks.length}`,
|
|
394
|
-
`permissions=${bundle.relevant_builtin_permissions.length}`,
|
|
395
|
-
];
|
|
396
|
-
if (bundle.risk_assessment)
|
|
397
|
-
parts.push(`overall_risk=${bundle.risk_assessment.overall_risk}`);
|
|
398
|
-
if (bundle.matched_template)
|
|
399
|
-
parts.push(`template=${bundle.matched_template.id}`);
|
|
400
|
-
if (bundle.relevant_order_flow_stages.length > 0)
|
|
401
|
-
parts.push(`order_flow=8-stages`);
|
|
402
|
-
return parts.join(", ");
|
|
403
|
-
}
|
|
1
|
+
import{MAX_SALE_COUNT,MAX_REPOSITORY_COUNT,MAX_ARBITRATION_COUNT,MAX_DISCOUNT_COUNT_ONCE,MAX_DISCOUNT_TOTAL_COUNT,MAX_WIP_LENGTH,MAX_WIP_HASH_LENGTH,DEFAULT_LOCK_DURATION}from'@wowok/wowok';import{findSceneById,inferSceneFromIntent,getScenesByCategory,isServicePermission,SERVICE_PERMISSIONS,SERVICE_ORDER_FLOW_STAGES,SERVICE_CROSS_OBJECT_BINDINGS}from'./service-ledger.js';import{getServiceTemplatesByScene}from'./service-templates.js';import{matchSemanticPattern}from'./service-translation.js';import{getAllServiceRiskRules,assessServiceRisks}from'./service-risk.js';import{initPuzzleFromIntent,checkPuzzleCompleteness}from'./service-puzzle.js';import{SERVICE_PUBLISH_CHECKLIST,SERVICE_CONFIRMATION_QUESTIONS}from'./service-confirm.js';export const SERVICE_CONTEXT_VERSION='1.0.0';export function buildServiceContext(a){const b=a['max_length']??0x1770;let c;a['intent']&&(c=inferSceneFromIntent(a['intent']));!c&&a['target_scene_id']&&(c=findSceneById(a['target_scene_id']));if(!c&&a['target_category']){const r=getScenesByCategory(a['target_category']);if(r['length']>0x0)c=r[0x0];}!c&&a['target_permission_index']!==undefined&&isServicePermission(a['target_permission_index'])&&(c=findSceneById('service_retail'));let d;if(c){const s=getServiceTemplatesByScene(c['id']);if(s['length']>0x0)d=s[0x0];}let e;if(a['intent']){const t=matchSemanticPattern(a['intent']);if(t['length']>0x0)e=t[0x0];}let f,g;a['mode']==='initial_design'&&a['intent']&&(f=initPuzzleFromIntent({'primary_goal':a['intent']}),g=checkPuzzleCompleteness(f));const h=filterRiskRules(a['mode'],a['stakeholder'],c);let i;if((a['mode']==='pre_publish'||a['mode']==='post_publish_modify'||a['mode']==='order_flow_check')&&a['service_json']){const u={'object':a['service_json']['object'],'description':a['service_json']['description'],'location':a['service_json']['location'],'sales':a['service_json']['sales'],'repositories':a['service_json']['repositories'],'rewards':a['service_json']['rewards'],'arbitrations':a['service_json']['arbitrations'],'machine':a['service_json']['machine'],'discount':a['service_json']['discount'],'customer_required':a['service_json']['customer_required'],'order_allocators':a['service_json']['order_allocators'],'buy_guard':a['service_json']['buy_guard'],'compensation_fund_add':a['service_json']['compensation_fund_add'],'setting_lock_duration_add':a['service_json']['setting_lock_duration_add'],'compensation_fund_receive':a['service_json']['compensation_fund_receive'],'owner_receive':a['service_json']['owner_receive'],'pause':a['service_json']['pause'],'publish':a['service_json']['publish'],'um':a['service_json']['um'],'order_new':a['service_json']['order_new'],'current_bPublished':a['current_bPublished'],'current_bPaused':a['current_bPaused'],'current_machine_bound':a['current_bPublished']};i=assessServiceRisks(u);}const j=filterChecklist(a['mode']),k=filterQuestions(a['mode']),l=c?c['builtin_indexes']:[...SERVICE_PERMISSIONS],m=a['mode']==='order_flow_check'?[...SERVICE_ORDER_FLOW_STAGES]:[],n=[...SERVICE_CROSS_OBJECT_BINDINGS],o=buildCrossObjectRefs(c),p=buildOnchainConstraints(),q=buildRenderingHints(a['mode'],b,!!a['service_json']?.['publish'],!!a['service_json']?.['builder'],!!a['service_json']?.['order_new'],a['current_bPublished']??![]);return{'version':SERVICE_CONTEXT_VERSION,'mode':a['mode'],'stakeholder_perspective':a['stakeholder'],'matched_scene':c,'matched_template':d,'matched_pattern':e,'puzzle_state':f,'puzzle_completeness':g,'relevant_risks':h,'risk_assessment':i,'relevant_checklist':j,'relevant_questions':k,'relevant_builtin_permissions':l,'relevant_order_flow_stages':m,'cross_object_bindings':n,'cross_object_refs':o,'onchain_constraints':p,'rendering_hints':q};}function filterRiskRules(a,b,c){let d=getAllServiceRiskRules();if(a==='initial_design')return d['filter'](e=>e['category']==='structural'||e['category']==='authority');if(a==='pre_publish')return d;if(a==='post_publish_modify')return d['filter'](e=>e['category']==='lifecycle'||e['category']==='cross_object');if(a==='order_flow_check')return d['filter'](e=>e['category']==='semantic'||e['id']['startsWith']('R-S-2'));if(a==='stakeholder_review'&&b){if(b==='owner')return d['filter'](e=>e['category']==='authority'||e['category']==='lifecycle');if(b==='customer')return d['filter'](e=>e['category']==='semantic'||e['id']['startsWith']('R-S-2'));if(b==='provider')return d['filter'](e=>e['category']==='cross_object'||e['id']['startsWith']('R-S-5-01'));if(b==='arbitrator')return d['filter'](e=>e['id']['startsWith']('R-S-5-02')||e['id']['startsWith']('R-S-2-02'));if(b==='system')return d['filter'](e=>e['category']==='lifecycle');}return d;}function filterChecklist(a){if(a==='initial_design')return SERVICE_PUBLISH_CHECKLIST['filter'](b=>['C-S-01','C-S-02','C-S-03','C-S-04','C-S-05','C-S-06','C-S-07']['includes'](b['id']));if(a==='pre_publish')return SERVICE_PUBLISH_CHECKLIST;if(a==='post_publish_modify')return SERVICE_PUBLISH_CHECKLIST['filter'](b=>['C-S-12','C-S-13','C-S-14','C-S-15','C-S-16']['includes'](b['id']));if(a==='order_flow_check')return SERVICE_PUBLISH_CHECKLIST['filter'](b=>['C-S-07']['includes'](b['id']));return SERVICE_PUBLISH_CHECKLIST;}function filterQuestions(a){if(a==='pre_publish')return SERVICE_CONFIRMATION_QUESTIONS;if(a==='post_publish_modify')return SERVICE_CONFIRMATION_QUESTIONS['filter'](b=>!['QS1','QS2','QS5']['includes'](b['id']));if(a==='order_flow_check')return SERVICE_CONFIRMATION_QUESTIONS['filter'](b=>b['id']==='QS9');return[];}function buildCrossObjectRefs(a){return[{'object':'Machine','field':'machine','scene_id':'service_workflow','description':'Machine\x20workflow\x20template\x20—\x20post-publish\x20immutable.\x20Progress\x20inherits\x20this\x20binding.','locked_after_publish':!![]},{'object':'Allocation','field':'order_allocators','scene_id':'service_order_allocator','description':'Fund\x20distribution\x20strategy\x20—\x20publish\x20prerequisite,\x20post-publish\x20immutable.','locked_after_publish':!![]},{'object':'Arbitration','field':'arbitrations','scene_id':'service_arbitration','description':'Dispute\x20handlers\x20—\x20required\x20when\x20compensation_fund\x20>\x200,\x20post-publish\x20immutable.','locked_after_publish':!![]},{'object':'Repository','field':'repositories','scene_id':'service_retail','description':'Shared\x20data\x20stores\x20—\x20mutable\x20post-publish.','locked_after_publish':![]},{'object':'Reward','field':'rewards','scene_id':'service_reward','description':'Marketing\x20incentives\x20—\x20mutable\x20but\x20locked\x20by\x20setting_lock_duration.','locked_after_publish':![]},{'object':'Guard','field':'buy_guard','scene_id':'service_buy_guard','description':'Buyer\x20eligibility\x20Guard\x20—\x20UNUSUAL:\x20still\x20mutable\x20post-publish.','locked_after_publish':![]},{'object':'Contact','field':'um','scene_id':'service_retail','description':'User\x20Manager\x20(Contact\x20object)\x20—\x20mutable\x20post-publish.','locked_after_publish':![]},{'object':'Treasury','field':'(indirect\x20via\x20order_allocators.sharing.who=Entity)','scene_id':'service_multi_allocator','description':'Treasury\x20referenced\x20by\x20Allocation.sharing.who=Entity\x20(Treasury\x20address).\x20Not\x20directly\x20bound\x20to\x20Service.','locked_after_publish':![]},{'object':'Progress','field':'(created\x20at\x20order\x20time)','scene_id':'service_workflow','description':'Progress\x20object\x20created\x20per\x20order\x20(Stage\x206\x20of\x20buy\x20flow).\x20Inherits\x20Machine\x20from\x20Service.','locked_after_publish':![]},{'object':'Permission','field':'permission','scene_id':'service_retail','description':'Permission\x20object\x20governing\x2021\x20SERVICE_*\x20indexes\x20(300-320).\x20Bound\x20at\x20Service\x20creation,\x20immutable.','locked_after_publish':!![]}];}function buildOnchainConstraints(){return[{'name':'MAX_SALE_COUNT','value':MAX_SALE_COUNT,'description':'Maximum\x20sales\x20items\x20per\x20Service'},{'name':'MAX_REPOSITORY_COUNT','value':MAX_REPOSITORY_COUNT,'description':'Maximum\x20repositories\x20per\x20Service'},{'name':'MAX_ARBITRATION_COUNT','value':MAX_ARBITRATION_COUNT,'description':'Maximum\x20arbitrations\x20per\x20Service'},{'name':'MAX_REWARD_COUNT','value':0x14,'description':'Maximum\x20rewards\x20per\x20Service'},{'name':'MAX_DISCOUNT_COUNT_ONCE','value':MAX_DISCOUNT_COUNT_ONCE,'description':'Maximum\x20discount\x20coupons\x20per\x20issue\x20call'},{'name':'MAX_DISCOUNT_TOTAL_COUNT','value':MAX_DISCOUNT_TOTAL_COUNT,'description':'Maximum\x20total\x20discount\x20coupons\x20per\x20Service'},{'name':'MAX_WIP_LENGTH','value':MAX_WIP_LENGTH,'description':'Maximum\x20WIP\x20URL\x20length'},{'name':'MAX_WIP_HASH_LENGTH','value':MAX_WIP_HASH_LENGTH,'description':'Maximum\x20WIP\x20hash\x20length\x20(sha256\x20hex)'},{'name':'DEFAULT_LOCK_DURATION','value':DEFAULT_LOCK_DURATION,'description':'Default\x20setting_lock_duration\x20(30\x20days\x20in\x20ms)'}];}function buildRenderingHints(a,b,c,d,e,f){return{'include_puzzle_template':a==='initial_design','include_risk_details':a==='pre_publish'||a==='stakeholder_review'||a==='order_flow_check','include_questions':a==='pre_publish'||a==='order_flow_check','include_publish_warning':c,'include_transfer_warning':d,'include_order_flow_warning':e,'include_immutability_matrix':a==='post_publish_modify'||a==='pre_publish'||f,'max_length':b};}export function buildPromptFromServiceContext(a){const d=[],e=a['rendering_hints'];d['push']('═══\x20Service\x20Context\x20(mode:\x20'+a['mode']+')\x20═══'),d['push']('');a['matched_scene']&&(d['push']('Scene:\x20'+a['matched_scene']['name']),d['push']('Category:\x20'+a['matched_scene']['category']),d['push']('Permission\x20range:\x20'+a['matched_scene']['permission_index_range']),d['push'](''));if(a['matched_template']){d['push']('Suggested\x20template:\x20'+a['matched_template']['id']+'\x20—\x20'+a['matched_template']['name']);if(a['matched_template']['notes']&&a['matched_template']['notes']['length']>0x0){d['push']('Notes:');for(const f of a['matched_template']['notes']['slice'](0x0,0x3)){d['push']('\x20\x20-\x20'+f);}}d['push']('');}if(e['include_puzzle_template']&&a['puzzle_completeness']){const g=a['puzzle_completeness'];d['push']('─\x20Puzzle\x20Completeness\x20──────────────'),d['push']('Complete:\x20'+(g['complete']?'YES':'NO'));if(g['missing']['length']>0x0){d['push']('Missing\x20dimensions:\x20'+g['missing']['join'](',\x20'));for(const i of g['missing_details']['slice'](0x0,0x3)){d['push']('\x20\x20-\x20'+i['dimension']+':\x20'+i['reason']);}}d['push']('Next:\x20'+g['next_step']),d['push']('');}if(e['include_risk_details']&&a['relevant_risks']['length']>0x0){d['push']('─\x20Relevant\x20Risk\x20Rules\x20('+a['relevant_risks']['length']+')\x20──────────────');for(const j of a['relevant_risks']['slice'](0x0,0x8)){d['push']('\x20\x20'+j['id']+'\x20['+j['category']+']\x20—\x20'+j['trigger']);}a['relevant_risks']['length']>0x8&&d['push']('\x20\x20...\x20and\x20'+(a['relevant_risks']['length']-0x8)+'\x20more'),d['push']('');}if(a['risk_assessment']){d['push']('─\x20Risk\x20Assessment\x20──────────────'),d['push']('Overall:\x20'+a['risk_assessment']['overall_risk']),d['push']('Detected:\x20'+a['risk_assessment']['risks']['length']+'\x20risk(s)');if(a['risk_assessment']['risks']['length']>0x0)for(const k of a['risk_assessment']['risks']['slice'](0x0,0x5)){d['push']('\x20\x20['+k['level']+']\x20'+k['id']+':\x20'+k['title']);}d['push']('');}if(a['relevant_builtin_permissions']['length']>0x0){d['push']('─\x20Builtin\x20Permissions\x20('+a['relevant_builtin_permissions']['length']+')\x20──────────────');for(const l of a['relevant_builtin_permissions']['slice'](0x0,0xa)){const m=l['post_publish_mutability']==='immutable'?'\x20[IMMUTABLE]':l['post_publish_mutability']==='one_shot'?'\x20[ONE-SHOT]':l['post_publish_mutability']==='locked_by_duration'?'\x20[LOCKED]':'';d['push']('\x20\x20['+l['index']+']\x20'+l['name']+':\x20'+l['description']+m);}a['relevant_builtin_permissions']['length']>0xa&&d['push']('\x20\x20...\x20and\x20'+(a['relevant_builtin_permissions']['length']-0xa)+'\x20more'),d['push']('');}if(a['relevant_order_flow_stages']['length']>0x0){d['push']('─\x208-Stage\x20Order\x20Flow\x20──────────────');for(const n of a['relevant_order_flow_stages']){d['push']('\x20\x20Stage\x20'+n['stage']+':\x20'+n['name']+'\x20'+(n['always_executed']?'(always)':'(conditional)')),n['side_effects']['length']>0x0&&d['push']('\x20\x20\x20\x20Side\x20effects:\x20'+n['side_effects'][0x0]);}d['push']('');}e['include_publish_warning']&&(d['push']('⚠️\x20PUBLISH\x20OPERATION\x20DETECTED\x20—\x20IRREVERSIBLE'),d['push']('\x20\x20Once\x20published:\x20machine/arbitrations/order_allocators\x20become\x20PERMANENTLY\x20immutable'),d['push']('\x20\x20bPublished\x20cannot\x20be\x20reset\x20to\x20false\x20—\x20clone\x20Service\x20to\x20\x27reset\x27'),d['push'](''));e['include_transfer_warning']&&(d['push']('⚠️\x20TRANSFER\x20OPERATION\x20DETECTED\x20—\x20IRREVERSIBLE'),d['push']('\x20\x20Original\x20owner\x20loses\x20ALL\x20control.\x20New\x20owner\x20inherits\x20everything.'),d['push'](''));e['include_order_flow_warning']&&(d['push']('⚠️\x20ORDER\x20FLOW\x20—\x208\x20STAGES,\x20stock\x20deducted\x20at\x20quote\x20(Stage\x203)'),d['push']('\x20\x20If\x20Stages\x204-7\x20fail,\x20stock\x20remains\x20deducted\x20(not\x20rolled\x20back)'),d['push'](''));if(e['include_immutability_matrix']&&a['cross_object_bindings']['length']>0x0){d['push']('─\x20Post-publish\x20Immutability\x20Matrix\x20──────────────');for(const o of a['cross_object_bindings']){const q=o['locked_after_publish']?'🔒\x20IMMUTABLE':'🔓\x20mutable';d['push']('\x20\x20'+o['object']+'\x20('+o['field']+'):\x20'+q);}d['push']('');}if(a['onchain_constraints']['length']>0x0){d['push']('─\x20On-chain\x20Constraints\x20──────────────');for(const s of a['onchain_constraints']){d['push']('\x20\x20'+s['name']+'\x20=\x20'+s['value']+'\x20—\x20'+s['description']);}d['push']('');}if(a['cross_object_refs']['length']>0x0){d['push']('─\x20Cross-object\x20References\x20('+a['cross_object_refs']['length']+')\x20──────────────');for(const t of a['cross_object_refs']['slice'](0x0,0x6)){const u=t['locked_after_publish']?'\x20[locked]':'';d['push']('\x20\x20'+t['object']+'\x20('+t['field']+')'+u+':\x20'+t['description']);}a['cross_object_refs']['length']>0x6&&d['push']('\x20\x20...\x20and\x20'+(a['cross_object_refs']['length']-0x6)+'\x20more'),d['push']('');}return d['join']('\x0a');}export function getServiceContextSummary(a){const b=['mode='+a['mode'],'scene='+(a['matched_scene']?.['id']??'none'),'risks='+a['relevant_risks']['length'],'permissions='+a['relevant_builtin_permissions']['length']];if(a['risk_assessment'])b['push']('overall_risk='+a['risk_assessment']['overall_risk']);if(a['matched_template'])b['push']('template='+a['matched_template']['id']);if(a['relevant_order_flow_stages']['length']>0x0)b['push']('order_flow=8-stages');return b['join'](',\x20');}
|