@wowok/agent-mcp 2.7.1 → 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.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 +9 -2
- package/dist/evaluation/arbitration-game.js +1 -48
- package/dist/evaluation/builtins/demand-match.js +1 -153
- package/dist/evaluation/builtins/index.js +1 -10
- package/dist/evaluation/builtins/service-risk.js +1 -55
- package/dist/evaluation/capability.js +1 -13
- package/dist/evaluation/composer.js +1 -40
- package/dist/evaluation/engine.js +1 -175
- package/dist/evaluation/extract.js +1 -115
- package/dist/evaluation/game-strategy.d.ts +27 -0
- package/dist/evaluation/game-strategy.js +1 -0
- package/dist/evaluation/gap.js +1 -100
- package/dist/evaluation/index.d.ts +1 -0
- package/dist/evaluation/index.js +1 -11
- package/dist/evaluation/node-game.d.ts +31 -3
- package/dist/evaluation/node-game.js +1 -57
- package/dist/evaluation/region.js +1 -36
- package/dist/evaluation/types.d.ts +1 -0
- package/dist/evaluation/types.js +1 -1
- package/dist/evaluation/user-injection.js +1 -27
- package/dist/experience/experience-reuse.js +1 -103
- package/dist/experience/index.js +1 -5
- package/dist/experience/intent-distill.js +1 -83
- package/dist/experience/realtime-feedback.js +1 -94
- package/dist/experience/types.js +1 -1
- package/dist/experience/user-profile.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 -315
- 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.js +1 -67
- package/dist/intent/index.js +1 -60
- package/dist/intent/matcher.js +1 -81
- package/dist/intent/store.js +1 -55
- package/dist/intent/types.js +1 -10
- package/dist/knowledge/acquisition-flywheel.js +1 -192
- package/dist/knowledge/allocation-confirm.js +1 -534
- package/dist/knowledge/allocation-context.js +1 -249
- package/dist/knowledge/allocation-ledger.js +1 -463
- package/dist/knowledge/allocation-puzzle.js +1 -298
- package/dist/knowledge/allocation-risk.js +1 -568
- package/dist/knowledge/allocation-templates.js +1 -970
- package/dist/knowledge/allocation-translation.js +1 -585
- package/dist/knowledge/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 -423
- 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.js +1 -60
- 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 -843
- 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 -669
- package/dist/knowledge/machine-templates.js +1 -1597
- package/dist/knowledge/machine-topology.js +1 -234
- package/dist/knowledge/machine-translation.js +1 -513
- package/dist/knowledge/mcp-schema-audit-cli.js +1 -45
- package/dist/knowledge/mcp-schema-audit.js +1 -777
- package/dist/knowledge/onchain-constants.js +1 -35
- package/dist/knowledge/order-confirm.js +1 -573
- package/dist/knowledge/order-context.js +1 -390
- package/dist/knowledge/order-ledger.js +1 -341
- package/dist/knowledge/order-puzzle.js +1 -255
- package/dist/knowledge/order-risk.js +1 -653
- package/dist/knowledge/order-templates.js +1 -368
- package/dist/knowledge/order-translation.js +1 -550
- package/dist/knowledge/overrides-loader.js +1 -65
- package/dist/knowledge/passport-confirm.js +1 -531
- package/dist/knowledge/passport-context.js +1 -306
- package/dist/knowledge/passport-ledger.js +1 -282
- package/dist/knowledge/passport-puzzle.js +1 -333
- package/dist/knowledge/passport-risk.js +1 -450
- package/dist/knowledge/passport-templates.js +1 -568
- package/dist/knowledge/passport-translation.js +1 -516
- package/dist/knowledge/payment-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 -651
- package/dist/knowledge/service-templates.js +1 -456
- package/dist/knowledge/service-translation.js +1 -622
- package/dist/knowledge/template-registry.js +1 -353
- package/dist/knowledge/tool-constraints.js +1 -195
- package/dist/knowledge/tools-reference.js +1 -178
- package/dist/knowledge/treasury-confirm.js +1 -512
- package/dist/knowledge/treasury-context.js +1 -363
- package/dist/knowledge/treasury-ledger.js +1 -300
- package/dist/knowledge/treasury-puzzle.js +1 -216
- package/dist/knowledge/treasury-risk.js +1 -440
- package/dist/knowledge/treasury-templates.js +1 -358
- package/dist/knowledge/treasury-translation.js +1 -498
- package/dist/knowledge/trust-metrics.js +1 -198
- package/dist/knowledge/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.js +1 -66
- package/dist/persona/bridge.js +1 -86
- package/dist/persona/defaults.js +1 -195
- package/dist/persona/experience-bridge.js +1 -23
- package/dist/persona/index.js +1 -71
- package/dist/persona/model.js +1 -111
- package/dist/persona/store.js +1 -62
- package/dist/persona/types.d.ts +3 -1
- package/dist/persona/types.js +1 -5
- 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.js +1 -1784
- 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 -292
- package/dist/project/stage-gate.js +1 -369
- package/dist/project/substep-trace.js +1 -332
- package/dist/project/task-tracker.js +1 -78
- package/dist/role/derivation.d.ts +18 -0
- package/dist/role/derivation.js +1 -0
- package/dist/role/index.d.ts +5 -0
- package/dist/role/index.js +1 -0
- package/dist/role/model.d.ts +8 -0
- package/dist/role/model.js +1 -0
- package/dist/role/resolution.d.ts +11 -0
- package/dist/role/resolution.js +1 -0
- package/dist/role/types.d.ts +11 -0
- package/dist/role/types.js +1 -0
- package/dist/rules.js +1 -52
- package/dist/safety/confirm-gate.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 -1679
- package/dist/schema/call/service.js +1 -184
- 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 +213 -16
- package/dist/schema/evaluation/index.js +1 -356
- package/dist/schema/index.js +1 -17
- package/dist/schema/intent-radar/index.d.ts +13 -13
- package/dist/schema/intent-radar/index.js +1 -89
- 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 +54 -54
- package/dist/schema/persona/index.js +1 -148
- package/dist/schema/project/index.d.ts +94 -48
- package/dist/schema/project/index.js +1 -2057
- package/dist/schema/query/index.d.ts +423 -7
- package/dist/schema/query/index.js +1 -1646
- package/dist/schema/schema-query/index.js +1 -104
- package/dist/schema/schema-version.js +1 -76
- package/dist/schema/sync-layer4.js +1 -286
- package/dist/schema/task-status.js +1 -36
- 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 +112 -7
- package/dist/schemas/evaluation_operation.schema.json +93 -6
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/intent_radar.output.json +4 -1
- package/dist/schemas/intent_radar.schema.json +4 -1
- 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 +4 -4
- 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 +1 -1
- package/dist/schemas/onchain_table_data.output.json +6 -3
- package/dist/schemas/persona_operation.output.json +4 -1
- package/dist/schemas/persona_operation.schema.json +4 -1
- package/dist/schemas/project_operation.output.json +28 -8
- package/dist/schemas/query_toolkit.output.json +8 -5
- 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.js +1 -123
- package/dist/tools/handlers/file-export.js +1 -90
- package/dist/tools/handlers/intent-radar.js +1 -76
- package/dist/tools/handlers/local.js +1 -53
- package/dist/tools/handlers/messenger.js +1 -188
- package/dist/tools/handlers/onchain.js +1 -1180
- package/dist/tools/handlers/persona.js +1 -89
- package/dist/tools/handlers/project.js +1 -211
- package/dist/tools/handlers/query.js +1 -434
- package/dist/tools/handlers/schema-query.js +1 -176
- package/dist/tools/handlers/task-status.js +1 -26
- package/dist/tools/handlers/trust.js +1 -380
- package/dist/tools/handlers/wip.js +1 -90
- package/dist/tools/index.js +1 -1382
- 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.js +1 -306
- package/dist/tools/wrap.js +1 -500
- package/package.json +4 -2
|
@@ -1,228 +1 @@
|
|
|
1
|
-
const EQUAL_OPERATORS = new Set([
|
|
2
|
-
'logic_equal',
|
|
3
|
-
'logic_string_nocase_equal',
|
|
4
|
-
'logic_as_u256_equal',
|
|
5
|
-
]);
|
|
6
|
-
function mapOperatorToTarget(operator, valueType) {
|
|
7
|
-
if (valueType === 'String' || valueType === 2) {
|
|
8
|
-
if (operator === 'logic_string_nocase_equal') {
|
|
9
|
-
return { target: 'vec_contains_string_nocase', vecType: 'VecString' };
|
|
10
|
-
}
|
|
11
|
-
if (operator === 'logic_equal') {
|
|
12
|
-
return { target: 'vec_contains_string', vecType: 'VecString' };
|
|
13
|
-
}
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
if (valueType === 'Address' || valueType === 1) {
|
|
17
|
-
if (operator === 'logic_equal') {
|
|
18
|
-
return { target: 'vec_contains_address', vecType: 'VecAddress' };
|
|
19
|
-
}
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
if (valueType === 'Bool' || valueType === 0) {
|
|
23
|
-
if (operator === 'logic_equal') {
|
|
24
|
-
return { target: 'vec_contains_bool', vecType: 'VecBool' };
|
|
25
|
-
}
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
const numericTypes = new Set([
|
|
29
|
-
'U8', 'U16', 'U32', 'U64', 'U128', 'U256',
|
|
30
|
-
3, 4, 5, 6, 7, 8,
|
|
31
|
-
]);
|
|
32
|
-
if (numericTypes.has(valueType)) {
|
|
33
|
-
if (operator === 'logic_equal' || operator === 'logic_as_u256_equal') {
|
|
34
|
-
return { target: 'vec_contains_number', vecType: 'VecU256' };
|
|
35
|
-
}
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
export function analyzeLogicOrConversion(orNode, table) {
|
|
41
|
-
const reasons = [];
|
|
42
|
-
if (orNode.type !== 'logic_or') {
|
|
43
|
-
return {
|
|
44
|
-
convertible: false,
|
|
45
|
-
reasons: [`Node type is '${orNode.type}', not 'logic_or'. Only logic_or nodes are candidates.`],
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
const children = orNode.nodes ?? [];
|
|
49
|
-
if (children.length < 2) {
|
|
50
|
-
return {
|
|
51
|
-
convertible: false,
|
|
52
|
-
reasons: [`logic_or has ${children.length} children; need at least 2 to convert.`],
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
if (children.length > 7) {
|
|
56
|
-
return {
|
|
57
|
-
convertible: false,
|
|
58
|
-
reasons: [
|
|
59
|
-
`logic_or has ${children.length} children; vec_contains_* supports at most 7 needles (1 haystack + 7 needles = 8 node limit). Keep the logic_or.`,
|
|
60
|
-
],
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
const childOperators = new Set();
|
|
64
|
-
for (const child of children) {
|
|
65
|
-
if (!EQUAL_OPERATORS.has(child.type)) {
|
|
66
|
-
if (child.type === 'logic_string_contains' || child.type === 'logic_string_nocase_contains') {
|
|
67
|
-
reasons.push(`Child uses '${child.type}' (substring match). vec_contains_* is whole-element membership, NOT substring. Cannot convert.`);
|
|
68
|
-
}
|
|
69
|
-
else if (child.type?.startsWith('logic_as_u256_greater') || child.type?.startsWith('logic_as_u256_lesser')) {
|
|
70
|
-
reasons.push(`Child uses '${child.type}' (ordering comparison). vec_contains_* is membership, not ordering. Cannot convert.`);
|
|
71
|
-
}
|
|
72
|
-
else if (child.type === 'logic_and' || child.type === 'logic_or' || child.type === 'logic_not') {
|
|
73
|
-
reasons.push(`Child is a nested logic node ('${child.type}'). Only leaf equal-style comparisons are convertible.`);
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
reasons.push(`Child uses '${child.type}' which is not an equal-style operator (logic_equal / logic_string_nocase_equal / logic_as_u256_equal).`);
|
|
77
|
-
}
|
|
78
|
-
return { convertible: false, reasons };
|
|
79
|
-
}
|
|
80
|
-
childOperators.add(child.type);
|
|
81
|
-
}
|
|
82
|
-
if (childOperators.size > 1) {
|
|
83
|
-
const opList = Array.from(childOperators).join(', ');
|
|
84
|
-
return {
|
|
85
|
-
convertible: false,
|
|
86
|
-
reasons: [
|
|
87
|
-
`Children use mixed operators: [${opList}]. Mixing case-sensitive (logic_equal) and case-insensitive (logic_string_nocase_equal) comparisons would change semantics. Keep the logic_or.`,
|
|
88
|
-
],
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
const sharedOperator = children[0].type;
|
|
92
|
-
for (let i = 0; i < children.length; i++) {
|
|
93
|
-
const childNodes = children[i].nodes ?? [];
|
|
94
|
-
if (childNodes.length !== 2) {
|
|
95
|
-
return {
|
|
96
|
-
convertible: false,
|
|
97
|
-
reasons: [
|
|
98
|
-
`Child ${i} ('${sharedOperator}') has ${childNodes.length} sub-nodes; expected exactly 2 (one constant side + one shared query side).`,
|
|
99
|
-
],
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
const constants = [];
|
|
104
|
-
let sharedNode = null;
|
|
105
|
-
let sharedNodeSerial = null;
|
|
106
|
-
for (let i = 0; i < children.length; i++) {
|
|
107
|
-
const childNodes = children[i].nodes;
|
|
108
|
-
const left = childNodes[0];
|
|
109
|
-
const right = childNodes[1];
|
|
110
|
-
const leftIsConstId = left.type === 'identifier' && typeof left.identifier === 'number';
|
|
111
|
-
const rightIsConstId = right.type === 'identifier' && typeof right.identifier === 'number';
|
|
112
|
-
if (!leftIsConstId && !rightIsConstId) {
|
|
113
|
-
return {
|
|
114
|
-
convertible: false,
|
|
115
|
-
reasons: [
|
|
116
|
-
`Child ${i} has no constant identifier side (both sub-nodes are non-identifier). Conversion requires one side to be a constant table entry.`,
|
|
117
|
-
],
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
if (leftIsConstId && rightIsConstId) {
|
|
121
|
-
return {
|
|
122
|
-
convertible: false,
|
|
123
|
-
reasons: [
|
|
124
|
-
`Child ${i} has two identifier sides. Conversion requires one side to be a non-constant (query/context/calc) node shared across all children.`,
|
|
125
|
-
],
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
const constIdNode = leftIsConstId ? left : right;
|
|
129
|
-
const nonConstNode = leftIsConstId ? right : left;
|
|
130
|
-
const tableEntry = table.find((e) => e.identifier === constIdNode.identifier);
|
|
131
|
-
if (!tableEntry) {
|
|
132
|
-
return {
|
|
133
|
-
convertible: false,
|
|
134
|
-
reasons: [
|
|
135
|
-
`Child ${i} references identifier[${constIdNode.identifier}] which is not in the table.`,
|
|
136
|
-
],
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
if (tableEntry.b_submission !== false) {
|
|
140
|
-
return {
|
|
141
|
-
convertible: false,
|
|
142
|
-
reasons: [
|
|
143
|
-
`Child ${i} references identifier[${constIdNode.identifier}] with b_submission=${tableEntry.b_submission}. Conversion requires compile-time constants (b_submission=false).`,
|
|
144
|
-
],
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
if (tableEntry.value === undefined || tableEntry.value === null) {
|
|
148
|
-
return {
|
|
149
|
-
convertible: false,
|
|
150
|
-
reasons: [
|
|
151
|
-
`Child ${i} references identifier[${constIdNode.identifier}] which has no 'value' field. Conversion requires explicit constant values.`,
|
|
152
|
-
],
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
const nonConstSerial = JSON.stringify(nonConstNode);
|
|
156
|
-
if (sharedNodeSerial === null) {
|
|
157
|
-
sharedNodeSerial = nonConstSerial;
|
|
158
|
-
sharedNode = nonConstNode;
|
|
159
|
-
}
|
|
160
|
-
else if (sharedNodeSerial !== nonConstSerial) {
|
|
161
|
-
return {
|
|
162
|
-
convertible: false,
|
|
163
|
-
reasons: [
|
|
164
|
-
`Child ${i}'s non-constant side differs from child 0's. All children must share the SAME non-constant node (same query, same convert_witness, same parameters). Keep the logic_or.`,
|
|
165
|
-
],
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
constants.push({
|
|
169
|
-
identifier: constIdNode.identifier,
|
|
170
|
-
value: tableEntry.value,
|
|
171
|
-
value_type: String(tableEntry.value_type ?? ''),
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
const valueTypes = new Set(constants.map((c) => c.value_type));
|
|
175
|
-
if (valueTypes.size > 1) {
|
|
176
|
-
return {
|
|
177
|
-
convertible: false,
|
|
178
|
-
reasons: [
|
|
179
|
-
`Constants have mixed value_types: [${Array.from(valueTypes).join(', ')}]. All constants must share the same type to form a single VecXxx.`,
|
|
180
|
-
],
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
const sharedValueType = constants[0].value_type;
|
|
184
|
-
const mapping = mapOperatorToTarget(sharedOperator, sharedValueType);
|
|
185
|
-
if (!mapping) {
|
|
186
|
-
return {
|
|
187
|
-
convertible: false,
|
|
188
|
-
reasons: [
|
|
189
|
-
`No vec_contains_* variant maps to operator='${sharedOperator}' with value_type='${sharedValueType}'. ` +
|
|
190
|
-
`Mappable combinations: (logic_string_nocase_equal, String)→vec_contains_string_nocase; ` +
|
|
191
|
-
`(logic_equal, String)→vec_contains_string; (logic_equal, Address)→vec_contains_address; ` +
|
|
192
|
-
`(logic_equal, Bool)→vec_contains_bool; (logic_equal|logic_as_u256_equal, numeric)→vec_contains_number.`,
|
|
193
|
-
],
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
return {
|
|
197
|
-
convertible: true,
|
|
198
|
-
targetOperator: mapping.target,
|
|
199
|
-
vectorValueType: mapping.vecType,
|
|
200
|
-
sharedNode: sharedNode ?? undefined,
|
|
201
|
-
constants,
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
export function buildShorthand(orNode, result, newIdentifier) {
|
|
205
|
-
if (!result.convertible || !result.targetOperator || !result.vectorValueType || !result.sharedNode || !result.constants) {
|
|
206
|
-
return null;
|
|
207
|
-
}
|
|
208
|
-
const values = result.constants.map((c) => c.value);
|
|
209
|
-
const removeIdentifiers = result.constants.map((c) => c.identifier);
|
|
210
|
-
const newRoot = {
|
|
211
|
-
type: result.targetOperator,
|
|
212
|
-
nodes: [
|
|
213
|
-
{ type: 'identifier', identifier: newIdentifier },
|
|
214
|
-
result.sharedNode,
|
|
215
|
-
],
|
|
216
|
-
};
|
|
217
|
-
return {
|
|
218
|
-
newRoot,
|
|
219
|
-
removeIdentifiers,
|
|
220
|
-
addEntry: {
|
|
221
|
-
identifier: newIdentifier,
|
|
222
|
-
b_submission: false,
|
|
223
|
-
value_type: result.vectorValueType,
|
|
224
|
-
value: values,
|
|
225
|
-
name: 'converted_constants',
|
|
226
|
-
},
|
|
227
|
-
};
|
|
228
|
-
}
|
|
1
|
+
const EQUAL_OPERATORS=new Set(['logic_equal','logic_string_nocase_equal','logic_as_u256_equal']);function mapOperatorToTarget(a,b){if(b==='String'||b===0x2){if(a==='logic_string_nocase_equal')return{'target':'vec_contains_string_nocase','vecType':'VecString'};if(a==='logic_equal')return{'target':'vec_contains_string','vecType':'VecString'};return null;}if(b==='Address'||b===0x1){if(a==='logic_equal')return{'target':'vec_contains_address','vecType':'VecAddress'};return null;}if(b==='Bool'||b===0x0){if(a==='logic_equal')return{'target':'vec_contains_bool','vecType':'VecBool'};return null;}const c=new Set(['U8','U16','U32','U64','U128','U256',0x3,0x4,0x5,0x6,0x7,0x8]);if(c['has'](b)){if(a==='logic_equal'||a==='logic_as_u256_equal')return{'target':'vec_contains_number','vecType':'VecU256'};return null;}return null;}export function analyzeLogicOrConversion(a,b){const c=[];if(a['type']!=='logic_or')return{'convertible':![],'reasons':['Node\x20type\x20is\x20\x27'+a['type']+'\x27,\x20not\x20\x27logic_or\x27.\x20Only\x20logic_or\x20nodes\x20are\x20candidates.']};const d=a['nodes']??[];if(d['length']<0x2)return{'convertible':![],'reasons':['logic_or\x20has\x20'+d['length']+'\x20children;\x20need\x20at\x20least\x202\x20to\x20convert.']};if(d['length']>0x7)return{'convertible':![],'reasons':['logic_or\x20has\x20'+d['length']+'\x20children;\x20vec_contains_*\x20supports\x20at\x20most\x207\x20needles\x20(1\x20haystack\x20+\x207\x20needles\x20=\x208\x20node\x20limit).\x20Keep\x20the\x20logic_or.']};const e=new Set();for(const n of d){if(!EQUAL_OPERATORS['has'](n['type'])){if(n['type']==='logic_string_contains'||n['type']==='logic_string_nocase_contains')c['push']('Child\x20uses\x20\x27'+n['type']+'\x27\x20(substring\x20match).\x20vec_contains_*\x20is\x20whole-element\x20membership,\x20NOT\x20substring.\x20Cannot\x20convert.');else{if(n['type']?.['startsWith']('logic_as_u256_greater')||n['type']?.['startsWith']('logic_as_u256_lesser'))c['push']('Child\x20uses\x20\x27'+n['type']+'\x27\x20(ordering\x20comparison).\x20vec_contains_*\x20is\x20membership,\x20not\x20ordering.\x20Cannot\x20convert.');else n['type']==='logic_and'||n['type']==='logic_or'||n['type']==='logic_not'?c['push']('Child\x20is\x20a\x20nested\x20logic\x20node\x20(\x27'+n['type']+'\x27).\x20Only\x20leaf\x20equal-style\x20comparisons\x20are\x20convertible.'):c['push']('Child\x20uses\x20\x27'+n['type']+'\x27\x20which\x20is\x20not\x20an\x20equal-style\x20operator\x20(logic_equal\x20/\x20logic_string_nocase_equal\x20/\x20logic_as_u256_equal).');}return{'convertible':![],'reasons':c};}e['add'](n['type']);}if(e['size']>0x1){const o=Array['from'](e)['join'](',\x20');return{'convertible':![],'reasons':['Children\x20use\x20mixed\x20operators:\x20['+o+'].\x20Mixing\x20case-sensitive\x20(logic_equal)\x20and\x20case-insensitive\x20(logic_string_nocase_equal)\x20comparisons\x20would\x20change\x20semantics.\x20Keep\x20the\x20logic_or.']};}const f=d[0x0]['type'];for(let p=0x0;p<d['length'];p++){const q=d[p]['nodes']??[];if(q['length']!==0x2)return{'convertible':![],'reasons':['Child\x20'+p+'\x20(\x27'+f+'\x27)\x20has\x20'+q['length']+'\x20sub-nodes;\x20expected\x20exactly\x202\x20(one\x20constant\x20side\x20+\x20one\x20shared\x20query\x20side).']};}const g=[];let h=null,j=null;for(let r=0x0;r<d['length'];r++){const s=d[r]['nodes'],t=s[0x0],u=s[0x1],v=t['type']==='identifier'&&typeof t['identifier']==='number',w=u['type']==='identifier'&&typeof u['identifier']==='number';if(!v&&!w)return{'convertible':![],'reasons':['Child\x20'+r+'\x20has\x20no\x20constant\x20identifier\x20side\x20(both\x20sub-nodes\x20are\x20non-identifier).\x20Conversion\x20requires\x20one\x20side\x20to\x20be\x20a\x20constant\x20table\x20entry.']};if(v&&w)return{'convertible':![],'reasons':['Child\x20'+r+'\x20has\x20two\x20identifier\x20sides.\x20Conversion\x20requires\x20one\x20side\x20to\x20be\x20a\x20non-constant\x20(query/context/calc)\x20node\x20shared\x20across\x20all\x20children.']};const x=v?t:u,y=v?u:t,z=b['find'](B=>B['identifier']===x['identifier']);if(!z)return{'convertible':![],'reasons':['Child\x20'+r+'\x20references\x20identifier['+x['identifier']+']\x20which\x20is\x20not\x20in\x20the\x20table.']};if(z['b_submission']!==![])return{'convertible':![],'reasons':['Child\x20'+r+'\x20references\x20identifier['+x['identifier']+']\x20with\x20b_submission='+z['b_submission']+'.\x20Conversion\x20requires\x20compile-time\x20constants\x20(b_submission=false).']};if(z['value']===undefined||z['value']===null)return{'convertible':![],'reasons':['Child\x20'+r+'\x20references\x20identifier['+x['identifier']+']\x20which\x20has\x20no\x20\x27value\x27\x20field.\x20Conversion\x20requires\x20explicit\x20constant\x20values.']};const A=JSON['stringify'](y);if(j===null)j=A,h=y;else{if(j!==A)return{'convertible':![],'reasons':['Child\x20'+r+'\x27s\x20non-constant\x20side\x20differs\x20from\x20child\x200\x27s.\x20All\x20children\x20must\x20share\x20the\x20SAME\x20non-constant\x20node\x20(same\x20query,\x20same\x20convert_witness,\x20same\x20parameters).\x20Keep\x20the\x20logic_or.']};}g['push']({'identifier':x['identifier'],'value':z['value'],'value_type':String(z['value_type']??'')});}const k=new Set(g['map'](B=>B['value_type']));if(k['size']>0x1)return{'convertible':![],'reasons':['Constants\x20have\x20mixed\x20value_types:\x20['+Array['from'](k)['join'](',\x20')+'].\x20All\x20constants\x20must\x20share\x20the\x20same\x20type\x20to\x20form\x20a\x20single\x20VecXxx.']};const l=g[0x0]['value_type'],m=mapOperatorToTarget(f,l);if(!m)return{'convertible':![],'reasons':['No\x20vec_contains_*\x20variant\x20maps\x20to\x20operator=\x27'+f+'\x27\x20with\x20value_type=\x27'+l+'\x27.\x20'+'Mappable\x20combinations:\x20(logic_string_nocase_equal,\x20String)→vec_contains_string_nocase;\x20'+'(logic_equal,\x20String)→vec_contains_string;\x20(logic_equal,\x20Address)→vec_contains_address;\x20'+'(logic_equal,\x20Bool)→vec_contains_bool;\x20(logic_equal|logic_as_u256_equal,\x20numeric)→vec_contains_number.']};return{'convertible':!![],'targetOperator':m['target'],'vectorValueType':m['vecType'],'sharedNode':h??undefined,'constants':g};}export function buildShorthand(a,b,c){if(!b['convertible']||!b['targetOperator']||!b['vectorValueType']||!b['sharedNode']||!b['constants'])return null;const d=b['constants']['map'](g=>g['value']),e=b['constants']['map'](g=>g['identifier']),f={'type':b['targetOperator'],'nodes':[{'type':'identifier','identifier':c},b['sharedNode']]};return{'newRoot':f,'removeIdentifiers':e,'addEntry':{'identifier':c,'b_submission':![],'value_type':b['vectorValueType'],'value':d,'name':'converted_constants'}};}
|