gateia 0.2.0 → 0.2.1

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 (2) hide show
  1. package/README.md +24 -16
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -39,40 +39,48 @@ npm install gateia zod
39
39
 
40
40
  ## ⚡️ Quick Start
41
41
 
42
- Secure a loan processing agent in 30 seconds.
42
+ **Scenario:** You have an AI Customer Support Agent. You need to ensure it **never** promises refunds it can't deliver, and **never** leaks customer PII.
43
43
 
44
44
  ```typescript
45
45
  import { verify } from 'gateia';
46
46
  import { z } from 'zod';
47
47
 
48
- // 1. Define the Business Contract
49
- // The AI *must* return data in this shape.
50
- const LoanDecisionContract = z.object({
51
- approved: z.boolean(),
52
- rate: z.number().min(2.5).max(10.0), // Business Logic
53
- reason: z.string(),
54
- risk_level: z.enum(['low', 'medium', 'high'])
48
+ // 1. Define the "Safe Reply" Contract
49
+ // The AI must generate a Draft Reply that fits this structure.
50
+ const CustomerSupportContract = z.object({
51
+ sentiment: z.enum(['happy', 'neutral', 'angry']),
52
+ reply_text: z.string(),
53
+ ticket_status: z.enum(['open', 'resolved', 'escalated']),
54
+ requires_human_review: z.boolean()
55
55
  });
56
56
 
57
57
  // 2. The Verification Step
58
- // Run this *after* your LLM generates content.
58
+ // Call this *after* obtaining the LLM response, but *before* sending it to the user.
59
59
  const result = await verify({
60
60
  output: llmResponse,
61
- contract: LoanDecisionContract,
62
- policies: ['finance-safe', 'pii-safe', 'secrets-safe'],
61
+ contract: CustomerSupportContract,
62
+ policies: [
63
+ 'finance-safe', // Block any unauthorized refund promises
64
+ 'pii-safe', // Redact any leaked phone numbers/emails
65
+ ],
63
66
  mode: 'enforce'
64
67
  });
65
68
 
66
69
  // 3. Deterministic Decision
67
70
  if (!result.allowed) {
68
- // Blocked. Do not show to user.
69
- console.error("Security Violation:", result.enforcement.violations);
71
+ // 🛑 BLOCKED: The AI tried to say something unsafe.
72
+ // Action: Fallback to a canned response or route to human agent.
73
+ console.warn("Safety Violation:", result.enforcement.violations);
74
+ sendToUser("I'm having trouble retrieving that info. A human will be with you shortly.");
70
75
  } else {
71
- // Safe. Proceed to database/frontend.
72
- console.log("Verified Data:", result.safeOutput);
76
+ // SAFE: The output adheres to your contract and policies.
77
+ // Action: Send the validated reply to the customer.
78
+ console.log("Verified Reply:", result.safeOutput.reply_text);
79
+ sendToUser(result.safeOutput.reply_text);
73
80
  }
74
81
  ```
75
82
 
83
+
76
84
  ---
77
85
 
78
86
  ## 🛡️ Policy Library
@@ -156,4 +164,4 @@ Every call to `verify()` returns a comprehensive `EnforcementReport`. Use this f
156
164
 
157
165
  ## License
158
166
 
159
- MIT
167
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gateia",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "The Deterministic Verification Layer for Enterprise AI.",
5
5
  "keywords": [
6
6
  "ai",