@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.
Files changed (2) hide show
  1. package/README.md +136 -109
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,34 +1,73 @@
1
- # @letterblack/lbe-sdk
1
+ <div align="center">
2
2
 
3
- Lockstep Boundary Engine SDK for local-first AI execution governance.
3
+ <img src="https://raw.githubusercontent.com/Letterblack0306/letterblack-Lockstep-boundry-engine/main/assets/logo.svg" width="100" alt="LetterBlack logo"/>
4
4
 
5
- Sandboxed writes. Workspace context. Audit. Rollback. MCP access.
5
+ # `@letterblack/lbe-sdk`
6
6
 
7
- Everything runs on your machine. No hosted service is required.
7
+ **Local-first AI execution governance.**
8
+ Sandboxed writes · Audit · Rollback · MCP · WASM engine
8
9
 
9
- ## Install
10
+ [![npm](https://img.shields.io/npm/v/@letterblack/lbe-sdk?color=black&label=npm)](https://www.npmjs.com/package/@letterblack/lbe-sdk)
11
+ [![license](https://img.shields.io/badge/license-Commercial-red)](./LICENSE)
12
+ [![node](https://img.shields.io/node/v/@letterblack/lbe-sdk?color=darkgreen)](https://nodejs.org)
13
+ [![engine](https://img.shields.io/badge/engine-WASM-blueviolet)](./runtime/lbe_engine.wasm)
10
14
 
11
- ```bash
12
- npm install @letterblack/lbe-sdk
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
- Requires Node.js 20.9.0 or newer.
39
+ ## How it works
16
40
 
17
- ## Initialize
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
- npx lbe init
58
+ npm install @letterblack/lbe-sdk
21
59
  ```
22
60
 
23
- Initializes local governance settings for the current workspace so agents can
24
- operate inside explicit project boundaries.
61
+ > Requires Node.js 20.9.0+
25
62
 
26
- Run once per workspace. Re-run when the workspace structure changes.
63
+ ---
27
64
 
28
65
  ## Quick Start
29
66
 
67
+ ### Sandbox
68
+
30
69
  ```js
31
- import { sandbox } from '@letterblack/lbe-sdk';
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
- `sandbox()` routes reads and writes through the workspace root you provide.
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 '@letterblack/lbe-sdk';
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('output.txt', 'governed write\n');
88
+ await sb.write('report.md', '# Report\n');
53
89
  ```
54
90
 
55
- Audit records and rollback state are stored locally. Use workspace-scoped
56
- state when your team shares governance artifacts:
91
+ ### Full SDK client
57
92
 
58
93
  ```js
59
- const sb = sandbox('./workspace', { state: 'workspace' });
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 Tools
126
+ ### Agent tools
78
127
 
79
128
  | Tool | Purpose |
80
129
  |---|---|
81
- | `lbe_workspace_context` | Fetch local workspace constraints before planning actions |
82
- | `lbe_write_file` | Governed write with backup and rollback support |
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 execution through the configured allowlist |
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
- ## Programmatic Use
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
- const result = await lbe.execute({
100
- actor: 'agent:sdk',
101
- intent: 'write_file',
102
- target: './output/report.md',
103
- content: '# Report\n'
104
- });
139
+ ## CLI
105
140
 
106
- console.log(result.ok);
107
- console.log(result.stage);
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
- ## Public API
150
+ ---
111
151
 
112
- ### `sandbox(root, opts?)`
152
+ ## Validation pipeline
113
153
 
114
- Creates a governed workspace helper.
154
+ Every execution proposal passes 7 stages inside the compiled WASM engine:
115
155
 
116
- | Option | Default | Description |
117
- |---|---|---|
118
- | `audit` | `false` | Record governed operations to the local audit log |
119
- | `rollback` | `false` | Back up before writes; restore on failure |
120
- | `state` | `'local'` | State storage: `'local'`, `'workspace'`, or adapter |
121
-
122
- ### `createLBE(options)`
123
-
124
- Creates a full SDK client for application integrations.
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
- | Option | Description |
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
- `createLBE()` returns an object with:
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
- - `execute({ actor, intent, target, content, args, transaction })` — run a governed operation
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
- ## CLI
177
+ ## SDK API status
143
178
 
144
- | Command | Description |
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
- ## Runtime
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
- The governance engine ships as a compiled WASM binary (`runtime/lbe_engine.wasm`).
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
- The engine loads once on first call and is cached for the process lifetime.
162
- No network access is required. No data leaves the machine.
190
+ ---
163
191
 
164
- ## Security Notes
192
+ ## What LBE protects against
165
193
 
166
- LBE governs agent actions routed through the SDK. It provides local policy
167
- enforcement, auditability, and rollback support for governed operations.
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
- ### What LBE reduces the risk of
206
+ ---
173
207
 
174
- - Unauthorized workspace modification by agent workflows
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
- ### What LBE does not replace
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
- - Operating-system security and user permissions
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
- ## License
215
+ Built by [LetterBlack](https://letterblack.ae)
188
216
 
189
- See [LICENSE](./LICENSE). Commercial usage requires an applicable LetterBlack
190
- license, subscription, evaluation agreement, or other written authorization.
217
+ </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letterblack/lbe-sdk",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Commercial SDK distribution for the Lockstep Boundary Engine.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",