AribotDevelopers Sign in

Aribot JavaScript and TypeScript SDK

The official client for the Aribot API by Ayurak. Use it to:

npm i @ayurak/sdk

It works in Node.js 18 and later and in browsers. It ships ESM, CommonJS and TypeScript types, and has no runtime dependencies.

Documentation: https://aribot.ayurak.com/developers/sdk/javascript/

Install

sh
npm install @ayurak/sdk

Sign in

Create an API key in Aribot under Company Admin > Developer & API. Keep it in a secret store or an environment variable, and keep it out of source code.

The client looks for a credential in this order:

  1. the apiKey option
  2. the ARIBOT_API_KEY environment variable (meant for CI pipelines)
  3. the ARIBOT_TOKEN environment variable

An API key is sent in the X-API-Key header. A JWT access token (a value with exactly two dots) is sent as Authorization: Bearer.

ts
import { Aribot } from '@ayurak/sdk';

const aribot = new Aribot();                       // reads ARIBOT_API_KEY, then ARIBOT_TOKEN
const other = new Aribot({ apiKey: process.env.MY_ARIBOT_KEY });

The default host is https://aribot.ayurak.com. For a dedicated deployment, pass its host:

ts
const aribot = new Aribot({ baseUrl: 'https://aribot.example.com' });

Example: a security gate decision

Send the changed file paths and line ranges. The server decides from your company's signed gate rules. File contents are never sent.

ts
import { Aribot } from '@ayurak/sdk';

const aribot = new Aribot();

const decision = await aribot.gates.decide({
  gateConfigId: 12,
  gate: 'pull_request',
  headSha: process.env.GITHUB_SHA!,
  files: [{ path: 'api/payments.py', changed_lines: [[40, 72]] }],
});

console.log(decision.outcome, decision.reasons);
for (const finding of decision.findings ?? []) {
  const fix = await aribot.gates.fix(finding.fix_ref);
  console.log(finding.threat_name, finding.component_name, fix);
}

Other gate calls: gates.listRuns, gates.feedbackFile, gates.listConfigs, gates.listRules, gates.importRules, gates.validateVersion, gates.dryRunVersion and gates.postRunnerResults.

Example: the agent decision API

Before an AI agent calls a tool, ask Aribot. The call authenticates with the agent's own key (it starts with agk_), passed as agentKey.

ts
import { Aribot } from '@ayurak/sdk';

const aribot = new Aribot({ agentKey: process.env.ARIBOT_AGENT_KEY });

async function guardedCall(tool: string, resource: string, args: unknown, run: () => Promise<unknown>) {
  let decision;
  try {
    decision = await aribot.agents.decide({ tool, resource, args });
  } catch {
    throw new Error(`${tool}: no decision, so the call is blocked`); // fail closed
  }
  if (!decision.allowed) {
    throw new Error(`${tool} blocked: ${decision.reason}`);
  }
  return run();
}

await guardedCall('crm.read_contact', 'contact/42', { id: 42 }, () => readContact(42));

The server stores a hash of args. When the call is allowed and permits are on, the response carries a signed permit that the tool can check before it acts.

What else is in the client

PropertyAPI
gatesSecurity gate decisions, rules, versions, gate runs
agentsAgent decision API
connectorConnector API: code review uploads, threat models from nodes and edges, scans, insights
developerAPI usage, rate limits, API keys
codeReviewRepositories, code review scans, traceability, threat verification, AI fixes
pipelinePipeline projects, scans, results, vulnerabilities, gate results
threatModelingDiagrams, threats, components, AI analysis, exports
complianceStandards, controls, diagram compliance scans, framework reports
remediationRemediation plans
cloudCloud accounts, findings, scans
sbomSBOM documents, generation, vulnerability checks
reportsThreat model reports
redTeam, digitalTwin, economics, maestro, multiAgent, mlThreat modeling analysis
marketplace, dashboardTemplates and security posture

Every method takes an optional last argument { signal, timeoutMs, idempotencyKey }. Responses are the server's JSON. List calls return either an array or a page {count, next, previous, results}; results(page) gives the items of either.

For a route this SDK does not wrap, use aribot.http.get('/v2/...'). Paths are relative to /aribot-api.

Errors

Every API error extends AribotError, which has status, code and payload (the parsed response body).

ClassWhen
ValidationError400 or 422
AuthenticationError401: the credential is missing, expired or revoked
LicenseRequiredError402: the feature needs a licence; payload says which
PermissionDeniedError403
NotFoundError404
ConflictError409
RateLimitError429; retryAfter holds the seconds from Retry-After
ServerError5xx
TimeoutErrorno response within the timeout (60 seconds by default)
NetworkErrorno HTTP response at all
ConfigErrora bad baseUrl, a credential with whitespace, or an agent call with no agentKey
ts
import { LicenseRequiredError, RateLimitError } from '@ayurak/sdk';

try {
  await aribot.codeReview.startScan(scanId);
} catch (err) {
  if (err instanceof LicenseRequiredError) console.error('Ask your company admin to enable', err.payload);
  else if (err instanceof RateLimitError) console.error('Try again in', err.retryAfter, 'seconds');
  else throw err;
}

Security notes

Requirements

Upgrading from 2.x

See CHANGELOG.md for every removed and renamed method.

Licence

Proprietary. Copyright Ayurak. All rights reserved.