Beacon
Programmatic control of the Beacon heartbeat system. Register agents, manage heartbeats, and handle kill switch signals from your application code.
ℹ️See Beacon Architecture for how the system works.
Creating a Beacon
typescript
import { createBeacon } from '@sekuire/sdk';
const beacon = createBeacon({
backendUrl: 'https://api.sekuire.com',
workspaceId: 'ws_abc123',
agentId: '7f8a9b3c...',
installToken: process.env.SEKUIRE_INSTALL_TOKEN,
heartbeatInterval: 30_000, // 30 seconds
onRevoked: (reason) => {
console.log('Agent revoked:', reason);
process.exit(0);
}
});
// Start the beacon loop
await beacon.start();
// ... your agent logic ...
// Stop cleanly on shutdown
await beacon.stop();Platform Detection
The beacon automatically detects the runtime platform and includes metadata in heartbeats:
typescript
import { detectPlatform } from '@sekuire/sdk';
const platform = detectPlatform();
// { type: 'kubernetes', podName: '...', namespace: '...', node: '...' }
// { type: 'docker', containerId: '...', imageName: '...' }
// { type: 'bare_metal', hostname: '...', os: '...', pid: 1234 }Custom Metrics
Report custom metrics alongside heartbeats:
typescript
beacon.reportMetrics({
requests_handled: 1500,
errors: 2,
avg_latency_ms: 145,
custom_metric: 'some_value'
});Next Steps
- Beacon Architecture - How the system works
- Kill Switch - Revocation handling
- sekuire run - CLI beacon wrapper