@letterblack/lbe-exec 1.2.3 → 1.2.4

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 +134 -58
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -3,8 +3,8 @@
3
3
  **Local-first execution governance for AI agents.**
4
4
 
5
5
  Every action any agent proposes — file write, shell command, anything — passes
6
- through a local validation gate before it can execute. One SDK, any agent,
7
- zero cloud dependency.
6
+ through a local validation gate before it can execute. One package, any agent,
7
+ zero cloud dependency, no daemon required.
8
8
 
9
9
  ---
10
10
 
@@ -26,22 +26,29 @@ dependency, no daemon required.
26
26
 
27
27
  ![LBE gate sequence — Request flows through Policy, Identity, and Scope gates before reaching Action. A rejected request is routed to denial before it reaches execution.](assets/lbe-gates.png)
28
28
 
29
- Every request the agent produces enters a gate sequence:
29
+ Every request the agent produces enters a 7-gate pipeline. A failure at any
30
+ gate returns a structured denial — the remaining gates are not evaluated.
30
31
 
31
- **Policy** — does the current project policy allow this action? Deny rules
32
- always win. If any deny rule matches, the gate closes before any other check
33
- runs.
34
-
35
- **Identity** — is the request signed by a trusted, active key? The executor
36
- signs every request locally with an Ed25519 key it holds in memory. Expired
37
- keys, tampered signatures, and replayed nonces are all rejected.
38
-
39
- **Scope** — is the target inside the allowed workspace? Paths outside the
40
- project root, symlink escapes, and commands outside the explicit allowlist
41
- are blocked regardless of policy.
32
+ ```
33
+ [1] Schema required fields and structural validity
34
+
35
+ [2] Timestamp permitted clock-skew window (±10 minutes)
36
+
37
+ [3] Key lifecycle trusted key, active, not expired
38
+
39
+ [4] Signature Ed25519 request authenticity (signed locally, no network)
40
+
41
+ [5] Rate limit per-requester sliding-window limit
42
+
43
+ [6] Nonce single-use replay protection
44
+
45
+ [7] Policy configured authorization (deny-wins)
46
+
47
+ allow / deny / error — structured result returned to host
48
+ ```
42
49
 
43
- Only a request that clears all three gates reaches **Action** — the point
44
- where something is actually written to disk or a command actually runs.
50
+ The executor signs every request with a host-held key before validation.
51
+ No key material leaves the process.
45
52
 
46
53
  ---
47
54
 
@@ -51,20 +58,17 @@ where something is actually written to disk or a command actually runs.
51
58
 
52
59
  When a request clears every gate:
53
60
 
54
- 1. The agent produces an action proposalintent, target, content.
55
- 2. The executor signs it locally with a host-held Ed25519 key. No key material
56
- leaves the process.
57
- 3. The project policy is evaluated. The action is approved.
61
+ 1. The agent calls a convenience method`lbe.writeFile()`, `lbe.runShell()`, etc.
62
+ 2. The executor constructs and signs the request locally with a host-held Ed25519 key.
63
+ 3. All seven gates pass. The project policy approves the action.
58
64
  4. The write or command executes inside the configured project root.
59
- 5. The audit chain is extended. Every approved action appends a hash-linked
60
- entry to `lbe.audit.jsonl` permanently verifiable, impossible to silently
61
- remove.
62
- 6. A structured result is returned: whether it succeeded, which rules matched,
63
- and the audit entry identifier.
65
+ 5. The audit chain is extended every approved action appends a hash-linked
66
+ entry to `.lbe/audit.jsonl`, permanently verifiable, impossible to silently remove.
67
+ 6. A structured result returns: whether it succeeded, which rules matched, and
68
+ the audit entry identifier.
64
69
 
65
- The application stays in control. The executor does not decide what to do with
66
- the result — it decides whether the action was permitted and hands the answer
67
- back.
70
+ The application stays in control. The executor decides whether the action was
71
+ permitted and hands the answer back.
68
72
 
69
73
  ---
70
74
 
@@ -100,32 +104,27 @@ is an agent that can grant itself permission.
100
104
 
101
105
  ---
102
106
 
103
- ## Observer mode — start here
104
-
105
- Not ready to block? Start in observer mode. Every request is fully validated
106
- and logged exactly as it would be in enforcement — but nothing is blocked.
107
-
108
- Watch what the agent is doing before you decide what to deny. Your rules take
109
- effect the moment you switch to enforcement.
110
-
111
- ```bash
112
- npx lbe-exec init # create lbe.policy.json — starts in observer mode
113
- npx lbe-exec status # see mode, rule count, audit entry count
114
- npx lbe-exec enforce # switch to blocking
115
- ```
116
-
117
- ---
118
-
119
107
  ## What this covers
120
108
 
121
109
  | Threat | Gate |
122
110
  |---|---|
123
- | Agent writes outside the project root | Scope — path check |
111
+ | Agent writes outside the project root | Scope — sandbox path check |
124
112
  | Replayed or stale request | Identity — nonce and timestamp |
125
113
  | Tampered or expired key | Identity — key lifecycle |
126
114
  | Excessive requests | Identity — rate limit |
127
115
  | Action not permitted by project policy | Policy — deny-wins evaluation |
128
116
  | Unauthorized shell command | Scope — explicit command allowlist |
117
+ | Injected payload (eval, exec, __proto__) | Content scan before pipeline |
118
+
119
+ ---
120
+
121
+ ## Observer mode — start here
122
+
123
+ Not ready to block? Start in observer mode. Every request is fully validated
124
+ and logged exactly as it would be in enforcement — but nothing is blocked.
125
+
126
+ Watch what the agent is doing before you decide what to deny. Your rules take
127
+ effect the moment you switch to enforcement.
129
128
 
130
129
  ---
131
130
 
@@ -136,13 +135,15 @@ npm install @letterblack/lbe-exec
136
135
  npx lbe-exec init
137
136
  ```
138
137
 
139
- `npx lbe-exec init` scans the project, writes `lbe.policy.json` in observer mode,
140
- generates `CLAUDE.md` and `.github/copilot-instructions.md` so every AI agent
141
- automatically discovers and follows governance without the user explaining it,
142
- and creates `.lbe/AGENT_CONTRACT.md` as a machine-readable contract.
138
+ `npx lbe-exec init` scans the project, writes `lbe.policy.json` in observer
139
+ mode, generates `CLAUDE.md` and `.github/copilot-instructions.md` so every AI
140
+ agent automatically discovers and follows governance, and creates
141
+ `.lbe/AGENT_CONTRACT.md` as a machine-readable contract.
143
142
 
144
143
  Requires Node.js ≥ 20.9.0.
145
144
 
145
+ ---
146
+
146
147
  ## Use in agent code
147
148
 
148
149
  ```js
@@ -150,27 +151,102 @@ import { createLocalExecutor } from '@letterblack/lbe-exec';
150
151
 
151
152
  const lbe = createLocalExecutor({ rootDir: process.cwd() });
152
153
 
154
+ // Every call routes through the full 7-gate pipeline
153
155
  await lbe.writeFile('output/report.md', content);
154
156
  await lbe.readFile('src/config.json');
155
157
  await lbe.patchFile('src/index.js', patch);
156
158
  await lbe.deleteFile('tmp/scratch.txt');
157
159
  await lbe.runShell('node', ['scripts/build.js']);
158
160
 
161
+ // Result shape
159
162
  const result = await lbe.writeFile('output/result.md', data);
160
- // { ok: true, decision: 'allow', executed: true }
161
- // { ok: false, decision: 'deny', error: { message: '...' } }
163
+ // { ok: true, decision: 'allow', executed: true, auditId: '...' }
164
+ // { ok: false, decision: 'deny', executed: false, error: { code, message } }
165
+ ```
166
+
167
+ No knowledge of the pipeline, request format, or policy internals required.
168
+ All signing, validation, and auditing happens automatically.
169
+
170
+ ### Options
171
+
172
+ ```js
173
+ const lbe = createLocalExecutor({
174
+ rootDir: process.cwd(), // sandbox root — no writes escape this path
175
+ mode: 'observe', // 'observe' (log only) or 'enforce' (block)
176
+ shell: {
177
+ allowCommands: ['node', 'npm'], // only these commands may run
178
+ denyCommands: ['rm', 'curl'], // always blocked regardless of policy
179
+ maxRequests: 20 // per-minute shell rate limit
180
+ }
181
+ });
162
182
  ```
163
183
 
164
- No knowledge of the validation pipeline, request format, or policy internals
165
- required. Every method routes through the full gate sequence and returns a
166
- structured result.
184
+ ### Policy management
185
+
186
+ ```js
187
+ // Propose a rule — returns an object for the host to review, writes nothing
188
+ const proposal = lbe.policy.proposeRule({
189
+ effect: 'deny',
190
+ type: 'path',
191
+ pattern: 'secrets/**',
192
+ from: 'agent: these files should not be modified'
193
+ });
194
+
195
+ // Host accepts and writes the rule
196
+ lbe.policy.addRule(proposal);
197
+
198
+ // Read current policy
199
+ const policy = lbe.policy.read();
200
+
201
+ // Verify the audit chain has not been tampered with
202
+ lbe.audit.verify();
203
+ ```
204
+
205
+ ---
206
+
207
+ ## CLI reference
208
+
209
+ ```bash
210
+ npx lbe-exec init # create lbe.policy.json in observer mode
211
+ npx lbe-exec status # show mode, rule count, and audit entry count
212
+ npx lbe-exec enforce # switch to blocking
213
+ npx lbe-exec observe # switch back to advisory
214
+ npx lbe-exec policy # list active rules
215
+ ```
216
+
217
+ | Command | Purpose |
218
+ |---|---|
219
+ | `npx lbe-exec init` | Bootstrap governance — policy, keys, agent files |
220
+ | `npx lbe-exec status` | Show mode, rule count, audit entry count |
221
+ | `npx lbe-exec policy` | List active rules |
222
+ | `npx lbe-exec observe` | Set advisory (log-only) mode |
223
+ | `npx lbe-exec enforce` | Set blocking mode |
224
+ | `npx lbe-exec execute` | Pipe a JSON request from stdin or `--input <file>` |
167
225
 
168
226
  ---
169
227
 
170
228
  ## What ships
171
229
 
172
- This package contains the in-process execution controller and the WASM
173
- validation runtime. It does not contain a hosted service, daemon, or network
174
- dependency.
230
+ ```
231
+ dist/index.js In-process executor createLocalExecutor()
232
+ dist/cli.js Local CLI (npx lbe-exec)
233
+ dist/lbe_engine.wasm Verified WASM runtime binary
234
+ dist/wasm.lock.json Runtime integrity lock (SHA-256 of wasm binary)
235
+ assets/lbe-gates.png Gate sequence diagram
236
+ assets/story-allow.png Approved-request storyboard
237
+ assets/story-deny.png Blocked-request storyboard
238
+ assets/runtime-boundary.svg Runtime boundary diagram
239
+ types.d.ts TypeScript declarations
240
+ ```
241
+
242
+ Source code, tests, keys, and runtime state are not included.
243
+
244
+ ---
245
+
246
+ ## Limits
247
+
248
+ This package governs actions routed through its executor. It does not provide
249
+ kernel-level process isolation, network-egress control, multi-tenant separation,
250
+ or a hosted control plane.
175
251
 
176
- Source code, tests, keys, and runtime state are never included.
252
+ For the raw WASM runtime without a controller, see `@letterblack/lbe-sdk`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letterblack/lbe-exec",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "Local host-signed execution layer for LetterBlack LBE.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",