@dawans/promptshield
Version:
Secure your LLM stack with enterprise-grade RulePacks for AI safety scanning
77 lines (76 loc) • 1.86 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ScanContext = void 0;
/**
* Represents the context for a scan operation
*/
class ScanContext {
constructor(config, rulePack, startTime = new Date()) {
this.config = config;
this.rulePack = rulePack;
this.startTime = startTime;
}
/**
* Gets the fields that should be scanned
*/
getFieldsToScan() {
return this.config.fields && this.config.fields.length > 0
? this.config.fields
: ['prompt', 'response'];
}
/**
* Checks if entire object should be scanned
*/
shouldScanEntireObject() {
return this.config.scanEntireObject || false;
}
/**
* Gets the maximum depth for object traversal
*/
getMaxDepth() {
return this.config.maxDepth || 4;
}
/**
* Gets the maximum number of objects to process
*/
getMaxObjects() {
return this.config.maxObjects;
}
/**
* Checks if NDJSON mode is enabled
*/
isNdjsonMode() {
return this.config.ndjsonMode || false;
}
/**
* Gets the streaming threshold
*/
getStreamingThreshold() {
return this.config.streamingThreshold || 1000;
}
/**
* Checks if parallel processing is enabled
*/
isParallelProcessing() {
return this.config.parallel !== false;
}
/**
* Gets the batch size for parallel processing
*/
getBatchSize() {
return this.config.batchSize || 10;
}
/**
* Gets the processing timeout
*/
getTimeout() {
return this.config.timeout || 300;
}
/**
* Gets elapsed time since scan started
*/
getElapsedTime() {
return Date.now() - this.startTime.getTime();
}
}
exports.ScanContext = ScanContext;