Full reference for @agentlog/sdk. TypeScript-first, ESM + CJS compatible.
npm install @agentlog/sdk ยท Requires Node.js 18+ or any modern browser runtime.npm install @agentlog/sdk
import { AgentLog } from '@agentlog/sdk'; const log = new AgentLog({ apiKey: 'al_live_...', // required orgId: 'org_...', // optional, read from API key if omitted endpoint: 'https://...', // optional, override ingest endpoint debug: false, // optional, log to console });
Logs a single agent event. Returns a Promise that resolves when the event is accepted.
{
agentId: string; // unique agent identifier
platform: string; 'zapier' | 'n8n' | 'make' | 'claude' | 'openai' | string
actionType: string; 'bulk_update' | 'data_export' | 'send_email' | string
dataCategory?: string; 'crm_contacts' | 'pii' | 'financial' | string
recordCount?: number; // number of records affected
outcome: 'success' | 'failed' | 'blocked';
metadata?: Record<string, unknown>; // custom fields, NOT logged as PII
timestamp?: Date; // defaults to now
}Log multiple events in a single request. Useful for high-throughput agents.
await log.batch([ { agentId: 'agent-1', platform: 'n8n', actionType: 'record_read', outcome: 'success' }, { agentId: 'agent-1', platform: 'n8n', actionType: 'send_email', outcome: 'success' }, ]);
Wrap any async function so AgentLog automatically tracks success and failure.
const result = await log.wrap( () => hubspot.updateContacts(contacts), { agentId: 'crm-sync', platform: 'hubspot', actionType: 'bulk_update', dataCategory: 'crm_contacts', recordCount: contacts.length, } );
The SDK never throws on network errors โ failed tracking calls are silently dropped so your agent is never blocked. Set debug: true to see errors in the console.
| Variable | Description |
|---|---|
AGENTLOG_API_KEY | Your API key. Read automatically if set. |
AGENTLOG_ORG_ID | Override org ID. Optional. |
AGENTLOG_DEBUG | Set to 1 to enable debug logging. |