ABS Core v3.5.0

ABSClient SDK

Node.js/TypeScript Integration for ABS Core.

ABSClient SDK

The ABS Core SDK (@abscore/sdk) provides a seamless way to integrate ABS Core governance into your Node.js and TypeScript applications. It handles event processing, policy enforcement, and Decision Envelopes with built-in audit trails.

Installation

Install via npm:

npm install @abscore/sdk

Usage

1. Initialization

Initialize the SDK with your API key and configuration.

import { ABSClient } from "@abscore/sdk";

// Initialize the client
const abs = new ABSClient({
  endpoint: "https://api.abscore.app",
  apiKey: process.env.ABS_PAT!,
  tenantId: "my-tenant",
  agentId: "agent-007",
});

async function main() {
  // Process an event to generate a decision and audit trail
  console.log("Processing event through ABS Governance...");
  const result = await abs.process({
    event_id: crypto.randomUUID(),
    tenant_id: "my-tenant",
    event_type: "agent.action",
    source: "agent-007",
    occurred_at: new Date().toISOString(),
    payload: {
      action: "transfer_funds",
      amount: 500,
      recipient: "Alice"
    }
  });

  console.log("Decision Verdict:", result.envelope.verdict); // ALLOW | DENY | HOLD
}

main().catch(console.error);

2. Synchronous Governance (Blocking)

Use sync: true to block execution until the kernel returns a final decision. This is required for high-risk operations.

import { ABSClient } from "@abscore/sdk";

const abs = new ABSClient({
  endpoint: "https://api.abscore.app",
  apiKey: process.env.ABS_PAT!,
  tenantId: "admin-ops",
});

async function safeDelete(userId: string) {
  // synchronous evaluation before the operation
  const result = await abs.process({
    event_id:    crypto.randomUUID(),
    tenant_id:   "admin-ops",
    event_type:  "system.delete_user",
    source:      "admin-agent",
    occurred_at: new Date().toISOString(),
    payload:     { userId },
  }, { sync: true });

  if (result.envelope.verdict !== "ALLOW") {
    console.error("Action blocked:", result.envelope.reason_human);
    return;
  }

  // Safe to proceed
  console.log("Action approved. Executing...");
}

3. Read Decision Envelopes

The DecisionEnvelope contains the verdict, risk score, and references to the policy that governed the action.

const result = await abs.process(event, { sync: true });
const envelope = result.envelope;

console.log("Decision ID:",    envelope.decision_id);
console.log("Verdict:",        envelope.verdict);      // ALLOW | DENIED | HOLD
console.log("Risk Score:",     envelope.risk_score);   // 0 to 100
console.log("Reason Human:",   envelope.reason_human); // Explanatory text
console.log("Policy Ref:",     envelope.policy_ref);   // Matched policy version

4. Heartbeat (Liveness)

Confirm agent health to the control plane.

// Heartbeat is managed via the process() API with heartbeat event types, 
// or by using specialized handlers if implemented in your agent wrapper.
await abs.process({
  event_type: "agent.heartbeat",
  payload: { status: "healthy" }
});

Configuration Options

OptionTypeDefaultDescription
endpointstring-URL of the ABS API (e.g., https://api.abscore.app)
apiKeystring-Your ABS Personal Access Token (PAT)
tenantIdstring-Your Workspace/Tenant ID
agentIdstring-(Optional) Default ID for this agent instance

Next steps: Configure your own dynamic policies in the Policy Engine, or return to the Quickstart.

On this page