@nullbridge/sdk 1.0.1 → 1.0.3
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 +197 -81
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,12 +12,14 @@ NullBridge gives your AI agents a cryptographic identity, secure credential vaul
|
|
|
12
12
|
npm install @nullbridge/sdk
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
+
Requires Node.js 18+.
|
|
16
|
+
|
|
15
17
|
---
|
|
16
18
|
|
|
17
19
|
## Quick Start
|
|
18
20
|
|
|
19
21
|
```js
|
|
20
|
-
|
|
22
|
+
import { NullBridge } from '@nullbridge/sdk';
|
|
21
23
|
|
|
22
24
|
const nb = new NullBridge({
|
|
23
25
|
licenseKey: process.env.NULLBRIDGE_LICENSE_KEY,
|
|
@@ -26,35 +28,22 @@ const nb = new NullBridge({
|
|
|
26
28
|
await nb.init();
|
|
27
29
|
|
|
28
30
|
const agent = await nb.agents.register({
|
|
29
|
-
|
|
31
|
+
id: 'claims-processor-001', // unique identifier for this agent
|
|
32
|
+
name: 'Claims Processor',
|
|
30
33
|
type: 'llm',
|
|
31
34
|
model: 'gpt-4o',
|
|
32
35
|
scopes: ['read:claims', 'write:reports'],
|
|
33
36
|
});
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
That's it. NullBridge validates your license on startup, registers your agent with a cryptographic identity, and begins monitoring automatically.
|
|
37
|
-
|
|
38
|
-
---
|
|
39
37
|
|
|
40
|
-
|
|
38
|
+
// Log every action your agent takes
|
|
39
|
+
await agent.logAction('process_claim', { claimId: 'CLM-001', outcome: 'approved' });
|
|
41
40
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
licenseKey: process.env.NULLBRIDGE_LICENSE_KEY, // required
|
|
45
|
-
serverUrl: 'https://nullbridge-license-server-production.up.railway.app', // default
|
|
46
|
-
apiUrl: 'https://api.nullbridge.ai', // default
|
|
47
|
-
skipLicense: false, // set true for local development only
|
|
48
|
-
autoShutdown: true, // shut down process if license is revoked
|
|
49
|
-
checkInterval: 86400000, // license check interval in ms (default: 24 hours)
|
|
50
|
-
debug: false, // enable verbose logging
|
|
51
|
-
siem: {
|
|
52
|
-
endpoint: 'https://your-siem.com/ingest', // optional
|
|
53
|
-
format: 'json', // 'json' | 'cef' | 'leef'
|
|
54
|
-
},
|
|
55
|
-
});
|
|
41
|
+
// Graceful shutdown
|
|
42
|
+
await nb.shutdown();
|
|
56
43
|
```
|
|
57
44
|
|
|
45
|
+
That's it. NullBridge validates your license on startup, registers your agent with a cryptographic identity, and begins monitoring automatically. Every action appears in your NullBridge dashboard in real time.
|
|
46
|
+
|
|
58
47
|
---
|
|
59
48
|
|
|
60
49
|
## Environment Variables
|
|
@@ -63,15 +52,30 @@ const nb = new NullBridge({
|
|
|
63
52
|
NULLBRIDGE_LICENSE_KEY=NB-XXXX-XXXX-XXXX-XXXX
|
|
64
53
|
```
|
|
65
54
|
|
|
66
|
-
Contact brian@nullbridge.ai to obtain a license key.
|
|
55
|
+
Contact [brian@nullbridge.ai](mailto:brian@nullbridge.ai) to obtain a license key.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Configuration
|
|
60
|
+
|
|
61
|
+
```js
|
|
62
|
+
const nb = new NullBridge({
|
|
63
|
+
licenseKey: process.env.NULLBRIDGE_LICENSE_KEY, // required
|
|
64
|
+
apiUrl: 'https://api.nullbridge.ai', // default
|
|
65
|
+
skipLicense: false, // set true for local dev only
|
|
66
|
+
autoShutdown: true, // shut down process if license is revoked
|
|
67
|
+
checkInterval: 86400000, // license recheck interval in ms (default: 24h)
|
|
68
|
+
debug: false, // enable verbose logging
|
|
69
|
+
});
|
|
70
|
+
```
|
|
67
71
|
|
|
68
72
|
---
|
|
69
73
|
|
|
70
74
|
## API Reference
|
|
71
75
|
|
|
72
76
|
### `nb.init()`
|
|
73
|
-
|
|
74
|
-
Validates license and starts background services.
|
|
77
|
+
|
|
78
|
+
Initialize NullBridge. Call once on application startup before serving traffic. Validates your license key and starts background services.
|
|
75
79
|
|
|
76
80
|
```js
|
|
77
81
|
await nb.init();
|
|
@@ -82,41 +86,106 @@ await nb.init();
|
|
|
82
86
|
### `nb.agents`
|
|
83
87
|
|
|
84
88
|
#### `nb.agents.register(options)`
|
|
85
|
-
|
|
89
|
+
|
|
90
|
+
Register an AI agent with NullBridge. The agent appears immediately in your NullBridge dashboard under Agent Registry.
|
|
86
91
|
|
|
87
92
|
```js
|
|
88
93
|
const agent = await nb.agents.register({
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
94
|
+
id: 'fraud-detector-001', // required — unique, stable identifier
|
|
95
|
+
name: 'Fraud Detector', // required — display name
|
|
96
|
+
type: 'llm', // required — 'llm' | 'rpa' | 'workflow' | 'custom'
|
|
97
|
+
model: 'claude-3-5-sonnet', // optional
|
|
92
98
|
scopes: ['read:transactions', 'write:alerts'], // optional
|
|
93
|
-
metadata: {
|
|
99
|
+
metadata: {
|
|
100
|
+
team: 'risk',
|
|
101
|
+
environment: 'prod',
|
|
102
|
+
owner_email: 'team@company.com',
|
|
103
|
+
},
|
|
94
104
|
});
|
|
95
105
|
```
|
|
96
106
|
|
|
97
|
-
|
|
98
|
-
|
|
107
|
+
Returns an agent instance with the following methods:
|
|
108
|
+
|
|
109
|
+
#### `agent.logAction(action, details?)`
|
|
110
|
+
|
|
111
|
+
Log an action this agent performed. Appears in the audit trail.
|
|
99
112
|
|
|
100
113
|
```js
|
|
101
|
-
await agent.logAction('analyze_transaction', {
|
|
114
|
+
await agent.logAction('analyze_transaction', {
|
|
115
|
+
txId: 'TX-1234',
|
|
116
|
+
amount: 5000,
|
|
117
|
+
result: 'approved',
|
|
118
|
+
});
|
|
102
119
|
```
|
|
103
120
|
|
|
104
121
|
#### `agent.hasScope(scope)`
|
|
105
|
-
|
|
122
|
+
|
|
123
|
+
Check if the agent has a specific permission scope.
|
|
106
124
|
|
|
107
125
|
```js
|
|
108
|
-
if (!agent.hasScope('write:alerts'))
|
|
126
|
+
if (!agent.hasScope('write:alerts')) {
|
|
127
|
+
throw new Error('Agent not authorized for this action');
|
|
128
|
+
}
|
|
109
129
|
```
|
|
110
130
|
|
|
111
131
|
#### `agent.deregister()`
|
|
112
|
-
|
|
132
|
+
|
|
133
|
+
Deregister the agent and revoke its identity. The agent status updates to `deprovisioned` in the dashboard.
|
|
134
|
+
|
|
135
|
+
```js
|
|
136
|
+
await agent.deregister();
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
### `nb.audit`
|
|
142
|
+
|
|
143
|
+
#### `nb.audit.log(event)`
|
|
144
|
+
|
|
145
|
+
Log an agent action to the audit trail. Supports fire-and-forget (no await required for non-critical logging).
|
|
146
|
+
|
|
147
|
+
```js
|
|
148
|
+
await nb.audit.log({
|
|
149
|
+
agentId: agent.id, // required
|
|
150
|
+
agentName: agent.name, // recommended
|
|
151
|
+
action: 'process_claim', // required
|
|
152
|
+
resource: 'claim:CLM-001', // optional
|
|
153
|
+
outcome: 'success', // 'success' | 'failure' | 'blocked'
|
|
154
|
+
details: { amount: 15000 }, // optional
|
|
155
|
+
ip: req.ip, // optional
|
|
156
|
+
duration_ms: 1240, // optional
|
|
157
|
+
});
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
#### `nb.audit.batch(events)`
|
|
161
|
+
|
|
162
|
+
Log multiple events in a single request. More efficient for high-throughput agents.
|
|
163
|
+
|
|
164
|
+
```js
|
|
165
|
+
await nb.audit.batch([
|
|
166
|
+
{ agentId: agent.id, agentName: agent.name, action: 'read_record', outcome: 'success' },
|
|
167
|
+
{ agentId: agent.id, agentName: agent.name, action: 'write_report', outcome: 'success' },
|
|
168
|
+
{ agentId: agent.id, agentName: agent.name, action: 'delete_record', outcome: 'blocked' },
|
|
169
|
+
]);
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
#### `nb.audit.logViolation(agentId, agentName, action, reason)`
|
|
173
|
+
|
|
174
|
+
Log a policy violation. Outcome is automatically set to `blocked` and triggers a SIEM alert.
|
|
175
|
+
|
|
176
|
+
```js
|
|
177
|
+
await nb.audit.logViolation(agent.id, agent.name, 'delete_record', 'scope_denied');
|
|
178
|
+
```
|
|
113
179
|
|
|
114
180
|
---
|
|
115
181
|
|
|
116
182
|
### `nb.credentials`
|
|
117
183
|
|
|
184
|
+
NullBridge tracks credential lifecycle metadata — store, rotate, and revoke events are logged to your audit trail and SIEM automatically.
|
|
185
|
+
|
|
118
186
|
#### `nb.credentials.store(options)`
|
|
119
|
-
|
|
187
|
+
|
|
188
|
+
Register a credential and log it to the audit trail.
|
|
120
189
|
|
|
121
190
|
```js
|
|
122
191
|
const credId = await nb.credentials.store({
|
|
@@ -124,52 +193,24 @@ const credId = await nb.credentials.store({
|
|
|
124
193
|
name: 'openai-api-key',
|
|
125
194
|
value: process.env.OPENAI_API_KEY,
|
|
126
195
|
type: 'api_key', // 'api_key' | 'oauth_token' | 'password' | 'certificate'
|
|
127
|
-
ttl: 86400, // optional:
|
|
196
|
+
ttl: 86400, // optional: seconds until expiry
|
|
128
197
|
});
|
|
129
198
|
```
|
|
130
199
|
|
|
131
|
-
#### `nb.credentials.
|
|
132
|
-
Retrieve a credential value.
|
|
200
|
+
#### `nb.credentials.rotate(credId, newValue?)`
|
|
133
201
|
|
|
134
|
-
|
|
135
|
-
const apiKey = await nb.credentials.get(credId);
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
#### `nb.credentials.rotate(credId, newValue)`
|
|
139
|
-
Rotate a credential and log the rotation in audit trail.
|
|
202
|
+
Log a credential rotation event.
|
|
140
203
|
|
|
141
204
|
```js
|
|
142
205
|
await nb.credentials.rotate(credId, newApiKey);
|
|
143
206
|
```
|
|
144
207
|
|
|
145
208
|
#### `nb.credentials.revoke(credId)`
|
|
146
|
-
Permanently revoke a credential.
|
|
147
|
-
|
|
148
|
-
---
|
|
149
209
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
#### `nb.audit.log(event)`
|
|
153
|
-
Log an agent action to the audit trail.
|
|
154
|
-
|
|
155
|
-
```js
|
|
156
|
-
nb.audit.log({
|
|
157
|
-
agentId: agent.id,
|
|
158
|
-
agentName: agent.name,
|
|
159
|
-
action: 'process_claim', // required
|
|
160
|
-
resource: 'claim:CLM-20240001', // optional
|
|
161
|
-
outcome: 'success', // 'success' | 'failure' | 'blocked'
|
|
162
|
-
details: { amount: 15000 }, // optional
|
|
163
|
-
ip: req.ip, // optional
|
|
164
|
-
duration: 1240, // optional: ms
|
|
165
|
-
});
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
#### `nb.audit.logViolation(agentId, agentName, action, reason)`
|
|
169
|
-
Log a policy violation (outcome is automatically set to 'blocked').
|
|
210
|
+
Permanently revoke a credential and log the revocation.
|
|
170
211
|
|
|
171
212
|
```js
|
|
172
|
-
nb.
|
|
213
|
+
await nb.credentials.revoke(credId);
|
|
173
214
|
```
|
|
174
215
|
|
|
175
216
|
---
|
|
@@ -177,7 +218,8 @@ nb.audit.logViolation(agent.id, agent.name, 'delete_record', 'scope_denied');
|
|
|
177
218
|
### `nb.anomaly`
|
|
178
219
|
|
|
179
220
|
#### `nb.anomaly.record(agentId, metric, value)`
|
|
180
|
-
|
|
221
|
+
|
|
222
|
+
Record a behavioral metric. NullBridge builds a statistical baseline and fires an alert when a value deviates significantly (z-score threshold configurable in dashboard).
|
|
181
223
|
|
|
182
224
|
```js
|
|
183
225
|
nb.anomaly.record(agent.id, 'api_calls_per_minute', 14);
|
|
@@ -186,27 +228,30 @@ nb.anomaly.record(agent.id, 'unique_endpoints', 3);
|
|
|
186
228
|
```
|
|
187
229
|
|
|
188
230
|
#### `nb.anomaly.onAlert(handler)`
|
|
189
|
-
|
|
231
|
+
|
|
232
|
+
Register a callback that fires when an anomaly is detected.
|
|
190
233
|
|
|
191
234
|
```js
|
|
192
235
|
nb.anomaly.onAlert(alert => {
|
|
193
|
-
console.error(`Anomaly: ${alert.agentId} — ${alert.metric} (z=${alert.zScore})`);
|
|
194
|
-
//
|
|
236
|
+
console.error(`Anomaly detected: ${alert.agentId} — ${alert.metric} (z=${alert.zScore})`);
|
|
237
|
+
// Forward to PagerDuty, Slack, OpsGenie, etc.
|
|
195
238
|
});
|
|
196
239
|
```
|
|
197
240
|
|
|
198
241
|
#### `nb.anomaly.check(agentId, metric, value)`
|
|
242
|
+
|
|
199
243
|
Check if a value is anomalous without recording it.
|
|
200
244
|
|
|
201
245
|
```js
|
|
202
246
|
const { anomalous, zScore } = nb.anomaly.check(agent.id, 'api_calls', 500);
|
|
203
|
-
if (anomalous) console.warn(
|
|
247
|
+
if (anomalous) console.warn(`Unusual API call volume — z-score: ${zScore}`);
|
|
204
248
|
```
|
|
205
249
|
|
|
206
250
|
---
|
|
207
251
|
|
|
208
252
|
### `nb.shutdown()`
|
|
209
|
-
|
|
253
|
+
|
|
254
|
+
Gracefully shut down NullBridge — flushes pending audit logs and stops background services. Call before `process.exit()`.
|
|
210
255
|
|
|
211
256
|
```js
|
|
212
257
|
process.on('SIGTERM', async () => {
|
|
@@ -217,16 +262,87 @@ process.on('SIGTERM', async () => {
|
|
|
217
262
|
|
|
218
263
|
---
|
|
219
264
|
|
|
265
|
+
## Full Example
|
|
266
|
+
|
|
267
|
+
```js
|
|
268
|
+
import { NullBridge } from '@nullbridge/sdk';
|
|
269
|
+
|
|
270
|
+
const nb = new NullBridge({
|
|
271
|
+
licenseKey: process.env.NULLBRIDGE_LICENSE_KEY,
|
|
272
|
+
debug: false,
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
await nb.init();
|
|
276
|
+
|
|
277
|
+
// Register your agent once on startup
|
|
278
|
+
const agent = await nb.agents.register({
|
|
279
|
+
id: 'invoice-processor-001',
|
|
280
|
+
name: 'Invoice Processor',
|
|
281
|
+
type: 'llm',
|
|
282
|
+
model: 'gpt-4o',
|
|
283
|
+
scopes: ['read:invoices', 'write:payments'],
|
|
284
|
+
metadata: { team: 'finance', environment: 'prod' },
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
// Store credentials securely
|
|
288
|
+
const credId = await nb.credentials.store({
|
|
289
|
+
agentId: agent.id,
|
|
290
|
+
name: 'stripe-api-key',
|
|
291
|
+
value: process.env.STRIPE_SECRET_KEY,
|
|
292
|
+
type: 'api_key',
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
// Monitor behavior
|
|
296
|
+
nb.anomaly.onAlert(alert => {
|
|
297
|
+
console.error(`[NullBridge] Anomaly: ${alert.metric} — z=${alert.zScore}`);
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
// Log every action
|
|
301
|
+
async function processInvoice(invoiceId) {
|
|
302
|
+
if (!agent.hasScope('write:payments')) {
|
|
303
|
+
await nb.audit.logViolation(agent.id, agent.name, 'process_payment', 'scope_denied');
|
|
304
|
+
throw new Error('Unauthorized');
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// ... your agent logic ...
|
|
308
|
+
|
|
309
|
+
await agent.logAction('process_invoice', { invoiceId, outcome: 'success' });
|
|
310
|
+
nb.anomaly.record(agent.id, 'invoices_per_hour', 1);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// Graceful shutdown
|
|
314
|
+
process.on('SIGTERM', async () => {
|
|
315
|
+
await nb.shutdown();
|
|
316
|
+
process.exit(0);
|
|
317
|
+
});
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
---
|
|
321
|
+
|
|
322
|
+
## Dashboard
|
|
323
|
+
|
|
324
|
+
All agent activity flows into your NullBridge dashboard at [app.nullbridge.ai](https://app.nullbridge.ai):
|
|
325
|
+
|
|
326
|
+
- **Agent Registry** — all registered agents, their status, tier, and risk score
|
|
327
|
+
- **Audit Trail** — every action logged with full context
|
|
328
|
+
- **SIEM Events** — policy violations, anomalies, and credential events
|
|
329
|
+
- **Anomaly Detection** — behavioral baselines and z-score alerts
|
|
330
|
+
|
|
331
|
+
---
|
|
332
|
+
|
|
333
|
+
## Support
|
|
334
|
+
|
|
335
|
+
- Email: [brian@nullbridge.ai](mailto:brian@nullbridge.ai)
|
|
336
|
+
- Website: [nullbridge.ai](https://nullbridge.ai)
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
220
340
|
## License
|
|
221
341
|
|
|
222
342
|
This software is proprietary and confidential. Use requires a valid NullBridge license key.
|
|
223
|
-
Contact brian@nullbridge.ai for licensing.
|
|
224
343
|
|
|
225
344
|
**NullBridge Technologies**
|
|
226
|
-
brian@nullbridge.ai | nullbridge.ai
|
|
227
345
|
|
|
228
346
|
---
|
|
229
347
|
|
|
230
|
-
CONFIDENTIALITY & IP NOTICE: This software and documentation contain proprietary and confidential
|
|
231
|
-
information belonging to NullBridge Technologies. Protected under applicable intellectual property
|
|
232
|
-
laws. Unauthorized use, disclosure, or distribution is strictly prohibited.
|
|
348
|
+
*CONFIDENTIALITY & IP NOTICE: This software and documentation contain proprietary and confidential information belonging to NullBridge Technologies. Protected under applicable intellectual property laws. Unauthorized use, disclosure, or distribution is strictly prohibited.*
|