SDK Node

HTTP server that exposes the full consensus-tools protocol as a REST API.

Overview

@consensus-tools/sdk-node is an HTTP server that exposes the entire consensus-tools protocol as REST endpoints. It covers jobs, ledger, guards, agents, workflows, cron scheduling, webhooks (GitHub, Linear, Slack, Teams, Discord, Telegram), and credential management. Use it when you need to run a consensus-tools backend accessible over HTTP.

Installation

pnpm add @consensus-tools/sdk-node

Quick start

import { ConsensusToolsServer } from "@consensus-tools/sdk-node";
import { JobEngine, LedgerEngine, createStorage } from "@consensus-tools/core";

const storage = await createStorage(config);
const ledger = new LedgerEngine(storage, config);
const engine = new JobEngine(storage, ledger, config);

const server = new ConsensusToolsServer({
  config,
  engine,
  ledger,
  storage,
});

await server.start();
// Consensus API running on host:port from config

Full setup with workflows and webhooks

Wire in all optional engines to enable the complete feature set:

import { ConsensusToolsServer } from "@consensus-tools/sdk-node";
import { WorkflowRunner, CronScheduler } from "@consensus-tools/workflows";
import {
  JobEngine, LedgerEngine, AgentRegistry,
  GuardEngine, HitlTracker, createStorage
} from "@consensus-tools/core";

const storage = await createStorage(config);
const ledger = new LedgerEngine(storage, config);
const engine = new JobEngine(storage, ledger, config);
const workflowRunner = new WorkflowRunner(storage);
const cronScheduler = new CronScheduler(storage, (wfId) => workflowRunner.run(wfId));

const server = new ConsensusToolsServer({
  config,
  engine,
  ledger,
  storage,
  agentRegistry: new AgentRegistry(storage),
  guardEngine: new GuardEngine({ storage }),
  hitlTracker: new HitlTracker({ storage }),
  workflowRunner,
  cronScheduler,
});

await server.start();

API reference

ConsensusToolsServer

The main export. Construct with a ServerDeps object, then call .start() to listen and .stop() to shut down.

ServerDeps

PropertyRequiredDescription
configYesConsensusToolsConfig
engineYesJobEngine
ledgerYesLedgerEngine
storageYesIStorage
agentRegistryNoAgentRegistry for agent management
guardEngineNoGuardEngine for action evaluation
hitlTrackerNoHitlTracker for human approval flows
workflowRunnerNoWorkflowRunner for workflow execution
cronSchedulerNoCronScheduler for scheduled workflows
credentialManagerNoCredentialManager for secrets
loggerNoLogger with info and warn methods

REST endpoints

AreaExample Endpoints
JobsPOST /api/jobs, GET /api/jobs, POST /api/jobs/:id/claim, POST /api/jobs/:id/submit, POST /api/jobs/:id/vote, POST /api/jobs/:id/resolve
LedgerGET /api/ledger/:agentId, POST /api/ledger/faucet
AgentsPOST /api/agents, GET /api/agents, POST /api/agents/:id/suspend
GuardsPOST /api/guard/evaluate
WorkflowsPOST /api/workflows, POST /api/workflows/:id/run, POST /api/workflows/:id/resume
CronPOST /api/cron/register, GET /api/cron
WebhooksPOST /api/webhooks/github, POST /api/webhooks/linear, POST /api/webhooks/slack
TemplatesGET /api/templates

Additional exports

ExportDescription
WorkflowRunnerMinimal workflow runner interface (for type compatibility)
CronSchedulerMinimal cron scheduler interface
WebhookHandlerContextContext passed to webhook handlers
HandlerResultReturn type from webhook handlers
  • SDK Client -- HTTP client that talks to this server
  • Local Board -- Pre-configured local-board app built on sdk-node
  • MCP -- MCP server adapter for LLM agents