Aribot JavaScript and TypeScript SDK
The official client for the Aribot API by Ayurak. Use it to:
npm i @ayurak/sdk- get security gate decisions for builds, pull requests and the IDE
- ask the agent decision API whether an AI agent may call a tool (AI agent governance)
- run threat modeling, code review, pipeline security, compliance and SBOM work from your own code
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
npm install @ayurak/sdkSign 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:
- the
apiKeyoption - the
ARIBOT_API_KEYenvironment variable (meant for CI pipelines) - the
ARIBOT_TOKENenvironment 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.
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:
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.
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.
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
| Property | API |
|---|---|
gates | Security gate decisions, rules, versions, gate runs |
agents | Agent decision API |
connector | Connector API: code review uploads, threat models from nodes and edges, scans, insights |
developer | API usage, rate limits, API keys |
codeReview | Repositories, code review scans, traceability, threat verification, AI fixes |
pipeline | Pipeline projects, scans, results, vulnerabilities, gate results |
threatModeling | Diagrams, threats, components, AI analysis, exports |
compliance | Standards, controls, diagram compliance scans, framework reports |
remediation | Remediation plans |
cloud | Cloud accounts, findings, scans |
sbom | SBOM documents, generation, vulnerability checks |
reports | Threat model reports |
redTeam, digitalTwin, economics, maestro, multiAgent, ml | Threat modeling analysis |
marketplace, dashboard | Templates 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).
| Class | When |
|---|---|
ValidationError | 400 or 422 |
AuthenticationError | 401: the credential is missing, expired or revoked |
LicenseRequiredError | 402: the feature needs a licence; payload says which |
PermissionDeniedError | 403 |
NotFoundError | 404 |
ConflictError | 409 |
RateLimitError | 429; retryAfter holds the seconds from Retry-After |
ServerError | 5xx |
TimeoutError | no response within the timeout (60 seconds by default) |
NetworkError | no HTTP response at all |
ConfigError | a bad baseUrl, a credential with whitespace, or an agent call with no agentKey |
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
- HTTPS only. The base URL must use https. Plain http is accepted for
localhost,127.0.0.1and::1alone, for local development. A base URL with credentials, a query or a path is refused. - Redirects are never followed. A 3xx response is an error, so the credential is never sent to another host.
- The credential stays out of output. It never appears in error messages,
toString(),JSON.stringify()orutil.inspect()of the client. - Safe retries. Only GET and HEAD are retried, on 429, 502, 503, 504 and network errors, at most 3 attempts, honouring
Retry-Afterup to 30 seconds. POST, PUT, PATCH and DELETE run once. To make a write retryable, pass anidempotencyKey; it is sent asIdempotency-Key. The connector uses it so a retried request is charged once. Other endpoints may ignore the header, and there a retried write can run twice. - Browsers. An API key in a web page is visible to anyone who loads the page. In a browser, use a short-lived JWT for the signed-in user, or call Aribot from your server.
- Agent keys are sent only by
agentscalls, asAuthorization: Bearer.
Requirements
- Node.js 18 or later, or a browser with
fetch,AbortControllerandFormData. - Other runtimes: pass
fetchin the options.
Upgrading from 2.x
See CHANGELOG.md for every removed and renamed method.
Licence
Proprietary. Copyright Ayurak. All rights reserved.