usertrust-verify 1.1.0 → 1.2.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 +268 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
# usertrust™
|
|
2
|
+
|
|
3
|
+
Financial governance for AI agents. Every LLM call becomes an immutable, auditable transaction.
|
|
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
|
+
```
|
|
44
|
+
|
|
45
|
+
## Install
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npx usertrust init
|
|
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
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Error messages
|
|
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`:
|
|
156
|
+
|
|
157
|
+
```json
|
|
158
|
+
{
|
|
159
|
+
"budget": 50000,
|
|
160
|
+
"tier": "pro",
|
|
161
|
+
"pii": "block",
|
|
162
|
+
"board": { "enabled": true, "vetoThreshold": "high" },
|
|
163
|
+
"circuitBreaker": { "failureThreshold": 5, "resetTimeout": 60000 },
|
|
164
|
+
"patterns": { "enabled": true },
|
|
165
|
+
"audit": { "rotation": "daily", "indexLimit": 10000 }
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
`defineConfig` is available as a TypeScript type-checking helper for validating config objects in your code. The actual config file must be `usertrust.config.json` (JSON format):
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
import { defineConfig } from "usertrust";
|
|
173
|
+
|
|
174
|
+
// Type-check your config object — useful for programmatic overrides
|
|
175
|
+
const config = defineConfig({
|
|
176
|
+
budget: 50_000,
|
|
177
|
+
tier: "pro",
|
|
178
|
+
pii: "block",
|
|
179
|
+
board: { enabled: true, vetoThreshold: "high" },
|
|
180
|
+
circuitBreaker: { failureThreshold: 5, resetTimeout: 60_000 },
|
|
181
|
+
patterns: { enabled: true },
|
|
182
|
+
audit: { rotation: "daily", indexLimit: 10_000 },
|
|
183
|
+
});
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Features
|
|
187
|
+
|
|
188
|
+
**Double-entry ledger** — TigerBeetle-backed financial transactions with two-phase lifecycle (PENDING, POST, VOID). Not a counter.
|
|
189
|
+
|
|
190
|
+
**SHA-256 hash-chained audit** — Every event links to the previous event's hash. Tamper-evident by construction. Append-only JSONL.
|
|
191
|
+
|
|
192
|
+
**Merkle proofs (RFC 6962)** — Inclusion and consistency proofs for public verifiability. Any third party can verify a specific event existed in the chain.
|
|
193
|
+
|
|
194
|
+
**Policy engine** — 12 field operators (`eq`, `gt`, `in`, `regex`, etc.) with soft/hard enforcement. Block specific models, cap costs, require approvals.
|
|
195
|
+
|
|
196
|
+
**PII detection** — Luhn-validated credit card numbers, SSN patterns, email addresses, phone numbers, IPv4 addresses. Block or warn before data leaves your network.
|
|
197
|
+
|
|
198
|
+
**Board of Directors** — Heuristic AI oversight layer. Risk and Compliance directors vote on high-stakes operations. Configurable veto thresholds.
|
|
199
|
+
|
|
200
|
+
**Circuit breakers** — Per-provider failure isolation. When a provider starts failing, the breaker opens and requests fail fast instead of cascading.
|
|
201
|
+
|
|
202
|
+
**Pattern memory** — Learns optimal model routing from historical prompt-cost-success data. Feeds routing decisions when connected to proxy.
|
|
203
|
+
|
|
204
|
+
## Why this exists
|
|
205
|
+
|
|
206
|
+
AI agents operate with financial authority. Every LLM call costs money. Without governance:
|
|
207
|
+
|
|
208
|
+
- There is no audit trail when an agent spends $500 on a hallucinated loop
|
|
209
|
+
- There is no budget enforcement across multiple concurrent agents
|
|
210
|
+
- There is no way to prove what happened after the fact
|
|
211
|
+
- A race condition between two agents can double-spend the same budget
|
|
212
|
+
|
|
213
|
+
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.
|
|
214
|
+
|
|
215
|
+
## Comparison
|
|
216
|
+
|
|
217
|
+
| Feature | usertrust | LiteLLM | Portkey | Langfuse |
|
|
218
|
+
|---------|-----------|---------|---------|----------|
|
|
219
|
+
| Financial ledger | TigerBeetle | Counter | Counter | Observation |
|
|
220
|
+
| Two-phase spend | PENDING/POST/VOID | No | No | No |
|
|
221
|
+
| Hash-chained audit | SHA-256 | No | No | No |
|
|
222
|
+
| Merkle proofs | RFC 6962 | No | No | No |
|
|
223
|
+
| Policy engine | 12 operators | Basic rules | Basic rules | No |
|
|
224
|
+
| PII detection | Luhn + regex | No | No | No |
|
|
225
|
+
| Circuit breakers | Per-provider | Global | Per-provider | No |
|
|
226
|
+
| Offline-first | Local vault | Proxy required | Proxy required | Proxy required |
|
|
227
|
+
| Open source | Apache 2.0 | Apache 2.0 | Proprietary | Apache 2.0 |
|
|
228
|
+
|
|
229
|
+
## Upgrade path
|
|
230
|
+
|
|
231
|
+
When you outgrow local mode, point at the proxy. One line:
|
|
232
|
+
|
|
233
|
+
```typescript
|
|
234
|
+
const client = await trust(new Anthropic(), {
|
|
235
|
+
proxy: "https://proxy.usertools.ai",
|
|
236
|
+
key: process.env.USERTOOLS_KEY,
|
|
237
|
+
});
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Same API. Same receipts. Now with cross-agent budget enforcement, centralized audit, and real-time dashboards.
|
|
241
|
+
|
|
242
|
+
## Verify
|
|
243
|
+
|
|
244
|
+
Standalone verification with zero dependencies:
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
npx usertrust-verify .usertrust
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
```
|
|
251
|
+
Vault integrity: VERIFIED
|
|
252
|
+
Chain length: 847 events
|
|
253
|
+
Merkle root: a3f8c1...d92b
|
|
254
|
+
Hash algorithm: SHA-256
|
|
255
|
+
First event: 2026-03-01T08:12:44.000Z
|
|
256
|
+
Last event: 2026-03-16T14:33:21.000Z
|
|
257
|
+
All hashes: valid (847/847)
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
The verify package has zero runtime dependencies. It reads JSONL, recomputes SHA-256 hashes, and checks the chain. Anyone can verify a vault without trusting the usertrust SDK.
|
|
261
|
+
|
|
262
|
+
## License
|
|
263
|
+
|
|
264
|
+
Apache 2.0
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
UserTrust™ is a trademark of Usertools, Inc.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "usertrust-verify",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Zero-dependency verifier for usertrust governance receipts. Validates hash chains, Merkle proofs, and audit trails.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Usertools, Inc. <hello@usertools.ai> (https://usertrust.ai)",
|