avantgate 1.7.0 β†’ 1.8.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/README.md CHANGED
@@ -86,17 +86,12 @@ Contact our team at [contact@gatewall.fr](mailto:contact@gatewall.fr) for privat
86
86
 
87
87
  ## πŸš€ Key Security & Defense Features
88
88
 
89
- - πŸ›‘οΈ **Active Threat Defense & Prompt Guardrails**: Blocks prompt injections, DAN jailbreaks, adversarial noise, and system prompt exfiltration *before* external API invocation.
90
- - πŸ”’ **Zero-Egress Data Loss Prevention (DLP)**: Automated local redaction of emails, phone numbers, IBAN/BIC, and French/EU identifiers (NIR SSN, SPI tax ID) before network egress.
91
- - ⚑ **Deterministic Workflow Engine (`avantgate/workflow`)**: In-process sequential state machine for multi-step agent orchestrations. Features automatic reverse compensation (Saga Pattern), non-blocking Human-in-the-Loop checkpoints, and safe-by-default AI tool conversion (`asTool()`).
92
- - 🎭 **Dual-Channel Tool Isolation (`avantgate/agent`)**: Decouples sensitive database records (streamed out-of-band directly to client UIs) from minimal cognitive LLM context (`llmDto`), keeping confidential fields out of context windows.
93
- - πŸ›‘ **Anti-IDOR & Multi-Tenant Defense**: Strict Row-Level Security, compile-time tenant tool enforcement (`createTenantTool`), post-fetch runtime assertions (`assertTenant`, `assertOwnership`), and native RBAC authorization at the agent tool boundary. See the [Anti-IDOR Architecture Guide](docs/anti-idor.md).
94
- - πŸ’° **Denial-of-Wallet & Pre-Flight Budgeting**: Enforces strict token and cent-level USD budget limits, rejecting abusive requests before paying for upstream inference.
95
- - πŸ”€ **Zero-Downtime Multi-Model Failover**: Seamless client-side failover to fallback providers (or local zero-cost Ollama) when upstream APIs return HTTP 429/500 errors.
96
- - πŸ”§ **Self-Repairing Structured Outputs**: Strict Zod schema compliance with automated heuristic markdown/JSON repair if the model hallucinates formatting.
97
- - πŸ“‘ **Zero-Dependency Telemetry Bridge (`HttpTelemetryExporter`, `PlatformStorageAdapter`)**: Mirror execution audits and hierarchical tool traces asynchronously without adding heavy external dependencies.
98
- - 🌐 **Lightweight Front-End SDK & React Hook (`avantgate/client`)**: Micro-bundle (< 1.7 KB gzipped) for browser UIs. Captures client-side security alerts (blocked API keys, prompt injection attempts), UI render metrics, and user feedback, streaming them directly to gateWall via `fetch(keepalive)` without loading backend infrastructure.
99
- - πŸ“¦ **100% Framework Agnostic**: Works seamlessly in Next.js, Express, Fastify, NestJS, Cloudflare Workers, AWS Lambda, or CLI scripts.
89
+ | Pillar | Core Capabilities & Architecture |
90
+ |---|---|
91
+ | πŸ›‘οΈ **AI-WAF & Privacy** | β€’ **Prompt Guardrails**: Blocks prompt injections, jailbreaks & exfiltration *pre-flight*.<br/>β€’ **Zero-Egress DLP**: In-process redaction of emails, phone numbers, IBANs & EU tax IDs.<br/>β€’ **Self-Repairing Outputs**: Native Zod validation with automatic JSON heuristic repair. |
92
+ | πŸ›‘ **Agent Isolation & Anti-IDOR** | β€’ **Dual-Channel DTOs**: Streams full records to UI while injecting sanitized summaries into LLM.<br/>β€’ **Anti-IDOR Boundary**: Compile-time tenant scoping (`createTenantTool`) & runtime ownership checks.<br/>β€’ **Infinite Loop Shield**: Detects and breaks recursive agent tool execution loops. |
93
+ | πŸ’° **FinOps & Resilience** | β€’ **Denial-of-Wallet**: Enforces hard token & USD budgets *before* external inference spend.<br/>β€’ **Multi-Model Failover**: Instant client-side routing to fallback models or local Ollama on 429/500.<br/>β€’ **Live Cost Ledger**: Token burn calculation & pricing adapters with zero external DB. |
94
+ | ⚑ **Sagas & Telemetry** | β€’ **Deterministic Sagas (`avantgate/workflow`)**: In-process FSM with automatic reverse compensation ($k-1 \to 0$).<br/>β€’ **Human-in-the-Loop (HITL)**: Non-blocking suspension & approval queues for high-risk tools.<br/>β€’ **Lightweight Telemetry (`avantgate/client`)**: < 1.7 KB client SDK & async audit bridge to GateWall. |
100
95
 
101
96
  ---
102
97
 
@@ -153,19 +148,6 @@ yarn add avantgate zod
153
148
 
154
149
  ---
155
150
 
156
- ## πŸ“– Documentation & Guides
157
-
158
- Comprehensive guides, copy-pasteable integration recipes, and architectural references are available in the dedicated documentation:
159
-
160
- | Guide | Description |
161
- |---|---|
162
- | **[Deterministic Workflow Engine](docs/workflow.md)** | Zero-infra Saga orchestrator, linear FSM rationale, reverse compensation, HITL checkpoints & agent tool conversion. |
163
- | **[Code Examples & Recipes](docs/examples.md)** | End-to-end security guardrails, PII redaction, anti-IDOR tool boundaries, cost tracking, Zod self-repair, and multi-model failover. |
164
- | **[Decoupled Pricing & DB Adapters](docs/pricing.md)** | Dynamic token pricing, database integration (Prisma / PostgreSQL / Drizzle), in-memory TTL caching, and runtime overrides. |
165
- | **[Durable Agent Harness & Tool Isolation](docs/agent.md)** | Serverless durable step execution, Human-in-the-Loop suspension, dual-channel DTO tool isolation, and telemetry streaming. |
166
-
167
- ---
168
-
169
151
  ## πŸ—οΈ Architecture & Extensibility
170
152
 
171
153
  AvantGate is built around clean **Ports and Adapters**:
@@ -177,41 +159,7 @@ AvantGate is built around clean **Ports and Adapters**:
177
159
 
178
160
  ## πŸ—ΊοΈ Roadmap & Milestones
179
161
 
180
- ### 🎯 Core Control Plane (`avantgate`)
181
-
182
- 1. ⏱️ **In-Process Sliding-Window Rate Limiter & User Quotas**
183
- - In-memory token bucket per User ID, IP address, or session without Redis.
184
- - Per-user daily & hourly token budget limits with automatic graceful throttling.
185
-
186
- 2. πŸ”’ **Bidirectional Sanitizer & Secret Leak Prevention**
187
- - Extend PII protection from input queries to **model outputs and audit logs**.
188
- - Active inspection to prevent LLM hallucinations from leaking server credentials, environment variables (`sk-...`, JWTs), or raw system instructions to client frontends.
189
-
190
- 3. ⚑ **Spend Velocity Circuit Breaker & Exponential Backoff**
191
- - Real-time spend velocity detection (trips if spend exceeds $X within Y minutes).
192
- - Configurable exponential backoff retries before triggering provider failover.
193
- - Safe degradation returning user-friendly messages instead of raw provider crashes.
194
-
195
- 4. βš–οΈ **Real-Time Evaluation Quality Gates**
196
- - Replace gut-feel and vibe-based evaluations with in-process, measurable output quality gates.
197
- - Built-in sub-millisecond heuristic gates:
198
- - **Refusal & Boilerplate Gate**: Detects unwanted refusal phrasing (*"As an AI..."*) and triggers fallback.
199
- - **Context Grounding Gate**: Verifies factual entity containment against supplied reference text.
200
- - Automated corrective retry loop (`onFailure: "retry_with_feedback"`) or instant model failover.
201
-
202
- 5. πŸ”Œ **Lifecycle Middleware Hooks (`beforeRequest`, `afterResponse`)**
203
- - Extensible middleware pipeline to inspect, enrich, or modify prompts and completions without modifying core logic.
204
- - Universal hook allowing any external RAG system or context engine to compose with AvantGate seamlessly.
205
-
206
- 6. πŸš€ **One-Line Launch-Safe Presets (`PRESETS.LAUNCH_SAFE`)**
207
- - Zero-config hardened setup with sensible defaults for security, budgets, and failovers.
208
-
209
- ### πŸ“¦ Modular Ecosystem & Extensions
210
-
211
- - **`avantgate/workflow`**: Deterministic sequential state machine, automatic reverse Saga rollback ($k-1 \to 0$), and durable HITL checkpoints.
212
- - **`avantgate/agent`**: Zero-infra durable step orchestration, human-in-the-loop pauses, and dual-channel PII tool isolation.
213
- - **`avantgate/finance`**: Zero-overhead financial accounting normalizer across international jurisdictions (FR PCG, US GAAP, UK IFRS, Swiss CO).
214
- - **Launch Readiness Linter**: Standalone developer tool to audit codebases before launch for exposed keys, unbudgeted endpoints, and missing guards.
162
+ Interested in upcoming features (output DLP & secret leak guard, lifecycle hooks, launch-safe presets) or release history See [**ROADMAP.md**](ROADMAP.md).
215
163
 
216
164
  ---
217
165
 
@@ -8,6 +8,7 @@ export declare class AvantGateControlLayer {
8
8
  private findProviderConfig;
9
9
  private calculateCost;
10
10
  private applySecurityGuards;
11
+ private applyOutputSecurityGuards;
11
12
  private checkPreflightBudget;
12
13
  private checkPostExecutionBudget;
13
14
  private buildMessages;
@@ -1 +1 @@
1
- {"version":3,"file":"control-layer.d.ts","sourceRoot":"","sources":["../src/control-layer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KA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AAS,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,gBAAgB,CAAC,EAAE,eAAe,CAAC;KACpC,KAAG,OAAO,CAAC,eAAe,CAAC,CA2B1B;IAEF;;OAEG;IACH,iBAAiB,GAAU,CAAC,EAAE,SAAS;QACrC,SAAS,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,gBAAgB,CAAC,EAAE,eAAe,CAAC;KACpC,KAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,CAyBvC;IAEF;;;OAGG;IACH,wBAAwB,GAAU,CAAC,EACjC,SAAS,+BAA+B,CAAC,CAAC,CAAC,KAC1C,OAAO,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,CAuHtC;CACH;AAED,eAAO,MAAM,qBAAqB,GAAI,QAAQ,kBAAkB,KAAG,qBAElE,CAAC;AAEF,eAAO,MAAM,eAAe,WAJkB,kBAAkB,KAAG,qBAIf,CAAC;AACrD,OAAO,EAAE,qBAAqB,IAAI,kBAAkB,EAAE,CAAC"}
package/dist/index.d.ts CHANGED
@@ -8,4 +8,5 @@ export * from "./control-layer";
8
8
  export * from "./prompts";
9
9
  export * from "./providers/http-client";
10
10
  export * from "./workflow";
11
+ export * from "./secret-guard";
11
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,yBAAyB,CAAC;AACxC,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,yBAAyB,CAAC;AACxC,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -33,6 +33,7 @@ __export(index_exports, {
33
33
  AvantGateBudgetExceededError: () => BudgetExceededError,
34
34
  AvantGateConfigurationError: () => ConfigurationError,
35
35
  AvantGateControlLayer: () => AvantGateControlLayer,
36
+ AvantGateSecretLeakBlockedError: () => SecretLeakBlockedError,
36
37
  BudgetExceededError: () => BudgetExceededError,
37
38
  CachedPricingAdapter: () => CachedPricingAdapter,
38
39
  ConfigurationError: () => ConfigurationError,
@@ -43,11 +44,13 @@ __export(index_exports, {
43
44
  PromptRegistry: () => PromptRegistry,
44
45
  PromptTemplate: () => PromptTemplate,
45
46
  SEED_MODEL_PRICES: () => SEED_MODEL_PRICES,
47
+ SecretLeakBlockedError: () => SecretLeakBlockedError,
46
48
  SqlitePricingAdapter: () => SqlitePricingAdapter,
47
49
  WorkflowAbortSignal: () => WorkflowAbortSignal,
48
50
  WorkflowSagaRollbackError: () => WorkflowSagaRollbackError,
49
51
  WorkflowValidationError: () => WorkflowValidationError,
50
52
  ZenLLMControlLayer: () => AvantGateControlLayer,
53
+ applyOutputGuards: () => applyOutputGuards,
51
54
  calculateCostUSD: () => calculateCostUSD,
52
55
  createAvantGate: () => createAvantGate,
53
56
  createHttpProviderClient: () => createHttpProviderClient,
@@ -59,6 +62,7 @@ __export(index_exports, {
59
62
  resolveModelPrice: () => resolveModelPrice,
60
63
  resolveModelPriceAsync: () => resolveModelPriceAsync,
61
64
  sanitizePII: () => sanitizePII,
65
+ sanitizeSecrets: () => sanitizeSecrets,
62
66
  validateUserInput: () => validateUserInput,
63
67
  validateWithZod: () => validateWithZod
64
68
  });
@@ -77,6 +81,14 @@ var BudgetExceededError = class extends Error {
77
81
  this.name = "BudgetExceededError";
78
82
  }
79
83
  };
84
+ var SecretLeakBlockedError = class extends Error {
85
+ detections;
86
+ constructor(message, detections) {
87
+ super(message);
88
+ this.name = "SecretLeakBlockedError";
89
+ this.detections = detections;
90
+ }
91
+ };
80
92
 
81
93
  // src/sqlite-pricing-adapter.ts
82
94
  var import_fs = __toESM(require("fs"));
@@ -1160,6 +1172,109 @@ var createHttpProviderClient = (config) => {
1160
1172
  return new HttpProviderClient(config);
1161
1173
  };
1162
1174
 
1175
+ // src/secret-guard.ts
1176
+ var SECRET_PATTERNS = [
1177
+ // 1. ClΓ©s privΓ©es (RSA, OpenSSH, EC, DSA)
1178
+ {
1179
+ type: "PRIVATE_KEY",
1180
+ regex: /-----BEGIN (?:[A-Z0-9_-]+ )?PRIVATE KEY-----[\s\S]*?-----END (?:[A-Z0-9_-]+ )?PRIVATE KEY-----/g,
1181
+ mask: "[REDACTED_PRIVATE_KEY]"
1182
+ },
1183
+ // 2. ClΓ©s Anthropic Claude (avant OpenAI pour Γ©viter collision sk-)
1184
+ {
1185
+ type: "ANTHROPIC_API_KEY",
1186
+ regex: /\bsk-ant-(?:api\d{2}-)?[A-Za-z0-9_-]{20,}\b/g,
1187
+ mask: "[REDACTED_ANTHROPIC_KEY]"
1188
+ },
1189
+ // 3. ClΓ©s OpenAI (standard, projet, admin) - exclut explicitement sk-ant-
1190
+ {
1191
+ type: "OPENAI_API_KEY",
1192
+ regex: /\bsk-(?!ant-)(?:proj-|admin-|org-)?[A-Za-z0-9_-]{20,}\b/g,
1193
+ mask: "[REDACTED_OPENAI_KEY]"
1194
+ },
1195
+ // 4. ClΓ©s AWS Access Key ID
1196
+ {
1197
+ type: "AWS_ACCESS_KEY",
1198
+ regex: /\b(?:AKIA|ABIA|ACCA|ASIA)[0-9A-Z]{16}\b/g,
1199
+ mask: "[REDACTED_AWS_KEY]"
1200
+ },
1201
+ // 5. Tokens GitHub (Personal, OAuth, User, Server)
1202
+ {
1203
+ type: "GITHUB_TOKEN",
1204
+ regex: /\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9_]{36,255}\b/g,
1205
+ mask: "[REDACTED_GITHUB_TOKEN]"
1206
+ },
1207
+ // 6. JSON Web Tokens (JWT)
1208
+ {
1209
+ type: "JWT_TOKEN",
1210
+ regex: /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9._-]{10,}\.[A-Za-z0-9._-]{10,}\b/g,
1211
+ mask: "[REDACTED_JWT]"
1212
+ },
1213
+ // 7. Tokens Slack
1214
+ {
1215
+ type: "SLACK_TOKEN",
1216
+ regex: /\bxox[baprs]-[0-9]{10,13}-[0-9]{10,13}-[a-zA-Z0-9]{24,}\b/g,
1217
+ mask: "[REDACTED_SLACK_TOKEN]"
1218
+ },
1219
+ // 8. Mots de passe dans URL de connexion (Postgres, Mongo, Redis, MySQL)
1220
+ {
1221
+ type: "DATABASE_CONNECTION_SECRET",
1222
+ regex: /(?:postgres|postgresql|mysql|mongodb(?:\+srv)?|redis|amqp):\/\/[^:\s\/@]+:([^@\s]+)@/gi,
1223
+ mask: "[REDACTED_DB_SECRET]"
1224
+ }
1225
+ ];
1226
+ var sanitizeSecrets = (input) => {
1227
+ let text = input;
1228
+ const detections = [];
1229
+ for (const pattern of SECRET_PATTERNS) {
1230
+ let matchCount = 0;
1231
+ if (pattern.type === "DATABASE_CONNECTION_SECRET") {
1232
+ text = text.replace(pattern.regex, (fullMatch, password) => {
1233
+ matchCount++;
1234
+ return fullMatch.replace(password, pattern.mask);
1235
+ });
1236
+ } else {
1237
+ text = text.replace(pattern.regex, () => {
1238
+ matchCount++;
1239
+ return pattern.mask;
1240
+ });
1241
+ }
1242
+ if (matchCount > 0) {
1243
+ detections.push({ type: pattern.type, matchedCount: matchCount });
1244
+ }
1245
+ }
1246
+ return {
1247
+ text,
1248
+ hasSecrets: detections.length > 0,
1249
+ detections
1250
+ };
1251
+ };
1252
+ var applyOutputGuards = (rawOutput, options) => {
1253
+ let currentText = rawOutput;
1254
+ let piiCount = 0;
1255
+ if (options?.maskPII) {
1256
+ const piiResult = sanitizePII(currentText);
1257
+ currentText = piiResult.text;
1258
+ piiCount = piiResult.maskedCount;
1259
+ }
1260
+ const secretResult = sanitizeSecrets(currentText);
1261
+ currentText = secretResult.text;
1262
+ if (secretResult.hasSecrets && options?.secretLeakAction === "BLOCK") {
1263
+ const types = secretResult.detections.map((d) => d.type).join(", ");
1264
+ throw new SecretLeakBlockedError(
1265
+ `[AvantGate Output Guard] Response blocked: detected potential secret leak (${types})`,
1266
+ secretResult.detections
1267
+ );
1268
+ }
1269
+ return {
1270
+ text: currentText,
1271
+ sanitized: piiCount > 0 || secretResult.hasSecrets,
1272
+ secretDetected: secretResult.hasSecrets,
1273
+ piiMaskedCount: piiCount,
1274
+ detections: secretResult.detections
1275
+ };
1276
+ };
1277
+
1163
1278
  // src/control-layer.ts
1164
1279
  var AvantGateControlLayer = class {
1165
1280
  config;
@@ -1225,6 +1340,19 @@ var AvantGateControlLayer = class {
1225
1340
  }
1226
1341
  return userQuery;
1227
1342
  };
1343
+ applyOutputSecurityGuards = (rawOutput) => {
1344
+ const isDlpEnabled = this.config.security?.outputDLP ?? this.config.security?.maskPII ?? false;
1345
+ const shouldCheckSecrets = this.config.security?.blockSecretLeaks ?? true;
1346
+ if (!isDlpEnabled && !shouldCheckSecrets) {
1347
+ return rawOutput;
1348
+ }
1349
+ const guardResult = applyOutputGuards(rawOutput, {
1350
+ maskPII: isDlpEnabled,
1351
+ blockSecretLeaks: shouldCheckSecrets,
1352
+ secretLeakAction: this.config.security?.secretLeakAction ?? "REDACT"
1353
+ });
1354
+ return guardResult.text;
1355
+ };
1228
1356
  checkPreflightBudget = async (estimatedPromptTokens, targetModel, provider) => {
1229
1357
  if (this.config.maxTokenBudget !== void 0 && estimatedPromptTokens > this.config.maxTokenBudget) {
1230
1358
  throw new BudgetExceededError(
@@ -1350,6 +1478,7 @@ var AvantGateControlLayer = class {
1350
1478
  throw lastError;
1351
1479
  };
1352
1480
  assembleResult = (output) => {
1481
+ const sanitizedText = this.applyOutputSecurityGuards(output.responseText);
1353
1482
  const costUSD = this.calculateCost(
1354
1483
  output.modelUsed,
1355
1484
  output.usage.promptTokens,
@@ -1357,7 +1486,7 @@ var AvantGateControlLayer = class {
1357
1486
  output.usage.promptCacheHitTokens ?? 0
1358
1487
  );
1359
1488
  return {
1360
- text: output.responseText,
1489
+ text: sanitizedText,
1361
1490
  tokens: {
1362
1491
  prompt: output.usage.promptTokens,
1363
1492
  completion: output.usage.completionTokens,
@@ -1496,10 +1625,11 @@ var AvantGateControlLayer = class {
1496
1625
  }
1497
1626
  accumulatedPromptTokens += attemptPromptTokens;
1498
1627
  accumulatedCompletionTokens += attemptCompletionTokens;
1628
+ const sanitizedResponse = this.applyOutputSecurityGuards(responseText);
1499
1629
  const isFinancial = options.financialNormalizer ?? Boolean(
1500
1630
  this.config.features?.finance?.enableFrenchAccounting || this.config.features?.finance
1501
1631
  );
1502
- const parsedData = validateWithZod(responseText, options.schema, {
1632
+ const parsedData = validateWithZod(sanitizedResponse, options.schema, {
1503
1633
  financialNormalizer: isFinancial,
1504
1634
  jurisdiction: this.config.features?.finance?.jurisdiction
1505
1635
  });
@@ -1508,7 +1638,7 @@ var AvantGateControlLayer = class {
1508
1638
  this.checkPostExecutionBudget(totalTokens, costUSD);
1509
1639
  const result = {
1510
1640
  data: parsedData,
1511
- rawText: responseText,
1641
+ rawText: sanitizedResponse,
1512
1642
  tokens: {
1513
1643
  prompt: accumulatedPromptTokens,
1514
1644
  completion: accumulatedCompletionTokens,
@@ -2449,6 +2579,7 @@ var defineWorkflow = (config) => {
2449
2579
  AvantGateBudgetExceededError,
2450
2580
  AvantGateConfigurationError,
2451
2581
  AvantGateControlLayer,
2582
+ AvantGateSecretLeakBlockedError,
2452
2583
  BudgetExceededError,
2453
2584
  CachedPricingAdapter,
2454
2585
  ConfigurationError,
@@ -2459,11 +2590,13 @@ var defineWorkflow = (config) => {
2459
2590
  PromptRegistry,
2460
2591
  PromptTemplate,
2461
2592
  SEED_MODEL_PRICES,
2593
+ SecretLeakBlockedError,
2462
2594
  SqlitePricingAdapter,
2463
2595
  WorkflowAbortSignal,
2464
2596
  WorkflowSagaRollbackError,
2465
2597
  WorkflowValidationError,
2466
2598
  ZenLLMControlLayer,
2599
+ applyOutputGuards,
2467
2600
  calculateCostUSD,
2468
2601
  createAvantGate,
2469
2602
  createHttpProviderClient,
@@ -2475,6 +2608,7 @@ var defineWorkflow = (config) => {
2475
2608
  resolveModelPrice,
2476
2609
  resolveModelPriceAsync,
2477
2610
  sanitizePII,
2611
+ sanitizeSecrets,
2478
2612
  validateUserInput,
2479
2613
  validateWithZod
2480
2614
  });
package/dist/index.mjs CHANGED
@@ -30,6 +30,14 @@ var BudgetExceededError = class extends Error {
30
30
  this.name = "BudgetExceededError";
31
31
  }
32
32
  };
33
+ var SecretLeakBlockedError = class extends Error {
34
+ detections;
35
+ constructor(message, detections) {
36
+ super(message);
37
+ this.name = "SecretLeakBlockedError";
38
+ this.detections = detections;
39
+ }
40
+ };
33
41
 
34
42
  // src/sqlite-pricing-adapter.ts
35
43
  import fs from "fs";
@@ -554,6 +562,109 @@ var createHttpProviderClient = (config) => {
554
562
  return new HttpProviderClient(config);
555
563
  };
556
564
 
565
+ // src/secret-guard.ts
566
+ var SECRET_PATTERNS = [
567
+ // 1. ClΓ©s privΓ©es (RSA, OpenSSH, EC, DSA)
568
+ {
569
+ type: "PRIVATE_KEY",
570
+ regex: /-----BEGIN (?:[A-Z0-9_-]+ )?PRIVATE KEY-----[\s\S]*?-----END (?:[A-Z0-9_-]+ )?PRIVATE KEY-----/g,
571
+ mask: "[REDACTED_PRIVATE_KEY]"
572
+ },
573
+ // 2. ClΓ©s Anthropic Claude (avant OpenAI pour Γ©viter collision sk-)
574
+ {
575
+ type: "ANTHROPIC_API_KEY",
576
+ regex: /\bsk-ant-(?:api\d{2}-)?[A-Za-z0-9_-]{20,}\b/g,
577
+ mask: "[REDACTED_ANTHROPIC_KEY]"
578
+ },
579
+ // 3. ClΓ©s OpenAI (standard, projet, admin) - exclut explicitement sk-ant-
580
+ {
581
+ type: "OPENAI_API_KEY",
582
+ regex: /\bsk-(?!ant-)(?:proj-|admin-|org-)?[A-Za-z0-9_-]{20,}\b/g,
583
+ mask: "[REDACTED_OPENAI_KEY]"
584
+ },
585
+ // 4. ClΓ©s AWS Access Key ID
586
+ {
587
+ type: "AWS_ACCESS_KEY",
588
+ regex: /\b(?:AKIA|ABIA|ACCA|ASIA)[0-9A-Z]{16}\b/g,
589
+ mask: "[REDACTED_AWS_KEY]"
590
+ },
591
+ // 5. Tokens GitHub (Personal, OAuth, User, Server)
592
+ {
593
+ type: "GITHUB_TOKEN",
594
+ regex: /\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9_]{36,255}\b/g,
595
+ mask: "[REDACTED_GITHUB_TOKEN]"
596
+ },
597
+ // 6. JSON Web Tokens (JWT)
598
+ {
599
+ type: "JWT_TOKEN",
600
+ regex: /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9._-]{10,}\.[A-Za-z0-9._-]{10,}\b/g,
601
+ mask: "[REDACTED_JWT]"
602
+ },
603
+ // 7. Tokens Slack
604
+ {
605
+ type: "SLACK_TOKEN",
606
+ regex: /\bxox[baprs]-[0-9]{10,13}-[0-9]{10,13}-[a-zA-Z0-9]{24,}\b/g,
607
+ mask: "[REDACTED_SLACK_TOKEN]"
608
+ },
609
+ // 8. Mots de passe dans URL de connexion (Postgres, Mongo, Redis, MySQL)
610
+ {
611
+ type: "DATABASE_CONNECTION_SECRET",
612
+ regex: /(?:postgres|postgresql|mysql|mongodb(?:\+srv)?|redis|amqp):\/\/[^:\s\/@]+:([^@\s]+)@/gi,
613
+ mask: "[REDACTED_DB_SECRET]"
614
+ }
615
+ ];
616
+ var sanitizeSecrets = (input) => {
617
+ let text = input;
618
+ const detections = [];
619
+ for (const pattern of SECRET_PATTERNS) {
620
+ let matchCount = 0;
621
+ if (pattern.type === "DATABASE_CONNECTION_SECRET") {
622
+ text = text.replace(pattern.regex, (fullMatch, password) => {
623
+ matchCount++;
624
+ return fullMatch.replace(password, pattern.mask);
625
+ });
626
+ } else {
627
+ text = text.replace(pattern.regex, () => {
628
+ matchCount++;
629
+ return pattern.mask;
630
+ });
631
+ }
632
+ if (matchCount > 0) {
633
+ detections.push({ type: pattern.type, matchedCount: matchCount });
634
+ }
635
+ }
636
+ return {
637
+ text,
638
+ hasSecrets: detections.length > 0,
639
+ detections
640
+ };
641
+ };
642
+ var applyOutputGuards = (rawOutput, options) => {
643
+ let currentText = rawOutput;
644
+ let piiCount = 0;
645
+ if (options?.maskPII) {
646
+ const piiResult = sanitizePII(currentText);
647
+ currentText = piiResult.text;
648
+ piiCount = piiResult.maskedCount;
649
+ }
650
+ const secretResult = sanitizeSecrets(currentText);
651
+ currentText = secretResult.text;
652
+ if (secretResult.hasSecrets && options?.secretLeakAction === "BLOCK") {
653
+ const types = secretResult.detections.map((d) => d.type).join(", ");
654
+ throw new SecretLeakBlockedError(
655
+ `[AvantGate Output Guard] Response blocked: detected potential secret leak (${types})`,
656
+ secretResult.detections
657
+ );
658
+ }
659
+ return {
660
+ text: currentText,
661
+ sanitized: piiCount > 0 || secretResult.hasSecrets,
662
+ secretDetected: secretResult.hasSecrets,
663
+ piiMaskedCount: piiCount,
664
+ detections: secretResult.detections
665
+ };
666
+ };
667
+
557
668
  // src/control-layer.ts
558
669
  var AvantGateControlLayer = class {
559
670
  config;
@@ -619,6 +730,19 @@ var AvantGateControlLayer = class {
619
730
  }
620
731
  return userQuery;
621
732
  };
733
+ applyOutputSecurityGuards = (rawOutput) => {
734
+ const isDlpEnabled = this.config.security?.outputDLP ?? this.config.security?.maskPII ?? false;
735
+ const shouldCheckSecrets = this.config.security?.blockSecretLeaks ?? true;
736
+ if (!isDlpEnabled && !shouldCheckSecrets) {
737
+ return rawOutput;
738
+ }
739
+ const guardResult = applyOutputGuards(rawOutput, {
740
+ maskPII: isDlpEnabled,
741
+ blockSecretLeaks: shouldCheckSecrets,
742
+ secretLeakAction: this.config.security?.secretLeakAction ?? "REDACT"
743
+ });
744
+ return guardResult.text;
745
+ };
622
746
  checkPreflightBudget = async (estimatedPromptTokens, targetModel, provider) => {
623
747
  if (this.config.maxTokenBudget !== void 0 && estimatedPromptTokens > this.config.maxTokenBudget) {
624
748
  throw new BudgetExceededError(
@@ -744,6 +868,7 @@ var AvantGateControlLayer = class {
744
868
  throw lastError;
745
869
  };
746
870
  assembleResult = (output) => {
871
+ const sanitizedText = this.applyOutputSecurityGuards(output.responseText);
747
872
  const costUSD = this.calculateCost(
748
873
  output.modelUsed,
749
874
  output.usage.promptTokens,
@@ -751,7 +876,7 @@ var AvantGateControlLayer = class {
751
876
  output.usage.promptCacheHitTokens ?? 0
752
877
  );
753
878
  return {
754
- text: output.responseText,
879
+ text: sanitizedText,
755
880
  tokens: {
756
881
  prompt: output.usage.promptTokens,
757
882
  completion: output.usage.completionTokens,
@@ -890,10 +1015,11 @@ var AvantGateControlLayer = class {
890
1015
  }
891
1016
  accumulatedPromptTokens += attemptPromptTokens;
892
1017
  accumulatedCompletionTokens += attemptCompletionTokens;
1018
+ const sanitizedResponse = this.applyOutputSecurityGuards(responseText);
893
1019
  const isFinancial = options.financialNormalizer ?? Boolean(
894
1020
  this.config.features?.finance?.enableFrenchAccounting || this.config.features?.finance
895
1021
  );
896
- const parsedData = validateWithZod(responseText, options.schema, {
1022
+ const parsedData = validateWithZod(sanitizedResponse, options.schema, {
897
1023
  financialNormalizer: isFinancial,
898
1024
  jurisdiction: this.config.features?.finance?.jurisdiction
899
1025
  });
@@ -902,7 +1028,7 @@ var AvantGateControlLayer = class {
902
1028
  this.checkPostExecutionBudget(totalTokens, costUSD);
903
1029
  const result = {
904
1030
  data: parsedData,
905
- rawText: responseText,
1031
+ rawText: sanitizedResponse,
906
1032
  tokens: {
907
1033
  prompt: accumulatedPromptTokens,
908
1034
  completion: accumulatedCompletionTokens,
@@ -1255,6 +1381,7 @@ export {
1255
1381
  BudgetExceededError as AvantGateBudgetExceededError,
1256
1382
  ConfigurationError as AvantGateConfigurationError,
1257
1383
  AvantGateControlLayer,
1384
+ SecretLeakBlockedError as AvantGateSecretLeakBlockedError,
1258
1385
  BudgetExceededError,
1259
1386
  CachedPricingAdapter,
1260
1387
  ConfigurationError,
@@ -1265,11 +1392,13 @@ export {
1265
1392
  PromptRegistry,
1266
1393
  PromptTemplate,
1267
1394
  SEED_MODEL_PRICES,
1395
+ SecretLeakBlockedError,
1268
1396
  SqlitePricingAdapter,
1269
1397
  WorkflowAbortSignal,
1270
1398
  WorkflowSagaRollbackError,
1271
1399
  WorkflowValidationError,
1272
1400
  AvantGateControlLayer as ZenLLMControlLayer,
1401
+ applyOutputGuards,
1273
1402
  calculateCostUSD,
1274
1403
  createAvantGate,
1275
1404
  createHttpProviderClient,
@@ -1281,6 +1410,7 @@ export {
1281
1410
  resolveModelPrice,
1282
1411
  resolveModelPriceAsync,
1283
1412
  sanitizePII,
1413
+ sanitizeSecrets,
1284
1414
  validateUserInput,
1285
1415
  validateWithZod
1286
1416
  };
@@ -0,0 +1,29 @@
1
+ export interface SecretPatternDef {
2
+ type: string;
3
+ regex: RegExp;
4
+ mask: string;
5
+ }
6
+ export interface SecretDetection {
7
+ type: string;
8
+ matchedCount: number;
9
+ }
10
+ export interface SanitizeSecretsResult {
11
+ text: string;
12
+ hasSecrets: boolean;
13
+ detections: SecretDetection[];
14
+ }
15
+ export declare const sanitizeSecrets: (input: string) => SanitizeSecretsResult;
16
+ export interface OutputGuardOptions {
17
+ maskPII?: boolean;
18
+ blockSecretLeaks?: boolean;
19
+ secretLeakAction?: "REDACT" | "BLOCK";
20
+ }
21
+ export interface OutputGuardResult {
22
+ text: string;
23
+ sanitized: boolean;
24
+ secretDetected: boolean;
25
+ piiMaskedCount: number;
26
+ detections: SecretDetection[];
27
+ }
28
+ export declare const applyOutputGuards: (rawOutput: string, options?: OutputGuardOptions) => OutputGuardResult;
29
+ //# sourceMappingURL=secret-guard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secret-guard.d.ts","sourceRoot":"","sources":["../src/secret-guard.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAqDD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,eAAe,EAAE,CAAC;CAC/B;AAED,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,KAAG,qBA4B/C,CAAC;AAEF,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,gBAAgB,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;CACvC;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,eAAe,EAAE,CAAC;CAC/B;AAED,eAAO,MAAM,iBAAiB,GAC5B,WAAW,MAAM,EACjB,UAAU,kBAAkB,KAC3B,iBA+BF,CAAC"}
package/dist/types.d.ts CHANGED
@@ -46,8 +46,19 @@ export declare class ConfigurationError extends Error {
46
46
  export declare class BudgetExceededError extends Error {
47
47
  constructor(message: string);
48
48
  }
49
+ export declare class SecretLeakBlockedError extends Error {
50
+ readonly detections?: Array<{
51
+ type: string;
52
+ matchedCount: number;
53
+ }>;
54
+ constructor(message: string, detections?: Array<{
55
+ type: string;
56
+ matchedCount: number;
57
+ }>);
58
+ }
49
59
  export { ConfigurationError as AvantGateConfigurationError };
50
60
  export { BudgetExceededError as AvantGateBudgetExceededError };
61
+ export { SecretLeakBlockedError as AvantGateSecretLeakBlockedError };
51
62
  export interface ProviderConfig {
52
63
  provider: "deepseek" | "mistral" | "openai" | "ollama" | "openrouter" | "custom";
53
64
  model: string;
@@ -60,6 +71,9 @@ export interface SecurityConfig {
60
71
  detectPromptInjection?: boolean;
61
72
  maskPII?: boolean;
62
73
  maxInputLength?: number;
74
+ outputDLP?: boolean;
75
+ blockSecretLeaks?: boolean;
76
+ secretLeakAction?: "REDACT" | "BLOCK";
63
77
  }
64
78
  export interface RetryConfig {
65
79
  maxRetries?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;IAC/C,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,QAAQ;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,WA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,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE;QACN,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,yBAAyB,CAAC,CAAC;IAC1C,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE;QACN,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,+BAA+B,CAAC,CAAC;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,eAAe,CAAC;IACnC,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "avantgate",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "Zero-infrastructure, in-process AI Application Firewall (AI-WAF) & privacy control plane for TypeScript: real-time prompt guardrails, zero-egress PII redaction, agent tool isolation, anti-IDOR defense, pre-flight token budgets, and multi-model failover.",
5
5
  "author": "Gatewall Team",
6
6
  "license": "MIT",
@@ -82,7 +82,8 @@
82
82
  ],
83
83
  "scripts": {
84
84
  "build": "tsup src/index.ts src/finance/index.ts src/agent/index.ts src/workflow/index.ts src/client/index.ts --format cjs --format esm --clean && tsc --emitDeclarationOnly --outDir dist",
85
- "test": "tsx tests/avantgate.test.ts && tsx tests/preflight-budget.test.ts && tsx tests/sqlite-pricing-adapter.test.ts && tsx tests/financial-normalizer.test.ts && tsx tests/prompt-builder.test.ts && tsx tests/pii-extended.test.ts && npm run test:agent && npm run test:workflow && npm run test:client",
85
+ "test": "tsx tests/avantgate.test.ts && tsx tests/preflight-budget.test.ts && tsx tests/sqlite-pricing-adapter.test.ts && tsx tests/financial-normalizer.test.ts && tsx tests/prompt-builder.test.ts && tsx tests/pii-extended.test.ts && tsx tests/output-dlp-secret-guard.test.ts && npm run test:agent && npm run test:workflow && npm run test:client",
86
+ "test:secrets": "tsx tests/output-dlp-secret-guard.test.ts",
86
87
  "test:pricing": "tsx tests/sqlite-pricing-adapter.test.ts",
87
88
  "test:finance": "tsx tests/financial-normalizer.test.ts",
88
89
  "test:prompts": "tsx tests/prompt-builder.test.ts",