@wowok/agent-mcp 2.7.2 → 2.7.4
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/runtime.js +1 -1
- package/dist/customer/account-events.d.ts +32 -0
- package/dist/customer/account-events.js +1 -0
- package/dist/customer/customer-advice.d.ts +1 -0
- package/dist/customer/customer-advice.js +1 -1
- package/dist/customer/info-puzzle.js +1 -1
- package/dist/customer/order-strategy.d.ts +1 -1
- package/dist/customer/reminder-system.d.ts +2 -0
- package/dist/customer/reminder-system.js +1 -1
- package/dist/customer/risk-assessment.d.ts +1 -0
- package/dist/customer/risk-assessment.js +1 -1
- package/dist/customer/types.d.ts +2 -0
- package/dist/evaluation/builtins/arbitration-score.d.ts +41 -0
- package/dist/evaluation/builtins/arbitration-score.js +1 -0
- package/dist/evaluation/builtins/index.d.ts +1 -0
- package/dist/evaluation/builtins/index.js +1 -1
- package/dist/evaluation/category-match-rules.d.ts +30 -0
- package/dist/evaluation/category-match-rules.js +1 -0
- package/dist/evaluation/engine.js +1 -1
- package/dist/evaluation/extract.js +1 -1
- package/dist/evaluation/index.d.ts +1 -0
- package/dist/evaluation/index.js +1 -1
- package/dist/evaluation/location-match.d.ts +42 -0
- package/dist/evaluation/location-match.js +1 -0
- package/dist/evaluation/path-reasoning.d.ts +35 -0
- package/dist/evaluation/path-reasoning.js +1 -0
- package/dist/evaluation/region.d.ts +6 -0
- package/dist/evaluation/region.js +1 -1
- package/dist/evaluation/types.d.ts +17 -0
- package/dist/experience/realtime-feedback.js +1 -1
- package/dist/experience/user-profile.d.ts +1 -1
- package/dist/extensions/index.d.ts +6 -0
- package/dist/extensions/index.js +1 -1
- package/dist/extensions/industry-layers.d.ts +75 -0
- package/dist/extensions/industry-layers.js +1 -0
- package/dist/extensions/industry-pack.d.ts +105 -0
- package/dist/extensions/industry-pack.js +1 -0
- package/dist/extensions/metric-registry.js +1 -1
- package/dist/extensions/mode-evaluator.d.ts +1 -1
- package/dist/extensions/registry.d.ts +1 -0
- package/dist/extensions/registry.js +1 -1
- package/dist/graph/base.d.ts +8 -0
- package/dist/graph/base.js +1 -0
- package/dist/harness/index.d.ts +1 -0
- package/dist/harness/index.js +1 -1
- package/dist/harness/plan.d.ts +2 -0
- package/dist/harness/plan.js +1 -1
- package/dist/harness/recover.d.ts +1 -1
- package/dist/harness/types.d.ts +2 -3
- package/dist/index.js +1 -1
- package/dist/knowledge/allocation-confirm.js +1 -1
- package/dist/knowledge/anti-cheat.d.ts +37 -0
- package/dist/knowledge/anti-cheat.js +1 -0
- package/dist/knowledge/arb-confirm.d.ts +28 -0
- package/dist/knowledge/arb-confirm.js +1 -0
- package/dist/knowledge/arb-translation.d.ts +48 -0
- package/dist/knowledge/arb-translation.js +1 -0
- package/dist/knowledge/arbitration-context.js +1 -1
- package/dist/knowledge/arbitration-ledger.js +1 -1
- package/dist/knowledge/bridge-confirm.d.ts +26 -0
- package/dist/knowledge/bridge-confirm.js +1 -0
- package/dist/knowledge/bridge-translation.d.ts +37 -0
- package/dist/knowledge/bridge-translation.js +1 -0
- package/dist/knowledge/contact-confirm.d.ts +27 -0
- package/dist/knowledge/contact-confirm.js +1 -0
- package/dist/knowledge/contact-translation.d.ts +39 -0
- package/dist/knowledge/contact-translation.js +1 -0
- package/dist/knowledge/demand-confirm.js +1 -1
- package/dist/knowledge/demand-context.d.ts +17 -0
- package/dist/knowledge/demand-context.js +1 -0
- package/dist/knowledge/demand-ledger.d.ts +26 -0
- package/dist/knowledge/demand-ledger.js +1 -0
- package/dist/knowledge/demand-puzzle.d.ts +29 -0
- package/dist/knowledge/demand-puzzle.js +1 -0
- package/dist/knowledge/demand-risk.js +1 -1
- package/dist/knowledge/demand-templates.d.ts +12 -0
- package/dist/knowledge/demand-templates.js +1 -0
- package/dist/knowledge/demand-translation.js +1 -1
- package/dist/knowledge/deployment-scanner.js +1 -1
- package/dist/knowledge/evidence-review.d.ts +12 -0
- package/dist/knowledge/evidence-review.js +1 -0
- package/dist/knowledge/examples-scanner-cli.js +1 -1
- package/dist/knowledge/examples-scanner.js +1 -1
- package/dist/knowledge/flywheel-loop.d.ts +0 -1
- package/dist/knowledge/flywheel-loop.js +1 -1
- package/dist/knowledge/guard-design-patterns.js +1 -1
- package/dist/knowledge/guard-migration.d.ts +1 -1
- package/dist/knowledge/index.d.ts +71 -3
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/machine-render.js +1 -1
- package/dist/knowledge/market-metrics.d.ts +12 -0
- package/dist/knowledge/market-metrics.js +1 -0
- package/dist/knowledge/market-operations.d.ts +46 -0
- package/dist/knowledge/market-operations.js +1 -0
- package/dist/knowledge/mcp-schema-audit-cli.js +1 -1
- package/dist/knowledge/mcp-schema-audit.d.ts +22 -22
- package/dist/knowledge/mcp-schema-audit.js +1 -1
- package/dist/knowledge/onchain-constants.d.ts +2 -2
- package/dist/knowledge/onchain-constants.js +1 -1
- package/dist/knowledge/payment-confirm.d.ts +26 -0
- package/dist/knowledge/payment-confirm.js +1 -0
- package/dist/knowledge/payment-risk.js +1 -1
- package/dist/knowledge/payment-translation.d.ts +37 -0
- package/dist/knowledge/payment-translation.js +1 -0
- package/dist/knowledge/permission-context.d.ts +11 -0
- package/dist/knowledge/permission-context.js +1 -1
- package/dist/knowledge/permission-ledger.d.ts +11 -0
- package/dist/knowledge/permission-ledger.js +1 -1
- package/dist/knowledge/personal-confirm.d.ts +29 -0
- package/dist/knowledge/personal-confirm.js +1 -0
- package/dist/knowledge/personal-risk.js +1 -1
- package/dist/knowledge/personal-translation.d.ts +37 -0
- package/dist/knowledge/personal-translation.js +1 -0
- package/dist/knowledge/process-model.d.ts +1 -11
- package/dist/knowledge/process-model.js +1 -1
- package/dist/knowledge/progress-ledger.js +1 -1
- package/dist/knowledge/progress-risk.js +1 -1
- package/dist/knowledge/progress-templates.js +1 -1
- package/dist/knowledge/progress-translation.js +1 -1
- package/dist/knowledge/proof-context.d.ts +17 -0
- package/dist/knowledge/proof-context.js +1 -0
- package/dist/knowledge/proof-ledger.d.ts +34 -0
- package/dist/knowledge/proof-ledger.js +1 -0
- package/dist/knowledge/proof-puzzle.d.ts +35 -0
- package/dist/knowledge/proof-puzzle.js +1 -0
- package/dist/knowledge/proof-templates.d.ts +22 -0
- package/dist/knowledge/proof-templates.js +1 -0
- package/dist/knowledge/registrar-confirm.d.ts +26 -0
- package/dist/knowledge/registrar-confirm.js +1 -0
- package/dist/knowledge/registrar-risk.js +1 -1
- package/dist/knowledge/registrar-translation.d.ts +37 -0
- package/dist/knowledge/registrar-translation.js +1 -0
- package/dist/knowledge/repository-context.d.ts +12 -0
- package/dist/knowledge/repository-context.js +1 -0
- package/dist/knowledge/repository-ledger.d.ts +25 -0
- package/dist/knowledge/repository-ledger.js +1 -0
- package/dist/knowledge/repository-puzzle.d.ts +30 -0
- package/dist/knowledge/repository-puzzle.js +1 -0
- package/dist/knowledge/repository-templates.d.ts +14 -0
- package/dist/knowledge/repository-templates.js +1 -0
- package/dist/knowledge/resource-confirm.d.ts +25 -0
- package/dist/knowledge/resource-confirm.js +1 -0
- package/dist/knowledge/resource-translation.d.ts +37 -0
- package/dist/knowledge/resource-translation.js +1 -0
- package/dist/knowledge/reward-context.d.ts +2 -2
- package/dist/knowledge/reward-ledger.js +1 -1
- package/dist/knowledge/reward-translation.js +1 -1
- package/dist/knowledge/safety-rules.d.ts +1 -0
- package/dist/knowledge/safety-rules.js +1 -1
- package/dist/knowledge/service-risk.d.ts +1 -1
- package/dist/knowledge/service-risk.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/tools-reference.js +1 -1
- package/dist/knowledge/treasury-context.d.ts +1 -1
- package/dist/knowledge/treasury-context.js +1 -1
- package/dist/knowledge/treasury-ledger.js +1 -1
- package/dist/knowledge/treasury-risk.js +1 -1
- package/dist/knowledge/universal-template.d.ts +22 -0
- package/dist/knowledge/universal-template.js +1 -0
- package/dist/knowledge/util-confirm.d.ts +24 -0
- package/dist/knowledge/util-confirm.js +1 -0
- package/dist/knowledge/util-risk.js +1 -1
- package/dist/knowledge/util-translation.d.ts +39 -0
- package/dist/knowledge/util-translation.js +1 -0
- package/dist/knowledge/workflow-guidance.d.ts +180 -0
- package/dist/knowledge/workflow-guidance.js +1 -0
- package/dist/participation/employee-kpi.d.ts +25 -0
- package/dist/participation/employee-kpi.js +1 -0
- package/dist/participation/employee-store.d.ts +16 -0
- package/dist/participation/employee-store.js +1 -0
- package/dist/participation/index.d.ts +2 -0
- package/dist/participation/index.js +1 -0
- package/dist/persona/defaults.js +1 -1
- package/dist/persona/index.d.ts +9 -2
- package/dist/persona/index.js +1 -1
- package/dist/persona/local-region.d.ts +20 -0
- package/dist/persona/local-region.js +1 -0
- package/dist/persona/model.js +1 -1
- package/dist/persona/overrides.d.ts +10 -0
- package/dist/persona/overrides.js +1 -0
- package/dist/persona/pack-personae.d.ts +11 -0
- package/dist/persona/pack-personae.js +1 -0
- package/dist/persona/strategy-intent.d.ts +20 -0
- package/dist/persona/strategy-intent.js +1 -0
- package/dist/persona/types.d.ts +3 -1
- package/dist/project/business-puzzle.d.ts +1 -1
- package/dist/project/business-puzzle.js +1 -1
- package/dist/project/deployment-doc.js +1 -1
- package/dist/project/edit-planner.js +1 -1
- package/dist/project/evaluation.d.ts +37 -1
- package/dist/project/evaluation.js +1 -1
- package/dist/project/graph-builder.d.ts +2 -2
- package/dist/project/graph-builder.js +1 -1
- package/dist/project/graph.d.ts +3 -6
- package/dist/project/handlers.d.ts +33 -2
- package/dist/project/handlers.js +1 -1
- package/dist/project/index.d.ts +1 -0
- package/dist/project/index.js +1 -1
- package/dist/project/merchant-guide.d.ts +19 -0
- package/dist/project/merchant-guide.js +1 -1
- package/dist/project/mode-actions.js +1 -1
- package/dist/project/rollback-policy.js +1 -1
- package/dist/project/semantic-assembler.d.ts +2 -2
- package/dist/project/semantic-assembler.js +1 -1
- package/dist/project/semantic-graph.d.ts +3 -5
- package/dist/project/workflow-design-assessment.d.ts +24 -0
- package/dist/project/workflow-design-assessment.js +1 -0
- package/dist/safety/confirm-gate.d.ts +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/call/allocation.d.ts +186 -1385
- package/dist/schema/call/arbitration.d.ts +272 -1871
- package/dist/schema/call/base.d.ts +1831 -9076
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/bridge.d.ts +911 -3171
- package/dist/schema/call/contact.d.ts +135 -931
- package/dist/schema/call/demand.d.ts +164 -1194
- package/dist/schema/call/guard.d.ts +298 -1140
- package/dist/schema/call/guard.js +1 -1
- package/dist/schema/call/machine.d.ts +459 -5403
- package/dist/schema/call/machine.js +1 -1
- package/dist/schema/call/order.d.ts +137 -844
- package/dist/schema/call/payment.d.ts +74 -561
- package/dist/schema/call/permission.d.ts +335 -2791
- package/dist/schema/call/personal.d.ts +227 -1814
- package/dist/schema/call/progress.d.ts +140 -843
- package/dist/schema/call/proof.d.ts +42 -258
- package/dist/schema/call/repository.d.ts +324 -2222
- package/dist/schema/call/reward.d.ts +153 -1183
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.d.ts +376 -3431
- package/dist/schema/call/treasury.d.ts +252 -2158
- package/dist/schema/common/index.d.ts +222 -697
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/config/index.d.ts +18 -161
- package/dist/schema/employee/index.d.ts +99 -0
- package/dist/schema/employee/index.js +1 -0
- package/dist/schema/evaluation/index.d.ts +1035 -3918
- package/dist/schema/evaluation/index.js +1 -1
- package/dist/schema/index.d.ts +5 -0
- package/dist/schema/index.js +1 -1
- package/dist/schema/industry-pack/index.d.ts +132 -0
- package/dist/schema/industry-pack/index.js +1 -0
- package/dist/schema/intent-radar/index.d.ts +92 -245
- package/dist/schema/intent-radar/index.js +1 -1
- package/dist/schema/local/index.d.ts +2045 -18080
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/local/wip.d.ts +61 -651
- package/dist/schema/local/wip.js +1 -1
- package/dist/schema/messenger/index.d.ts +949 -5557
- package/dist/schema/messenger/index.js +1 -1
- package/dist/schema/operations.d.ts +3168 -26468
- package/dist/schema/operations.js +1 -1
- package/dist/schema/permission/index.d.ts +121 -0
- package/dist/schema/permission/index.js +1 -0
- package/dist/schema/persona/index.d.ts +469 -1820
- package/dist/schema/persona/index.js +1 -1
- package/dist/schema/project/index.d.ts +1023 -8450
- package/dist/schema/project/index.js +1 -1
- package/dist/schema/query/index.d.ts +12121 -75556
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-query/index.d.ts +35 -98
- package/dist/schema/schema-query/index.js +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema/task-status.d.ts +26 -132
- package/dist/schema/trust/index.d.ts +194 -1290
- package/dist/schema/utils/guard-parser.js +1 -1
- package/dist/schema/utils/node-parser.js +1 -1
- package/dist/schema/utils/skills-recommendation.d.ts +1 -0
- package/dist/schema/utils/skills-recommendation.js +1 -1
- package/dist/schema/workflow/index.d.ts +161 -0
- package/dist/schema/workflow/index.js +1 -0
- package/dist/schema/workspace/index.d.ts +69 -0
- package/dist/schema/workspace/index.js +1 -0
- package/dist/{schema-query → schema-query-impl}/index.js +1 -1
- package/dist/schemas/account_operation.output.json +3147 -1655
- package/dist/schemas/account_operation.schema.json +225 -218
- package/dist/schemas/bridge_operation.output.json +1168 -653
- package/dist/schemas/bridge_operation.schema.json +736 -504
- package/dist/schemas/config_operation.output.json +185 -179
- package/dist/schemas/config_operation.schema.json +21 -26
- package/dist/schemas/employee_operation.output.json +207 -0
- package/dist/schemas/employee_operation.schema.json +176 -0
- package/dist/schemas/evaluation_operation.output.json +2268 -601
- package/dist/schemas/evaluation_operation.schema.json +2919 -787
- package/dist/schemas/guard2file.output.json +58 -64
- package/dist/schemas/guard2file.schema.json +79 -81
- package/dist/schemas/index.json +41 -11
- package/dist/schemas/industry_pack_operation.output.json +594 -0
- package/dist/schemas/industry_pack_operation.schema.json +55 -0
- package/dist/schemas/intent_radar.output.json +275 -203
- package/dist/schemas/intent_radar.schema.json +124 -126
- package/dist/schemas/local_info_operation.output.json +1174 -660
- package/dist/schemas/local_info_operation.schema.json +119 -125
- package/dist/schemas/local_mark_operation.output.json +1239 -692
- package/dist/schemas/local_mark_operation.schema.json +91 -96
- package/dist/schemas/machineNode2file.output.json +63 -69
- package/dist/schemas/machineNode2file.schema.json +79 -81
- package/dist/schemas/messenger_operation.output.json +2722 -1531
- package/dist/schemas/messenger_operation.schema.json +1482 -1264
- package/dist/schemas/onchain_events.output.json +2590 -978
- package/dist/schemas/onchain_events.schema.json +117 -99
- package/dist/schemas/onchain_operations.output.json +3957 -2312
- package/dist/schemas/onchain_operations.schema.json +20799 -9285
- package/dist/schemas/onchain_operations_allocation.schema.json +171 -107
- package/dist/schemas/onchain_operations_arbitration.schema.json +233 -146
- package/dist/schemas/onchain_operations_contact.schema.json +129 -90
- package/dist/schemas/onchain_operations_demand.schema.json +170 -112
- package/dist/schemas/onchain_operations_gen_passport.schema.json +61 -646
- package/dist/schemas/onchain_operations_gen_proof.schema.json +40 -172
- package/dist/schemas/onchain_operations_guard.schema.json +3765 -294
- package/dist/schemas/onchain_operations_machine.schema.json +536 -163
- package/dist/schemas/onchain_operations_order.schema.json +126 -96
- package/dist/schemas/onchain_operations_payment.schema.json +82 -67
- package/dist/schemas/onchain_operations_permission.schema.json +331 -93
- package/dist/schemas/onchain_operations_personal.schema.json +636 -96
- package/dist/schemas/onchain_operations_progress.schema.json +125 -92
- package/dist/schemas/onchain_operations_proof.schema.json +76 -69
- package/dist/schemas/onchain_operations_repository.schema.json +636 -249
- package/dist/schemas/onchain_operations_reward.schema.json +218 -108
- package/dist/schemas/onchain_operations_service.schema.json +678 -220
- package/dist/schemas/onchain_operations_treasury.schema.json +401 -135
- package/dist/schemas/onchain_table_data.output.json +6833 -2432
- package/dist/schemas/onchain_table_data.schema.json +684 -417
- package/dist/schemas/permission_operation.output.json +173 -0
- package/dist/schemas/permission_operation.schema.json +39 -0
- package/dist/schemas/persona_operation.output.json +1568 -268
- package/dist/schemas/persona_operation.schema.json +346 -205
- package/dist/schemas/project_operation.output.json +6922 -5132
- package/dist/schemas/project_operation.schema.json +1050 -1020
- package/dist/schemas/query_task_status.output.json +195 -99
- package/dist/schemas/query_task_status.schema.json +12 -18
- package/dist/schemas/query_toolkit.output.json +18862 -14561
- package/dist/schemas/query_toolkit.schema.json +614 -522
- package/dist/schemas/schema_query.output.json +127 -129
- package/dist/schemas/schema_query.schema.json +64 -69
- package/dist/schemas/trust_score.output.json +678 -587
- package/dist/schemas/trust_score.schema.json +289 -277
- package/dist/schemas/wip_file.output.json +116 -124
- package/dist/schemas/wip_file.schema.json +142 -143
- package/dist/schemas/workflow_operation.output.json +164 -0
- package/dist/schemas/workflow_operation.schema.json +116 -0
- package/dist/schemas/workspace_operation.output.json +277 -0
- package/dist/schemas/workspace_operation.schema.json +45 -0
- package/dist/schemas/wowok_buildin_info.output.json +1682 -844
- package/dist/schemas/wowok_buildin_info.schema.json +576 -526
- package/dist/tools/handlers/bridge.d.ts +8 -1
- package/dist/tools/handlers/bridge.js +1 -1
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/employee.d.ts +2 -0
- package/dist/tools/handlers/employee.js +1 -0
- package/dist/tools/handlers/evaluation.js +1 -1
- package/dist/tools/handlers/file-export.js +1 -1
- package/dist/tools/handlers/industry-pack.d.ts +2 -0
- package/dist/tools/handlers/industry-pack.js +1 -0
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/permission.d.ts +2 -0
- package/dist/tools/handlers/permission.js +1 -0
- package/dist/tools/handlers/persona.js +1 -1
- package/dist/tools/handlers/project.js +1 -1
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/handlers/schema-query.js +1 -1
- package/dist/tools/handlers/trust.js +1 -1
- package/dist/tools/handlers/wip.js +1 -1
- package/dist/tools/handlers/workflow.d.ts +2 -0
- package/dist/tools/handlers/workflow.js +1 -0
- package/dist/tools/handlers/workspace.d.ts +4 -0
- package/dist/tools/handlers/workspace.js +1 -0
- package/dist/tools/index.d.ts +2 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/rules-hook.d.ts +1 -1
- package/dist/tools/rules-hook.js +1 -1
- package/dist/tools/shared.d.ts +1 -1
- package/dist/tools/shared.js +1 -1
- package/dist/tools/types.d.ts +2 -1
- package/package.json +4 -5
- package/dist/knowledge/arbitration-trust.d.ts +0 -24
- package/dist/knowledge/arbitration-trust.js +0 -1
- package/dist/schema/call/bridge-handler.d.ts +0 -8
- package/dist/schema/call/bridge-handler.js +0 -1
- package/dist/schema/sync-layer4.d.ts +0 -21
- package/dist/schema/sync-layer4.js +0 -1
- /package/dist/{schema-query → schema-query-impl}/index.d.ts +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const TRAE_MCPS_ROOT = "c:\\Users\\zhou\\.trae-cn\\mcps";
|
|
2
2
|
export declare const GENERATED_SCHEMAS_DIR = "d:\\wowok\\agent\\mcp\\dist\\schemas";
|
|
3
3
|
export declare const MCP_SRC_SCHEMA_DIR = "d:\\wowok\\agent\\mcp\\src\\schema";
|
|
4
4
|
export declare const MCP_SRC_TOOLS_DIR = "d:\\wowok\\agent\\mcp\\src\\tools";
|
|
5
5
|
export declare const GENERATION_SCRIPT = "d:\\wowok\\agent\\mcp\\scripts\\generate-json-schemas.ts";
|
|
6
6
|
export declare const TOOLS_INDEX_FILE = "d:\\wowok\\agent\\mcp\\src\\tools\\index.ts";
|
|
7
|
-
export declare const MCP_SCHEMA_AUDIT_VERSION = "1.0
|
|
7
|
+
export declare const MCP_SCHEMA_AUDIT_VERSION = "2.1.0";
|
|
8
8
|
export interface ToolDescriptor {
|
|
9
9
|
name: string;
|
|
10
10
|
input_schema_export: string;
|
|
@@ -12,7 +12,7 @@ export interface ToolDescriptor {
|
|
|
12
12
|
}
|
|
13
13
|
export declare const ALL_TOOLS: readonly ToolDescriptor[];
|
|
14
14
|
export type FindingSeverity = 'critical' | 'high' | 'medium' | 'low' | 'info';
|
|
15
|
-
export type FindingCategory = 'layer_census' | '
|
|
15
|
+
export type FindingCategory = 'layer_census' | 'gateway_deployment' | 'layer_parity' | 'any_unknown' | 'handler_types' | 'output_coverage' | 'generation_sync' | 'reflection' | 'glossary_alignment';
|
|
16
16
|
export interface Finding {
|
|
17
17
|
rule_id: string;
|
|
18
18
|
severity: FindingSeverity;
|
|
@@ -37,20 +37,19 @@ export interface LayerCensus {
|
|
|
37
37
|
input_size_bytes: number;
|
|
38
38
|
output_size_bytes: number;
|
|
39
39
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
};
|
|
40
|
+
}
|
|
41
|
+
export interface Layer4GatewayInfo {
|
|
42
|
+
gateway_file: string;
|
|
43
|
+
file_exists: boolean;
|
|
44
|
+
gateway_name: string | null;
|
|
45
|
+
has_definitions: boolean;
|
|
46
|
+
definitions_count: number;
|
|
47
|
+
has_tool_field: boolean;
|
|
48
|
+
has_data_field: boolean;
|
|
49
|
+
is_strict: boolean;
|
|
50
|
+
has_schema_hint: boolean;
|
|
51
|
+
size_bytes: number;
|
|
52
|
+
all_mounts: string[];
|
|
54
53
|
}
|
|
55
54
|
export type AnyUnknownPattern = 'z.any()' | 'z.unknown()' | 'args: any' | 'Promise<any>' | 'Record<string, any>' | 'as any' | ': any' | '<any>';
|
|
56
55
|
export type AnyUnknownCategory = 'fixable' | 'legitimate' | 'external';
|
|
@@ -65,6 +64,7 @@ export interface AnyUnknownInstance {
|
|
|
65
64
|
}
|
|
66
65
|
export interface ScanResult {
|
|
67
66
|
census: LayerCensus[];
|
|
67
|
+
gateway: Layer4GatewayInfo;
|
|
68
68
|
findings: Finding[];
|
|
69
69
|
any_unknown_instances: AnyUnknownInstance[];
|
|
70
70
|
findings_by_severity: Map<FindingSeverity, Finding[]>;
|
|
@@ -73,18 +73,18 @@ export interface ScanResult {
|
|
|
73
73
|
fixable_any_count: number;
|
|
74
74
|
legitimate_any_count: number;
|
|
75
75
|
external_any_count: number;
|
|
76
|
-
stub_count: number;
|
|
77
|
-
full_schema_count: number;
|
|
78
76
|
}
|
|
79
|
-
export declare function
|
|
77
|
+
export declare function discoverDeployedGatewayMounts(): string[];
|
|
78
|
+
export declare function loadLayer4Gateway(): Layer4GatewayInfo;
|
|
80
79
|
export declare function loadLayer3Generated(toolName: string): LayerCensus['layer3_generated'];
|
|
81
80
|
export declare function analyzeLayerCensus(): LayerCensus[];
|
|
82
|
-
export declare function
|
|
83
|
-
export declare function
|
|
81
|
+
export declare function analyzeGatewayDeployment(gateway: Layer4GatewayInfo): Finding[];
|
|
82
|
+
export declare function analyzeGatewayDispatchContract(gateway: Layer4GatewayInfo): Finding[];
|
|
84
83
|
export declare function analyzeAnyUnknownCensus(): AnyUnknownInstance[];
|
|
85
84
|
export declare function analyzeHandlerTypeSafety(instances: AnyUnknownInstance[]): Finding[];
|
|
86
85
|
export declare function analyzeOutputSchemaCoverage(census: LayerCensus[]): Finding[];
|
|
87
86
|
export declare function analyzeGenerationScriptSync(): Finding[];
|
|
88
87
|
export declare function analyzeSchemaQueryReflection(census: LayerCensus[]): Finding[];
|
|
88
|
+
export declare function analyzeGlossaryAlignment(): Finding[];
|
|
89
89
|
export declare function scanAllMcpSchemas(): ScanResult;
|
|
90
90
|
export declare function formatAuditReport(result: ScanResult): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as a116a from'fs';import*as a116b from'path';export const DEPLOYED_TOOLS_DIR='c:\x5cUsers\x5czhou\x5c.trae-cn\x5cmcps\x5cs_wowok-7838e181\x5csolo_agent\x5cmcp_wagent\x5ctools';export const GENERATED_SCHEMAS_DIR='d:\x5cwowok\x5cagent\x5cmcp\x5cdist\x5cschemas';export const MCP_SRC_SCHEMA_DIR='d:\x5cwowok\x5cagent\x5cmcp\x5csrc\x5cschema';export const MCP_SRC_TOOLS_DIR='d:\x5cwowok\x5cagent\x5cmcp\x5csrc\x5ctools';export const GENERATION_SCRIPT='d:\x5cwowok\x5cagent\x5cmcp\x5cscripts\x5cgenerate-json-schemas.ts';export const TOOLS_INDEX_FILE='d:\x5cwowok\x5cagent\x5cmcp\x5csrc\x5ctools\x5cindex.ts';export const MCP_SCHEMA_AUDIT_VERSION='1.0.0';export const ALL_TOOLS=[{'name':'onchain_operations','input_schema_export':'OnchainOperationsSchema','output_schema_export':'CallOutputSchema'},{'name':'account_operation','input_schema_export':'AccountOperationSchema','output_schema_export':'AccountOperationOutputWrappedSchema'},{'name':'local_mark_operation','input_schema_export':'LocalMarkOperationSchema','output_schema_export':'LocalMarkOperationOutputWrappedSchema'},{'name':'local_info_operation','input_schema_export':'LocalInfoOperationSchema','output_schema_export':'LocalInfoOperationOutputWrappedSchema'},{'name':'wip_file','input_schema_export':'WipOperationsSchema','output_schema_export':'WipOperationOutputSchema'},{'name':'messenger_operation','input_schema_export':'MessengerOperationInputSchema','output_schema_export':'MessengerOperationOutputSchema'},{'name':'guard2file','input_schema_export':'Guard2File_InputSchema','output_schema_export':'Guard2File_OutputWrappedSchema'},{'name':'machineNode2file','input_schema_export':'MachineNode2File_InputSchema','output_schema_export':'MachineNode2File_OutputWrappedSchema'},{'name':'query_toolkit','input_schema_export':'WatchQueryOperationsSchema','output_schema_export':'WatchQueryOperationsResultSchema'},{'name':'onchain_table_data','input_schema_export':'OnchainTableDataSchema','output_schema_export':'OnchainTableDataResultSchema'},{'name':'onchain_events','input_schema_export':'OnchainEventsInputSchema','output_schema_export':'OnchainEventsResultSchema'},{'name':'wowok_buildin_info','input_schema_export':'ProtocolInfoQuerySchema','output_schema_export':'ProtocolInfoResultSchema'},{'name':'schema_query','input_schema_export':'SchemaQueryInputSchema','output_schema_export':'SchemaQueryOutputSchema'},{'name':'bridge_operation','input_schema_export':'BridgeOperationsSchema','output_schema_export':'BridgeCallOutputSchema'},{'name':'project_operation','input_schema_export':'ProjectOperationInputSchema','output_schema_export':'ProjectOperationOutputSchema'},{'name':'config_operation','input_schema_export':'ConfigOperationInputSchema','output_schema_export':'ConfigOperationOutputSchema'},{'name':'trust_score','input_schema_export':'TrustScoreInputSchema','output_schema_export':'TrustScoreOutputSchema'},{'name':'query_task_status','input_schema_export':'QueryTaskStatusInputSchema','output_schema_export':'QueryTaskStatusOutputSchema'},{'name':'evaluation_operation','input_schema_export':'EvaluationOperationInputSchema','output_schema_export':'EvaluationOperationOutputSchema'},{'name':'persona_operation','input_schema_export':'PersonaOperationInputSchema','output_schema_export':'PersonaOperationOutputSchema'},{'name':'intent_radar','input_schema_export':'IntentRadarInputSchema','output_schema_export':'IntentRadarOutputSchema'}];export function loadLayer4Deployed(a){const b=a116b['join'](DEPLOYED_TOOLS_DIR,a+'.json'),c={'tool_descriptor_file':b,'file_exists':![],'is_stub':!![],'properties_count':0x0,'required_count':0x0,'has_schema_hint':![],'has_additional_properties_false':![],'has_dollar_schema':![],'has_oneof':![],'has_anyof':![],'has_allof':![],'union_count':0x0};if(!a116a['existsSync'](b))return c;try{const d=a116a['readFileSync'](b,'utf-8'),e=JSON['parse'](d),f=e['arguments']??{},g=f['properties']??{},h=f['required']??[],i=Object['keys'](g),j=f['oneOf']??[],k=f['anyOf']??[],l=f['allOf']??[],m=j['length']>0x0,n=k['length']>0x0,o=l['length']>0x0,p=j['length']+k['length']+l['length'],q=i['length']===0x0&&p===0x0,r=e['description']??'',s=r['includes']('schema_query');return{'tool_descriptor_file':b,'file_exists':!![],'is_stub':q,'properties_count':i['length'],'required_count':h['length'],'has_schema_hint':s,'has_additional_properties_false':f['additionalProperties']===![],'has_dollar_schema':!!f['$schema'],'has_oneof':m,'has_anyof':n,'has_allof':o,'union_count':p};}catch{return c;}}export function loadLayer3Generated(a){const b=a116b['join'](GENERATED_SCHEMAS_DIR,a+'.schema.json'),c=a116b['join'](GENERATED_SCHEMAS_DIR,a+'.output.json'),d=a116a['existsSync'](b),e=a116a['existsSync'](c),f=d?a116a['statSync'](b)['size']:0x0,g=e?a116a['statSync'](c)['size']:0x0;return{'input_schema_file':b,'output_schema_file':c,'input_exists':d,'output_exists':e,'input_size_bytes':f,'output_size_bytes':g};}export function analyzeLayerCensus(){const a=[];for(const b of ALL_TOOLS){a['push']({'name':b['name'],'layer2_zod':{'input_schema_export':b['input_schema_export'],'output_schema_export':b['output_schema_export'],'schema_dir':MCP_SRC_SCHEMA_DIR},'layer3_generated':loadLayer3Generated(b['name']),'layer4_deployed':loadLayer4Deployed(b['name'])??{}});}return a;}export function analyzeDeployedStubInconsistency(a){const b=[],d=[],e=[];for(const f of a){if(!f['layer4_deployed']['file_exists']){b['push']({'rule_id':'MCP-DEPLOY-001','severity':'critical','category':'stub_inconsistency','tool_name':f['name'],'description':'Layer\x204\x20deployed\x20file\x20does\x20not\x20exist:\x20'+f['layer4_deployed']['tool_descriptor_file'],'location':f['layer4_deployed']['tool_descriptor_file'],'fix':'Create\x20'+f['name']+'.json\x20in\x20DEPLOYED_TOOLS_DIR\x20matching\x20the\x20Layer\x203\x20generated\x20schema.'});continue;}f['layer4_deployed']['is_stub']?d['push'](f):e['push'](f);}for(const g of d){b['push']({'rule_id':'MCP-STUB-001','severity':'high','category':'stub_inconsistency','tool_name':g['name'],'description':'Layer\x204\x20deployed\x20file\x20is\x20a\x20STUB\x20(empty\x20properties:{})\x20—\x20LLM\x20must\x20call\x20schema_query(action=\x27get\x27,\x20name=\x27'+g['name']+'\x27)\x20to\x20learn\x20the\x20parameter\x20structure.\x20This\x20is\x20inconsistent\x20with\x20the\x20'+e['length']+'\x20tools\x20that\x20embed\x20full\x20schemas.','location':g['layer4_deployed']['tool_descriptor_file'],'fix':'Regenerate\x20'+g['name']+'.json\x20from\x20dist/schemas/'+g['name']+'.schema.json\x20(resolve\x20$ref,\x20inline\x20definitions,\x20wrap\x20as\x20{name,\x20description,\x20arguments}).'}),!g['layer4_deployed']['has_schema_hint']&&b['push']({'rule_id':'MCP-STUB-003','severity':'high','category':'stub_inconsistency','tool_name':g['name'],'description':'Stub\x20file\x20is\x20missing\x20schema_query\x20hint\x20in\x20description\x20—\x20the\x20LLM\x20has\x20no\x20way\x20to\x20discover\x20the\x20parameter\x20structure.\x20Description\x20should\x20mention\x20schema_query(action=\x27get\x27,\x20name=\x27'+g['name']+'\x27).','location':g['layer4_deployed']['tool_descriptor_file'],'fix':'Add\x20\x22💡\x20Schema\x20hint:\x20Use\x20schema_query\x20with\x20action=\x27get\x27\x20and\x20name=\x27'+g['name']+'\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema\x20before\x20calling.\x22\x20to\x20the\x20description.'});}return d['length']>0x0&&e['length']>0x0&&b['push']({'rule_id':'MCP-STUB-002','severity':'info','category':'stub_inconsistency','tool_name':'(all)','description':'Layer\x204\x20deployed\x20files\x20are\x20INCONSISTENT:\x20'+d['length']+'\x20stubs\x20+\x20'+e['length']+'\x20full\x20schemas.\x20Stubs:\x20'+d['map'](h=>h['name'])['join'](',\x20')+'.\x20Full:\x20'+e['map'](h=>h['name'])['join'](',\x20')+'.','fix':'Make\x20all\x2017\x20files\x20consistent\x20—\x20either\x20(a)\x20embed\x20full\x20schemas\x20in\x20all\x2017\x20(RECOMMENDED\x20—\x20gives\x20LLM\x20immediate\x20access),\x20or\x20(b)\x20keep\x20all\x20stubs\x20and\x20rely\x20on\x20schema_query\x20(increases\x20token\x20cost\x20+\x20latency).'}),b;}export function analyzeLayerParity(a){const b=[];for(const d of a){if(!d['layer4_deployed']['file_exists']||d['layer4_deployed']['is_stub'])continue;if(!d['layer3_generated']['input_exists']){b['push']({'rule_id':'MCP-PARITY-001','severity':'critical','category':'layer_parity','tool_name':d['name'],'description':'Layer\x204\x20has\x20full\x20schema\x20but\x20Layer\x203\x20generated\x20file\x20is\x20missing:\x20'+d['layer3_generated']['input_schema_file'],'fix':'Run\x20pnpm\x20generate:schemas\x20to\x20regenerate\x20Layer\x203\x20from\x20Zod\x20source.'});continue;}const e=readLayer4Arguments(d['name']),f=readLayer3ResolvedSchema(d['name']);if(!e||!f)continue;const g=new Set(Object['keys'](e['properties']??{})),h=new Set(Object['keys'](f['properties']??{})),i=[...h]['filter'](q=>!g['has'](q)),j=[...g]['filter'](q=>!h['has'](q));i['length']>0x0&&b['push']({'rule_id':'MCP-PARITY-002','severity':'high','category':'layer_parity','tool_name':d['name'],'description':'Layer\x204\x20deployed\x20schema\x20is\x20missing\x20'+i['length']+'\x20properties\x20present\x20in\x20Layer\x203\x20generated\x20schema:\x20'+i['join'](',\x20'),'location':d['layer4_deployed']['tool_descriptor_file'],'fix':'Regenerate\x20'+d['name']+'.json\x20from\x20dist/schemas/'+d['name']+'.schema.json.'});j['length']>0x0&&b['push']({'rule_id':'MCP-PARITY-003','severity':'medium','category':'layer_parity','tool_name':d['name'],'description':'Layer\x204\x20deployed\x20schema\x20has\x20'+j['length']+'\x20extra\x20properties\x20not\x20in\x20Layer\x203:\x20'+j['join'](',\x20'),'location':d['layer4_deployed']['tool_descriptor_file'],'fix':'Regenerate\x20'+d['name']+'.json\x20from\x20dist/schemas/'+d['name']+'.schema.json.'});const k=new Set(e['required']??[]),l=new Set(f['required']??[]),m=[...l]['filter'](q=>!k['has'](q)),n=[...k]['filter'](q=>!l['has'](q));(m['length']>0x0||n['length']>0x0)&&b['push']({'rule_id':'MCP-PARITY-004','severity':'high','category':'layer_parity','tool_name':d['name'],'description':'Layer\x204\x20\x27required\x27\x20array\x20differs\x20from\x20Layer\x203.\x20Missing\x20in\x20L4:\x20['+m['join'](',\x20')+'].\x20Extra\x20in\x20L4:\x20['+n['join'](',\x20')+'].','location':d['layer4_deployed']['tool_descriptor_file'],'fix':'Sync\x20\x27required\x27\x20array\x20from\x20Layer\x203\x20to\x20Layer\x204.'});const o=e['additionalProperties'],p=f['additionalProperties'];o!==p&&b['push']({'rule_id':'MCP-PARITY-005','severity':'medium','category':'layer_parity','tool_name':d['name'],'description':'Layer\x204\x20\x27additionalProperties\x27\x20('+JSON['stringify'](o)+')\x20differs\x20from\x20Layer\x203\x20('+JSON['stringify'](p)+').','location':d['layer4_deployed']['tool_descriptor_file'],'fix':'Sync\x20\x27additionalProperties\x27\x20value.'});}return b;}function readLayer4Arguments(a){const b=a116b['join'](DEPLOYED_TOOLS_DIR,a+'.json');try{const c=a116a['readFileSync'](b,'utf-8'),d=JSON['parse'](c);return d['arguments']??null;}catch{return null;}}function readLayer3ResolvedSchema(a){const b=a116b['join'](GENERATED_SCHEMAS_DIR,a+'.schema.json');try{const c=a116a['readFileSync'](b,'utf-8'),d=JSON['parse'](c);if(d['$ref']&&d['$ref']['startsWith']('#/definitions/')){const e=d['$ref']['slice']('#/definitions/'['length']),f=d['definitions']?.[e];if(f&&typeof f==='object')return f;}return d;}catch{return null;}}export function analyzeAnyUnknownCensus(){const a=[],b=[MCP_SRC_SCHEMA_DIR,MCP_SRC_TOOLS_DIR];for(const c of b){const d=listTypeScriptFiles(c);for(const e of d){const f=a116a['readFileSync'](e,'utf-8')['split']('\x0a');for(let g=0x0;g<f['length'];g++){const h=f[g],j=h['trim']();if(j['startsWith']('//')||j['startsWith']('*'))continue;const k=[{'regex':/z\.any\(\)/g,'pattern':'z.any()'},{'regex':/z\.unknown\(\)/g,'pattern':'z.unknown()'},{'regex':/args\s*:\s*any\b/g,'pattern':'args:\x20any'},{'regex':/Promise\s*<\s*any\s*>/g,'pattern':'Promise<any>'},{'regex':/Record\s*<\s*string\s*,\s*any\s*>/g,'pattern':'Record<string,\x20any>'},{'regex':/\bas\s+any\b/g,'pattern':'as\x20any'}];for(const {regex:l,pattern:n}of k){l['lastIndex']=0x0;let o;while((o=l['exec'](h))!==null){const p=categorizeAnyInstance(e,g+0x1,h,n);a['push']({'file':e,'line':g+0x1,'code':j['length']>0x78?j['slice'](0x0,0x75)+'...':j,'pattern':n,'category':p['category'],'reason':p['reason'],'fix_suggestion':p['fix']});}}}}}return a;}function listTypeScriptFiles(a){const b=[];if(!a116a['existsSync'](a))return b;const c=a116a['readdirSync'](a,{'withFileTypes':!![]});for(const d of c){const e=a116b['join'](a,d['name']);if(d['isDirectory']()){if(d['name']==='__tests__'||d['name']==='node_modules')continue;b['push'](...listTypeScriptFiles(e));}else d['isFile']()&&d['name']['endsWith']('.ts')&&b['push'](e);}return b;}function categorizeAnyInstance(a,b,c,d){const e=a116b['basename'](a),f=c['trim']();if(d==='z.any()'&&/SemanticSummarySchema\s*=\s*z\.any\(\)/['test'](f))return{'category':'fixable','reason':'Circular-dependency\x20workaround\x20for\x20SemanticSummarySchema\x20—\x20can\x20use\x20z.lazy()\x20or\x20refactor\x20to\x20break\x20the\x20cycle.','fix':'Define\x20SemanticSummarySchema\x20with\x20z.lazy(()\x20=>\x20SemanticSummarySchemaReal)\x20or\x20restructure\x20imports\x20to\x20break\x20the\x20cycle.'};if(d==='z.any()'&&/result\s*:\s*z\.any\(\)/['test'](f)&&/[\\/]config[\\/]|[\\/]project[\\/]/['test'](a))return{'category':'fixable','reason':'Result\x20shape\x20depends\x20on\x20action\x20—\x20can\x20use\x20z.discriminatedUnion(\x27action\x27,\x20[...])\x20to\x20type\x20each\x20action\x27s\x20result.','fix':'Define\x20discriminated\x20union:\x20z.discriminatedUnion(\x27action\x27,\x20[z.object({action:\x20z.literal(\x27list\x27),\x20result:\x20...}),\x20...]).'};if(d==='z.unknown()'&&/result\s*:\s*z\.unknown\(\)/['test'](f)&&/index\.ts/['test'](e))return{'category':'fixable','reason':'query_toolkit\x20output\x20result\x20depends\x20on\x20query_type\x20—\x20can\x20use\x20z.discriminatedUnion(\x27query_type\x27,\x20[...]).','fix':'Define\x20discriminated\x20union:\x20z.discriminatedUnion(\x27query_type\x27,\x20[z.object({query_type:\x20z.literal(\x27local_mark_list\x27),\x20result:\x20z.array(MarkDataSchema)}),\x20...]).'};if(d==='z.any()'&&/data\s*:\s*z\.any\(\)/['test'](f)&&/[\\/]schema-query[\\/]/['test'](a))return{'category':'fixable','reason':'SchemaQuery\x20output\x20data\x20depends\x20on\x20action\x20—\x20can\x20use\x20discriminated\x20union\x20by\x20action.','fix':'Define\x20discriminated\x20union:\x20action=\x27get\x27\x20returns\x20JSON\x20Schema,\x20action=\x27list\x27\x20returns\x20array\x20of\x20items.'};if(d==='args:\x20any'&&/handlers[\\/]/['test'](a))return{'category':'fixable','reason':'Handler\x20args\x20can\x20use\x20`unknown`\x20(forces\x20runtime\x20validation)\x20or\x20a\x20typed\x20input\x20schema.','fix':'Replace\x20`args:\x20any`\x20with\x20`args:\x20unknown`\x20and\x20use\x20strictParse(schema,\x20args)\x20at\x20the\x20top\x20of\x20the\x20handler.'};if(d==='args:\x20any'&&/tools[\\/]index\.ts/['test'](a))return{'category':'fixable','reason':'dispatchToolCall\x20args\x20is\x20`any`\x20—\x20can\x20be\x20`unknown`\x20since\x20each\x20tool\x20parses\x20with\x20its\x20own\x20schema.','fix':'Change\x20`args:\x20any`\x20to\x20`args:\x20unknown`\x20in\x20dispatchToolCall\x20signature.'};if(d==='args:\x20any'&&/types\.ts/['test'](e)&&/handler/['test'](f))return{'category':'fixable','reason':'ToolEntry.handler\x20args\x20is\x20`any`\x20—\x20can\x20be\x20`unknown`\x20(each\x20handler\x20parses\x20with\x20its\x20own\x20schema).','fix':'Change\x20`handler:\x20(args:\x20any)\x20=>\x20...`\x20to\x20`handler:\x20(args:\x20unknown)\x20=>\x20...`.'};if(d==='z.any()'&&/claimReceipt|ethReceipt|wowReceipt/['test'](f))return{'category':'legitimate','reason':'EVM\x20transaction\x20receipts\x20have\x20an\x20externally-defined\x20shape\x20from\x20viem/ethers\x20—\x20z.any()\x20is\x20acceptable\x20(receipt\x20is\x20informational,\x20not\x20validated).'};if(d==='z.any()'&&/content_raw/['test'](f))return{'category':'legitimate','reason':'content_raw\x20holds\x20raw\x20content\x20for\x20unknown\x20object\x20types\x20—\x20by\x20definition\x20untyped.\x20z.any()\x20is\x20acceptable\x20here.'};if((d==='z.unknown()'||d==='z.any()')&&/parsedJson/['test'](f))return{'category':'legitimate','reason':'Event\x20parsedJson\x20is\x20arbitrary\x20on-chain\x20event\x20data\x20—\x20z.record(z.string(),\x20z.unknown())\x20is\x20appropriate.'};if(d==='z.any()'&&/key_value/['test'](f))return{'category':'fixable','reason':'Repository\x20key_value\x20depends\x20on\x20key_type\x20—\x20could\x20use\x20discriminated\x20union\x20by\x20key_type\x20(string→z.string(),\x20u64→z.bigint()/number,\x20etc.).','fix':'Define\x20z.discriminatedUnion(\x27key_type\x27,\x20[...])\x20with\x20each\x20variant\x20typed.'};if(d==='z.unknown()'&&/data\s*:\s*z\.unknown\(\)/['test'](f)&&/[\\/]bridge/['test'](a))return{'category':'legitimate','reason':'Bridge\x20operation\x20result\x20data\x20varies\x20by\x20operation_type\x20—\x20currently\x209\x20different\x20shapes.\x20Discriminated\x20union\x20would\x20be\x20ideal\x20but\x20high\x20refactor\x20cost.'};if(d==='z.unknown()'&&/adjusted_params/['test'](f))return{'category':'legitimate','reason':'adjusted_params\x20are\x20free-form\x20key-value\x20pairs\x20suggested\x20by\x20AI\x20—\x20z.record(z.string(),\x20z.unknown())\x20is\x20appropriate.'};if(d==='z.any()'&&/object\s*:\s*z\.union.*z\.record\(z\.any\(\)/['test'](f))return{'category':'fixable','reason':'Creation\x20vs\x20reference\x20object\x20union\x20—\x20z.record(z.any())\x20should\x20be\x20replaced\x20with\x20NamedObjectSchema\x20(structured\x20creation\x20input).','fix':'Replace\x20z.record(z.any())\x20with\x20NamedObjectSchema\x20(already\x20defined\x20in\x20base.ts).'};if(d==='z.any()'&&/result\s*:\s*z\.any\(\)\.optional\(\)/['test'](f)&&/[\\/]bridge/['test'](a))return{'category':'legitimate','reason':'Bridge\x20result\x20is\x20operation-specific\x20(manage_evm_rpc\x20has\x20different\x20result\x20per\x20operation)\x20—\x20z.any().optional()\x20is\x20acceptable\x20here.'};if(d==='Promise<any>'&&/[\\/](wrap|shared)\.ts/['test'](a))return{'category':'fixable','reason':'Generic\x20wrappers\x20in\x20wrap.ts/shared.ts\x20use\x20Promise<any>\x20—\x20could\x20be\x20made\x20generic\x20<T>.','fix':'Replace\x20`Promise<any>`\x20with\x20`Promise<ToolDispatchResult>`\x20(the\x20actual\x20return\x20shape).'};if(d==='Record<string,\x20any>'&&/types\.ts/['test'](e)&&/_meta|structuredContent/['test'](f))return{'category':'fixable','reason':'ToolConfig._meta\x20and\x20ToolDispatchResult.structuredContent\x20could\x20use\x20structured\x20types.','fix':'Define\x20ToolMeta\x20interface\x20(category,\x20tags)\x20and\x20replace\x20structuredContent:\x20any\x20with\x20structured\x20type.'};if(d==='as\x20any')return{'category':'legitimate','reason':'`as\x20any`\x20cast\x20—\x20usually\x20for\x20third-party\x20type\x20mismatches\x20(MCP\x20SDK).\x20Acceptable\x20if\x20isolated.'};return{'category':'legitimate','reason':'Unclassified\x20any/unknown\x20usage\x20—\x20review\x20manually.\x20Defaulting\x20to\x20legitimate\x20(no\x20auto-fix).'};}export function analyzeHandlerTypeSafety(a){const b=[];for(const c of a){if(c['pattern']!=='args:\x20any')continue;if(!/tools[\\/]/['test'](c['file']))continue;b['push']({'rule_id':'MCP-HANDLER-001','severity':'medium','category':'handler_types','tool_name':a116b['basename'](c['file'],'.ts'),'description':'Handler\x20uses\x20`args:\x20any`\x20—\x20bypasses\x20TypeScript\x20type\x20checking.\x20'+c['reason'],'location':c['file']+':'+c['line'],'fix':c['fix_suggestion']});}return b;}export function analyzeOutputSchemaCoverage(a){const b=[];for(const d of a){!d['layer3_generated']['output_exists']&&d['name']!=='onchain_operations'&&b['push']({'rule_id':'MCP-OUTPUT-001','severity':'high','category':'output_coverage','tool_name':d['name'],'description':'Layer\x203\x20output\x20schema\x20file\x20does\x20not\x20exist:\x20'+d['layer3_generated']['output_schema_file'],'fix':'Add\x20outputSchema\x20to\x20'+d['name']+'\x27s\x20tool\x20definition\x20and\x20regenerate\x20schemas.'}),d['layer2_zod']['output_schema_export']===null&&b['push']({'rule_id':'MCP-OUTPUT-002','severity':'medium','category':'output_coverage','tool_name':d['name'],'description':'Layer\x202\x20outputSchema\x20is\x20defined\x20inline\x20(not\x20exported\x20with\x20a\x20stable\x20name).\x20This\x20makes\x20it\x20harder\x20to\x20reference\x20from\x20tests.','fix':'Export\x20the\x20outputSchema\x20with\x20a\x20stable\x20name\x20(e.g.,\x20'+d['name']+'OutputSchema).'});}return b;}export function analyzeGenerationScriptSync(){const a=[];if(!a116a['existsSync'](GENERATION_SCRIPT))return a['push']({'rule_id':'MCP-GENSYNC-001','severity':'critical','category':'generation_sync','tool_name':'(all)','description':'Generation\x20script\x20not\x20found:\x20'+GENERATION_SCRIPT}),a;const b=a116a['readFileSync'](GENERATION_SCRIPT,'utf-8'),c=/name:\s*["']([^"']+)["']/g,d=new Set();let e;while((e=c['exec'](b))!==null){ALL_TOOLS['some'](f=>f['name']===e[0x1])&&d['add'](e[0x1]);}for(const f of ALL_TOOLS){!d['has'](f['name'])&&a['push']({'rule_id':'MCP-GENSYNC-002','severity':'high','category':'generation_sync','tool_name':f['name'],'description':'Tool\x20\x22'+f['name']+'\x22\x20is\x20in\x20TOOL_REGISTRY\x20but\x20missing\x20from\x20generate-json-schemas.ts.\x20Layer\x203\x20schemas\x20will\x20not\x20be\x20generated.','location':GENERATION_SCRIPT,'fix':'Add\x20a\x20get'+toPascalCase(f['name'])+'Tool()\x20function\x20and\x20add\x20it\x20to\x20the\x20tools\x20array.'});}return a;}function toPascalCase(a){return a['split']('_')['map'](b=>b['charAt'](0x0)['toUpperCase']()+b['slice'](0x1)['toLowerCase']())['join']('');}export function analyzeSchemaQueryReflection(a){const b=[];for(const e of a){!e['layer3_generated']['input_exists']&&b['push']({'rule_id':'MCP-REFLECT-001','severity':'high','category':'reflection','tool_name':e['name'],'description':'schema_query(action=\x27get\x27,\x20name=\x27'+e['name']+'\x27)\x20would\x20fail\x20—\x20Layer\x203\x20input\x20schema\x20missing.','fix':'Run\x20pnpm\x20generate:schemas.'}),!e['layer3_generated']['output_exists']&&e['name']!=='onchain_operations'&&b['push']({'rule_id':'MCP-REFLECT-002','severity':'medium','category':'reflection','tool_name':e['name'],'description':'schema_query(action=\x27get_output\x27,\x20name=\x27'+e['name']+'\x27)\x20would\x20fail\x20—\x20Layer\x203\x20output\x20schema\x20missing.','fix':'Run\x20pnpm\x20generate:schemas.'});}const d=['permission','service','machine','progress','guard','arbitration','repository','contact','treasury','reward','allocation','personal','payment','demand','order','gen_passport','proof','gen_proof'];for(const f of d){const g=a116b['join'](GENERATED_SCHEMAS_DIR,'onchain_operations_'+f+'.schema.json');!a116a['existsSync'](g)&&b['push']({'rule_id':'MCP-REFLECT-003','severity':'medium','category':'reflection','tool_name':'onchain_operations_'+f,'description':'Individual\x20operation\x20schema\x20missing:\x20'+g+'.\x20schema_query(action=\x27get\x27,\x20name=\x27onchain_operations_'+f+'\x27)\x20would\x20fail.','fix':'Run\x20pnpm\x20generate:schemas.'});}return b;}export function scanAllMcpSchemas(){const a=analyzeLayerCensus(),b=analyzeAnyUnknownCensus(),c=[...analyzeDeployedStubInconsistency(a),...analyzeLayerParity(a),...analyzeHandlerTypeSafety(b),...analyzeOutputSchemaCoverage(a),...analyzeGenerationScriptSync(),...analyzeSchemaQueryReflection(a)],d=new Map(),e=new Map();for(const l of c){if(!d['has'](l['severity']))d['set'](l['severity'],[]);d['get'](l['severity'])['push'](l);if(!e['has'](l['category']))e['set'](l['category'],[]);e['get'](l['category'])['push'](l);}const g=b['filter'](m=>m['category']==='fixable')['length'],h=b['filter'](m=>m['category']==='legitimate')['length'],i=b['filter'](m=>m['category']==='external')['length'],j=a['filter'](m=>m['layer4_deployed']['is_stub'])['length'],k=a['filter'](m=>!m['layer4_deployed']['is_stub']&&m['layer4_deployed']['file_exists'])['length'];return{'census':a,'findings':c,'any_unknown_instances':b,'findings_by_severity':d,'findings_by_category':e,'total_findings':c['length'],'fixable_any_count':g,'legitimate_any_count':h,'external_any_count':i,'stub_count':j,'full_schema_count':k};}export function formatAuditReport(a){const b=[];b['push']('#\x20MCP\x20Schema\x20Audit\x20Report\x20—\x2017\x20WoWok\x20Tools'),b['push'](''),b['push']('>\x20Auto-generated\x20by\x20`mcp-schema-audit.ts`\x20v'+MCP_SCHEMA_AUDIT_VERSION+'\x20—\x20comprehensive'),b['push']('>\x204-layer\x20audit\x20of\x20schema\x20consistency,\x20any/unknown\x20usage,\x20and\x20I/O\x20coverage.'),b['push'](''),b['push']('##\x20Summary'),b['push'](''),b['push']('-\x20**Tools\x20audited**:\x20'+a['census']['length']),b['push']('-\x20**Total\x20findings**:\x20'+a['total_findings']),b['push']('-\x20**Stub\x20files**:\x20'+a['stub_count']+'\x20/\x20'+a['census']['length']),b['push']('-\x20**Full\x20schema\x20files**:\x20'+a['full_schema_count']+'\x20/\x20'+a['census']['length']),b['push']('-\x20**any/unknown\x20instances**:\x20'+a['any_unknown_instances']['length']+'\x20total'),b['push']('\x20\x20-\x20Fixable:\x20'+a['fixable_any_count']),b['push']('\x20\x20-\x20Legitimate:\x20'+a['legitimate_any_count']),b['push']('\x20\x20-\x20External:\x20'+a['external_any_count']),b['push'](''),b['push']('###\x20Findings\x20by\x20Severity'),b['push'](''),b['push']('|\x20Severity\x20|\x20Count\x20|'),b['push']('|----------|-------|');for(const h of['critical','high','medium','low','info']){const i=a['findings_by_severity']['get'](h)??[];b['push']('|\x20'+h+'\x20|\x20'+i['length']+'\x20|');}b['push'](''),b['push']('###\x20Findings\x20by\x20Category'),b['push'](''),b['push']('|\x20Category\x20|\x20Count\x20|'),b['push']('|----------|-------|');for(const j of['stub_inconsistency','layer_parity','handler_types','output_coverage','generation_sync','reflection']){const k=a['findings_by_category']['get'](j)??[];b['push']('|\x20'+j+'\x20|\x20'+k['length']+'\x20|');}b['push'](''),b['push']('##\x20Layer\x20Census\x20—\x20All\x2017\x20Tools'),b['push'](''),b['push']('|\x20Tool\x20|\x20L3\x20Input\x20|\x20L3\x20Output\x20|\x20L4\x20Status\x20|\x20L4\x20Properties\x20|\x20L4\x20Required\x20|'),b['push']('|------|----------|-----------|-----------|---------------|-------------|');for(const l of a['census']){const m=l['layer3_generated']['input_exists']?'✓\x20'+(l['layer3_generated']['input_size_bytes']/0x400)['toFixed'](0x1)+'KB':'✗\x20MISSING',n=l['layer3_generated']['output_exists']?'✓\x20'+(l['layer3_generated']['output_size_bytes']/0x400)['toFixed'](0x1)+'KB':'✗\x20MISSING',o=!l['layer4_deployed']['file_exists']?'✗\x20MISSING':l['layer4_deployed']['is_stub']?'⚠\x20STUB':'✓\x20FULL',p=l['layer4_deployed']['properties_count'],q=l['layer4_deployed']['required_count'];b['push']('|\x20'+l['name']+'\x20|\x20'+m+'\x20|\x20'+n+'\x20|\x20'+o+'\x20|\x20'+p+'\x20|\x20'+q+'\x20|');}b['push'](''),b['push']('##\x20Findings\x20Detail'),b['push']('');const d=['critical','high','medium','low','info'];for(const r of d){const s=a['findings_by_severity']['get'](r)??[];if(s['length']===0x0)continue;const t=r['toUpperCase']();b['push']('###\x20'+t+'\x20('+s['length']+')'),b['push']('');for(const u of s){b['push']('-\x20**['+u['rule_id']+']\x20'+u['description']);if(u['location'])b['push']('\x20\x20-\x20Location:\x20`'+u['location']+'`');if(u['fix'])b['push']('\x20\x20-\x20Fix:\x20'+u['fix']);b['push']('');}}b['push']('##\x20any/unknown\x20Census\x20Detail'),b['push'](''),b['push']('Total\x20instances:\x20'+a['any_unknown_instances']['length']),b['push'](''),b['push']('###\x20By\x20Pattern'),b['push'](''),b['push']('|\x20Pattern\x20|\x20Total\x20|\x20Fixable\x20|\x20Legitimate\x20|\x20External\x20|'),b['push']('|---------|-------|---------|------------|----------|');const e=new Map();for(const v of a['any_unknown_instances']){if(!e['has'](v['pattern']))e['set'](v['pattern'],[]);e['get'](v['pattern'])['push'](v);}for(const [w,x]of[...e['entries']()]['sort']((y,z)=>z[0x1]['length']-y[0x1]['length'])){const y=x['filter'](B=>B['category']==='fixable')['length'],z=x['filter'](B=>B['category']==='legitimate')['length'],A=x['filter'](B=>B['category']==='external')['length'];b['push']('|\x20`'+w+'`\x20|\x20'+x['length']+'\x20|\x20'+y+'\x20|\x20'+z+'\x20|\x20'+A+'\x20|');}b['push']('');const g=a['any_unknown_instances']['filter'](B=>B['category']==='fixable');if(g['length']>0x0){b['push']('###\x20Fixable\x20Instances\x20(Priority\x20List)'),b['push']('');for(const B of g){b['push']('-\x20**'+a116b['basename'](B['file'])+':'+B['line']+'**\x20[`'+B['pattern']+'`]'),b['push']('\x20\x20-\x20Code:\x20`'+B['code']+'`'),b['push']('\x20\x20-\x20Reason:\x20'+B['reason']);if(B['fix_suggestion'])b['push']('\x20\x20-\x20Fix:\x20'+B['fix_suggestion']);b['push']('');}}return b['push']('##\x20Recommended\x20Action\x20Plan'),b['push'](''),b['push']('###\x20Phase\x201:\x20Fix\x20Layer\x204\x20Stub\x20Inconsistency\x20(CRITICAL\x20UX)'),b['push'](''),b['push']('The\x20'+a['stub_count']+'\x20stub\x20files\x20force\x20the\x20LLM\x20to\x20call\x20`schema_query`\x20first,\x20creating\x20an\x20extra\x20round-trip.\x20Fix\x20by\x20regenerating\x20all\x2017\x20Layer\x204\x20files\x20from\x20Layer\x203\x20schemas:'),b['push'](''),b['push']('```bash'),b['push']('#\x201.\x20Generate\x20Layer\x203\x20schemas\x20from\x20Zod\x20source'),b['push']('cd\x20d:/wowok/agent/mcp\x20&&\x20pnpm\x20generate:schemas'),b['push'](''),b['push']('#\x202.\x20Generate\x20Layer\x204\x20deployed\x20files\x20from\x20Layer\x203'),b['push']('#\x20(Run\x20the\x20new\x20sync-deployed-tools.ts\x20script\x20—\x20see\x20E2.4)'),b['push']('npx\x20tsx\x20scripts/sync-deployed-tools.ts'),b['push']('```'),b['push'](''),b['push']('###\x20Phase\x202:\x20Type\x20the\x20'+a['fixable_any_count']+'\x20fixable\x20any/unknown\x20instances'),b['push'](''),b['push']('Priority\x20order:'),b['push'](''),b['push']('1.\x20**SemanticSummarySchema**\x20(src/schema/local/index.ts:6)\x20—\x20use\x20`z.lazy()`'),b['push']('2.\x20**ConfigOperationOutputSchema.result**\x20(src/schema/config/index.ts:17)\x20—\x20discriminated\x20union\x20by\x20action'),b['push']('3.\x20**ProjectOperationOutputSchema.result**\x20(src/schema/project/index.ts:34)\x20—\x20discriminated\x20union\x20by\x20action'),b['push']('4.\x20**query_toolkit\x20output\x20result**\x20(src/tools/index.ts:250)\x20—\x20discriminated\x20union\x20by\x20query_type'),b['push']('5.\x20**SchemaQueryOutputSchema.data**\x20(src/schema/schema-query/index.ts:34)\x20—\x20discriminated\x20union\x20by\x20action'),b['push']('6.\x20**RepositoryKeyValueSchema.key_value**\x20(src/schema/operations.ts:331)\x20—\x20discriminated\x20union\x20by\x20key_type'),b['push']('7.\x20**Handler\x20args:\x20any**\x20—\x20replace\x20with\x20`unknown`\x20(forces\x20strictParse\x20at\x20top\x20of\x20handler)'),b['push']('8.\x20**dispatchToolCall(name,\x20args:\x20any)**\x20—\x20replace\x20with\x20`unknown`'),b['push'](''),b['push']('###\x20Phase\x203:\x20Verify\x20I/O\x20Schema\x20Match'),b['push'](''),b['push']('For\x20each\x20tool,\x20write\x20a\x20parity\x20test\x20that:'),b['push']('1.\x20Calls\x20the\x20handler\x20with\x20a\x20minimal\x20valid\x20input'),b['push']('2.\x20Captures\x20the\x20structuredContent'),b['push']('3.\x20Validates\x20structuredContent\x20against\x20outputSchema'),b['push']('4.\x20Reports\x20any\x20mismatch'),b['push'](''),b['join']('\x0a');}
|
|
1
|
+
import*as a137a from'fs';import*as a137b from'path';import{CONCEPT_GLOSSARY}from'./glossary.js';export const TRAE_MCPS_ROOT='c:\x5cUsers\x5czhou\x5c.trae-cn\x5cmcps';export const GENERATED_SCHEMAS_DIR='d:\x5cwowok\x5cagent\x5cmcp\x5cdist\x5cschemas';export const MCP_SRC_SCHEMA_DIR='d:\x5cwowok\x5cagent\x5cmcp\x5csrc\x5cschema';export const MCP_SRC_TOOLS_DIR='d:\x5cwowok\x5cagent\x5cmcp\x5csrc\x5ctools';export const GENERATION_SCRIPT='d:\x5cwowok\x5cagent\x5cmcp\x5cscripts\x5cgenerate-json-schemas.ts';export const TOOLS_INDEX_FILE='d:\x5cwowok\x5cagent\x5cmcp\x5csrc\x5ctools\x5cindex.ts';export const MCP_SCHEMA_AUDIT_VERSION='2.1.0';export const ALL_TOOLS=[{'name':'onchain_operations','input_schema_export':'OnchainOperationsSchema','output_schema_export':'CallOutputSchema'},{'name':'account_operation','input_schema_export':'AccountOperationSchema','output_schema_export':'AccountOperationOutputWrappedSchema'},{'name':'local_mark_operation','input_schema_export':'LocalMarkOperationSchema','output_schema_export':'LocalMarkOperationOutputWrappedSchema'},{'name':'local_info_operation','input_schema_export':'LocalInfoOperationSchema','output_schema_export':'LocalInfoOperationOutputWrappedSchema'},{'name':'wip_file','input_schema_export':'WipOperationsSchema','output_schema_export':'WipOperationOutputSchema'},{'name':'messenger_operation','input_schema_export':'MessengerOperationInputSchema','output_schema_export':'MessengerOperationOutputSchema'},{'name':'guard2file','input_schema_export':'Guard2File_InputSchema','output_schema_export':'Guard2File_OutputWrappedSchema'},{'name':'machineNode2file','input_schema_export':'MachineNode2File_InputSchema','output_schema_export':'MachineNode2File_OutputWrappedSchema'},{'name':'query_toolkit','input_schema_export':'WatchQueryOperationsSchema','output_schema_export':'WatchQueryOperationsResultSchema'},{'name':'onchain_table_data','input_schema_export':'OnchainTableDataSchema','output_schema_export':'OnchainTableDataResultSchema'},{'name':'onchain_events','input_schema_export':'OnchainEventsInputSchema','output_schema_export':'OnchainEventsResultSchema'},{'name':'wowok_buildin_info','input_schema_export':'ProtocolInfoQuerySchema','output_schema_export':'ProtocolInfoResultSchema'},{'name':'schema_query','input_schema_export':'SchemaQueryInputSchema','output_schema_export':'SchemaQueryOutputSchema'},{'name':'bridge_operation','input_schema_export':'BridgeOperationsSchema','output_schema_export':'BridgeCallOutputSchema'},{'name':'project_operation','input_schema_export':'ProjectOperationInputSchema','output_schema_export':'ProjectOperationOutputSchema'},{'name':'config_operation','input_schema_export':'ConfigOperationInputSchema','output_schema_export':'ConfigOperationOutputSchema'},{'name':'trust_score','input_schema_export':'TrustScoreInputSchema','output_schema_export':'TrustScoreOutputSchema'},{'name':'query_task_status','input_schema_export':'QueryTaskStatusInputSchema','output_schema_export':'QueryTaskStatusOutputSchema'},{'name':'evaluation_operation','input_schema_export':'EvaluationOperationInputSchema','output_schema_export':'EvaluationOperationOutputSchema'},{'name':'persona_operation','input_schema_export':'PersonaOperationInputSchema','output_schema_export':'PersonaOperationOutputSchema'},{'name':'intent_radar','input_schema_export':'IntentRadarInputSchema','output_schema_export':'IntentRadarOutputSchema'},{'name':'employee_operation','input_schema_export':'EmployeeOperationInputSchema','output_schema_export':'EmployeeOperationOutputSchema'},{'name':'industry_pack_operation','input_schema_export':'IndustryPackOperationInputSchema','output_schema_export':'IndustryPackOperationOutputSchema'},{'name':'workspace_operation','input_schema_export':'WorkspaceOperationInputSchema','output_schema_export':'WorkspaceOperationOutputSchema'}];export function discoverDeployedGatewayMounts(){const a=[];if(!a137a['existsSync'](TRAE_MCPS_ROOT))return[];for(const b of a137a['readdirSync'](TRAE_MCPS_ROOT,{'withFileTypes':!![]})){if(!b['isDirectory']())continue;const c=a137b['join'](TRAE_MCPS_ROOT,b['name'],'solo_agent','mcp_wagent','tools','wowok.json');try{const d=a137a['statSync'](c);if(d['isFile']())a['push']({'file':c,'mtime':d['mtimeMs']});}catch{}}return a['sort']((e,f)=>f['mtime']-e['mtime']),a['map'](e=>e['file']);}const GATEWAY_MISSING={'gateway_file':a137b['join'](TRAE_MCPS_ROOT,'<none>','solo_agent','mcp_wagent','tools','wowok.json'),'file_exists':![],'gateway_name':null,'has_definitions':![],'definitions_count':0x0,'has_tool_field':![],'has_data_field':![],'is_strict':![],'has_schema_hint':![],'size_bytes':0x0,'all_mounts':[]};export function loadLayer4Gateway(){const a=discoverDeployedGatewayMounts();if(a['length']===0x0)return GATEWAY_MISSING;const b=a[0x0];try{const c=a137a['readFileSync'](b,'utf-8'),d=JSON['parse'](c),e=d['arguments']??{},f=e['definitions']??{},g=Object['keys'](f)['length'];let h=e;const i=e['$ref'];if(i&&i['startsWith']('#/definitions/')){const l=i['slice']('#/definitions/'['length']),m=f[l];if(m&&typeof m==='object')h=m;}const j=h['properties']??{},k=d['description']??'';return{'gateway_file':b,'file_exists':!![],'gateway_name':d['name']??null,'has_definitions':g>0x0,'definitions_count':g,'has_tool_field':'tool'in j,'has_data_field':'data'in j,'is_strict':h['additionalProperties']===![],'has_schema_hint':k['includes']('schema_query'),'size_bytes':Buffer['byteLength'](c,'utf-8'),'all_mounts':a};}catch{return{...GATEWAY_MISSING,'gateway_file':b,'all_mounts':a};}}export function loadLayer3Generated(a){const b=a137b['join'](GENERATED_SCHEMAS_DIR,a+'.schema.json'),c=a137b['join'](GENERATED_SCHEMAS_DIR,a+'.output.json'),d=a137a['existsSync'](b),e=a137a['existsSync'](c),f=d?a137a['statSync'](b)['size']:0x0,g=e?a137a['statSync'](c)['size']:0x0;return{'input_schema_file':b,'output_schema_file':c,'input_exists':d,'output_exists':e,'input_size_bytes':f,'output_size_bytes':g};}export function analyzeLayerCensus(){const a=[];for(const b of ALL_TOOLS){a['push']({'name':b['name'],'layer2_zod':{'input_schema_export':b['input_schema_export'],'output_schema_export':b['output_schema_export'],'schema_dir':MCP_SRC_SCHEMA_DIR},'layer3_generated':loadLayer3Generated(b['name'])});}return a;}export function analyzeGatewayDeployment(a){const b=[],c='(gateway)';if(!a['file_exists'])return b['push']({'rule_id':'MCP-GATEWAY-001','severity':'critical','category':'gateway_deployment','tool_name':c,'description':'No\x20deployed\x20wowok.json\x20gateway\x20descriptor\x20found\x20under\x20any\x20Trae\x20mount\x20in\x20'+TRAE_MCPS_ROOT+'.\x20The\x20MCP\x20server\x20is\x20not\x20loaded\x20by\x20any\x20Trae\x20session,\x20or\x20tools/list\x20failed.','fix':'Load\x20the\x20WoWok\x20MCP\x20server\x20in\x20a\x20Trae\x20session\x20and\x20verify\x20tools/list\x20returns\x20the\x20single\x20\x27wowok\x27\x20tool.'}),b;return a['gateway_name']!=='wowok'&&b['push']({'rule_id':'MCP-GATEWAY-002','severity':'high','category':'gateway_deployment','tool_name':c,'description':'Deployed\x20gateway\x20descriptor\x20name\x20is\x20\x27'+a['gateway_name']+'\x27\x20—\x20expected\x20\x27wowok\x27\x20(the\x20single\x20unified\x20tool\x20registered\x20by\x20the\x20server).','location':a['gateway_file'],'fix':'Restart\x20the\x20Trae\x20session\x20so\x20Trae\x20regenerates\x20wowok.json\x20from\x20the\x20server\x27s\x20tools/list.'}),!a['has_definitions']&&a['definitions_count']===0x0&&b['push']({'rule_id':'MCP-GATEWAY-003','severity':'high','category':'gateway_deployment','tool_name':c,'description':'Deployed\x20gateway\x20descriptor\x20carries\x20no\x20argument\x20schema\x20(no\x20definitions,\x20no\x20properties)\x20—\x20the\x20LLM\x20has\x20no\x20parameter\x20structure\x20at\x20all.','location':a['gateway_file'],'fix':'Ensure\x20listTools()\x20advertises\x20WowokToolDisplaySchema\x20and\x20restart\x20the\x20Trae\x20session.'}),!a['has_schema_hint']&&b['push']({'rule_id':'MCP-GATEWAY-004','severity':'medium','category':'gateway_deployment','tool_name':c,'description':'Gateway\x20descriptor\x20description\x20does\x20not\x20mention\x20schema_query\x20—\x20the\x20LLM\x20is\x20not\x20told\x20about\x20the\x20schema\x20self-correction\x20path\x20(sub-tool\x20schemas\x20are\x20returned\x20on\x20validation\x20mismatch).','location':a['gateway_file'],'fix':'Keep\x20the\x20schema_query\x20mention\x20in\x20WOWOK_TOOL_DESCRIPTION\x20(src/tools/index.ts).'}),b;}export function analyzeGatewayDispatchContract(a){const b=[],c='(gateway)';if(!a['file_exists'])return b;const d=[];if(!a['has_tool_field'])d['push']('tool');if(!a['has_data_field'])d['push']('data');return d['length']>0x0&&b['push']({'rule_id':'MCP-PARITY-001','severity':'high','category':'layer_parity','tool_name':c,'description':'Deployed\x20gateway\x20argument\x20schema\x20is\x20missing\x20dispatch\x20field(s):\x20'+d['join'](',\x20')+'.\x20Calls\x20of\x20the\x20form\x20wowok({\x20tool,\x20data\x20})\x20cannot\x20be\x20validated.','location':a['gateway_file'],'fix':'Ensure\x20WowokToolDisplaySchema\x20exposes\x20tool/data\x20properties\x20and\x20restart\x20the\x20Trae\x20session.'}),!a['is_strict']&&b['push']({'rule_id':'MCP-PARITY-002','severity':'medium','category':'layer_parity','tool_name':c,'description':'Deployed\x20gateway\x20root\x20schema\x20is\x20not\x20strict\x20(additionalProperties\x20!==\x20false)\x20—\x20unknown\x20keys\x20silently\x20pass\x20the\x20client-side\x20check.','location':a['gateway_file'],'fix':'Keep\x20additionalProperties:false\x20on\x20WowokToolDisplaySchema\x20(aliases\x20are\x20explicit\x20properties).'}),b;}export function analyzeAnyUnknownCensus(){const a=[],b=[MCP_SRC_SCHEMA_DIR,MCP_SRC_TOOLS_DIR];for(const c of b){const d=listTypeScriptFiles(c);for(const e of d){const f=a137a['readFileSync'](e,'utf-8')['split']('\x0a');for(let g=0x0;g<f['length'];g++){const h=f[g],j=h['trim']();if(j['startsWith']('//')||j['startsWith']('*'))continue;const k=[{'regex':/z\.any\(\)/g,'pattern':'z.any()'},{'regex':/z\.unknown\(\)/g,'pattern':'z.unknown()'},{'regex':/args\s*:\s*any\b/g,'pattern':'args:\x20any'},{'regex':/Promise\s*<\s*any\s*>/g,'pattern':'Promise<any>'},{'regex':/Record\s*<\s*string\s*,\s*any\s*>/g,'pattern':'Record<string,\x20any>'},{'regex':/\bas\s+any\b/g,'pattern':'as\x20any'}];for(const {regex:l,pattern:n}of k){l['lastIndex']=0x0;let o;while((o=l['exec'](h))!==null){const p=categorizeAnyInstance(e,g+0x1,h,n);a['push']({'file':e,'line':g+0x1,'code':j['length']>0x78?j['slice'](0x0,0x75)+'...':j,'pattern':n,'category':p['category'],'reason':p['reason'],'fix_suggestion':p['fix']});}}}}}return a;}function listTypeScriptFiles(a){const b=[];if(!a137a['existsSync'](a))return b;const c=a137a['readdirSync'](a,{'withFileTypes':!![]});for(const d of c){const e=a137b['join'](a,d['name']);if(d['isDirectory']()){if(d['name']==='__tests__'||d['name']==='node_modules')continue;b['push'](...listTypeScriptFiles(e));}else d['isFile']()&&d['name']['endsWith']('.ts')&&b['push'](e);}return b;}function categorizeAnyInstance(a,b,c,d){const e=a137b['basename'](a),f=c['trim']();if(d==='z.any()'&&/SemanticSummarySchema\s*=\s*z\.any\(\)/['test'](f))return{'category':'fixable','reason':'Circular-dependency\x20workaround\x20for\x20SemanticSummarySchema\x20—\x20can\x20use\x20z.lazy()\x20or\x20refactor\x20to\x20break\x20the\x20cycle.','fix':'Define\x20SemanticSummarySchema\x20with\x20z.lazy(()\x20=>\x20SemanticSummarySchemaReal)\x20or\x20restructure\x20imports\x20to\x20break\x20the\x20cycle.'};if(d==='z.any()'&&/result\s*:\s*z\.any\(\)/['test'](f)&&/[\\/]config[\\/]|[\\/]project[\\/]/['test'](a))return{'category':'fixable','reason':'Result\x20shape\x20depends\x20on\x20action\x20—\x20can\x20use\x20z.discriminatedUnion(\x27action\x27,\x20[...])\x20to\x20type\x20each\x20action\x27s\x20result.','fix':'Define\x20discriminated\x20union:\x20z.discriminatedUnion(\x27action\x27,\x20[z.object({action:\x20z.literal(\x27list\x27),\x20result:\x20...}),\x20...]).'};if(d==='z.unknown()'&&/result\s*:\s*z\.unknown\(\)/['test'](f)&&/index\.ts/['test'](e))return{'category':'fixable','reason':'query_toolkit\x20output\x20result\x20depends\x20on\x20query_type\x20—\x20can\x20use\x20z.discriminatedUnion(\x27query_type\x27,\x20[...]).','fix':'Define\x20discriminated\x20union:\x20z.discriminatedUnion(\x27query_type\x27,\x20[z.object({query_type:\x20z.literal(\x27local_mark_list\x27),\x20result:\x20z.array(MarkDataSchema)}),\x20...]).'};if(d==='z.any()'&&/data\s*:\s*z\.any\(\)/['test'](f)&&/[\\/]schema-query[\\/]/['test'](a))return{'category':'fixable','reason':'SchemaQuery\x20output\x20data\x20depends\x20on\x20action\x20—\x20can\x20use\x20discriminated\x20union\x20by\x20action.','fix':'Define\x20discriminated\x20union:\x20action=\x27get\x27\x20returns\x20JSON\x20Schema,\x20action=\x27list\x27\x20returns\x20array\x20of\x20items.'};if(d==='args:\x20any'&&/handlers[\\/]/['test'](a))return{'category':'fixable','reason':'Handler\x20args\x20can\x20use\x20`unknown`\x20(forces\x20runtime\x20validation)\x20or\x20a\x20typed\x20input\x20schema.','fix':'Replace\x20`args:\x20any`\x20with\x20`args:\x20unknown`\x20and\x20use\x20strictParse(schema,\x20args)\x20at\x20the\x20top\x20of\x20the\x20handler.'};if(d==='args:\x20any'&&/tools[\\/]index\.ts/['test'](a))return{'category':'fixable','reason':'dispatchToolCall\x20args\x20is\x20`any`\x20—\x20can\x20be\x20`unknown`\x20since\x20each\x20tool\x20parses\x20with\x20its\x20own\x20schema.','fix':'Change\x20`args:\x20any`\x20to\x20`args:\x20unknown`\x20in\x20dispatchToolCall\x20signature.'};if(d==='args:\x20any'&&/types\.ts/['test'](e)&&/handler/['test'](f))return{'category':'fixable','reason':'ToolEntry.handler\x20args\x20is\x20`any`\x20—\x20can\x20be\x20`unknown`\x20(each\x20handler\x20parses\x20with\x20its\x20own\x20schema).','fix':'Change\x20`handler:\x20(args:\x20any)\x20=>\x20...`\x20to\x20`handler:\x20(args:\x20unknown)\x20=>\x20...`.'};if(d==='z.any()'&&/claimReceipt|ethReceipt|wowReceipt/['test'](f))return{'category':'legitimate','reason':'EVM\x20transaction\x20receipts\x20have\x20an\x20externally-defined\x20shape\x20from\x20viem/ethers\x20—\x20z.any()\x20is\x20acceptable\x20(receipt\x20is\x20informational,\x20not\x20validated).'};if(d==='z.any()'&&/content_raw/['test'](f))return{'category':'legitimate','reason':'content_raw\x20holds\x20raw\x20content\x20for\x20unknown\x20object\x20types\x20—\x20by\x20definition\x20untyped.\x20z.any()\x20is\x20acceptable\x20here.'};if((d==='z.unknown()'||d==='z.any()')&&/parsedJson/['test'](f))return{'category':'legitimate','reason':'Event\x20parsedJson\x20is\x20arbitrary\x20on-chain\x20event\x20data\x20—\x20z.record(z.string(),\x20z.unknown())\x20is\x20appropriate.'};if(d==='z.any()'&&/key_value/['test'](f))return{'category':'fixable','reason':'Repository\x20key_value\x20depends\x20on\x20key_type\x20—\x20could\x20use\x20discriminated\x20union\x20by\x20key_type\x20(string→z.string(),\x20u64→z.bigint()/number,\x20etc.).','fix':'Define\x20z.discriminatedUnion(\x27key_type\x27,\x20[...])\x20with\x20each\x20variant\x20typed.'};if(d==='z.unknown()'&&/data\s*:\s*z\.unknown\(\)/['test'](f)&&/[\\/]bridge/['test'](a))return{'category':'legitimate','reason':'Bridge\x20operation\x20result\x20data\x20varies\x20by\x20operation_type\x20—\x20currently\x209\x20different\x20shapes.\x20Discriminated\x20union\x20would\x20be\x20ideal\x20but\x20high\x20refactor\x20cost.'};if(d==='z.unknown()'&&/adjusted_params/['test'](f))return{'category':'legitimate','reason':'adjusted_params\x20are\x20free-form\x20key-value\x20pairs\x20suggested\x20by\x20AI\x20—\x20z.record(z.string(),\x20z.unknown())\x20is\x20appropriate.'};if(d==='z.any()'&&/object\s*:\s*z\.union.*z\.record\(z\.any\(\)/['test'](f))return{'category':'fixable','reason':'Creation\x20vs\x20reference\x20object\x20union\x20—\x20z.record(z.any())\x20should\x20be\x20replaced\x20with\x20NamedObjectSchema\x20(structured\x20creation\x20input).','fix':'Replace\x20z.record(z.any())\x20with\x20NamedObjectSchema\x20(already\x20defined\x20in\x20base.ts).'};if(d==='z.any()'&&/result\s*:\s*z\.any\(\)\.optional\(\)/['test'](f)&&/[\\/]bridge/['test'](a))return{'category':'legitimate','reason':'Bridge\x20result\x20is\x20operation-specific\x20(manage_evm_rpc\x20has\x20different\x20result\x20per\x20operation)\x20—\x20z.any().optional()\x20is\x20acceptable\x20here.'};if(d==='Promise<any>'&&/[\\/](wrap|shared)\.ts/['test'](a))return{'category':'fixable','reason':'Generic\x20wrappers\x20in\x20wrap.ts/shared.ts\x20use\x20Promise<any>\x20—\x20could\x20be\x20made\x20generic\x20<T>.','fix':'Replace\x20`Promise<any>`\x20with\x20`Promise<ToolDispatchResult>`\x20(the\x20actual\x20return\x20shape).'};if(d==='Record<string,\x20any>'&&/types\.ts/['test'](e)&&/_meta|structuredContent/['test'](f))return{'category':'fixable','reason':'ToolConfig._meta\x20and\x20ToolDispatchResult.structuredContent\x20could\x20use\x20structured\x20types.','fix':'Define\x20ToolMeta\x20interface\x20(category,\x20tags)\x20and\x20replace\x20structuredContent:\x20any\x20with\x20structured\x20type.'};if(d==='as\x20any')return{'category':'legitimate','reason':'`as\x20any`\x20cast\x20—\x20usually\x20for\x20third-party\x20type\x20mismatches\x20(MCP\x20SDK).\x20Acceptable\x20if\x20isolated.'};return{'category':'legitimate','reason':'Unclassified\x20any/unknown\x20usage\x20—\x20review\x20manually.\x20Defaulting\x20to\x20legitimate\x20(no\x20auto-fix).'};}export function analyzeHandlerTypeSafety(a){const b=[];for(const c of a){if(c['pattern']!=='args:\x20any')continue;if(!/tools[\\/]/['test'](c['file']))continue;b['push']({'rule_id':'MCP-HANDLER-001','severity':'medium','category':'handler_types','tool_name':a137b['basename'](c['file'],'.ts'),'description':'Handler\x20uses\x20`args:\x20any`\x20—\x20bypasses\x20TypeScript\x20type\x20checking.\x20'+c['reason'],'location':c['file']+':'+c['line'],'fix':c['fix_suggestion']});}return b;}export function analyzeOutputSchemaCoverage(a){const b=[];for(const d of a){!d['layer3_generated']['output_exists']&&d['name']!=='onchain_operations'&&b['push']({'rule_id':'MCP-OUTPUT-001','severity':'high','category':'output_coverage','tool_name':d['name'],'description':'Layer\x203\x20output\x20schema\x20file\x20does\x20not\x20exist:\x20'+d['layer3_generated']['output_schema_file'],'fix':'Add\x20outputSchema\x20to\x20'+d['name']+'\x27s\x20tool\x20definition\x20and\x20regenerate\x20schemas.'}),d['layer2_zod']['output_schema_export']===null&&b['push']({'rule_id':'MCP-OUTPUT-002','severity':'medium','category':'output_coverage','tool_name':d['name'],'description':'Layer\x202\x20outputSchema\x20is\x20defined\x20inline\x20(not\x20exported\x20with\x20a\x20stable\x20name).\x20This\x20makes\x20it\x20harder\x20to\x20reference\x20from\x20tests.','fix':'Export\x20the\x20outputSchema\x20with\x20a\x20stable\x20name\x20(e.g.,\x20'+d['name']+'OutputSchema).'});}return b;}export function analyzeGenerationScriptSync(){const a=[];if(!a137a['existsSync'](GENERATION_SCRIPT))return a['push']({'rule_id':'MCP-GENSYNC-001','severity':'critical','category':'generation_sync','tool_name':'(all)','description':'Generation\x20script\x20not\x20found:\x20'+GENERATION_SCRIPT}),a;const b=a137a['readFileSync'](GENERATION_SCRIPT,'utf-8'),c=/name:\s*["']([^"']+)["']/g,d=new Set();let e;while((e=c['exec'](b))!==null){ALL_TOOLS['some'](f=>f['name']===e[0x1])&&d['add'](e[0x1]);}for(const f of ALL_TOOLS){!d['has'](f['name'])&&a['push']({'rule_id':'MCP-GENSYNC-002','severity':'high','category':'generation_sync','tool_name':f['name'],'description':'Tool\x20\x22'+f['name']+'\x22\x20is\x20in\x20TOOL_REGISTRY\x20but\x20missing\x20from\x20generate-json-schemas.ts.\x20Layer\x203\x20schemas\x20will\x20not\x20be\x20generated.','location':GENERATION_SCRIPT,'fix':'Add\x20a\x20get'+toPascalCase(f['name'])+'Tool()\x20function\x20and\x20add\x20it\x20to\x20the\x20tools\x20array.'});}return a;}function toPascalCase(a){return a['split']('_')['map'](b=>b['charAt'](0x0)['toUpperCase']()+b['slice'](0x1)['toLowerCase']())['join']('');}export function analyzeSchemaQueryReflection(a){const b=[];for(const e of a){!e['layer3_generated']['input_exists']&&b['push']({'rule_id':'MCP-REFLECT-001','severity':'high','category':'reflection','tool_name':e['name'],'description':'schema_query(action=\x27get\x27,\x20name=\x27'+e['name']+'\x27)\x20would\x20fail\x20—\x20Layer\x203\x20input\x20schema\x20missing.','fix':'Run\x20pnpm\x20generate:schemas.'}),!e['layer3_generated']['output_exists']&&e['name']!=='onchain_operations'&&b['push']({'rule_id':'MCP-REFLECT-002','severity':'medium','category':'reflection','tool_name':e['name'],'description':'schema_query(action=\x27get_output\x27,\x20name=\x27'+e['name']+'\x27)\x20would\x20fail\x20—\x20Layer\x203\x20output\x20schema\x20missing.','fix':'Run\x20pnpm\x20generate:schemas.'});}const d=['permission','service','machine','progress','guard','arbitration','repository','contact','treasury','reward','allocation','personal','payment','demand','order','gen_passport','proof','gen_proof'];for(const f of d){const g=a137b['join'](GENERATED_SCHEMAS_DIR,'onchain_operations_'+f+'.schema.json');!a137a['existsSync'](g)&&b['push']({'rule_id':'MCP-REFLECT-003','severity':'medium','category':'reflection','tool_name':'onchain_operations_'+f,'description':'Individual\x20operation\x20schema\x20missing:\x20'+g+'.\x20schema_query(action=\x27get\x27,\x20name=\x27onchain_operations_'+f+'\x27)\x20would\x20fail.','fix':'Run\x20pnpm\x20generate:schemas.'});}return b;}function normalizeGlossaryTerm(a){return a['toLowerCase']()['replace'](/[-_\s]/g,'');}const GLOSSARY_ALIAS_INDEX=((()=>{const a=new Set(CONCEPT_GLOSSARY['map'](c=>normalizeGlossaryTerm(c['term']))),b=new Map();for(const c of CONCEPT_GLOSSARY){for(const d of c['aliases']){const e=normalizeGlossaryTerm(d);if(a['has'](e))continue;if(!b['has'](e))b['set'](e,c['term']);}}return b;})());function collectSchemaProperties(a,b,c){if(!a||typeof a!=='object')return;const d=a;if(d['properties']&&typeof d['properties']==='object')for(const e of Object['keys'](d['properties'])){c['push']({'file':b,'property':e}),collectSchemaProperties(d['properties'][e],b,c);}if(d['definitions']&&typeof d['definitions']==='object')for(const f of Object['keys'](d['definitions'])){collectSchemaProperties(d['definitions'][f],b,c);}if(d['items'])collectSchemaProperties(d['items'],b,c);if(Array['isArray'](d['anyOf']))d['anyOf']['forEach'](g=>collectSchemaProperties(g,b,c));if(Array['isArray'](d['oneOf']))d['oneOf']['forEach'](g=>collectSchemaProperties(g,b,c));d['additionalProperties']&&typeof d['additionalProperties']==='object'&&collectSchemaProperties(d['additionalProperties'],b,c);}export function analyzeGlossaryAlignment(){const a=[];if(!a137a['existsSync'](GENERATED_SCHEMAS_DIR))return a;const b=a137a['readdirSync'](GENERATED_SCHEMAS_DIR)['filter'](d=>d['endsWith']('.schema.json')||d['endsWith']('.output.json')),c=new Set();for(const d of b){const e=a137b['join'](GENERATED_SCHEMAS_DIR,d);let f;try{f=JSON['parse'](a137a['readFileSync'](e,'utf-8'));}catch{continue;}const g=[];collectSchemaProperties(f,d,g);for(const h of g){const i=normalizeGlossaryTerm(h['property']),j=GLOSSARY_ALIAS_INDEX['get'](i);if(!j)continue;const k=h['file']+'::'+h['property'];if(c['has'](k))continue;c['add'](k),a['push']({'rule_id':'MCP-GLOSSARY-001','severity':'medium','category':'glossary_alignment','tool_name':d['replace'](/\.(schema|output)\.json$/,''),'description':'Schema\x20field\x20\x27'+h['property']+'\x27\x20uses\x20a\x20deprecated\x20glossary\x20alias\x20—\x20the\x20canonical\x20term\x20is\x20\x27'+j+'\x27.','location':e,'fix':'Rename\x20the\x20field\x20to\x20the\x20canonical\x20term\x20(camelCase/snake_case\x20of\x20\x27'+j+'\x27).'});}}return a;}export function scanAllMcpSchemas(){const a=analyzeLayerCensus(),b=loadLayer4Gateway(),c=analyzeAnyUnknownCensus(),d=[...analyzeGatewayDeployment(b),...analyzeGatewayDispatchContract(b),...analyzeHandlerTypeSafety(c),...analyzeOutputSchemaCoverage(a),...analyzeGenerationScriptSync(),...analyzeSchemaQueryReflection(a),...analyzeGlossaryAlignment()],e=new Map(),g=new Map();for(const k of d){if(!e['has'](k['severity']))e['set'](k['severity'],[]);e['get'](k['severity'])['push'](k);if(!g['has'](k['category']))g['set'](k['category'],[]);g['get'](k['category'])['push'](k);}const h=c['filter'](l=>l['category']==='fixable')['length'],i=c['filter'](l=>l['category']==='legitimate')['length'],j=c['filter'](l=>l['category']==='external')['length'];return{'census':a,'gateway':b,'findings':d,'any_unknown_instances':c,'findings_by_severity':e,'findings_by_category':g,'total_findings':d['length'],'fixable_any_count':h,'legitimate_any_count':i,'external_any_count':j};}export function formatAuditReport(a){const b=[];b['push']('#\x20MCP\x20Schema\x20Audit\x20Report\x20—\x20'+a['census']['length']+'\x20WoWok\x20Sub-Tools\x20+\x20Unified\x20Gateway'),b['push'](''),b['push']('>\x20Auto-generated\x20by\x20`mcp-schema-audit.ts`\x20v'+MCP_SCHEMA_AUDIT_VERSION+'\x20—\x20comprehensive'),b['push']('>\x204-layer\x20audit\x20of\x20schema\x20consistency,\x20any/unknown\x20usage,\x20and\x20I/O\x20coverage.'),b['push'](''),b['push']('##\x20Summary'),b['push'](''),b['push']('-\x20**Tools\x20audited**:\x20'+a['census']['length']),b['push']('-\x20**Total\x20findings**:\x20'+a['total_findings']),b['push']('-\x20**Gateway\x20deployed**:\x20'+(a['gateway']['file_exists']?'yes\x20('+a['gateway']['all_mounts']['length']+'\x20Trae\x20mount(s))':'NO')),b['push']('-\x20**any/unknown\x20instances**:\x20'+a['any_unknown_instances']['length']+'\x20total'),b['push']('\x20\x20-\x20Fixable:\x20'+a['fixable_any_count']),b['push']('\x20\x20-\x20Legitimate:\x20'+a['legitimate_any_count']),b['push']('\x20\x20-\x20External:\x20'+a['external_any_count']),b['push']('-\x20**Glossary\x20alignment**:\x20'+(a['findings_by_category']['get']('glossary_alignment')??[])['length']+'\x20deprecated-alias\x20schema\x20field(s)'),b['push'](''),b['push']('###\x20Findings\x20by\x20Severity'),b['push'](''),b['push']('|\x20Severity\x20|\x20Count\x20|'),b['push']('|----------|-------|');for(const h of['critical','high','medium','low','info']){const i=a['findings_by_severity']['get'](h)??[];b['push']('|\x20'+h+'\x20|\x20'+i['length']+'\x20|');}b['push'](''),b['push']('###\x20Findings\x20by\x20Category'),b['push'](''),b['push']('|\x20Category\x20|\x20Count\x20|'),b['push']('|----------|-------|');for(const j of['gateway_deployment','layer_parity','handler_types','output_coverage','generation_sync','reflection','glossary_alignment']){const k=a['findings_by_category']['get'](j)??[];b['push']('|\x20'+j+'\x20|\x20'+k['length']+'\x20|');}b['push'](''),b['push']('##\x20Layer\x204\x20—\x20Deployed\x20Gateway'),b['push']('');a['gateway']['file_exists']?(b['push']('-\x20**Descriptor**:\x20`'+a['gateway']['gateway_file']+'`\x20('+(a['gateway']['size_bytes']/0x400)['toFixed'](0x1)+'KB)'),b['push']('-\x20**Name**:\x20'+a['gateway']['gateway_name']),b['push']('-\x20**Dispatch\x20contract**:\x20tool='+(a['gateway']['has_tool_field']?'✓':'✗')+'\x20data='+(a['gateway']['has_data_field']?'✓':'✗')+'\x20strict='+(a['gateway']['is_strict']?'✓':'✗')),b['push']('-\x20**Definitions**:\x20'+a['gateway']['definitions_count']),b['push']('-\x20**schema_query\x20hint**:\x20'+(a['gateway']['has_schema_hint']?'✓':'✗')),b['push']('-\x20**Trae\x20mounts**:\x20'+a['gateway']['all_mounts']['length'])):b['push']('-\x20✗\x20No\x20wowok.json\x20found\x20under\x20any\x20Trae\x20mount\x20in\x20'+TRAE_MCPS_ROOT);b['push'](''),b['push']('##\x20Layer\x20Census\x20—\x20All\x20'+a['census']['length']+'\x20Sub-Tools\x20(dispatched\x20via\x20the\x20wowok\x20gateway)'),b['push'](''),b['push']('|\x20Tool\x20|\x20L3\x20Input\x20|\x20L3\x20Output\x20|'),b['push']('|------|----------|-----------|');for(const l of a['census']){const m=l['layer3_generated']['input_exists']?'✓\x20'+(l['layer3_generated']['input_size_bytes']/0x400)['toFixed'](0x1)+'KB':'✗\x20MISSING',n=l['layer3_generated']['output_exists']?'✓\x20'+(l['layer3_generated']['output_size_bytes']/0x400)['toFixed'](0x1)+'KB':'✗\x20MISSING';b['push']('|\x20'+l['name']+'\x20|\x20'+m+'\x20|\x20'+n+'\x20|');}b['push'](''),b['push']('##\x20Findings\x20Detail'),b['push']('');const d=['critical','high','medium','low','info'];for(const o of d){const p=a['findings_by_severity']['get'](o)??[];if(p['length']===0x0)continue;const q=o['toUpperCase']();b['push']('###\x20'+q+'\x20('+p['length']+')'),b['push']('');for(const r of p){b['push']('-\x20**['+r['rule_id']+']\x20'+r['description']);if(r['location'])b['push']('\x20\x20-\x20Location:\x20`'+r['location']+'`');if(r['fix'])b['push']('\x20\x20-\x20Fix:\x20'+r['fix']);b['push']('');}}b['push']('##\x20any/unknown\x20Census\x20Detail'),b['push'](''),b['push']('Total\x20instances:\x20'+a['any_unknown_instances']['length']),b['push'](''),b['push']('###\x20By\x20Pattern'),b['push'](''),b['push']('|\x20Pattern\x20|\x20Total\x20|\x20Fixable\x20|\x20Legitimate\x20|\x20External\x20|'),b['push']('|---------|-------|---------|------------|----------|');const e=new Map();for(const s of a['any_unknown_instances']){if(!e['has'](s['pattern']))e['set'](s['pattern'],[]);e['get'](s['pattern'])['push'](s);}for(const [t,u]of[...e['entries']()]['sort']((v,w)=>w[0x1]['length']-v[0x1]['length'])){const v=u['filter'](y=>y['category']==='fixable')['length'],w=u['filter'](y=>y['category']==='legitimate')['length'],x=u['filter'](y=>y['category']==='external')['length'];b['push']('|\x20`'+t+'`\x20|\x20'+u['length']+'\x20|\x20'+v+'\x20|\x20'+w+'\x20|\x20'+x+'\x20|');}b['push']('');const g=a['any_unknown_instances']['filter'](y=>y['category']==='fixable');if(g['length']>0x0){b['push']('###\x20Fixable\x20Instances\x20(Priority\x20List)'),b['push']('');for(const y of g){b['push']('-\x20**'+a137b['basename'](y['file'])+':'+y['line']+'**\x20[`'+y['pattern']+'`]'),b['push']('\x20\x20-\x20Code:\x20`'+y['code']+'`'),b['push']('\x20\x20-\x20Reason:\x20'+y['reason']);if(y['fix_suggestion'])b['push']('\x20\x20-\x20Fix:\x20'+y['fix_suggestion']);b['push']('');}}return b['push']('##\x20Recommended\x20Action\x20Plan'),b['push'](''),b['push']('###\x20Phase\x201:\x20Keep\x20the\x20Layer\x203\x20schema\x20set\x20regenerable'),b['push'](''),b['push']('Layer\x204\x20(the\x20deployed\x20wowok.json\x20gateway)\x20is\x20CLIENT-generated\x20from\x20our\x20tools/list\x20—\x20keep\x20Layer\x203\x20in\x20sync\x20so\x20schema_query\x20reflection\x20always\x20serves\x20fresh\x20schemas:'),b['push'](''),b['push']('```bash'),b['push']('cd\x20d:/wowok/agent/mcp\x20&&\x20pnpm\x20generate:schemas'),b['push']('```'),b['push'](''),b['push']('###\x20Phase\x202:\x20Type\x20the\x20'+a['fixable_any_count']+'\x20fixable\x20any/unknown\x20instances'),b['push'](''),b['push']('Priority\x20order:'),b['push'](''),b['push']('1.\x20**SemanticSummarySchema**\x20(src/schema/local/index.ts:6)\x20—\x20use\x20`z.lazy()`'),b['push']('2.\x20**ConfigOperationOutputSchema.result**\x20(src/schema/config/index.ts:17)\x20—\x20discriminated\x20union\x20by\x20action'),b['push']('3.\x20**ProjectOperationOutputSchema.result**\x20(src/schema/project/index.ts:34)\x20—\x20discriminated\x20union\x20by\x20action'),b['push']('4.\x20**query_toolkit\x20output\x20result**\x20(src/tools/index.ts:250)\x20—\x20discriminated\x20union\x20by\x20query_type'),b['push']('5.\x20**SchemaQueryOutputSchema.data**\x20(src/schema/schema-query/index.ts:34)\x20—\x20discriminated\x20union\x20by\x20action'),b['push']('6.\x20**RepositoryKeyValueSchema.key_value**\x20(src/schema/operations.ts:331)\x20—\x20discriminated\x20union\x20by\x20key_type'),b['push']('7.\x20**Handler\x20args:\x20any**\x20—\x20replace\x20with\x20`unknown`\x20(forces\x20strictParse\x20at\x20top\x20of\x20handler)'),b['push']('8.\x20**dispatchToolCall(name,\x20args:\x20any)**\x20—\x20replace\x20with\x20`unknown`'),b['push'](''),b['push']('###\x20Phase\x203:\x20Verify\x20I/O\x20Schema\x20Match'),b['push'](''),b['push']('For\x20each\x20tool,\x20write\x20a\x20parity\x20test\x20that:'),b['push']('1.\x20Calls\x20the\x20handler\x20with\x20a\x20minimal\x20valid\x20input'),b['push']('2.\x20Captures\x20the\x20structuredContent'),b['push']('3.\x20Validates\x20structuredContent\x20against\x20outputSchema'),b['push']('4.\x20Reports\x20any\x20mismatch'),b['push'](''),b['join']('\x0a');}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ONCHAIN_CONSTANTS, MAX_NODE_COUNT, MAX_NODE_COUNT_ONCHAIN, MAX_FORWARD_COUNT, MAX_FORWARD_ORDER_COUNT, MAX_NODE_PAIR_COUNT, MAX_CONSENSUS_REPOSITORIES_COUNT, USER_DEFINED_PERM_INDEX_START, MAX_PERM_FOR_ENTITY, MAX_ADMIN_COUNT, MAX_AGENT_COUNT, MAX_DISPUTE_COUNT, MAX_SHARING_COUNT, MAX_VOTING_GUARD_COUNT, MAX_POLICY_COUNT, MAX_ID_COUNT_ONCE, MAX_REWARD_COUNT, MAX_GUARD_COUNT_REWARD, MAX_RECORD_COUNT_REWARD, MAX_CONTEXT_REPOSITORY_COUNT, MAX_NAMED_OPERATOR_COUNT, MAX_NAMED_OPERATOR_ADDRESS_COUNT, MAX_IM_COUNT, MAX_TAGS_COUNT, MAX_RECIPIENT_COUNT, MAX_PROPOSITION_COUNT, MAX_VOTOR_COUNT, WITHDRAW_DURATION_TIME, MAX_ADDRESS_COUNT, MAX_RECORD_LENGTH, BRIDGE_MESSAGE_VERSION, BRIDGE_EVM_ADDRESS_LENGTH, BRIDGE_CURRENT_VERSION, BRIDGE_TRANSFER_STATUS_PENDING, BRIDGE_TRANSFER_STATUS_APPROVED, BRIDGE_TRANSFER_STATUS_CLAIMED, BRIDGE_TRANSFER_STATUS_NOT_FOUND, type OnchainConstantName, type MaxNodeCountSdkLiteral } from "@wowok/wowok";
|
|
2
|
-
export { ONCHAIN_CONSTANTS, MAX_NODE_COUNT, MAX_NODE_COUNT_ONCHAIN, MAX_FORWARD_COUNT, MAX_FORWARD_ORDER_COUNT, MAX_NODE_PAIR_COUNT, MAX_CONSENSUS_REPOSITORIES_COUNT, USER_DEFINED_PERM_INDEX_START, MAX_PERM_FOR_ENTITY, MAX_ADMIN_COUNT, MAX_AGENT_COUNT, MAX_DISPUTE_COUNT, MAX_SHARING_COUNT, MAX_VOTING_GUARD_COUNT, MAX_POLICY_COUNT, MAX_ID_COUNT_ONCE, MAX_REWARD_COUNT, MAX_GUARD_COUNT_REWARD, MAX_RECORD_COUNT_REWARD, MAX_CONTEXT_REPOSITORY_COUNT, MAX_NAMED_OPERATOR_COUNT, MAX_NAMED_OPERATOR_ADDRESS_COUNT, MAX_IM_COUNT, MAX_TAGS_COUNT, MAX_RECIPIENT_COUNT, MAX_PROPOSITION_COUNT, MAX_VOTOR_COUNT, WITHDRAW_DURATION_TIME, MAX_ADDRESS_COUNT, MAX_RECORD_LENGTH, BRIDGE_MESSAGE_VERSION, BRIDGE_EVM_ADDRESS_LENGTH, BRIDGE_CURRENT_VERSION, BRIDGE_TRANSFER_STATUS_PENDING, BRIDGE_TRANSFER_STATUS_APPROVED, BRIDGE_TRANSFER_STATUS_CLAIMED, BRIDGE_TRANSFER_STATUS_NOT_FOUND, type OnchainConstantName, type MaxNodeCountSdkLiteral, };
|
|
1
|
+
import { ONCHAIN_CONSTANTS, MAX_NODE_COUNT, MAX_NODE_COUNT_ONCHAIN, MAX_FORWARD_COUNT, MAX_FORWARD_ORDER_COUNT, MAX_NODE_PAIR_COUNT, MAX_CONSENSUS_REPOSITORIES_COUNT, USER_DEFINED_PERM_INDEX_START, MAX_PERM_FOR_ENTITY, MAX_ADMIN_COUNT, MAX_ITEM_COUNT, ROLE_OWNER, ROLE_ADMIN, ROLE_ENTITY, MAX_AGENT_COUNT, MAX_DISPUTE_COUNT, MAX_SHARING_COUNT, MAX_VOTING_GUARD_COUNT, MAX_POLICY_COUNT, MAX_ID_COUNT_ONCE, MAX_REWARD_COUNT, MAX_GUARD_COUNT_REWARD, MAX_RECORD_COUNT_REWARD, MAX_CONTEXT_REPOSITORY_COUNT, MAX_NAMED_OPERATOR_COUNT, MAX_NAMED_OPERATOR_ADDRESS_COUNT, MAX_IM_COUNT, MAX_TAGS_COUNT, MAX_RECIPIENT_COUNT, MAX_PROPOSITION_COUNT, MAX_VOTOR_COUNT, WITHDRAW_DURATION_TIME, MAX_ADDRESS_COUNT, MAX_RECORD_LENGTH, BRIDGE_MESSAGE_VERSION, BRIDGE_EVM_ADDRESS_LENGTH, BRIDGE_CURRENT_VERSION, BRIDGE_TRANSFER_STATUS_PENDING, BRIDGE_TRANSFER_STATUS_APPROVED, BRIDGE_TRANSFER_STATUS_CLAIMED, BRIDGE_TRANSFER_STATUS_NOT_FOUND, type OnchainConstantName, type MaxNodeCountSdkLiteral } from "@wowok/wowok";
|
|
2
|
+
export { ONCHAIN_CONSTANTS, MAX_NODE_COUNT, MAX_NODE_COUNT_ONCHAIN, MAX_FORWARD_COUNT, MAX_FORWARD_ORDER_COUNT, MAX_NODE_PAIR_COUNT, MAX_CONSENSUS_REPOSITORIES_COUNT, USER_DEFINED_PERM_INDEX_START, MAX_PERM_FOR_ENTITY, MAX_ADMIN_COUNT, MAX_ITEM_COUNT, ROLE_OWNER, ROLE_ADMIN, ROLE_ENTITY, MAX_AGENT_COUNT, MAX_DISPUTE_COUNT, MAX_SHARING_COUNT, MAX_VOTING_GUARD_COUNT, MAX_POLICY_COUNT, MAX_ID_COUNT_ONCE, MAX_REWARD_COUNT, MAX_GUARD_COUNT_REWARD, MAX_RECORD_COUNT_REWARD, MAX_CONTEXT_REPOSITORY_COUNT, MAX_NAMED_OPERATOR_COUNT, MAX_NAMED_OPERATOR_ADDRESS_COUNT, MAX_IM_COUNT, MAX_TAGS_COUNT, MAX_RECIPIENT_COUNT, MAX_PROPOSITION_COUNT, MAX_VOTOR_COUNT, WITHDRAW_DURATION_TIME, MAX_ADDRESS_COUNT, MAX_RECORD_LENGTH, BRIDGE_MESSAGE_VERSION, BRIDGE_EVM_ADDRESS_LENGTH, BRIDGE_CURRENT_VERSION, BRIDGE_TRANSFER_STATUS_PENDING, BRIDGE_TRANSFER_STATUS_APPROVED, BRIDGE_TRANSFER_STATUS_CLAIMED, BRIDGE_TRANSFER_STATUS_NOT_FOUND, type OnchainConstantName, type MaxNodeCountSdkLiteral, };
|
|
3
3
|
export declare const ONCHAIN_CONSTANT_MCP_CONSUMERS: Record<string, string[]>;
|
|
4
4
|
export declare function getOnchainConstant(name: OnchainConstantName): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ONCHAIN_CONSTANTS,MAX_NODE_COUNT,MAX_NODE_COUNT_ONCHAIN,MAX_FORWARD_COUNT,MAX_FORWARD_ORDER_COUNT,MAX_NODE_PAIR_COUNT,MAX_CONSENSUS_REPOSITORIES_COUNT,USER_DEFINED_PERM_INDEX_START,MAX_PERM_FOR_ENTITY,MAX_ADMIN_COUNT,MAX_AGENT_COUNT,MAX_DISPUTE_COUNT,MAX_SHARING_COUNT,MAX_VOTING_GUARD_COUNT,MAX_POLICY_COUNT,MAX_ID_COUNT_ONCE,MAX_REWARD_COUNT,MAX_GUARD_COUNT_REWARD,MAX_RECORD_COUNT_REWARD,MAX_CONTEXT_REPOSITORY_COUNT,MAX_NAMED_OPERATOR_COUNT,MAX_NAMED_OPERATOR_ADDRESS_COUNT,MAX_IM_COUNT,MAX_TAGS_COUNT,MAX_RECIPIENT_COUNT,MAX_PROPOSITION_COUNT,MAX_VOTOR_COUNT,WITHDRAW_DURATION_TIME,MAX_ADDRESS_COUNT,MAX_RECORD_LENGTH,BRIDGE_MESSAGE_VERSION,BRIDGE_EVM_ADDRESS_LENGTH,BRIDGE_CURRENT_VERSION,BRIDGE_TRANSFER_STATUS_PENDING,BRIDGE_TRANSFER_STATUS_APPROVED,BRIDGE_TRANSFER_STATUS_CLAIMED,BRIDGE_TRANSFER_STATUS_NOT_FOUND}from'@wowok/wowok';export{ONCHAIN_CONSTANTS,MAX_NODE_COUNT,MAX_NODE_COUNT_ONCHAIN,MAX_FORWARD_COUNT,MAX_FORWARD_ORDER_COUNT,MAX_NODE_PAIR_COUNT,MAX_CONSENSUS_REPOSITORIES_COUNT,USER_DEFINED_PERM_INDEX_START,MAX_PERM_FOR_ENTITY,MAX_ADMIN_COUNT,MAX_AGENT_COUNT,MAX_DISPUTE_COUNT,MAX_SHARING_COUNT,MAX_VOTING_GUARD_COUNT,MAX_POLICY_COUNT,MAX_ID_COUNT_ONCE,MAX_REWARD_COUNT,MAX_GUARD_COUNT_REWARD,MAX_RECORD_COUNT_REWARD,MAX_CONTEXT_REPOSITORY_COUNT,MAX_NAMED_OPERATOR_COUNT,MAX_NAMED_OPERATOR_ADDRESS_COUNT,MAX_IM_COUNT,MAX_TAGS_COUNT,MAX_RECIPIENT_COUNT,MAX_PROPOSITION_COUNT,MAX_VOTOR_COUNT,WITHDRAW_DURATION_TIME,MAX_ADDRESS_COUNT,MAX_RECORD_LENGTH,BRIDGE_MESSAGE_VERSION,BRIDGE_EVM_ADDRESS_LENGTH,BRIDGE_CURRENT_VERSION,BRIDGE_TRANSFER_STATUS_PENDING,BRIDGE_TRANSFER_STATUS_APPROVED,BRIDGE_TRANSFER_STATUS_CLAIMED,BRIDGE_TRANSFER_STATUS_NOT_FOUND};export const ONCHAIN_CONSTANT_MCP_CONSUMERS={'MAX_NODE_COUNT':['machine-topology.ts\x20(within_limits\x20check)','machine-risk.ts\x20R-M1-07','machine-confirm.ts\x20C-07','machine-translation.ts\x20MC-C-01','machine-context.ts\x20(hints)','knowledge/index.ts\x20(max_node_count\x20field)'],'MAX_FORWARD_ORDER_COUNT':['machine-confirm.ts\x20C-07'],'MAX_NODE_PAIR_COUNT':['machine-confirm.ts\x20C-07','machine-topology.ts\x20(within_limits\x20check)'],'USER_DEFINED_PERM_INDEX_START':['machine-risk.ts\x20R-M3-08','machine-confirm.ts\x20C-11','glossary.ts\x20(Permission\x20entry)','guard-risk.ts\x20(forward\x20permissionIndex\x20guidance)'],'MAX_VOTING_GUARD_COUNT':['arbitration-
|
|
1
|
+
import{ONCHAIN_CONSTANTS,MAX_NODE_COUNT,MAX_NODE_COUNT_ONCHAIN,MAX_FORWARD_COUNT,MAX_FORWARD_ORDER_COUNT,MAX_NODE_PAIR_COUNT,MAX_CONSENSUS_REPOSITORIES_COUNT,USER_DEFINED_PERM_INDEX_START,MAX_PERM_FOR_ENTITY,MAX_ADMIN_COUNT,MAX_ITEM_COUNT,ROLE_OWNER,ROLE_ADMIN,ROLE_ENTITY,MAX_AGENT_COUNT,MAX_DISPUTE_COUNT,MAX_SHARING_COUNT,MAX_VOTING_GUARD_COUNT,MAX_POLICY_COUNT,MAX_ID_COUNT_ONCE,MAX_REWARD_COUNT,MAX_GUARD_COUNT_REWARD,MAX_RECORD_COUNT_REWARD,MAX_CONTEXT_REPOSITORY_COUNT,MAX_NAMED_OPERATOR_COUNT,MAX_NAMED_OPERATOR_ADDRESS_COUNT,MAX_IM_COUNT,MAX_TAGS_COUNT,MAX_RECIPIENT_COUNT,MAX_PROPOSITION_COUNT,MAX_VOTOR_COUNT,WITHDRAW_DURATION_TIME,MAX_ADDRESS_COUNT,MAX_RECORD_LENGTH,BRIDGE_MESSAGE_VERSION,BRIDGE_EVM_ADDRESS_LENGTH,BRIDGE_CURRENT_VERSION,BRIDGE_TRANSFER_STATUS_PENDING,BRIDGE_TRANSFER_STATUS_APPROVED,BRIDGE_TRANSFER_STATUS_CLAIMED,BRIDGE_TRANSFER_STATUS_NOT_FOUND}from'@wowok/wowok';export{ONCHAIN_CONSTANTS,MAX_NODE_COUNT,MAX_NODE_COUNT_ONCHAIN,MAX_FORWARD_COUNT,MAX_FORWARD_ORDER_COUNT,MAX_NODE_PAIR_COUNT,MAX_CONSENSUS_REPOSITORIES_COUNT,USER_DEFINED_PERM_INDEX_START,MAX_PERM_FOR_ENTITY,MAX_ADMIN_COUNT,MAX_ITEM_COUNT,ROLE_OWNER,ROLE_ADMIN,ROLE_ENTITY,MAX_AGENT_COUNT,MAX_DISPUTE_COUNT,MAX_SHARING_COUNT,MAX_VOTING_GUARD_COUNT,MAX_POLICY_COUNT,MAX_ID_COUNT_ONCE,MAX_REWARD_COUNT,MAX_GUARD_COUNT_REWARD,MAX_RECORD_COUNT_REWARD,MAX_CONTEXT_REPOSITORY_COUNT,MAX_NAMED_OPERATOR_COUNT,MAX_NAMED_OPERATOR_ADDRESS_COUNT,MAX_IM_COUNT,MAX_TAGS_COUNT,MAX_RECIPIENT_COUNT,MAX_PROPOSITION_COUNT,MAX_VOTOR_COUNT,WITHDRAW_DURATION_TIME,MAX_ADDRESS_COUNT,MAX_RECORD_LENGTH,BRIDGE_MESSAGE_VERSION,BRIDGE_EVM_ADDRESS_LENGTH,BRIDGE_CURRENT_VERSION,BRIDGE_TRANSFER_STATUS_PENDING,BRIDGE_TRANSFER_STATUS_APPROVED,BRIDGE_TRANSFER_STATUS_CLAIMED,BRIDGE_TRANSFER_STATUS_NOT_FOUND};export const ONCHAIN_CONSTANT_MCP_CONSUMERS={'MAX_NODE_COUNT':['machine-topology.ts\x20(within_limits\x20check)','machine-risk.ts\x20R-M1-07','machine-confirm.ts\x20C-07','machine-translation.ts\x20MC-C-01','machine-context.ts\x20(hints)','knowledge/index.ts\x20(max_node_count\x20field)'],'MAX_FORWARD_ORDER_COUNT':['machine-confirm.ts\x20C-07'],'MAX_NODE_PAIR_COUNT':['machine-confirm.ts\x20C-07','machine-topology.ts\x20(within_limits\x20check)'],'USER_DEFINED_PERM_INDEX_START':['machine-risk.ts\x20R-M3-08','machine-confirm.ts\x20C-11','glossary.ts\x20(Permission\x20entry)','guard-risk.ts\x20(forward\x20permissionIndex\x20guidance)'],'MAX_VOTING_GUARD_COUNT':['evaluation/builtins/arbitration-score.ts\x20(fairness_governance\x20reason)'],'MAX_ITEM_COUNT':['permission-context.ts\x20(entity_permission\x20reverse\x20index)'],'ROLE_OWNER':['permission-context.ts\x20(entity_permission\x20role\x20flags)'],'ROLE_ADMIN':['permission-context.ts\x20(entity_permission\x20role\x20flags)'],'ROLE_ENTITY':['permission-context.ts\x20(entity_permission\x20role\x20flags)']};export function getOnchainConstant(a){const b=ONCHAIN_CONSTANTS[a];if(b===undefined)throw new Error('Unknown\x20on-chain\x20constant:\x20'+String(a));return b;}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const PAYMENT_CONFIRM_VERSION = "1.0.0";
|
|
2
|
+
export type ConfirmSeverity = "block" | "warn" | "info";
|
|
3
|
+
export interface PaymentConfirmItem {
|
|
4
|
+
id: string;
|
|
5
|
+
severity: ConfirmSeverity;
|
|
6
|
+
title: string;
|
|
7
|
+
description: string;
|
|
8
|
+
passed: boolean;
|
|
9
|
+
evidence?: string;
|
|
10
|
+
fix_hint?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface PaymentCreationCheckInput {
|
|
13
|
+
recipient_count?: number;
|
|
14
|
+
uses_unsafe_unwrap?: boolean;
|
|
15
|
+
expects_mutation?: boolean;
|
|
16
|
+
payment_info_variant?: "payment_info" | "payment_info2" | "payment_info_with_guard" | "payment_info2_with_guard";
|
|
17
|
+
uses_scene_binding?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare function preCheckPaymentCreation(input: PaymentCreationCheckInput): PaymentConfirmItem[];
|
|
20
|
+
export declare function canCreatePayment(input: PaymentCreationCheckInput): {
|
|
21
|
+
canCreate: boolean;
|
|
22
|
+
blockers: PaymentConfirmItem[];
|
|
23
|
+
warnings: PaymentConfirmItem[];
|
|
24
|
+
info: PaymentConfirmItem[];
|
|
25
|
+
};
|
|
26
|
+
export declare function formatPaymentCreationSummary(input: PaymentCreationCheckInput): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{MAX_RECIPIENT_COUNT}from'@wowok/wowok';export const PAYMENT_CONFIRM_VERSION='1.0.0';function checkRecipientCount(a){if(a['recipient_count']===undefined)return{'id':'C-PAYMENT-01','severity':'info','title':'recipient_count\x20in\x20(0,\x20MAX_RECIPIENT_COUNT]\x20('+MAX_RECIPIENT_COUNT+')','description':'create\x20aborts\x20with\x20ERECIPIENT_EMPTY\x20(4)\x20when\x200,\x20or\x20ERECIPIENT_COUNT_EXCEEDED\x20(1)\x20above\x20the\x20cap.','passed':!![],'evidence':'not\x20provided'};const b=a['recipient_count']>0x0&&a['recipient_count']<=MAX_RECIPIENT_COUNT;return{'id':'C-PAYMENT-01','severity':b?'info':'block','title':'recipient_count\x20in\x20(0,\x20MAX_RECIPIENT_COUNT]\x20('+MAX_RECIPIENT_COUNT+')','description':'Payment\x20may\x20carry\x20up\x20to\x20MAX_RECIPIENT_COUNT='+MAX_RECIPIENT_COUNT+'\x20recipients;\x200\x20aborts\x20with\x20ERECIPIENT_EMPTY\x20(4).','passed':b,'evidence':'recipient_count='+a['recipient_count']+',\x20limit='+MAX_RECIPIENT_COUNT,'fix_hint':'Split\x20mass\x20payouts\x20across\x20multiple\x20Payment\x20objects.'};}function checkUnwrap(a){const b=!!a['uses_unsafe_unwrap'];return{'id':'C-PAYMENT-02','severity':b?'block':'info','title':'unwrap_with_check\x20is\x20used\x20(Payment\x20match\x20enforced)','description':'unwrap()\x20performs\x20no\x20Payment\x20match\x20check\x20and\x20can\x20release\x20a\x20CoinWrapper\x20minted\x20for\x20a\x20different\x20Payment.\x20unwrap_with_check\x20enforces\x20EPAYMENT_NOT_MATCH\x20(3).','passed':!b,'evidence':b?'uses_unsafe_unwrap=true':'safe\x20unwrap_with_check','fix_hint':'Use\x20unwrap_with_check\x20for\x20all\x20coin\x20release\x20paths.'};}function checkImmutability(a){const b=!!a['expects_mutation'];return{'id':'C-PAYMENT-03','severity':b?'warn':'info','title':'Payment\x20is\x20immutable\x20after\x20create\x20(freeze_object)','description':'create()\x20freezes\x20the\x20Payment;\x20amount/time/info/from_object/signer/record\x20are\x20permanent.\x20Correction\x20requires\x20a\x20new\x20Payment.','passed':!b,'evidence':b?'expects_mutation=true\x20(frozen\x20at\x20create)':'immutability\x20understood','fix_hint':'Verify\x20all\x20fields\x20before\x20create;\x20issue\x20a\x20reverse\x20Payment\x20for\x20corrections.'};}function checkVariant(a){if(!a['uses_scene_binding'])return{'id':'C-PAYMENT-04','severity':'info','title':'PaymentInfo\x20variant\x20selection','description':'4\x20constructors\x20exist:\x20payment_info\x20/\x20payment_info2\x20/\x20payment_info_with_guard\x20/\x20payment_info2_with_guard.','passed':!![],'evidence':'no\x20scene\x20binding'};const b=a['payment_info_variant']==='payment_info_with_guard';return{'id':'C-PAYMENT-04','severity':b?'info':'warn','title':'Use\x20payment_info_with_guard\x20for\x20exception-branch\x20scene\x20binding','description':'For\x20anti-reuse\x20compensation\x20Payments\x20(for_object\x20+\x20for_guard\x20+\x20index),\x20always\x20use\x20payment_info_with_guard.\x20Other\x20variants\x20drop\x20for_guard\x20or\x20for_object.','passed':b,'evidence':'uses_scene_binding=true,\x20variant='+(a['payment_info_variant']??'unknown'),'fix_hint':'Select\x20payment_info_with_guard\x20to\x20bind\x20order\x20+\x20guard\x20+\x20progress\x20index.'};}export function preCheckPaymentCreation(a){return[checkRecipientCount(a),checkUnwrap(a),checkImmutability(a),checkVariant(a)];}export function canCreatePayment(a){const b=preCheckPaymentCreation(a);return{'canCreate':b['every'](c=>c['severity']!=='block'||c['passed']),'blockers':b['filter'](c=>c['severity']==='block'&&!c['passed']),'warnings':b['filter'](c=>c['severity']==='warn'&&!c['passed']),'info':b['filter'](c=>c['severity']==='info')};}export function formatPaymentCreationSummary(a){const {canCreate:b,blockers:c,warnings:d}=canCreatePayment(a),e=[b?'✓\x20Payment\x20creation\x20pre-check\x20PASSED':'✗\x20Payment\x20creation\x20pre-check\x20FAILED',''];return c['length']>0x0&&(e['push']('BLOCKERS:'),c['forEach'](f=>e['push']('\x20\x20['+f['id']+']\x20'+f['title']+'\x20—\x20'+(f['evidence']??''))),e['push']('')),d['length']>0x0&&(e['push']('WARNINGS:'),d['forEach'](f=>e['push']('\x20\x20['+f['id']+']\x20'+f['title']+'\x20—\x20'+(f['evidence']??'')))),e['join']('\x0a');}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MAX_RECIPIENT_COUNT}from'@wowok/wowok';const R_P_01={'rule':{'id':'R-PAYMENT-01','level':'HIGH','category':'permission','title':'unwrap()\x20performs\x20no\x20Payment\x20match\x20check\x20—\x20may\x20unwrap\x20wrong\x20CoinWrapper','description':'unwrap(wrapper,\x20ctx)\x20(payment.move:50)\x20returns\x20(Coin,\x20payment_address)\x20without\x20'+'verifying\x20that\x20wrapper.payment\x20matches\x20any\x20expected\x20Payment.\x20Callers\x20who\x20use\x20unwrap\x20'+'instead\x20of\x20unwrap_with_check\x20can\x20unwrap\x20a\x20CoinWrapper\x20that\x20was\x20minted\x20for\x20a\x20different\x20'+'Payment,\x20leading\x20to\x20fund\x20loss\x20or\x20accounting\x20corruption.\x20unwrap_with_check(payment_check)\x20'+'exists\x20specifically\x20to\x20enforce\x20the\x20match\x20(payment.move:54).','affected_stakeholders':['signer','recipient'],'scenario':'Caller\x20uses\x20unwrap\x20on\x20a\x20wrapper\x20from\x20a\x20different\x20Payment;\x20funds\x20are\x20released\x20anyway','mitigation':'SDK\x20should\x20force\x20callers\x20to\x20use\x20unwrap_with_check\x20and\x20deprecate\x20direct\x20unwrap\x20calls.\x20'+'The\x20only\x20safe\x20use\x20of\x20unwrap\x20is\x20when\x20the\x20caller\x20has\x20already\x20verified\x20the\x20match\x20off-chain.','related_move_error':'EPAYMENT_NOT_MATCH\x20(3)\x20—\x20only\x20raised\x20by\x20unwrap_with_check','auto_fixable':![]},'check':a=>{if(!a['uses_unsafe_unwrap'])return null;return{...R_P_01['rule'],'evidence':'uses_unsafe_unwrap=true\x20(no\x20Payment\x20match\x20check)'};}},R_P_02={'rule':{'id':'R-PAYMENT-02','level':'MEDIUM','category':'structural','title':'MAX_RECIPIENT_COUNT='+MAX_RECIPIENT_COUNT+'\x20permissive\x20—\x20gas\x20and\x20confirmation\x20cost','description':'A\x20single\x20Payment\x20may\x20carry\x20up\x20to\x20MAX_RECIPIENT_COUNT='+MAX_RECIPIENT_COUNT+'\x20recipients\x20'+'(payment.move:14).\x20The\x20limit\x20aborts\x20with\x20ERECIPIENT_COUNT_EXCEEDED\x20(1)\x20only\x20at\x20the\x20boundary.\x20'+'200\x20recipients\x20in\x20one\x20transaction\x20inflates\x20gas,\x20slows\x20finalization,\x20and\x20complicates\x20'+'retry\x20on\x20partial\x20failure.','affected_stakeholders':['signer','recipient'],'scenario':'Caller\x20submits\x20a\x20Payment\x20with\x20200\x20recipients;\x20transaction\x20is\x20heavy\x20and\x20slow','mitigation':'Business\x20layer\x20should\x20self-limit\x20recipient\x20count\x20(e.g.\x20≤50).\x20For\x20mass\x20payouts,\x20split\x20'+'across\x20multiple\x20Payment\x20objects\x20in\x20separate\x20transactions.','related_move_error':'ERECIPIENT_COUNT_EXCEEDED\x20(1)','auto_fixable':![]},'check':a=>{if(a['recipient_count']===undefined)return null;if(a['recipient_count']<MAX_RECIPIENT_COUNT)return null;return{...R_P_02['rule'],'evidence':'recipient_count='+a['recipient_count']+',\x20limit='+MAX_RECIPIENT_COUNT};}},R_P_03={'rule':{'id':'R-PAYMENT-03','level':'LOW','category':'lifecycle','title':'Payment\x20is\x20immutable\x20after\x20create\x20—\x20errors\x20cannot\x20be\x20corrected','description':'create()\x20calls\x20transfer::freeze_object(payment)\x20(payment.move:160).\x20All\x20fields\x20'+'(amount,\x20time,\x20info,\x20from_object,\x20signer,\x20record)\x20are\x20permanently\x20fixed.\x20There\x20is\x20no\x20'+'update,\x20refund,\x20or\x20void\x20API\x20on\x20the\x20Payment\x20object\x20itself\x20—\x20correction\x20requires\x20a\x20new\x20'+'Payment\x20(and\x20off-chain\x20reconciliation).','affected_stakeholders':['signer','consumer'],'scenario':'Signer\x20mistypes\x20a\x20recipient\x20address;\x20the\x20Payment\x20cannot\x20be\x20edited\x20post-create','mitigation':'Verify\x20all\x20fields\x20before\x20calling\x20create.\x20For\x20refunds,\x20create\x20a\x20new\x20Payment\x20in\x20the\x20'+'opposite\x20direction.\x20Off-chain\x20systems\x20should\x20treat\x20Payment\x20as\x20an\x20immutable\x20receipt.','auto_fixable':![]},'check':a=>{if(!a['expects_mutation'])return null;return{...R_P_03['rule'],'evidence':'expects_mutation=true\x20(Payment\x20is\x20frozen\x20at\x20create)'};}},R_P_04={'rule':{'id':'R-PAYMENT-04','level':'MEDIUM','category':'structural','title':'CoinWrapper\x20suppresses\x20coin_field\x20lint\x20—\x20Balance<T>\x20stored\x20in\x20a\x20struct\x20field','description':'CoinWrapper<phantom\x20T>\x20stores\x20Balance<T>\x20directly\x20in\x20a\x20struct\x20field\x20and\x20uses\x20'+'#[allow(lint(coin_field))]\x20to\x20suppress\x20the\x20Wow\x20lint\x20(payment.move:43-48).\x20The\x20lint\x20'+'normally\x20warns\x20against\x20storing\x20Balance\x20in\x20arbitrary\x20structs\x20because\x20of\x20object\x20'+'lifecycle\x20concerns.\x20The\x20suppression\x20is\x20intentional\x20but\x20should\x20be\x20reviewed\x20whenever\x20'+'the\x20Wow\x20framework\x20updates\x20its\x20coin_field\x20rules.','affected_stakeholders':['system'],'scenario':'Wow\x20framework\x20tightens\x20coin_field\x20lint\x20semantics;\x20CoinWrapper\x20becomes\x20non-compliant','mitigation':'Review\x20the\x20coin_field\x20suppression\x20on\x20each\x20Wow\x20upgrade.\x20Confirm\x20that\x20Balance<T>\x20'+'ownership\x20transfer\x20in\x20unwrap/unwrap_with_check\x20is\x20correct.','auto_fixable':![]},'check':a=>{if(a['coin_field_lint_reviewed'])return null;return{...R_P_04['rule'],'evidence':'coin_field_lint_reviewed=false\x20(needs\x20review)'};}},R_P_05={'rule':{'id':'R-PAYMENT-05','level':'LOW','category':'semantic','title':'PaymentInfo\x20has\x204\x20constructor\x20variants\x20—\x20caller\x20may\x20pick\x20the\x20wrong\x20one','description':'PaymentInfo\x20can\x20be\x20built\x20via\x20payment_info\x20(for_object+remark+index),\x20payment_info2\x20'+'(remark+index,\x20no\x20for_object),\x20payment_info_with_guard\x20(for_object+for_guard+remark+index),\x20'+'or\x20payment_info2_with_guard\x20(for_guard+remark+index,\x20no\x20for_object).\x20Selecting\x20the\x20'+'wrong\x20variant\x20leaves\x20for_object/for_guard\x20as\x20None,\x20breaking\x20downstream\x20lookups.','affected_stakeholders':['signer','consumer'],'scenario':'Caller\x20uses\x20payment_info2\x20when\x20they\x20meant\x20payment_info_with_guard;\x20for_object\x20is\x20lost','mitigation':'Document\x20each\x20variant\x27s\x20use\x20case\x20clearly.\x20SDK\x20should\x20pick\x20the\x20variant\x20automatically\x20'+'based\x20on\x20which\x20optional\x20fields\x20the\x20caller\x20provides.','auto_fixable':!![]},'check':a=>null},R_P_06={'rule':{'id':'R-PAYMENT-06','level':'MEDIUM','category':'cross_object','title':'Registrar\x20registration\x20filters\x20recipients\x20by\x20is_object_address\x20—\x20user\x20addresses\x20skipped','description':'create()\x20iterates\x20recipients\x20and\x20only\x20calls\x20registrar.affiliation\x20for\x20addresses\x20that\x20'+'pass\x20util::is_object_address\x20(payment.move:147-161).\x20User\x20addresses\x20(EOAs)\x20are\x20not\x20'+'registered\x20in\x20the\x20Registrar\x20dependency\x20graph.\x20Callers\x20who\x20expect\x20every\x20recipient\x20to\x20'+'appear\x20in\x20affiliation\x20queries\x20will\x20miss\x20EOA\x20recipients.','affected_stakeholders':['signer','consumer'],'scenario':'Caller\x20queries\x20Registrar\x20for\x20all\x20Payment\x20recipients;\x20EOA\x20recipients\x20are\x20missing','mitigation':'Document\x20that\x20affiliation\x20is\x20registered\x20only\x20for\x20object-address\x20recipients.\x20Off-chain\x20'+'systems\x20should\x20track\x20EOA\x20recipients\x20via\x20the\x20NewPaymentEvent\x20record,\x20not\x20via\x20Registrar.','auto_fixable':![]},'check':a=>{if(!a['expects_user_recipient_registered'])return null;return{...R_P_06['rule'],'evidence':'expects_user_recipient_registered=true\x20(EOAs\x20are\x20skipped)'};}},R_P_07={'rule':{'id':'R-PAYMENT-07','level':'LOW','category':'semantic','title':'Payment.signer\x20records\x20payer\x20—\x20useful\x20for\x20provenance\x20but\x20not\x20authorization','description':'Payment.signer\x20is\x20set\x20to\x20ctx.sender()\x20at\x20creation\x20(payment.move).\x20It\x20can\x20be\x20read\x20via\x20'+'payment_signer<T>(payment)\x20for\x20provenance\x20(e.g.\x20\x27who\x20paid\x20for\x20this\x20order\x27).\x20It\x20is\x20'+'purely\x20informational\x20—\x20it\x20does\x20NOT\x20authorize\x20any\x20later\x20operation.\x20Consumers\x20must\x20not\x20'+'treat\x20signer\x20as\x20a\x20permission\x20grant.','affected_stakeholders':['consumer'],'scenario':'Consumer\x20treats\x20Payment.signer\x20as\x20authorizing\x20a\x20refund;\x20signer\x20is\x20just\x20provenance','mitigation':'Use\x20Payment.signer\x20only\x20for\x20audit/provenance.\x20Authorization\x20must\x20come\x20from\x20the\x20'+'referencing\x20object\x27s\x20own\x20Permission,\x20not\x20from\x20Payment.signer.','auto_fixable':![]},'check':a=>{if(!a['uses_signer_for_provenance'])return null;return{...R_P_07['rule'],'evidence':'uses_signer_for_provenance=true\x20(informational\x20only)'};}},R_P_08={'rule':{'id':'R-PAYMENT-08','level':'MEDIUM','category':'semantic','title':'Payment\x20scene\x20binding\x20(for_object\x20+\x20for_guard\x20+\x20index)\x20—\x20anti-reuse\x20for\x20exception\x20branches','description':'PaymentInfo\x20supports\x20for_object\x20(binds\x20to\x20specific\x20Order),\x20for_guard\x20(binds\x20to\x20specific\x20Guard),\x20'+'and\x20index\x20(binds\x20to\x20specific\x20Progress\x20step)\x20—\x20payment.move#L66-71.\x20When\x20all\x20three\x20are\x20set\x20via\x20'+'payment_info_with_guard\x20(payment.move#L82-86),\x20the\x20Payment\x20is\x20scene-bound:\x20it\x20can\x20ONLY\x20be\x20used\x20'+'in\x20the\x20specific\x20order\x20+\x20guard\x20+\x20progress\x20context.\x20This\x20is\x20the\x20anti-reuse\x20design\x20for\x20exception\x20'+'branch\x20compensation\x20(e.g.,\x20delivery\x20delay\x20>30min\x20triggers\x20auto-compensation).\x20'+'Payment\x20is\x20immutable\x20(freeze_object,\x20payment.move#L160)\x20—\x20binding\x20cannot\x20be\x20altered.\x20'+'VERIFIER-EVIDENCE\x20DESIGN:\x20customer\x20submits\x20Payment,\x20Guard\x20verifies\x20binding\x20fields\x20match\x20current\x20context.','affected_stakeholders':['signer','recipient','consumer'],'scenario':'Treasury\x20creates\x20compensation\x20Payment\x20with\x20PaymentInfo(for_object=order,\x20for_guard=exception_guard,\x20index=current_progress)\x20for\x20delivery\x20delay','mitigation':'Use\x20payment_info_with_guard\x20for\x20all\x20exception\x20branch\x20Payments.\x20Ensure\x20for_object,\x20for_guard,\x20and\x20index\x20'+'all\x20match\x20the\x20intended\x20context.\x20Use\x20tpl_payment_exception_compensation\x20(guard-templates.ts)\x20as\x20design\x20template.','auto_fixable':![]},'check':a=>{if(!a['uses_scene_binding'])return null;const b=[];if(!a['has_for_object'])b['push']('for_object\x20not\x20set\x20(Order\x20binding\x20missing)');if(!a['has_for_guard'])b['push']('for_guard\x20not\x20set\x20(Guard\x20binding\x20missing)');if(!a['has_index'])b['push']('index\x20not\x20set\x20(Progress\x20step\x20binding\x20missing)');if(b['length']===0x0)return null;return{...R_P_08['rule'],'evidence':'incomplete\x20scene\x20binding:\x20'+b['join'](',\x20')};}},R_P_09={'rule':{'id':'R-PAYMENT-09','level':'LOW','category':'semantic','title':'PaymentInfo\x20variant\x20selection\x20—\x20use\x20payment_info_with_guard\x20for\x20exception\x20branches','description':'PaymentInfo\x20has\x204\x20constructor\x20variants\x20(payment.move#L66-86):\x20'+'payment_info\x20(for_object+remark+index,\x20no\x20for_guard),\x20'+'payment_info2\x20(remark+index,\x20no\x20for_object/for_guard),\x20'+'payment_info_with_guard\x20(for_object+for_guard+remark+index\x20—\x20FULL\x20binding),\x20'+'payment_info2_with_guard\x20(for_guard+remark+index,\x20no\x20for_object).\x20'+'For\x20exception\x20branch\x20compensation,\x20ALWAYS\x20use\x20payment_info_with_guard\x20to\x20get\x20full\x20scene\x20binding.\x20'+'Using\x20payment_info\x20(without\x20for_guard)\x20or\x20payment_info2\x20(without\x20for_object)\x20weakens\x20anti-reuse\x20protection.','affected_stakeholders':['signer','consumer'],'scenario':'Caller\x20uses\x20payment_info\x20instead\x20of\x20payment_info_with_guard\x20for\x20exception\x20compensation;\x20for_guard\x20is\x20lost','mitigation':'For\x20exception\x20branch\x20Payments:\x20always\x20use\x20payment_info_with_guard(for_object,\x20for_guard,\x20remark,\x20index).\x20'+'For\x20simple\x20Payments\x20without\x20scene\x20binding:\x20payment_info\x20or\x20payment_info2\x20is\x20fine.\x20'+'SDK\x20should\x20auto-select\x20the\x20variant\x20based\x20on\x20which\x20fields\x20are\x20provided.','auto_fixable':!![]},'check':a=>{if(!a['uses_scene_binding'])return null;if(a['payment_info_variant']==='payment_info_with_guard')return null;return{...R_P_09['rule'],'evidence':'uses_scene_binding=true\x20but\x20variant='+(a['payment_info_variant']??'unknown')+'\x20(should\x20be\x20payment_info_with_guard)'};}};export const PAYMENT_RISK_RULES=[R_P_01,R_P_02,R_P_03,R_P_04,R_P_05,R_P_06,R_P_07,R_P_08,R_P_09];export const PAYMENT_RISK_VERSION='1.0.0';export function checkPaymentRisks(a){const b=[];for(const c of PAYMENT_RISK_RULES){const d=c['check'](a);if(d)b['push'](d);}return!b['find'](e=>e['id']==='R-PAYMENT-05')&&b['push'](R_P_05['rule']),b;}export function getPaymentRiskById(a){return PAYMENT_RISK_RULES['find'](b=>b['rule']['id']===a)?.['rule'];}
|
|
1
|
+
import{MAX_RECIPIENT_COUNT}from'@wowok/wowok';const R_P_01={'rule':{'id':'R-PAYMENT-01','level':'HIGH','category':'permission','title':'unwrap()\x20performs\x20no\x20Payment\x20match\x20check\x20—\x20may\x20unwrap\x20wrong\x20CoinWrapper','description':'unwrap(wrapper,\x20ctx)\x20(payment.move:50)\x20returns\x20(Coin,\x20payment_address)\x20without\x20'+'verifying\x20that\x20wrapper.payment\x20matches\x20any\x20expected\x20Payment.\x20Callers\x20who\x20use\x20unwrap\x20'+'instead\x20of\x20unwrap_with_check\x20can\x20unwrap\x20a\x20CoinWrapper\x20that\x20was\x20minted\x20for\x20a\x20different\x20'+'Payment,\x20leading\x20to\x20fund\x20loss\x20or\x20accounting\x20corruption.\x20unwrap_with_check(payment_check)\x20'+'exists\x20specifically\x20to\x20enforce\x20the\x20match\x20(payment.move:54).','affected_stakeholders':['signer','recipient'],'scenario':'Caller\x20uses\x20unwrap\x20on\x20a\x20wrapper\x20from\x20a\x20different\x20Payment;\x20funds\x20are\x20released\x20anyway','mitigation':'SDK\x20should\x20force\x20callers\x20to\x20use\x20unwrap_with_check\x20and\x20deprecate\x20direct\x20unwrap\x20calls.\x20'+'The\x20only\x20safe\x20use\x20of\x20unwrap\x20is\x20when\x20the\x20caller\x20has\x20already\x20verified\x20the\x20match\x20off-chain.','related_move_error':'EPAYMENT_NOT_MATCH\x20(3)\x20—\x20only\x20raised\x20by\x20unwrap_with_check','auto_fixable':![]},'check':a=>{if(!a['uses_unsafe_unwrap'])return null;return{...R_P_01['rule'],'evidence':'uses_unsafe_unwrap=true\x20(no\x20Payment\x20match\x20check)'};}},R_P_02={'rule':{'id':'R-PAYMENT-02','level':'MEDIUM','category':'structural','title':'MAX_RECIPIENT_COUNT='+MAX_RECIPIENT_COUNT+'\x20permissive\x20—\x20gas\x20and\x20confirmation\x20cost','description':'A\x20single\x20Payment\x20may\x20carry\x20up\x20to\x20MAX_RECIPIENT_COUNT='+MAX_RECIPIENT_COUNT+'\x20recipients\x20'+'(payment.move:14).\x20The\x20limit\x20aborts\x20with\x20ERECIPIENT_COUNT_EXCEEDED\x20(1)\x20only\x20at\x20the\x20boundary.\x20'+'200\x20recipients\x20in\x20one\x20transaction\x20inflates\x20gas,\x20slows\x20finalization,\x20and\x20complicates\x20'+'retry\x20on\x20partial\x20failure.','affected_stakeholders':['signer','recipient'],'scenario':'Caller\x20submits\x20a\x20Payment\x20with\x20200\x20recipients;\x20transaction\x20is\x20heavy\x20and\x20slow','mitigation':'Business\x20layer\x20should\x20self-limit\x20recipient\x20count\x20(e.g.\x20≤50).\x20For\x20mass\x20payouts,\x20split\x20'+'across\x20multiple\x20Payment\x20objects\x20in\x20separate\x20transactions.','related_move_error':'ERECIPIENT_COUNT_EXCEEDED\x20(1)','auto_fixable':![]},'check':a=>{if(a['recipient_count']===undefined)return null;if(a['recipient_count']<MAX_RECIPIENT_COUNT)return null;return{...R_P_02['rule'],'evidence':'recipient_count='+a['recipient_count']+',\x20limit='+MAX_RECIPIENT_COUNT};}},R_P_03={'rule':{'id':'R-PAYMENT-03','level':'LOW','category':'lifecycle','title':'Payment\x20is\x20immutable\x20after\x20create\x20—\x20errors\x20cannot\x20be\x20corrected','description':'create()\x20calls\x20transfer::freeze_object(payment)\x20(payment.move:160).\x20All\x20fields\x20'+'(amount,\x20time,\x20info,\x20from_object,\x20signer,\x20record)\x20are\x20permanently\x20fixed.\x20There\x20is\x20no\x20'+'update,\x20refund,\x20or\x20void\x20API\x20on\x20the\x20Payment\x20object\x20itself\x20—\x20correction\x20requires\x20a\x20new\x20'+'Payment\x20(and\x20off-chain\x20reconciliation).','affected_stakeholders':['signer','consumer'],'scenario':'Signer\x20mistypes\x20a\x20recipient\x20address;\x20the\x20Payment\x20cannot\x20be\x20edited\x20post-create','mitigation':'Verify\x20all\x20fields\x20before\x20calling\x20create.\x20For\x20refunds,\x20create\x20a\x20new\x20Payment\x20in\x20the\x20'+'opposite\x20direction.\x20Off-chain\x20systems\x20should\x20treat\x20Payment\x20as\x20an\x20immutable\x20receipt.','auto_fixable':![]},'check':a=>{if(!a['expects_mutation'])return null;return{...R_P_03['rule'],'evidence':'expects_mutation=true\x20(Payment\x20is\x20frozen\x20at\x20create)'};}},R_P_04={'rule':{'id':'R-PAYMENT-04','level':'MEDIUM','category':'structural','title':'CoinWrapper\x20suppresses\x20coin_field\x20lint\x20—\x20Balance<T>\x20stored\x20in\x20a\x20struct\x20field','description':'CoinWrapper<phantom\x20T>\x20stores\x20Balance<T>\x20directly\x20in\x20a\x20struct\x20field\x20and\x20uses\x20'+'#[allow(lint(coin_field))]\x20to\x20suppress\x20the\x20Wow\x20lint\x20(payment.move:43-48).\x20The\x20lint\x20'+'normally\x20warns\x20against\x20storing\x20Balance\x20in\x20arbitrary\x20structs\x20because\x20of\x20object\x20'+'lifecycle\x20concerns.\x20The\x20suppression\x20is\x20intentional\x20but\x20should\x20be\x20reviewed\x20whenever\x20'+'the\x20Wow\x20framework\x20updates\x20its\x20coin_field\x20rules.','affected_stakeholders':['system'],'scenario':'Wow\x20framework\x20tightens\x20coin_field\x20lint\x20semantics;\x20CoinWrapper\x20becomes\x20non-compliant','mitigation':'Review\x20the\x20coin_field\x20suppression\x20on\x20each\x20Wow\x20upgrade.\x20Confirm\x20that\x20Balance<T>\x20'+'ownership\x20transfer\x20in\x20unwrap/unwrap_with_check\x20is\x20correct.','auto_fixable':![]},'check':a=>{if(a['coin_field_lint_reviewed'])return null;return{...R_P_04['rule'],'evidence':'coin_field_lint_reviewed=false\x20(needs\x20review)'};}},R_P_05={'rule':{'id':'R-PAYMENT-05','level':'LOW','category':'semantic','title':'PaymentInfo\x20has\x204\x20constructor\x20variants\x20—\x20caller\x20may\x20pick\x20the\x20wrong\x20one','description':'PaymentInfo\x20can\x20be\x20built\x20via\x20payment_info\x20(for_object+remark+index),\x20payment_info2\x20'+'(remark+index,\x20no\x20for_object),\x20payment_info_with_guard\x20(for_object+for_guard+remark+index),\x20'+'or\x20payment_info2_with_guard\x20(for_guard+remark+index,\x20no\x20for_object).\x20Selecting\x20the\x20'+'wrong\x20variant\x20leaves\x20for_object/for_guard\x20as\x20None,\x20breaking\x20downstream\x20lookups.','affected_stakeholders':['signer','consumer'],'scenario':'Caller\x20uses\x20payment_info2\x20when\x20they\x20meant\x20payment_info_with_guard;\x20for_object\x20is\x20lost','mitigation':'Document\x20each\x20variant\x27s\x20use\x20case\x20clearly.\x20SDK\x20should\x20pick\x20the\x20variant\x20automatically\x20'+'based\x20on\x20which\x20optional\x20fields\x20the\x20caller\x20provides.','auto_fixable':!![]},'check':a=>null},R_P_06={'rule':{'id':'R-PAYMENT-06','level':'MEDIUM','category':'cross_object','title':'object-linker\x20tx\x20registration\x20filters\x20recipients\x20by\x20is_object_address\x20—\x20user\x20addresses\x20skipped','description':'create()\x20iterates\x20recipients\x20and\x20only\x20calls\x20object_linker::affiliation_tx\x20for\x20addresses\x20that\x20'+'pass\x20util::is_object_address\x20(payment.move:147-161).\x20User\x20addresses\x20(EOAs)\x20are\x20not\x20'+'registered\x20in\x20the\x20object-linker\x20tx\x20index.\x20Callers\x20who\x20expect\x20every\x20recipient\x20to\x20'+'appear\x20in\x20object-linker\x20tx\x20queries\x20will\x20miss\x20EOA\x20recipients.','affected_stakeholders':['signer','consumer'],'scenario':'Caller\x20queries\x20object-linker\x20tx\x20for\x20all\x20Payment\x20recipients;\x20EOA\x20recipients\x20are\x20missing','mitigation':'Document\x20that\x20affiliation_tx\x20is\x20registered\x20only\x20for\x20object-address\x20recipients.\x20Off-chain\x20'+'systems\x20should\x20track\x20EOA\x20recipients\x20via\x20the\x20NewPaymentEvent\x20record,\x20not\x20via\x20object-linker\x20tx.','auto_fixable':![]},'check':a=>{if(!a['expects_user_recipient_registered'])return null;return{...R_P_06['rule'],'evidence':'expects_user_recipient_registered=true\x20(EOAs\x20are\x20skipped)'};}},R_P_07={'rule':{'id':'R-PAYMENT-07','level':'LOW','category':'semantic','title':'Payment.signer\x20records\x20payer\x20—\x20useful\x20for\x20provenance\x20but\x20not\x20authorization','description':'Payment.signer\x20is\x20set\x20to\x20ctx.sender()\x20at\x20creation\x20(payment.move).\x20It\x20can\x20be\x20read\x20via\x20'+'payment_signer<T>(payment)\x20for\x20provenance\x20(e.g.\x20\x27who\x20paid\x20for\x20this\x20order\x27).\x20It\x20is\x20'+'purely\x20informational\x20—\x20it\x20does\x20NOT\x20authorize\x20any\x20later\x20operation.\x20Consumers\x20must\x20not\x20'+'treat\x20signer\x20as\x20a\x20permission\x20grant.','affected_stakeholders':['consumer'],'scenario':'Consumer\x20treats\x20Payment.signer\x20as\x20authorizing\x20a\x20refund;\x20signer\x20is\x20just\x20provenance','mitigation':'Use\x20Payment.signer\x20only\x20for\x20audit/provenance.\x20Authorization\x20must\x20come\x20from\x20the\x20'+'referencing\x20object\x27s\x20own\x20Permission,\x20not\x20from\x20Payment.signer.','auto_fixable':![]},'check':a=>{if(!a['uses_signer_for_provenance'])return null;return{...R_P_07['rule'],'evidence':'uses_signer_for_provenance=true\x20(informational\x20only)'};}},R_P_08={'rule':{'id':'R-PAYMENT-08','level':'MEDIUM','category':'semantic','title':'Payment\x20scene\x20binding\x20(for_object\x20+\x20for_guard\x20+\x20index)\x20—\x20anti-reuse\x20for\x20exception\x20branches','description':'PaymentInfo\x20supports\x20for_object\x20(binds\x20to\x20specific\x20Order),\x20for_guard\x20(binds\x20to\x20specific\x20Guard),\x20'+'and\x20index\x20(binds\x20to\x20specific\x20Progress\x20step)\x20—\x20payment.move#L66-71.\x20When\x20all\x20three\x20are\x20set\x20via\x20'+'payment_info_with_guard\x20(payment.move#L82-86),\x20the\x20Payment\x20is\x20scene-bound:\x20it\x20can\x20ONLY\x20be\x20used\x20'+'in\x20the\x20specific\x20order\x20+\x20guard\x20+\x20progress\x20context.\x20This\x20is\x20the\x20anti-reuse\x20design\x20for\x20exception\x20'+'branch\x20compensation\x20(e.g.,\x20delivery\x20delay\x20>30min\x20triggers\x20auto-compensation).\x20'+'Payment\x20is\x20immutable\x20(freeze_object,\x20payment.move#L160)\x20—\x20binding\x20cannot\x20be\x20altered.\x20'+'VERIFIER-EVIDENCE\x20DESIGN:\x20customer\x20submits\x20Payment,\x20Guard\x20verifies\x20binding\x20fields\x20match\x20current\x20context.','affected_stakeholders':['signer','recipient','consumer'],'scenario':'Treasury\x20creates\x20compensation\x20Payment\x20with\x20PaymentInfo(for_object=order,\x20for_guard=exception_guard,\x20index=current_progress)\x20for\x20delivery\x20delay','mitigation':'Use\x20payment_info_with_guard\x20for\x20all\x20exception\x20branch\x20Payments.\x20Ensure\x20for_object,\x20for_guard,\x20and\x20index\x20'+'all\x20match\x20the\x20intended\x20context.\x20Use\x20tpl_payment_exception_compensation\x20(guard-templates.ts)\x20as\x20design\x20template.','auto_fixable':![]},'check':a=>{if(!a['uses_scene_binding'])return null;const b=[];if(!a['has_for_object'])b['push']('for_object\x20not\x20set\x20(Order\x20binding\x20missing)');if(!a['has_for_guard'])b['push']('for_guard\x20not\x20set\x20(Guard\x20binding\x20missing)');if(!a['has_index'])b['push']('index\x20not\x20set\x20(Progress\x20step\x20binding\x20missing)');if(b['length']===0x0)return null;return{...R_P_08['rule'],'evidence':'incomplete\x20scene\x20binding:\x20'+b['join'](',\x20')};}},R_P_09={'rule':{'id':'R-PAYMENT-09','level':'LOW','category':'semantic','title':'PaymentInfo\x20variant\x20selection\x20—\x20use\x20payment_info_with_guard\x20for\x20exception\x20branches','description':'PaymentInfo\x20has\x204\x20constructor\x20variants\x20(payment.move#L66-86):\x20'+'payment_info\x20(for_object+remark+index,\x20no\x20for_guard),\x20'+'payment_info2\x20(remark+index,\x20no\x20for_object/for_guard),\x20'+'payment_info_with_guard\x20(for_object+for_guard+remark+index\x20—\x20FULL\x20binding),\x20'+'payment_info2_with_guard\x20(for_guard+remark+index,\x20no\x20for_object).\x20'+'For\x20exception\x20branch\x20compensation,\x20ALWAYS\x20use\x20payment_info_with_guard\x20to\x20get\x20full\x20scene\x20binding.\x20'+'Using\x20payment_info\x20(without\x20for_guard)\x20or\x20payment_info2\x20(without\x20for_object)\x20weakens\x20anti-reuse\x20protection.','affected_stakeholders':['signer','consumer'],'scenario':'Caller\x20uses\x20payment_info\x20instead\x20of\x20payment_info_with_guard\x20for\x20exception\x20compensation;\x20for_guard\x20is\x20lost','mitigation':'For\x20exception\x20branch\x20Payments:\x20always\x20use\x20payment_info_with_guard(for_object,\x20for_guard,\x20remark,\x20index).\x20'+'For\x20simple\x20Payments\x20without\x20scene\x20binding:\x20payment_info\x20or\x20payment_info2\x20is\x20fine.\x20'+'SDK\x20should\x20auto-select\x20the\x20variant\x20based\x20on\x20which\x20fields\x20are\x20provided.','auto_fixable':!![]},'check':a=>{if(!a['uses_scene_binding'])return null;if(a['payment_info_variant']==='payment_info_with_guard')return null;return{...R_P_09['rule'],'evidence':'uses_scene_binding=true\x20but\x20variant='+(a['payment_info_variant']??'unknown')+'\x20(should\x20be\x20payment_info_with_guard)'};}};export const PAYMENT_RISK_RULES=[R_P_01,R_P_02,R_P_03,R_P_04,R_P_05,R_P_06,R_P_07,R_P_08,R_P_09];export const PAYMENT_RISK_VERSION='1.0.0';export function checkPaymentRisks(a){const b=[];for(const c of PAYMENT_RISK_RULES){const d=c['check'](a);if(d)b['push'](d);}return!b['find'](e=>e['id']==='R-PAYMENT-05')&&b['push'](R_P_05['rule']),b;}export function getPaymentRiskById(a){return PAYMENT_RISK_RULES['find'](b=>b['rule']['id']===a)?.['rule'];}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export declare const PAYMENT_TRANSLATION_VERSION = "1.0.0";
|
|
2
|
+
export interface SemanticToPaymentSchemaRule {
|
|
3
|
+
id: string;
|
|
4
|
+
pattern_name: string;
|
|
5
|
+
semantic_intent: string;
|
|
6
|
+
match_keywords: string[];
|
|
7
|
+
required_fields: string[];
|
|
8
|
+
optional_fields: string[];
|
|
9
|
+
example: Record<string, unknown>;
|
|
10
|
+
}
|
|
11
|
+
export declare const SEMANTIC_TO_PAYMENT_SCHEMA_RULES: SemanticToPaymentSchemaRule[];
|
|
12
|
+
export interface PaymentFieldTranslation {
|
|
13
|
+
field_name: string;
|
|
14
|
+
value_type: string;
|
|
15
|
+
semantic: string;
|
|
16
|
+
format_example: string;
|
|
17
|
+
validation_rules: string[];
|
|
18
|
+
}
|
|
19
|
+
export declare const PAYMENT_FIELD_TRANSLATIONS: PaymentFieldTranslation[];
|
|
20
|
+
export interface PaymentConstraintRule {
|
|
21
|
+
id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
description: string;
|
|
24
|
+
related_field: string;
|
|
25
|
+
}
|
|
26
|
+
export declare const PAYMENT_CONSTRAINT_RULES: PaymentConstraintRule[];
|
|
27
|
+
export interface PaymentExplainInput {
|
|
28
|
+
recipient_count?: number;
|
|
29
|
+
payment_info_variant?: "payment_info" | "payment_info2" | "payment_info_with_guard" | "payment_info2_with_guard";
|
|
30
|
+
amount?: number;
|
|
31
|
+
}
|
|
32
|
+
export interface PaymentExplanation {
|
|
33
|
+
summary: string;
|
|
34
|
+
variant: string;
|
|
35
|
+
warnings: string[];
|
|
36
|
+
}
|
|
37
|
+
export declare function explainPayment(input: PaymentExplainInput): PaymentExplanation;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{MAX_RECIPIENT_COUNT}from'@wowok/wowok';export const PAYMENT_TRANSLATION_VERSION='1.0.0';export const SEMANTIC_TO_PAYMENT_SCHEMA_RULES=[{'id':'P-PAYMENT-01','pattern_name':'Single-recipient\x20payment','semantic_intent':'Pay\x20a\x20single\x20recipient\x20(new_singleton\x20wraps\x20a\x20CoinWrapper).','match_keywords':['pay','single\x20payment','send\x20to'],'required_fields':['recipient','coin','info'],'optional_fields':[],'example':{'recipient':'0x...','coin':'0x...','info':{'remark':'refund','index':0x0}}},{'id':'P-PAYMENT-02','pattern_name':'Multi-recipient\x20payment','semantic_intent':'Split\x20coins\x20across\x20multiple\x20recipients\x20(new).','match_keywords':['batch\x20pay','multi\x20recipient','mass\x20payout'],'required_fields':['recipient','coin','info'],'optional_fields':[],'example':{'recipient':['0x...','0x...'],'coin':['0x...','0x...'],'info':{'remark':'split','index':0x0}}},{'id':'P-PAYMENT-03','pattern_name':'Scene-bound\x20compensation','semantic_intent':'Exception-branch\x20compensation\x20with\x20full\x20scene\x20binding\x20(for_object+for_guard+index).','match_keywords':['compensation','exception','auto\x20refund'],'required_fields':['recipient','coin','info'],'optional_fields':[],'example':{'recipient':'0x...','coin':'0x...','info':{'for_object':'0x...','for_guard':'0x...','remark':'delay','index':0x2}}}];export const PAYMENT_FIELD_TRANSLATIONS=[{'field_name':'amount','value_type':'u64','semantic':'Total\x20transferred\x20amount.','format_example':'1000000000','validation_rules':['derived\x20from\x20coin\x20values']},{'field_name':'time','value_type':'u64','semantic':'Creation\x20timestamp\x20(clock::timestamp_ms).','format_example':'1710000000000','validation_rules':['frozen\x20at\x20create']},{'field_name':'info','value_type':'PaymentInfo','semantic':'Context\x20binding:\x20for_object\x20/\x20for_guard\x20/\x20remark\x20/\x20index.','format_example':'{for_object,\x20for_guard,\x20remark,\x20index}','validation_rules':['remark\x20uses\x20common::NAME_ALLOW_EMPTY']},{'field_name':'from_object','value_type':'Option<address>','semantic':'Source\x20object\x20(set\x20via\x20from_object_set).','format_example':'0x...order...','validation_rules':['optional']},{'field_name':'signer','value_type':'address','semantic':'Payer\x20address\x20(provenance\x20only,\x20not\x20authorization).','format_example':'0x...payer...','validation_rules':['informational']},{'field_name':'record','value_type':'vector<Revenue>','semantic':'Recipient\x20list\x20(≤\x20MAX_RECIPIENT_COUNT\x20'+MAX_RECIPIENT_COUNT+');\x20Revenue{recipient,\x20amount}.','format_example':'[{recipient,\x20amount}]','validation_rules':['ERECIPIENT_EMPTY\x20(4)\x20when\x200','ERECIPIENT_COUNT_EXCEEDED\x20(1)\x20at\x20cap','EVECTOR_COUNT_NOT_EQUAL\x20(2)']}];export const PAYMENT_CONSTRAINT_RULES=[{'id':'PAYMENT_C_01','name':'recipient\x20count','description':'0\x20<\x20count\x20≤\x20MAX_RECIPIENT_COUNT\x20('+MAX_RECIPIENT_COUNT+').','related_field':'record'},{'id':'PAYMENT_C_02','name':'vector\x20length\x20match','description':'recipient\x20count\x20==\x20coin\x20count\x20(EVECTOR_COUNT_NOT_EQUAL\x202).','related_field':'record'},{'id':'PAYMENT_C_03','name':'unwrap\x20match','description':'unwrap_with_check\x20enforces\x20payment\x20match\x20(EPAYMENT_NOT_MATCH\x203).','related_field':'record'},{'id':'PAYMENT_C_04','name':'immutability','description':'create()\x20freezes\x20the\x20Payment;\x20no\x20post-create\x20edit.','related_field':'amount'}];export function explainPayment(a){const b=[],c=a['payment_info_variant']??'unknown';if(a['recipient_count']!==undefined){if(a['recipient_count']<=0x0)b['push']('recipient_count\x200\x20→\x20ERECIPIENT_EMPTY');if(a['recipient_count']>MAX_RECIPIENT_COUNT)b['push']('recipient_count\x20'+a['recipient_count']+'\x20>\x20'+MAX_RECIPIENT_COUNT);}return a['payment_info_variant']&&a['payment_info_variant']!=='payment_info_with_guard'&&b['push']('consider\x20payment_info_with_guard\x20for\x20scene-bound\x20exception\x20payments'),{'summary':'Payment\x20amount='+(a['amount']??'?')+'.\x20variant='+c+'.\x20'+(a['recipient_count']??'?')+'\x20recipients.','variant':c,'warnings':b};}
|
|
@@ -54,5 +54,16 @@ export interface BuildPermissionContextInput {
|
|
|
54
54
|
max_length?: number;
|
|
55
55
|
}
|
|
56
56
|
export declare function buildPermissionContext(input: BuildPermissionContextInput): PermissionContextBundle;
|
|
57
|
+
export declare const ENTITY_PERMISSION_ERROR_CODES: {
|
|
58
|
+
readonly E_ITEM_COUNT_EXCEEDED: 1;
|
|
59
|
+
readonly E_NOT_SYSTEM_ADDRESS: 2;
|
|
60
|
+
};
|
|
61
|
+
export declare const ENTITY_PERMISSION_OBJECT_ID = "0xaad";
|
|
62
|
+
export declare const ENTITY_CONTACT_OBJECT_ID = "0xaa9";
|
|
63
|
+
export declare const OBJECT_LINKER_CORE_OBJECT_ID = "0xaae";
|
|
64
|
+
export declare const OBJECT_LINKER_TX_OBJECT_ID = "0xaaf";
|
|
65
|
+
export declare const VOTE_BIT_LIKE = 2;
|
|
66
|
+
export declare const VOTE_BIT_DISLIKE = 4;
|
|
67
|
+
export declare const VOTE_BIT_FAVOR = 8;
|
|
57
68
|
export declare function buildPromptFromPermissionContext(bundle: PermissionContextBundle): string;
|
|
58
69
|
export declare function getPermissionContextSummary(bundle: PermissionContextBundle): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{USER_DEFINED_PERM_INDEX_START,MAX_ENTITY_COUNT,MAX_PERM_FOR_ENTITY,MAX_ADMIN_COUNT}from'@wowok/wowok';import{PERMISSION_SCENES,findSceneByPermissionIndex,inferSceneFromIntent,getScenesByHostObject,getAllBuiltinPermissions}from'./permission-ledger.js';import{getTemplatesByScene}from'./permission-templates.js';import{matchSemanticPattern}from'./permission-translation.js';import{getAllRiskRules,assessPermissionRisks}from'./permission-risk.js';import{initPuzzleFromIntent,checkPuzzleCompleteness}from'./permission-puzzle.js';import{PERMISSION_PUBLISH_CHECKLIST,PERMISSION_CONFIRMATION_QUESTIONS}from'./permission-confirm.js';export const PERMISSION_CONTEXT_VERSION='1.0.0';export function buildPermissionContext(a){const b=a['max_length']??0xfa0;let c;if(a['intent'])c=inferSceneFromIntent(a['intent']);else{if(a['target_permission_index']!==undefined)c=findSceneByPermissionIndex(a['target_permission_index']);else{if(a['target_host_object']){const p=getScenesByHostObject(a['target_host_object']);if(p['length']>0x0)c=p[0x0];}}}let d;if(c){const q=getTemplatesByScene(c['id']);if(q['length']>0x0)d=q[0x0];}let e;if(a['intent']){const r=matchSemanticPattern(a['intent']);if(r['length']>0x0)e=r[0x0];}let f,g;a['mode']==='initial_design'&&a['intent']&&(f=initPuzzleFromIntent({'rule_sentence':a['intent']}),g=checkPuzzleCompleteness(f));const h=filterRiskRules(a['mode'],a['stakeholder'],c);let i;if(a['mode']==='pre_publish'&&a['permission_json']){const s={'object':a['permission_json']['object'],'admin':a['permission_json']['admin'],'table':a['permission_json']['table'],'entity':a['permission_json']['entity'],'remark':a['permission_json']['remark'],'apply':a['permission_json']['apply'],'builder':a['permission_json']['builder'],'um':a['permission_json']['um']};i=assessPermissionRisks(s);}const j=filterChecklist(a['mode']),k=filterQuestions(a['mode']),l=c?c['builtin_indexes']:getAllBuiltinPermissions(),m=buildCrossObjectRefs(c),n=buildOnchainConstraints(),o=buildRenderingHints(a['mode'],b,!!a['permission_json']?.['builder']);return{'version':PERMISSION_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,'cross_object_refs':m,'onchain_constraints':n,'rendering_hints':o};}function filterRiskRules(a,b,c){let d=getAllRiskRules();if(a==='initial_design')return d['filter'](e=>e['category']==='structural'||e['category']==='authority');if(a==='pre_publish')return d;if(a==='stakeholder_review'&&b){if(b==='owner')return d['filter'](e=>e['category']==='authority'||e['category']==='lifecycle');if(b==='admin')return d['filter'](e=>e['category']==='structural'||e['category']==='semantic');}return d;}function filterChecklist(a){if(a==='initial_design')return PERMISSION_PUBLISH_CHECKLIST['filter'](b=>['C-P-01','C-P-02','C-P-03','C-P-04']['includes'](b['id']));return PERMISSION_PUBLISH_CHECKLIST;}function filterQuestions(a){if(a==='pre_publish')return PERMISSION_CONFIRMATION_QUESTIONS;if(a==='post_publish_modify')return PERMISSION_CONFIRMATION_QUESTIONS['filter'](b=>b['id']!=='QP5');return[];}function buildCrossObjectRefs(a){if(!a)return[];const b=[];for(const c of PERMISSION_SCENES){if(c['host_object']===a['host_object']||c['id']===a['id'])continue;b['push']({'object':c['host_object'],'field':'permission','scene_id':c['id'],'description':c['host_object']+'\x20uses\x20permission\x20indexes\x20'+c['permission_index_range']});}return b;}function buildOnchainConstraints(){return[{'name':'USER_DEFINED_PERM_INDEX_START','value':USER_DEFINED_PERM_INDEX_START,'description':'Custom\x20permission\x20indexes\x20must\x20be\x20>=\x20this\x20value'},{'name':'MAX_ENTITY_COUNT','value':MAX_ENTITY_COUNT,'description':'Maximum\x20entities\x20per\x20Permission'},{'name':'MAX_PERM_FOR_ENTITY','value':MAX_PERM_FOR_ENTITY,'description':'Maximum\x20permission\x20indexes\x20per\x20entity'},{'name':'MAX_ADMIN_COUNT','value':MAX_ADMIN_COUNT,'description':'Maximum\x20admins\x20per\x20Permission'}];}function buildRenderingHints(a,b,c){return{'include_puzzle_template':a==='initial_design','include_risk_details':a==='pre_publish'||a==='stakeholder_review','include_questions':a==='pre_publish','include_immutability_warning':a==='post_publish_modify','include_transfer_warning':c,'max_length':b};}export function buildPromptFromPermissionContext(a){const b=[],d=a['rendering_hints'];b['push']('═══\x20Permission\x20Context\x20(mode:\x20'+a['mode']+')\x20═══'),b['push']('');a['matched_scene']&&(b['push']('Scene:\x20'+a['matched_scene']['name']),b['push']('Host\x20object:\x20'+a['matched_scene']['host_object']),b['push']('Permission\x20range:\x20'+a['matched_scene']['permission_index_range']),b['push'](''));a['matched_template']&&(b['push']('Suggested\x20template:\x20'+a['matched_template']['id']+'\x20—\x20'+a['matched_template']['name']),b['push'](''));if(d['include_puzzle_template']&&a['puzzle_completeness']){const e=a['puzzle_completeness'];b['push']('─\x20Puzzle\x20Completeness\x20──────────────'),b['push']('Complete:\x20'+(e['complete']?'YES':'NO')),e['missing']['length']>0x0&&b['push']('Missing:\x20'+e['missing']['join'](',\x20')),b['push']('Next:\x20'+e['next_step']),b['push']('');}if(d['include_risk_details']&&a['relevant_risks']['length']>0x0){b['push']('─\x20Relevant\x20Risk\x20Rules\x20('+a['relevant_risks']['length']+')\x20──────────────');for(const f of a['relevant_risks']['slice'](0x0,0x5)){b['push']('\x20\x20'+f['id']+'\x20—\x20'+f['trigger']);}a['relevant_risks']['length']>0x5&&b['push']('\x20\x20...\x20and\x20'+(a['relevant_risks']['length']-0x5)+'\x20more'),b['push']('');}a['risk_assessment']&&(b['push']('─\x20Risk\x20Assessment\x20──────────────'),b['push']('Overall:\x20'+a['risk_assessment']['overall_risk']),b['push']('Detected:\x20'+a['risk_assessment']['risks']['length']+'\x20risk(s)'),b['push'](''));if(a['relevant_builtin_permissions']['length']>0x0){b['push']('─\x20Builtin\x20Permissions\x20('+a['relevant_builtin_permissions']['length']+')\x20──────────────');for(const g of a['relevant_builtin_permissions']['slice'](0x0,0x8)){b['push']('\x20\x20['+g['index']+']\x20'+g['name']+':\x20'+g['description']);}a['relevant_builtin_permissions']['length']>0x8&&b['push']('\x20\x20...\x20and\x20'+(a['relevant_builtin_permissions']['length']-0x8)+'\x20more'),b['push']('');}d['include_transfer_warning']&&(b['push']('⚠️\x20TRANSFER\x20OPERATION\x20DETECTED\x20—\x20This\x20is\x20IRREVERSIBLE'),b['push'](''));if(a['onchain_constraints']['length']>0x0){b['push']('─\x20On-chain\x20Constraints\x20──────────────');for(const i of a['onchain_constraints']){b['push']('\x20\x20'+i['name']+'\x20=\x20'+i['value']+'\x20—\x20'+i['description']);}b['push']('');}return b['join']('\x0a');}export function getPermissionContextSummary(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']);return b['join'](',\x20');}
|
|
1
|
+
import{USER_DEFINED_PERM_INDEX_START,MAX_ENTITY_COUNT,MAX_PERM_FOR_ENTITY,MAX_ADMIN_COUNT,MAX_ITEM_COUNT,ROLE_OWNER,ROLE_ADMIN,ROLE_ENTITY}from'@wowok/wowok';import{PERMISSION_SCENES,findSceneByPermissionIndex,inferSceneFromIntent,getScenesByHostObject,getAllBuiltinPermissions}from'./permission-ledger.js';import{getTemplatesByScene}from'./permission-templates.js';import{matchSemanticPattern}from'./permission-translation.js';import{getAllRiskRules,assessPermissionRisks}from'./permission-risk.js';import{initPuzzleFromIntent,checkPuzzleCompleteness}from'./permission-puzzle.js';import{PERMISSION_PUBLISH_CHECKLIST,PERMISSION_CONFIRMATION_QUESTIONS}from'./permission-confirm.js';export const PERMISSION_CONTEXT_VERSION='1.0.0';export function buildPermissionContext(a){const b=a['max_length']??0xfa0;let c;if(a['intent'])c=inferSceneFromIntent(a['intent']);else{if(a['target_permission_index']!==undefined)c=findSceneByPermissionIndex(a['target_permission_index']);else{if(a['target_host_object']){const p=getScenesByHostObject(a['target_host_object']);if(p['length']>0x0)c=p[0x0];}}}let d;if(c){const q=getTemplatesByScene(c['id']);if(q['length']>0x0)d=q[0x0];}let e;if(a['intent']){const r=matchSemanticPattern(a['intent']);if(r['length']>0x0)e=r[0x0];}let f,g;a['mode']==='initial_design'&&a['intent']&&(f=initPuzzleFromIntent({'rule_sentence':a['intent']}),g=checkPuzzleCompleteness(f));const h=filterRiskRules(a['mode'],a['stakeholder'],c);let i;if(a['mode']==='pre_publish'&&a['permission_json']){const s={'object':a['permission_json']['object'],'admin':a['permission_json']['admin'],'table':a['permission_json']['table'],'entity':a['permission_json']['entity'],'remark':a['permission_json']['remark'],'apply':a['permission_json']['apply'],'builder':a['permission_json']['builder'],'um':a['permission_json']['um']};i=assessPermissionRisks(s);}const j=filterChecklist(a['mode']),k=filterQuestions(a['mode']),l=c?c['builtin_indexes']:getAllBuiltinPermissions(),m=buildCrossObjectRefs(c),n=buildOnchainConstraints(),o=buildRenderingHints(a['mode'],b,!!a['permission_json']?.['builder']);return{'version':PERMISSION_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,'cross_object_refs':m,'onchain_constraints':n,'rendering_hints':o};}function filterRiskRules(a,b,c){let d=getAllRiskRules();if(a==='initial_design')return d['filter'](e=>e['category']==='structural'||e['category']==='authority');if(a==='pre_publish')return d;if(a==='stakeholder_review'&&b){if(b==='owner')return d['filter'](e=>e['category']==='authority'||e['category']==='lifecycle');if(b==='admin')return d['filter'](e=>e['category']==='structural'||e['category']==='semantic');}return d;}function filterChecklist(a){if(a==='initial_design')return PERMISSION_PUBLISH_CHECKLIST['filter'](b=>['C-P-01','C-P-02','C-P-03','C-P-04']['includes'](b['id']));return PERMISSION_PUBLISH_CHECKLIST;}function filterQuestions(a){if(a==='pre_publish')return PERMISSION_CONFIRMATION_QUESTIONS;if(a==='post_publish_modify')return PERMISSION_CONFIRMATION_QUESTIONS['filter'](b=>b['id']!=='QP5');return[];}function buildCrossObjectRefs(a){if(!a)return[];const b=[];for(const c of PERMISSION_SCENES){if(c['host_object']===a['host_object']||c['id']===a['id'])continue;b['push']({'object':c['host_object'],'field':'permission','scene_id':c['id'],'description':c['host_object']+'\x20uses\x20permission\x20indexes\x20'+c['permission_index_range']});}return b;}function buildOnchainConstraints(){return[{'name':'USER_DEFINED_PERM_INDEX_START','value':USER_DEFINED_PERM_INDEX_START,'description':'Custom\x20permission\x20indexes\x20must\x20be\x20>=\x20this\x20value'},{'name':'MAX_ENTITY_COUNT','value':MAX_ENTITY_COUNT,'description':'Maximum\x20entities\x20per\x20Permission'},{'name':'MAX_PERM_FOR_ENTITY','value':MAX_PERM_FOR_ENTITY,'description':'Maximum\x20permission\x20indexes\x20per\x20entity'},{'name':'MAX_ADMIN_COUNT','value':MAX_ADMIN_COUNT,'description':'Maximum\x20admins\x20per\x20Permission'},{'name':'MAX_ITEM_COUNT','value':MAX_ITEM_COUNT,'description':'Maximum\x20permissions\x20per\x20entity\x20in\x20the\x20global\x20reverse\x20index'},{'name':'ROLE_OWNER','value':ROLE_OWNER,'description':'Entity\x20permission\x20role\x20flag:\x20owner'},{'name':'ROLE_ADMIN','value':ROLE_ADMIN,'description':'Entity\x20permission\x20role\x20flag:\x20admin'},{'name':'ROLE_ENTITY','value':ROLE_ENTITY,'description':'Entity\x20permission\x20role\x20flag:\x20entity'}];}export const ENTITY_PERMISSION_ERROR_CODES={'E_ITEM_COUNT_EXCEEDED':0x1,'E_NOT_SYSTEM_ADDRESS':0x2};export const ENTITY_PERMISSION_OBJECT_ID='0xaad';export const ENTITY_CONTACT_OBJECT_ID='0xaa9';export const OBJECT_LINKER_CORE_OBJECT_ID='0xaae';export const OBJECT_LINKER_TX_OBJECT_ID='0xaaf';export const VOTE_BIT_LIKE=0x2;export const VOTE_BIT_DISLIKE=0x4;export const VOTE_BIT_FAVOR=0x8;function buildRenderingHints(a,b,c){return{'include_puzzle_template':a==='initial_design','include_risk_details':a==='pre_publish'||a==='stakeholder_review','include_questions':a==='pre_publish','include_immutability_warning':a==='post_publish_modify','include_transfer_warning':c,'max_length':b};}export function buildPromptFromPermissionContext(a){const b=[],d=a['rendering_hints'];b['push']('═══\x20Permission\x20Context\x20(mode:\x20'+a['mode']+')\x20═══'),b['push']('');a['matched_scene']&&(b['push']('Scene:\x20'+a['matched_scene']['name']),b['push']('Host\x20object:\x20'+a['matched_scene']['host_object']),b['push']('Permission\x20range:\x20'+a['matched_scene']['permission_index_range']),b['push'](''));a['matched_template']&&(b['push']('Suggested\x20template:\x20'+a['matched_template']['id']+'\x20—\x20'+a['matched_template']['name']),b['push'](''));if(d['include_puzzle_template']&&a['puzzle_completeness']){const e=a['puzzle_completeness'];b['push']('─\x20Puzzle\x20Completeness\x20──────────────'),b['push']('Complete:\x20'+(e['complete']?'YES':'NO')),e['missing']['length']>0x0&&b['push']('Missing:\x20'+e['missing']['join'](',\x20')),b['push']('Next:\x20'+e['next_step']),b['push']('');}if(d['include_risk_details']&&a['relevant_risks']['length']>0x0){b['push']('─\x20Relevant\x20Risk\x20Rules\x20('+a['relevant_risks']['length']+')\x20──────────────');for(const f of a['relevant_risks']['slice'](0x0,0x5)){b['push']('\x20\x20'+f['id']+'\x20—\x20'+f['trigger']);}a['relevant_risks']['length']>0x5&&b['push']('\x20\x20...\x20and\x20'+(a['relevant_risks']['length']-0x5)+'\x20more'),b['push']('');}a['risk_assessment']&&(b['push']('─\x20Risk\x20Assessment\x20──────────────'),b['push']('Overall:\x20'+a['risk_assessment']['overall_risk']),b['push']('Detected:\x20'+a['risk_assessment']['risks']['length']+'\x20risk(s)'),b['push'](''));if(a['relevant_builtin_permissions']['length']>0x0){b['push']('─\x20Builtin\x20Permissions\x20('+a['relevant_builtin_permissions']['length']+')\x20──────────────');for(const g of a['relevant_builtin_permissions']['slice'](0x0,0x8)){b['push']('\x20\x20['+g['index']+']\x20'+g['name']+':\x20'+g['description']);}a['relevant_builtin_permissions']['length']>0x8&&b['push']('\x20\x20...\x20and\x20'+(a['relevant_builtin_permissions']['length']-0x8)+'\x20more'),b['push']('');}d['include_transfer_warning']&&(b['push']('⚠️\x20TRANSFER\x20OPERATION\x20DETECTED\x20—\x20This\x20is\x20IRREVERSIBLE'),b['push'](''));if(a['onchain_constraints']['length']>0x0){b['push']('─\x20On-chain\x20Constraints\x20──────────────');for(const i of a['onchain_constraints']){b['push']('\x20\x20'+i['name']+'\x20=\x20'+i['value']+'\x20—\x20'+i['description']);}b['push']('');}return b['join']('\x0a');}export function getPermissionContextSummary(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']);return b['join'](',\x20');}
|
|
@@ -17,6 +17,17 @@ export interface BuiltinPermissionEntry {
|
|
|
17
17
|
description: string;
|
|
18
18
|
governed_operation: string;
|
|
19
19
|
}
|
|
20
|
+
export type PermissionScope = "organization" | "order" | "order_holder";
|
|
21
|
+
export interface PermissionTypeDef {
|
|
22
|
+
name: "Permission" | "NamedOperator" | "OrderHolder";
|
|
23
|
+
scope: PermissionScope;
|
|
24
|
+
definedOn: string;
|
|
25
|
+
controls: string;
|
|
26
|
+
grantedBy: string;
|
|
27
|
+
example: string;
|
|
28
|
+
}
|
|
29
|
+
export declare const PERMISSION_TYPES: PermissionTypeDef[];
|
|
30
|
+
export declare function getPermissionType(name: string): PermissionTypeDef | undefined;
|
|
20
31
|
export declare const REPOSITORY_PERMISSIONS: BuiltinPermissionEntry[];
|
|
21
32
|
export declare const REWARD_PERMISSIONS: BuiltinPermissionEntry[];
|
|
22
33
|
export declare const MACHINE_PERMISSIONS: BuiltinPermissionEntry[];
|