@lelu-auth/lelu 0.1.9 → 0.1.10

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Abenezer <abenezergetachew0923@gmail.com>
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Abenezer <abenezergetachew0923@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,55 +1,96 @@
1
- # Lelu
2
-
3
- The TypeScript SDK for Lelu — the confidence-aware authorization engine for autonomous AI agents.
4
-
5
- Lelu provides confidence-aware access control, human-in-the-loop approvals, and SOC 2-ready audit trails for your autonomous agents.
6
-
7
- ## Installation
8
-
9
- ```bash
10
- npm install @lelu-auth/lelu
11
- ```
12
-
13
- ## Quick Start
14
-
15
- ```typescript
16
- import { createClient } from "@lelu-auth/lelu";
17
-
18
- // Initialize the client
19
- const lelu = createClient({
20
- baseUrl: "http://localhost:8082"
21
- });
22
-
23
- // Authorize an agent action
24
- async function runAgent() {
25
- const { allowed, reason } = await lelu.agentAuthorize({
26
- agentId: "agent-123",
27
- action: "read_database",
28
- resource: "users_table",
29
- context: {
30
- confidence: 0.95
31
- }
32
- });
33
-
34
- if (allowed) {
35
- console.log("Action permitted!");
36
- } else {
37
- console.log("Action denied:", reason);
38
- }
39
- }
40
- ```
41
-
42
- ## Features
43
-
44
- - **Confidence-Aware**: Dynamically adjust permissions based on the AI agent's confidence level.
45
- - **Human-in-the-loop**: Require human approval for low-confidence or high-risk actions.
46
- - **Audit Trails**: SOC 2-ready logging of all agent decisions and actions.
47
- - **Framework Agnostic**: Works with LangChain, AutoGPT, or custom agent frameworks.
48
-
49
- ## Documentation
50
-
51
- For full documentation, visit [https://github.com/lelu-auth/lelu](https://github.com/lelu-auth/lelu).
52
-
53
- ## License
54
-
55
- MIT
1
+ [![Lelu logo](https://ui-seven-amber.vercel.app/logo.svg)](https://ui-seven-amber.vercel.app/)
2
+
3
+ # Lelu
4
+
5
+ The TypeScript SDK for Lelu the confidence-aware authorization engine for autonomous AI agents.
6
+
7
+ Lelu provides confidence-aware access control, human-in-the-loop approvals, and SOC 2-ready audit trails for your autonomous agents.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install @lelu-auth/lelu
13
+ ```
14
+
15
+ ## Start Dashboard (Localhost)
16
+
17
+ After installing the package, start the local dashboard stack with one command:
18
+
19
+ ```bash
20
+ npx @lelu-auth/lelu dashboard
21
+ ```
22
+
23
+ Then open:
24
+
25
+ ```text
26
+ http://localhost:3002/audit
27
+ ```
28
+
29
+ This command clones/updates the Lelu stack in `~/.lelu-stack` and runs `docker compose up -d --build`.
30
+
31
+ Or run the public Lelu engine image:
32
+
33
+ ```bash
34
+ docker pull abenezer0923/lelu-engine:latest
35
+ docker run --rm -p 8083:8080 abenezer0923/lelu-engine:latest
36
+ ```
37
+
38
+ ## Docker Support
39
+
40
+ Lelu works in Dockerized apps.
41
+
42
+ The SDK resolves engine URL in this order:
43
+
44
+ 1. `baseUrl` passed to `createClient(...)`
45
+ 2. `LELU_BASE_URL` environment variable
46
+ 3. `http://localhost:8080` fallback
47
+
48
+ Example for containers:
49
+
50
+ ```bash
51
+ LELU_BASE_URL=http://host.docker.internal:8083
52
+ ```
53
+
54
+ ## Quick Start
55
+
56
+ ```typescript
57
+ import { createClient } from "@lelu-auth/lelu";
58
+
59
+ // Initialize the client
60
+ const lelu = createClient({
61
+ baseUrl: "http://localhost:8083"
62
+ });
63
+
64
+ // Authorize an agent action
65
+ async function runAgent() {
66
+ const { allowed, reason } = await lelu.agentAuthorize({
67
+ agentId: "agent-123",
68
+ action: "read_database",
69
+ resource: "users_table",
70
+ context: {
71
+ confidence: 0.95
72
+ }
73
+ });
74
+
75
+ if (allowed) {
76
+ console.log("Action permitted!");
77
+ } else {
78
+ console.log("Action denied:", reason);
79
+ }
80
+ }
81
+ ```
82
+
83
+ ## Features
84
+
85
+ - **Confidence-Aware**: Dynamically adjust permissions based on the AI agent's confidence level.
86
+ - **Human-in-the-loop**: Require human approval for low-confidence or high-risk actions.
87
+ - **Audit Trails**: SOC 2-ready logging of all agent decisions and actions.
88
+ - **Framework Agnostic**: Works with LangChain, AutoGPT, or custom agent frameworks.
89
+
90
+ ## Documentation
91
+
92
+ For full documentation, visit [https://ui-seven-amber.vercel.app/](https://ui-seven-amber.vercel.app/).
93
+
94
+ ## License
95
+
96
+ MIT
@@ -151,12 +151,56 @@ interface DelegateScopeResult {
151
151
  interface RevokeTokenResult {
152
152
  success: boolean;
153
153
  }
154
+ interface AuditEvent {
155
+ id: number;
156
+ tenantId: string;
157
+ traceId: string;
158
+ timestamp: string;
159
+ actor: string;
160
+ action: string;
161
+ resource?: Record<string, string>;
162
+ confidenceScore?: number;
163
+ decision: string;
164
+ reason?: string;
165
+ downgradedScope?: string;
166
+ latencyMs: number;
167
+ engineVersion?: string;
168
+ policyVersion?: string;
169
+ createdAt: string;
170
+ }
171
+ interface ListAuditEventsRequest {
172
+ /** Maximum number of events to return (default: 20, max: 500) */
173
+ limit?: number;
174
+ /** Pagination cursor (offset) */
175
+ cursor?: number;
176
+ /** Filter by actor */
177
+ actor?: string;
178
+ /** Filter by action */
179
+ action?: string;
180
+ /** Filter by decision */
181
+ decision?: string;
182
+ /** Filter by trace ID */
183
+ traceId?: string;
184
+ /** Filter events from this timestamp (ISO 8601) */
185
+ from?: string;
186
+ /** Filter events to this timestamp (ISO 8601) */
187
+ to?: string;
188
+ /** Tenant ID (defaults to "default") */
189
+ tenantId?: string;
190
+ }
191
+ interface ListAuditEventsResult {
192
+ events: AuditEvent[];
193
+ count: number;
194
+ limit: number;
195
+ cursor: number;
196
+ nextCursor: number;
197
+ }
154
198
  type AuthRequest = z.infer<typeof AuthRequestSchema>;
155
199
  type AgentAuthRequest = z.infer<typeof AgentAuthRequestSchema>;
156
200
  type AgentContext = z.infer<typeof AgentContextSchema>;
157
201
  type MintTokenRequest = z.infer<typeof MintTokenRequestSchema>;
158
202
  interface ClientConfig {
159
- /** Base URL of the Auth Permission Engine (default: http://localhost:8080) */
203
+ /** Base URL of the Auth Permission Engine (defaults to LELU_BASE_URL env var, else http://localhost:8080) */
160
204
  baseUrl?: string;
161
205
  /** Request timeout in milliseconds (default: 5000) */
162
206
  timeoutMs?: number;
@@ -168,6 +212,92 @@ declare class AuthEngineError extends Error {
168
212
  readonly details?: unknown | undefined;
169
213
  constructor(message: string, status?: number | undefined, details?: unknown | undefined);
170
214
  }
215
+ interface Policy {
216
+ id: string;
217
+ tenantId: string;
218
+ name: string;
219
+ content: string;
220
+ version: string;
221
+ hmacSha256: string;
222
+ createdAt: string;
223
+ updatedAt: string;
224
+ }
225
+ interface Policy {
226
+ id: string;
227
+ tenantId: string;
228
+ name: string;
229
+ content: string;
230
+ version: string;
231
+ hmacSha256: string;
232
+ createdAt: string;
233
+ updatedAt: string;
234
+ }
235
+ interface ListPoliciesRequest {
236
+ /** Tenant ID (defaults to "default") */
237
+ tenantId?: string;
238
+ }
239
+ interface ListPoliciesRequest {
240
+ /** Tenant ID (defaults to "default") */
241
+ tenantId?: string;
242
+ }
243
+ interface ListPoliciesResult {
244
+ policies: Policy[];
245
+ count: number;
246
+ }
247
+ interface ListPoliciesResult {
248
+ policies: Policy[];
249
+ count: number;
250
+ }
251
+ interface GetPolicyRequest {
252
+ /** Policy name */
253
+ name: string;
254
+ /** Tenant ID (defaults to "default") */
255
+ tenantId?: string;
256
+ }
257
+ interface GetPolicyRequest {
258
+ /** Policy name */
259
+ name: string;
260
+ /** Tenant ID (defaults to "default") */
261
+ tenantId?: string;
262
+ }
263
+ interface UpsertPolicyRequest {
264
+ /** Policy name */
265
+ name: string;
266
+ /** Policy content (Rego code) */
267
+ content: string;
268
+ /** Policy version (defaults to "1.0") */
269
+ version?: string;
270
+ /** Tenant ID (defaults to "default") */
271
+ tenantId?: string;
272
+ }
273
+ interface UpsertPolicyRequest {
274
+ /** Policy name */
275
+ name: string;
276
+ /** Policy content (Rego code) */
277
+ content: string;
278
+ /** Policy version (defaults to "1.0") */
279
+ version?: string;
280
+ /** Tenant ID (defaults to "default") */
281
+ tenantId?: string;
282
+ }
283
+ interface DeletePolicyRequest {
284
+ /** Policy name */
285
+ name: string;
286
+ /** Tenant ID (defaults to "default") */
287
+ tenantId?: string;
288
+ }
289
+ interface DeletePolicyRequest {
290
+ /** Policy name */
291
+ name: string;
292
+ /** Tenant ID (defaults to "default") */
293
+ tenantId?: string;
294
+ }
295
+ interface DeletePolicyResult {
296
+ deleted: boolean;
297
+ }
298
+ interface DeletePolicyResult {
299
+ deleted: boolean;
300
+ }
171
301
 
172
302
  /**
173
303
  * LeluClient is the core SDK entry-point. It communicates with the local
@@ -225,6 +355,15 @@ declare class LeluClient {
225
355
  * Returns true if the engine is reachable and healthy.
226
356
  */
227
357
  isHealthy(): Promise<boolean>;
358
+ /**
359
+ * Lists audit events from the platform API.
360
+ * Requires the platform service to be running (not just the engine).
361
+ */
362
+ listAuditEvents(req?: ListAuditEventsRequest): Promise<ListAuditEventsResult>;
363
+ listPolicies(req?: ListPoliciesRequest): Promise<ListPoliciesResult>;
364
+ getPolicy(req: GetPolicyRequest): Promise<Policy>;
365
+ upsertPolicy(req: UpsertPolicyRequest): Promise<Policy>;
366
+ deletePolicy(req: DeletePolicyRequest): Promise<DeletePolicyResult>;
228
367
  private headers;
229
368
  private post;
230
369
  private delete;
@@ -232,4 +371,4 @@ declare class LeluClient {
232
371
  private parseResponse;
233
372
  }
234
373
 
235
- export { type AgentAuthDecision as A, type ClientConfig as C, type DelegateScopeRequest as D, LeluClient as L, type MintTokenRequest as M, type RevokeTokenResult as R, type AgentAuthRequest as a, AgentAuthRequestSchema as b, type AgentContext as c, AgentContextSchema as d, type AuthDecision as e, AuthEngineError as f, type AuthRequest as g, AuthRequestSchema as h, DelegateScopeRequestSchema as i, type DelegateScopeResult as j, MintTokenRequestSchema as k, type MintTokenResult as l };
374
+ export { type AgentAuthDecision as A, type ClientConfig as C, type DelegateScopeRequest as D, LeluClient as L, type MintTokenRequest as M, type RevokeTokenResult as R, type AgentAuthRequest as a, AgentAuthRequestSchema as b, type AgentContext as c, AgentContextSchema as d, type AuditEvent as e, type AuthDecision as f, AuthEngineError as g, type AuthRequest as h, AuthRequestSchema as i, DelegateScopeRequestSchema as j, type DelegateScopeResult as k, type ListAuditEventsRequest as l, type ListAuditEventsResult as m, MintTokenRequestSchema as n, type MintTokenResult as o };
@@ -151,12 +151,56 @@ interface DelegateScopeResult {
151
151
  interface RevokeTokenResult {
152
152
  success: boolean;
153
153
  }
154
+ interface AuditEvent {
155
+ id: number;
156
+ tenantId: string;
157
+ traceId: string;
158
+ timestamp: string;
159
+ actor: string;
160
+ action: string;
161
+ resource?: Record<string, string>;
162
+ confidenceScore?: number;
163
+ decision: string;
164
+ reason?: string;
165
+ downgradedScope?: string;
166
+ latencyMs: number;
167
+ engineVersion?: string;
168
+ policyVersion?: string;
169
+ createdAt: string;
170
+ }
171
+ interface ListAuditEventsRequest {
172
+ /** Maximum number of events to return (default: 20, max: 500) */
173
+ limit?: number;
174
+ /** Pagination cursor (offset) */
175
+ cursor?: number;
176
+ /** Filter by actor */
177
+ actor?: string;
178
+ /** Filter by action */
179
+ action?: string;
180
+ /** Filter by decision */
181
+ decision?: string;
182
+ /** Filter by trace ID */
183
+ traceId?: string;
184
+ /** Filter events from this timestamp (ISO 8601) */
185
+ from?: string;
186
+ /** Filter events to this timestamp (ISO 8601) */
187
+ to?: string;
188
+ /** Tenant ID (defaults to "default") */
189
+ tenantId?: string;
190
+ }
191
+ interface ListAuditEventsResult {
192
+ events: AuditEvent[];
193
+ count: number;
194
+ limit: number;
195
+ cursor: number;
196
+ nextCursor: number;
197
+ }
154
198
  type AuthRequest = z.infer<typeof AuthRequestSchema>;
155
199
  type AgentAuthRequest = z.infer<typeof AgentAuthRequestSchema>;
156
200
  type AgentContext = z.infer<typeof AgentContextSchema>;
157
201
  type MintTokenRequest = z.infer<typeof MintTokenRequestSchema>;
158
202
  interface ClientConfig {
159
- /** Base URL of the Auth Permission Engine (default: http://localhost:8080) */
203
+ /** Base URL of the Auth Permission Engine (defaults to LELU_BASE_URL env var, else http://localhost:8080) */
160
204
  baseUrl?: string;
161
205
  /** Request timeout in milliseconds (default: 5000) */
162
206
  timeoutMs?: number;
@@ -168,6 +212,92 @@ declare class AuthEngineError extends Error {
168
212
  readonly details?: unknown | undefined;
169
213
  constructor(message: string, status?: number | undefined, details?: unknown | undefined);
170
214
  }
215
+ interface Policy {
216
+ id: string;
217
+ tenantId: string;
218
+ name: string;
219
+ content: string;
220
+ version: string;
221
+ hmacSha256: string;
222
+ createdAt: string;
223
+ updatedAt: string;
224
+ }
225
+ interface Policy {
226
+ id: string;
227
+ tenantId: string;
228
+ name: string;
229
+ content: string;
230
+ version: string;
231
+ hmacSha256: string;
232
+ createdAt: string;
233
+ updatedAt: string;
234
+ }
235
+ interface ListPoliciesRequest {
236
+ /** Tenant ID (defaults to "default") */
237
+ tenantId?: string;
238
+ }
239
+ interface ListPoliciesRequest {
240
+ /** Tenant ID (defaults to "default") */
241
+ tenantId?: string;
242
+ }
243
+ interface ListPoliciesResult {
244
+ policies: Policy[];
245
+ count: number;
246
+ }
247
+ interface ListPoliciesResult {
248
+ policies: Policy[];
249
+ count: number;
250
+ }
251
+ interface GetPolicyRequest {
252
+ /** Policy name */
253
+ name: string;
254
+ /** Tenant ID (defaults to "default") */
255
+ tenantId?: string;
256
+ }
257
+ interface GetPolicyRequest {
258
+ /** Policy name */
259
+ name: string;
260
+ /** Tenant ID (defaults to "default") */
261
+ tenantId?: string;
262
+ }
263
+ interface UpsertPolicyRequest {
264
+ /** Policy name */
265
+ name: string;
266
+ /** Policy content (Rego code) */
267
+ content: string;
268
+ /** Policy version (defaults to "1.0") */
269
+ version?: string;
270
+ /** Tenant ID (defaults to "default") */
271
+ tenantId?: string;
272
+ }
273
+ interface UpsertPolicyRequest {
274
+ /** Policy name */
275
+ name: string;
276
+ /** Policy content (Rego code) */
277
+ content: string;
278
+ /** Policy version (defaults to "1.0") */
279
+ version?: string;
280
+ /** Tenant ID (defaults to "default") */
281
+ tenantId?: string;
282
+ }
283
+ interface DeletePolicyRequest {
284
+ /** Policy name */
285
+ name: string;
286
+ /** Tenant ID (defaults to "default") */
287
+ tenantId?: string;
288
+ }
289
+ interface DeletePolicyRequest {
290
+ /** Policy name */
291
+ name: string;
292
+ /** Tenant ID (defaults to "default") */
293
+ tenantId?: string;
294
+ }
295
+ interface DeletePolicyResult {
296
+ deleted: boolean;
297
+ }
298
+ interface DeletePolicyResult {
299
+ deleted: boolean;
300
+ }
171
301
 
172
302
  /**
173
303
  * LeluClient is the core SDK entry-point. It communicates with the local
@@ -225,6 +355,15 @@ declare class LeluClient {
225
355
  * Returns true if the engine is reachable and healthy.
226
356
  */
227
357
  isHealthy(): Promise<boolean>;
358
+ /**
359
+ * Lists audit events from the platform API.
360
+ * Requires the platform service to be running (not just the engine).
361
+ */
362
+ listAuditEvents(req?: ListAuditEventsRequest): Promise<ListAuditEventsResult>;
363
+ listPolicies(req?: ListPoliciesRequest): Promise<ListPoliciesResult>;
364
+ getPolicy(req: GetPolicyRequest): Promise<Policy>;
365
+ upsertPolicy(req: UpsertPolicyRequest): Promise<Policy>;
366
+ deletePolicy(req: DeletePolicyRequest): Promise<DeletePolicyResult>;
228
367
  private headers;
229
368
  private post;
230
369
  private delete;
@@ -232,4 +371,4 @@ declare class LeluClient {
232
371
  private parseResponse;
233
372
  }
234
373
 
235
- export { type AgentAuthDecision as A, type ClientConfig as C, type DelegateScopeRequest as D, LeluClient as L, type MintTokenRequest as M, type RevokeTokenResult as R, type AgentAuthRequest as a, AgentAuthRequestSchema as b, type AgentContext as c, AgentContextSchema as d, type AuthDecision as e, AuthEngineError as f, type AuthRequest as g, AuthRequestSchema as h, DelegateScopeRequestSchema as i, type DelegateScopeResult as j, MintTokenRequestSchema as k, type MintTokenResult as l };
374
+ export { type AgentAuthDecision as A, type ClientConfig as C, type DelegateScopeRequest as D, LeluClient as L, type MintTokenRequest as M, type RevokeTokenResult as R, type AgentAuthRequest as a, AgentAuthRequestSchema as b, type AgentContext as c, AgentContextSchema as d, type AuditEvent as e, type AuthDecision as f, AuthEngineError as g, type AuthRequest as h, AuthRequestSchema as i, DelegateScopeRequestSchema as j, type DelegateScopeResult as k, type ListAuditEventsRequest as l, type ListAuditEventsResult as m, MintTokenRequestSchema as n, type MintTokenResult as o };
@@ -1,5 +1,5 @@
1
1
  import { RequestHandler } from 'express';
2
- import { L as LeluClient } from '../client-BD9h8CBT.mjs';
2
+ import { L as LeluClient } from '../client-DauLJ9a4.mjs';
3
3
  import 'zod';
4
4
 
5
5
  interface AuthorizeOptions {
@@ -1,5 +1,5 @@
1
1
  import { RequestHandler } from 'express';
2
- import { L as LeluClient } from '../client-BD9h8CBT.js';
2
+ import { L as LeluClient } from '../client-DauLJ9a4.js';
3
3
  import 'zod';
4
4
 
5
5
  interface AuthorizeOptions {