ReferenceReferenceSDKs

SDKs

Three clients. TypeScript is the full one; Python and Go are thin and dependency-free, so they drop into a constrained environment without a resolver argument.

Install

bash
npm install @memnox/sdk

Connect

ts
import { MemnoxClient } from '@memnox/sdk';
 
const memnox = new MemnoxClient({
  baseUrl: 'http://127.0.0.1:7466',
  token: process.env.MEMNOX_AGENT_TOKEN,
});

check, inspect the verdict

ts
const decision = await memnox.check({
  action: 'deploy.service',
  target: 'checkout-api',
  environment: 'production',
  sessionId: runId,
});
 
if (decision.effect === 'allow') await deploy();

guard, run only if allowed

ts
await memnox.guard(
  { action: 'code.modify', target: 'payment/checkout.ts' },
  async () => { await applyChanges(); },
);

The callback runs only if the runtime allows it. This is the shape to reach for by default, it makes "we forgot to check" impossible rather than unlikely.

guardVerified, prove it worked

ts
const outcome = await memnox.guardVerified(
  { action: 'code.modify', target: 'src/payment/checkout.ts' },
  {
    preconditions: [{ description: 'branch is clean', check: () => isClean() }],
    execute: () => applyPatch(),
    postconditions: [{ description: 'tests pass', check: () => runTests() }],
    rollback: { description: 'revert commit', execute: () => revert() },
  },
);

outcome.status is succeeded · precondition_failed · execution_failed · postcondition_failed. See Verified execution.

governTools, wrap a whole registry

ts
import { governTools } from '@memnox/sdk';
 
const tools = governTools(memnox, { readFile, writeFile, runShell }, {
  sessionId: runId,
  environment: 'production',
});

Same signatures, same framework wiring. OpenAI Agents SDK, LangGraph, CrewAI, or a loop of your own. governTool wraps a single function.

context, the briefing

ts
const brief = await memnox.context({
  action: 'file.write',
  target: 'src/auth/session.ts',
});

Records nothing, raises no approval.

Predicates

ts
import { RuntimeApi } from '@memnox/sdk';
 
const api = new RuntimeApi(memnox);
if (await api.canDeploy({ environment: 'production' })) await deploy();

Also available

memnox.approvals, memnox.audit, memnox.memory, memnox.reports.

Things every client does

Strips arguments. Raw tool-call payloads are matched in-process by @memnox/local-gate and never sent. Do not add them back by hand.

Carries the session. Pass sessionId consistently across an agent run, taint attaches to the session, so a run split across several ids loses the connection between reading untrusted content and acting on it.

Retries into a grant. When check returns require_approval, poll GET /v1/approvals/:id and then retry the same action. The grant is claimed by fingerprint; there is no id to pass back.

Where the token comes from

MEMNOX_AGENT_TOKEN when set, otherwise ~/.memnox/config.json (mode 0600). The environment wins, which is how CI passes one.

The other client

@memnox/organization is a separate package, because it asks a separate question. These clients ask the runtime whether an action breaks a rule. That one asks the organization whether it should happen: who owns it, what was already decided, who authorizes it at this size, and how much of the evidence this agent is entitled to see.

bash
npm install @memnox/organization

Apache-2.0, no dependency on the runtime client, and usable on its own. Most agents end up with both: the runtime gate on the machine, and one evaluate call before the work starts.

The Python client is in the same distribution rather than a second one, because pip install twice to govern one agent is a step people skip.