@ai-pip/core 0.1.7 → 0.2.0
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/CHANGELOG.md +175 -1
- package/README.md +751 -22
- package/dist/AAL/index.d.ts +28 -0
- package/dist/AAL/index.d.ts.map +1 -0
- package/dist/AAL/index.js +28 -0
- package/dist/AAL/index.js.map +1 -0
- package/dist/AAL/lineage/buildAALLineage.d.ts +22 -0
- package/dist/AAL/lineage/buildAALLineage.d.ts.map +1 -0
- package/dist/AAL/lineage/buildAALLineage.js +26 -0
- package/dist/AAL/lineage/buildAALLineage.js.map +1 -0
- package/dist/AAL/lineage/index.d.ts +5 -0
- package/dist/AAL/lineage/index.d.ts.map +1 -0
- package/dist/AAL/lineage/index.js +5 -0
- package/dist/AAL/lineage/index.js.map +1 -0
- package/dist/AAL/process/buildDecisionReason.d.ts +36 -0
- package/dist/AAL/process/buildDecisionReason.d.ts.map +1 -0
- package/dist/AAL/process/buildDecisionReason.js +48 -0
- package/dist/AAL/process/buildDecisionReason.js.map +1 -0
- package/dist/AAL/process/buildRemovalPlan.d.ts +32 -0
- package/dist/AAL/process/buildRemovalPlan.d.ts.map +1 -0
- package/dist/AAL/process/buildRemovalPlan.js +50 -0
- package/dist/AAL/process/buildRemovalPlan.js.map +1 -0
- package/dist/AAL/process/index.d.ts +9 -0
- package/dist/AAL/process/index.d.ts.map +1 -0
- package/dist/AAL/process/index.js +7 -0
- package/dist/AAL/process/index.js.map +1 -0
- package/dist/AAL/process/resolveAgentAction.d.ts +31 -0
- package/dist/AAL/process/resolveAgentAction.d.ts.map +1 -0
- package/dist/AAL/process/resolveAgentAction.js +43 -0
- package/dist/AAL/process/resolveAgentAction.js.map +1 -0
- package/dist/AAL/types.d.ts +104 -0
- package/dist/AAL/types.d.ts.map +1 -0
- package/dist/AAL/types.js +2 -0
- package/dist/AAL/types.js.map +1 -0
- package/dist/{isl → AAL}/value-objects/AnomalyScore.d.ts +2 -1
- package/dist/AAL/value-objects/AnomalyScore.d.ts.map +1 -0
- package/dist/{isl → AAL}/value-objects/AnomalyScore.js.map +1 -1
- package/dist/{isl → AAL}/value-objects/PolicyRule.d.ts.map +1 -1
- package/dist/{isl → AAL}/value-objects/PolicyRule.js.map +1 -1
- package/dist/AAL/value-objects/index.d.ts +5 -0
- package/dist/AAL/value-objects/index.d.ts.map +1 -0
- package/dist/AAL/value-objects/index.js +3 -0
- package/dist/AAL/value-objects/index.js.map +1 -0
- package/dist/csl/classify.d.ts +2 -2
- package/dist/csl/classify.js +5 -5
- package/dist/csl/classify.js.map +1 -1
- package/dist/csl/value-objects/Origin-map.js +5 -5
- package/dist/csl/value-objects/Origin-map.js.map +1 -1
- package/dist/index.d.ts +10 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -5
- package/dist/index.js.map +1 -1
- package/dist/isl/index.d.ts +15 -6
- package/dist/isl/index.d.ts.map +1 -1
- package/dist/isl/index.js +15 -5
- package/dist/isl/index.js.map +1 -1
- package/dist/isl/lineage/buildISLLineage.d.ts +22 -0
- package/dist/isl/lineage/buildISLLineage.d.ts.map +1 -0
- package/dist/isl/lineage/buildISLLineage.js +26 -0
- package/dist/isl/lineage/buildISLLineage.js.map +1 -0
- package/dist/isl/lineage/index.d.ts +5 -0
- package/dist/isl/lineage/index.d.ts.map +1 -0
- package/dist/isl/lineage/index.js +5 -0
- package/dist/isl/lineage/index.js.map +1 -0
- package/dist/isl/process/buildISLResult.d.ts +24 -0
- package/dist/isl/process/buildISLResult.d.ts.map +1 -0
- package/dist/isl/process/buildISLResult.js +38 -0
- package/dist/isl/process/buildISLResult.js.map +1 -0
- package/dist/isl/process/emitSignal.d.ts +23 -0
- package/dist/isl/process/emitSignal.d.ts.map +1 -0
- package/dist/isl/process/emitSignal.js +39 -0
- package/dist/isl/process/emitSignal.js.map +1 -0
- package/dist/isl/process/index.d.ts +6 -0
- package/dist/isl/process/index.d.ts.map +1 -0
- package/dist/isl/process/index.js +6 -0
- package/dist/isl/process/index.js.map +1 -0
- package/dist/isl/sanitize.d.ts +5 -5
- package/dist/isl/sanitize.d.ts.map +1 -1
- package/dist/isl/sanitize.js +24 -38
- package/dist/isl/sanitize.js.map +1 -1
- package/dist/isl/signals.d.ts +98 -0
- package/dist/isl/signals.d.ts.map +1 -0
- package/dist/isl/signals.js +92 -0
- package/dist/isl/signals.js.map +1 -0
- package/dist/isl/types.d.ts +4 -48
- package/dist/isl/types.d.ts.map +1 -1
- package/dist/isl/types.js +1 -1
- package/dist/isl/value-objects/PiDetection.d.ts +2 -1
- package/dist/isl/value-objects/PiDetection.d.ts.map +1 -1
- package/dist/isl/value-objects/PiDetectionResult.d.ts +2 -3
- package/dist/isl/value-objects/PiDetectionResult.d.ts.map +1 -1
- package/dist/isl/value-objects/PiDetectionResult.js +1 -27
- package/dist/isl/value-objects/PiDetectionResult.js.map +1 -1
- package/dist/isl/value-objects/RiskScore.d.ts +70 -0
- package/dist/isl/value-objects/RiskScore.d.ts.map +1 -0
- package/dist/isl/value-objects/RiskScore.js +85 -0
- package/dist/isl/value-objects/RiskScore.js.map +1 -0
- package/dist/isl/value-objects/index.d.ts +2 -2
- package/dist/isl/value-objects/index.d.ts.map +1 -1
- package/dist/isl/value-objects/index.js +1 -3
- package/dist/isl/value-objects/index.js.map +1 -1
- package/dist/shared/audit.d.ts +150 -0
- package/dist/shared/audit.d.ts.map +1 -0
- package/dist/shared/audit.js +173 -0
- package/dist/shared/audit.js.map +1 -0
- package/dist/shared/index.d.ts +5 -3
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index.js +5 -6
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/types.d.ts +36 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/shared/types.js +2 -0
- package/dist/shared/types.js.map +1 -0
- package/package.json +7 -2
- package/dist/isl/value-objects/AnomalyScore.d.ts.map +0 -1
- /package/dist/{isl → AAL}/value-objects/AnomalyScore.js +0 -0
- /package/dist/{isl → AAL}/value-objects/PolicyRule.d.ts +0 -0
- /package/dist/{isl → AAL}/value-objects/PolicyRule.js +0 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RiskScore - Value Object
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Represents a normalized risk value produced by the core semantic layers.
|
|
6
|
+
*
|
|
7
|
+
* - Value range is **0.0 to 1.0**
|
|
8
|
+
* - `0` = no risk detected
|
|
9
|
+
* - `1` = maximum risk confidence
|
|
10
|
+
*
|
|
11
|
+
* Although this type aliases `number`, it is intentionally defined
|
|
12
|
+
* as a value object to preserve **semantic meaning**, enforce conceptual clarity,
|
|
13
|
+
* and stabilize public contracts across layers and SDKs.
|
|
14
|
+
*
|
|
15
|
+
* This type MUST NOT be interpreted as a decision signal.
|
|
16
|
+
* Decisions based on RiskScore belong to higher layers (AAL / SDK).
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Minimum valid risk score value
|
|
20
|
+
*/
|
|
21
|
+
export const MIN_RISK_SCORE = 0;
|
|
22
|
+
/**
|
|
23
|
+
* Maximum valid risk score value
|
|
24
|
+
*/
|
|
25
|
+
export const MAX_RISK_SCORE = 1;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a valid RiskScore value
|
|
28
|
+
*
|
|
29
|
+
* @param value - Numeric value to validate and normalize
|
|
30
|
+
* @returns Validated RiskScore
|
|
31
|
+
* @throws {Error} If value is outside valid range [0.0, 1.0]
|
|
32
|
+
*/
|
|
33
|
+
export function createRiskScore(value) {
|
|
34
|
+
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
|
35
|
+
throw new TypeError('RiskScore must be a finite number');
|
|
36
|
+
}
|
|
37
|
+
if (value < MIN_RISK_SCORE || value > MAX_RISK_SCORE) {
|
|
38
|
+
throw new Error(`RiskScore must be between ${MIN_RISK_SCORE} and ${MAX_RISK_SCORE}, got ${value}`);
|
|
39
|
+
}
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Normalizes a risk score to the valid range [0.0, 1.0]
|
|
44
|
+
*
|
|
45
|
+
* @param value - Numeric value to normalize
|
|
46
|
+
* @returns Normalized RiskScore clamped to [0.0, 1.0]
|
|
47
|
+
*/
|
|
48
|
+
export function normalizeRiskScore(value) {
|
|
49
|
+
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
|
50
|
+
return MIN_RISK_SCORE;
|
|
51
|
+
}
|
|
52
|
+
return Math.max(MIN_RISK_SCORE, Math.min(MAX_RISK_SCORE, value));
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Checks if a risk score is considered high
|
|
56
|
+
*
|
|
57
|
+
* @param score - RiskScore to evaluate
|
|
58
|
+
* @param threshold - Threshold for high risk (default: 0.7)
|
|
59
|
+
* @returns true if score >= threshold
|
|
60
|
+
*/
|
|
61
|
+
export function isHighRiskScore(score, threshold = 0.7) {
|
|
62
|
+
return score >= threshold;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Checks if a risk score is considered medium
|
|
66
|
+
*
|
|
67
|
+
* @param score - RiskScore to evaluate
|
|
68
|
+
* @param lowThreshold - Lower threshold (default: 0.3)
|
|
69
|
+
* @param highThreshold - Upper threshold (default: 0.7)
|
|
70
|
+
* @returns true if score is in medium range
|
|
71
|
+
*/
|
|
72
|
+
export function isMediumRiskScore(score, lowThreshold = 0.3, highThreshold = 0.7) {
|
|
73
|
+
return score >= lowThreshold && score < highThreshold;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Checks if a risk score is considered low
|
|
77
|
+
*
|
|
78
|
+
* @param score - RiskScore to evaluate
|
|
79
|
+
* @param threshold - Threshold for low risk (default: 0.3)
|
|
80
|
+
* @returns true if score < threshold
|
|
81
|
+
*/
|
|
82
|
+
export function isLowRiskScore(score, threshold = 0.3) {
|
|
83
|
+
return score < threshold;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=RiskScore.js.map
|
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YAAY,IAAI,KAAK,GAAG,aAAa,CAAA;AACvD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,KAAgB,EAAE,YAAoB,GAAG;IACtE,OAAO,KAAK,GAAG,SAAS,CAAA;AAC1B,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export type { PiDetection } from './PiDetection.js';
|
|
2
2
|
export type { PiDetectionResult } from './PiDetectionResult.js';
|
|
3
|
-
export type { AnomalyScore } from './AnomalyScore.js';
|
|
4
3
|
export type { Pattern } from './Pattern.js';
|
|
4
|
+
export type { RiskScore } from './RiskScore.js';
|
|
5
5
|
export { createPiDetection, getDetectionLength, isHighConfidence, isMediumConfidence, isLowConfidence } from './PiDetection.js';
|
|
6
6
|
export { createPiDetectionResult, hasDetections, getDetectionCount, getDetectionsByType, getHighestConfidenceDetection } from './PiDetectionResult.js';
|
|
7
|
-
export { createAnomalyScore, isHighRisk, isWarnRisk, isLowRisk } from './AnomalyScore.js';
|
|
8
7
|
export { createPattern, matchesPattern, findMatch, MAX_CONTENT_LENGTH, MAX_PATTERN_LENGTH, MAX_MATCHES } from './Pattern.js';
|
|
8
|
+
export { createRiskScore, normalizeRiskScore, isHighRiskScore, isMediumRiskScore, isLowRiskScore, MIN_RISK_SCORE, MAX_RISK_SCORE } from './RiskScore.js';
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/isl/value-objects/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,YAAY,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/isl/value-objects/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,YAAY,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE/C,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EAChB,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EACL,uBAAuB,EACvB,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,6BAA6B,EAC9B,MAAM,wBAAwB,CAAA;AAI/B,OAAO,EACL,aAAa,EACb,cAAc,EACd,SAAS,EACT,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACZ,MAAM,cAAc,CAAA;AAErB,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,cAAc,EACf,MAAM,gBAAgB,CAAA"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
// Funciones de creación
|
|
2
2
|
export { createPiDetection, getDetectionLength, isHighConfidence, isMediumConfidence, isLowConfidence } from './PiDetection.js';
|
|
3
3
|
export { createPiDetectionResult, hasDetections, getDetectionCount, getDetectionsByType, getHighestConfidenceDetection } from './PiDetectionResult.js';
|
|
4
|
-
export { createAnomalyScore, isHighRisk, isWarnRisk, isLowRisk } from './AnomalyScore.js';
|
|
5
4
|
export { createPattern, matchesPattern, findMatch, MAX_CONTENT_LENGTH, MAX_PATTERN_LENGTH, MAX_MATCHES } from './Pattern.js';
|
|
6
|
-
|
|
7
|
-
// Se mantiene el tipo para compatibilidad pero las funciones de decisión no son core
|
|
5
|
+
export { createRiskScore, normalizeRiskScore, isHighRiskScore, isMediumRiskScore, isLowRiskScore, MIN_RISK_SCORE, MAX_RISK_SCORE } from './RiskScore.js';
|
|
8
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/isl/value-objects/index.ts"],"names":[],"mappings":"AAKA,wBAAwB;AACxB,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EAChB,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EACL,uBAAuB,EACvB,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,6BAA6B,EAC9B,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/isl/value-objects/index.ts"],"names":[],"mappings":"AAKA,wBAAwB;AACxB,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EAChB,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EACL,uBAAuB,EACvB,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,6BAA6B,EAC9B,MAAM,wBAAwB,CAAA;AAI/B,OAAO,EACL,aAAa,EACb,cAAc,EACd,SAAS,EACT,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACZ,MAAM,cAAc,CAAA;AAErB,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,cAAc,EACf,MAAM,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI-PIP Audit utilities - Pure functions for ordered, human-readable audit output
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* These functions format layer results and signals into consistent, pretty-printed
|
|
6
|
+
* strings or structured data for auditing, logging, and compliance. They are
|
|
7
|
+
* layer-agnostic (accept minimal shapes) and do not depend on layer internals.
|
|
8
|
+
*/
|
|
9
|
+
/** Lineage entry shape used across layers */
|
|
10
|
+
export interface LineageEntryLike {
|
|
11
|
+
readonly step: string;
|
|
12
|
+
readonly timestamp: number;
|
|
13
|
+
}
|
|
14
|
+
/** CSL result shape for audit formatting */
|
|
15
|
+
export interface CSLResultLike {
|
|
16
|
+
readonly segments: ReadonlyArray<{
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly content: string;
|
|
19
|
+
readonly trust: {
|
|
20
|
+
readonly value: string;
|
|
21
|
+
};
|
|
22
|
+
readonly lineage?: readonly LineageEntryLike[];
|
|
23
|
+
}>;
|
|
24
|
+
readonly lineage: readonly LineageEntryLike[];
|
|
25
|
+
readonly processingTimeMs?: number;
|
|
26
|
+
}
|
|
27
|
+
/** ISL result shape for audit formatting */
|
|
28
|
+
export interface ISLResultLike {
|
|
29
|
+
readonly segments: ReadonlyArray<{
|
|
30
|
+
readonly id: string;
|
|
31
|
+
readonly originalContent: string;
|
|
32
|
+
readonly sanitizedContent: string;
|
|
33
|
+
readonly trust: {
|
|
34
|
+
readonly value: string;
|
|
35
|
+
};
|
|
36
|
+
readonly sanitizationLevel: string;
|
|
37
|
+
readonly lineage?: readonly LineageEntryLike[];
|
|
38
|
+
}>;
|
|
39
|
+
readonly lineage: readonly LineageEntryLike[];
|
|
40
|
+
readonly metadata: {
|
|
41
|
+
readonly totalSegments: number;
|
|
42
|
+
readonly sanitizedSegments: number;
|
|
43
|
+
readonly processingTimeMs?: number;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/** ISL signal shape for audit formatting */
|
|
47
|
+
export interface ISLSignalLike {
|
|
48
|
+
readonly riskScore: number;
|
|
49
|
+
readonly hasThreats: boolean;
|
|
50
|
+
readonly timestamp: number;
|
|
51
|
+
readonly piDetection: {
|
|
52
|
+
readonly detected: boolean;
|
|
53
|
+
readonly score: number;
|
|
54
|
+
readonly detections: ReadonlyArray<unknown>;
|
|
55
|
+
readonly patterns?: readonly string[];
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** AAL decision reason shape for audit formatting */
|
|
59
|
+
export interface DecisionReasonLike {
|
|
60
|
+
readonly action: string;
|
|
61
|
+
readonly reason: string;
|
|
62
|
+
readonly riskScore: number;
|
|
63
|
+
readonly threshold: number;
|
|
64
|
+
readonly hasThreats: boolean;
|
|
65
|
+
readonly detectionCount: number;
|
|
66
|
+
}
|
|
67
|
+
/** AAL removal plan shape for audit formatting */
|
|
68
|
+
export interface RemovalPlanLike {
|
|
69
|
+
readonly shouldRemove: boolean;
|
|
70
|
+
readonly removalEnabled: boolean;
|
|
71
|
+
readonly instructionsToRemove: ReadonlyArray<{
|
|
72
|
+
readonly type?: string;
|
|
73
|
+
readonly pattern?: string;
|
|
74
|
+
readonly description?: string;
|
|
75
|
+
}>;
|
|
76
|
+
}
|
|
77
|
+
/** CPE result shape for audit formatting */
|
|
78
|
+
export interface CPEResultLike {
|
|
79
|
+
readonly envelope: {
|
|
80
|
+
readonly metadata: {
|
|
81
|
+
readonly timestamp: number;
|
|
82
|
+
readonly nonce: string;
|
|
83
|
+
readonly protocolVersion?: string;
|
|
84
|
+
};
|
|
85
|
+
readonly signature: {
|
|
86
|
+
readonly algorithm: string;
|
|
87
|
+
readonly value?: string;
|
|
88
|
+
};
|
|
89
|
+
readonly lineage: readonly LineageEntryLike[];
|
|
90
|
+
};
|
|
91
|
+
readonly processingTimeMs?: number;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Formats lineage entries for pretty audit output
|
|
95
|
+
*
|
|
96
|
+
* @param lineage - Array of lineage entries (any layer)
|
|
97
|
+
* @returns Formatted string
|
|
98
|
+
*/
|
|
99
|
+
export declare function formatLineageForAudit(lineage: readonly LineageEntryLike[]): string;
|
|
100
|
+
/**
|
|
101
|
+
* Formats CSL result for audit - ordered and human-readable
|
|
102
|
+
*
|
|
103
|
+
* @param result - CSL result (or compatible shape)
|
|
104
|
+
* @returns Formatted string for auditing
|
|
105
|
+
*/
|
|
106
|
+
export declare function formatCSLForAudit(result: CSLResultLike): string;
|
|
107
|
+
/**
|
|
108
|
+
* Formats ISL result for audit - ordered and human-readable
|
|
109
|
+
*
|
|
110
|
+
* @param result - ISL result (or compatible shape)
|
|
111
|
+
* @returns Formatted string for auditing
|
|
112
|
+
*/
|
|
113
|
+
export declare function formatISLForAudit(result: ISLResultLike): string;
|
|
114
|
+
/**
|
|
115
|
+
* Formats ISL signal for audit - ordered and human-readable
|
|
116
|
+
*
|
|
117
|
+
* @param signal - ISL signal (or compatible shape)
|
|
118
|
+
* @returns Formatted string for auditing
|
|
119
|
+
*/
|
|
120
|
+
export declare function formatISLSignalForAudit(signal: ISLSignalLike): string;
|
|
121
|
+
/**
|
|
122
|
+
* Formats AAL decision reason and optional removal plan for audit
|
|
123
|
+
*
|
|
124
|
+
* @param reason - Decision reason (or compatible shape)
|
|
125
|
+
* @param removalPlan - Optional removal plan (or compatible shape)
|
|
126
|
+
* @returns Formatted string for auditing
|
|
127
|
+
*/
|
|
128
|
+
export declare function formatAALForAudit(reason: DecisionReasonLike, removalPlan?: RemovalPlanLike | null): string;
|
|
129
|
+
/**
|
|
130
|
+
* Formats CPE result for audit - ordered and human-readable
|
|
131
|
+
*
|
|
132
|
+
* @param result - CPE result (or compatible shape)
|
|
133
|
+
* @returns Formatted string for auditing
|
|
134
|
+
*/
|
|
135
|
+
export declare function formatCPEForAudit(result: CPEResultLike): string;
|
|
136
|
+
/**
|
|
137
|
+
* Builds a full pipeline audit report (CSL → ISL → CPE) from layer results.
|
|
138
|
+
* Accepts minimal shapes for flexibility.
|
|
139
|
+
*
|
|
140
|
+
* @param csl - CSL result (or compatible shape)
|
|
141
|
+
* @param isl - ISL result (or compatible shape)
|
|
142
|
+
* @param cpe - CPE result (or compatible shape)
|
|
143
|
+
* @param options - Optional title and separator
|
|
144
|
+
* @returns Single formatted string for full audit
|
|
145
|
+
*/
|
|
146
|
+
export declare function formatPipelineAudit(csl: CSLResultLike, isl: ISLResultLike, cpe: CPEResultLike, options?: {
|
|
147
|
+
title?: string;
|
|
148
|
+
sectionSeparator?: string;
|
|
149
|
+
}): string;
|
|
150
|
+
//# sourceMappingURL=audit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAAE,GACtD,MAAM,CAaR"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI-PIP Audit utilities - Pure functions for ordered, human-readable audit output
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* These functions format layer results and signals into consistent, pretty-printed
|
|
6
|
+
* strings or structured data for auditing, logging, and compliance. They are
|
|
7
|
+
* layer-agnostic (accept minimal shapes) and do not depend on layer internals.
|
|
8
|
+
*/
|
|
9
|
+
const SEP = ' ';
|
|
10
|
+
const BORDER = '---';
|
|
11
|
+
/**
|
|
12
|
+
* Formats lineage entries for pretty audit output
|
|
13
|
+
*
|
|
14
|
+
* @param lineage - Array of lineage entries (any layer)
|
|
15
|
+
* @returns Formatted string
|
|
16
|
+
*/
|
|
17
|
+
export function formatLineageForAudit(lineage) {
|
|
18
|
+
if (lineage.length === 0)
|
|
19
|
+
return 'Lineage: (none)';
|
|
20
|
+
const lines = lineage.map((e, i) => `${SEP}${i + 1}. [${e.step}] ${new Date(e.timestamp).toISOString()}`);
|
|
21
|
+
return ['Lineage:', ...lines].join('\n');
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Formats CSL result for audit - ordered and human-readable
|
|
25
|
+
*
|
|
26
|
+
* @param result - CSL result (or compatible shape)
|
|
27
|
+
* @returns Formatted string for auditing
|
|
28
|
+
*/
|
|
29
|
+
export function formatCSLForAudit(result) {
|
|
30
|
+
const processingTimeLine = typeof result.processingTimeMs === 'number'
|
|
31
|
+
? [`Processing time: ${result.processingTimeMs}ms`]
|
|
32
|
+
: [];
|
|
33
|
+
const segmentLines = result.segments.map((seg, i) => `${SEP}Segment ${i + 1}: id=${seg.id} trust=${seg.trust.value} content_length=${seg.content.length}`);
|
|
34
|
+
const lines = [
|
|
35
|
+
'[CSL] Context Segmentation Layer',
|
|
36
|
+
BORDER,
|
|
37
|
+
`Segments: ${result.segments.length}`,
|
|
38
|
+
...processingTimeLine,
|
|
39
|
+
...segmentLines,
|
|
40
|
+
'',
|
|
41
|
+
formatLineageForAudit(result.lineage)
|
|
42
|
+
];
|
|
43
|
+
return lines.join('\n');
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Formats ISL result for audit - ordered and human-readable
|
|
47
|
+
*
|
|
48
|
+
* @param result - ISL result (or compatible shape)
|
|
49
|
+
* @returns Formatted string for auditing
|
|
50
|
+
*/
|
|
51
|
+
export function formatISLForAudit(result) {
|
|
52
|
+
const meta = result.metadata;
|
|
53
|
+
const processingTimeLine = typeof meta.processingTimeMs === 'number' ? [`Processing time: ${meta.processingTimeMs}ms`] : [];
|
|
54
|
+
const segmentLines = result.segments.flatMap((seg, i) => [
|
|
55
|
+
`${SEP}Segment ${i + 1}: id=${seg.id} trust=${seg.trust.value} level=${seg.sanitizationLevel}`,
|
|
56
|
+
`${SEP} original_length=${seg.originalContent.length} sanitized_length=${seg.sanitizedContent.length}`
|
|
57
|
+
]);
|
|
58
|
+
const lines = [
|
|
59
|
+
'[ISL] Instruction Sanitization Layer',
|
|
60
|
+
BORDER,
|
|
61
|
+
`Segments: ${meta.totalSegments} (sanitized: ${meta.sanitizedSegments})`,
|
|
62
|
+
...processingTimeLine,
|
|
63
|
+
...segmentLines,
|
|
64
|
+
'',
|
|
65
|
+
formatLineageForAudit(result.lineage)
|
|
66
|
+
];
|
|
67
|
+
return lines.join('\n');
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Formats ISL signal for audit - ordered and human-readable
|
|
71
|
+
*
|
|
72
|
+
* @param signal - ISL signal (or compatible shape)
|
|
73
|
+
* @returns Formatted string for auditing
|
|
74
|
+
*/
|
|
75
|
+
export function formatISLSignalForAudit(signal) {
|
|
76
|
+
const pd = signal.piDetection;
|
|
77
|
+
const patternLine = pd.patterns && pd.patterns.length > 0 ? [`${SEP}Patterns: ${pd.patterns.join(', ')}`] : [];
|
|
78
|
+
const lines = [
|
|
79
|
+
'[ISL Signal] External contract',
|
|
80
|
+
BORDER,
|
|
81
|
+
`Risk score: ${signal.riskScore.toFixed(3)}`,
|
|
82
|
+
`Has threats: ${signal.hasThreats}`,
|
|
83
|
+
`Timestamp: ${new Date(signal.timestamp).toISOString()}`,
|
|
84
|
+
`Detections: ${pd.detections.length} (score: ${pd.score.toFixed(3)}, detected: ${pd.detected})`,
|
|
85
|
+
...patternLine
|
|
86
|
+
];
|
|
87
|
+
return lines.join('\n');
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Formats AAL decision reason and optional removal plan for audit
|
|
91
|
+
*
|
|
92
|
+
* @param reason - Decision reason (or compatible shape)
|
|
93
|
+
* @param removalPlan - Optional removal plan (or compatible shape)
|
|
94
|
+
* @returns Formatted string for auditing
|
|
95
|
+
*/
|
|
96
|
+
export function formatAALForAudit(reason, removalPlan) {
|
|
97
|
+
const plan = removalPlan ?? undefined;
|
|
98
|
+
const removalBlock = plan === undefined
|
|
99
|
+
? []
|
|
100
|
+
: [
|
|
101
|
+
'',
|
|
102
|
+
`Removal enabled: ${plan.removalEnabled}`,
|
|
103
|
+
`Should remove: ${plan.shouldRemove}`,
|
|
104
|
+
...(plan.instructionsToRemove.length > 0
|
|
105
|
+
? [
|
|
106
|
+
`Instructions to remove: ${plan.instructionsToRemove.length}`,
|
|
107
|
+
...plan.instructionsToRemove.map((inst, i) => `${SEP}${i + 1}. ${inst.type ?? 'unknown'} - ${inst.description ?? inst.pattern ?? ''}`)
|
|
108
|
+
]
|
|
109
|
+
: [])
|
|
110
|
+
];
|
|
111
|
+
const lines = [
|
|
112
|
+
'[AAL] Agent Action Lock',
|
|
113
|
+
BORDER,
|
|
114
|
+
`Action: ${reason.action}`,
|
|
115
|
+
`Risk score: ${reason.riskScore.toFixed(3)} (threshold: ${reason.threshold.toFixed(3)})`,
|
|
116
|
+
`Reason: ${reason.reason}`,
|
|
117
|
+
`Threats: ${reason.hasThreats} (count: ${reason.detectionCount})`,
|
|
118
|
+
...removalBlock
|
|
119
|
+
];
|
|
120
|
+
return lines.join('\n');
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Formats CPE result for audit - ordered and human-readable
|
|
124
|
+
*
|
|
125
|
+
* @param result - CPE result (or compatible shape)
|
|
126
|
+
* @returns Formatted string for auditing
|
|
127
|
+
*/
|
|
128
|
+
export function formatCPEForAudit(result) {
|
|
129
|
+
const env = result.envelope;
|
|
130
|
+
const protocolVersionLine = typeof env.metadata.protocolVersion === 'string'
|
|
131
|
+
? [`Protocol version: ${env.metadata.protocolVersion}`]
|
|
132
|
+
: [];
|
|
133
|
+
const processingTimeLine = typeof result.processingTimeMs === 'number'
|
|
134
|
+
? [`Processing time: ${result.processingTimeMs}ms`]
|
|
135
|
+
: [];
|
|
136
|
+
const lines = [
|
|
137
|
+
'[CPE] Cryptographic Prompt Envelope',
|
|
138
|
+
BORDER,
|
|
139
|
+
`Nonce: ${env.metadata.nonce}`,
|
|
140
|
+
`Timestamp: ${new Date(env.metadata.timestamp).toISOString()}`,
|
|
141
|
+
...protocolVersionLine,
|
|
142
|
+
`Signature algorithm: ${env.signature.algorithm}`,
|
|
143
|
+
...processingTimeLine,
|
|
144
|
+
'',
|
|
145
|
+
formatLineageForAudit(env.lineage)
|
|
146
|
+
];
|
|
147
|
+
return lines.join('\n');
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Builds a full pipeline audit report (CSL → ISL → CPE) from layer results.
|
|
151
|
+
* Accepts minimal shapes for flexibility.
|
|
152
|
+
*
|
|
153
|
+
* @param csl - CSL result (or compatible shape)
|
|
154
|
+
* @param isl - ISL result (or compatible shape)
|
|
155
|
+
* @param cpe - CPE result (or compatible shape)
|
|
156
|
+
* @param options - Optional title and separator
|
|
157
|
+
* @returns Single formatted string for full audit
|
|
158
|
+
*/
|
|
159
|
+
export function formatPipelineAudit(csl, isl, cpe, options) {
|
|
160
|
+
const sep = options?.sectionSeparator ?? '\n\n';
|
|
161
|
+
const title = options?.title ?? 'AI-PIP Pipeline Audit';
|
|
162
|
+
const parts = [
|
|
163
|
+
title,
|
|
164
|
+
BORDER,
|
|
165
|
+
formatCSLForAudit(csl),
|
|
166
|
+
sep,
|
|
167
|
+
formatISLForAudit(isl),
|
|
168
|
+
sep,
|
|
169
|
+
formatCPEForAudit(cpe)
|
|
170
|
+
];
|
|
171
|
+
return parts.join('\n');
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=audit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../../src/shared/audit.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAyFH,MAAM,GAAG,GAAG,IAAI,CAAA;AAChB,MAAM,MAAM,GAAG,KAAK,CAAA;AAEpB;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAoC;IACxE,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,iBAAiB,CAAA;IAClD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;IACzG,OAAO,CAAC,UAAU,EAAE,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC1C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAqB;IACrD,MAAM,kBAAkB,GACtB,OAAO,MAAM,CAAC,gBAAgB,KAAK,QAAQ;QACzC,CAAC,CAAC,CAAC,oBAAoB,MAAM,CAAC,gBAAgB,IAAI,CAAC;QACnD,CAAC,CAAC,EAAE,CAAA;IACR,MAAM,YAAY,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CACtC,CAAC,GAAG,EAAE,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CAAA;IACR,MAAM,KAAK,GAAG;QACZ,qCAAqC;QACrC,MAAM;QACN,UAAU,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE;QAC9B,cAAc,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,EAAE;QAC9D,GAAG,mBAAmB;QACtB,wBAAwB,GAAG,CAAC,SAAS,CAAC,SAAS,EAAE;QACjD,GAAG,kBAAkB;QACrB,EAAE;QACF,qBAAqB,CAAC,GAAG,CAAC,OAAO,CAAC;KACnC,CAAA;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CACjC,GAAkB,EAClB,GAAkB,EAClB,GAAkB,EAClB,OAAuD;IAEvD,MAAM,GAAG,GAAG,OAAO,EAAE,gBAAgB,IAAI,MAAM,CAAA;IAC/C,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,uBAAuB,CAAA;IACvD,MAAM,KAAK,GAAG;QACZ,KAAK;QACL,MAAM;QACN,iBAAiB,CAAC,GAAG,CAAC;QACtB,GAAG;QACH,iBAAiB,CAAC,GAAG,CAAC;QACtB,GAAG;QACH,iBAAiB,CAAC,GAAG,CAAC;KACvB,CAAA;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC"}
|
package/dist/shared/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Shared utilities for all layers -
|
|
2
|
+
* Shared utilities for all layers - pure functions shared across the core
|
|
3
3
|
*
|
|
4
4
|
* @remarks
|
|
5
|
-
*
|
|
6
|
-
* Auditoría y análisis avanzado van al SDK.
|
|
5
|
+
* Lineage handling and AI-PIP audit formatting for clear, flexible auditing.
|
|
7
6
|
*/
|
|
8
7
|
export { addLineageEntry, addLineageEntries, filterLineageByStep, getLastLineageEntry } from './lineage.js';
|
|
8
|
+
export { formatLineageForAudit, formatCSLForAudit, formatISLForAudit, formatISLSignalForAudit, formatAALForAudit, formatCPEForAudit, formatPipelineAudit } from './audit.js';
|
|
9
|
+
export type { LineageEntryLike, CSLResultLike, ISLResultLike, ISLSignalLike, DecisionReasonLike, RemovalPlanLike, CPEResultLike } from './audit.js';
|
|
10
|
+
export type { Position, SegmentRef } from './types.js';
|
|
9
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,cAAc,CAAA;AAGrB,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,YAAY,CAAA;AAEnB,YAAY,EACV,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,aAAa,EACd,MAAM,YAAY,CAAA;AAEnB,YAAY,EACV,QAAQ,EACR,UAAU,EACX,MAAM,YAAY,CAAA"}
|
package/dist/shared/index.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Shared utilities for all layers -
|
|
2
|
+
* Shared utilities for all layers - pure functions shared across the core
|
|
3
3
|
*
|
|
4
4
|
* @remarks
|
|
5
|
-
*
|
|
6
|
-
* Auditoría y análisis avanzado van al SDK.
|
|
5
|
+
* Lineage handling and AI-PIP audit formatting for clear, flexible auditing.
|
|
7
6
|
*/
|
|
8
|
-
// Lineage
|
|
7
|
+
// Lineage
|
|
9
8
|
export { addLineageEntry, addLineageEntries, filterLineageByStep, getLastLineageEntry } from './lineage.js';
|
|
10
|
-
//
|
|
11
|
-
|
|
9
|
+
// Audit / pretty-print for AI-PIP layers (ordered, human-readable)
|
|
10
|
+
export { formatLineageForAudit, formatCSLForAudit, formatISLForAudit, formatISLSignalForAudit, formatAALForAudit, formatCPEForAudit, formatPipelineAudit } from './audit.js';
|
|
12
11
|
//# sourceMappingURL=index.js.map
|
package/dist/shared/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,UAAU;AACV,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,cAAc,CAAA;AAErB,mEAAmE;AACnE,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,YAAY,CAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a zero-based position range within a string or segment.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* - `start` is inclusive
|
|
6
|
+
* - `end` is exclusive
|
|
7
|
+
* - Must satisfy: 0 <= start <= end
|
|
8
|
+
*
|
|
9
|
+
* This type is purely structural and shared across layers
|
|
10
|
+
* (CSL, ISL, AAL, reporters).
|
|
11
|
+
*/
|
|
12
|
+
export type Position = {
|
|
13
|
+
/** Inclusive start index */
|
|
14
|
+
readonly start: number;
|
|
15
|
+
/** Exclusive end index */
|
|
16
|
+
readonly end: number;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* References a specific segment and an optional position within it.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* Used to precisely point to a sub-range of a segment without
|
|
23
|
+
* mutating or interpreting its content.
|
|
24
|
+
*
|
|
25
|
+
* Common use cases:
|
|
26
|
+
* - ISL: attach threat signals to exact locations
|
|
27
|
+
* - AAL: target removals or locks precisely
|
|
28
|
+
* - Reporting: highlight affected content
|
|
29
|
+
*/
|
|
30
|
+
export type SegmentRef = {
|
|
31
|
+
/** Unique identifier of the segment */
|
|
32
|
+
readonly segmentId: string;
|
|
33
|
+
/** Optional position within the segment */
|
|
34
|
+
readonly position?: Position;
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/shared/types.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,MAAM,MAAM,QAAQ,GAAG;IACnB,4BAA4B;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IAEtB,0BAA0B;IAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CACrB,CAAA;AAED;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,uCAAuC;IACvC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAE1B,2CAA2C;IAC3C,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAA;CAC7B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/shared/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-pip/core",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Core implementation of the AI-PIP protocol. Provides layered, zero-trust context processing (CSL, ISL,
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Core implementation of the AI-PIP protocol. Provides layered, zero-trust context processing (CSL, ISL, AAL, CPE)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -21,6 +21,11 @@
|
|
|
21
21
|
"import": "./dist/isl/index.js",
|
|
22
22
|
"default": "./dist/isl/index.js"
|
|
23
23
|
},
|
|
24
|
+
"./aal": {
|
|
25
|
+
"types": "./dist/AAL/index.d.ts",
|
|
26
|
+
"import": "./dist/AAL/index.js",
|
|
27
|
+
"default": "./dist/AAL/index.js"
|
|
28
|
+
},
|
|
24
29
|
"./cpe": {
|
|
25
30
|
"types": "./dist/cpe/index.d.ts",
|
|
26
31
|
"import": "./dist/cpe/index.js",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AnomalyScore.d.ts","sourceRoot":"","sources":["../../../src/isl/value-objects/AnomalyScore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE3D;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAA;CAC/B,CAAA;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,YAAY,CAUxF;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAEzD;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAEzD;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAExD"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|