@blacklake-systems/sdk
TypeScript SDK for BlackLake Surface — agent governance infrastructure.
Install
npm install @blacklake-systems/sdk
Quick Start
import { BlackLake } from '@blacklake-systems/sdk';
const bl = new BlackLake({
apiKey: process.env.BLACKLAKE_API_KEY!,
});
const result = await bl.govern({
agent: 'expense-bot',
tool: 'payments.send',
action: { amount: 4200, vendor: 'Acme Corp' },
});
if (result.decision === 'allow') {
}
Sign up at console.blacklake.systems to get your API key. The console also provides a dashboard for managing agents, tools, policies, and reviewing the audit trail.
API Reference
new BlackLake(config)
apiKey | string | — | Your BlackLake API key (required) |
baseUrl | string | https://api.blacklake.systems | API base URL. Override only for local development (e.g. http://localhost:3100). |
bl.govern(request)
Evaluate whether an agent is allowed to invoke a tool.
const result = await bl.govern({
agent: 'expense-bot',
tool: 'payments.send',
action: { amount: 4200 },
context: { ip: '10.0.0.1' }
});
bl.agents
await bl.agents.create({ name, environment, risk_classification, description?, approval_mode? });
await bl.agents.list({ environment?, status? });
await bl.agents.get(id);
await bl.agents.update(id, { name?, description?, environment?, risk_classification?, status?, approval_mode? });
await bl.agents.suspend(id);
await bl.agents.activate(id);
await bl.agents.bindTool(agentId, toolId);
await bl.agents.listTools(agentId);
await bl.agents.unbindTool(agentId, toolId);
bl.tools
await bl.tools.create({ name, risk_classification, description? });
await bl.tools.list();
await bl.tools.get(id);
bl.policies
await bl.policies.create({ name, priority, outcome, agent_selector?, tool_selector?, enabled? });
await bl.policies.list();
await bl.policies.get(id);
await bl.policies.update(id, { name?, priority?, outcome?, agent_selector?, tool_selector?, enabled? });
await bl.policies.delete(id);
bl.evaluations
await bl.evaluations.list({ agent_id?, tool_id?, outcome?, limit?, offset? });
await bl.evaluations.get(id);
bl.organisation
await bl.organisation.get();
await bl.organisation.delete(confirmation);
bl.apiKeys
await bl.apiKeys.list();
await bl.apiKeys.create('prod-key');
await bl.apiKeys.revoke(id);
bl.approvals
await bl.approvals.list({ status?, agent_id?, tool_id?, limit?, offset? });
await bl.approvals.get(id);
await bl.approvals.status(id);
await bl.approvals.approve(id, { decided_by, reason });
await bl.approvals.reject(id, { decided_by, reason });
await bl.approvals.wait(id, { interval?, timeout? });
wait() defaults to polling every 2 000 ms with a 5-minute total timeout. Returns the fully-populated Approval once the status leaves 'pending'.
bl.webhooks
await bl.webhooks.list();
await bl.webhooks.create({ url, events, enabled? });
await bl.webhooks.get(id);
await bl.webhooks.update(id, { url?, events?, enabled? });
await bl.webhooks.delete(id);
await bl.webhooks.listDeliveries(id, { limit?, offset? });
Webhooks fire on 'approval.created', 'approval.approved', and 'approval.rejected'. Each request is signed with HMAC-SHA256; the signature is sent in the X-BlackLake-Signature header.
Error Handling
import { BlackLake, BlackLakeError } from '@blacklake-systems/sdk';
try {
await bl.govern({ agent: 'unknown', tool: 'unknown' });
} catch (err) {
if (err instanceof BlackLakeError) {
console.error(err.status, err.code, err.message);
}
}
Documentation
Full documentation at blacklake.systems/docs.