@ai-pip/core 0.3.0 → 0.5.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 +74 -1
- package/README.md +52 -1037
- package/dist/AAL/index.d.ts +4 -4
- package/dist/AAL/index.d.ts.map +1 -1
- package/dist/AAL/index.js +2 -2
- package/dist/AAL/index.js.map +1 -1
- package/dist/AAL/process/buildDecisionReason.d.ts.map +1 -1
- package/dist/AAL/process/buildDecisionReason.js +2 -4
- package/dist/AAL/process/buildDecisionReason.js.map +1 -1
- package/dist/AAL/process/buildRemediationPlan.d.ts +22 -0
- package/dist/AAL/process/buildRemediationPlan.d.ts.map +1 -0
- package/dist/AAL/process/buildRemediationPlan.js +81 -0
- package/dist/AAL/process/buildRemediationPlan.js.map +1 -0
- package/dist/AAL/process/index.d.ts +2 -3
- package/dist/AAL/process/index.d.ts.map +1 -1
- package/dist/AAL/process/index.js +2 -2
- package/dist/AAL/process/index.js.map +1 -1
- package/dist/AAL/process/resolveAgentAction.d.ts.map +1 -1
- package/dist/AAL/process/resolveAgentAction.js +3 -14
- package/dist/AAL/process/resolveAgentAction.js.map +1 -1
- package/dist/AAL/process/validatePolicy.d.ts +20 -0
- package/dist/AAL/process/validatePolicy.d.ts.map +1 -0
- package/dist/AAL/process/validatePolicy.js +40 -0
- package/dist/AAL/process/validatePolicy.js.map +1 -0
- package/dist/AAL/types.d.ts +18 -35
- package/dist/AAL/types.d.ts.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/isl/detect/detect.js +19 -19
- package/dist/isl/detect/detect.js.map +1 -1
- package/dist/isl/index.d.ts +2 -0
- package/dist/isl/index.d.ts.map +1 -1
- package/dist/isl/index.js +2 -0
- package/dist/isl/index.js.map +1 -1
- package/dist/isl/process/buildISLResult.d.ts +3 -1
- package/dist/isl/process/buildISLResult.d.ts.map +1 -1
- package/dist/isl/process/buildISLResult.js +3 -1
- package/dist/isl/process/buildISLResult.js.map +1 -1
- package/dist/isl/sanitize.d.ts.map +1 -1
- package/dist/isl/sanitize.js +15 -3
- package/dist/isl/sanitize.js.map +1 -1
- package/dist/isl/tags/index.d.ts +19 -0
- package/dist/isl/tags/index.d.ts.map +1 -0
- package/dist/isl/tags/index.js +17 -0
- package/dist/isl/tags/index.js.map +1 -0
- package/dist/isl/tags/namespace.d.ts +18 -0
- package/dist/isl/tags/namespace.d.ts.map +1 -0
- package/dist/isl/tags/namespace.js +18 -0
- package/dist/isl/tags/namespace.js.map +1 -0
- package/dist/isl/tags/serializer.d.ts +39 -0
- package/dist/isl/tags/serializer.d.ts.map +1 -0
- package/dist/isl/tags/serializer.js +45 -0
- package/dist/isl/tags/serializer.js.map +1 -0
- package/dist/isl/tags/tag-registry.d.ts +15 -0
- package/dist/isl/tags/tag-registry.d.ts.map +1 -0
- package/dist/isl/tags/tag-registry.js +17 -0
- package/dist/isl/tags/tag-registry.js.map +1 -0
- package/dist/isl/tags/threat-tag-type.d.ts +13 -0
- package/dist/isl/tags/threat-tag-type.d.ts.map +1 -0
- package/dist/isl/tags/threat-tag-type.js +9 -0
- package/dist/isl/tags/threat-tag-type.js.map +1 -0
- package/dist/isl/tags/threat-tag.d.ts +32 -0
- package/dist/isl/tags/threat-tag.d.ts.map +1 -0
- package/dist/isl/tags/threat-tag.js +43 -0
- package/dist/isl/tags/threat-tag.js.map +1 -0
- package/dist/isl/types.d.ts +13 -0
- package/dist/isl/types.d.ts.map +1 -1
- package/dist/shared/audit.d.ts +16 -18
- package/dist/shared/audit.d.ts.map +1 -1
- package/dist/shared/audit.js +27 -31
- package/dist/shared/audit.js.map +1 -1
- package/dist/shared/envelope/envelope.d.ts +23 -0
- package/dist/shared/envelope/envelope.d.ts.map +1 -0
- package/dist/{cpe → shared/envelope}/envelope.js +9 -21
- package/dist/shared/envelope/envelope.js.map +1 -0
- package/dist/{cpe → shared/envelope}/exceptions/EnvelopeError.d.ts +1 -1
- package/dist/shared/envelope/exceptions/EnvelopeError.d.ts.map +1 -0
- package/dist/{cpe → shared/envelope}/exceptions/EnvelopeError.js +1 -1
- package/dist/shared/envelope/exceptions/EnvelopeError.js.map +1 -0
- package/dist/shared/envelope/exceptions/index.d.ts +2 -0
- package/dist/shared/envelope/exceptions/index.d.ts.map +1 -0
- package/dist/shared/envelope/exceptions/index.js +2 -0
- package/dist/shared/envelope/exceptions/index.js.map +1 -0
- package/dist/shared/envelope/index.d.ts +18 -0
- package/dist/shared/envelope/index.d.ts.map +1 -0
- package/dist/shared/envelope/index.js +15 -0
- package/dist/shared/envelope/index.js.map +1 -0
- package/dist/shared/envelope/types.d.ts +45 -0
- package/dist/shared/envelope/types.d.ts.map +1 -0
- package/dist/shared/envelope/types.js +10 -0
- package/dist/shared/envelope/types.js.map +1 -0
- package/dist/shared/envelope/value-objects/Metadata.d.ts +27 -0
- package/dist/shared/envelope/value-objects/Metadata.d.ts.map +1 -0
- package/dist/{cpe → shared/envelope}/value-objects/Metadata.js +11 -19
- package/dist/shared/envelope/value-objects/Metadata.js.map +1 -0
- package/dist/shared/envelope/value-objects/Nonce.d.ts +26 -0
- package/dist/shared/envelope/value-objects/Nonce.d.ts.map +1 -0
- package/dist/{cpe → shared/envelope}/value-objects/Nonce.js +11 -17
- package/dist/shared/envelope/value-objects/Nonce.js.map +1 -0
- package/dist/shared/envelope/value-objects/Signature.d.ts +28 -0
- package/dist/shared/envelope/value-objects/Signature.d.ts.map +1 -0
- package/dist/shared/envelope/value-objects/Signature.js +50 -0
- package/dist/shared/envelope/value-objects/Signature.js.map +1 -0
- package/dist/{cpe → shared/envelope}/value-objects/index.d.ts +1 -1
- package/dist/shared/envelope/value-objects/index.d.ts.map +1 -0
- package/dist/{cpe → shared/envelope}/value-objects/index.js +1 -1
- package/dist/shared/envelope/value-objects/index.js.map +1 -0
- package/dist/shared/index.d.ts +1 -1
- package/dist/shared/index.d.ts.map +1 -1
- package/package.json +8 -6
- package/dist/AAL/process/applyRemovalPlan.d.ts +0 -21
- package/dist/AAL/process/applyRemovalPlan.d.ts.map +0 -1
- package/dist/AAL/process/applyRemovalPlan.js +0 -150
- package/dist/AAL/process/applyRemovalPlan.js.map +0 -1
- package/dist/AAL/process/buildRemovalPlan.d.ts +0 -39
- package/dist/AAL/process/buildRemovalPlan.d.ts.map +0 -1
- package/dist/AAL/process/buildRemovalPlan.js +0 -104
- package/dist/AAL/process/buildRemovalPlan.js.map +0 -1
- package/dist/cpe/envelope.d.ts +0 -34
- package/dist/cpe/envelope.d.ts.map +0 -1
- package/dist/cpe/envelope.js.map +0 -1
- package/dist/cpe/exceptions/EnvelopeError.d.ts.map +0 -1
- package/dist/cpe/exceptions/EnvelopeError.js.map +0 -1
- package/dist/cpe/exceptions/index.d.ts +0 -5
- package/dist/cpe/exceptions/index.d.ts.map +0 -1
- package/dist/cpe/exceptions/index.js +0 -5
- package/dist/cpe/exceptions/index.js.map +0 -1
- package/dist/cpe/index.d.ts +0 -24
- package/dist/cpe/index.d.ts.map +0 -1
- package/dist/cpe/index.js +0 -26
- package/dist/cpe/index.js.map +0 -1
- package/dist/cpe/types.d.ts +0 -58
- package/dist/cpe/types.d.ts.map +0 -1
- package/dist/cpe/types.js +0 -5
- package/dist/cpe/types.js.map +0 -1
- package/dist/cpe/utils.d.ts +0 -38
- package/dist/cpe/utils.d.ts.map +0 -1
- package/dist/cpe/utils.js +0 -47
- package/dist/cpe/utils.js.map +0 -1
- package/dist/cpe/value-objects/Metadata.d.ts +0 -32
- package/dist/cpe/value-objects/Metadata.d.ts.map +0 -1
- package/dist/cpe/value-objects/Metadata.js.map +0 -1
- package/dist/cpe/value-objects/Nonce.d.ts +0 -33
- package/dist/cpe/value-objects/Nonce.d.ts.map +0 -1
- package/dist/cpe/value-objects/Nonce.js.map +0 -1
- package/dist/cpe/value-objects/Signature.d.ts +0 -39
- package/dist/cpe/value-objects/Signature.d.ts.map +0 -1
- package/dist/cpe/value-objects/Signature.js +0 -60
- package/dist/cpe/value-objects/Signature.js.map +0 -1
- package/dist/cpe/value-objects/index.d.ts.map +0 -1
- package/dist/cpe/value-objects/index.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,79 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
+
## [0.5.0] - (latest)
|
|
11
|
+
|
|
12
|
+
### ✨ Added
|
|
13
|
+
|
|
14
|
+
- **ISL – Semantic isolation and canonical tags (v0.5.0)**
|
|
15
|
+
- **ThreatTag**: Structural metadata for semantic isolation: `segmentId`, `startOffset`, `endOffset`, `type` (ThreatTagType), `confidence`. ISL (or SDK) produces ThreatTags; the core does not insert tags into text.
|
|
16
|
+
- **createThreatTag(segmentId, startOffset, endOffset, type, confidence)**: Factory that validates and returns a frozen ThreatTag. Validates non-empty segmentId, 0 ≤ start ≤ end, valid type, confidence in [0, 1].
|
|
17
|
+
- **Tag registry**: `VALID_TAG_TYPES` (readonly list aligned with ISL detect taxonomy) and `isValidThreatTagType(value)` for validation.
|
|
18
|
+
- **Canonical AI-PIP tag serializer** (`isl/tags/serializer.ts`): Official protocol representation only. No offsets, no segment mutation, no encapsulation logic.
|
|
19
|
+
- **openTag(type)**: Returns canonical opening tag string, e.g. `<aipip:prompt-injection>`.
|
|
20
|
+
- **closeTag(type)**: Returns canonical closing tag string, e.g. `</aipip:prompt-injection>`.
|
|
21
|
+
- **wrapWithTag(type, content)**: Returns content wrapped with opening and closing tags (pure string concatenation).
|
|
22
|
+
- **Namespace**: `AIPIP_NAMESPACE` (`"aipip"`) and `AIPIP_TAG_SCHEMA_VERSION` (1) for forward compatibility.
|
|
23
|
+
- **ThreatTagType**: Alias for threat type in tag context (aligned with `ThreatType` from detect); single source of truth remains ISL detect.
|
|
24
|
+
- **ISLResult.threatTags**: `readonly ThreatTag[]` — List of threat tags derived from segment detections (only detections with valid `ThreatTagType`). Built in `sanitize()` and passed to `buildISLResult`; SDK uses it with the canonical serializer to apply encapsulation.
|
|
25
|
+
- **buildISLResult(segments, lineage, threatTags, processingTimeMs?)**: New third parameter **threatTags** (required); `processingTimeMs` is now the fourth optional argument. Callers (e.g. `sanitize`) must pass the array of ThreatTag derived from detections (or `[]` when none).
|
|
26
|
+
|
|
27
|
+
- **Benefits of semantic isolation**
|
|
28
|
+
- **No semantic corruption**: Core does not modify segment text; it produces metadata (ThreatTag) and defines the canonical tag format.
|
|
29
|
+
- **Auditable and reversible**: Tag format is deterministic and standardized; SDK applies tags at fragment level using offsets.
|
|
30
|
+
- **Clear responsibility**: SDK is responsible for applying offsets, inserting tags at correct positions, resolving multiple/overlapping tags (e.g. by descending offset order). The serializer only builds strings.
|
|
31
|
+
|
|
32
|
+
### 📚 Documentation
|
|
33
|
+
|
|
34
|
+
- **README.md**: New subsection *Semantic isolation and canonical tags (v0.5.0)*: ThreatTag, serializer (openTag, closeTag, wrapWithTag), encapsulation at fragment level, SDK responsibilities.
|
|
35
|
+
- **FEATURE.md**: 0.5.0 section with new APIs (ThreatTag, createThreatTag, tag registry, serializer), benefits, and methods table.
|
|
36
|
+
- **docs/readme.md**: Same 0.5.0 content and link from Architecture / ISL.
|
|
37
|
+
|
|
38
|
+
### 📎 More information
|
|
39
|
+
|
|
40
|
+
See **[FEATURE.md](./FEATURE.md)** for 0.5.0 API details.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## [0.4.0] - (unreleased)
|
|
45
|
+
|
|
46
|
+
### ✨ Added
|
|
47
|
+
|
|
48
|
+
- **AAL – Remediation plan (what to clean, not how)**
|
|
49
|
+
- `buildRemediationPlan(islResult, policy)`: builds a **RemediationPlan** describing *what* to clean (target segment IDs, goals, constraints). The SDK or an AI tool performs the actual cleanup.
|
|
50
|
+
- **RemediationPlan**: `strategy: 'AI_CLEANUP'`, `goals: string[]` (e.g. `remove_prompt_injection`, `remove_role_hijacking`), `constraints: string[]` (e.g. `preserve_user_intent`, `do_not_add_information`, `do_not_change_language`), `targetSegments: string[]` (segment IDs with detections), `needsRemediation: boolean`.
|
|
51
|
+
- Policy: **`remediation: { enabled: boolean }`** (replaces `removal`).
|
|
52
|
+
|
|
53
|
+
- **Shared – Audit with remediation plan**
|
|
54
|
+
- **RemediationPlanLike** (shared type) for audit payloads; same shape as RemediationPlan.
|
|
55
|
+
- `formatPipelineAuditFull(..., remediationPlan?, cpe?, options?)` and `buildFullAuditPayload` / `formatPipelineAuditAsJson` accept **`remediationPlan`** in options (replacing removal plan).
|
|
56
|
+
- `formatAALForAudit(reason, remediationPlan?)` documents the remediation plan in the AAL section.
|
|
57
|
+
|
|
58
|
+
- **CPE – Transversal (documented and clarified)**
|
|
59
|
+
- CPE (Cryptographic Prompt Envelope) is **transversal**: it **ensures the integrity of each layer** for greater security. It is not a sequential processing layer but a shared capability that wraps pipeline output (e.g. ISL or AAL result) with a cryptographic envelope (nonce, metadata, HMAC-SHA256), so that the result of each layer can be verified and tampering detected. Implementation lives in **`shared/envelope`**; the package exports it as **`@ai-pip/core/cpe`** for backward compatibility. Use `envelope(islResult, secretKey)` to wrap any pipeline result.
|
|
60
|
+
|
|
61
|
+
### 🗑️ Removed
|
|
62
|
+
|
|
63
|
+
- **AAL – Removal plan and application (moved to SDK)**
|
|
64
|
+
- **Removed**: `buildRemovalPlan`, `buildRemovalPlanFromResult`, `applyRemovalPlan`, **RemovalPlan**, **RemovedInstruction**.
|
|
65
|
+
- The core no longer performs instruction removal; it only produces a remediation plan. The SDK (or an AI cleanup tool) uses the plan to clean the content.
|
|
66
|
+
|
|
67
|
+
### 🔄 Changed
|
|
68
|
+
|
|
69
|
+
- **AgentPolicy**: `removal: { enabled }` → **`remediation: { enabled }`**.
|
|
70
|
+
- **Audit**: All formatters and payloads use **remediationPlan** / **RemediationPlanLike** instead of removal plan / RemovalPlanLike.
|
|
71
|
+
|
|
72
|
+
### 📚 Documentation
|
|
73
|
+
|
|
74
|
+
- **README.md**: Examples and use cases updated to remediation (buildRemediationPlan, RemediationPlan, policy.remediation); audit section uses remediationPlan; SDK responsibility clarified (remediation execution, e.g. AI cleanup). New subsection *CPE as transversal* in Architecture: CPE ensures the **integrity of each layer** for greater security (shared/envelope, export `@ai-pip/core/cpe`); pipeline clarified (CSL → ISL → optional AAL; CPE wraps result for verification).
|
|
75
|
+
- **FEATURE.md**: 0.4.0 section with new APIs, removed APIs, and CPE transversal; tables updated for remediation.
|
|
76
|
+
|
|
77
|
+
### 📎 More information
|
|
78
|
+
|
|
79
|
+
See **[FEATURE.md](./FEATURE.md)** for API details.
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
10
83
|
## [0.3.0] - (unreleased)
|
|
11
84
|
|
|
12
85
|
### ✨ Added
|
|
@@ -414,6 +487,6 @@ For specific method signatures and API changes in 0.3.0, see **[FEATURE.md](./FE
|
|
|
414
487
|
|
|
415
488
|
---
|
|
416
489
|
|
|
417
|
-
**Current Version**: 0.
|
|
490
|
+
**Current Version**: 0.5.0
|
|
418
491
|
**Status**: Phase 1 - Core Layers (100% completed)
|
|
419
492
|
|