@letterblack/lbe-sdk 0.4.0 → 0.4.2
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 +136 -109
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,34 +1,73 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<img src="https://raw.githubusercontent.com/Letterblack0306/letterblack-Lockstep-boundry-engine/main/assets/logo.svg" width="100" alt="LetterBlack logo"/>
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
# `@letterblack/lbe-sdk`
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
**Local-first AI execution governance.**
|
|
8
|
+
Sandboxed writes · Audit · Rollback · MCP · WASM engine
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
[](https://www.npmjs.com/package/@letterblack/lbe-sdk)
|
|
11
|
+
[](./LICENSE)
|
|
12
|
+
[](https://nodejs.org)
|
|
13
|
+
[](./runtime/lbe_engine.wasm)
|
|
10
14
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## What LBE is
|
|
20
|
+
|
|
21
|
+
LBE is a local SDK that enforces a cryptographic policy gate between an AI agent and your system. It installs as an npm package, runs entirely in your process, and requires no external service, cloud connection, or hosted API. Every action an agent proposes passes through the validation engine before anything executes. Nothing phones home.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## The problem
|
|
26
|
+
|
|
27
|
+
AI agents can write files, run shell commands, and modify your system — and most frameworks let them do it without any gate.
|
|
28
|
+
|
|
29
|
+
There is no policy asking "is this agent allowed to do this?" There is no audit trail recording what happened. There is no rollback if it goes wrong. If an agent overwrites a config file, deletes the wrong directory, or runs a command it shouldn't — you find out after the fact, with no record and no recovery.
|
|
30
|
+
|
|
31
|
+
LBE is the enforcement layer that sits between an AI agent and your system. Every action the agent proposes must pass a cryptographic validation pipeline before anything executes. If it fails — nothing runs, nothing changes, and the denial is logged. If it passes — the action executes under a governed adapter, a hash-chained audit entry is written, and rollback state is saved.
|
|
32
|
+
|
|
33
|
+
<div align="center">
|
|
34
|
+
<img src="https://raw.githubusercontent.com/Letterblack0306/letterblack-Lockstep-boundry-engine/main/assets/storyboard-deny.png" width="680" alt="Rogue agent blocked: bypass attempt denied, shell untouched, filesystem unchanged, audit sealed"/>
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
---
|
|
14
38
|
|
|
15
|
-
|
|
39
|
+
## How it works
|
|
16
40
|
|
|
17
|
-
|
|
41
|
+
<div align="center">
|
|
42
|
+
<img src="https://raw.githubusercontent.com/Letterblack0306/letterblack-Lockstep-boundry-engine/main/assets/architecture.svg" width="680" alt="LBE SDK architecture diagram"/>
|
|
43
|
+
</div>
|
|
18
44
|
|
|
45
|
+
Every action proposal from an agent is validated across 7 stages — schema, timestamp, key lifecycle, Ed25519 signature, rate limit, nonce deduplication, and policy — before the adapter executes anything. All 7 stages run inside the compiled WASM engine. A denial at any stage stops execution immediately and writes an audit entry. No cloud. No data leaves the machine.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Install
|
|
50
|
+
|
|
51
|
+
**PowerShell**
|
|
52
|
+
```powershell
|
|
53
|
+
npm install "@letterblack/lbe-sdk"
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**bash / zsh / cmd**
|
|
19
57
|
```bash
|
|
20
|
-
|
|
58
|
+
npm install @letterblack/lbe-sdk
|
|
21
59
|
```
|
|
22
60
|
|
|
23
|
-
|
|
24
|
-
operate inside explicit project boundaries.
|
|
61
|
+
> Requires Node.js 20.9.0+
|
|
25
62
|
|
|
26
|
-
|
|
63
|
+
---
|
|
27
64
|
|
|
28
65
|
## Quick Start
|
|
29
66
|
|
|
67
|
+
### Sandbox
|
|
68
|
+
|
|
30
69
|
```js
|
|
31
|
-
import { sandbox } from
|
|
70
|
+
import { sandbox } from "@letterblack/lbe-sdk";
|
|
32
71
|
|
|
33
72
|
const sb = sandbox('./workspace');
|
|
34
73
|
|
|
@@ -36,32 +75,42 @@ await sb.write('output.txt', 'Hello\n');
|
|
|
36
75
|
const text = await sb.read('output.txt');
|
|
37
76
|
```
|
|
38
77
|
|
|
39
|
-
|
|
40
|
-
Use it as the boundary for all agent-facing file operations.
|
|
41
|
-
|
|
42
|
-
## Audit and Rollback
|
|
78
|
+
### With audit + rollback
|
|
43
79
|
|
|
44
80
|
```js
|
|
45
|
-
import { sandbox } from
|
|
81
|
+
import { sandbox } from "@letterblack/lbe-sdk";
|
|
46
82
|
|
|
47
83
|
const sb = sandbox('./workspace', {
|
|
48
84
|
audit: true,
|
|
49
85
|
rollback: true
|
|
50
86
|
});
|
|
51
87
|
|
|
52
|
-
await sb.write('
|
|
88
|
+
await sb.write('report.md', '# Report\n');
|
|
53
89
|
```
|
|
54
90
|
|
|
55
|
-
|
|
56
|
-
state when your team shares governance artifacts:
|
|
91
|
+
### Full SDK client
|
|
57
92
|
|
|
58
93
|
```js
|
|
59
|
-
|
|
94
|
+
import { createLBE } from "@letterblack/lbe-sdk";
|
|
95
|
+
|
|
96
|
+
const lbe = createLBE({ rootDir: process.cwd() });
|
|
97
|
+
|
|
98
|
+
const result = await lbe.execute({
|
|
99
|
+
actor: 'agent:sdk',
|
|
100
|
+
intent: 'write_file',
|
|
101
|
+
target: './output/report.md',
|
|
102
|
+
content: '# Report\n'
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
console.log(result.ok); // true
|
|
106
|
+
console.log(result.stage); // 'ok'
|
|
60
107
|
```
|
|
61
108
|
|
|
109
|
+
---
|
|
110
|
+
|
|
62
111
|
## MCP Server
|
|
63
112
|
|
|
64
|
-
Add LBE governance to any MCP-compatible AI host:
|
|
113
|
+
Add LBE governance to any MCP-compatible AI host in one config block:
|
|
65
114
|
|
|
66
115
|
```json
|
|
67
116
|
{
|
|
@@ -74,117 +123,95 @@ Add LBE governance to any MCP-compatible AI host:
|
|
|
74
123
|
}
|
|
75
124
|
```
|
|
76
125
|
|
|
77
|
-
### Agent
|
|
126
|
+
### Agent tools
|
|
78
127
|
|
|
79
128
|
| Tool | Purpose |
|
|
80
129
|
|---|---|
|
|
81
|
-
| `lbe_workspace_context` | Fetch
|
|
82
|
-
| `lbe_write_file` | Governed write with backup
|
|
130
|
+
| `lbe_workspace_context` | Fetch workspace constraints before planning |
|
|
131
|
+
| `lbe_write_file` | Governed write with backup + rollback |
|
|
83
132
|
| `lbe_read_file` | Governed read |
|
|
84
|
-
| `lbe_patch_file` | Governed append/patch |
|
|
85
|
-
| `lbe_shell_command` | Governed command
|
|
133
|
+
| `lbe_patch_file` | Governed append / patch |
|
|
134
|
+
| `lbe_shell_command` | Governed command via configured allowlist |
|
|
86
135
|
| `lbe_health` | Verify local SDK readiness |
|
|
87
136
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
Use `createLBE()` for full SDK integration:
|
|
91
|
-
|
|
92
|
-
```js
|
|
93
|
-
import { createLBE } from '@letterblack/lbe-sdk';
|
|
94
|
-
|
|
95
|
-
const lbe = createLBE({
|
|
96
|
-
rootDir: process.cwd()
|
|
97
|
-
});
|
|
137
|
+
---
|
|
98
138
|
|
|
99
|
-
|
|
100
|
-
actor: 'agent:sdk',
|
|
101
|
-
intent: 'write_file',
|
|
102
|
-
target: './output/report.md',
|
|
103
|
-
content: '# Report\n'
|
|
104
|
-
});
|
|
139
|
+
## CLI
|
|
105
140
|
|
|
106
|
-
|
|
107
|
-
|
|
141
|
+
```bash
|
|
142
|
+
npx lbe init # Initialize workspace governance
|
|
143
|
+
npx lbe health # Verify runtime readiness
|
|
144
|
+
npx lbe verify --in proposal.json # Validate a proposal (no execution)
|
|
145
|
+
npx lbe run --in proposal.json # Validate + execute
|
|
146
|
+
npx lbe audit-verify # Verify audit chain integrity
|
|
147
|
+
npx lbe-mcp # Start MCP server on stdio
|
|
108
148
|
```
|
|
109
149
|
|
|
110
|
-
|
|
150
|
+
---
|
|
111
151
|
|
|
112
|
-
|
|
152
|
+
## Validation pipeline
|
|
113
153
|
|
|
114
|
-
|
|
154
|
+
Every execution proposal passes 7 stages inside the compiled WASM engine:
|
|
115
155
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
156
|
+
```
|
|
157
|
+
[1] Schema — required fields, types, structure
|
|
158
|
+
[2] Timestamp — skew tolerance, replay window
|
|
159
|
+
[3] Key — lifecycle, expiry, revocation
|
|
160
|
+
[4] Signature — Ed25519, RFC 8785 canonicalization
|
|
161
|
+
[5] Rate limit — sliding window per requester
|
|
162
|
+
[6] Nonce — replay detection
|
|
163
|
+
[7] Policy — deny-by-default allowlist
|
|
164
|
+
│
|
|
165
|
+
▼
|
|
166
|
+
execute ──▶ audit entry ──▶ rollback state
|
|
167
|
+
```
|
|
125
168
|
|
|
126
|
-
|
|
127
|
-
|---|---|
|
|
128
|
-
| `rootDir` | Workspace root — enables automatic local setup |
|
|
129
|
-
| `secretKey` | Ed25519 signing key (base64). Required for execution |
|
|
130
|
-
| `keyStore` | Trusted key registry object |
|
|
131
|
-
| `policy` | Inline policy object (overrides policy file) |
|
|
132
|
-
| `state` | State storage mode |
|
|
133
|
-
| `logLevel` | Runtime log level (`DEBUG`, `INFO`, `WARN`, `ERROR`) |
|
|
169
|
+
All 7 stages execute inside `runtime/lbe_engine.wasm`. The JS layer handles file IO, adapter dispatch, and the public SDK surface only.
|
|
134
170
|
|
|
135
|
-
|
|
171
|
+
<div align="center">
|
|
172
|
+
<img src="https://raw.githubusercontent.com/Letterblack0306/letterblack-Lockstep-boundry-engine/main/assets/storyboard-allow.png" width="680" alt="Trusted agent approved: identity confirmed, policy passed, governed write executed, audit chain extended"/>
|
|
173
|
+
</div>
|
|
136
174
|
|
|
137
|
-
|
|
138
|
-
- `writeFile(target, content)` — convenience governed write
|
|
139
|
-
- `readFile(target)` — convenience governed read
|
|
140
|
-
- `exportLogs()` — return the in-memory operation log
|
|
175
|
+
---
|
|
141
176
|
|
|
142
|
-
##
|
|
177
|
+
## SDK API status
|
|
143
178
|
|
|
144
|
-
|
|
145
|
-
|---|---|
|
|
146
|
-
| `npx lbe init` | Initialize local workspace governance |
|
|
147
|
-
| `npx lbe health` | Verify local runtime readiness |
|
|
148
|
-
| `npx lbe verify --in proposal.json` | Validate an execution proposal |
|
|
149
|
-
| `npx lbe run --in proposal.json` | Validate and execute a proposal |
|
|
150
|
-
| `npx lbe audit-verify` | Verify local audit chain integrity |
|
|
151
|
-
| `npx lbe-mcp` | Start the LBE MCP server on stdio |
|
|
179
|
+
The public SDK surface is intentionally minimal in v0.4.0.
|
|
152
180
|
|
|
153
|
-
|
|
181
|
+
Current stable entry points:
|
|
182
|
+
- `sandbox(root, opts?)`
|
|
183
|
+
- `createLBE(options)`
|
|
184
|
+
- `lbe.execute(proposal)`
|
|
185
|
+
- `lbe.readFile(path)`
|
|
186
|
+
- `lbe.writeFile(path, content)`
|
|
154
187
|
|
|
155
|
-
|
|
156
|
-
Validation pipeline, policy decisions, nonce deduplication, rate-limit enforcement,
|
|
157
|
-
audit hash chaining, risk classification, and rollback logic all execute inside
|
|
158
|
-
the compiled runtime. The JS layer handles file IO, adapter dispatch, and the
|
|
159
|
-
public API surface only.
|
|
188
|
+
Expanded API documentation will be published after the runtime contract stabilizes.
|
|
160
189
|
|
|
161
|
-
|
|
162
|
-
No network access is required. No data leaves the machine.
|
|
190
|
+
---
|
|
163
191
|
|
|
164
|
-
##
|
|
192
|
+
## What LBE protects against
|
|
165
193
|
|
|
166
|
-
|
|
167
|
-
|
|
194
|
+
| Risk | Protection |
|
|
195
|
+
|---|---|
|
|
196
|
+
| Unauthorized workspace writes | Policy + sandbox boundary |
|
|
197
|
+
| Agent behavior drift | Deny-by-default allowlist |
|
|
198
|
+
| Accidental destructive ops | Rollback + backup |
|
|
199
|
+
| Replay attacks | Nonce deduplication |
|
|
200
|
+
| Rate abuse | Sliding window rate limit |
|
|
201
|
+
| Tampered audit records | SHA-256 hash chain |
|
|
202
|
+
| Key misuse | Ed25519 lifecycle enforcement |
|
|
168
203
|
|
|
169
|
-
LBE does not replace OS-level sandboxing, container isolation, network egress
|
|
170
|
-
controls, or multi-tenant workload isolation.
|
|
204
|
+
> LBE does not replace OS-level sandboxing, container isolation, or network egress controls.
|
|
171
205
|
|
|
172
|
-
|
|
206
|
+
---
|
|
173
207
|
|
|
174
|
-
|
|
175
|
-
- Policy bypass caused by agent behavior drift
|
|
176
|
-
- Accidental destructive operations (delete, overwrite)
|
|
177
|
-
- Loss of visibility into agent-driven changes
|
|
208
|
+
## License
|
|
178
209
|
|
|
179
|
-
|
|
210
|
+
Commercial. See [LICENSE](./LICENSE) and [COMMERCIAL_DISTRIBUTION.md](./COMMERCIAL_DISTRIBUTION.md).
|
|
211
|
+
Usage requires an applicable [LetterBlack](https://letterblack.ae) license, subscription, or evaluation agreement.
|
|
180
212
|
|
|
181
|
-
|
|
182
|
-
- Root or administrator access controls
|
|
183
|
-
- Malware protection
|
|
184
|
-
- Container or VM isolation
|
|
185
|
-
- Network security controls
|
|
213
|
+
<div align="center">
|
|
186
214
|
|
|
187
|
-
|
|
215
|
+
Built by [LetterBlack](https://letterblack.ae)
|
|
188
216
|
|
|
189
|
-
|
|
190
|
-
license, subscription, evaluation agreement, or other written authorization.
|
|
217
|
+
</div>
|