@ai-pip/core 0.1.5 → 0.1.7
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 +181 -0
- package/README.md +96 -176
- package/dist/cpe/envelope.d.ts +2 -2
- package/dist/cpe/envelope.d.ts.map +1 -1
- package/dist/cpe/envelope.js +6 -6
- package/dist/cpe/envelope.js.map +1 -1
- package/dist/cpe/exceptions/index.d.ts +1 -1
- package/dist/cpe/exceptions/index.d.ts.map +1 -1
- package/dist/cpe/exceptions/index.js +1 -1
- package/dist/cpe/exceptions/index.js.map +1 -1
- package/dist/cpe/index.d.ts +8 -8
- package/dist/cpe/index.d.ts.map +1 -1
- package/dist/cpe/index.js +5 -5
- package/dist/cpe/index.js.map +1 -1
- package/dist/cpe/types.d.ts +1 -1
- package/dist/cpe/types.d.ts.map +1 -1
- package/dist/cpe/value-objects/Metadata.d.ts +2 -2
- package/dist/cpe/value-objects/Metadata.d.ts.map +1 -1
- package/dist/cpe/value-objects/Signature.d.ts +1 -1
- package/dist/cpe/value-objects/Signature.d.ts.map +1 -1
- package/dist/cpe/value-objects/index.d.ts +5 -5
- package/dist/cpe/value-objects/index.d.ts.map +1 -1
- package/dist/cpe/value-objects/index.js +3 -3
- package/dist/cpe/value-objects/index.js.map +1 -1
- package/dist/csl/classify.d.ts +4 -4
- package/dist/csl/classify.d.ts.map +1 -1
- package/dist/csl/classify.js +4 -4
- package/dist/csl/classify.js.map +1 -1
- package/dist/csl/exceptions/index.d.ts +2 -2
- package/dist/csl/exceptions/index.d.ts.map +1 -1
- package/dist/csl/exceptions/index.js +2 -2
- package/dist/csl/exceptions/index.js.map +1 -1
- package/dist/csl/index.d.ts +10 -10
- package/dist/csl/index.d.ts.map +1 -1
- package/dist/csl/index.js +8 -8
- package/dist/csl/index.js.map +1 -1
- package/dist/csl/lineage.d.ts +2 -2
- package/dist/csl/lineage.d.ts.map +1 -1
- package/dist/csl/lineage.js +1 -1
- package/dist/csl/lineage.js.map +1 -1
- package/dist/csl/segment.d.ts +1 -1
- package/dist/csl/segment.d.ts.map +1 -1
- package/dist/csl/segment.js +4 -4
- package/dist/csl/segment.js.map +1 -1
- package/dist/csl/types.d.ts +1 -1
- package/dist/csl/types.d.ts.map +1 -1
- package/dist/csl/value-objects/ContentHash.d.ts +1 -1
- package/dist/csl/value-objects/ContentHash.d.ts.map +1 -1
- package/dist/csl/value-objects/Origin-map.d.ts +1 -1
- package/dist/csl/value-objects/Origin-map.d.ts.map +1 -1
- package/dist/csl/value-objects/Origin-map.js +1 -1
- package/dist/csl/value-objects/Origin-map.js.map +1 -1
- package/dist/csl/value-objects/Origin.d.ts +1 -1
- package/dist/csl/value-objects/Origin.d.ts.map +1 -1
- package/dist/csl/value-objects/Origin.js +1 -1
- package/dist/csl/value-objects/Origin.js.map +1 -1
- package/dist/csl/value-objects/TrustLevel.d.ts +1 -1
- package/dist/csl/value-objects/TrustLevel.d.ts.map +1 -1
- package/dist/csl/value-objects/TrustLevel.js +1 -1
- package/dist/csl/value-objects/TrustLevel.js.map +1 -1
- package/dist/csl/value-objects/index.d.ts +9 -9
- package/dist/csl/value-objects/index.d.ts.map +1 -1
- package/dist/csl/value-objects/index.js +5 -5
- package/dist/csl/value-objects/index.js.map +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/isl/exceptions/index.d.ts +1 -1
- package/dist/isl/exceptions/index.d.ts.map +1 -1
- package/dist/isl/exceptions/index.js +1 -1
- package/dist/isl/exceptions/index.js.map +1 -1
- package/dist/isl/index.d.ts +5 -5
- package/dist/isl/index.d.ts.map +1 -1
- package/dist/isl/index.js +3 -3
- package/dist/isl/index.js.map +1 -1
- package/dist/isl/sanitize.d.ts +2 -2
- package/dist/isl/sanitize.d.ts.map +1 -1
- package/dist/isl/sanitize.js +3 -3
- package/dist/isl/sanitize.js.map +1 -1
- package/dist/isl/types.d.ts +3 -3
- package/dist/isl/types.d.ts.map +1 -1
- package/dist/isl/value-objects/AnomalyScore.d.ts +1 -1
- package/dist/isl/value-objects/AnomalyScore.d.ts.map +1 -1
- package/dist/isl/value-objects/Pattern.d.ts +1 -1
- package/dist/isl/value-objects/Pattern.d.ts.map +1 -1
- package/dist/isl/value-objects/PiDetection.d.ts +1 -1
- package/dist/isl/value-objects/PiDetection.d.ts.map +1 -1
- package/dist/isl/value-objects/PiDetectionResult.d.ts +2 -2
- package/dist/isl/value-objects/PiDetectionResult.d.ts.map +1 -1
- package/dist/isl/value-objects/PolicyRule.d.ts +1 -1
- package/dist/isl/value-objects/PolicyRule.d.ts.map +1 -1
- package/dist/isl/value-objects/index.d.ts +8 -8
- package/dist/isl/value-objects/index.d.ts.map +1 -1
- package/dist/isl/value-objects/index.js +4 -4
- package/dist/isl/value-objects/index.js.map +1 -1
- package/dist/shared/index.d.ts +1 -1
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index.js +1 -1
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/lineage.d.ts +1 -1
- package/dist/shared/lineage.d.ts.map +1 -1
- package/package.json +3 -2
- package/tsconfig.json +0 -30
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## [0.1.7] - 2026-01-04
|
|
11
|
+
|
|
12
|
+
### 🐛 Critical Fixes
|
|
13
|
+
|
|
14
|
+
#### Type Resolution Fix
|
|
15
|
+
- **Fixed nested type resolution**: Changed `moduleResolution` from `"bundler"` to `"nodenext"` in `tsconfig.json`
|
|
16
|
+
- **Added explicit file extensions**: All relative imports now include `.js` extension (required by `nodenext`)
|
|
17
|
+
- **Fixed type accessibility**: Types with nested properties (e.g., `TrustLevel.value`) now resolve correctly in consuming projects
|
|
18
|
+
|
|
19
|
+
#### What This Fixes
|
|
20
|
+
|
|
21
|
+
**Problem**: When importing types from `@ai-pip/core` in SDK projects, TypeScript could not resolve nested type properties:
|
|
22
|
+
- `this.data.trust.value` appeared as `any` instead of `TrustLevelType`
|
|
23
|
+
- No autocompletado for nested properties
|
|
24
|
+
- Type inference failed for complex types
|
|
25
|
+
|
|
26
|
+
**Root Cause**: Incompatibility between `moduleResolution: "bundler"` (used in `@ai-pip-core`) and `moduleResolution: "nodenext"` (used in SDK projects). TypeScript couldn't follow the chain of type imports correctly.
|
|
27
|
+
|
|
28
|
+
**Solution**:
|
|
29
|
+
- Aligned `moduleResolution` to `"nodenext"` in both projects
|
|
30
|
+
- Added explicit `.js` extensions to all relative imports (required by Node.js ESM resolution)
|
|
31
|
+
- Changed `module` from `"ESNext"` to `"NodeNext"` for consistency
|
|
32
|
+
|
|
33
|
+
**Impact**:
|
|
34
|
+
- ✅ Nested types now resolve correctly
|
|
35
|
+
- ✅ Autocompletado works for all type properties
|
|
36
|
+
- ✅ Type inference works correctly in consuming projects
|
|
37
|
+
- ✅ Better compatibility with Node.js ESM module resolution
|
|
38
|
+
|
|
39
|
+
### 🔧 Technical Changes
|
|
40
|
+
|
|
41
|
+
- **Removed `tsconfig.json` from package files**: `tsconfig.json` is only needed for development, not for published packages
|
|
42
|
+
- **Updated `tsconfig.json`**:
|
|
43
|
+
- `module: "ESNext"` → `module: "NodeNext"`
|
|
44
|
+
- `moduleResolution: "bundler"` → `moduleResolution: "nodenext"`
|
|
45
|
+
- **Updated all source files**: Added `.js` extension to 107+ relative imports across the codebase
|
|
46
|
+
|
|
47
|
+
### 📦 Package Changes
|
|
48
|
+
|
|
49
|
+
- **Removed from `files` array**: `tsconfig.json` (only needed for development)
|
|
50
|
+
- **Package now includes**: `dist/`, `README.md`, `LICENSE` only
|
|
51
|
+
|
|
52
|
+
### ⚠️ Breaking Changes
|
|
53
|
+
|
|
54
|
+
**None** - This is a patch version that fixes type resolution issues without changing the API.
|
|
55
|
+
|
|
56
|
+
### 📚 Documentation
|
|
57
|
+
|
|
58
|
+
- Updated README to reference centralized CHANGELOG.md
|
|
59
|
+
- Added detailed explanation of type resolution fixes
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## [0.1.6] - 2025-12-28
|
|
64
|
+
|
|
65
|
+
### 📚 Documentation Improvements
|
|
66
|
+
- **Centralized documentation**: Moved all protocol documentation to `ai-pip-docs` repository
|
|
67
|
+
- **Updated README**: Added comprehensive links to centralized documentation
|
|
68
|
+
- **Documentation structure**: Reorganized documentation section with links to whitepaper, architecture, roadmap, and SDK guides
|
|
69
|
+
|
|
70
|
+
### 🔧 Package Improvements
|
|
71
|
+
- **Documentation links**: All documentation now points to `ai-pip-docs` repository
|
|
72
|
+
- **README cleanup**: Removed redundant documentation sections, kept only code-specific documentation
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## [0.1.5] - 2025-12-28
|
|
77
|
+
|
|
78
|
+
### 📚 Documentation Improvements
|
|
79
|
+
- **Updated README**: Added links to whitepaper, roadmap, and complete layer documentation
|
|
80
|
+
- **Updated Roadmap**: Added SDK-browser in Phase 4, updated Phase 1 status to 100% completed
|
|
81
|
+
- **Architecture clarification**: Corrected documentation about Shared (not a layer, but shared features)
|
|
82
|
+
- **SDK note**: Updated explanation about AAL and Model Gateway (they are SDK components, not core)
|
|
83
|
+
|
|
84
|
+
### 🔧 Optimizations
|
|
85
|
+
- **Package size reduction**: Removed `src/` from `files` field in `package.json` to make the package lighter
|
|
86
|
+
- **Optimized package**: Only necessary files are included (`dist/`, `tsconfig.json`, `README.md`, `LICENSE`)
|
|
87
|
+
|
|
88
|
+
### ✨ Improvements
|
|
89
|
+
- **Layer documentation**: Added link to Shared documentation (shared features)
|
|
90
|
+
- **Documentation organization**: Reorganized documentation section with priority on whitepaper and roadmap
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## [0.1.3] - 2025-12-28
|
|
95
|
+
|
|
96
|
+
### ✨ New Features
|
|
97
|
+
- **JavaScript compilation**: The package now compiles to JavaScript (`dist/`) for better compatibility
|
|
98
|
+
- **Type declaration files**: `.d.ts` files are generated for full TypeScript support
|
|
99
|
+
- **Source maps**: Included for better debugging
|
|
100
|
+
|
|
101
|
+
### 🔧 Technical Changes
|
|
102
|
+
- **Publication structure**: Changed from publishing `.ts` files directly to compiling to `dist/`
|
|
103
|
+
- **Improved exports**: Exports now point to compiled files (`.js` and `.d.ts`)
|
|
104
|
+
- **Relative paths**: Replaced path aliases (`@/`) with relative paths for compatibility
|
|
105
|
+
- **Build configuration**: Fixed generation of `.d.ts` files in `dist/` instead of `src/`
|
|
106
|
+
- **ESLint**: Configured to ignore generated `.d.ts` files
|
|
107
|
+
|
|
108
|
+
### 🐛 Fixes
|
|
109
|
+
- **Type resolution**: TypeScript types now resolve correctly from `node_modules`
|
|
110
|
+
- **Imports from subpaths**: Fixed imports from `@ai-pip/core/csl`, `@ai-pip/core/isl`, etc.
|
|
111
|
+
- **Complete exports**: Added `default` field to all exports for Node.js ESM
|
|
112
|
+
- **File generation**: `.d.ts` files now generate correctly in `dist/`
|
|
113
|
+
|
|
114
|
+
### 📚 Documentation
|
|
115
|
+
- **TypeScript requirements**: Improved documentation about required configuration
|
|
116
|
+
- **Updated examples**: Usage examples updated for new structure
|
|
117
|
+
- **Complete CHANGELOG**: Documentation of all versions and deprecations
|
|
118
|
+
|
|
119
|
+
### 🛠️ Development Improvements
|
|
120
|
+
- **test:install script**: Script to verify installation before publishing
|
|
121
|
+
- **prepublishOnly script**: Automatically runs build, lint, tests, and test:install before publishing
|
|
122
|
+
|
|
123
|
+
### ⚠️ Breaking Changes
|
|
124
|
+
- **TypeScript configuration required**: It's now **mandatory** to use `module: "NodeNext"` and `moduleResolution: "nodenext"` in `tsconfig.json`
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## [0.1.2] - 2025-12-28
|
|
129
|
+
|
|
130
|
+
### ⚠️ DEPRECATED
|
|
131
|
+
|
|
132
|
+
**Deprecation reason**: This version had issues with compilation and `.d.ts` file generation. Files were generated in incorrect locations (`src/` instead of `dist/`), causing linting errors and type resolution problems.
|
|
133
|
+
|
|
134
|
+
**Known issues**:
|
|
135
|
+
- `.d.ts` files were generated in `src/` instead of `dist/`
|
|
136
|
+
- ESLint tried to lint generated `.d.ts` files, causing errors
|
|
137
|
+
- Incomplete build configuration (`declarationDir` misconfigured)
|
|
138
|
+
- Types did not resolve correctly in some cases
|
|
139
|
+
|
|
140
|
+
**Recommendation**: Update to `0.1.3` or higher.
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## [0.1.1] - 2025-12-28
|
|
145
|
+
|
|
146
|
+
### ⚠️ DEPRECATED
|
|
147
|
+
|
|
148
|
+
**Deprecation reason**: This version had issues with path alias resolution (`@/`) that caused errors when importing from other projects. Types did not resolve correctly when the package was installed from npm.
|
|
149
|
+
|
|
150
|
+
**Known issues**:
|
|
151
|
+
- Errors: `Module '"@ai-pip/core/csl"' has no exported member 'CSLResult'`
|
|
152
|
+
- Path aliases did not work in consumer projects
|
|
153
|
+
- Types did not resolve correctly from `node_modules`
|
|
154
|
+
|
|
155
|
+
**Recommendation**: Update to `0.1.3` or higher.
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## [0.1.0] - 2025-12-28
|
|
160
|
+
|
|
161
|
+
### ⚠️ DEPRECATED
|
|
162
|
+
|
|
163
|
+
**Deprecation reason**: Initial version with fundamental compatibility issues. Exports did not include the `default` field required by Node.js ESM, causing `ERR_PACKAGE_PATH_NOT_EXPORTED` errors.
|
|
164
|
+
|
|
165
|
+
**Known issues**:
|
|
166
|
+
- Errors: `ERR_PACKAGE_PATH_NOT_EXPORTED` when importing subpaths
|
|
167
|
+
- Incomplete exports: Missing `default` field in exports
|
|
168
|
+
- Path aliases did not work correctly
|
|
169
|
+
|
|
170
|
+
**Recommendation**: Update to `0.1.3` or higher.
|
|
171
|
+
|
|
172
|
+
### 📦 Initial Content
|
|
173
|
+
- **CSL (Context Segmentation Layer)**: Content segmentation and classification
|
|
174
|
+
- **ISL (Instruction Sanitization Layer)**: Instruction sanitization
|
|
175
|
+
- **CPE (Cryptographic Prompt Envelope)**: Cryptographic envelope with HMAC-SHA256
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
**Current Version**: 0.1.7
|
|
180
|
+
**Status**: Phase 1 - Core Layers (100% completed)
|
|
181
|
+
|
package/README.md
CHANGED
|
@@ -5,74 +5,74 @@
|
|
|
5
5
|
[](https://www.npmjs.com/package/@ai-pip/core)
|
|
6
6
|
[](LICENSE)
|
|
7
7
|
|
|
8
|
-
## 📋
|
|
8
|
+
## 📋 Description
|
|
9
9
|
|
|
10
|
-
**AI-PIP (AI Prompt Integrity Protocol)**
|
|
10
|
+
**AI-PIP (AI Prompt Integrity Protocol)** is a multi-layer security protocol designed to protect AI systems against prompt injection and malicious context manipulation.
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
This package contains the **core** implementation of the protocol, which includes pure functions, immutable value objects, and semantic contracts between layers.
|
|
13
13
|
|
|
14
|
-
## 🏗️
|
|
14
|
+
## 🏗️ Architecture
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
The AI-PIP protocol is composed of the following layers:
|
|
17
17
|
|
|
18
|
-
### ✅
|
|
18
|
+
### ✅ Implemented Layers
|
|
19
19
|
|
|
20
|
-
- **CSL (Context Segmentation Layer)**:
|
|
21
|
-
- **ISL (Instruction Sanitization Layer)**:
|
|
22
|
-
- **CPE (Cryptographic Prompt Envelope)**:
|
|
20
|
+
- **CSL (Context Segmentation Layer)**: Segments and classifies content according to its origin
|
|
21
|
+
- **ISL (Instruction Sanitization Layer)**: Sanitizes instructions according to trust level
|
|
22
|
+
- **CPE (Cryptographic Prompt Envelope)**: Generates cryptographic envelope with HMAC-SHA256 signature
|
|
23
23
|
|
|
24
|
-
### 🔧 Features
|
|
24
|
+
### 🔧 Shared Features
|
|
25
25
|
|
|
26
|
-
- **Shared**:
|
|
26
|
+
- **Shared**: Shared functions and global incremental lineage (not a layer, but features shared between layers)
|
|
27
27
|
|
|
28
|
-
### 📝
|
|
28
|
+
### 📝 Note on AAL and Model Gateway
|
|
29
29
|
|
|
30
|
-
**AAL (Agent Action Lock)**
|
|
30
|
+
**AAL (Agent Action Lock)** and **Model Gateway** are SDK components, not part of the semantic core. The semantic core focuses on pure functions and signals, while these layers require operational decisions and side effects that belong to the implementation (SDK).
|
|
31
31
|
|
|
32
|
-
## 📦
|
|
32
|
+
## 📦 Installation
|
|
33
33
|
|
|
34
34
|
```bash
|
|
35
35
|
pnpm add @ai-pip/core
|
|
36
|
-
#
|
|
36
|
+
# or
|
|
37
37
|
npm install @ai-pip/core
|
|
38
|
-
#
|
|
38
|
+
# or
|
|
39
39
|
yarn add @ai-pip/core
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
## 🚀
|
|
42
|
+
## 🚀 Basic Usage
|
|
43
43
|
|
|
44
|
-
###
|
|
44
|
+
### Import from main package
|
|
45
45
|
|
|
46
46
|
```typescript
|
|
47
47
|
import { segment, sanitize, envelope } from '@ai-pip/core'
|
|
48
48
|
import type { CSLResult, ISLResult, CPEResult } from '@ai-pip/core'
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
-
###
|
|
51
|
+
### Complete Example
|
|
52
52
|
|
|
53
53
|
```typescript
|
|
54
54
|
import { segment, sanitize, envelope } from '@ai-pip/core'
|
|
55
55
|
import type { CSLResult, ISLResult, CPEResult } from '@ai-pip/core'
|
|
56
56
|
|
|
57
|
-
// 1.
|
|
57
|
+
// 1. Segment content (CSL)
|
|
58
58
|
const cslResult: CSLResult = segment({
|
|
59
59
|
content: 'User input here',
|
|
60
60
|
source: 'UI',
|
|
61
61
|
metadata: {}
|
|
62
62
|
})
|
|
63
63
|
|
|
64
|
-
// 2.
|
|
64
|
+
// 2. Sanitize content (ISL)
|
|
65
65
|
const islResult: ISLResult = sanitize(cslResult)
|
|
66
66
|
|
|
67
|
-
// 3.
|
|
67
|
+
// 3. Generate cryptographic envelope (CPE)
|
|
68
68
|
const secretKey = 'your-secret-key'
|
|
69
69
|
const cpeResult: CPEResult = envelope(islResult, secretKey)
|
|
70
70
|
|
|
71
|
-
// cpeResult.envelope
|
|
71
|
+
// cpeResult.envelope contains the protected prompt
|
|
72
72
|
console.log(JSON.stringify(cpeResult, null, 2))
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
-
###
|
|
75
|
+
### Example with additional functions
|
|
76
76
|
|
|
77
77
|
```typescript
|
|
78
78
|
import {
|
|
@@ -91,59 +91,69 @@ import type {
|
|
|
91
91
|
TrustLevel
|
|
92
92
|
} from '@ai-pip/core'
|
|
93
93
|
|
|
94
|
-
//
|
|
94
|
+
// Classify a source
|
|
95
95
|
const trust = classifySource('UI' as Source)
|
|
96
96
|
|
|
97
|
-
//
|
|
97
|
+
// Add lineage entry
|
|
98
98
|
const updatedLineage = addLineageEntry(cslResult.lineage, {
|
|
99
99
|
step: 'CUSTOM',
|
|
100
100
|
timestamp: Date.now()
|
|
101
101
|
})
|
|
102
102
|
|
|
103
|
-
//
|
|
103
|
+
// Generate nonce
|
|
104
104
|
const nonce = createNonce()
|
|
105
105
|
```
|
|
106
106
|
|
|
107
|
-
## 📚
|
|
107
|
+
## 📚 Documentation
|
|
108
108
|
|
|
109
|
-
|
|
109
|
+
All AI-PIP protocol documentation is centralized in the [documentation repository](https://github.com/AI-PIP/ai-pip-docs):
|
|
110
110
|
|
|
111
|
-
|
|
112
|
-
- **[ISL - Instruction Sanitization Layer](docs/layer/isl.md)**: Documentación completa de la capa de sanitización
|
|
113
|
-
- **[CPE - Cryptographic Prompt Envelope](docs/layer/cpe.md)**: Documentación completa del envoltorio criptográfico
|
|
111
|
+
### Protocol Documentation
|
|
114
112
|
|
|
113
|
+
- **[Whitepaper](https://github.com/AI-PIP/ai-pip-docs/blob/main/docs/whitepaper.md)** - Complete technical specification
|
|
114
|
+
- **[Architecture](https://github.com/AI-PIP/ai-pip-docs/blob/main/docs/architecture.md)** - Semantic architecture
|
|
115
|
+
- **[Roadmap](https://github.com/AI-PIP/ai-pip-docs/blob/main/docs/roadmap.md)** - Development plan
|
|
115
116
|
|
|
116
|
-
|
|
117
|
+
### Core Documentation
|
|
117
118
|
|
|
118
|
-
|
|
119
|
+
- **[Core Overview](https://github.com/AI-PIP/ai-pip-docs/blob/main/docs/core/CORE.md)** - Semantic core description
|
|
120
|
+
- **[CSL (Context Segmentation Layer)](https://github.com/AI-PIP/ai-pip-docs/blob/main/docs/core/layers/CSL.md)** - Context segmentation layer
|
|
121
|
+
- **[ISL (Instruction Sanitization Layer)](https://github.com/AI-PIP/ai-pip-docs/blob/main/docs/core/layers/ISL.md)** - Instruction sanitization layer
|
|
122
|
+
- **[CPE (Cryptographic Prompt Envelope)](https://github.com/AI-PIP/ai-pip-docs/blob/main/docs/core/layers/CPE.md)** - Cryptographic prompt envelope
|
|
123
|
+
- **[Shared](https://github.com/AI-PIP/ai-pip-docs/blob/main/docs/core/layers/shared.md)** - Shared features and lineage
|
|
119
124
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
- **[
|
|
123
|
-
- **[SDK Reference](docs/
|
|
125
|
+
### SDK Documentation
|
|
126
|
+
|
|
127
|
+
- **[SDK](https://github.com/AI-PIP/ai-pip-docs/blob/main/docs/sdk/sdk.md)** - SDK implementation guide
|
|
128
|
+
- **[SDK Reference](https://github.com/AI-PIP/ai-pip-docs/blob/main/docs/sdk/sdk-reference.md)** - Complete SDK reference guide
|
|
129
|
+
|
|
130
|
+
### Code-Specific Documentation
|
|
131
|
+
|
|
132
|
+
- **[CHANGELOG](./CHANGELOG.md)** - Package version history
|
|
133
|
+
- **[API Reference](#-basic-usage)** - Usage examples in this README
|
|
124
134
|
|
|
125
135
|
## 🧪 Testing
|
|
126
136
|
|
|
127
137
|
```bash
|
|
128
|
-
#
|
|
138
|
+
# Run tests
|
|
129
139
|
pnpm test
|
|
130
140
|
|
|
131
|
-
# Tests
|
|
141
|
+
# Tests in watch mode
|
|
132
142
|
pnpm test:watch
|
|
133
143
|
|
|
134
|
-
# Tests
|
|
144
|
+
# Tests with coverage
|
|
135
145
|
pnpm test:coverage
|
|
136
146
|
|
|
137
|
-
# UI
|
|
147
|
+
# Test UI
|
|
138
148
|
pnpm test:ui
|
|
139
149
|
```
|
|
140
150
|
|
|
141
|
-
**
|
|
151
|
+
**Current coverage**: 87%
|
|
142
152
|
|
|
143
|
-
## 🔧
|
|
153
|
+
## 🔧 Development
|
|
144
154
|
|
|
145
155
|
```bash
|
|
146
|
-
#
|
|
156
|
+
# Install dependencies
|
|
147
157
|
pnpm install
|
|
148
158
|
|
|
149
159
|
# Type checking
|
|
@@ -152,21 +162,21 @@ pnpm type-check
|
|
|
152
162
|
# Linting
|
|
153
163
|
pnpm lint
|
|
154
164
|
|
|
155
|
-
#
|
|
165
|
+
# Development
|
|
156
166
|
pnpm dev
|
|
157
167
|
```
|
|
158
168
|
|
|
159
|
-
## 📋
|
|
169
|
+
## 📋 Requirements
|
|
160
170
|
|
|
161
171
|
### Runtime
|
|
162
172
|
- **Node.js**: >= 18.0.0
|
|
163
|
-
- **pnpm**: >= 8.0.0 (
|
|
173
|
+
- **pnpm**: >= 8.0.0 (recommended) or npm/yarn
|
|
164
174
|
|
|
165
|
-
### TypeScript ⚠️ **
|
|
175
|
+
### TypeScript ⚠️ **REQUIRED**
|
|
166
176
|
|
|
167
|
-
|
|
177
|
+
This package uses ESM (`"type": "module"`) and exports with subpaths. For TypeScript to correctly resolve imports and types, your project **MUST** have the following configuration in `tsconfig.json`:
|
|
168
178
|
|
|
169
|
-
**
|
|
179
|
+
**Minimum required configuration:**
|
|
170
180
|
|
|
171
181
|
```json
|
|
172
182
|
{
|
|
@@ -178,12 +188,12 @@ Este paquete utiliza ESM (`"type": "module"`) y exports con subpaths. Para que T
|
|
|
178
188
|
}
|
|
179
189
|
```
|
|
180
190
|
|
|
181
|
-
**⚠️
|
|
191
|
+
**⚠️ CRITICAL**: Without this configuration, you will get errors like:
|
|
182
192
|
- `Module '"@ai-pip/core/csl"' has no exported member 'CSLResult'`
|
|
183
193
|
- `ERR_PACKAGE_PATH_NOT_EXPORTED`
|
|
184
|
-
-
|
|
194
|
+
- Types will not resolve correctly
|
|
185
195
|
|
|
186
|
-
####
|
|
196
|
+
#### Recommended complete `tsconfig.json` example
|
|
187
197
|
|
|
188
198
|
```json
|
|
189
199
|
{
|
|
@@ -200,159 +210,69 @@ Este paquete utiliza ESM (`"type": "module"`) y exports con subpaths. Para que T
|
|
|
200
210
|
}
|
|
201
211
|
```
|
|
202
212
|
|
|
203
|
-
####
|
|
213
|
+
#### Important notes
|
|
204
214
|
|
|
205
|
-
- **
|
|
206
|
-
- **
|
|
207
|
-
- **JavaScript
|
|
215
|
+
- **From version 0.1.2+**: This configuration is mandatory. Previous versions (0.1.0, 0.1.1) are deprecated.
|
|
216
|
+
- **If you use `tsx` or `ts-node`**: Even if you run TypeScript directly, you **still need** this configuration in `tsconfig.json` for TypeScript to resolve types correctly.
|
|
217
|
+
- **Pure JavaScript**: If you use JavaScript without TypeScript, you don't need this configuration, but you will lose type support.
|
|
208
218
|
|
|
209
|
-
## 📄
|
|
219
|
+
## 📄 License
|
|
210
220
|
|
|
211
|
-
Apache-2.0 -
|
|
221
|
+
Apache-2.0 - See [LICENSE](LICENSE) for more details.
|
|
212
222
|
|
|
213
|
-
## 🤝
|
|
223
|
+
## 🤝 Contributing
|
|
214
224
|
|
|
215
|
-
|
|
225
|
+
Contributions are welcome. Please:
|
|
216
226
|
|
|
217
|
-
1.
|
|
218
|
-
2.
|
|
219
|
-
3.
|
|
227
|
+
1. Review the [Roadmap](https://github.com/AI-PIP/ai-pip-docs/blob/main/roadmap.md) to see what's pending
|
|
228
|
+
2. Open an issue to discuss major changes
|
|
229
|
+
3. Submit a pull request with your improvements
|
|
220
230
|
|
|
221
|
-
**
|
|
231
|
+
**Repository**: https://github.com/AI-PIP/ai-pip-core
|
|
222
232
|
**Issues**: https://github.com/AI-PIP/ai-pip-core/issues
|
|
223
233
|
|
|
224
|
-
## 🔗
|
|
234
|
+
## 🔗 Links
|
|
225
235
|
|
|
226
|
-
- **
|
|
236
|
+
- **Documentation**: [ai-pip-docs](https://github.com/AI-PIP/ai-pip-docs)
|
|
227
237
|
- **NPM Package**: https://www.npmjs.com/package/@ai-pip/core
|
|
228
238
|
- **GitHub**: https://github.com/AI-PIP/ai-pip-core
|
|
229
239
|
|
|
230
|
-
## 🔮
|
|
240
|
+
## 🔮 Future Improvements
|
|
231
241
|
|
|
232
|
-
### Imports
|
|
242
|
+
### Imports by Specific Layer
|
|
233
243
|
|
|
234
|
-
|
|
244
|
+
Currently, it's recommended to import from the main package (`@ai-pip/core`) to avoid confusion with similar names between layers. In future versions, support for direct imports from specific layers will be improved:
|
|
235
245
|
|
|
236
246
|
```typescript
|
|
237
|
-
//
|
|
247
|
+
// Future (in development)
|
|
238
248
|
import { segment } from '@ai-pip/core/csl'
|
|
239
249
|
import { sanitize } from '@ai-pip/core/isl'
|
|
240
250
|
import { envelope } from '@ai-pip/core/cpe'
|
|
241
251
|
```
|
|
242
252
|
|
|
243
|
-
|
|
244
|
-
- **
|
|
245
|
-
- **
|
|
246
|
-
- **
|
|
253
|
+
This will enable:
|
|
254
|
+
- **Better organization**: Import only what's needed from each layer
|
|
255
|
+
- **Avoid conflicts**: Prevent confusion with similarly named functions
|
|
256
|
+
- **Improved tree-shaking**: Bundlers will be able to eliminate unused code more efficiently
|
|
247
257
|
|
|
248
|
-
**
|
|
258
|
+
**Note**: Exports by layer are technically available, but it's recommended to use the main package until module resolution optimization is complete.
|
|
249
259
|
|
|
250
260
|
---
|
|
251
261
|
|
|
252
262
|
## 📝 CHANGELOG
|
|
253
263
|
|
|
254
|
-
### [0.1.
|
|
255
|
-
|
|
256
|
-
#### 📚 Mejoras de Documentación
|
|
257
|
-
- **README actualizado**: Agregados links a whitepaper, roadmap y documentación completa de capas
|
|
258
|
-
- **Roadmap actualizado**: Agregado SDK-browser en Fase 4, actualizado estado de Fase 1 a 100% completado
|
|
259
|
-
- **Clarificación de arquitectura**: Corregida documentación sobre Shared (no es una capa, son features compartidas)
|
|
260
|
-
- **Nota sobre SDK**: Actualizada explicación sobre AAL y Model Gateway (son componentes del SDK, no del core)
|
|
261
|
-
|
|
262
|
-
#### 🔧 Optimizaciones
|
|
263
|
-
- **Reducción de tamaño del paquete**: Removido `src/` del campo `files` en `package.json` para hacer el paquete más liviano
|
|
264
|
-
- **Paquete optimizado**: Solo se incluyen archivos necesarios (`dist/`, `tsconfig.json`, `README.md`, `LICENSE`)
|
|
265
|
-
|
|
266
|
-
#### ✨ Mejoras
|
|
267
|
-
- **Documentación de capas**: Agregado link a documentación de Shared (features compartidas)
|
|
268
|
-
- **Organización de documentación**: Reorganizada sección de documentación con prioridad en whitepaper y roadmap
|
|
269
|
-
|
|
270
|
-
---
|
|
271
|
-
|
|
272
|
-
### [0.1.3] - 2025-12-28
|
|
273
|
-
|
|
274
|
-
#### ✨ Nuevas características
|
|
275
|
-
- **Compilación a JavaScript**: El paquete ahora se compila a JavaScript (`dist/`) para mayor compatibilidad
|
|
276
|
-
- **Archivos de declaración de tipos**: Se generan archivos `.d.ts` para soporte completo de TypeScript
|
|
277
|
-
- **Source maps**: Incluidos para mejor debugging
|
|
278
|
-
|
|
279
|
-
#### 🔧 Cambios técnicos
|
|
280
|
-
- **Estructura de publicación**: Cambio de publicar archivos `.ts` directamente a compilar a `dist/`
|
|
281
|
-
- **Exports mejorados**: Los exports ahora apuntan a archivos compilados (`.js` y `.d.ts`)
|
|
282
|
-
- **Rutas relativas**: Reemplazo de path aliases (`@/`) por rutas relativas para compatibilidad
|
|
283
|
-
- **Configuración de build**: Corregida la generación de archivos `.d.ts` en `dist/` en lugar de `src/`
|
|
284
|
-
- **ESLint**: Configurado para ignorar archivos `.d.ts` generados
|
|
285
|
-
|
|
286
|
-
#### 🐛 Correcciones
|
|
287
|
-
- **Resolución de tipos**: Los tipos TypeScript ahora se resuelven correctamente desde `node_modules`
|
|
288
|
-
- **Imports desde subpaths**: Corregidos los imports desde `@ai-pip/core/csl`, `@ai-pip/core/isl`, etc.
|
|
289
|
-
- **Exports completos**: Agregado campo `default` a todos los exports para Node.js ESM
|
|
290
|
-
- **Generación de archivos**: Archivos `.d.ts` ahora se generan correctamente en `dist/`
|
|
291
|
-
|
|
292
|
-
#### 📚 Documentación
|
|
293
|
-
- **Requisitos de TypeScript**: Documentación mejorada sobre configuración requerida
|
|
294
|
-
- **Ejemplos actualizados**: Ejemplos de uso actualizados para la nueva estructura
|
|
295
|
-
- **CHANGELOG completo**: Documentación de todas las versiones y deprecaciones
|
|
296
|
-
|
|
297
|
-
#### 🛠️ Mejoras de desarrollo
|
|
298
|
-
- **Script test:install**: Script para verificar instalación antes de publicar
|
|
299
|
-
- **Script prepublishOnly**: Ejecuta automáticamente build, lint, tests y test:install antes de publicar
|
|
300
|
-
|
|
301
|
-
#### ⚠️ Breaking Changes
|
|
302
|
-
- **Configuración TypeScript requerida**: Ahora es **obligatorio** usar `module: "NodeNext"` y `moduleResolution: "nodenext"` en `tsconfig.json`
|
|
303
|
-
|
|
304
|
-
---
|
|
305
|
-
|
|
306
|
-
### [0.1.2] - 2025-12-28
|
|
307
|
-
|
|
308
|
-
#### ⚠️ DEPRECADA
|
|
309
|
-
|
|
310
|
-
**Motivo de deprecación**: Esta versión tenía problemas con la compilación y generación de archivos `.d.ts`. Los archivos se generaban en ubicaciones incorrectas (`src/` en lugar de `dist/`), causando errores de linting y problemas de resolución de tipos.
|
|
311
|
-
|
|
312
|
-
**Problemas conocidos**:
|
|
313
|
-
- Archivos `.d.ts` se generaban en `src/` en lugar de `dist/`
|
|
314
|
-
- ESLint intentaba lintear archivos `.d.ts` generados, causando errores
|
|
315
|
-
- Configuración de build incompleta (`declarationDir` mal configurado)
|
|
316
|
-
- Los tipos no se resolvían correctamente en algunos casos
|
|
317
|
-
|
|
318
|
-
**Recomendación**: Actualizar a `0.1.3` o superior.
|
|
319
|
-
|
|
320
|
-
---
|
|
321
|
-
|
|
322
|
-
### [0.1.1] - 2025-12-28
|
|
323
|
-
|
|
324
|
-
#### ⚠️ DEPRECADA
|
|
325
|
-
|
|
326
|
-
**Motivo de deprecación**: Esta versión tenía problemas con la resolución de path aliases (`@/`) que causaban errores al importar desde otros proyectos. Los tipos no se resolvían correctamente cuando el paquete se instalaba desde npm.
|
|
327
|
-
|
|
328
|
-
**Problemas conocidos**:
|
|
329
|
-
- Errores: `Module '"@ai-pip/core/csl"' has no exported member 'CSLResult'`
|
|
330
|
-
- Path aliases no funcionaban en proyectos consumidores
|
|
331
|
-
- Tipos no se resolvían correctamente desde `node_modules`
|
|
332
|
-
|
|
333
|
-
**Recomendación**: Actualizar a `0.1.3` o superior.
|
|
334
|
-
|
|
335
|
-
---
|
|
336
|
-
|
|
337
|
-
### [0.1.0] - 2025-12-28
|
|
338
|
-
|
|
339
|
-
#### ⚠️ DEPRECADA
|
|
340
|
-
|
|
341
|
-
**Motivo de deprecación**: Versión inicial con problemas fundamentales de compatibilidad. Los exports no incluían el campo `default` requerido por Node.js ESM, causando errores `ERR_PACKAGE_PATH_NOT_EXPORTED`.
|
|
264
|
+
### [0.1.7] - 2026-01-01
|
|
342
265
|
|
|
343
|
-
|
|
344
|
-
-
|
|
345
|
-
-
|
|
346
|
-
-
|
|
266
|
+
#### 🐛 Critical Fixes
|
|
267
|
+
- **Fixed nested type resolution**: Changed `moduleResolution` from `"bundler"` to `"nodenext"` to fix type accessibility issues
|
|
268
|
+
- **Added explicit file extensions**: All relative imports now include `.js` extension (required by `nodenext`)
|
|
269
|
+
- **Removed `tsconfig.json` from package**: Only needed for development, not for published packages
|
|
347
270
|
|
|
348
|
-
**
|
|
271
|
+
**What this fixes**: TypeScript now correctly recognizes and resolves all type properties in consuming projects. Previously, nested type properties were not recognized, appearing as `any` instead of their correct types, and autocompletado didn't work for type properties. This fix ensures proper type inference, autocompletado, and type checking for all exported types and their nested properties.
|
|
349
272
|
|
|
350
|
-
|
|
351
|
-
- **CSL (Context Segmentation Layer)**: Segmentación y clasificación de contenido
|
|
352
|
-
- **ISL (Instruction Sanitization Layer)**: Sanitización de instrucciones
|
|
353
|
-
- **CPE (Cryptographic Prompt Envelope)**: Envoltorio criptográfico con HMAC-SHA256
|
|
273
|
+
For complete details and all version history, see [CHANGELOG.md](./CHANGELOG.md).
|
|
354
274
|
|
|
355
275
|
---
|
|
356
276
|
|
|
357
|
-
**
|
|
358
|
-
**
|
|
277
|
+
**Current Version**: 0.1.7
|
|
278
|
+
**Status**: Phase 1 - Core Layers (100% completed)
|
package/dist/cpe/envelope.d.ts
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* // - lineage: linaje completo
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
|
-
import type { ISLResult } from '../isl/types';
|
|
32
|
-
import type { CPEResult } from './types';
|
|
31
|
+
import type { ISLResult } from '../isl/types.js';
|
|
32
|
+
import type { CPEResult } from './types.js';
|
|
33
33
|
export declare function envelope(islResult: ISLResult, secretKey: string): CPEResult;
|
|
34
34
|
//# sourceMappingURL=envelope.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envelope.d.ts","sourceRoot":"","sources":["../../src/cpe/envelope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"envelope.d.ts","sourceRoot":"","sources":["../../src/cpe/envelope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,KAAK,EAAc,SAAS,EAAE,MAAM,YAAY,CAAA;AAUvD,wBAAgB,QAAQ,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,CAwE3E"}
|
package/dist/cpe/envelope.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { createNonce } from './value-objects/Nonce';
|
|
2
|
-
import { createMetadata } from './value-objects/Metadata';
|
|
3
|
-
import { createSignature } from './value-objects/Signature';
|
|
4
|
-
import { EnvelopeError } from './exceptions';
|
|
1
|
+
import { createNonce } from './value-objects/Nonce.js';
|
|
2
|
+
import { createMetadata } from './value-objects/Metadata.js';
|
|
3
|
+
import { createSignature } from './value-objects/Signature.js';
|
|
4
|
+
import { EnvelopeError } from './exceptions/index.js';
|
|
5
5
|
// Serialización NO es core - va al SDK
|
|
6
6
|
// El core solo define la estructura del envelope
|
|
7
|
-
import { addLineageEntries } from '../shared/lineage';
|
|
8
|
-
import { createLineageEntry } from '../csl/value-objects/LineageEntry';
|
|
7
|
+
import { addLineageEntries } from '../shared/lineage.js';
|
|
8
|
+
import { createLineageEntry } from '../csl/value-objects/LineageEntry.js';
|
|
9
9
|
export function envelope(islResult, secretKey) {
|
|
10
10
|
const startTime = Date.now();
|
|
11
11
|
try {
|