@bryan-thompson/inspector-assessment-client 1.25.4 → 1.25.6
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/assets/{OAuthCallback-DE62cdTZ.js → OAuthCallback-D6y8tFfF.js} +1 -1
- package/dist/assets/{OAuthDebugCallback-CWjFdCIE.js → OAuthDebugCallback-DHegnqTa.js} +1 -1
- package/dist/assets/{index-PCQVSwHa.js → index-Cu02Ah3g.js} +4 -4
- package/dist/assets/{index-Df9Sx1jt.css → index-cHhcEXbr.css} +4 -0
- package/dist/index.html +2 -2
- package/lib/lib/assessment/coreTypes.d.ts +65 -0
- package/lib/lib/assessment/coreTypes.d.ts.map +1 -1
- package/lib/lib/assessment/extendedTypes.d.ts +127 -0
- package/lib/lib/assessment/extendedTypes.d.ts.map +1 -1
- package/lib/lib/assessment/resultTypes.d.ts +45 -0
- package/lib/lib/assessment/resultTypes.d.ts.map +1 -1
- package/lib/lib/moduleScoring.d.ts +2 -2
- package/lib/lib/moduleScoring.d.ts.map +1 -1
- package/lib/lib/moduleScoring.js +3 -2
- package/lib/services/assessment/AssessmentOrchestrator.d.ts +3 -7
- package/lib/services/assessment/AssessmentOrchestrator.d.ts.map +1 -1
- package/lib/services/assessment/AssessmentOrchestrator.js +13 -2
- package/lib/services/assessment/TestDataGenerator.d.ts +9 -1
- package/lib/services/assessment/TestDataGenerator.d.ts.map +1 -1
- package/lib/services/assessment/TestDataGenerator.js +32 -6
- package/lib/services/assessment/TestScenarioEngine.d.ts +9 -1
- package/lib/services/assessment/TestScenarioEngine.d.ts.map +1 -1
- package/lib/services/assessment/TestScenarioEngine.js +17 -14
- package/lib/services/assessment/config/annotationPatterns.d.ts +3 -1
- package/lib/services/assessment/config/annotationPatterns.d.ts.map +1 -1
- package/lib/services/assessment/config/annotationPatterns.js +5 -2
- package/lib/services/assessment/config/architecturePatterns.d.ts +101 -0
- package/lib/services/assessment/config/architecturePatterns.d.ts.map +1 -0
- package/lib/services/assessment/config/architecturePatterns.js +248 -0
- package/lib/services/assessment/config/performanceConfig.d.ts +122 -0
- package/lib/services/assessment/config/performanceConfig.d.ts.map +1 -0
- package/lib/services/assessment/config/performanceConfig.js +154 -0
- package/lib/services/assessment/config/sanitizationPatterns.d.ts +63 -0
- package/lib/services/assessment/config/sanitizationPatterns.d.ts.map +1 -0
- package/lib/services/assessment/config/sanitizationPatterns.js +223 -0
- package/lib/services/assessment/lib/claudeCodeBridge.d.ts +40 -3
- package/lib/services/assessment/lib/claudeCodeBridge.d.ts.map +1 -1
- package/lib/services/assessment/lib/claudeCodeBridge.js +149 -8
- package/lib/services/assessment/lib/concurrencyLimit.d.ts +6 -2
- package/lib/services/assessment/lib/concurrencyLimit.d.ts.map +1 -1
- package/lib/services/assessment/lib/concurrencyLimit.js +13 -6
- package/lib/services/assessment/lib/errors.d.ts +90 -0
- package/lib/services/assessment/lib/errors.d.ts.map +1 -0
- package/lib/services/assessment/lib/errors.js +136 -0
- package/lib/services/assessment/lib/timeoutUtils.d.ts +69 -0
- package/lib/services/assessment/lib/timeoutUtils.d.ts.map +1 -0
- package/lib/services/assessment/lib/timeoutUtils.js +103 -0
- package/lib/services/assessment/modules/BaseAssessor.d.ts +43 -8
- package/lib/services/assessment/modules/BaseAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/BaseAssessor.js +103 -34
- package/lib/services/assessment/modules/DeveloperExperienceAssessor.d.ts +38 -1
- package/lib/services/assessment/modules/DeveloperExperienceAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/DeveloperExperienceAssessor.js +185 -19
- package/lib/services/assessment/modules/DocumentationAssessor.d.ts +5 -0
- package/lib/services/assessment/modules/DocumentationAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/DocumentationAssessor.js +11 -0
- package/lib/services/assessment/modules/ErrorHandlingAssessor.js +1 -1
- package/lib/services/assessment/modules/FunctionalityAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/FunctionalityAssessor.js +6 -3
- package/lib/services/assessment/modules/MCPSpecComplianceAssessor.d.ts +3 -0
- package/lib/services/assessment/modules/MCPSpecComplianceAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/MCPSpecComplianceAssessor.js +14 -2
- package/lib/services/assessment/modules/ManifestValidationAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/ManifestValidationAssessor.js +7 -2
- package/lib/services/assessment/modules/PromptAssessor.d.ts +1 -0
- package/lib/services/assessment/modules/PromptAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/PromptAssessor.js +26 -16
- package/lib/services/assessment/modules/ProtocolComplianceAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/ProtocolComplianceAssessor.js +6 -2
- package/lib/services/assessment/modules/ProtocolConformanceAssessor.d.ts +5 -0
- package/lib/services/assessment/modules/ProtocolConformanceAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/ProtocolConformanceAssessor.js +15 -0
- package/lib/services/assessment/modules/ResourceAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/ResourceAssessor.js +8 -2
- package/lib/services/assessment/modules/SecurityAssessor.d.ts +3 -171
- package/lib/services/assessment/modules/SecurityAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/SecurityAssessor.js +25 -1480
- package/lib/services/assessment/modules/ToolAnnotationAssessor.d.ts +27 -28
- package/lib/services/assessment/modules/ToolAnnotationAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/ToolAnnotationAssessor.js +340 -863
- package/lib/services/assessment/modules/UsabilityAssessor.d.ts +5 -0
- package/lib/services/assessment/modules/UsabilityAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/UsabilityAssessor.js +11 -0
- package/lib/services/assessment/modules/annotations/AnnotationDeceptionDetector.d.ts +57 -0
- package/lib/services/assessment/modules/annotations/AnnotationDeceptionDetector.d.ts.map +1 -0
- package/lib/services/assessment/modules/annotations/AnnotationDeceptionDetector.js +176 -0
- package/lib/services/assessment/modules/annotations/ArchitectureDetector.d.ts +67 -0
- package/lib/services/assessment/modules/annotations/ArchitectureDetector.d.ts.map +1 -0
- package/lib/services/assessment/modules/annotations/ArchitectureDetector.js +239 -0
- package/lib/services/assessment/modules/annotations/BehaviorInference.d.ts +46 -0
- package/lib/services/assessment/modules/annotations/BehaviorInference.d.ts.map +1 -0
- package/lib/services/assessment/modules/annotations/BehaviorInference.js +394 -0
- package/lib/services/assessment/modules/annotations/DescriptionAnalyzer.d.ts +64 -0
- package/lib/services/assessment/modules/annotations/DescriptionAnalyzer.d.ts.map +1 -0
- package/lib/services/assessment/modules/annotations/DescriptionAnalyzer.js +304 -0
- package/lib/services/assessment/modules/annotations/DescriptionPoisoningDetector.d.ts +43 -0
- package/lib/services/assessment/modules/annotations/DescriptionPoisoningDetector.d.ts.map +1 -0
- package/lib/services/assessment/modules/annotations/DescriptionPoisoningDetector.js +276 -0
- package/lib/services/assessment/modules/annotations/SchemaAnalyzer.d.ts +122 -0
- package/lib/services/assessment/modules/annotations/SchemaAnalyzer.d.ts.map +1 -0
- package/lib/services/assessment/modules/annotations/SchemaAnalyzer.js +388 -0
- package/lib/services/assessment/modules/annotations/index.d.ts +13 -0
- package/lib/services/assessment/modules/annotations/index.d.ts.map +1 -0
- package/lib/services/assessment/modules/annotations/index.js +15 -0
- package/lib/services/assessment/modules/index.d.ts +10 -0
- package/lib/services/assessment/modules/index.d.ts.map +1 -1
- package/lib/services/assessment/modules/index.js +13 -0
- package/lib/services/assessment/modules/securityTests/SanitizationDetector.d.ts +125 -0
- package/lib/services/assessment/modules/securityTests/SanitizationDetector.d.ts.map +1 -0
- package/lib/services/assessment/modules/securityTests/SanitizationDetector.js +345 -0
- package/lib/services/assessment/modules/securityTests/SecurityPayloadGenerator.d.ts +33 -0
- package/lib/services/assessment/modules/securityTests/SecurityPayloadGenerator.d.ts.map +1 -0
- package/lib/services/assessment/modules/securityTests/SecurityPayloadGenerator.js +128 -0
- package/lib/services/assessment/modules/securityTests/SecurityPayloadTester.d.ts +67 -0
- package/lib/services/assessment/modules/securityTests/SecurityPayloadTester.d.ts.map +1 -0
- package/lib/services/assessment/modules/securityTests/SecurityPayloadTester.js +372 -0
- package/lib/services/assessment/modules/securityTests/SecurityResponseAnalyzer.d.ts +178 -0
- package/lib/services/assessment/modules/securityTests/SecurityResponseAnalyzer.d.ts.map +1 -0
- package/lib/services/assessment/modules/securityTests/SecurityResponseAnalyzer.js +1207 -0
- package/lib/services/assessment/modules/securityTests/index.d.ts +8 -0
- package/lib/services/assessment/modules/securityTests/index.d.ts.map +1 -0
- package/lib/services/assessment/modules/securityTests/index.js +7 -0
- package/lib/services/assessment/tool-classifier-patterns.d.ts +1 -0
- package/lib/services/assessment/tool-classifier-patterns.d.ts.map +1 -1
- package/lib/services/assessment/tool-classifier-patterns.js +17 -0
- package/package.json +1 -1
|
@@ -3,9 +3,14 @@
|
|
|
3
3
|
* Evaluates tool naming, parameter clarity, and best practices
|
|
4
4
|
*/
|
|
5
5
|
import { UsabilityAssessment } from "../../../lib/assessmentTypes.js";
|
|
6
|
+
import { AssessmentConfiguration } from "../../../lib/assessment/configTypes.js";
|
|
6
7
|
import { BaseAssessor } from "./BaseAssessor.js";
|
|
7
8
|
import { AssessmentContext } from "../AssessmentOrchestrator.js";
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Use DeveloperExperienceAssessor instead. Will be removed in v2.0.0.
|
|
11
|
+
*/
|
|
8
12
|
export declare class UsabilityAssessor extends BaseAssessor {
|
|
13
|
+
constructor(config: AssessmentConfiguration);
|
|
9
14
|
assess(context: AssessmentContext): Promise<UsabilityAssessment>;
|
|
10
15
|
private analyzeUsability;
|
|
11
16
|
private analyzeNamingConvention;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UsabilityAssessor.d.ts","sourceRoot":"","sources":["../../../../src/services/assessment/modules/UsabilityAssessor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,mBAAmB,
|
|
1
|
+
{"version":3,"file":"UsabilityAssessor.d.ts","sourceRoot":"","sources":["../../../../src/services/assessment/modules/UsabilityAssessor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,mBAAmB,EAIpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAEvE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAQ9D;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,YAAY;gBACrC,MAAM,EAAE,uBAAuB;IAYrC,MAAM,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAgBtE,OAAO,CAAC,gBAAgB;IAcxB,OAAO,CAAC,uBAAuB;IAuC/B,OAAO,CAAC,uBAAuB;IA0C/B,OAAO,CAAC,iBAAiB;IAezB,OAAO,CAAC,kBAAkB;IA6C1B,OAAO,CAAC,iBAAiB;IAoCzB,OAAO,CAAC,aAAa;IAQrB,OAAO,CAAC,wBAAwB;IAkBhC,OAAO,CAAC,mBAAmB;IAwB3B,OAAO,CAAC,uBAAuB;CAyBhC"}
|
|
@@ -3,7 +3,18 @@
|
|
|
3
3
|
* Evaluates tool naming, parameter clarity, and best practices
|
|
4
4
|
*/
|
|
5
5
|
import { BaseAssessor } from "./BaseAssessor.js";
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use DeveloperExperienceAssessor instead. Will be removed in v2.0.0.
|
|
8
|
+
*/
|
|
6
9
|
export class UsabilityAssessor extends BaseAssessor {
|
|
10
|
+
constructor(config) {
|
|
11
|
+
super(config);
|
|
12
|
+
this.logger.warn("UsabilityAssessor is deprecated. Use DeveloperExperienceAssessor instead. " +
|
|
13
|
+
"This module will be removed in v2.0.0.", {
|
|
14
|
+
module: "UsabilityAssessor",
|
|
15
|
+
replacement: "DeveloperExperienceAssessor",
|
|
16
|
+
});
|
|
17
|
+
}
|
|
7
18
|
async assess(context) {
|
|
8
19
|
this.log("Starting usability assessment");
|
|
9
20
|
const metrics = this.analyzeUsability(context.tools);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Annotation Deception Detector
|
|
3
|
+
* High-confidence deception detection for obvious annotation misalignments
|
|
4
|
+
*
|
|
5
|
+
* Extracted from ToolAnnotationAssessor.ts for maintainability.
|
|
6
|
+
* Handles keyword-based misalignment detection.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Keywords that contradict readOnlyHint=true (these tools modify state)
|
|
10
|
+
*/
|
|
11
|
+
export declare const READONLY_CONTRADICTION_KEYWORDS: string[];
|
|
12
|
+
/**
|
|
13
|
+
* Suffixes that exempt "run" from readOnlyHint contradiction detection.
|
|
14
|
+
* Tools matching "run" + these suffixes are legitimately read-only (fetch analysis data).
|
|
15
|
+
* Issue #18: browser-tools-mcp uses runAccessibilityAudit, runSEOAudit, etc.
|
|
16
|
+
*/
|
|
17
|
+
export declare const RUN_READONLY_EXEMPT_SUFFIXES: string[];
|
|
18
|
+
/**
|
|
19
|
+
* Keywords that contradict destructiveHint=false (these tools delete/destroy data)
|
|
20
|
+
*/
|
|
21
|
+
export declare const DESTRUCTIVE_CONTRADICTION_KEYWORDS: string[];
|
|
22
|
+
/**
|
|
23
|
+
* Deception detection result
|
|
24
|
+
*/
|
|
25
|
+
export interface DeceptionResult {
|
|
26
|
+
field: "readOnlyHint" | "destructiveHint";
|
|
27
|
+
matchedKeyword: string;
|
|
28
|
+
reason: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Check if a tool name contains any of the given keywords (case-insensitive)
|
|
32
|
+
* Uses word segment matching to avoid false positives (e.g., "put" in "output")
|
|
33
|
+
* Issue #25: Substring matching caused false positives for words like "output", "input", "compute"
|
|
34
|
+
*
|
|
35
|
+
* Handles: camelCase (putFile), snake_case (put_file), kebab-case (put-file), PascalCase (PutFile)
|
|
36
|
+
*/
|
|
37
|
+
export declare function containsKeyword(toolName: string, keywords: string[]): string | null;
|
|
38
|
+
/**
|
|
39
|
+
* Check if a tool name with "run" keyword is exempt from readOnlyHint contradiction.
|
|
40
|
+
* Tools like "runAccessibilityAudit" are genuinely read-only (fetch analysis data).
|
|
41
|
+
* Issue #18: Prevents false positives for analysis/audit tools.
|
|
42
|
+
*/
|
|
43
|
+
export declare function isRunKeywordExempt(toolName: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Type guard for confidence levels that warrant event emission or status changes.
|
|
46
|
+
* Uses positive check for acceptable levels (safer than !== "low" if new levels added).
|
|
47
|
+
*/
|
|
48
|
+
export declare function isActionableConfidence(confidence: string): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Detect high-confidence annotation deception
|
|
51
|
+
* Returns misalignment info if obvious deception detected, null otherwise
|
|
52
|
+
*/
|
|
53
|
+
export declare function detectAnnotationDeception(toolName: string, annotations: {
|
|
54
|
+
readOnlyHint?: boolean;
|
|
55
|
+
destructiveHint?: boolean;
|
|
56
|
+
}): DeceptionResult | null;
|
|
57
|
+
//# sourceMappingURL=AnnotationDeceptionDetector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnnotationDeceptionDetector.d.ts","sourceRoot":"","sources":["../../../../../src/services/assessment/modules/annotations/AnnotationDeceptionDetector.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AACH,eAAO,MAAM,+BAA+B,UA0C3C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,UAexC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kCAAkC,UAgB9C,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,cAAc,GAAG,iBAAiB,CAAC;IAC1C,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAAE,GACjB,MAAM,GAAG,IAAI,CAkBf;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAU5D;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAElE;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAC;IAAC,eAAe,CAAC,EAAE,OAAO,CAAA;CAAE,GACjE,eAAe,GAAG,IAAI,CAoCxB"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Annotation Deception Detector
|
|
3
|
+
* High-confidence deception detection for obvious annotation misalignments
|
|
4
|
+
*
|
|
5
|
+
* Extracted from ToolAnnotationAssessor.ts for maintainability.
|
|
6
|
+
* Handles keyword-based misalignment detection.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Keywords that contradict readOnlyHint=true (these tools modify state)
|
|
10
|
+
*/
|
|
11
|
+
export const READONLY_CONTRADICTION_KEYWORDS = [
|
|
12
|
+
// Execution keywords - tools that execute code/commands are never read-only
|
|
13
|
+
"exec",
|
|
14
|
+
"execute",
|
|
15
|
+
"run",
|
|
16
|
+
"shell",
|
|
17
|
+
"command",
|
|
18
|
+
"cmd",
|
|
19
|
+
"spawn",
|
|
20
|
+
"invoke",
|
|
21
|
+
// Write/modify keywords
|
|
22
|
+
"write",
|
|
23
|
+
"create",
|
|
24
|
+
"delete",
|
|
25
|
+
"remove",
|
|
26
|
+
"modify",
|
|
27
|
+
"update",
|
|
28
|
+
"edit",
|
|
29
|
+
"change",
|
|
30
|
+
"set",
|
|
31
|
+
"put",
|
|
32
|
+
"patch",
|
|
33
|
+
// Deployment/installation keywords
|
|
34
|
+
"install",
|
|
35
|
+
"deploy",
|
|
36
|
+
"upload",
|
|
37
|
+
"push",
|
|
38
|
+
// Communication keywords (sending data)
|
|
39
|
+
"send",
|
|
40
|
+
"post",
|
|
41
|
+
"submit",
|
|
42
|
+
"publish",
|
|
43
|
+
// Destructive keywords
|
|
44
|
+
"destroy",
|
|
45
|
+
"drop",
|
|
46
|
+
"purge",
|
|
47
|
+
"wipe",
|
|
48
|
+
"clear",
|
|
49
|
+
"truncate",
|
|
50
|
+
"reset",
|
|
51
|
+
"kill",
|
|
52
|
+
"terminate",
|
|
53
|
+
];
|
|
54
|
+
/**
|
|
55
|
+
* Suffixes that exempt "run" from readOnlyHint contradiction detection.
|
|
56
|
+
* Tools matching "run" + these suffixes are legitimately read-only (fetch analysis data).
|
|
57
|
+
* Issue #18: browser-tools-mcp uses runAccessibilityAudit, runSEOAudit, etc.
|
|
58
|
+
*/
|
|
59
|
+
export const RUN_READONLY_EXEMPT_SUFFIXES = [
|
|
60
|
+
"audit", // runAccessibilityAudit, runPerformanceAudit, runSEOAudit
|
|
61
|
+
"check", // runHealthCheck, runSecurityCheck
|
|
62
|
+
"mode", // runAuditMode, runDebuggerMode
|
|
63
|
+
"test", // runTest, runUnitTest (analysis, not execution)
|
|
64
|
+
"scan", // runSecurityScan, runVulnerabilityScan
|
|
65
|
+
"analyze", // runAnalyze, runCodeAnalyze
|
|
66
|
+
"report", // runReport, runStatusReport
|
|
67
|
+
"status", // runStatus, runHealthStatus
|
|
68
|
+
"validate", // runValidate, runSchemaValidate
|
|
69
|
+
"verify", // runVerify, runIntegrityVerify
|
|
70
|
+
"inspect", // runInspect, runCodeInspect
|
|
71
|
+
"lint", // runLint, runEslint
|
|
72
|
+
"benchmark", // runBenchmark, runPerfBenchmark
|
|
73
|
+
"diagnostic", // runDiagnostic
|
|
74
|
+
];
|
|
75
|
+
/**
|
|
76
|
+
* Keywords that contradict destructiveHint=false (these tools delete/destroy data)
|
|
77
|
+
*/
|
|
78
|
+
export const DESTRUCTIVE_CONTRADICTION_KEYWORDS = [
|
|
79
|
+
"delete",
|
|
80
|
+
"remove",
|
|
81
|
+
"drop",
|
|
82
|
+
"destroy",
|
|
83
|
+
"purge",
|
|
84
|
+
"wipe",
|
|
85
|
+
"erase",
|
|
86
|
+
"truncate",
|
|
87
|
+
"clear",
|
|
88
|
+
"reset",
|
|
89
|
+
"kill",
|
|
90
|
+
"terminate",
|
|
91
|
+
"revoke",
|
|
92
|
+
"cancel",
|
|
93
|
+
"force",
|
|
94
|
+
];
|
|
95
|
+
/**
|
|
96
|
+
* Check if a tool name contains any of the given keywords (case-insensitive)
|
|
97
|
+
* Uses word segment matching to avoid false positives (e.g., "put" in "output")
|
|
98
|
+
* Issue #25: Substring matching caused false positives for words like "output", "input", "compute"
|
|
99
|
+
*
|
|
100
|
+
* Handles: camelCase (putFile), snake_case (put_file), kebab-case (put-file), PascalCase (PutFile)
|
|
101
|
+
*/
|
|
102
|
+
export function containsKeyword(toolName, keywords) {
|
|
103
|
+
// Normalize camelCase/PascalCase by inserting separator before uppercase letters
|
|
104
|
+
// "putFile" → "put_File", "updateUser" → "update_User", "GetOutput" → "Get_Output"
|
|
105
|
+
const normalized = toolName.replace(/([a-z])([A-Z])/g, "$1_$2").toLowerCase();
|
|
106
|
+
// Split by common separators (underscore, hyphen)
|
|
107
|
+
const segments = normalized.split(/[_-]/);
|
|
108
|
+
for (const keyword of keywords) {
|
|
109
|
+
for (const segment of segments) {
|
|
110
|
+
// Match if segment equals keyword or starts with keyword
|
|
111
|
+
// This handles: "exec" matches "exec" segment, "exec_command" segment starts with "exec"
|
|
112
|
+
if (segment === keyword || segment.startsWith(keyword)) {
|
|
113
|
+
return keyword;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Check if a tool name with "run" keyword is exempt from readOnlyHint contradiction.
|
|
121
|
+
* Tools like "runAccessibilityAudit" are genuinely read-only (fetch analysis data).
|
|
122
|
+
* Issue #18: Prevents false positives for analysis/audit tools.
|
|
123
|
+
*/
|
|
124
|
+
export function isRunKeywordExempt(toolName) {
|
|
125
|
+
const lowerName = toolName.toLowerCase();
|
|
126
|
+
// Only applies when "run" is detected
|
|
127
|
+
if (!lowerName.includes("run")) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
// Check if any exempt suffix is present
|
|
131
|
+
return RUN_READONLY_EXEMPT_SUFFIXES.some((suffix) => lowerName.includes(suffix));
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Type guard for confidence levels that warrant event emission or status changes.
|
|
135
|
+
* Uses positive check for acceptable levels (safer than !== "low" if new levels added).
|
|
136
|
+
*/
|
|
137
|
+
export function isActionableConfidence(confidence) {
|
|
138
|
+
return confidence === "high" || confidence === "medium";
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Detect high-confidence annotation deception
|
|
142
|
+
* Returns misalignment info if obvious deception detected, null otherwise
|
|
143
|
+
*/
|
|
144
|
+
export function detectAnnotationDeception(toolName, annotations) {
|
|
145
|
+
// Check readOnlyHint=true contradiction
|
|
146
|
+
if (annotations.readOnlyHint === true) {
|
|
147
|
+
const keyword = containsKeyword(toolName, READONLY_CONTRADICTION_KEYWORDS);
|
|
148
|
+
if (keyword) {
|
|
149
|
+
// Issue #18: Skip deception flagging for "run" + analysis suffix combinations
|
|
150
|
+
// Tools like "runAccessibilityAudit" are genuinely read-only
|
|
151
|
+
if (keyword === "run" && isRunKeywordExempt(toolName)) {
|
|
152
|
+
// Tool matches "run" but has an analysis suffix - not deceptive
|
|
153
|
+
// Fall through to normal pattern-based inference
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
return {
|
|
157
|
+
field: "readOnlyHint",
|
|
158
|
+
matchedKeyword: keyword,
|
|
159
|
+
reason: `Tool name contains '${keyword}' but claims readOnlyHint=true - this is likely deceptive`,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
// Check destructiveHint=false contradiction
|
|
165
|
+
if (annotations.destructiveHint === false) {
|
|
166
|
+
const keyword = containsKeyword(toolName, DESTRUCTIVE_CONTRADICTION_KEYWORDS);
|
|
167
|
+
if (keyword) {
|
|
168
|
+
return {
|
|
169
|
+
field: "destructiveHint",
|
|
170
|
+
matchedKeyword: keyword,
|
|
171
|
+
reason: `Tool name contains '${keyword}' but claims destructiveHint=false - this is likely deceptive`,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Architecture Detector
|
|
3
|
+
*
|
|
4
|
+
* Detects server architecture characteristics including:
|
|
5
|
+
* - Database backends (Neo4j, MongoDB, PostgreSQL, etc.)
|
|
6
|
+
* - Transport modes (stdio, HTTP, SSE)
|
|
7
|
+
* - Server type classification (local, hybrid, remote)
|
|
8
|
+
* - Network access requirements
|
|
9
|
+
*
|
|
10
|
+
* Part of Issue #57: Architecture detection and behavior inference modules
|
|
11
|
+
*/
|
|
12
|
+
import type { ArchitectureAnalysis, DatabaseBackend } from "../../../../lib/assessment/extendedTypes.js";
|
|
13
|
+
/**
|
|
14
|
+
* Tool definition for analysis
|
|
15
|
+
*/
|
|
16
|
+
export interface Tool {
|
|
17
|
+
name: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
inputSchema?: unknown;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Context provided for architecture detection
|
|
23
|
+
*/
|
|
24
|
+
export interface ArchitectureContext {
|
|
25
|
+
/** Tools provided by the server */
|
|
26
|
+
tools: Tool[];
|
|
27
|
+
/** Transport type if known (from connection) */
|
|
28
|
+
transportType?: string;
|
|
29
|
+
/** Source code files (filename -> content) */
|
|
30
|
+
sourceCodeFiles?: Map<string, string>;
|
|
31
|
+
/** Manifest JSON content */
|
|
32
|
+
manifestJson?: {
|
|
33
|
+
name?: string;
|
|
34
|
+
description?: string;
|
|
35
|
+
dependencies?: Record<string, string>;
|
|
36
|
+
devDependencies?: Record<string, string>;
|
|
37
|
+
};
|
|
38
|
+
/** Package.json content if available */
|
|
39
|
+
packageJson?: {
|
|
40
|
+
dependencies?: Record<string, string>;
|
|
41
|
+
devDependencies?: Record<string, string>;
|
|
42
|
+
};
|
|
43
|
+
/** Requirements.txt content if available */
|
|
44
|
+
requirementsTxt?: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Detect architecture characteristics from the provided context.
|
|
48
|
+
*
|
|
49
|
+
* @param context - Architecture context with tools, source code, etc.
|
|
50
|
+
* @returns ArchitectureAnalysis with detected characteristics
|
|
51
|
+
*/
|
|
52
|
+
export declare function detectArchitecture(context: ArchitectureContext): ArchitectureAnalysis;
|
|
53
|
+
/**
|
|
54
|
+
* Quick check if tools suggest database operations.
|
|
55
|
+
*
|
|
56
|
+
* @param tools - Tools to analyze
|
|
57
|
+
* @returns True if tools suggest database operations
|
|
58
|
+
*/
|
|
59
|
+
export declare function hasDatabaseToolPatterns(tools: Tool[]): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Extract database types from package.json dependencies.
|
|
62
|
+
*
|
|
63
|
+
* @param dependencies - Package.json dependencies object
|
|
64
|
+
* @returns Array of detected database types
|
|
65
|
+
*/
|
|
66
|
+
export declare function extractDatabasesFromDependencies(dependencies: Record<string, string>): DatabaseBackend[];
|
|
67
|
+
//# sourceMappingURL=ArchitectureDetector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArchitectureDetector.d.ts","sourceRoot":"","sources":["../../../../../src/services/assessment/modules/annotations/ArchitectureDetector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACV,oBAAoB,EACpB,eAAe,EAGhB,MAAM,gCAAgC,CAAC;AAQxC;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,mCAAmC;IACnC,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,gDAAgD;IAChD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,8CAA8C;IAC9C,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,4BAA4B;IAC5B,YAAY,CAAC,EAAE;QACb,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACtC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAC1C,CAAC;IACF,wCAAwC;IACxC,WAAW,CAAC,EAAE;QACZ,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACtC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAC1C,CAAC;IACF,4CAA4C;IAC5C,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,mBAAmB,GAC3B,oBAAoB,CAiEtB;AAwKD;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,OAAO,CAa9D;AAED;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAC9C,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACnC,eAAe,EAAE,CAYnB"}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Architecture Detector
|
|
3
|
+
*
|
|
4
|
+
* Detects server architecture characteristics including:
|
|
5
|
+
* - Database backends (Neo4j, MongoDB, PostgreSQL, etc.)
|
|
6
|
+
* - Transport modes (stdio, HTTP, SSE)
|
|
7
|
+
* - Server type classification (local, hybrid, remote)
|
|
8
|
+
* - Network access requirements
|
|
9
|
+
*
|
|
10
|
+
* Part of Issue #57: Architecture detection and behavior inference modules
|
|
11
|
+
*/
|
|
12
|
+
import { detectDatabasesFromContent, detectTransportsFromContent, checkNetworkAccess, detectExternalServices, } from "../../config/architecturePatterns.js";
|
|
13
|
+
/**
|
|
14
|
+
* Detect architecture characteristics from the provided context.
|
|
15
|
+
*
|
|
16
|
+
* @param context - Architecture context with tools, source code, etc.
|
|
17
|
+
* @returns ArchitectureAnalysis with detected characteristics
|
|
18
|
+
*/
|
|
19
|
+
export function detectArchitecture(context) {
|
|
20
|
+
const evidence = {
|
|
21
|
+
databaseIndicators: [],
|
|
22
|
+
transportIndicators: [],
|
|
23
|
+
networkIndicators: [],
|
|
24
|
+
};
|
|
25
|
+
// Collect all text content for analysis
|
|
26
|
+
const allContent = collectAnalyzableContent(context);
|
|
27
|
+
// Detect databases
|
|
28
|
+
const databaseResults = detectDatabasesFromContent(allContent);
|
|
29
|
+
const databaseBackends = databaseResults.map((r) => r.backend);
|
|
30
|
+
const primaryDatabase = databaseBackends[0];
|
|
31
|
+
evidence.databaseIndicators = databaseResults.map((r) => r.evidence);
|
|
32
|
+
// Detect transports
|
|
33
|
+
const detectedTransports = detectTransportsFromContent(allContent);
|
|
34
|
+
// Include transport from connection if known
|
|
35
|
+
if (context.transportType) {
|
|
36
|
+
const normalized = normalizeTransport(context.transportType);
|
|
37
|
+
if (normalized && !detectedTransports.includes(normalized)) {
|
|
38
|
+
detectedTransports.push(normalized);
|
|
39
|
+
}
|
|
40
|
+
evidence.transportIndicators.push(`Connection transport: ${normalized}`);
|
|
41
|
+
}
|
|
42
|
+
// Detect network access requirements
|
|
43
|
+
const networkCheck = checkNetworkAccess(allContent);
|
|
44
|
+
if (networkCheck.requiresNetwork) {
|
|
45
|
+
evidence.networkIndicators = networkCheck.indicators;
|
|
46
|
+
}
|
|
47
|
+
// Detect external services
|
|
48
|
+
const externalServices = detectExternalServices(allContent);
|
|
49
|
+
// Classify server type
|
|
50
|
+
const serverType = classifyServerType(detectedTransports, networkCheck.requiresNetwork, networkCheck.localOnly, externalServices);
|
|
51
|
+
// Calculate confidence
|
|
52
|
+
const confidence = calculateConfidence(databaseResults, detectedTransports, evidence, context);
|
|
53
|
+
return {
|
|
54
|
+
serverType,
|
|
55
|
+
databaseBackend: primaryDatabase,
|
|
56
|
+
databaseBackends: databaseBackends.length > 0 ? databaseBackends : [],
|
|
57
|
+
transportModes: detectedTransports.length > 0 ? detectedTransports : ["stdio"],
|
|
58
|
+
externalDependencies: externalServices,
|
|
59
|
+
requiresNetworkAccess: networkCheck.requiresNetwork || externalServices.length > 0,
|
|
60
|
+
confidence,
|
|
61
|
+
evidence,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Collect all analyzable text content from context.
|
|
66
|
+
*/
|
|
67
|
+
function collectAnalyzableContent(context) {
|
|
68
|
+
const parts = [];
|
|
69
|
+
// Tool names and descriptions
|
|
70
|
+
for (const tool of context.tools) {
|
|
71
|
+
parts.push(tool.name);
|
|
72
|
+
if (tool.description) {
|
|
73
|
+
parts.push(tool.description);
|
|
74
|
+
}
|
|
75
|
+
// Include schema as stringified JSON for pattern matching
|
|
76
|
+
if (tool.inputSchema) {
|
|
77
|
+
try {
|
|
78
|
+
parts.push(JSON.stringify(tool.inputSchema));
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
// Ignore stringify errors
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Manifest content
|
|
86
|
+
if (context.manifestJson) {
|
|
87
|
+
if (context.manifestJson.name)
|
|
88
|
+
parts.push(context.manifestJson.name);
|
|
89
|
+
if (context.manifestJson.description)
|
|
90
|
+
parts.push(context.manifestJson.description);
|
|
91
|
+
if (context.manifestJson.dependencies) {
|
|
92
|
+
parts.push(Object.keys(context.manifestJson.dependencies).join(" "));
|
|
93
|
+
}
|
|
94
|
+
if (context.manifestJson.devDependencies) {
|
|
95
|
+
parts.push(Object.keys(context.manifestJson.devDependencies).join(" "));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// Package.json dependencies
|
|
99
|
+
if (context.packageJson) {
|
|
100
|
+
if (context.packageJson.dependencies) {
|
|
101
|
+
parts.push(Object.keys(context.packageJson.dependencies).join(" "));
|
|
102
|
+
}
|
|
103
|
+
if (context.packageJson.devDependencies) {
|
|
104
|
+
parts.push(Object.keys(context.packageJson.devDependencies).join(" "));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// Requirements.txt
|
|
108
|
+
if (context.requirementsTxt) {
|
|
109
|
+
parts.push(context.requirementsTxt);
|
|
110
|
+
}
|
|
111
|
+
// Source code files (limited to avoid overwhelming)
|
|
112
|
+
if (context.sourceCodeFiles) {
|
|
113
|
+
let charCount = 0;
|
|
114
|
+
const maxChars = 100000; // Limit to ~100KB of source
|
|
115
|
+
for (const [filename, content] of context.sourceCodeFiles) {
|
|
116
|
+
parts.push(filename);
|
|
117
|
+
if (charCount + content.length <= maxChars) {
|
|
118
|
+
parts.push(content);
|
|
119
|
+
charCount += content.length;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return parts.join("\n");
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Normalize transport type string to TransportMode.
|
|
127
|
+
*/
|
|
128
|
+
function normalizeTransport(transport) {
|
|
129
|
+
const lower = transport.toLowerCase();
|
|
130
|
+
if (lower.includes("stdio"))
|
|
131
|
+
return "stdio";
|
|
132
|
+
if (lower.includes("sse"))
|
|
133
|
+
return "sse";
|
|
134
|
+
if (lower.includes("http"))
|
|
135
|
+
return "http";
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Classify server architecture type based on detected characteristics.
|
|
140
|
+
*/
|
|
141
|
+
function classifyServerType(transports, requiresNetwork, _localOnly, // Reserved for future local-only detection enhancement
|
|
142
|
+
externalServices) {
|
|
143
|
+
// Remote: HTTP/SSE transport without stdio, or many external services
|
|
144
|
+
if ((transports.includes("http") || transports.includes("sse")) &&
|
|
145
|
+
!transports.includes("stdio")) {
|
|
146
|
+
return "remote";
|
|
147
|
+
}
|
|
148
|
+
// Remote: Many external service dependencies
|
|
149
|
+
if (externalServices.length >= 3) {
|
|
150
|
+
return "remote";
|
|
151
|
+
}
|
|
152
|
+
// Hybrid: Both local (stdio) and remote capabilities
|
|
153
|
+
if (transports.includes("stdio") &&
|
|
154
|
+
(transports.includes("http") || transports.includes("sse"))) {
|
|
155
|
+
return "hybrid";
|
|
156
|
+
}
|
|
157
|
+
// Hybrid: Local transport but requires network
|
|
158
|
+
if (transports.includes("stdio") && requiresNetwork) {
|
|
159
|
+
return "hybrid";
|
|
160
|
+
}
|
|
161
|
+
// Hybrid: Has some external services
|
|
162
|
+
if (externalServices.length > 0) {
|
|
163
|
+
return "hybrid";
|
|
164
|
+
}
|
|
165
|
+
// Local: stdio-only with no network requirements
|
|
166
|
+
return "local";
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Calculate confidence level based on evidence strength.
|
|
170
|
+
*/
|
|
171
|
+
function calculateConfidence(databaseResults, transports, _evidence, // Reserved for future evidence-based scoring
|
|
172
|
+
context) {
|
|
173
|
+
let score = 0;
|
|
174
|
+
// Database detection confidence
|
|
175
|
+
const highConfidenceDbs = databaseResults.filter((r) => r.confidence === "high");
|
|
176
|
+
if (highConfidenceDbs.length > 0)
|
|
177
|
+
score += 30;
|
|
178
|
+
else if (databaseResults.length > 0)
|
|
179
|
+
score += 15;
|
|
180
|
+
// Transport detection
|
|
181
|
+
if (context.transportType)
|
|
182
|
+
score += 30; // Known from connection
|
|
183
|
+
else if (transports.length > 0)
|
|
184
|
+
score += 20; // Detected from patterns
|
|
185
|
+
// Source code analysis
|
|
186
|
+
if (context.sourceCodeFiles && context.sourceCodeFiles.size > 0)
|
|
187
|
+
score += 20;
|
|
188
|
+
// Package.json/requirements.txt
|
|
189
|
+
if (context.packageJson || context.requirementsTxt)
|
|
190
|
+
score += 15;
|
|
191
|
+
// Tool descriptions
|
|
192
|
+
const toolsWithDescriptions = context.tools.filter((t) => t.description && t.description.length > 20);
|
|
193
|
+
if (toolsWithDescriptions.length >= 3)
|
|
194
|
+
score += 15;
|
|
195
|
+
else if (toolsWithDescriptions.length > 0)
|
|
196
|
+
score += 10;
|
|
197
|
+
// Convert score to confidence level
|
|
198
|
+
if (score >= 60)
|
|
199
|
+
return "high";
|
|
200
|
+
if (score >= 30)
|
|
201
|
+
return "medium";
|
|
202
|
+
return "low";
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Quick check if tools suggest database operations.
|
|
206
|
+
*
|
|
207
|
+
* @param tools - Tools to analyze
|
|
208
|
+
* @returns True if tools suggest database operations
|
|
209
|
+
*/
|
|
210
|
+
export function hasDatabaseToolPatterns(tools) {
|
|
211
|
+
// Pattern matches database operation keywords at word boundaries or with underscores
|
|
212
|
+
// Uses (?:^|[\s_-]) for start boundary and (?:$|[\s_-]) for end boundary
|
|
213
|
+
// to handle snake_case naming like "select_records"
|
|
214
|
+
const dbPatterns = /(?:^|[\s_-])(query|select|insert|update|delete|find|aggregate|create_table|drop_table|migrate|seed|backup)(?:$|[\s_-])/i;
|
|
215
|
+
for (const tool of tools) {
|
|
216
|
+
if (dbPatterns.test(tool.name))
|
|
217
|
+
return true;
|
|
218
|
+
if (tool.description && dbPatterns.test(tool.description))
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Extract database types from package.json dependencies.
|
|
225
|
+
*
|
|
226
|
+
* @param dependencies - Package.json dependencies object
|
|
227
|
+
* @returns Array of detected database types
|
|
228
|
+
*/
|
|
229
|
+
export function extractDatabasesFromDependencies(dependencies) {
|
|
230
|
+
const results = [];
|
|
231
|
+
const depNames = Object.keys(dependencies).join(" ");
|
|
232
|
+
const detected = detectDatabasesFromContent(depNames);
|
|
233
|
+
for (const d of detected) {
|
|
234
|
+
if (!results.includes(d.backend)) {
|
|
235
|
+
results.push(d.backend);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return results;
|
|
239
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Behavior Inference
|
|
3
|
+
* Infers expected tool behavior from name patterns and descriptions
|
|
4
|
+
*
|
|
5
|
+
* Extracted from ToolAnnotationAssessor.ts for maintainability.
|
|
6
|
+
* Handles persistence model detection and behavior classification.
|
|
7
|
+
*
|
|
8
|
+
* Enhanced in Issue #57 with multi-signal inference from descriptions and schemas.
|
|
9
|
+
*/
|
|
10
|
+
import type { InferenceConfidence } from "../../../../lib/assessmentTypes.js";
|
|
11
|
+
import type { EnhancedBehaviorInferenceResult } from "../../../../lib/assessment/extendedTypes.js";
|
|
12
|
+
import { type JSONSchema } from "./SchemaAnalyzer.js";
|
|
13
|
+
import { type CompiledPatterns, type ServerPersistenceContext } from "../../config/annotationPatterns.js";
|
|
14
|
+
/**
|
|
15
|
+
* Result of behavior inference
|
|
16
|
+
*/
|
|
17
|
+
export interface BehaviorInferenceResult {
|
|
18
|
+
expectedReadOnly: boolean;
|
|
19
|
+
expectedDestructive: boolean;
|
|
20
|
+
reason: string;
|
|
21
|
+
confidence: InferenceConfidence;
|
|
22
|
+
isAmbiguous: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Infer expected behavior from tool name and description
|
|
26
|
+
* Returns confidence level and ambiguity flag for better handling
|
|
27
|
+
*/
|
|
28
|
+
export declare function inferBehavior(toolName: string, description?: string, compiledPatterns?: CompiledPatterns, persistenceContext?: ServerPersistenceContext): BehaviorInferenceResult;
|
|
29
|
+
/**
|
|
30
|
+
* Enhanced behavior inference using multiple signals.
|
|
31
|
+
*
|
|
32
|
+
* Analyzes tool name patterns, descriptions, and schemas to provide
|
|
33
|
+
* a more accurate behavior inference with aggregated confidence.
|
|
34
|
+
*
|
|
35
|
+
* Part of Issue #57: Architecture detection and behavior inference modules
|
|
36
|
+
*
|
|
37
|
+
* @param toolName - Name of the tool
|
|
38
|
+
* @param description - Tool description (optional)
|
|
39
|
+
* @param inputSchema - Input parameter schema (optional)
|
|
40
|
+
* @param outputSchema - Output/return schema (optional)
|
|
41
|
+
* @param compiledPatterns - Compiled regex patterns for name matching
|
|
42
|
+
* @param persistenceContext - Server-level persistence context
|
|
43
|
+
* @returns EnhancedBehaviorInferenceResult with multi-signal analysis
|
|
44
|
+
*/
|
|
45
|
+
export declare function inferBehaviorEnhanced(toolName: string, description?: string, inputSchema?: JSONSchema, outputSchema?: JSONSchema, compiledPatterns?: CompiledPatterns, persistenceContext?: ServerPersistenceContext): EnhancedBehaviorInferenceResult;
|
|
46
|
+
//# sourceMappingURL=BehaviorInference.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BehaviorInference.d.ts","sourceRoot":"","sources":["../../../../../src/services/assessment/modules/annotations/BehaviorInference.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,EAEV,+BAA+B,EAChC,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAGL,KAAK,UAAU,EAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAI9B,MAAM,iCAAiC,CAAC;AAGzC;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,gBAAgB,EAAE,OAAO,CAAC;IAC1B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,mBAAmB,CAAC;IAChC,WAAW,EAAE,OAAO,CAAC;CACtB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAChB,WAAW,CAAC,EAAE,MAAM,EACpB,gBAAgB,CAAC,EAAE,gBAAgB,EACnC,kBAAkB,CAAC,EAAE,wBAAwB,GAC5C,uBAAuB,CA8KzB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,EAChB,WAAW,CAAC,EAAE,MAAM,EACpB,WAAW,CAAC,EAAE,UAAU,EACxB,YAAY,CAAC,EAAE,UAAU,EACzB,gBAAgB,CAAC,EAAE,gBAAgB,EACnC,kBAAkB,CAAC,EAAE,wBAAwB,GAC5C,+BAA+B,CA4DjC"}
|