usertrust-openclaw 1.3.0 → 1.4.0
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 +37 -236
- package/package.json +3 -15
package/README.md
CHANGED
|
@@ -1,264 +1,65 @@
|
|
|
1
|
-
# usertrust
|
|
1
|
+
# usertrust-openclaw
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
```typescript
|
|
6
|
-
import { trust } from "usertrust";
|
|
7
|
-
import Anthropic from "@anthropic-ai/sdk";
|
|
8
|
-
|
|
9
|
-
// dryRun: true — skips TigerBeetle so you can try instantly.
|
|
10
|
-
// Audit chain and policy engine still run.
|
|
11
|
-
const client = await trust(new Anthropic(), { dryRun: true, budget: 50_000 });
|
|
12
|
-
|
|
13
|
-
const { response, governance } = await client.messages.create({
|
|
14
|
-
model: "claude-sonnet-4.6",
|
|
15
|
-
max_tokens: 1024,
|
|
16
|
-
messages: [{ role: "user", content: "Analyze this contract" }],
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
console.log(governance);
|
|
20
|
-
|
|
21
|
-
// REQUIRED — process hangs without this
|
|
22
|
-
await client.destroy();
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
That's it. One function wraps any supported LLM client. Every call is metered, audited, and policy-checked.
|
|
26
|
-
|
|
27
|
-
### Expected Output
|
|
28
|
-
|
|
29
|
-
The `governance` receipt returned from every call:
|
|
30
|
-
|
|
31
|
-
```
|
|
32
|
-
{
|
|
33
|
-
cost: 42,
|
|
34
|
-
budgetRemaining: 49958,
|
|
35
|
-
transferId: "tx_m4k7p2_a1b2c3",
|
|
36
|
-
auditHash: "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
|
37
|
-
settled: true,
|
|
38
|
-
model: "claude-sonnet-4.6",
|
|
39
|
-
provider: "anthropic",
|
|
40
|
-
inputTokens: 12,
|
|
41
|
-
outputTokens: 28
|
|
42
|
-
}
|
|
43
|
-
```
|
|
3
|
+
[`usertrust`](https://usertrust.ai) governance plugin for **OpenClaw**. Adds budget enforcement, policy gates, PII/injection scanning, and a hash-chained audit trail to every LLM call — with zero changes to your agent code. Install the plugin and every streamed call is governed.
|
|
44
4
|
|
|
45
5
|
## Install
|
|
46
6
|
|
|
47
7
|
```bash
|
|
48
|
-
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
This creates a `.usertrust/` vault in your project root with default config, policies, and an empty audit chain.
|
|
52
|
-
|
|
53
|
-
## Integration
|
|
54
|
-
|
|
55
|
-
Works with Anthropic, OpenAI, and Google AI SDKs:
|
|
56
|
-
|
|
57
|
-
```typescript
|
|
58
|
-
import { trust } from "usertrust";
|
|
59
|
-
import Anthropic from "@anthropic-ai/sdk";
|
|
60
|
-
import OpenAI from "openai";
|
|
61
|
-
|
|
62
|
-
// Anthropic
|
|
63
|
-
const anthropic = await trust(new Anthropic());
|
|
64
|
-
const { response, governance } = await anthropic.messages.create({ ... });
|
|
65
|
-
|
|
66
|
-
// OpenAI
|
|
67
|
-
const openai = await trust(new OpenAI());
|
|
68
|
-
const { response, governance } = await openai.chat.completions.create({ ... });
|
|
69
|
-
|
|
70
|
-
// With options (full mode — requires TigerBeetle)
|
|
71
|
-
const client = await trust(new Anthropic(), {
|
|
72
|
-
budget: 100_000,
|
|
73
|
-
});
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
Every call returns `{ response, governance }` where `governance` is a receipt:
|
|
77
|
-
|
|
78
|
-
```typescript
|
|
79
|
-
{
|
|
80
|
-
transferId: "tx_m4k7r2_a1b2c3",
|
|
81
|
-
cost: 142,
|
|
82
|
-
budgetRemaining: 49_858,
|
|
83
|
-
auditHash: "a3f8...",
|
|
84
|
-
settled: true,
|
|
85
|
-
model: "claude-sonnet-4.6",
|
|
86
|
-
provider: "anthropic",
|
|
87
|
-
timestamp: "2026-03-16T12:00:00.000Z"
|
|
88
|
-
}
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
## Inspect
|
|
92
|
-
|
|
93
|
-
```bash
|
|
94
|
-
npx usertrust inspect
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
```
|
|
98
|
-
=== Vault Report ===
|
|
99
|
-
Chain: 847 events · 12 segments
|
|
100
|
-
Budget: 38,420 / 50,000 UT remaining
|
|
101
|
-
Models: claude-sonnet-4-6 (412) · gpt-4o (289) · gemini-2.0-flash (146)
|
|
102
|
-
Policy: 3 rules active · 0 violations
|
|
103
|
-
PII: 2 warnings · 0 blocks
|
|
104
|
-
Merkle: a3f8c1...d92b (root)
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
## CLI
|
|
108
|
-
|
|
109
|
-
All commands support `--json` for machine-readable output.
|
|
110
|
-
|
|
111
|
-
```bash
|
|
112
|
-
usertrust init # Create .usertrust/ vault
|
|
113
|
-
usertrust inspect # Vault bank statement
|
|
114
|
-
usertrust health # Entropy diagnostics (6 signals, 0-100 score)
|
|
115
|
-
usertrust verify # Verify audit chain integrity
|
|
116
|
-
usertrust snapshot # Checkpoint/restore vault state
|
|
117
|
-
usertrust tb # TigerBeetle process management
|
|
118
|
-
usertrust completions # Shell completions (bash, zsh, fish)
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
### JSON output
|
|
122
|
-
|
|
123
|
-
Every command supports `--json` for scripting and CI:
|
|
124
|
-
|
|
125
|
-
```bash
|
|
126
|
-
usertrust inspect --json | jq '.data.remaining'
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
### Shell completions
|
|
130
|
-
|
|
131
|
-
```bash
|
|
132
|
-
# Bash
|
|
133
|
-
usertrust completions bash > ~/.local/share/bash-completion/completions/usertrust
|
|
134
|
-
|
|
135
|
-
# Zsh
|
|
136
|
-
usertrust completions zsh > "${fpath[1]}/_usertrust"
|
|
137
|
-
|
|
138
|
-
# Fish
|
|
139
|
-
usertrust completions fish > ~/.config/fish/completions/usertrust.fish
|
|
8
|
+
openclaw plugins install usertrust-openclaw
|
|
140
9
|
```
|
|
141
10
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
All errors include fix suggestions and documentation links:
|
|
145
|
-
|
|
146
|
-
```
|
|
147
|
-
Ledger unavailable: connection refused
|
|
148
|
-
|
|
149
|
-
Hint: Start TigerBeetle with "npx usertrust tb start" or use { dryRun: true } to skip the ledger.
|
|
150
|
-
Docs: https://usertrust.ai/docs/errors/ledger-unavailable
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
## Config
|
|
154
|
-
|
|
155
|
-
Create `.usertrust/usertrust.config.json`:
|
|
11
|
+
Or configure it manually in `openclaw.json`:
|
|
156
12
|
|
|
157
13
|
```json
|
|
158
14
|
{
|
|
159
|
-
"
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
15
|
+
"plugins": {
|
|
16
|
+
"entries": {
|
|
17
|
+
"usertrust": {
|
|
18
|
+
"enabled": true,
|
|
19
|
+
"config": { "budget": 100000, "dryRun": true }
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
165
23
|
}
|
|
166
24
|
```
|
|
167
25
|
|
|
168
|
-
|
|
26
|
+
## Programmatic use
|
|
169
27
|
|
|
170
28
|
```typescript
|
|
171
|
-
import {
|
|
29
|
+
import { createUsertrustPlugin } from "usertrust-openclaw";
|
|
172
30
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
tier: "pro",
|
|
177
|
-
pii: "block",
|
|
178
|
-
circuitBreaker: { failureThreshold: 5, resetTimeout: 60_000 },
|
|
179
|
-
patterns: { enabled: true },
|
|
180
|
-
audit: { rotation: "daily", indexLimit: 10_000 },
|
|
31
|
+
const plugin = createUsertrustPlugin({
|
|
32
|
+
budget: 100_000, // usertokens for this session
|
|
33
|
+
dryRun: true, // try instantly — skips TigerBeetle, keeps policy + audit
|
|
181
34
|
});
|
|
182
35
|
```
|
|
183
36
|
|
|
184
|
-
##
|
|
185
|
-
|
|
186
|
-
**Double-entry ledger** — TigerBeetle-backed financial transactions with two-phase lifecycle (PENDING, POST, VOID). Not a counter.
|
|
187
|
-
|
|
188
|
-
**SHA-256 hash-chained audit** — Every event links to the previous event's hash. Tamper-evident by construction. Append-only JSONL.
|
|
189
|
-
|
|
190
|
-
**Merkle proofs (RFC 6962)** — Inclusion and consistency proofs for public verifiability. Any third party can verify a specific event existed in the chain.
|
|
191
|
-
|
|
192
|
-
**Policy engine** — 12 field operators (`eq`, `gt`, `in`, `regex`, etc.) with soft/hard enforcement. Block specific models, cap costs, require approvals.
|
|
193
|
-
|
|
194
|
-
**PII detection** — Luhn-validated credit card numbers, SSN patterns, email addresses, phone numbers, IPv4 addresses. Block or warn before data leaves your network.
|
|
37
|
+
## How it works
|
|
195
38
|
|
|
196
|
-
|
|
39
|
+
The plugin hooks OpenClaw's `wrapStreamFn`, so it sits directly on the stream:
|
|
197
40
|
|
|
198
|
-
**Pattern memory** — Learns optimal model routing from historical prompt-cost-success data. Feeds routing decisions when connected to proxy.
|
|
199
|
-
|
|
200
|
-
## Why this exists
|
|
201
|
-
|
|
202
|
-
AI agents operate with financial authority. Every LLM call costs money. Without governance:
|
|
203
|
-
|
|
204
|
-
- There is no audit trail when an agent spends $500 on a hallucinated loop
|
|
205
|
-
- There is no budget enforcement across multiple concurrent agents
|
|
206
|
-
- There is no way to prove what happened after the fact
|
|
207
|
-
- A race condition between two agents can double-spend the same budget
|
|
208
|
-
|
|
209
|
-
A counter in a database is not a financial ledger. `usertrust` uses the same double-entry, two-phase commit pattern that banks use. PENDING holds reserve the budget atomically. POST settles. VOID releases. The audit chain is hash-linked and Merkle-provable.
|
|
210
|
-
|
|
211
|
-
## Comparison
|
|
212
|
-
|
|
213
|
-
| Feature | usertrust | LiteLLM | Portkey | Langfuse |
|
|
214
|
-
|---------|-----------|---------|---------|----------|
|
|
215
|
-
| Financial ledger | TigerBeetle | Counter | Counter | Observation |
|
|
216
|
-
| Two-phase spend | PENDING/POST/VOID | No | No | No |
|
|
217
|
-
| Hash-chained audit | SHA-256 | No | No | No |
|
|
218
|
-
| Merkle proofs | RFC 6962 | No | No | No |
|
|
219
|
-
| Policy engine | 12 operators | Basic rules | Basic rules | No |
|
|
220
|
-
| PII detection | Luhn + regex | No | No | No |
|
|
221
|
-
| Circuit breakers | Per-provider | Global | Per-provider | No |
|
|
222
|
-
| Offline-first | Local vault | Proxy required | Proxy required | Proxy required |
|
|
223
|
-
| Open source | Apache 2.0 | Apache 2.0 | Proprietary | Apache 2.0 |
|
|
224
|
-
|
|
225
|
-
## Upgrade path
|
|
226
|
-
|
|
227
|
-
When you outgrow local mode, point at the proxy. One line:
|
|
228
|
-
|
|
229
|
-
```typescript
|
|
230
|
-
const client = await trust(new Anthropic(), {
|
|
231
|
-
proxy: "https://proxy.usertools.ai",
|
|
232
|
-
key: process.env.USERTOOLS_KEY,
|
|
233
|
-
});
|
|
234
41
|
```
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
npx usertrust-verify .usertrust
|
|
42
|
+
agent call → OpenClaw → usertrust wrapStreamFn
|
|
43
|
+
1. Pre-flight budget check — a call whose estimated cost would exceed the
|
|
44
|
+
remaining budget is DENIED before it starts (no single-call overshoot).
|
|
45
|
+
2. PENDING hold reserves the estimate.
|
|
46
|
+
3. Forward to the real stream, accumulating token usage from each chunk.
|
|
47
|
+
4. POST settles the actual cost (or VOID on error); an early consumer
|
|
48
|
+
`break` still settles and releases the hold — no leaked reservation.
|
|
49
|
+
5. Every call is written to the tamper-evident audit chain.
|
|
244
50
|
```
|
|
245
51
|
|
|
246
|
-
|
|
247
|
-
Vault integrity: VERIFIED
|
|
248
|
-
Chain length: 847 events
|
|
249
|
-
Merkle root: a3f8c1...d92b
|
|
250
|
-
Hash algorithm: SHA-256
|
|
251
|
-
First event: 2026-03-01T08:12:44.000Z
|
|
252
|
-
Last event: 2026-03-16T14:33:21.000Z
|
|
253
|
-
All hashes: valid (847/847)
|
|
254
|
-
```
|
|
52
|
+
## Config
|
|
255
53
|
|
|
256
|
-
|
|
54
|
+
| Field | Type | Description |
|
|
55
|
+
|-------|------|-------------|
|
|
56
|
+
| `budget` | `number` | Session budget in usertokens (required). |
|
|
57
|
+
| `dryRun` | `boolean` | Skip TigerBeetle; policy gate + audit still run. |
|
|
58
|
+
| `vaultBase` | `string` | Vault location (defaults to the project root). |
|
|
59
|
+
| `proxy` / `proxyKey` | `string` | Point at the hosted proxy for cross-agent budget enforcement. |
|
|
257
60
|
|
|
258
|
-
|
|
61
|
+
Budget enforcement is **pre-spend**: because a stream's cost isn't known until it finishes, the estimate assumes the model's full output budget, so calls are denied conservatively rather than allowed to overshoot. Size `budget` accordingly.
|
|
259
62
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
---
|
|
63
|
+
## License
|
|
263
64
|
|
|
264
|
-
UserTrust™ is a trademark of Usertools, Inc.
|
|
65
|
+
Apache 2.0 · UserTrust™ is a trademark of Usertools, Inc.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "usertrust-openclaw",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "usertrust governance plugin for OpenClaw. Budget enforcement, audit trails, and policy gates for every LLM call — zero code changes.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Usertools, Inc. <hello@usertools.ai> (https://usertrust.ai)",
|
|
@@ -11,16 +11,7 @@
|
|
|
11
11
|
"directory": "packages/openclaw"
|
|
12
12
|
},
|
|
13
13
|
"bugs": "https://github.com/usertools-ai/usertrust/issues",
|
|
14
|
-
"keywords": [
|
|
15
|
-
"openclaw",
|
|
16
|
-
"usertrust",
|
|
17
|
-
"ai",
|
|
18
|
-
"governance",
|
|
19
|
-
"budget",
|
|
20
|
-
"audit",
|
|
21
|
-
"llm",
|
|
22
|
-
"plugin"
|
|
23
|
-
],
|
|
14
|
+
"keywords": ["openclaw", "usertrust", "ai", "governance", "budget", "audit", "llm", "plugin"],
|
|
24
15
|
"type": "module",
|
|
25
16
|
"main": "dist/index.js",
|
|
26
17
|
"types": "dist/index.d.ts",
|
|
@@ -35,10 +26,7 @@
|
|
|
35
26
|
"prepublishOnly": "tsc",
|
|
36
27
|
"demo": "tsx demo/runaway-agent.ts"
|
|
37
28
|
},
|
|
38
|
-
"files": [
|
|
39
|
-
"dist",
|
|
40
|
-
"openclaw.plugin.json"
|
|
41
|
-
],
|
|
29
|
+
"files": ["dist", "openclaw.plugin.json"],
|
|
42
30
|
"dependencies": {
|
|
43
31
|
"usertrust": "*"
|
|
44
32
|
},
|