@peac/policy-kit 0.12.5 → 0.12.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 (2) hide show
  1. package/README.md +63 -3
  2. package/package.json +17 -4
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @peac/policy-kit
2
2
 
3
- PEAC Policy Kit - deterministic policy evaluation for CAL semantics
3
+ Deterministic policy evaluation for PEAC Control Abstraction Layer (CAL) semantics. No scripting, no dynamic code.
4
4
 
5
5
  ## Installation
6
6
 
@@ -8,9 +8,69 @@ PEAC Policy Kit - deterministic policy evaluation for CAL semantics
8
8
  pnpm add @peac/policy-kit
9
9
  ```
10
10
 
11
- ## Documentation
11
+ ## What It Does
12
12
 
13
- See [peacprotocol.org](https://www.peacprotocol.org) for full documentation.
13
+ `@peac/policy-kit` provides a file-based policy format (YAML or JSON) with first-match-wins rule semantics for controlling access to resources. It evaluates policies deterministically with no side effects, supports subject matching by type, labels, and ID patterns, and compiles policies into `peac.txt`, `robots.txt`, and AIPREF artifacts. Includes built-in enforcement profiles (strict, balanced, open) and a profile system for reusable policy templates.
14
+
15
+ ## How Do I Use It?
16
+
17
+ ### Load and evaluate a policy
18
+
19
+ ```typescript
20
+ import { loadPolicy, evaluate, isAllowed } from '@peac/policy-kit';
21
+
22
+ const policy = loadPolicy('peac-policy.yaml');
23
+
24
+ const result = evaluate(policy, {
25
+ subject: { type: 'agent', labels: ['verified'] },
26
+ purpose: 'inference',
27
+ licensing_mode: 'subscription',
28
+ });
29
+
30
+ console.log(result.decision); // 'allow', 'deny', or 'review'
31
+ console.log(isAllowed(result)); // true
32
+ ```
33
+
34
+ ### Compile policy to discovery artifacts
35
+
36
+ ```typescript
37
+ import { compilePeacTxt, compileRobotsSnippet, compileAiprefTemplates } from '@peac/policy-kit';
38
+
39
+ const peacTxt = compilePeacTxt(policy);
40
+ const robotsTxt = compileRobotsSnippet(policy);
41
+ const aiprefTemplates = compileAiprefTemplates(policy);
42
+ ```
43
+
44
+ ### Use enforcement profiles for HTTP responses
45
+
46
+ ```typescript
47
+ import { getEnforcementProfile, enforceForHttp } from '@peac/policy-kit';
48
+
49
+ const profile = getEnforcementProfile('balanced');
50
+
51
+ const httpResult = enforceForHttp({
52
+ decision: evaluationResult,
53
+ profile,
54
+ request: { method: 'GET', path: '/content' },
55
+ });
56
+
57
+ console.log(httpResult.statusCode); // 200, 403, etc.
58
+ ```
59
+
60
+ ## Integrates With
61
+
62
+ - `@peac/schema` (Layer 1): Zod schemas for policy validation
63
+ - `@peac/disc`: Discovery document generation from compiled policies
64
+ - `@peac/middleware-express`: HTTP enforcement middleware
65
+ - `@peac/protocol` (Layer 3): Policy binding and digest verification
66
+
67
+ ## For Agent Developers
68
+
69
+ If you are building an AI agent or MCP server that needs evidence receipts:
70
+
71
+ - Start with [`@peac/mcp-server`](https://www.npmjs.com/package/@peac/mcp-server) for a ready-to-use MCP tool server
72
+ - Use `@peac/protocol` for programmatic receipt issuance and verification
73
+ - See the [llms.txt](https://github.com/peacprotocol/peac/blob/main/llms.txt) for a concise overview
14
74
 
15
75
  ## License
16
76
 
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@peac/policy-kit",
3
- "version": "0.12.5",
3
+ "version": "0.12.7",
4
4
  "description": "PEAC Policy Kit - deterministic policy evaluation for CAL semantics",
5
5
  "main": "dist/index.cjs",
6
6
  "types": "dist/index.d.ts",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "https://github.com/peacprotocol/peac.git",
9
+ "url": "git+https://github.com/peacprotocol/peac.git",
10
10
  "directory": "packages/policy-kit"
11
11
  },
12
- "author": "jithinraj <7850727+jithinraj@users.noreply.github.com>",
12
+ "author": "PEAC Protocol Contributors",
13
13
  "license": "Apache-2.0",
14
14
  "bugs": {
15
15
  "url": "https://github.com/peacprotocol/peac/issues"
@@ -25,7 +25,7 @@
25
25
  "dependencies": {
26
26
  "yaml": "^2.3.4",
27
27
  "zod": "^4.3.6",
28
- "@peac/schema": "0.12.5"
28
+ "@peac/schema": "0.12.7"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/node": "^22.19.11",
@@ -43,6 +43,19 @@
43
43
  },
44
44
  "./package.json": "./package.json"
45
45
  },
46
+ "keywords": [
47
+ "peac",
48
+ "peacprotocol",
49
+ "interaction-records",
50
+ "signed-records",
51
+ "receipts",
52
+ "originary",
53
+ "policy",
54
+ "discovery",
55
+ "well-known",
56
+ "peac-txt",
57
+ "issuer-config"
58
+ ],
46
59
  "scripts": {
47
60
  "generate:profiles": "tsx scripts/generate-profiles.ts",
48
61
  "generate:profiles:check": "tsx scripts/generate-profiles.ts --check",