@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.
Files changed (104) hide show
  1. package/CHANGELOG.md +181 -0
  2. package/README.md +96 -176
  3. package/dist/cpe/envelope.d.ts +2 -2
  4. package/dist/cpe/envelope.d.ts.map +1 -1
  5. package/dist/cpe/envelope.js +6 -6
  6. package/dist/cpe/envelope.js.map +1 -1
  7. package/dist/cpe/exceptions/index.d.ts +1 -1
  8. package/dist/cpe/exceptions/index.d.ts.map +1 -1
  9. package/dist/cpe/exceptions/index.js +1 -1
  10. package/dist/cpe/exceptions/index.js.map +1 -1
  11. package/dist/cpe/index.d.ts +8 -8
  12. package/dist/cpe/index.d.ts.map +1 -1
  13. package/dist/cpe/index.js +5 -5
  14. package/dist/cpe/index.js.map +1 -1
  15. package/dist/cpe/types.d.ts +1 -1
  16. package/dist/cpe/types.d.ts.map +1 -1
  17. package/dist/cpe/value-objects/Metadata.d.ts +2 -2
  18. package/dist/cpe/value-objects/Metadata.d.ts.map +1 -1
  19. package/dist/cpe/value-objects/Signature.d.ts +1 -1
  20. package/dist/cpe/value-objects/Signature.d.ts.map +1 -1
  21. package/dist/cpe/value-objects/index.d.ts +5 -5
  22. package/dist/cpe/value-objects/index.d.ts.map +1 -1
  23. package/dist/cpe/value-objects/index.js +3 -3
  24. package/dist/cpe/value-objects/index.js.map +1 -1
  25. package/dist/csl/classify.d.ts +4 -4
  26. package/dist/csl/classify.d.ts.map +1 -1
  27. package/dist/csl/classify.js +4 -4
  28. package/dist/csl/classify.js.map +1 -1
  29. package/dist/csl/exceptions/index.d.ts +2 -2
  30. package/dist/csl/exceptions/index.d.ts.map +1 -1
  31. package/dist/csl/exceptions/index.js +2 -2
  32. package/dist/csl/exceptions/index.js.map +1 -1
  33. package/dist/csl/index.d.ts +10 -10
  34. package/dist/csl/index.d.ts.map +1 -1
  35. package/dist/csl/index.js +8 -8
  36. package/dist/csl/index.js.map +1 -1
  37. package/dist/csl/lineage.d.ts +2 -2
  38. package/dist/csl/lineage.d.ts.map +1 -1
  39. package/dist/csl/lineage.js +1 -1
  40. package/dist/csl/lineage.js.map +1 -1
  41. package/dist/csl/segment.d.ts +1 -1
  42. package/dist/csl/segment.d.ts.map +1 -1
  43. package/dist/csl/segment.js +4 -4
  44. package/dist/csl/segment.js.map +1 -1
  45. package/dist/csl/types.d.ts +1 -1
  46. package/dist/csl/types.d.ts.map +1 -1
  47. package/dist/csl/value-objects/ContentHash.d.ts +1 -1
  48. package/dist/csl/value-objects/ContentHash.d.ts.map +1 -1
  49. package/dist/csl/value-objects/Origin-map.d.ts +1 -1
  50. package/dist/csl/value-objects/Origin-map.d.ts.map +1 -1
  51. package/dist/csl/value-objects/Origin-map.js +1 -1
  52. package/dist/csl/value-objects/Origin-map.js.map +1 -1
  53. package/dist/csl/value-objects/Origin.d.ts +1 -1
  54. package/dist/csl/value-objects/Origin.d.ts.map +1 -1
  55. package/dist/csl/value-objects/Origin.js +1 -1
  56. package/dist/csl/value-objects/Origin.js.map +1 -1
  57. package/dist/csl/value-objects/TrustLevel.d.ts +1 -1
  58. package/dist/csl/value-objects/TrustLevel.d.ts.map +1 -1
  59. package/dist/csl/value-objects/TrustLevel.js +1 -1
  60. package/dist/csl/value-objects/TrustLevel.js.map +1 -1
  61. package/dist/csl/value-objects/index.d.ts +9 -9
  62. package/dist/csl/value-objects/index.d.ts.map +1 -1
  63. package/dist/csl/value-objects/index.js +5 -5
  64. package/dist/csl/value-objects/index.js.map +1 -1
  65. package/dist/index.d.ts +8 -8
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/index.js +5 -5
  68. package/dist/index.js.map +1 -1
  69. package/dist/isl/exceptions/index.d.ts +1 -1
  70. package/dist/isl/exceptions/index.d.ts.map +1 -1
  71. package/dist/isl/exceptions/index.js +1 -1
  72. package/dist/isl/exceptions/index.js.map +1 -1
  73. package/dist/isl/index.d.ts +5 -5
  74. package/dist/isl/index.d.ts.map +1 -1
  75. package/dist/isl/index.js +3 -3
  76. package/dist/isl/index.js.map +1 -1
  77. package/dist/isl/sanitize.d.ts +2 -2
  78. package/dist/isl/sanitize.d.ts.map +1 -1
  79. package/dist/isl/sanitize.js +3 -3
  80. package/dist/isl/sanitize.js.map +1 -1
  81. package/dist/isl/types.d.ts +3 -3
  82. package/dist/isl/types.d.ts.map +1 -1
  83. package/dist/isl/value-objects/AnomalyScore.d.ts +1 -1
  84. package/dist/isl/value-objects/AnomalyScore.d.ts.map +1 -1
  85. package/dist/isl/value-objects/Pattern.d.ts +1 -1
  86. package/dist/isl/value-objects/Pattern.d.ts.map +1 -1
  87. package/dist/isl/value-objects/PiDetection.d.ts +1 -1
  88. package/dist/isl/value-objects/PiDetection.d.ts.map +1 -1
  89. package/dist/isl/value-objects/PiDetectionResult.d.ts +2 -2
  90. package/dist/isl/value-objects/PiDetectionResult.d.ts.map +1 -1
  91. package/dist/isl/value-objects/PolicyRule.d.ts +1 -1
  92. package/dist/isl/value-objects/PolicyRule.d.ts.map +1 -1
  93. package/dist/isl/value-objects/index.d.ts +8 -8
  94. package/dist/isl/value-objects/index.d.ts.map +1 -1
  95. package/dist/isl/value-objects/index.js +4 -4
  96. package/dist/isl/value-objects/index.js.map +1 -1
  97. package/dist/shared/index.d.ts +1 -1
  98. package/dist/shared/index.d.ts.map +1 -1
  99. package/dist/shared/index.js +1 -1
  100. package/dist/shared/index.js.map +1 -1
  101. package/dist/shared/lineage.d.ts +1 -1
  102. package/dist/shared/lineage.d.ts.map +1 -1
  103. package/package.json +3 -2
  104. 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
  [![npm version](https://img.shields.io/npm/v/@ai-pip/core)](https://www.npmjs.com/package/@ai-pip/core)
6
6
  [![License](https://img.shields.io/badge/license-Apache--2.0-blue)](LICENSE)
7
7
 
8
- ## 📋 Descripción
8
+ ## 📋 Description
9
9
 
10
- **AI-PIP (AI Prompt Integrity Protocol)** es un protocolo de seguridad de múltiples capas diseñado para proteger sistemas de IA contra prompt injection y manipulación maliciosa de contexto.
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
- Este paquete contiene la implementación **core** del protocolo, que incluye funciones puras, value objects inmutables y contratos semánticos entre capas.
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
- ## 🏗️ Arquitectura
14
+ ## 🏗️ Architecture
15
15
 
16
- El protocolo AI-PIP está compuesto por las siguientes capas:
16
+ The AI-PIP protocol is composed of the following layers:
17
17
 
18
- ### ✅ Capas Implementadas
18
+ ### ✅ Implemented Layers
19
19
 
20
- - **CSL (Context Segmentation Layer)**: Segmenta y clasifica contenido según su origen
21
- - **ISL (Instruction Sanitization Layer)**: Sanitiza instrucciones según nivel de confianza
22
- - **CPE (Cryptographic Prompt Envelope)**: Genera envoltorio criptográfico con firma HMAC-SHA256
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 Compartidas
24
+ ### 🔧 Shared Features
25
25
 
26
- - **Shared**: Funciones compartidas y linaje global e incremental (no es una capa, son features compartidas entre capas)
26
+ - **Shared**: Shared functions and global incremental lineage (not a layer, but features shared between layers)
27
27
 
28
- ### 📝 Nota sobre AAL y Model Gateway
28
+ ### 📝 Note on AAL and Model Gateway
29
29
 
30
- **AAL (Agent Action Lock)** y **Model Gateway** son componentes del SDK, no del core semántico. El core semántico se enfoca en funciones puras y señales, mientras que estas capas requieren decisiones operativas y efectos secundarios que pertenecen a la implementación (SDK).
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
- ## 📦 Instalación
32
+ ## 📦 Installation
33
33
 
34
34
  ```bash
35
35
  pnpm add @ai-pip/core
36
- # o
36
+ # or
37
37
  npm install @ai-pip/core
38
- # o
38
+ # or
39
39
  yarn add @ai-pip/core
40
40
  ```
41
41
 
42
- ## 🚀 Uso Básico
42
+ ## 🚀 Basic Usage
43
43
 
44
- ### Importar desde el paquete principal
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
- ### Ejemplo Completo
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. Segmentar contenido (CSL)
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. Sanitizar contenido (ISL)
64
+ // 2. Sanitize content (ISL)
65
65
  const islResult: ISLResult = sanitize(cslResult)
66
66
 
67
- // 3. Generar envelope criptográfico (CPE)
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 contiene el prompt protegido
71
+ // cpeResult.envelope contains the protected prompt
72
72
  console.log(JSON.stringify(cpeResult, null, 2))
73
73
  ```
74
74
 
75
- ### Ejemplo con funciones adicionales
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
- // Clasificar un source
94
+ // Classify a source
95
95
  const trust = classifySource('UI' as Source)
96
96
 
97
- // Agregar entrada de linaje
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
- // Generar nonce
103
+ // Generate nonce
104
104
  const nonce = createNonce()
105
105
  ```
106
106
 
107
- ## 📚 Documentación
107
+ ## 📚 Documentation
108
108
 
109
- ### Documentación de Capas
109
+ All AI-PIP protocol documentation is centralized in the [documentation repository](https://github.com/AI-PIP/ai-pip-docs):
110
110
 
111
- - **[CSL - Context Segmentation Layer](docs/layer/csl.md)**: Documentación completa de la capa de segmentación
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
- - **[Shared - Features Compartidas](docs/layer/shared.md)**: Funciones compartidas y linaje global
117
+ ### Core Documentation
117
118
 
118
- ### Documentación General
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
- - **[Whitepaper](docs/whitepaper.md)**: Especificación técnica completa del protocolo AI-PIP
121
- - **[Roadmap](docs/roadmap.md)**: Plan de desarrollo y evolución del protocolo
122
- - **[Arquitectura](docs/architecture.md)**: Arquitectura semántica del protocolo
123
- - **[SDK Reference](docs/SDK.md)**: Referencia para desarrollo de SDKs
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
- # Ejecutar tests
138
+ # Run tests
129
139
  pnpm test
130
140
 
131
- # Tests en modo watch
141
+ # Tests in watch mode
132
142
  pnpm test:watch
133
143
 
134
- # Tests con cobertura
144
+ # Tests with coverage
135
145
  pnpm test:coverage
136
146
 
137
- # UI de tests
147
+ # Test UI
138
148
  pnpm test:ui
139
149
  ```
140
150
 
141
- **Cobertura actual**: 87%
151
+ **Current coverage**: 87%
142
152
 
143
- ## 🔧 Desarrollo
153
+ ## 🔧 Development
144
154
 
145
155
  ```bash
146
- # Instalar dependencias
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
- # Desarrollo
165
+ # Development
156
166
  pnpm dev
157
167
  ```
158
168
 
159
- ## 📋 Requisitos
169
+ ## 📋 Requirements
160
170
 
161
171
  ### Runtime
162
172
  - **Node.js**: >= 18.0.0
163
- - **pnpm**: >= 8.0.0 (recomendado) o npm/yarn
173
+ - **pnpm**: >= 8.0.0 (recommended) or npm/yarn
164
174
 
165
- ### TypeScript ⚠️ **REQUERIDO**
175
+ ### TypeScript ⚠️ **REQUIRED**
166
176
 
167
- Este paquete utiliza ESM (`"type": "module"`) y exports con subpaths. Para que TypeScript resuelva correctamente los imports y tipos, tu proyecto **DEBE** tener la siguiente configuración en `tsconfig.json`:
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
- **Configuración mínima requerida:**
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
- **⚠️ CRÍTICO**: Sin esta configuración, obtendrás errores como:
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
- - Los tipos no se resolverán correctamente
194
+ - Types will not resolve correctly
185
195
 
186
- #### Ejemplo de `tsconfig.json` completo recomendado
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
- #### Notas importantes
213
+ #### Important notes
204
214
 
205
- - **Desde la versión 0.1.2+**: Esta configuración es obligatoria. Las versiones anteriores (0.1.0, 0.1.1) están deprecadas.
206
- - **Si usas `tsx` o `ts-node`**: Aunque ejecutes TypeScript directamente, **aún necesitas** esta configuración en `tsconfig.json` para que TypeScript resuelva los tipos correctamente.
207
- - **JavaScript puro**: Si usas JavaScript sin TypeScript, no necesitas esta configuración, pero perderás el soporte de tipos.
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
- ## 📄 Licencia
219
+ ## 📄 License
210
220
 
211
- Apache-2.0 - Ver [LICENSE](LICENSE) para más detalles.
221
+ Apache-2.0 - See [LICENSE](LICENSE) for more details.
212
222
 
213
- ## 🤝 Contribuir
223
+ ## 🤝 Contributing
214
224
 
215
- Las contribuciones son bienvenidas. Por favor:
225
+ Contributions are welcome. Please:
216
226
 
217
- 1. Revisa el [Roadmap](docs/roadmap.md) para ver qué está pendiente
218
- 2. Abre un issue para discutir cambios mayores
219
- 3. Envía un pull request con tus mejoras
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
- **Repositorio**: https://github.com/AI-PIP/ai-pip-core
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
- ## 🔗 Enlaces
234
+ ## 🔗 Links
225
235
 
226
- - **Documentación**: [docs/](docs/)
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
- ## 🔮 Mejoras Futuras
240
+ ## 🔮 Future Improvements
231
241
 
232
- ### Imports por Capa Específica
242
+ ### Imports by Specific Layer
233
243
 
234
- Actualmente, se recomienda importar desde el paquete principal (`@ai-pip/core`) para evitar confusiones con nombres similares entre capas. En futuras versiones, se mejorará el soporte para imports directos desde capas específicas:
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
- // Futuro (en desarrollo)
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
- Esto permitirá:
244
- - **Mejor organización**: Importar solo lo necesario de cada capa
245
- - **Evitar conflictos**: Prevenir confusiones con funciones de nombres similares
246
- - **Tree-shaking mejorado**: Los bundlers podrán eliminar código no usado más eficientemente
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
- **Nota**: Los exports por capa están técnicamente disponibles, pero se recomienda usar el paquete principal hasta que se complete la optimización de resolución de módulos.
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.5] - 2025-12-28
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
- **Problemas conocidos**:
344
- - Errores: `ERR_PACKAGE_PATH_NOT_EXPORTED` al importar subpaths
345
- - Exports incompletos: Faltaba el campo `default` en los exports
346
- - Path aliases no funcionaban correctamente
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
- **Recomendación**: Actualizar a `0.1.3` o superior.
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
- #### 📦 Contenido inicial
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
- **Versión actual**: 0.1.5
358
- **Estado**: Fase 1 - Capas Core (100% completado)
277
+ **Current Version**: 0.1.7
278
+ **Status**: Phase 1 - Core Layers (100% completed)
@@ -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,cAAc,CAAA;AAC7C,OAAO,KAAK,EAAc,SAAS,EAAE,MAAM,SAAS,CAAA;AAUpD,wBAAgB,QAAQ,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,CAwE3E"}
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"}
@@ -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 {