@dataparade/cli 0.0.1
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/LICENSE +674 -0
- package/README.md +592 -0
- package/dist/bin/cli.d.ts +2 -0
- package/dist/bin/cli.js +7 -0
- package/dist/bin/load-env.d.ts +2 -0
- package/dist/bin/load-env.js +4 -0
- package/dist/src/ai-enrichment/agent-orchestrator.d.ts +28 -0
- package/dist/src/ai-enrichment/agent-orchestrator.js +476 -0
- package/dist/src/ai-enrichment/agents/index.d.ts +4 -0
- package/dist/src/ai-enrichment/agents/index.js +50 -0
- package/dist/src/ai-enrichment/candidate-selector.d.ts +10 -0
- package/dist/src/ai-enrichment/candidate-selector.js +158 -0
- package/dist/src/ai-enrichment/fallbacks.d.ts +6 -0
- package/dist/src/ai-enrichment/fallbacks.js +762 -0
- package/dist/src/ai-enrichment/index.d.ts +15 -0
- package/dist/src/ai-enrichment/index.js +31 -0
- package/dist/src/ai-enrichment/merge-rules.d.ts +12 -0
- package/dist/src/ai-enrichment/merge-rules.js +321 -0
- package/dist/src/ai-enrichment/non-pii-signal-rules.d.ts +10 -0
- package/dist/src/ai-enrichment/non-pii-signal-rules.js +72 -0
- package/dist/src/ai-enrichment/openai-proposals-response.schema.d.ts +94 -0
- package/dist/src/ai-enrichment/openai-proposals-response.schema.js +82 -0
- package/dist/src/ai-enrichment/pii-signal-rules.d.ts +8 -0
- package/dist/src/ai-enrichment/pii-signal-rules.js +68 -0
- package/dist/src/ai-enrichment/pipeline.d.ts +2 -0
- package/dist/src/ai-enrichment/pipeline.js +48 -0
- package/dist/src/ai-enrichment/planner.d.ts +2 -0
- package/dist/src/ai-enrichment/planner.js +60 -0
- package/dist/src/ai-enrichment/prompts/provider-enrichment-prompts.d.ts +12 -0
- package/dist/src/ai-enrichment/prompts/provider-enrichment-prompts.js +45 -0
- package/dist/src/ai-enrichment/provider-prompt.d.ts +32 -0
- package/dist/src/ai-enrichment/provider-prompt.js +222 -0
- package/dist/src/ai-enrichment/provider-topology-rules.d.ts +52 -0
- package/dist/src/ai-enrichment/provider-topology-rules.js +190 -0
- package/dist/src/ai-enrichment/provider-topology-shared.d.ts +48 -0
- package/dist/src/ai-enrichment/provider-topology-shared.js +329 -0
- package/dist/src/ai-enrichment/providers/endpoint-resolution.d.ts +13 -0
- package/dist/src/ai-enrichment/providers/endpoint-resolution.js +41 -0
- package/dist/src/ai-enrichment/providers/families/chat-completions-family.d.ts +13 -0
- package/dist/src/ai-enrichment/providers/families/chat-completions-family.js +181 -0
- package/dist/src/ai-enrichment/providers/families/generate-content-family.d.ts +10 -0
- package/dist/src/ai-enrichment/providers/families/generate-content-family.js +93 -0
- package/dist/src/ai-enrichment/providers/families/messages-family.d.ts +10 -0
- package/dist/src/ai-enrichment/providers/families/messages-family.js +86 -0
- package/dist/src/ai-enrichment/providers/families/ollama-generate-family.d.ts +10 -0
- package/dist/src/ai-enrichment/providers/families/ollama-generate-family.js +69 -0
- package/dist/src/ai-enrichment/providers/fetch-with-timeout.d.ts +2 -0
- package/dist/src/ai-enrichment/providers/fetch-with-timeout.js +22 -0
- package/dist/src/ai-enrichment/providers/index.d.ts +16 -0
- package/dist/src/ai-enrichment/providers/index.js +40 -0
- package/dist/src/ai-enrichment/providers/mock.d.ts +5 -0
- package/dist/src/ai-enrichment/providers/mock.js +12 -0
- package/dist/src/ai-enrichment/providers/platform-proxy-provider.d.ts +20 -0
- package/dist/src/ai-enrichment/providers/platform-proxy-provider.js +116 -0
- package/dist/src/ai-enrichment/providers/presets.d.ts +14 -0
- package/dist/src/ai-enrichment/providers/presets.js +50 -0
- package/dist/src/ai-enrichment/providers/provider-contract.d.ts +20 -0
- package/dist/src/ai-enrichment/providers/provider-contract.js +703 -0
- package/dist/src/ai-enrichment/providers/provider-json-parse.d.ts +23 -0
- package/dist/src/ai-enrichment/providers/provider-json-parse.js +96 -0
- package/dist/src/ai-enrichment/providers/provider-output-token-budget.d.ts +5 -0
- package/dist/src/ai-enrichment/providers/provider-output-token-budget.js +11 -0
- package/dist/src/ai-enrichment/providers/provider-pricing.d.ts +7 -0
- package/dist/src/ai-enrichment/providers/provider-pricing.js +32 -0
- package/dist/src/ai-enrichment/providers/provider-runtime.d.ts +9 -0
- package/dist/src/ai-enrichment/providers/provider-runtime.js +54 -0
- package/dist/src/ai-enrichment/providers/resolve-provider.d.ts +27 -0
- package/dist/src/ai-enrichment/providers/resolve-provider.js +41 -0
- package/dist/src/ai-enrichment/providers/types.d.ts +24 -0
- package/dist/src/ai-enrichment/providers/types.js +2 -0
- package/dist/src/ai-enrichment/scan-paths.d.ts +9 -0
- package/dist/src/ai-enrichment/scan-paths.js +28 -0
- package/dist/src/ai-enrichment/sensitive-paths.d.ts +5 -0
- package/dist/src/ai-enrichment/sensitive-paths.js +10 -0
- package/dist/src/ai-enrichment/third-party-data-flow.d.ts +27 -0
- package/dist/src/ai-enrichment/third-party-data-flow.js +518 -0
- package/dist/src/ai-enrichment/third-party-evidence.d.ts +14 -0
- package/dist/src/ai-enrichment/third-party-evidence.js +426 -0
- package/dist/src/ai-enrichment/third-party-property-matrix.d.ts +14 -0
- package/dist/src/ai-enrichment/third-party-property-matrix.js +52 -0
- package/dist/src/ai-enrichment/third-party-subtype.d.ts +14 -0
- package/dist/src/ai-enrichment/third-party-subtype.js +166 -0
- package/dist/src/ai-enrichment/tools/index.d.ts +39 -0
- package/dist/src/ai-enrichment/tools/index.js +121 -0
- package/dist/src/ai-enrichment/types.d.ts +170 -0
- package/dist/src/ai-enrichment/types.js +12 -0
- package/dist/src/analyzers/python/dependency-manifests.d.ts +8 -0
- package/dist/src/analyzers/python/dependency-manifests.js +131 -0
- package/dist/src/analyzers/python/detector.d.ts +3 -0
- package/dist/src/analyzers/python/detector.js +22 -0
- package/dist/src/analyzers/python/index.d.ts +2 -0
- package/dist/src/analyzers/python/index.js +11 -0
- package/dist/src/analyzers/python/manifest-parsers.d.ts +3 -0
- package/dist/src/analyzers/python/manifest-parsers.js +134 -0
- package/dist/src/analyzers/python/parser.d.ts +26 -0
- package/dist/src/analyzers/python/parser.js +187 -0
- package/dist/src/analyzers/python/patterns.d.ts +7 -0
- package/dist/src/analyzers/python/patterns.js +106 -0
- package/dist/src/analyzers/python/python-detection-config.d.ts +75 -0
- package/dist/src/analyzers/python/python-detection-config.js +148 -0
- package/dist/src/analyzers/registry.d.ts +13 -0
- package/dist/src/analyzers/registry.js +60 -0
- package/dist/src/analyzers/shared/manifest-budgets.d.ts +19 -0
- package/dist/src/analyzers/shared/manifest-budgets.js +21 -0
- package/dist/src/analyzers/shared/manifest-fs.d.ts +13 -0
- package/dist/src/analyzers/shared/manifest-fs.js +138 -0
- package/dist/src/analyzers/shared/property-inference.d.ts +8 -0
- package/dist/src/analyzers/shared/property-inference.js +165 -0
- package/dist/src/analyzers/terraform/detector.d.ts +10 -0
- package/dist/src/analyzers/terraform/detector.js +198 -0
- package/dist/src/analyzers/terraform/index.d.ts +2 -0
- package/dist/src/analyzers/terraform/index.js +13 -0
- package/dist/src/analyzers/terraform/parser.d.ts +29 -0
- package/dist/src/analyzers/terraform/parser.js +202 -0
- package/dist/src/analyzers/terraform/terraform-detection-config.d.ts +48 -0
- package/dist/src/analyzers/terraform/terraform-detection-config.js +218 -0
- package/dist/src/analyzers/terraform/terraform-exec.d.ts +11 -0
- package/dist/src/analyzers/terraform/terraform-exec.js +35 -0
- package/dist/src/analyzers/terraform/terraform-module-manifest.d.ts +19 -0
- package/dist/src/analyzers/terraform/terraform-module-manifest.js +75 -0
- package/dist/src/analyzers/terraform/terraform-show-json.d.ts +15 -0
- package/dist/src/analyzers/terraform/terraform-show-json.js +188 -0
- package/dist/src/analyzers/terraform/terraform-utility-resource.d.ts +12 -0
- package/dist/src/analyzers/terraform/terraform-utility-resource.js +30 -0
- package/dist/src/analyzers/types.d.ts +5 -0
- package/dist/src/analyzers/types.js +2 -0
- package/dist/src/analyzers/typescript/actor-detection.d.ts +4 -0
- package/dist/src/analyzers/typescript/actor-detection.js +15 -0
- package/dist/src/analyzers/typescript/dependency-manifests.d.ts +9 -0
- package/dist/src/analyzers/typescript/dependency-manifests.js +131 -0
- package/dist/src/analyzers/typescript/detector.d.ts +3 -0
- package/dist/src/analyzers/typescript/detector.js +23 -0
- package/dist/src/analyzers/typescript/index.d.ts +2 -0
- package/dist/src/analyzers/typescript/index.js +11 -0
- package/dist/src/analyzers/typescript/manifest-parsers.d.ts +1 -0
- package/dist/src/analyzers/typescript/manifest-parsers.js +30 -0
- package/dist/src/analyzers/typescript/parser.d.ts +44 -0
- package/dist/src/analyzers/typescript/parser.js +287 -0
- package/dist/src/analyzers/typescript/third-party-detection.d.ts +4 -0
- package/dist/src/analyzers/typescript/third-party-detection.js +16 -0
- package/dist/src/analyzers/typescript/typescript-detection-config.d.ts +68 -0
- package/dist/src/analyzers/typescript/typescript-detection-config.js +171 -0
- package/dist/src/analyzers/typescript/typescript-detection.d.ts +10 -0
- package/dist/src/analyzers/typescript/typescript-detection.js +57 -0
- package/dist/src/classifier/application-injection.d.ts +12 -0
- package/dist/src/classifier/application-injection.js +335 -0
- package/dist/src/classifier/classify.d.ts +3 -0
- package/dist/src/classifier/classify.js +15 -0
- package/dist/src/classifier/component-factory.d.ts +3 -0
- package/dist/src/classifier/component-factory.js +488 -0
- package/dist/src/classifier/config.d.ts +38 -0
- package/dist/src/classifier/config.js +260 -0
- package/dist/src/classifier/enhance-defaults.d.ts +28 -0
- package/dist/src/classifier/enhance-defaults.js +369 -0
- package/dist/src/classifier/enhance.d.ts +13 -0
- package/dist/src/classifier/enhance.js +295 -0
- package/dist/src/classifier/external-url-third-party.d.ts +26 -0
- package/dist/src/classifier/external-url-third-party.js +195 -0
- package/dist/src/classifier/grouping.d.ts +1 -0
- package/dist/src/classifier/grouping.js +2 -0
- package/dist/src/classifier/main-application-selection.d.ts +41 -0
- package/dist/src/classifier/main-application-selection.js +222 -0
- package/dist/src/classifier/naming.d.ts +4 -0
- package/dist/src/classifier/naming.js +78 -0
- package/dist/src/classifier/postprocessing.d.ts +12 -0
- package/dist/src/classifier/postprocessing.js +510 -0
- package/dist/src/classifier/sectioning.d.ts +5 -0
- package/dist/src/classifier/sectioning.js +60 -0
- package/dist/src/classifier/terraform-provider-hub.d.ts +6 -0
- package/dist/src/classifier/terraform-provider-hub.js +38 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +498 -0
- package/dist/src/config/actor-detection-config.d.ts +21 -0
- package/dist/src/config/actor-detection-config.js +97 -0
- package/dist/src/config/env.d.ts +2 -0
- package/dist/src/config/env.js +75 -0
- package/dist/src/config/file.d.ts +6 -0
- package/dist/src/config/file.js +74 -0
- package/dist/src/config/inference-scope.d.ts +2 -0
- package/dist/src/config/inference-scope.js +15 -0
- package/dist/src/config/load-cli-env.d.ts +1 -0
- package/dist/src/config/load-cli-env.js +54 -0
- package/dist/src/config/normalize-ai-provider.d.ts +5 -0
- package/dist/src/config/normalize-ai-provider.js +18 -0
- package/dist/src/config/property-detection-config.d.ts +27 -0
- package/dist/src/config/property-detection-config.js +355 -0
- package/dist/src/config/redact.d.ts +3 -0
- package/dist/src/config/redact.js +14 -0
- package/dist/src/config/resolve.d.ts +15 -0
- package/dist/src/config/resolve.js +361 -0
- package/dist/src/config/scan-env.d.ts +7 -0
- package/dist/src/config/scan-env.js +38 -0
- package/dist/src/config/third-party-detection-config.d.ts +25 -0
- package/dist/src/config/third-party-detection-config.js +97 -0
- package/dist/src/config/types.d.ts +106 -0
- package/dist/src/config/types.js +2 -0
- package/dist/src/config/validate-scan-ai.d.ts +3 -0
- package/dist/src/config/validate-scan-ai.js +33 -0
- package/dist/src/core/pipeline/ai-orchestrator-options.d.ts +6 -0
- package/dist/src/core/pipeline/ai-orchestrator-options.js +46 -0
- package/dist/src/core/pipeline/classifier-phase.d.ts +7 -0
- package/dist/src/core/pipeline/classifier-phase.js +78 -0
- package/dist/src/core/pipeline/dataflow-phase.d.ts +7 -0
- package/dist/src/core/pipeline/dataflow-phase.js +10 -0
- package/dist/src/core/pipeline/diagram-layout/app-section-layout.d.ts +7 -0
- package/dist/src/core/pipeline/diagram-layout/app-section-layout.js +74 -0
- package/dist/src/core/pipeline/diagram-layout/constants.d.ts +11 -0
- package/dist/src/core/pipeline/diagram-layout/constants.js +14 -0
- package/dist/src/core/pipeline/diagram-layout/edge-handles.d.ts +3 -0
- package/dist/src/core/pipeline/diagram-layout/edge-handles.js +26 -0
- package/dist/src/core/pipeline/diagram-layout/managed-provider-layout.d.ts +3 -0
- package/dist/src/core/pipeline/diagram-layout/managed-provider-layout.js +40 -0
- package/dist/src/core/pipeline/diagram-layout/minimal-terraform-layout.d.ts +6 -0
- package/dist/src/core/pipeline/diagram-layout/minimal-terraform-layout.js +53 -0
- package/dist/src/core/pipeline/diagram-layout/section-helpers.d.ts +30 -0
- package/dist/src/core/pipeline/diagram-layout/section-helpers.js +62 -0
- package/dist/src/core/pipeline/diagram-layout/terraform-lane-layout.d.ts +3 -0
- package/dist/src/core/pipeline/diagram-layout/terraform-lane-layout.js +109 -0
- package/dist/src/core/pipeline/diagram-layout/types.d.ts +2 -0
- package/dist/src/core/pipeline/diagram-layout/types.js +2 -0
- package/dist/src/core/pipeline/graph-mapping.d.ts +6 -0
- package/dist/src/core/pipeline/graph-mapping.js +308 -0
- package/dist/src/core/pipeline/mixed-app-terraform-scan.d.ts +13 -0
- package/dist/src/core/pipeline/mixed-app-terraform-scan.js +81 -0
- package/dist/src/core/pipeline/orchestrator-result.d.ts +6 -0
- package/dist/src/core/pipeline/orchestrator-result.js +2 -0
- package/dist/src/core/pipeline/orchestrator.d.ts +26 -0
- package/dist/src/core/pipeline/orchestrator.js +79 -0
- package/dist/src/core/pipeline/resolve-path-under-scan-root.d.ts +7 -0
- package/dist/src/core/pipeline/resolve-path-under-scan-root.js +55 -0
- package/dist/src/core/pipeline/scan-pipeline.d.ts +6 -0
- package/dist/src/core/pipeline/scan-pipeline.js +364 -0
- package/dist/src/core/pipeline/sorting.d.ts +3 -0
- package/dist/src/core/pipeline/sorting.js +48 -0
- package/dist/src/core/pipeline/stable-component-ids.d.ts +15 -0
- package/dist/src/core/pipeline/stable-component-ids.js +68 -0
- package/dist/src/core/pipeline/structural-scan.d.ts +19 -0
- package/dist/src/core/pipeline/structural-scan.js +304 -0
- package/dist/src/core/pipeline/terraform-flow-utils.d.ts +6 -0
- package/dist/src/core/pipeline/terraform-flow-utils.js +32 -0
- package/dist/src/core/pipeline/terraform-minimal-services.d.ts +31 -0
- package/dist/src/core/pipeline/terraform-minimal-services.js +225 -0
- package/dist/src/core/schema/dataflow-wrapper.schema.d.ts +83 -0
- package/dist/src/core/schema/dataflow-wrapper.schema.js +40 -0
- package/dist/src/core/schema/diagram-graph.schema.d.ts +93 -0
- package/dist/src/core/schema/diagram-graph.schema.js +55 -0
- package/dist/src/core/schema/index.d.ts +4 -0
- package/dist/src/core/schema/index.js +20 -0
- package/dist/src/core/schema/scan-config.schema.d.ts +66 -0
- package/dist/src/core/schema/scan-config.schema.js +67 -0
- package/dist/src/core/schema/scan-result.schema.d.ts +450 -0
- package/dist/src/core/schema/scan-result.schema.js +236 -0
- package/dist/src/core/sectioning/discover-service-sections.d.ts +80 -0
- package/dist/src/core/sectioning/discover-service-sections.js +468 -0
- package/dist/src/core/sectioning/section-runtime.d.ts +21 -0
- package/dist/src/core/sectioning/section-runtime.js +148 -0
- package/dist/src/core/terraform/component-predicates.d.ts +13 -0
- package/dist/src/core/terraform/component-predicates.js +71 -0
- package/dist/src/core/types/component.d.ts +18 -0
- package/dist/src/core/types/component.js +2 -0
- package/dist/src/core/types/config.d.ts +57 -0
- package/dist/src/core/types/config.js +2 -0
- package/dist/src/core/types/data-flow.d.ts +24 -0
- package/dist/src/core/types/data-flow.js +2 -0
- package/dist/src/core/types/detection.d.ts +12 -0
- package/dist/src/core/types/detection.js +19 -0
- package/dist/src/core/types/file.d.ts +14 -0
- package/dist/src/core/types/file.js +2 -0
- package/dist/src/core/types/index.d.ts +7 -0
- package/dist/src/core/types/index.js +23 -0
- package/dist/src/core/types/progress.d.ts +9 -0
- package/dist/src/core/types/progress.js +2 -0
- package/dist/src/core/types/result.d.ts +140 -0
- package/dist/src/core/types/result.js +2 -0
- package/dist/src/data-flow/application-hub.d.ts +7 -0
- package/dist/src/data-flow/application-hub.js +88 -0
- package/dist/src/data-flow/dedupe.d.ts +7 -0
- package/dist/src/data-flow/dedupe.js +92 -0
- package/dist/src/data-flow/detect.d.ts +16 -0
- package/dist/src/data-flow/detect.js +203 -0
- package/dist/src/data-flow/detector.d.ts +15 -0
- package/dist/src/data-flow/detector.js +18 -0
- package/dist/src/data-flow/drop-cross-section-flows.d.ts +8 -0
- package/dist/src/data-flow/drop-cross-section-flows.js +32 -0
- package/dist/src/data-flow/ensure-actor-flow.d.ts +16 -0
- package/dist/src/data-flow/ensure-actor-flow.js +101 -0
- package/dist/src/data-flow/ensure-manifest-declared-flows.d.ts +14 -0
- package/dist/src/data-flow/ensure-manifest-declared-flows.js +76 -0
- package/dist/src/data-flow/ensure-section-api-flows.d.ts +6 -0
- package/dist/src/data-flow/ensure-section-api-flows.js +57 -0
- package/dist/src/data-flow/flow-builder.d.ts +5 -0
- package/dist/src/data-flow/flow-builder.js +80 -0
- package/dist/src/data-flow/import-graph.d.ts +10 -0
- package/dist/src/data-flow/import-graph.js +147 -0
- package/dist/src/data-flow/index.d.ts +8 -0
- package/dist/src/data-flow/index.js +20 -0
- package/dist/src/data-flow/internal-fetch.d.ts +8 -0
- package/dist/src/data-flow/internal-fetch.js +209 -0
- package/dist/src/data-flow/postprocess.d.ts +9 -0
- package/dist/src/data-flow/postprocess.js +63 -0
- package/dist/src/data-flow/rewire.d.ts +10 -0
- package/dist/src/data-flow/rewire.js +93 -0
- package/dist/src/data-flow/source-attribution.d.ts +8 -0
- package/dist/src/data-flow/source-attribution.js +131 -0
- package/dist/src/data-flow/source-resolution.d.ts +13 -0
- package/dist/src/data-flow/source-resolution.js +61 -0
- package/dist/src/data-flow/target-matching.d.ts +21 -0
- package/dist/src/data-flow/target-matching.js +253 -0
- package/dist/src/data-flow/terraform-flows.d.ts +32 -0
- package/dist/src/data-flow/terraform-flows.js +170 -0
- package/dist/src/evals/metrics.d.ts +18 -0
- package/dist/src/evals/metrics.js +58 -0
- package/dist/src/evals/run-model-matrix.d.ts +1 -0
- package/dist/src/evals/run-model-matrix.js +68 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +20 -0
- package/dist/src/ingest/file-system.d.ts +17 -0
- package/dist/src/ingest/file-system.js +239 -0
- package/dist/src/ingest/gitignore.d.ts +12 -0
- package/dist/src/ingest/gitignore.js +127 -0
- package/dist/src/ingest/sensitive-paths.d.ts +2 -0
- package/dist/src/ingest/sensitive-paths.js +8 -0
- package/dist/src/observability/scan-sentry.d.ts +20 -0
- package/dist/src/observability/scan-sentry.js +133 -0
- package/dist/src/output/json.d.ts +51 -0
- package/dist/src/output/json.js +59 -0
- package/dist/src/patterns/config.d.ts +22 -0
- package/dist/src/patterns/config.js +119 -0
- package/dist/src/patterns/detectors/helpers.d.ts +19 -0
- package/dist/src/patterns/detectors/helpers.js +68 -0
- package/dist/src/patterns/detectors/python.d.ts +8 -0
- package/dist/src/patterns/detectors/python.js +412 -0
- package/dist/src/patterns/detectors/typescript.d.ts +8 -0
- package/dist/src/patterns/detectors/typescript.js +328 -0
- package/dist/src/patterns/engine.d.ts +40 -0
- package/dist/src/patterns/engine.js +111 -0
- package/dist/src/patterns/flow-source-patterns.d.ts +6 -0
- package/dist/src/patterns/flow-source-patterns.js +39 -0
- package/dist/src/patterns/frontend-frameworks.d.ts +4 -0
- package/dist/src/patterns/frontend-frameworks.js +25 -0
- package/dist/src/patterns/scan-exclusions.d.ts +14 -0
- package/dist/src/patterns/scan-exclusions.js +76 -0
- package/dist/src/platform-api/dataparade-api-base-url.d.ts +8 -0
- package/dist/src/platform-api/dataparade-api-base-url.js +17 -0
- package/dist/src/platform-api/estimate-scan-footprint.d.ts +8 -0
- package/dist/src/platform-api/estimate-scan-footprint.js +120 -0
- package/dist/src/platform-api/scan-quota-client.d.ts +28 -0
- package/dist/src/platform-api/scan-quota-client.js +79 -0
- package/dist/src/tracing/langsmith-tracing.d.ts +37 -0
- package/dist/src/tracing/langsmith-tracing.js +171 -0
- package/dist/tests/cli/cli.spec.d.ts +1 -0
- package/dist/tests/cli/cli.spec.js +87 -0
- package/dist/tests/fixtures/e2e-ts-sample/db-client-import.d.ts +2 -0
- package/dist/tests/fixtures/e2e-ts-sample/db-client-import.js +8 -0
- package/dist/tests/fixtures/e2e-ts-sample/db.d.ts +3 -0
- package/dist/tests/fixtures/e2e-ts-sample/db.js +7 -0
- package/dist/tests/fixtures/e2e-ts-sample/external-api.d.ts +1 -0
- package/dist/tests/fixtures/e2e-ts-sample/external-api.js +18 -0
- package/dist/tests/fixtures/e2e-ts-sample/pg-client.d.ts +3 -0
- package/dist/tests/fixtures/e2e-ts-sample/pg-client.js +7 -0
- package/dist/tests/fixtures/e2e-ts-sample/server.d.ts +14 -0
- package/dist/tests/fixtures/e2e-ts-sample/server.js +4 -0
- package/dist/tests/fixtures/e2e-ts-sentry-route-env/server.d.ts +1 -0
- package/dist/tests/fixtures/e2e-ts-sentry-route-env/server.js +24 -0
- package/dist/tests/fixtures/ingest-basic/src/index.d.ts +1 -0
- package/dist/tests/fixtures/ingest-basic/src/index.js +6 -0
- package/dist/tests/fixtures/mixed-language-basic/api.d.ts +2 -0
- package/dist/tests/fixtures/mixed-language-basic/api.js +12 -0
- package/dist/tests/fixtures/monorepo-app-plus-terraform/packages/app/app/route.d.ts +1 -0
- package/dist/tests/fixtures/monorepo-app-plus-terraform/packages/app/app/route.js +6 -0
- package/dist/tests/fixtures/monorepo-front-back-sections/backend/app/route.d.ts +1 -0
- package/dist/tests/fixtures/monorepo-front-back-sections/backend/app/route.js +6 -0
- package/dist/tests/fixtures/monorepo-front-back-sections/frontend/app/route.d.ts +1 -0
- package/dist/tests/fixtures/monorepo-front-back-sections/frontend/app/route.js +7 -0
- package/dist/tests/fixtures/typescript-basic/app/route.d.ts +1 -0
- package/dist/tests/fixtures/typescript-basic/app/route.js +7 -0
- package/dist/tests/fixtures/typescript-basic/db-client-import.d.ts +2 -0
- package/dist/tests/fixtures/typescript-basic/db-client-import.js +8 -0
- package/dist/tests/fixtures/typescript-basic/db.d.ts +3 -0
- package/dist/tests/fixtures/typescript-basic/db.js +7 -0
- package/dist/tests/fixtures/typescript-basic/external-api.d.ts +1 -0
- package/dist/tests/fixtures/typescript-basic/external-api.js +18 -0
- package/dist/tests/fixtures/typescript-basic/pg-client.d.ts +3 -0
- package/dist/tests/fixtures/typescript-basic/pg-client.js +7 -0
- package/dist/tests/fixtures/typescript-basic/server.d.ts +14 -0
- package/dist/tests/fixtures/typescript-basic/server.js +4 -0
- package/dist/tests/fixtures/typescript-dependency-manifests-basic/src/index.d.ts +0 -0
- package/dist/tests/fixtures/typescript-dependency-manifests-basic/src/index.js +2 -0
- package/dist/tests/helpers/scan-result-builders.d.ts +2 -0
- package/dist/tests/helpers/scan-result-builders.js +15 -0
- package/dist/tests/schema/dataflow-wrapper.schema.spec.d.ts +1 -0
- package/dist/tests/schema/dataflow-wrapper.schema.spec.js +89 -0
- package/dist/tests/schema/diagram-graph.schema.spec.d.ts +1 -0
- package/dist/tests/schema/diagram-graph.schema.spec.js +48 -0
- package/dist/tests/schema/scan-config.schema.spec.d.ts +1 -0
- package/dist/tests/schema/scan-config.schema.spec.js +135 -0
- package/dist/tests/schema/scan-result.schema.spec.d.ts +1 -0
- package/dist/tests/schema/scan-result.schema.spec.js +177 -0
- package/dist/tests/unit/ai-enrichment/agent-orchestrator.spec.d.ts +1 -0
- package/dist/tests/unit/ai-enrichment/agent-orchestrator.spec.js +483 -0
- package/dist/tests/unit/ai-enrichment/candidate-selector.spec.d.ts +1 -0
- package/dist/tests/unit/ai-enrichment/candidate-selector.spec.js +106 -0
- package/dist/tests/unit/ai-enrichment/create-ai-provider.spec.d.ts +1 -0
- package/dist/tests/unit/ai-enrichment/create-ai-provider.spec.js +32 -0
- package/dist/tests/unit/ai-enrichment/endpoint-resolution.spec.d.ts +1 -0
- package/dist/tests/unit/ai-enrichment/endpoint-resolution.spec.js +47 -0
- package/dist/tests/unit/ai-enrichment/fallbacks.spec.d.ts +1 -0
- package/dist/tests/unit/ai-enrichment/fallbacks.spec.js +1304 -0
- package/dist/tests/unit/ai-enrichment/families/chat-completions-family.spec.d.ts +1 -0
- package/dist/tests/unit/ai-enrichment/families/chat-completions-family.spec.js +219 -0
- package/dist/tests/unit/ai-enrichment/families/generate-content-family.spec.d.ts +1 -0
- package/dist/tests/unit/ai-enrichment/families/generate-content-family.spec.js +119 -0
- package/dist/tests/unit/ai-enrichment/families/messages-family.spec.d.ts +1 -0
- package/dist/tests/unit/ai-enrichment/families/messages-family.spec.js +129 -0
- package/dist/tests/unit/ai-enrichment/families/ollama-generate-family.spec.d.ts +1 -0
- package/dist/tests/unit/ai-enrichment/families/ollama-generate-family.spec.js +69 -0
- package/dist/tests/unit/ai-enrichment/merge-rules.spec.d.ts +1 -0
- package/dist/tests/unit/ai-enrichment/merge-rules.spec.js +422 -0
- package/dist/tests/unit/ai-enrichment/openai-proposals-response.schema.spec.d.ts +1 -0
- package/dist/tests/unit/ai-enrichment/openai-proposals-response.schema.spec.js +30 -0
- package/dist/tests/unit/ai-enrichment/pipeline.spec.d.ts +1 -0
- package/dist/tests/unit/ai-enrichment/pipeline.spec.js +120 -0
- package/dist/tests/unit/ai-enrichment/planner.spec.d.ts +1 -0
- package/dist/tests/unit/ai-enrichment/planner.spec.js +106 -0
- package/dist/tests/unit/ai-enrichment/platform-proxy-provider.spec.d.ts +1 -0
- package/dist/tests/unit/ai-enrichment/platform-proxy-provider.spec.js +51 -0
- package/dist/tests/unit/ai-enrichment/provider-contract.spec.d.ts +1 -0
- package/dist/tests/unit/ai-enrichment/provider-contract.spec.js +244 -0
- package/dist/tests/unit/ai-enrichment/provider-json-parse.spec.d.ts +1 -0
- package/dist/tests/unit/ai-enrichment/provider-json-parse.spec.js +24 -0
- package/dist/tests/unit/ai-enrichment/provider-output-token-budget.spec.d.ts +1 -0
- package/dist/tests/unit/ai-enrichment/provider-output-token-budget.spec.js +15 -0
- package/dist/tests/unit/ai-enrichment/provider-prompt-env.spec.d.ts +1 -0
- package/dist/tests/unit/ai-enrichment/provider-prompt-env.spec.js +54 -0
- package/dist/tests/unit/ai-enrichment/provider-prompt.spec.d.ts +1 -0
- package/dist/tests/unit/ai-enrichment/provider-prompt.spec.js +206 -0
- package/dist/tests/unit/ai-enrichment/provider-topology-terraform-aws.spec.d.ts +1 -0
- package/dist/tests/unit/ai-enrichment/provider-topology-terraform-aws.spec.js +43 -0
- package/dist/tests/unit/ai-enrichment/provider-topology-terraform-kubernetes.spec.d.ts +1 -0
- package/dist/tests/unit/ai-enrichment/provider-topology-terraform-kubernetes.spec.js +40 -0
- package/dist/tests/unit/ai-enrichment/providers/fetch-with-timeout.spec.d.ts +1 -0
- package/dist/tests/unit/ai-enrichment/providers/fetch-with-timeout.spec.js +22 -0
- package/dist/tests/unit/ai-enrichment/resolve-provider.spec.d.ts +1 -0
- package/dist/tests/unit/ai-enrichment/resolve-provider.spec.js +67 -0
- package/dist/tests/unit/ai-enrichment/scan-paths-exact.spec.d.ts +1 -0
- package/dist/tests/unit/ai-enrichment/scan-paths-exact.spec.js +35 -0
- package/dist/tests/unit/ai-enrichment/scan-paths.spec.d.ts +1 -0
- package/dist/tests/unit/ai-enrichment/scan-paths.spec.js +21 -0
- package/dist/tests/unit/ai-enrichment/sensitive-paths.spec.d.ts +1 -0
- package/dist/tests/unit/ai-enrichment/sensitive-paths.spec.js +20 -0
- package/dist/tests/unit/ai-enrichment/third-party-data-flow.spec.d.ts +1 -0
- package/dist/tests/unit/ai-enrichment/third-party-data-flow.spec.js +963 -0
- package/dist/tests/unit/ai-enrichment/third-party-evidence.spec.d.ts +1 -0
- package/dist/tests/unit/ai-enrichment/third-party-evidence.spec.js +117 -0
- package/dist/tests/unit/ai-enrichment/third-party-subtype.spec.d.ts +1 -0
- package/dist/tests/unit/ai-enrichment/third-party-subtype.spec.js +45 -0
- package/dist/tests/unit/ai-enrichment/tools-validation.spec.d.ts +1 -0
- package/dist/tests/unit/ai-enrichment/tools-validation.spec.js +66 -0
- package/dist/tests/unit/analyzers/python/parser.spec.d.ts +1 -0
- package/dist/tests/unit/analyzers/python/parser.spec.js +104 -0
- package/dist/tests/unit/analyzers/python/patterns.spec.d.ts +1 -0
- package/dist/tests/unit/analyzers/python/patterns.spec.js +289 -0
- package/dist/tests/unit/analyzers/registry.spec.d.ts +1 -0
- package/dist/tests/unit/analyzers/registry.spec.js +234 -0
- package/dist/tests/unit/analyzers/terraform/classifier-subtype-parity.spec.d.ts +1 -0
- package/dist/tests/unit/analyzers/terraform/classifier-subtype-parity.spec.js +87 -0
- package/dist/tests/unit/analyzers/terraform/detector.spec.d.ts +1 -0
- package/dist/tests/unit/analyzers/terraform/detector.spec.js +110 -0
- package/dist/tests/unit/analyzers/terraform/generated-provider-hints.spec.d.ts +1 -0
- package/dist/tests/unit/analyzers/terraform/generated-provider-hints.spec.js +53 -0
- package/dist/tests/unit/analyzers/terraform/parser.spec.d.ts +1 -0
- package/dist/tests/unit/analyzers/terraform/parser.spec.js +56 -0
- package/dist/tests/unit/analyzers/terraform/terraform-module-manifest.spec.d.ts +1 -0
- package/dist/tests/unit/analyzers/terraform/terraform-module-manifest.spec.js +63 -0
- package/dist/tests/unit/analyzers/terraform/terraform-utility-resource.spec.d.ts +1 -0
- package/dist/tests/unit/analyzers/terraform/terraform-utility-resource.spec.js +19 -0
- package/dist/tests/unit/analyzers/terraform-exec.spec.d.ts +1 -0
- package/dist/tests/unit/analyzers/terraform-exec.spec.js +27 -0
- package/dist/tests/unit/analyzers/terraform-show-json.spec.d.ts +1 -0
- package/dist/tests/unit/analyzers/terraform-show-json.spec.js +77 -0
- package/dist/tests/unit/analyzers/typescript/dependency-manifests.spec.d.ts +1 -0
- package/dist/tests/unit/analyzers/typescript/dependency-manifests.spec.js +61 -0
- package/dist/tests/unit/analyzers/typescript/detector.spec.d.ts +1 -0
- package/dist/tests/unit/analyzers/typescript/detector.spec.js +225 -0
- package/dist/tests/unit/analyzers/typescript/external-apis-auth0.spec.d.ts +1 -0
- package/dist/tests/unit/analyzers/typescript/external-apis-auth0.spec.js +49 -0
- package/dist/tests/unit/analyzers/typescript/external-apis-sentry.spec.d.ts +1 -0
- package/dist/tests/unit/analyzers/typescript/external-apis-sentry.spec.js +27 -0
- package/dist/tests/unit/analyzers/typescript/fixture-integration.spec.d.ts +1 -0
- package/dist/tests/unit/analyzers/typescript/fixture-integration.spec.js +64 -0
- package/dist/tests/unit/analyzers/typescript/parser.spec.d.ts +1 -0
- package/dist/tests/unit/analyzers/typescript/parser.spec.js +99 -0
- package/dist/tests/unit/analyzers/typescript/pattern-config.spec.d.ts +1 -0
- package/dist/tests/unit/analyzers/typescript/pattern-config.spec.js +24 -0
- package/dist/tests/unit/analyzers/typescript/property-detection.spec.d.ts +1 -0
- package/dist/tests/unit/analyzers/typescript/property-detection.spec.js +138 -0
- package/dist/tests/unit/classifier/classify.spec.d.ts +1 -0
- package/dist/tests/unit/classifier/classify.spec.js +1453 -0
- package/dist/tests/unit/classifier/enhance.spec.d.ts +1 -0
- package/dist/tests/unit/classifier/enhance.spec.js +400 -0
- package/dist/tests/unit/classifier/external-url-third-party.spec.d.ts +1 -0
- package/dist/tests/unit/classifier/external-url-third-party.spec.js +83 -0
- package/dist/tests/unit/classifier/frontend-framework-grouping.spec.d.ts +1 -0
- package/dist/tests/unit/classifier/frontend-framework-grouping.spec.js +44 -0
- package/dist/tests/unit/classifier/terraform-grouping.spec.d.ts +1 -0
- package/dist/tests/unit/classifier/terraform-grouping.spec.js +96 -0
- package/dist/tests/unit/cli/config-command.spec.d.ts +1 -0
- package/dist/tests/unit/cli/config-command.spec.js +51 -0
- package/dist/tests/unit/cli/scan-command-ai-flags.spec.d.ts +0 -0
- package/dist/tests/unit/cli/scan-command-ai-flags.spec.js +149 -0
- package/dist/tests/unit/cli/scan-command-diagram-graph.spec.d.ts +1 -0
- package/dist/tests/unit/cli/scan-command-diagram-graph.spec.js +26 -0
- package/dist/tests/unit/cli/scan-command-e2e-monorepo-app-plus-terraform.spec.d.ts +1 -0
- package/dist/tests/unit/cli/scan-command-e2e-monorepo-app-plus-terraform.spec.js +107 -0
- package/dist/tests/unit/cli/scan-command-e2e-monorepo-front-back-sections.spec.d.ts +1 -0
- package/dist/tests/unit/cli/scan-command-e2e-monorepo-front-back-sections.spec.js +74 -0
- package/dist/tests/unit/cli/scan-command-e2e-python-basic.spec.d.ts +1 -0
- package/dist/tests/unit/cli/scan-command-e2e-python-basic.spec.js +43 -0
- package/dist/tests/unit/cli/scan-command-e2e-terraform-basic.spec.d.ts +1 -0
- package/dist/tests/unit/cli/scan-command-e2e-terraform-basic.spec.js +62 -0
- package/dist/tests/unit/cli/scan-command-e2e-ts-sample.spec.d.ts +1 -0
- package/dist/tests/unit/cli/scan-command-e2e-ts-sample.spec.js +41 -0
- package/dist/tests/unit/cli/scan-command-e2e-ts-sentry-route-env.spec.d.ts +1 -0
- package/dist/tests/unit/cli/scan-command-e2e-ts-sentry-route-env.spec.js +85 -0
- package/dist/tests/unit/cli/scan-command-exit-code.spec.d.ts +1 -0
- package/dist/tests/unit/cli/scan-command-exit-code.spec.js +131 -0
- package/dist/tests/unit/cli/scan-quota-flow.spec.d.ts +1 -0
- package/dist/tests/unit/cli/scan-quota-flow.spec.js +76 -0
- package/dist/tests/unit/config/property-detection-config.spec.d.ts +1 -0
- package/dist/tests/unit/config/property-detection-config.spec.js +38 -0
- package/dist/tests/unit/config/redact.spec.d.ts +1 -0
- package/dist/tests/unit/config/redact.spec.js +19 -0
- package/dist/tests/unit/config/resolve-config.spec.d.ts +1 -0
- package/dist/tests/unit/config/resolve-config.spec.js +172 -0
- package/dist/tests/unit/config/scan-env-debug.spec.d.ts +1 -0
- package/dist/tests/unit/config/scan-env-debug.spec.js +17 -0
- package/dist/tests/unit/config/validate-scan-ai.spec.d.ts +1 -0
- package/dist/tests/unit/config/validate-scan-ai.spec.js +53 -0
- package/dist/tests/unit/core/classifier-phase-regressions.spec.d.ts +1 -0
- package/dist/tests/unit/core/classifier-phase-regressions.spec.js +68 -0
- package/dist/tests/unit/core/dependency-manifest-performance-budgets.spec.d.ts +1 -0
- package/dist/tests/unit/core/dependency-manifest-performance-budgets.spec.js +66 -0
- package/dist/tests/unit/core/dependency-manifest-toggles-confidence.spec.d.ts +1 -0
- package/dist/tests/unit/core/dependency-manifest-toggles-confidence.spec.js +132 -0
- package/dist/tests/unit/core/discover-service-sections.spec.d.ts +1 -0
- package/dist/tests/unit/core/discover-service-sections.spec.js +204 -0
- package/dist/tests/unit/core/graph-mapping.spec.d.ts +1 -0
- package/dist/tests/unit/core/graph-mapping.spec.js +779 -0
- package/dist/tests/unit/core/invariant-tests-dedupe-determinism.spec.d.ts +1 -0
- package/dist/tests/unit/core/invariant-tests-dedupe-determinism.spec.js +64 -0
- package/dist/tests/unit/core/manifest-package-hub.spec.d.ts +1 -0
- package/dist/tests/unit/core/manifest-package-hub.spec.js +53 -0
- package/dist/tests/unit/core/monorepo-package-sections.spec.d.ts +1 -0
- package/dist/tests/unit/core/monorepo-package-sections.spec.js +121 -0
- package/dist/tests/unit/core/no-source-code-leakage.spec.d.ts +1 -0
- package/dist/tests/unit/core/no-source-code-leakage.spec.js +48 -0
- package/dist/tests/unit/core/orchestrator.spec.d.ts +1 -0
- package/dist/tests/unit/core/orchestrator.spec.js +252 -0
- package/dist/tests/unit/core/output-json.spec.d.ts +1 -0
- package/dist/tests/unit/core/output-json.spec.js +65 -0
- package/dist/tests/unit/core/parsing-error-handling-nonfatal.spec.d.ts +1 -0
- package/dist/tests/unit/core/parsing-error-handling-nonfatal.spec.js +42 -0
- package/dist/tests/unit/core/resolve-path-under-scan-root.spec.d.ts +1 -0
- package/dist/tests/unit/core/resolve-path-under-scan-root.spec.js +54 -0
- package/dist/tests/unit/core/scan-result-language-stats.spec.d.ts +1 -0
- package/dist/tests/unit/core/scan-result-language-stats.spec.js +15 -0
- package/dist/tests/unit/core/section-discovery-excludes.spec.d.ts +1 -0
- package/dist/tests/unit/core/section-discovery-excludes.spec.js +49 -0
- package/dist/tests/unit/core/section-runtime.spec.d.ts +1 -0
- package/dist/tests/unit/core/section-runtime.spec.js +166 -0
- package/dist/tests/unit/core/stable-component-ids.spec.d.ts +1 -0
- package/dist/tests/unit/core/stable-component-ids.spec.js +112 -0
- package/dist/tests/unit/core/structural-scan.spec.d.ts +1 -0
- package/dist/tests/unit/core/structural-scan.spec.js +83 -0
- package/dist/tests/unit/core/terraform-json-overlay.spec.d.ts +1 -0
- package/dist/tests/unit/core/terraform-json-overlay.spec.js +36 -0
- package/dist/tests/unit/core/terraform-minimal-services.spec.d.ts +1 -0
- package/dist/tests/unit/core/terraform-minimal-services.spec.js +378 -0
- package/dist/tests/unit/data-flow/application-hub.spec.d.ts +1 -0
- package/dist/tests/unit/data-flow/application-hub.spec.js +48 -0
- package/dist/tests/unit/data-flow/cross-section-terraform-bridge.spec.d.ts +1 -0
- package/dist/tests/unit/data-flow/cross-section-terraform-bridge.spec.js +95 -0
- package/dist/tests/unit/data-flow/dedupe.spec.d.ts +1 -0
- package/dist/tests/unit/data-flow/dedupe.spec.js +134 -0
- package/dist/tests/unit/data-flow/detector.spec.d.ts +1 -0
- package/dist/tests/unit/data-flow/detector.spec.js +1254 -0
- package/dist/tests/unit/data-flow/drop-cross-section-flows.spec.d.ts +1 -0
- package/dist/tests/unit/data-flow/drop-cross-section-flows.spec.js +132 -0
- package/dist/tests/unit/data-flow/ensure-actor-flow.spec.d.ts +1 -0
- package/dist/tests/unit/data-flow/ensure-actor-flow.spec.js +233 -0
- package/dist/tests/unit/data-flow/ensure-manifest-declared-flows.spec.d.ts +1 -0
- package/dist/tests/unit/data-flow/ensure-manifest-declared-flows.spec.js +125 -0
- package/dist/tests/unit/data-flow/ensure-section-api-flows.spec.d.ts +1 -0
- package/dist/tests/unit/data-flow/ensure-section-api-flows.spec.js +40 -0
- package/dist/tests/unit/data-flow/postprocess.spec.d.ts +1 -0
- package/dist/tests/unit/data-flow/postprocess.spec.js +78 -0
- package/dist/tests/unit/data-flow/rewire.spec.d.ts +1 -0
- package/dist/tests/unit/data-flow/rewire.spec.js +194 -0
- package/dist/tests/unit/data-flow/terraform-flows.spec.d.ts +1 -0
- package/dist/tests/unit/data-flow/terraform-flows.spec.js +199 -0
- package/dist/tests/unit/evals/metrics.spec.d.ts +1 -0
- package/dist/tests/unit/evals/metrics.spec.js +54 -0
- package/dist/tests/unit/ingest/env-exclusion.spec.d.ts +1 -0
- package/dist/tests/unit/ingest/env-exclusion.spec.js +43 -0
- package/dist/tests/unit/ingest/file-system.spec.d.ts +1 -0
- package/dist/tests/unit/ingest/file-system.spec.js +180 -0
- package/dist/tests/unit/ingest/gitignore.spec.d.ts +1 -0
- package/dist/tests/unit/ingest/gitignore.spec.js +30 -0
- package/dist/tests/unit/observability/scan-sentry.spec.d.ts +1 -0
- package/dist/tests/unit/observability/scan-sentry.spec.js +60 -0
- package/dist/tests/unit/patterns/scan-exclusions.spec.d.ts +1 -0
- package/dist/tests/unit/patterns/scan-exclusions.spec.js +58 -0
- package/dist/tests/unit/pipeline/ai-orchestrator-options.spec.d.ts +1 -0
- package/dist/tests/unit/pipeline/ai-orchestrator-options.spec.js +19 -0
- package/dist/tests/unit/platform-api/dataparade-api-base-url.spec.d.ts +1 -0
- package/dist/tests/unit/platform-api/dataparade-api-base-url.spec.js +19 -0
- package/dist/tests/unit/platform-api/estimate-scan-footprint.spec.d.ts +1 -0
- package/dist/tests/unit/platform-api/estimate-scan-footprint.spec.js +50 -0
- package/dist/tests/unit/tracing/langsmith-tracing.spec.d.ts +1 -0
- package/dist/tests/unit/tracing/langsmith-tracing.spec.js +118 -0
- package/package.json +84 -0
|
@@ -0,0 +1,703 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildProposalsValidationContext = buildProposalsValidationContext;
|
|
4
|
+
exports.parseAgentFromPrompt = parseAgentFromPrompt;
|
|
5
|
+
exports.aiDebugEnabled = aiDebugEnabled;
|
|
6
|
+
exports.strictParseAndNormalizeProposals = strictParseAndNormalizeProposals;
|
|
7
|
+
const openai_proposals_response_schema_1 = require("../openai-proposals-response.schema");
|
|
8
|
+
const scan_paths_1 = require("../scan-paths");
|
|
9
|
+
const scan_env_1 = require("../../config/scan-env");
|
|
10
|
+
const AGENTS = new Set([
|
|
11
|
+
"tpAgent",
|
|
12
|
+
"propertyAgent",
|
|
13
|
+
"directionAgent",
|
|
14
|
+
"interactionAgent",
|
|
15
|
+
]);
|
|
16
|
+
const CANDIDATE_TYPES = new Set([
|
|
17
|
+
"third_party",
|
|
18
|
+
"node_property",
|
|
19
|
+
"flow_direction",
|
|
20
|
+
"missing_interaction",
|
|
21
|
+
]);
|
|
22
|
+
const FLOW_TYPES = new Set([
|
|
23
|
+
"api_call",
|
|
24
|
+
"database_query",
|
|
25
|
+
"message_queue",
|
|
26
|
+
"file_transfer",
|
|
27
|
+
"webhook",
|
|
28
|
+
"rpc",
|
|
29
|
+
]);
|
|
30
|
+
function pathsFromSlimComponentEntry(entry) {
|
|
31
|
+
const out = [];
|
|
32
|
+
const df = entry.detectedFrom;
|
|
33
|
+
if (Array.isArray(df)) {
|
|
34
|
+
for (const x of df) {
|
|
35
|
+
if (x && typeof x === "object") {
|
|
36
|
+
const fp = x.filePath;
|
|
37
|
+
if (typeof fp === "string" && fp.trim())
|
|
38
|
+
out.push((0, scan_paths_1.normScanPath)(fp.trim()));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const sl = entry.sourceLocations;
|
|
43
|
+
if (Array.isArray(sl)) {
|
|
44
|
+
for (const x of sl) {
|
|
45
|
+
if (x && typeof x === "object") {
|
|
46
|
+
const fp = x.filePath;
|
|
47
|
+
if (typeof fp === "string" && fp.trim())
|
|
48
|
+
out.push((0, scan_paths_1.normScanPath)(fp.trim()));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return out;
|
|
53
|
+
}
|
|
54
|
+
function buildProposalsValidationContext(userPrompt) {
|
|
55
|
+
let parsed;
|
|
56
|
+
try {
|
|
57
|
+
parsed = JSON.parse(userPrompt);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
63
|
+
return null;
|
|
64
|
+
const o = parsed;
|
|
65
|
+
const excerptPaths = new Set();
|
|
66
|
+
const excerptsByNormPath = new Map();
|
|
67
|
+
const rc = o.relevantFileContents;
|
|
68
|
+
if (rc && typeof rc === "object" && !Array.isArray(rc)) {
|
|
69
|
+
for (const key of Object.keys(rc)) {
|
|
70
|
+
const n = (0, scan_paths_1.normScanPath)(key);
|
|
71
|
+
excerptPaths.add(n);
|
|
72
|
+
const val = rc[key];
|
|
73
|
+
if (typeof val === "string")
|
|
74
|
+
excerptsByNormPath.set(n, val);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const allowedPathsByComponentId = new Map();
|
|
78
|
+
const cc = o.componentContext;
|
|
79
|
+
if (cc && typeof cc === "object" && !Array.isArray(cc)) {
|
|
80
|
+
for (const [compId, entry] of Object.entries(cc)) {
|
|
81
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry))
|
|
82
|
+
continue;
|
|
83
|
+
const set = new Set(pathsFromSlimComponentEntry(entry));
|
|
84
|
+
allowedPathsByComponentId.set(compId, set);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return { excerptPaths, excerptsByNormPath, allowedPathsByComponentId };
|
|
88
|
+
}
|
|
89
|
+
function posixBasename(p) {
|
|
90
|
+
const n = (0, scan_paths_1.normScanPath)(p);
|
|
91
|
+
const i = n.lastIndexOf("/");
|
|
92
|
+
return i >= 0 ? n.slice(i + 1) : n;
|
|
93
|
+
}
|
|
94
|
+
function findExcerptContent(normFp, excerptsByNormPath) {
|
|
95
|
+
if (excerptsByNormPath.has(normFp))
|
|
96
|
+
return excerptsByNormPath.get(normFp);
|
|
97
|
+
for (const [k, v] of excerptsByNormPath) {
|
|
98
|
+
if (normFp === k || normFp.endsWith(`/${k}`) || k.endsWith(`/${normFp}`)) {
|
|
99
|
+
return v;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const bn = posixBasename(normFp);
|
|
103
|
+
if (bn.length > 0) {
|
|
104
|
+
for (const [k, v] of excerptsByNormPath) {
|
|
105
|
+
if (posixBasename(k) === bn)
|
|
106
|
+
return v;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
function pathsMatchAllowed(normFp, allowed) {
|
|
112
|
+
if (allowed.size === 0)
|
|
113
|
+
return true;
|
|
114
|
+
if (allowed.has(normFp))
|
|
115
|
+
return true;
|
|
116
|
+
for (const a of allowed) {
|
|
117
|
+
if (normFp === a)
|
|
118
|
+
return true;
|
|
119
|
+
if (normFp.endsWith(`/${a}`) || a.endsWith(`/${normFp}`))
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
const bn = posixBasename(normFp);
|
|
123
|
+
if (bn.length > 0) {
|
|
124
|
+
for (const a of allowed) {
|
|
125
|
+
if (posixBasename(a) === bn)
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Ensure evidence points at payload files; when an excerpt exists, clamp line ranges to
|
|
133
|
+
* file length instead of dropping (models often overshoot endLine).
|
|
134
|
+
*/
|
|
135
|
+
function normalizeEvidenceRefForContext(ref, targetComponentId, ctx) {
|
|
136
|
+
if (!ctx)
|
|
137
|
+
return ref;
|
|
138
|
+
const normFp = (0, scan_paths_1.normScanPath)(ref.filePath);
|
|
139
|
+
const componentPaths = ctx.allowedPathsByComponentId.get(targetComponentId) ?? new Set();
|
|
140
|
+
const allowed = new Set([...ctx.excerptPaths, ...componentPaths]);
|
|
141
|
+
if (allowed.size > 0 && !pathsMatchAllowed(normFp, allowed)) {
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
const content = findExcerptContent(normFp, ctx.excerptsByNormPath);
|
|
145
|
+
if (content != null) {
|
|
146
|
+
const lineCount = Math.max(1, content.split(/\r?\n/).length);
|
|
147
|
+
let start = Math.max(1, Math.floor(ref.startLine));
|
|
148
|
+
let end = Math.max(start, Math.floor(ref.endLine));
|
|
149
|
+
start = Math.min(start, lineCount);
|
|
150
|
+
end = Math.min(end, lineCount);
|
|
151
|
+
if (end < start)
|
|
152
|
+
end = start;
|
|
153
|
+
return { ...ref, filePath: ref.filePath.trim(), startLine: start, endLine: end };
|
|
154
|
+
}
|
|
155
|
+
return { ...ref, filePath: ref.filePath.trim() };
|
|
156
|
+
}
|
|
157
|
+
function evidenceRefKey(ref) {
|
|
158
|
+
return `${(0, scan_paths_1.normScanPath)(ref.filePath)}|${ref.startLine}|${ref.endLine}|${ref.reason}`;
|
|
159
|
+
}
|
|
160
|
+
function flattenPropertyEvidence(map) {
|
|
161
|
+
const seen = new Set();
|
|
162
|
+
const out = [];
|
|
163
|
+
for (const refs of Object.values(map)) {
|
|
164
|
+
for (const ref of refs) {
|
|
165
|
+
const k = evidenceRefKey(ref);
|
|
166
|
+
if (seen.has(k))
|
|
167
|
+
continue;
|
|
168
|
+
seen.add(k);
|
|
169
|
+
out.push(ref);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return out;
|
|
173
|
+
}
|
|
174
|
+
function isPlaceholderPropertyValue(value) {
|
|
175
|
+
if (value === null || value === undefined)
|
|
176
|
+
return true;
|
|
177
|
+
if (typeof value === "string") {
|
|
178
|
+
const normalized = value.trim().toLowerCase();
|
|
179
|
+
return normalized === "" || normalized === "none";
|
|
180
|
+
}
|
|
181
|
+
if (Array.isArray(value))
|
|
182
|
+
return value.length === 0;
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
function sanitizeSetProperties(raw) {
|
|
186
|
+
const sanitized = {};
|
|
187
|
+
for (const [key, value] of Object.entries(raw)) {
|
|
188
|
+
if (key === "inference_status")
|
|
189
|
+
continue;
|
|
190
|
+
if (isPlaceholderPropertyValue(value))
|
|
191
|
+
continue;
|
|
192
|
+
sanitized[key] = value;
|
|
193
|
+
}
|
|
194
|
+
return sanitized;
|
|
195
|
+
}
|
|
196
|
+
const UI_DATA_CATEGORY_ALLOWED = new Set([
|
|
197
|
+
"personal_identifiers",
|
|
198
|
+
"contact_information",
|
|
199
|
+
"financial_information",
|
|
200
|
+
"health_data",
|
|
201
|
+
"biometric_data",
|
|
202
|
+
"location_data",
|
|
203
|
+
"behavioral_data",
|
|
204
|
+
"employment_data",
|
|
205
|
+
"education_data",
|
|
206
|
+
"special_category_data",
|
|
207
|
+
"criminal_records",
|
|
208
|
+
"demographic_data",
|
|
209
|
+
"online_identifiers",
|
|
210
|
+
"device_identifiers",
|
|
211
|
+
"usage_data",
|
|
212
|
+
"aggregated_analytics",
|
|
213
|
+
"financial_data",
|
|
214
|
+
"geolocation_gps",
|
|
215
|
+
"geolocation_ip",
|
|
216
|
+
"photos_selfies",
|
|
217
|
+
"professional_data",
|
|
218
|
+
"sensitive_personal_data",
|
|
219
|
+
"special_categories",
|
|
220
|
+
"user_identity_direct",
|
|
221
|
+
"user_identity_indirect",
|
|
222
|
+
"other",
|
|
223
|
+
]);
|
|
224
|
+
const UI_DATA_CATEGORY_ALIASES = {
|
|
225
|
+
personal_data: "user_identity_direct",
|
|
226
|
+
pii: "user_identity_direct",
|
|
227
|
+
personally_identifiable_information: "user_identity_direct",
|
|
228
|
+
document_files: "other",
|
|
229
|
+
document_metadata: "other",
|
|
230
|
+
file_content: "other",
|
|
231
|
+
file_metadata: "other",
|
|
232
|
+
email_address: "contact_information",
|
|
233
|
+
credit_card_data: "financial_data",
|
|
234
|
+
payment_data: "financial_data",
|
|
235
|
+
phi: "health_data",
|
|
236
|
+
ip_address: "geolocation_ip",
|
|
237
|
+
device_id: "device_identifiers",
|
|
238
|
+
};
|
|
239
|
+
const UI_PROCESSING_PURPOSE_ALLOWED = new Set([
|
|
240
|
+
"authentication",
|
|
241
|
+
"service_provision",
|
|
242
|
+
"customer_support",
|
|
243
|
+
"payment_processing",
|
|
244
|
+
"fraud_prevention",
|
|
245
|
+
"analytics",
|
|
246
|
+
"marketing",
|
|
247
|
+
"advertising",
|
|
248
|
+
"development_testing",
|
|
249
|
+
"debugging",
|
|
250
|
+
"security_monitoring",
|
|
251
|
+
"compliance",
|
|
252
|
+
"audit",
|
|
253
|
+
"data_migration",
|
|
254
|
+
"backup_recovery",
|
|
255
|
+
"research",
|
|
256
|
+
"infrastructure_management",
|
|
257
|
+
"hosting_services",
|
|
258
|
+
"data_storage",
|
|
259
|
+
"email_delivery",
|
|
260
|
+
"security",
|
|
261
|
+
"user_insights",
|
|
262
|
+
"performance_monitoring",
|
|
263
|
+
"customer_management",
|
|
264
|
+
"sales_automation",
|
|
265
|
+
"legal_compliance",
|
|
266
|
+
"transactional_emails",
|
|
267
|
+
"marketing_communications",
|
|
268
|
+
"backup_services",
|
|
269
|
+
"disaster_recovery",
|
|
270
|
+
"other",
|
|
271
|
+
]);
|
|
272
|
+
const UI_PROCESSING_PURPOSE_ALIASES = {
|
|
273
|
+
legal: "legal_compliance",
|
|
274
|
+
legal_basis: "legal_compliance",
|
|
275
|
+
provisioning: "service_provision",
|
|
276
|
+
document_processing: "service_provision",
|
|
277
|
+
storage: "data_storage",
|
|
278
|
+
backup: "backup_services",
|
|
279
|
+
};
|
|
280
|
+
function normalizeToken(value) {
|
|
281
|
+
return value
|
|
282
|
+
.trim()
|
|
283
|
+
.toLowerCase()
|
|
284
|
+
.replace(/[\s-]+/g, "_")
|
|
285
|
+
.replace(/[^a-z0-9_]/g, "");
|
|
286
|
+
}
|
|
287
|
+
function toStringArray(raw) {
|
|
288
|
+
if (raw == null)
|
|
289
|
+
return [];
|
|
290
|
+
if (Array.isArray(raw))
|
|
291
|
+
return raw.map((v) => String(v)).map((v) => v.trim()).filter(Boolean);
|
|
292
|
+
if (typeof raw === "string") {
|
|
293
|
+
return raw
|
|
294
|
+
.split(",")
|
|
295
|
+
.map((v) => v.trim())
|
|
296
|
+
.filter(Boolean);
|
|
297
|
+
}
|
|
298
|
+
return [String(raw).trim()].filter(Boolean);
|
|
299
|
+
}
|
|
300
|
+
function mapToAllowed(values, allowed, aliases) {
|
|
301
|
+
const out = [];
|
|
302
|
+
const seen = new Set();
|
|
303
|
+
for (const value of values) {
|
|
304
|
+
const token = normalizeToken(value);
|
|
305
|
+
if (!token)
|
|
306
|
+
continue;
|
|
307
|
+
const mapped = allowed.has(token) ? token : aliases[token] ?? "other";
|
|
308
|
+
if (!allowed.has(mapped))
|
|
309
|
+
continue;
|
|
310
|
+
if (!seen.has(mapped)) {
|
|
311
|
+
seen.add(mapped);
|
|
312
|
+
out.push(mapped);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return out;
|
|
316
|
+
}
|
|
317
|
+
function normalizeThirdPartySetPropertiesForUi(input) {
|
|
318
|
+
const normalized = { ...input };
|
|
319
|
+
const evidenceSourceByKey = {};
|
|
320
|
+
if (Object.prototype.hasOwnProperty.call(normalized, "data_categories_received")) {
|
|
321
|
+
const values = toStringArray(normalized.data_categories_received);
|
|
322
|
+
const mapped = mapToAllowed(values, UI_DATA_CATEGORY_ALLOWED, UI_DATA_CATEGORY_ALIASES);
|
|
323
|
+
if (mapped.length > 0)
|
|
324
|
+
normalized.data_categories_received = mapped;
|
|
325
|
+
else
|
|
326
|
+
delete normalized.data_categories_received;
|
|
327
|
+
}
|
|
328
|
+
if (Object.prototype.hasOwnProperty.call(normalized, "processing_purpose")) {
|
|
329
|
+
const values = toStringArray(normalized.processing_purpose);
|
|
330
|
+
const mapped = mapToAllowed(values, UI_PROCESSING_PURPOSE_ALLOWED, UI_PROCESSING_PURPOSE_ALIASES);
|
|
331
|
+
if (mapped.length > 0)
|
|
332
|
+
normalized.processing_purpose = mapped;
|
|
333
|
+
else
|
|
334
|
+
delete normalized.processing_purpose;
|
|
335
|
+
}
|
|
336
|
+
if (!Object.prototype.hasOwnProperty.call(normalized, "cloud_provider") &&
|
|
337
|
+
Object.prototype.hasOwnProperty.call(normalized, "cloud_services_used")) {
|
|
338
|
+
const services = toStringArray(normalized.cloud_services_used).map(normalizeToken);
|
|
339
|
+
const provider = services.find((s) => s === "aws" || s === "amazon" || s === "amazon_web_services")
|
|
340
|
+
? "AWS"
|
|
341
|
+
: services.find((s) => s === "gcp" || s === "google" || s === "google_cloud")
|
|
342
|
+
? "GCP"
|
|
343
|
+
: services.find((s) => s === "azure" || s === "microsoft_azure")
|
|
344
|
+
? "Azure"
|
|
345
|
+
: undefined;
|
|
346
|
+
if (provider) {
|
|
347
|
+
normalized.cloud_provider = provider;
|
|
348
|
+
evidenceSourceByKey.cloud_provider = "cloud_services_used";
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
return { normalized, evidenceSourceByKey };
|
|
352
|
+
}
|
|
353
|
+
function parseAgentFromPrompt(prompt) {
|
|
354
|
+
try {
|
|
355
|
+
const o = JSON.parse(prompt);
|
|
356
|
+
if (o.agent && AGENTS.has(o.agent)) {
|
|
357
|
+
return o.agent;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
catch {
|
|
361
|
+
/* user message may not be JSON */
|
|
362
|
+
}
|
|
363
|
+
return "propertyAgent";
|
|
364
|
+
}
|
|
365
|
+
function aiDebugEnabled() {
|
|
366
|
+
return (0, scan_env_1.isScanAiDebugEnabled)();
|
|
367
|
+
}
|
|
368
|
+
function normalizeEvidence(raw) {
|
|
369
|
+
if (!Array.isArray(raw))
|
|
370
|
+
return [];
|
|
371
|
+
const out = [];
|
|
372
|
+
for (const x of raw) {
|
|
373
|
+
if (!x || typeof x !== "object")
|
|
374
|
+
continue;
|
|
375
|
+
const o = x;
|
|
376
|
+
const filePath = typeof o.filePath === "string" ? o.filePath.trim() : "";
|
|
377
|
+
const startLine = typeof o.startLine === "number" && Number.isFinite(o.startLine)
|
|
378
|
+
? Math.max(1, Math.floor(o.startLine))
|
|
379
|
+
: 1;
|
|
380
|
+
const endLine = typeof o.endLine === "number" && Number.isFinite(o.endLine)
|
|
381
|
+
? Math.max(startLine, Math.floor(o.endLine))
|
|
382
|
+
: startLine;
|
|
383
|
+
const reason = typeof o.reason === "string" ? o.reason.trim() : "";
|
|
384
|
+
if (!filePath || !reason)
|
|
385
|
+
continue;
|
|
386
|
+
out.push({ filePath, startLine, endLine, reason });
|
|
387
|
+
}
|
|
388
|
+
return out;
|
|
389
|
+
}
|
|
390
|
+
function normalizeConfidence(raw) {
|
|
391
|
+
if (!raw || typeof raw !== "object")
|
|
392
|
+
return null;
|
|
393
|
+
const o = raw;
|
|
394
|
+
const score = typeof o.score === "number" && Number.isFinite(o.score) ? o.score : NaN;
|
|
395
|
+
if (score < 0 || score > 1)
|
|
396
|
+
return null;
|
|
397
|
+
const band = o.band === "high" || o.band === "medium" || o.band === "low" ? o.band : "medium";
|
|
398
|
+
return { score, band };
|
|
399
|
+
}
|
|
400
|
+
function normalizeComponentPatch(p, ct, conf, defaults, validationCtx, reportDrop) {
|
|
401
|
+
const targetComponentId = typeof p.targetComponentId === "string" ? p.targetComponentId.trim() : "";
|
|
402
|
+
if (!targetComponentId) {
|
|
403
|
+
reportDrop?.("component_patch_missing_targetComponentId", p);
|
|
404
|
+
return null;
|
|
405
|
+
}
|
|
406
|
+
const setProperties = p.setProperties;
|
|
407
|
+
if (typeof setProperties !== "object" ||
|
|
408
|
+
setProperties === null ||
|
|
409
|
+
Array.isArray(setProperties)) {
|
|
410
|
+
reportDrop?.("component_patch_invalid_setProperties_object", p);
|
|
411
|
+
return null;
|
|
412
|
+
}
|
|
413
|
+
const peRaw = p.propertyEvidence;
|
|
414
|
+
if (typeof peRaw !== "object" ||
|
|
415
|
+
peRaw === null ||
|
|
416
|
+
Array.isArray(peRaw)) {
|
|
417
|
+
reportDrop?.("component_patch_invalid_propertyEvidence_object", p);
|
|
418
|
+
return null;
|
|
419
|
+
}
|
|
420
|
+
const sanitizedSetProperties = sanitizeSetProperties(setProperties);
|
|
421
|
+
const thirdPartyNormalized = ct === "third_party"
|
|
422
|
+
? normalizeThirdPartySetPropertiesForUi(sanitizedSetProperties)
|
|
423
|
+
: { normalized: sanitizedSetProperties, evidenceSourceByKey: {} };
|
|
424
|
+
const normalizedSetProperties = thirdPartyNormalized.normalized;
|
|
425
|
+
const evidenceSourceByKey = thirdPartyNormalized.evidenceSourceByKey;
|
|
426
|
+
const propKeys = Object.keys(normalizedSetProperties);
|
|
427
|
+
if (propKeys.length === 0) {
|
|
428
|
+
reportDrop?.("component_patch_setProperties_empty_after_sanitize", p);
|
|
429
|
+
return null;
|
|
430
|
+
}
|
|
431
|
+
const propertyEvidenceRecord = peRaw;
|
|
432
|
+
const keptProps = {};
|
|
433
|
+
const keptEvidence = {};
|
|
434
|
+
for (const key of propKeys) {
|
|
435
|
+
const sourceKey = evidenceSourceByKey[key] ?? key;
|
|
436
|
+
const refs = normalizeEvidence(propertyEvidenceRecord[sourceKey]);
|
|
437
|
+
if (refs.length === 0) {
|
|
438
|
+
reportDrop?.(`component_patch_property_${key}_missing_or_invalid_evidence`, {
|
|
439
|
+
targetComponentId,
|
|
440
|
+
key,
|
|
441
|
+
});
|
|
442
|
+
continue;
|
|
443
|
+
}
|
|
444
|
+
const adjustedRefs = [];
|
|
445
|
+
let allRefsValid = true;
|
|
446
|
+
for (const ref of refs) {
|
|
447
|
+
const adj = normalizeEvidenceRefForContext(ref, targetComponentId, validationCtx);
|
|
448
|
+
if (!adj) {
|
|
449
|
+
allRefsValid = false;
|
|
450
|
+
reportDrop?.(`component_patch_property_${key}_evidence_path_not_allowed`, {
|
|
451
|
+
targetComponentId,
|
|
452
|
+
key,
|
|
453
|
+
evidenceFilePath: ref.filePath,
|
|
454
|
+
});
|
|
455
|
+
break;
|
|
456
|
+
}
|
|
457
|
+
adjustedRefs.push(adj);
|
|
458
|
+
}
|
|
459
|
+
if (!allRefsValid)
|
|
460
|
+
continue;
|
|
461
|
+
keptProps[key] = normalizedSetProperties[key];
|
|
462
|
+
keptEvidence[key] = adjustedRefs;
|
|
463
|
+
}
|
|
464
|
+
if (Object.keys(keptProps).length === 0) {
|
|
465
|
+
reportDrop?.("component_patch_all_properties_dropped_by_evidence_validation", {
|
|
466
|
+
targetComponentId,
|
|
467
|
+
attemptedPropertyKeys: propKeys,
|
|
468
|
+
});
|
|
469
|
+
return null;
|
|
470
|
+
}
|
|
471
|
+
const evidence = flattenPropertyEvidence(keptEvidence);
|
|
472
|
+
if (evidence.length === 0) {
|
|
473
|
+
reportDrop?.("component_patch_flattened_evidence_empty", {
|
|
474
|
+
targetComponentId,
|
|
475
|
+
keptPropertyKeys: Object.keys(keptProps),
|
|
476
|
+
});
|
|
477
|
+
return null;
|
|
478
|
+
}
|
|
479
|
+
return {
|
|
480
|
+
kind: "component_patch",
|
|
481
|
+
targetComponentId,
|
|
482
|
+
candidateType: ct,
|
|
483
|
+
setSubType: typeof p.setSubType === "string" && p.setSubType.trim()
|
|
484
|
+
? p.setSubType.trim()
|
|
485
|
+
: undefined,
|
|
486
|
+
setDescription: typeof p.setDescription === "string" && p.setDescription.trim()
|
|
487
|
+
? p.setDescription.trim()
|
|
488
|
+
: undefined,
|
|
489
|
+
setProperties: keptProps,
|
|
490
|
+
propertyEvidence: keptEvidence,
|
|
491
|
+
confidence: conf,
|
|
492
|
+
evidence,
|
|
493
|
+
provider: defaults.provider,
|
|
494
|
+
model: defaults.model,
|
|
495
|
+
agent: defaults.agent,
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
function normalizeProposal(raw, defaults, validationCtx, reportDrop) {
|
|
499
|
+
if (!raw || typeof raw !== "object") {
|
|
500
|
+
reportDrop?.("proposal_not_object", raw);
|
|
501
|
+
return null;
|
|
502
|
+
}
|
|
503
|
+
const p = raw;
|
|
504
|
+
const kind = p.kind;
|
|
505
|
+
const candidateType = p.candidateType;
|
|
506
|
+
if (typeof candidateType !== "string" ||
|
|
507
|
+
!CANDIDATE_TYPES.has(candidateType)) {
|
|
508
|
+
reportDrop?.("proposal_invalid_candidateType", p);
|
|
509
|
+
return null;
|
|
510
|
+
}
|
|
511
|
+
const ct = candidateType;
|
|
512
|
+
const conf = normalizeConfidence(p.confidence);
|
|
513
|
+
if (!conf) {
|
|
514
|
+
reportDrop?.("proposal_invalid_confidence", p);
|
|
515
|
+
return null;
|
|
516
|
+
}
|
|
517
|
+
if (kind === "component_patch") {
|
|
518
|
+
return normalizeComponentPatch(p, ct, conf, defaults, validationCtx, reportDrop);
|
|
519
|
+
}
|
|
520
|
+
const evidence = normalizeEvidence(p.evidence);
|
|
521
|
+
if (evidence.length === 0) {
|
|
522
|
+
reportDrop?.("flow_patch_missing_or_invalid_evidence", p);
|
|
523
|
+
return null;
|
|
524
|
+
}
|
|
525
|
+
if (kind === "flow_patch") {
|
|
526
|
+
const targetFlowId = typeof p.targetFlowId === "string" && p.targetFlowId.trim()
|
|
527
|
+
? p.targetFlowId.trim()
|
|
528
|
+
: undefined;
|
|
529
|
+
const sourceComponentId = typeof p.sourceComponentId === "string" ? p.sourceComponentId.trim() : "";
|
|
530
|
+
const targetComponentId = typeof p.targetComponentId === "string" ? p.targetComponentId.trim() : "";
|
|
531
|
+
if (!targetFlowId && (!sourceComponentId || !targetComponentId)) {
|
|
532
|
+
reportDrop?.("flow_patch_missing_target_and_endpoints", p);
|
|
533
|
+
return null;
|
|
534
|
+
}
|
|
535
|
+
let setType;
|
|
536
|
+
if (typeof p.setType === "string" && FLOW_TYPES.has(p.setType)) {
|
|
537
|
+
setType = p.setType;
|
|
538
|
+
}
|
|
539
|
+
return {
|
|
540
|
+
kind: "flow_patch",
|
|
541
|
+
candidateType: ct,
|
|
542
|
+
targetFlowId,
|
|
543
|
+
insertIfMissing: p.insertIfMissing === true,
|
|
544
|
+
sourceComponentId: sourceComponentId || undefined,
|
|
545
|
+
targetComponentId: targetComponentId || undefined,
|
|
546
|
+
setType,
|
|
547
|
+
setDirection: p.setDirection === "forward" || p.setDirection === "reverse"
|
|
548
|
+
? p.setDirection
|
|
549
|
+
: undefined,
|
|
550
|
+
setMethod: typeof p.setMethod === "string" && p.setMethod.trim()
|
|
551
|
+
? p.setMethod.trim()
|
|
552
|
+
: undefined,
|
|
553
|
+
setEndpoint: typeof p.setEndpoint === "string" && p.setEndpoint.trim()
|
|
554
|
+
? p.setEndpoint.trim()
|
|
555
|
+
: undefined,
|
|
556
|
+
setDescription: typeof p.setDescription === "string" && p.setDescription.trim()
|
|
557
|
+
? p.setDescription.trim()
|
|
558
|
+
: undefined,
|
|
559
|
+
confidence: conf,
|
|
560
|
+
evidence,
|
|
561
|
+
provider: defaults.provider,
|
|
562
|
+
model: defaults.model,
|
|
563
|
+
agent: defaults.agent,
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
reportDrop?.("proposal_unknown_kind", p);
|
|
567
|
+
return null;
|
|
568
|
+
}
|
|
569
|
+
function previewJson(value, maxChars) {
|
|
570
|
+
try {
|
|
571
|
+
const serialized = JSON.stringify(value);
|
|
572
|
+
if (!serialized)
|
|
573
|
+
return "<empty>";
|
|
574
|
+
if (typeof maxChars !== "number" || !Number.isFinite(maxChars) || maxChars <= 0) {
|
|
575
|
+
return serialized;
|
|
576
|
+
}
|
|
577
|
+
return serialized.length > maxChars
|
|
578
|
+
? `${serialized.slice(0, maxChars)}...<truncated>`
|
|
579
|
+
: serialized;
|
|
580
|
+
}
|
|
581
|
+
catch {
|
|
582
|
+
return "<unserializable>";
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
function coercePropertyEvidenceShape(proposal) {
|
|
586
|
+
if (!proposal || typeof proposal !== "object" || Array.isArray(proposal)) {
|
|
587
|
+
return proposal;
|
|
588
|
+
}
|
|
589
|
+
const p = proposal;
|
|
590
|
+
const propertyEvidence = p.propertyEvidence;
|
|
591
|
+
if (!propertyEvidence || typeof propertyEvidence !== "object" || Array.isArray(propertyEvidence)) {
|
|
592
|
+
return proposal;
|
|
593
|
+
}
|
|
594
|
+
const pe = propertyEvidence;
|
|
595
|
+
let changed = false;
|
|
596
|
+
const coerced = {};
|
|
597
|
+
for (const [key, value] of Object.entries(pe)) {
|
|
598
|
+
if (Array.isArray(value)) {
|
|
599
|
+
coerced[key] = value;
|
|
600
|
+
continue;
|
|
601
|
+
}
|
|
602
|
+
if (value && typeof value === "object") {
|
|
603
|
+
coerced[key] = [value];
|
|
604
|
+
changed = true;
|
|
605
|
+
continue;
|
|
606
|
+
}
|
|
607
|
+
coerced[key] = value;
|
|
608
|
+
}
|
|
609
|
+
if (!changed)
|
|
610
|
+
return proposal;
|
|
611
|
+
return { ...p, propertyEvidence: coerced };
|
|
612
|
+
}
|
|
613
|
+
function strictParseAndNormalizeProposals(raw, defaults, options) {
|
|
614
|
+
const dropReasonCounts = new Map();
|
|
615
|
+
const dropReasonSamples = new Map();
|
|
616
|
+
const reportDrop = (reason, rawValue) => {
|
|
617
|
+
dropReasonCounts.set(reason, (dropReasonCounts.get(reason) ?? 0) + 1);
|
|
618
|
+
if (!dropReasonSamples.has(reason) && rawValue !== undefined) {
|
|
619
|
+
dropReasonSamples.set(reason, previewJson(rawValue, 400));
|
|
620
|
+
}
|
|
621
|
+
};
|
|
622
|
+
const coerceRaw = (() => {
|
|
623
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
624
|
+
return raw;
|
|
625
|
+
const o = raw;
|
|
626
|
+
const proposals = o.proposals;
|
|
627
|
+
if (Array.isArray(proposals)) {
|
|
628
|
+
return {
|
|
629
|
+
...o,
|
|
630
|
+
proposals: proposals.map((item) => coercePropertyEvidenceShape(item)),
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
if (!proposals || typeof proposals !== "object") {
|
|
634
|
+
return raw;
|
|
635
|
+
}
|
|
636
|
+
// Anthropic occasionally returns `proposals` as an object keyed by index.
|
|
637
|
+
// Coerce this shape into the expected array before strict schema validation.
|
|
638
|
+
const base = {
|
|
639
|
+
...o,
|
|
640
|
+
proposals: Object.values(proposals),
|
|
641
|
+
};
|
|
642
|
+
const arr = base.proposals;
|
|
643
|
+
return Array.isArray(arr)
|
|
644
|
+
? { ...base, proposals: arr.map((item) => coercePropertyEvidenceShape(item)) }
|
|
645
|
+
: base;
|
|
646
|
+
})();
|
|
647
|
+
const validated = openai_proposals_response_schema_1.openAiProposalsResponseSchema.safeParse(coerceRaw);
|
|
648
|
+
if (!validated.success) {
|
|
649
|
+
if (aiDebugEnabled()) {
|
|
650
|
+
const rawObj = raw && typeof raw === "object" && !Array.isArray(raw)
|
|
651
|
+
? raw
|
|
652
|
+
: null;
|
|
653
|
+
const coercedObj = coerceRaw && typeof coerceRaw === "object" && !Array.isArray(coerceRaw)
|
|
654
|
+
? coerceRaw
|
|
655
|
+
: null;
|
|
656
|
+
const rawProposals = rawObj?.proposals;
|
|
657
|
+
const coercedProposals = coercedObj?.proposals;
|
|
658
|
+
console.warn(`[dataparade-ai] ${options.debugLabel}: schema validation failed for provider response.`, validated.error.flatten());
|
|
659
|
+
console.warn(`[dataparade-ai] ${options.debugLabel}: response shape debug`, {
|
|
660
|
+
rawType: Array.isArray(raw) ? "array" : typeof raw,
|
|
661
|
+
rawKeys: rawObj ? Object.keys(rawObj).slice(0, 20) : [],
|
|
662
|
+
rawProposalsType: Array.isArray(rawProposals) ? "array" : typeof rawProposals,
|
|
663
|
+
coercedProposalsType: Array.isArray(coercedProposals)
|
|
664
|
+
? "array"
|
|
665
|
+
: typeof coercedProposals,
|
|
666
|
+
coercedProposalsLength: Array.isArray(coercedProposals)
|
|
667
|
+
? coercedProposals.length
|
|
668
|
+
: undefined,
|
|
669
|
+
});
|
|
670
|
+
console.warn(`[dataparade-ai] ${options.debugLabel}: raw response preview ${previewJson(raw)}`);
|
|
671
|
+
console.warn(`[dataparade-ai] ${options.debugLabel}: coerced response preview ${previewJson(coerceRaw)}`);
|
|
672
|
+
}
|
|
673
|
+
return [];
|
|
674
|
+
}
|
|
675
|
+
const validationCtx = options.userPrompt
|
|
676
|
+
? buildProposalsValidationContext(options.userPrompt)
|
|
677
|
+
: null;
|
|
678
|
+
const out = [];
|
|
679
|
+
const totalValidated = validated.data.proposals.length;
|
|
680
|
+
for (const item of validated.data.proposals) {
|
|
681
|
+
const proposal = normalizeProposal(item, defaults, validationCtx, reportDrop);
|
|
682
|
+
if (proposal)
|
|
683
|
+
out.push(proposal);
|
|
684
|
+
}
|
|
685
|
+
if (aiDebugEnabled()) {
|
|
686
|
+
const dropped = totalValidated - out.length;
|
|
687
|
+
console.warn(`[dataparade-ai] ${options.debugLabel}: normalization summary validated=${totalValidated} kept=${out.length} dropped=${dropped}`);
|
|
688
|
+
if (dropped > 0) {
|
|
689
|
+
const sortedReasons = [...dropReasonCounts.entries()].sort((a, b) => b[1] - a[1]);
|
|
690
|
+
console.warn(`[dataparade-ai] ${options.debugLabel}: normalization drop reasons`, Object.fromEntries(sortedReasons));
|
|
691
|
+
for (const [reason] of sortedReasons.slice(0, 8)) {
|
|
692
|
+
const sample = dropReasonSamples.get(reason);
|
|
693
|
+
if (sample) {
|
|
694
|
+
console.warn(`[dataparade-ai] ${options.debugLabel}: sample for ${reason}: ${sample}`);
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
if (out.length > 0) {
|
|
699
|
+
console.warn(`[dataparade-ai] ${options.debugLabel}: first normalized proposal preview ${previewJson(out[0])}`);
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
return out;
|
|
703
|
+
}
|