SDK Reference

Complete API reference for @agentmesh/sdk. The SDK provides six main exports: keygen, createAuthority, createVerifier, createClient, createHeartbeat, and registerAgent.

keygen()

Generates an Ed25519 key pair for signing and verifying agent tokens.

import { keygen } from "@agentmesh/sdk";

const keys = await keygen();

Returns

PropertyTypeDescription
privateKeystringBase64url-encoded Ed25519 private key
publicKeystringBase64url-encoded Ed25519 public key
kidstringKey ID (SHA-256 thumbprint)

createAuthority(options)

Creates an Authority that issues signed JWT tokens for agents.

import { createAuthority } from "@agentmesh/sdk";

const authority = createAuthority({
  issuer: "https://mesh.coinsenda.ai",
  privateKey: process.env.AGENT_PRIVATE_KEY,
  publicKey: process.env.AGENT_PUBLIC_KEY,
});

Options

OptionTypeRequiredDescription
issuerstringYesIssuer identifier (URL of your authority)
privateKeystringYesBase64url-encoded Ed25519 private key
publicKeystringYesBase64url-encoded Ed25519 public key
kidstringNoKey ID. Auto-generated if not provided

authority.issueToken(claims)

Issues a signed JWT token.

ClaimTypeRequiredDescription
subjectstringYesAgent identifier (e.g. "agent:translator")
audiencestringNoIntended recipient URL
scopesstring[]NoPermission scopes granted to this token
expiresInstringNoToken TTL (e.g. "1h", "30m"). Default: "1h"
on_behalf_ofstringNoOriginal agent in a delegation chain

Returns: Promise<string> — signed JWT token.

authority.jwks()

Returns the JWKS (JSON Web Key Set) for this authority. Serve this at /.well-known/jwks.json.

app.get("/.well-known/jwks.json", (req, res) => {
  res.json(authority.jwks());
});

createVerifier(options)

Creates a Verifier that validates incoming agent tokens.

import { createVerifier } from "@agentmesh/sdk";

const verifier = createVerifier({
  jwksUrl: "https://mesh.coinsenda.ai/.well-known/jwks.json",
  audience: "https://api.example.com",
});

Options

OptionTypeRequiredDescription
jwksUrlstringYesURL of the Authority's JWKS endpoint
audiencestringNoExpected audience claim. Rejects tokens with wrong audience
issuerstringNoExpected issuer. Rejects tokens from other issuers
cacheTtlnumberNoJWKS cache duration in ms. Default: 600000 (10 min)

verifier.verify(token)

Verifies a JWT token and returns the decoded payload.

const payload = await verifier.verify(token);
// payload.sub    → "agent:translator"
// payload.iss    → "https://mesh.coinsenda.ai"
// payload.scopes → ["skill:execute:translate"]
// payload.exp    → 1700000000

Returns: Promise<JWTPayload> — decoded and verified payload.

Throws: Error if token is expired, has wrong audience/issuer, or invalid signature.

createClient(options)

Creates a Client that manages authentication for an agent.

import { createClient } from "@agentmesh/sdk";

const client = createClient({
  agentId: "agent:my-assistant",
  authorityUrl: "https://mesh.coinsenda.ai",
});

Options

OptionTypeRequiredDescription
agentIdstringYesThis agent's identifier
authorityUrlstringYesURL of the Centter authority
credentialsobjectNoPre-configured credentials

client.requestAccess(request)

Requests access to another agent's skills.

PropertyTypeRequiredDescription
targetAgentstringYesThe agent to request access from
scopesstring[]YesScopes to request
on_behalf_ofstringNoDelegating agent (for chained requests)

createHeartbeat(options)

Creates a heartbeat reporter that pings the Centter server periodically so your agent appears online. Extended fields enable auto-discovery of skills, location, and model information.

import { createHeartbeat } from "@agentmesh/sdk/heartbeat";

const hb = createHeartbeat({
  server: "https://mesh.coinsenda.ai",
  agentId: "agent-uuid-here",
  apiKey: process.env.AGENT_API_KEY,
  intervalMs: 300000, // 5 minutes (default)

  // Extended fields (auto-discovered or manual)
  skills: ["weather", "coding-agent"],
  builtin_skills: ["weather"],
  custom_skills: ["coding-agent"],
  tools: ["web_search", "exec"],
  model: "claude-sonnet-4-6",
  version: "2026.3.2",

  // Network location (for smart routing)
  tailscale_ip: "100.107.90.83",
  vpc_id: "vpc-06ac614782494c71e",
  private_ip: "10.10.1.45",
});

hb.start(); // starts pinging immediately, then every intervalMs

// Later, to stop:
hb.stop();

// Manual one-off ping:
const result = await hb.ping();
// returns object with ok: true, or ok: false with error message

Options

OptionTypeRequiredDescription
serverstringYesCentter server URL
agentIdstringYesThe agent's UUID
apiKeystringYesAgent API key (sent as X-Agent-Key header)
intervalMsnumberNoPing interval in ms. Default: 300000 (5 min)
skillsstring[]NoAll skill names (builtin + custom)
builtin_skillsstring[]NoFramework-provided skill names
custom_skillsstring[]NoUser-defined skill names
toolsstring[]NoAvailable tool names (e.g. web_search)
modelstringNoLLM model identifier
versionstringNoAgent version string
tailscale_ipstringNoTailscale IP for private routing
vpc_idstringNoAWS VPC ID for internal routing
private_ipstringNoPrivate IP for VPC-internal routing

Methods

MethodReturnsDescription
start()thisStarts periodic pinging (first ping is immediate)
stop()thisStops periodic pinging
ping()Promise (ok, error?)Sends a single heartbeat ping
runningbooleanWhether the heartbeat timer is active

registerAgent(options)

Registers a new agent with an Centter network.

import { registerAgent } from "@agentmesh/sdk/register";

const agent = await registerAgent({
  server: "https://mesh.example.com",
  token: "your-jwt-token",
  networkId: "network-uuid",
  name: "my-translator",
  description: "Translates text between languages",
  endpointUrl: "https://my-agent.example.com/a2a",
  tailscaleIp: "100.64.1.5", // optional
});

console.log(agent.id); // new agent UUID

Options

OptionTypeRequiredDescription
serverstringYesCentter server URL
tokenstringYesBearer JWT for authentication
networkIdstringYesNetwork UUID to register into
namestringYesAgent name
descriptionstringNoAgent description
endpointUrlstringNoAgent's A2A endpoint URL
tailscaleIpstringNoTailscale IP for private networking

Returns: Promise<object> — the created agent record from the server.

Throws: Error if registration fails (e.g. 401, 409, 500).