blockintel-gate-sdk 0.4.0 → 0.4.1
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 +17 -30
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/pilot/index.cjs +1 -1
- package/dist/pilot/index.cjs.map +1 -1
- package/dist/pilot/index.js +1 -1
- package/dist/pilot/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -408,27 +408,11 @@ The SDK includes a **Heartbeat Manager** that automatically acquires and refresh
|
|
|
408
408
|
|
|
409
409
|
### How It Works
|
|
410
410
|
|
|
411
|
-
1. **
|
|
412
|
-
2. **
|
|
413
|
-
3. **
|
|
414
|
-
4. **
|
|
415
|
-
5. **
|
|
416
|
-
6. **Local Rate Limiting**: Per-signer guard prevents re-requesting within `localRateLimitMs` (default: 2.1s) to avoid hammering the Control Plane.
|
|
417
|
-
7. **Token Inclusion**: The heartbeat token is automatically included in the `signingContext` of every evaluation request.
|
|
418
|
-
|
|
419
|
-
### Multi-Signer Support
|
|
420
|
-
|
|
421
|
-
Trading desks running 3+ bot profiles no longer experience `HEARTBEAT_MISSING` errors when switching signers. Each signer's token is cached independently:
|
|
422
|
-
|
|
423
|
-
```typescript
|
|
424
|
-
// KMS wrapper automatically uses the correct signer from KeyId
|
|
425
|
-
const protectedKms = gate.wrapKmsClient(kmsClient);
|
|
426
|
-
|
|
427
|
-
// These calls use independent heartbeat tokens — no cross-invalidation
|
|
428
|
-
await protectedKms.sign({ KeyId: 'alias/bot-1', Message: tx1, ... });
|
|
429
|
-
await protectedKms.sign({ KeyId: 'alias/bot-2', Message: tx2, ... });
|
|
430
|
-
await protectedKms.sign({ KeyId: 'alias/bot-1', Message: tx3, ... }); // cache hit
|
|
431
|
-
```
|
|
411
|
+
1. **Automatic Token Acquisition**: The SDK automatically starts a background heartbeat refresher when the `GateClient` is initialized. This continuously sends heartbeats to the Control Plane, keeping the signer status active in the UI.
|
|
412
|
+
2. **Token Refresh**: Heartbeat tokens are refreshed every 10 seconds (configurable via `heartbeatRefreshIntervalSeconds`) to maintain a valid token
|
|
413
|
+
3. **Signing Enforcement**: Before any `evaluate()` call, the SDK checks for a valid heartbeat token. If missing or expired, it throws `HEARTBEAT_MISSING` error
|
|
414
|
+
4. **Token Inclusion**: The heartbeat token is automatically included in the `signingContext` of every evaluation request
|
|
415
|
+
5. **No Manual Scripts Needed**: The SDK handles all heartbeat management automatically - no need for separate heartbeat scripts
|
|
432
416
|
|
|
433
417
|
### Configuration
|
|
434
418
|
|
|
@@ -442,11 +426,8 @@ const gate = new GateClient({
|
|
|
442
426
|
// Heartbeat manager uses baseUrl to infer Control Plane URL
|
|
443
427
|
// Or explicitly set controlPlaneUrl if different
|
|
444
428
|
controlPlaneUrl: 'https://control-plane.blockintelai.com', // Optional
|
|
445
|
-
signerId: 'my-signer-id', // Optional:
|
|
429
|
+
signerId: 'my-signer-id', // Optional: signerId for heartbeat (if known upfront)
|
|
446
430
|
heartbeatRefreshIntervalSeconds: 10, // Optional: heartbeat refresh interval (default: 10s)
|
|
447
|
-
maxSigners: 20, // Optional: max concurrent signer entries (default: 20)
|
|
448
|
-
signerIdleTtlMs: 300000, // Optional: evict idle signers after this many ms (default: 5 min)
|
|
449
|
-
localRateLimitMs: 2100, // Optional: min ms between acquire attempts per signer (default: 2.1s)
|
|
450
431
|
});
|
|
451
432
|
```
|
|
452
433
|
|
|
@@ -477,17 +458,23 @@ try {
|
|
|
477
458
|
|
|
478
459
|
### Heartbeat Manager API
|
|
479
460
|
|
|
480
|
-
The
|
|
461
|
+
The heartbeat manager is internal to the SDK, but you can access it if needed:
|
|
481
462
|
|
|
482
463
|
```typescript
|
|
483
|
-
//
|
|
484
|
-
const
|
|
464
|
+
// Check if heartbeat is valid
|
|
465
|
+
const isValid = gate.heartbeatManager.isValid();
|
|
466
|
+
|
|
467
|
+
// Get current heartbeat token (if valid)
|
|
468
|
+
const token = gate.heartbeatManager.getToken();
|
|
469
|
+
|
|
470
|
+
// Update signer ID (called automatically when signer is known)
|
|
471
|
+
gate.heartbeatManager.updateSignerId('new-signer-id');
|
|
485
472
|
|
|
486
|
-
// Stop heartbeat
|
|
473
|
+
// Stop heartbeat refresher (e.g., on shutdown)
|
|
487
474
|
gate.heartbeatManager.stop();
|
|
488
475
|
```
|
|
489
476
|
|
|
490
|
-
**Note**: The
|
|
477
|
+
**Note**: The heartbeat manager automatically updates the `signerId` when using the KMS wrapper, so manual updates are typically not needed.
|
|
491
478
|
|
|
492
479
|
## Secret Rotation
|
|
493
480
|
|
package/dist/index.cjs
CHANGED
|
@@ -1315,7 +1315,7 @@ var HeartbeatManager = class {
|
|
|
1315
1315
|
this.started = true;
|
|
1316
1316
|
this.startEvictionTimer();
|
|
1317
1317
|
this.getTokenForSigner(this.defaultSignerId, 0).catch((error) => {
|
|
1318
|
-
console.
|
|
1318
|
+
console.warn("[HEARTBEAT] Failed to acquire initial heartbeat:", error instanceof Error ? error.message : error);
|
|
1319
1319
|
});
|
|
1320
1320
|
}
|
|
1321
1321
|
startEvictionTimer() {
|